Browse Source

2024-06-26

codeMan 1 year ago
parent
commit
1f453eaa81

+ 53 - 36
src/optionSystem/itemManage/detail/index.vue

@@ -12,7 +12,7 @@
       ownertable="plm_item"
       tags=""
       :tabs="['基本信息']"
-      :statusCheck="[{key:'status',value:'审核'}]"
+      :statusCheck="[{ key: 'status', value: '审核' }]"
       @pageChange="pageChange"
       @onEditSuccess="queryMainData($route.query.id)"
       v-if="Object.keys(mainData).length"
@@ -25,9 +25,11 @@
           idName="2024060309490502"
           keyName="itemids"
           :id="[$route.query.id]"
-          :paramData="[{key:'ischeck',value:1}]"
+          :paramData="[{ key: 'ischeck', value: 1 }]"
           @onSuccess="queryMainData()"
-          v-if="mainData.status == '新建' && tool.checkAuth($route.name,'check')"
+          v-if="
+            mainData.status == '新建' && tool.checkAuth($route.name, 'check')
+          "
         />
         <customBtn
           class="inline-16"
@@ -36,9 +38,11 @@
           idName="2024060309490502"
           keyName="itemids"
           :id="[$route.query.id]"
-          :paramData="[{key:'ischeck',value:0}]"
+          :paramData="[{ key: 'ischeck', value: 0 }]"
           @onSuccess="queryMainData()"
-          v-if="mainData.status == '审核' && tool.checkAuth($route.name,'nocheck')"
+          v-if="
+            mainData.status == '审核' && tool.checkAuth($route.name, 'nocheck')
+          "
         />
       </div>
       <div slot="slot0">
@@ -73,25 +77,32 @@ export default {
     detailInfo,
   },
   methods: {
-    async queryMainData(id) {
-      const res = await this.$api.requested({
-        id:2024060309171602,
-        content: {
-          itemid: this.$route.query.id,
-        },
+    async queryMainData(id,init) {
+      return new Promise(async (resolve) => {
+        const res = await this.$api.requested({
+          id: 2024060309171602,
+          content: {
+            itemid: this.$route.query.id,
+          },
+        });
+        resolve(res);
+        if (init) return
+        this.mainData = res.data;
+        console.log(this.mainData,'详情');
+        this.changeDataStructure();
       });
-      this.mainData = res.data;
-      console.log(this.mainData,'详情');
-      this.changeDataStructure();
     },
     optionList() {
-      this.$store.dispatch("optiontypeselect", "itemstype").then((res) => {
-        this.typeList = res.data;
-        console.log(this.typeList, "阀门类型");
+      return new Promise((resolve) => {
+        this.$store.dispatch("optiontypeselect", "itemstype").then((res) => {
+          // this.typeList = res.data;
+          resolve(res);
+          // console.log(this.typeList, "阀门类型");
+        });
       });
     },
     changeDataStructure() {
-        let that = this
+      let that = this;
       this.mainAreaData = [
         {
           label: "主阀料号",
@@ -107,25 +118,25 @@ export default {
         },
         {
           label: "价格",
-          value: this.tool.formatAmount(this.mainData.marketprice,2),
+          value: this.tool.formatAmount(this.mainData.marketprice, 2),
         },
         {
           label: "状态",
-          value:this.mainData.status,
-          style:function () {
-            let style = {}
+          value: this.mainData.status,
+          style: function () {
+            let style = {};
             switch (that.mainData.status) {
-              case '新建':
-                style = {color:"#000000"}
+              case "新建":
+                style = { color: "#000000" };
                 break;
-              case '审核':
-                style = {color:"#52C41A"}
+              case "审核":
+                style = { color: "#52C41A" };
                 break;
               default:
                 break;
             }
-            return style
-          }
+            return style;
+          },
         },
       ];
       this.detailInfo = [
@@ -136,14 +147,17 @@ export default {
             { label: "名称", value: this.mainData.itemname },
             { label: "阀门类型", value: this.mainData.valvetype },
             { label: "公称通径", value: this.mainData.caliber },
-            { label: "公称压力", value: this.mainData.nominalpressure.join(',') },
+            {
+              label: "公称压力",
+              value: this.mainData.nominalpressure.join(","),
+            },
             { label: "连接方式", value: this.mainData.connection },
             { label: "阀体材质", value: this.mainData.bodymaterial },
             { label: "蝶板材质", value: this.mainData.valveplatematerial },
             { label: "阀杆材质", value: this.mainData.stemmaterial },
             { label: "阀座材质", value: this.mainData.plinthmaterial },
             { label: "阀门扭矩", value: this.mainData.torque },
-            { label: "驱动方式", value: this.mainData.drivetype.join(',') },
+            { label: "驱动方式", value: this.mainData.drivetype.join(",") },
             { label: "法兰号", value: this.mainData.flh },
             { label: "阀杆尺寸", value: this.mainData.stemsize },
             { label: "圆阀杆最大直径", value: this.mainData.maxrounddiameter },
@@ -176,17 +190,20 @@ export default {
       this.queryMainData(id);
     },
     onSuccess() {
-      this.visible = false;
       this.queryMainData(this.$route.query.id);
       this.$emit("onSuccess");
     },
   },
-  created() {
-    this.optionList()
+  mounted() {
+    Promise.all([
+      this.optionList(),
+      this.queryMainData(this.$route.query.id,true),
+    ]).then((res) => {
+      this.typeList = res[0].data
+      this.mainData = res[1].data
+      this.changeDataStructure();
+    });
   },
-  mounted () {
-    this.queryMainData(this.$route.query.id)
-  }
 };
 </script>
 

+ 2 - 5
src/optionSystem/itemManage/modules/edit.vue

@@ -32,8 +32,7 @@ export default {
     return {
       drawer:false,
       type:'',
-      valvetype:'',
-      cacheFun:''
+      valvetype:''
     }
   },
   computed:{
@@ -58,9 +57,7 @@ export default {
     onShow () {
       this.drawer = true
       this.$nextTick(() => {
-        setTimeout(() => {
-          this.$refs.form.getFormLayoutData(this.type)
-        },500)
+        this.$refs.form.getFormLayoutData(this.type)
         this.$refs.form.form = JSON.parse(JSON.stringify(this.data))
       })
     },