From 2fe9aa2ac5117b28da11e6180d1457e1b57f1d0e Mon Sep 17 00:00:00 2001 From: awsl <1072050380@qq.com> Date: Tue, 11 Mar 2025 22:42:35 +0800 Subject: [PATCH] update --- .../components/markForm.vue | 180 ++++-- .../identificationPlate/index.vue | 563 ++++++++++-------- 2 files changed, 439 insertions(+), 304 deletions(-) diff --git a/src/views/dike/engineeringCondition/identificationPlate/components/markForm.vue b/src/views/dike/engineeringCondition/identificationPlate/components/markForm.vue index f300b8c..e0df339 100644 --- a/src/views/dike/engineeringCondition/identificationPlate/components/markForm.vue +++ b/src/views/dike/engineeringCondition/identificationPlate/components/markForm.vue @@ -56,12 +56,16 @@ - + {{ + !rowIsEdit ? "添加" : "修改" + }} + + @@ -109,10 +113,26 @@ export default { }, }, index: {}, - type: {}, + type: { + type: Number, + default() { + return 1; + }, + }, editItem: {}, - status: {}, + status: { + type: Boolean, + default() { + return false; + }, + }, comForm: {}, + rowIsEdit: { + type: Boolean, + default() { + return false; + }, + }, }, data() { return { @@ -127,43 +147,45 @@ export default { }, created() { // 判断打开的弹出框,是新增还是编辑 - if (this.status) { - this.form = this.editItem; + // if (this.status) { + // this.form = this.editItem; - this.form.type = this.type; - this.form.dikeName = this.comForm.dikeName; - this.form.dikeCode = this.comForm.dikeCode; - this.form.adcd = this.comForm.adcd; - if (this.form.photo) { - this.fileList = JSON.parse(this.form.photo); - } - } else { - this.form = { - id: null, - adcd: null, - dikeCode: null, - markName: null, - dikeName: null, - markLocation: null, - type: null, - markType: null, - photo: null, - markCode: null, - proNo: null, - proCode: null, - createUid: null, - updateUid: null, - createTime: null, - updateTime: null, - owerDept: null, - remark: null, - }; - this.form.type = this.type; - // console.log(7777777777, this.comForm); - this.form.dikeName = this.comForm.dikeName; - this.form.dikeCode = this.comForm.dikeCode; - this.form.adcd = this.comForm.adcd; - } + // this.form.type = this.type; + // this.form.dikeName = this.comForm.dikeName; + // this.form.dikeCode = this.comForm.dikeCode; + // this.form.adcd = this.comForm.adcd; + // if (this.editItem.photo) { + // console.log("文件列表", this.editItem.photo); + + // this.fileList = this.editItem.photo; + // } + // } else { + this.form = { + id: null, + adcd: null, + dikeCode: null, + markName: null, + dikeName: null, + markLocation: null, + type: null, + markType: null, + photo: null, + markCode: null, + proNo: null, + proCode: null, + createUid: null, + updateUid: null, + createTime: null, + updateTime: null, + owerDept: null, + remark: null, + }; + this.form.type = this.type; + // console.log(7777777777, this.comForm); + this.form.dikeName = this.comForm.dikeName; + this.form.dikeCode = this.comForm.dikeCode; + this.form.adcd = this.comForm.adcd; + // } console.log("this.form in components", this.form); // 当时是第一个表单时,form有父组件传入 // if (this.isFirst) { @@ -174,12 +196,42 @@ export default { // console.log("markTypeOptions", this.markTypeOptions); }, watch: { + // status: { + // handler(newVal, oldVal) { + // console.log("status", newVal, oldVal); + // console.log("this.editItem", this.editItem); + + // if (newVal) { + // this.form = this.editItem; + + // this.form.type = this.type; + // this.form.dikeName = this.comForm.dikeName; + // this.form.dikeCode = this.comForm.dikeCode; + // this.form.adcd = this.comForm.adcd; + // if (this.editItem.photo) { + // console.log("文件列表", this.editItem.photo); + + // this.fileList = this.editItem.photo; + // } + // } + // }, + // }, editItem: { deep: true, handler(newVal, oldVal) { // 表单内点击减号时,重新赋值刷新显示 + // this.form = newVal; this.form = newVal; - // console.log("新的name", newVal); + + this.form.type = this.type; + this.form.dikeName = this.comForm.dikeName; + this.form.dikeCode = this.comForm.dikeCode; + this.form.adcd = this.comForm.adcd; + if (newVal.photo) { + console.log("文件列表", newVal.photo); + + this.fileList = JSON.parse(newVal.photo); + } }, }, "comForm.dikeName": { @@ -238,8 +290,52 @@ export default { // }, }, methods: { + resetForm() { + this.$refs["form"].resetFields(); + this.form = { + id: null, + adcd: null, + dikeCode: null, + markName: null, + dikeName: null, + markLocation: null, + type: null, + markType: null, + photo: null, + markCode: null, + proNo: null, + proCode: null, + createUid: null, + updateUid: null, + createTime: null, + updateTime: null, + owerDept: null, + remark: null, + }; + this.fileList = []; + this.$nextTick(() => { + this.form.type = this.type; + console.log(7777777777, this.comForm, this.type); + this.form.dikeName = this.comForm.dikeName; + this.form.dikeCode = this.comForm.dikeCode; + this.form.adcd = this.comForm.adcd; + }); + }, addFormFarther() { - this.addForm(this.index, this.type, this.formName); + this.$refs["form"].validate((valid) => { + if (valid) { + // this.addForm(this.index, this.type, this.form) + this.form.photo = JSON.stringify(this.fileList); + this.addForm({ + formData: JSON.parse(JSON.stringify(this.form)), + type: this.type, + }); + this.resetForm(); + } else { + console.log("error submit!!"); + return false; + } + }); }, delFormFarther() { this.$emit("delForm", this.form.id, this.type, this.index); diff --git a/src/views/dike/engineeringCondition/identificationPlate/index.vue b/src/views/dike/engineeringCondition/identificationPlate/index.vue index 3991377..6c9ebf8 100644 --- a/src/views/dike/engineeringCondition/identificationPlate/index.vue +++ b/src/views/dike/engineeringCondition/identificationPlate/index.vue @@ -11,7 +11,6 @@
-
搜索 --> 重置重置 @@ -118,7 +117,7 @@ size="mini" @click="handleAdd" v-hasPermi="['yg:dikeMark:add']" - >新增新增 @@ -129,7 +128,7 @@ :disabled="single" @click="handleUpdate" v-hasPermi="['yg:dikeMark:edit']" - >修改修改 @@ -140,7 +139,7 @@ :disabled="multiple" @click="handleDelete" v-hasPermi="['yg:dikeMark:remove']" - >删除删除 修改修改 删除删除 @@ -297,249 +296,115 @@ - -
- 堤防公告类 -
-
- -
- -
- 堤防警告类 -
-
- - -
- -
- 堤防指引类 -
-
- - -
- -
- 堤防名称类 -
-
- - - +
+
+ + + + + + + + + + + + + + + + +
+ @@ -606,7 +471,7 @@ export default { // 弹出层标题 title: "", // 是否显示弹出层 - open: false, + open: true, // 标牌类型字典 typeOptions: [], // 标识类型字典 @@ -658,13 +523,66 @@ export default { }, dikeNameOptions: [], isEdit: false, - counter0: [{}], - counter1: [{}], - counter2: [{}], - counter3: [{}], + counter0: [], + counter1: [], + counter2: [], + counter3: [], delIdList: [], + activeName: "noticeForm", + editItem: {}, + editIndex: null, + rowIsEdit: false, + search: "", }; }, + computed: { + tabsOpt() { + return [ + { + label: "堤防公告类", + name: "noticeForm", + type: 0, + markTypeOptions: this.markTypeOptions1, + }, + { + label: "堤防警告类", + name: "warnForm", + type: 1, + markTypeOptions: this.markTypeOptions2, + }, + { + label: "堤防指引类", + name: "guideForm", + type: 2, + markTypeOptions: this.markTypeOptions3, + }, + { + label: "堤防名称类", + name: "nameForm", + type: 3, + markTypeOptions: this.markTypeOptions4, + }, + ]; + }, + getTabsOpt() { + return this.tabsOpt.filter((item) => { + return item.name === this.activeName; + })[0]; + }, + getDialogTabelData() { + return this[`counter${this.getTabsOpt.type}`]; + // switch (this.activeName) { + // case "noticeForm": + // return this.counter0; + // case "noticeForm": + // return this.counter0; + // case "noticeForm": + // return this.counter0; + // case "noticeForm": + // return this.counter0; + // } + }, + }, created() { this.getList(); this.getDicts("breastplate_type").then((response) => { @@ -691,6 +609,47 @@ export default { // this.counter1[0] = this.noticeForm; // }, methods: { + formatType(row) { + console.log("row", row); + + let { type, markType } = row; + if (markType) { + const markTypeOptions = "markTypeOptions" + (parseInt(type) + 1); + return this[markTypeOptions].filter((item) => { + return item.dictValue == markType; + })[0].dictLabel; + } else { + return "--"; + } + }, + handleDialogUpdate(row, col, index) { + console.log("row", row, col, index); + this.rowIsEdit = true; + this.editIndex = index; + this.editItem = JSON.parse(JSON.stringify(row)); + }, + handleDialogDelete(row, col, index) { + let { type } = row; + const counterType = "counter" + type; + this.$confirm("是否删除选中的数据?", "警告", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning", + }) + .then(() => { + console.log("删除", row, index); + this[counterType].splice(index, 1); + }) + .catch(function () {}); + }, + getCounterLen(type) { + const counterType = "counter" + type; + return this[counterType].length; + }, + handleClick() { + this.search = ""; + this.$refs.markForm.resetForm(); + }, formatAdcd(row) { if (row.adcd) { let provinceCode = row.adcd.slice(0, 2); @@ -713,6 +672,19 @@ export default { } } }, + addForm1(rowData) { + console.log("rowData", rowData); + let { type, formData } = rowData; + const counterType = "counter" + type; + console.log(formData); + + if (this.rowIsEdit) { + this[counterType].splice(this.editIndex, 1, formData); + this.rowIsEdit = false; + } else { + this[counterType].push(formData); + } + }, addForm(index, type, formName) { console.log("index和type", index, type); const counterType = "counter" + type; @@ -837,10 +809,10 @@ export default { // 表单重置 reset() { this.delIdList = []; - this.counter0 = [{}]; - this.counter1 = [{}]; - this.counter2 = [{}]; - this.counter3 = [{}]; + this.counter0 = []; + this.counter1 = []; + this.counter2 = []; + this.counter3 = []; this.comForm = { dikeName: null, dikeCode: null, @@ -1001,13 +973,13 @@ export default { this.comForm.adcd = response.data[0].adcd; console.log("this.comForm", this.comForm); this.counter0 = response.data.filter((item) => item.type == 0); - if (this.counter0.length == 0) this.counter0 = [{}]; + if (this.counter0.length == 0) this.counter0 = []; this.counter1 = response.data.filter((item) => item.type == 1); - if (this.counter1.length == 0) this.counter1 = [{}]; + if (this.counter1.length == 0) this.counter1 = []; this.counter2 = response.data.filter((item) => item.type == 2); - if (this.counter2.length == 0) this.counter2 = [{}]; + if (this.counter2.length == 0) this.counter2 = []; this.counter3 = response.data.filter((item) => item.type == 3); - if (this.counter3.length == 0) this.counter3 = [{}]; + if (this.counter3.length == 0) this.counter3 = []; console.log("回显的数据时的counter0", this.counter0); console.log("回显的数据时的counter1", this.counter1); console.log("回显的数据时的counter2", this.counter2); @@ -1017,6 +989,73 @@ export default { }); }, /** 提交按钮 */ + submitForm1() { + let isAllTrue = + this.counter0.length || + this.counter1.length || + this.counter2.length || + this.counter3.length + ? true + : false; + + this.$refs["comForm"].validate((valid0) => { + if (valid0) { + if (!isAllTrue) { + this.msgError("堤防标识标牌列表数据为空"); + return; + } + this.counter0.forEach((item) => { + if (item) { + item = { ...item, ...this.comForm }; + } + }); + this.counter1.forEach((item) => { + if (item) { + item = { ...item, ...this.comForm }; + } + }); + this.counter2.forEach((item) => { + if (item) { + item = { ...item, ...this.comForm }; + } + }); + this.counter3.forEach((item) => { + if (item) { + item = { ...item, ...this.comForm }; + } + }); + + if (this.isEdit) { + updateDikeMark([ + ...this.counter0, + ...this.counter1, + ...this.counter2, + ...this.counter3, + ]).then((response) => { + if (response.code === 200) { + this.msgSuccess("修改成功"); + this.open = false; + this.getList(); + } + }); + if (this.delIdList.length > 0) delDikeMark(this.delIdList); + } else { + addDikeMark([ + ...this.counter0, + ...this.counter1, + ...this.counter2, + ...this.counter3, + ]).then((response) => { + if (response.code === 200) { + this.msgSuccess("新增成功"); + this.open = false; + this.getList(); + } + }); + } + } + }); + }, submitForm() { // console.log(1111111111, this.$refs.noticeForm0[0].$refs.form); // 表单校验 @@ -1065,26 +1104,26 @@ export default { this.counter0.length > 1 ? this.counter0 : this.$refs["noticeForm0"][0].form.markName - ? [this.$refs["noticeForm0"][0].form] - : []; + ? [this.$refs["noticeForm0"][0].form] + : []; const C1 = this.counter1.length > 1 ? this.counter1 : this.$refs["warnForm0"][0].form.markName - ? [this.$refs["warnForm0"][0].form] - : []; + ? [this.$refs["warnForm0"][0].form] + : []; const C2 = this.counter2.length > 1 ? this.counter2 : this.$refs["guideForm0"][0].form.markName - ? [this.$refs["guideForm0"][0].form] - : []; + ? [this.$refs["guideForm0"][0].form] + : []; const C3 = this.counter3.length > 1 ? this.counter3 : this.$refs["nameForm0"][0].form.markName - ? [this.$refs["nameForm0"][0].form] - : []; + ? [this.$refs["nameForm0"][0].form] + : []; // console.log("C0C0", C0, C1); if (this.isEdit) {