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/code.vue                     |   70 +++++++++++++++-------------------
 Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue |   10 +++-
 Source/UBCS-WEB/src/util/func.js                            |   17 ++++++++
 Source/UBCS-WEB/src/views/code/codeApply.vue                |    7 ++-
 4 files changed, 60 insertions(+), 44 deletions(-)

diff --git a/Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue b/Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue
index f7a0b3d..0658b01 100644
--- a/Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue
+++ b/Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue
@@ -167,6 +167,7 @@
 import {validatenull} from "@/util/validate";
 import fileInHtml from "@/components/file/inHtml.vue";
 import {getUserInfo} from "@/api/system/user";
+import func from "@/util/func";
 
 export default {
   components: {
@@ -328,7 +329,7 @@
         oids.push(ele.oid);
       });
       return oids;
-    }
+    },
   },
   created() {
     // const index = this.$route.query.id.indexOf('@name=') + '@name='.length;
@@ -881,8 +882,11 @@
     },
     //澧炲姞淇濆瓨
     AddSumbit(val) {
-      console.log(val)
-      val.ts = val.ts.toISOString().replace("Z", "");
+      //console.log(val)
+      if(func.notEmpty(val.ts)) {
+        val.ts = func.formattedDateTime(val.ts);
+        //console.log(val.ts);
+      }
       addSaveCode(val).then(res => {
         this.$nextTick(() => {
           this.addvisible = false;
diff --git a/Source/UBCS-WEB/src/util/func.js b/Source/UBCS-WEB/src/util/func.js
index cdc52f2..78bd256 100644
--- a/Source/UBCS-WEB/src/util/func.js
+++ b/Source/UBCS-WEB/src/util/func.js
@@ -74,6 +74,23 @@
   }
 
   /**
+   * ts鏃ユ湡鏍煎紡澶勭悊
+   * @param {瑕佸鐞嗙殑鏃ユ湡} thisDate 
+   * @returns 
+   */
+  static formattedDateTime(thisDate) {
+    const date = new Date(thisDate);
+    const year = date.getFullYear();
+    const month = (date.getMonth() + 1).toString().padStart(2, '0');
+    const day = date.getDate().toString().padStart(2, '0');
+    const hours = date.getHours().toString().padStart(2, '0');
+    const minutes = date.getMinutes().toString().padStart(2, '0');
+    const seconds = date.getSeconds().toString().padStart(2, '0');
+    const milliseconds = date.getMilliseconds().toString().padStart(3, '0');
+    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}.${milliseconds}`;
+  }
+
+  /**
    * 鏍规嵁閫楀彿鑱斿悎
    * @param arr
    * @returns {string}
diff --git a/Source/UBCS-WEB/src/views/code/code.vue b/Source/UBCS-WEB/src/views/code/code.vue
index b8dddd0..ccc8e0c 100644
--- a/Source/UBCS-WEB/src/views/code/code.vue
+++ b/Source/UBCS-WEB/src/views/code/code.vue
@@ -1186,9 +1186,7 @@
           </el-row>
         </div>
         <div slot="footer" class="dialog-footer">
-          <el-button type="primary" @click="selectedListClassifyLinkAttr"
-            >纭� 瀹�</el-button
-          >
+          <el-button type="primary" @click="selectedListClassifyLinkAttr">纭� 瀹�</el-button>
           <el-button @click="isShowSelectAttrOption = false">鍙� 娑�</el-button>
         </div>
       </el-dialog>
@@ -1601,7 +1599,7 @@
         basicMoveupBtn: this.vaildData(this.permission.code_rule.code_basic_moveup, false),
         basicDownBtn: this.vaildData(this.permission.code_rule.code_basic_down, false),
       }
-    }
+    },
   },
   watch: {},
   mounted() {
@@ -2696,16 +2694,16 @@
                 type: "success",
                 message: "鎿嶄綔鎴愬姛!",
               });
+              // 鍏抽棴瀵硅瘽妗�
+              this.addBasicCodeSettingBox = false;
+              // 鐐瑰嚮鏂板鍩虹鐮佹,鍏抽棴绐楀彛涔嬪悗瑙﹀彂閲嶆柊鍔犺浇
+              this.loadBasic(this.selectionList[0]);
             },
             (error) => {
               window.console.log(error);
             }
           );
-          // 鍏抽棴瀵硅瘽妗�
-          this.addBasicCodeSettingBox = false;
         }
-        // 鐐瑰嚮鏂板鍩虹鐮佹,鍏抽棴绐楀彛涔嬪悗瑙﹀彂閲嶆柊鍔犺浇
-        this.loadBasic(this.selectionList[0]);
       } else {
         // 鍙兘鍙傜収寮曠敤鐨勪笟鍔$被鍨嬩細鍙戠敓鏀瑰彉鎵�浠ヨ繖鍎跨洿鎺ュreferConfig鐨刯son杩涜鏀瑰彉
         if (
@@ -2725,14 +2723,14 @@
               type: "success",
               message: "鎿嶄綔鎴愬姛!",
             });
+            this.loadBasic(this.selectionList[0]);
+            // 鍏抽棴瀵硅瘽妗�
+            this.addBasicCodeSettingBox = false;
           },
           (error) => {
             window.console.log(error);
           }
         );
-        this.loadBasic(this.selectionList[0]);
-        // 鍏抽棴瀵硅瘽妗�
-        this.addBasicCodeSettingBox = false;
       }
       this.isLoadingSecCodeAddBtn = false;
     },
@@ -3171,34 +3169,19 @@
       ) {
         this.loadCodeSecType();
       }
-      if (row != null) {
-        this.form = {
-          oid: row.oid,
-          id: row.id, //缂栧彿,
-          name: row.name, //鍚嶇О
-          secType: row.secType, //鐮佹绫诲瀷
-          description: row.description, //鎻忚堪
-          serialDependFlag: row.serialDependFlag == "true" ? true : false, //鏄惁娴佹按渚濊禆
-          serialDependOrder: row.serialDependOrder, //娴佹按渚濊禆椤哄簭
-          nullableFlag: row.nullableFlag == "true" ? true : false, //鏄惁涓虹┖
-          displayFlag: row.displayFlag == "true" ? true : false,
-          componentCodeFlag: row.componentCodeFlag == "true" ? true : false, //鏄惁鍙備笌缂栫爜
-          pkCodeRule: row.pkCodeRule, //鎵�灞炵紪鐮佽鍒�
-        };
-      } else {
-        this.form = {
-          id: this.form.id, //缂栧彿
-          name: this.form.name, //鍚嶇О
-          secType: this.form.secType, //鐮佹绫诲瀷
-          description: this.form.description, //鎻忚堪
-          serialDependFlag: this.form.serialDependFlag, //鏄惁娴佹按渚濊禆
-          serialDependOrder: this.form.serialDependOrder, //娴佹按渚濊禆椤哄簭
-          nullableFlag: this.form.nullableFlag, //鏄惁涓虹┖
-          displayFlag: this.form.displayFlag, //
-          componentCodeFlag: this.form.componentCodeFlag, //鏄惁鍙備笌缂栫爜
-          pkCodeRule: this.form.pkCodeRule, //鎵�灞炵紪鐮佽鍒�
-        };
-      }
+      this.form = {
+        oid: row !=null ? row.oid:this.form.oid,
+        id: row !=null ? row.id:this.form.id, //缂栧彿,
+        name: row !=null ? row.name:this.form.name, //鍚嶇О
+        secType: row !=null ?  row.secType:this.form.secType, //鐮佹绫诲瀷
+        description:  row !=null ? row.description:this.form.description, //鎻忚堪
+        serialDependFlag: this.isNullJsonBoolean(row,this.form, 'serialDependFlag'), //鏄惁娴佹按渚濊禆
+        serialDependOrder:  row !=null ? row.serialDependOrder:this.form.serialDependOrder, //娴佹按渚濊禆椤哄簭
+        nullableFlag: this.isNullJsonBoolean(row, this.form, 'nullableFlag'), //鏄惁涓虹┖
+        displayFlag: this.isNullJsonBoolean(row, this.form, 'displayFlag'),
+        componentCodeFlag: this.isNullJsonBoolean(row, this.form, 'componentCodeFlag'), //鏄惁鍙備笌缂栫爜
+        pkCodeRule:  row !=null ? row.pkCodeRule:this.form.pkCodeRule, //鎵�灞炵紪鐮佽鍒�
+      };
       if (this.form.secType === "codefixedsec") {
         //鍥哄畾鐮佹
         this.form = Object.assign({}, this.form, {
@@ -3351,6 +3334,15 @@
         this.loadCodeFillSeparator();
       }
     },
+    // 鍒ゆ柇Boolean鍊兼槸鍚︿负绌猴紝骞朵笖瀵箂tr绫诲瀷甯冨皵鍊艰繘琛岃浆鎹�
+    isNullJsonBoolean(row,form,attr) {
+        //console.log(row[attr],form[attr]);
+        if(row != null){
+          return JSON.parse(row[attr]);
+        }else {
+          return form[attr];
+        }
+    },
     /** 绗竴娆¤姹傜殑鏋氫妇鏁版嵁鏀剧紦瀛�*/
     getLocalStorageEnum(enumKey) {
       let enumCach = JSON.parse(localStorage.getItem(enumKey));
diff --git a/Source/UBCS-WEB/src/views/code/codeApply.vue b/Source/UBCS-WEB/src/views/code/codeApply.vue
index 32ce26e..30bf0f2 100644
--- a/Source/UBCS-WEB/src/views/code/codeApply.vue
+++ b/Source/UBCS-WEB/src/views/code/codeApply.vue
@@ -53,7 +53,7 @@
 
 <script>
 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') },
@@ -217,7 +217,10 @@
       resForm.codeRuleOid = this.codeRuleOid;
       resForm.templateOid = this.templateOid;
       // this.$emit("submit", resForm);
-      resForm.ts = resForm.ts.toISOString().replace("Z", "");
+      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;

--
Gitblit v1.9.3