From a647b8fb3c96791c126dcf26c78676adc35c670f Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期五, 27 十月 2023 17:12:18 +0800
Subject: [PATCH] 修改编码规则管理基础码段编辑bug,修改ts日期转换报错bug

---
 Source/UBCS-WEB/src/views/code/codeApply.vue |  162 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 157 insertions(+), 5 deletions(-)

diff --git a/Source/UBCS-WEB/src/views/code/codeApply.vue b/Source/UBCS-WEB/src/views/code/codeApply.vue
index 0475372..30bf0f2 100644
--- a/Source/UBCS-WEB/src/views/code/codeApply.vue
+++ b/Source/UBCS-WEB/src/views/code/codeApply.vue
@@ -18,6 +18,7 @@
               key="masterForm" data-key="masterForm"
               v-bind="$attrs"
               :type="type"
+              :LoadingStatus="status"
               :TreeValue="TreeValue"
               :eventList="eventList"
               ref="FormTemplate"
@@ -35,8 +36,15 @@
                   @getFormData="getCodeApplyFormData"
                   @referConfigDataUpdate="referConfigDataUpdate"
                 ></FormTemplate>
+                <el-button
+                  @click="submit()"
+                  type="primary"
+                  size="small"
+                  style="float: right"
+                >淇濆瓨</el-button>
               </el-tab-pane>
             </el-tabs>
+
           </div>
         </basic-container>
       </el-col>
@@ -44,15 +52,48 @@
 </template>
 
 <script>
-import {getAuthTree,getUsedTemplateByClassifyOid,getCodeRule} from '@/api/code/codeApply.js'
-
+import {getAuthTree,getUsedTemplateByClassifyOid,getCodeRule,addSaveCode} from '@/api/code/codeApply.js'
+import func from '@/util/func';
 export default {
   name: "codeApply",
   components: { FormTemplate: () => import('@/components/FormTemplate/FormTemplate') },
   data() {
     return {
+      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",
+      ],
       codeClassifyOid:'',
       type:'add',
+      status:'code',
       TreeValue:'',
       dialogVisible:true,
       setForm:{},
@@ -61,6 +102,8 @@
       activeName: "codeApply",
       showCodeApply: false,
       eventList:[],
+      showResembleQuery:false,
+      hasResemble:false,
       form: {},
       TreeData:[],
       TreeOption: {
@@ -110,6 +153,101 @@
     this.getTreeData()
   },
   methods:{
+    async submit() {
+      // 杩涜琛ㄥ崟鏍¢獙
+      const formValidate = await this.$refs.FormTemplate.validate();
+      if (!formValidate) return;
+      let resembleQueryList = [];
+      if (this.showResembleQuery && this.$refs.resembleQueryRef) {
+        // 杩涜鐩镐技椤规煡璇�
+        resembleQueryList = await this.$refs.resembleQueryRef.resembleQuery(
+          this.form
+        );
+      }
+      if (resembleQueryList.length > 0) {
+        await this.$confirm(
+          `璇ョ墿鏂欏凡鏈�${resembleQueryList.length}鏉$浉浼兼暟鎹紝鏄惁缁х画淇濆瓨锛焋,
+          "闇�瑕佹偍纭",
+          {
+            confirmButtonText: "纭畾",
+            cancelButtonText: "鍙栨秷",
+            type: "warning",
+          }
+        );
+      }
+      // 鎺掗櫎涓�浜涘瓧娈�
+      const noData = [
+        "jiliangdwname",
+        "materialtypeText",
+        "morengongysname",
+        "$caigouwl",
+        "$xiaoshouwl",
+        "$shifoupihaoguanli",
+        "lcstatus_text",
+        "hesuanfenleiname",
+        "$kucunwl",
+        "oldcode",
+        "lastmodifier"
+      ];
+      let resForm = {};
+      const { defaultValue, formValue } = this.getDefaultValueAndFormValues(
+        this.form
+      );
+      noData.forEach((item) => {
+        this.$delete(formValue, item);
+      });
+      const keys = Object.keys(formValue);
+      keys.forEach((item, index) => {
+        keys.forEach((itm, idx) => {
+          if ((item === ('$' + itm)) && idx !== index) {
+            this.$delete(formValue, keys[index]);
+          }
+        })
+      });
+
+      resForm.data = formValue;
+      resForm = Object.assign({}, resForm, defaultValue);
+      resForm.secDTOList = this.secVOList.map((item) => {
+        return {
+          secOid: item.oid,
+          secValue: this.codeApplyForm[item.oid],
+        };
+      });
+      resForm.codeClassifyOid = this.codeClassifyOid;
+      resForm.codeRuleOid = this.codeRuleOid;
+      resForm.templateOid = this.templateOid;
+      // this.$emit("submit", resForm);
+      if(func.notEmpty(resForm.ts)) {
+        resForm.ts = func.formattedDateTime(resForm.ts);
+        // resForm.ts = resForm.ts.toISOString().replace("Z", "");
+      }
+      addSaveCode(resForm).then(res => {
+        this.$nextTick(() => {
+          this.addvisible = false;
+          this.$message.success("淇濆瓨鎴愬姛");
+          this.onLoad()
+        })
+      })
+      // console.log(resForm)
+    },
+    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,
+      };
+    },
     getFormData(form) {
       this.form = form;
     },
@@ -139,14 +277,28 @@
       });
     },
     nodeClick(row){
-      // console.log(row)
+      console.log(row)
       this.TreeValue=row.text.split(" ")[0].trim();
       this.codeClassifyOid = row.oid;
       getUsedTemplateByClassifyOid({ 'codeClassifyOid': this.codeClassifyOid,templateOid:' 97e979919a1f1dca67290e85fee22688' }).then((res) => {
         console.log('===res',res)
-        if (res.data.code === 200) {
+        if (res.status === 200) {
+          this.hasResemble =
+            res.data.resembleTableVO &&
+            res.data.resembleTableVO.cols &&
+            res.data.resembleTableVO.cols.length > 0;
+          this.resembleTableColumn = res.data.resembleTableVO.cols || [];
+          if (this.hasResemble) {
+            this.activeName = "resembleQuery";
+            this.showResembleQuery = true;
+          } else {
+            this.showResembleQuery = false;
+          }
           this.$nextTick(() => {
-            this.eventList=res.data.data.attributes
+            this.$refs.FormTemplate.templateRender(
+              res.data.formDefineVO.items
+            );
+            this.eventList=res.data.templateVO.attributes
             // this.$refs.FormTemplate.$emit('eventList',  res.data.templateVO.attributes);
             if (Object.keys(this.setForm).length > 0) {
               this.$refs.FormTemplate.form = this.setForm;

--
Gitblit v1.9.3