From b5b28e8b9c639f49e69efc60684e68bf642d1092 Mon Sep 17 00:00:00 2001 From: xiejun <xj@2023> Date: 星期三, 21 六月 2023 16:43:28 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- Source/UBCS-WEB/src/components/FormTemplate/index.vue | 210 +++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 182 insertions(+), 28 deletions(-) diff --git a/Source/UBCS-WEB/src/components/FormTemplate/index.vue b/Source/UBCS-WEB/src/components/FormTemplate/index.vue index b910397..f37041e 100644 --- a/Source/UBCS-WEB/src/components/FormTemplate/index.vue +++ b/Source/UBCS-WEB/src/components/FormTemplate/index.vue @@ -3,9 +3,8 @@ :visible.sync="dialogVisible" v-if="dialogVisible" v-dialogDrag - top="0vh" + top="5vh" :title="title" - class="avue-dialog avue-dialog--top" :width="width" append-to-body @opened="openDialog" @@ -37,7 +36,8 @@ :selfColumnType="selfColumnType" :selfColumnConfig="selfColumnConfig" ref="CodeApply" - @getFormData="getFormData" + @getFormData="getCodeApplyFormData" + @referConfigDataUpdate="referConfigDataUpdate" ></FormTempalte> </el-tab-pane> <el-tab-pane @@ -57,18 +57,25 @@ </el-tab-pane> </el-tabs> </div> - <div class="avue-dialog__footer" v-if="type !== 'detail'"> - <el-button @click="close()">鍙� 娑�</el-button> - <el-button @click="submit()" type="primary" :loading="submitBtnLoading" - >{{ submitText }}</el-button - > - <el-button - @click="resembleQuerySubmit" - type="primary" - v-if="showResembleQuery" - >鐩镐技鍍忔煡璇�</el-button - > - </div> + <template #footer> + <div class="" v-if="type !== 'detail'"> + <el-button @click="close()" size="small">鍙� 娑�</el-button> + <el-button + @click="submit()" + type="primary" + :loading="submitBtnLoading" + size="small" + >{{ submitText }}</el-button + > + <el-button + @click="resembleQuerySubmit" + type="primary" + size="small" + v-if="showResembleQuery" + >鐩镐技鍍忔煡璇�</el-button + > + </div> + </template> </el-dialog> </template> @@ -107,8 +114,8 @@ }, submitText: { type: String, - default: '纭� 瀹�' - } + default: "纭� 瀹�", + }, }, data() { return { @@ -118,6 +125,7 @@ resembleTableColumn: [], secVOList: [], form: {}, + codeApplyForm: {}, activeName: "codeApply", showCodeApply: true, showResembleQuery: true, @@ -132,6 +140,8 @@ required: this.isRequired, dicData: this.getOptionList, type: this.getType, + referConfig: this.getReferConfig, + readOnly: this.getDisabled, }, exchange: { text: "name", @@ -151,6 +161,38 @@ }, }, }, + defaultKeys: [ + "oid", + "id", + "name", + "description", + "revisionoid", + "nameoid", + "btmname", + "lastr", + "firstr", + "lastv", + "firstv", + "creator", + "createtime", + "lastModifier", + "lastmodifytime", + "revisionrule", + "revisionseq", + "revisionvalue", + "versionrule", + "versionseq", + "versionvalue", + "lcstatus", + "ts", + "owner", + "checkinby", + "checkintime", + "checkoutby", + "checkouttime", + "copyfromversion", + "secretgrade", + ], }; }, created() {}, @@ -167,7 +209,7 @@ methods: { openDialog() { this.getFormTemplate(); - if (this.type === 'add') { + if (this.type === "add") { this.getCodeRule(); } }, @@ -188,20 +230,20 @@ res.data.resembleTableVO.cols.length > 0; this.resembleTableColumn = res.data.resembleTableVO.cols || []; if (this.hasResemble) { - this.activeName = 'resembleQuery' - this.showResembleQuery = true + this.activeName = "resembleQuery"; + this.showResembleQuery = true; } this.$refs.FormTempalte.templateRender(res.data.formDefineVO.items); } }) .catch((err) => { this.loading = false; - console.log(err); }); }, // 鑾峰彇鐮佸�肩敵璇锋暟鎹� getCodeRule() { getCodeRule({ codeClassifyOid: this.codeClassifyOid }).then((res) => { + console.log(res, "resresresresres"); if (res.data && res.data.code === 200) { const typeList = [ "codefixedsec", @@ -210,15 +252,16 @@ "coderefersec", ]; this.secVOList = (res.data.data.secVOList || []).filter((item) => - typeList.includes(item) + typeList.includes(item.secType) ); + console.log(this.secVOList, "this.secVOListthis.secVOList"); this.$nextTick(() => { - if (this.secVOList.length > 0 && this.type === 'add') { - this.showCodeApply = true - this.activeName = 'codeApply' + if (this.secVOList.length > 0 && this.type === "add") { + this.showCodeApply = true; + this.activeName = "codeApply"; this.$refs.CodeApply.templateRender(this.secVOList); } else { - this.showCodeApply = false + this.showCodeApply = false; } }); } @@ -226,6 +269,21 @@ }, getFormData(form) { this.form = form; + }, + getCodeApplyFormData(codeApplyForm) { + this.codeApplyForm = codeApplyForm; + }, + // 鍙傜収缁勪欢鏁版嵁鍙樻洿 + referConfigDataUpdate(data) { + const { field } = data; + this.secVOList = this.secVOList.map((item) => { + if (item.parentClassifySecOid === field) { + this.$refs.CodeApply.form[item.oid] = undefined; + this.$refs.CodeApply.form[item.name] = undefined; + } + return item; + }); + this.$refs.CodeApply.templateRender(this.secVOList); }, resembleQuerySubmit() { this.activeName = "resembleQuery"; @@ -243,7 +301,8 @@ let codeValidate = true; // 杩涜鐮佸�肩敵璇锋牎楠� if (this.showCodeApply) { - codeValidate = await this.$refs.codeApply.validate(); + codeValidate = await this.$refs.CodeApply.validate(); + console.log(9999); if (!codeValidate) return; } // 杩涜鐩镐技椤规煡璇� @@ -251,7 +310,22 @@ this.form ); if (resembleQueryList.length === 0) { - this.$emit("submit", this.form); + let resForm = {}; + const { defaultValue, formValue } = this.getDefaultValueAndFormValues( + this.form + ); + resForm.data = formValue; + resForm = Object.assign({}, resForm, defaultValue); + resForm.secDTOList = []; + for (const key in this.codeApplyForm) { + if (Object.hasOwnProperty.call(this.codeApplyForm, key)) { + const value = this.codeApplyForm[key]; + if (value) { + resForm.secDTOList.push({ [key]: value }); + } + } + } + this.$emit("submit", resForm); } else { this.$confirm( `璇ョ墿鏂欏凡鏈�${resembleQueryList.length}鏉$浉浼兼暟鎹紝鏄惁缁х画淇濆瓨锛焋, @@ -268,9 +342,89 @@ .catch(() => {}); } }, + getDefaultValueAndFormValues(form) { + let defaultValue = {}; + let formValue = {}; + for (const key in form) { + if (Object.hasOwnProperty.call(form, key)) { + const element = form[key]; + if (this.defaultKeys.includes(key)) { + defaultValue[key] = element; + } else { + formValue[key] = element; + } + } + } + return { + defaultValue, + formValue, + }; + }, getType(item) { return this.selfColumnType[item.sectype]; }, + getReferConfig(item) { + let params = {}; + if (item.sectype == "codeclassifysec") { + params = { + isMuti: false, + type: "grid", + tableConfig: { + limit: -1, + cols: [ + { + field: "id", + title: "鑻辨枃鍚嶇О", + sort: true, + width: 150, + }, + { + field: "name", + title: "涓枃鍚嶇О", + sort: true, + width: 150, + }, + { + field: "description", + title: "鎻忚堪", + width: 250, + }, + ], + queryColumns: [ + { + field: "id", + title: "鑻辨枃鍚嶇О", + }, + { + field: "name", + title: "涓枃鍚嶇О", + }, + ], + }, + url: "api/ubcs-code/ubcs-code/mdmEngineController/listCodeClassifyValueBySecOid", + extraParams: { + classifySecOid: item.oid, + parentClassifyValueOid: item.parentClassifySecOid + ? this.codeApplyForm[item.parentClassifySecOid] + : "", + }, + }; + } else if (item.sectype == "coderefersec") { + params = JSON.parse(item.referValueInfo); + } + return params; + }, + getDisabled(item) { + if (item.sectype === "codeclassifysec") { + if (item.parentClassifySecOid) { + if (!this.codeApplyForm[item.parentClassifySecOid]) { + return true; + } else { + return false; + } + } + } + }, isRequired(item) { return item.nullableFlag != "true"; }, -- Gitblit v1.9.3