diff --git a/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs b/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs index a8be890..5b5273d 100644 --- a/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs +++ b/Api/Ewide.Application/Service/HouseProjectInfo/HouseProjectInfoService.cs @@ -98,6 +98,8 @@ namespace Ewide.Application.Service.HouseProjectInfo var areaCodeRep = Db.GetRepository(); var projects = await _houseProjectInfoRep.DetachedEntities .Join(areaCodeRep.DetachedEntities, p => p.AreaCode, a => a.Code, (p, a) => new { p, AreaName = a.Name }) + .Where(!string.IsNullOrEmpty(input.Name), x => x.p.Name.Contains(input.Name)) + .Where(!string.IsNullOrEmpty(input.Note), x => x.p.Note.Contains(input.Note)) .Where(!string.IsNullOrEmpty(input.AreaCode), x => x.p.AreaCode == input.AreaCode) .Where(!string.IsNullOrEmpty(input.pid) , x=> x.p.AreaCode.Contains(input.pid)) .Select(x => new { x.p.Id, x.p.Name, x.p.Note, x.p.Sort, x.p.AreaCode, x.AreaName, x.p.Type }.Adapt()).ToPagedListAsync(input.PageNo, input.PageSize); diff --git a/Web/src/common/api/requests/business/houseProjectInfo.js b/Web/src/common/api/requests/business/houseProjectInfo.js index bad72bd..cdedfaa 100644 --- a/Web/src/common/api/requests/business/houseProjectInfo.js +++ b/Web/src/common/api/requests/business/houseProjectInfo.js @@ -3,5 +3,6 @@ export default { houseProejctAdd: ['/houseProjectInfo/add', 'post'], houseProejctEdit: ['/houseProjectInfo/edit', 'post'], houseProejctDelete: ['/houseProjectInfo/delete', 'post'], - houseProejctDetail:['/houseProjectInfo/detail','get'] + houseProejctDetail: ['/houseProjectInfo/detail', 'get'], + houseProjectNextSort:['/houseProjectInfo/nextSort','get'] } \ No newline at end of file diff --git a/Web/src/pages/business/house/project/form.vue b/Web/src/pages/business/house/project/form.vue index a1c3836..ce880ee 100644 --- a/Web/src/pages/business/house/project/form.vue +++ b/Web/src/pages/business/house/project/form.vue @@ -10,25 +10,27 @@
- - - - - - - - - - - - - +
+ +
- + 住宅 非住宅 + + + + + + + + + + + +
@@ -50,7 +52,7 @@ export default { note: [{ required: true, message: '请输入备注' }], name: [{ required: true, message: '请输入项目名称' }], sort: [{ required: true, message: '请输入排序' }], - areaCode: [{ required: true, message: '请选择所属区域' }], + areaCode: [{ required: true, message: '请选择所属区域,必须选到社区' }], type: [{ required: true, message: '请选择类型' }], }, @@ -58,10 +60,42 @@ export default { loading: false, /** 其他成员属性 */ areaData: [], + intEntity: {}, /* ... */ }; }, - + created() { + // 用于监视复杂表达式的函数 + this.$watch( + // 表达式 `this.a + this.b` 每次得出一个不同的结果时 + // 处理函数都会被调用。 + // 这就像监听一个未被定义的计算属性 + () => [this.form.areaCode, this.form.type], + (newVal, oldVal) => { + // 做点什么 + if (this.form.areaCode.length == 4 && this.form.type) { + if (this.intEntity.id && this.intEntity.type == this.form.type) { + this.$set(this.form, 'sort', this.intEntity.sort); + this.$set(this.form, 'name', this.intEntity.name); + } else { + this.loading = true; + this.$api + .houseProjectNextSort({ areaCode: this.form.areaCode[this.form.areaCode.length - 1], type: this.form.type }) + .then((res) => { + this.$set(this.form, 'sort', res.data); + this.$set(this.form, 'name', '项目' + this.toChinesNum(res.data)); + }) + .finally(() => { + this.loading = false; + }); + } + } else { + this.$set(this.form, 'sort', this.intEntity.sort); + this.$set(this.form, 'name', this.intEntity.name); + } + } + ); + }, methods: { /** * 必要的方法 @@ -102,6 +136,13 @@ export default { areaCode: areaCode.length == 4 ? areaCode : [], /* ... */ }); + this.intEntity = this.$_.cloneDeep({ + ...defaultForm, + ...params.record, + /** 在此处添加其他默认数据转换 */ + areaCode: areaCode.length == 4 ? areaCode : [], + /* ... */ + }); }, /** @@ -167,6 +208,30 @@ export default { displayRender({ labels }) { return labels[labels.length - 1]; }, + toChinesNum(val) { + let num = parseInt(val); + let changeNum = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']; + let unit = ['', '十', '百', '千', '万']; + let getWan = (temp) => { + let strArr = temp.toString().split('').reverse(); + let newNum = ''; + for (var i = 0; i < strArr.length; i++) { + newNum = (i == 0 && strArr[i] == 0 ? '' : i > 0 && strArr[i] == 0 && strArr[i - 1] == 0 ? '' : changeNum[strArr[i]] + (strArr[i] == 0 ? unit[0] : unit[i])) + newNum; + } + return newNum; + }; + let overWan = Math.floor(num / 10000); + let noWan = num % 10000; + if (noWan.toString().length < 4) noWan = '0' + noWan; + + let chinanum = overWan ? getWan(overWan) + '万' + getWan(noWan) : getWan(num); + return chinanum; + }, + formAreaCodeChange(val) { + if (val.length != 4) { + this.form.areaCode = []; + } + }, /* ... */ }, }; diff --git a/Web/src/pages/business/house/project/index.vue b/Web/src/pages/business/house/project/index.vue index c8e8577..bef5afe 100644 --- a/Web/src/pages/business/house/project/index.vue +++ b/Web/src/pages/business/house/project/index.vue @@ -14,6 +14,9 @@ + + +