Browse Source

设备点检优化

wyh 1 year ago
parent
commit
12fd597e1a

+ 40 - 15
src/views/module_cmms/spotcheck/SpotcheckList.vue

@@ -113,7 +113,10 @@
     </div>
 
     <!-- <cmms-spotcheck-modal ref="modalForm" @ok="modalFormOk"></cmms-spotcheck-modal> -->
-    <spotcheck-modal ref="modalForm" @ok="modalFormOk" :dataList="dataList"></spotcheck-modal>
+    <!-- 第二版 -->
+    <!-- <spotcheck-modal ref="modalForm" @ok="modalFormOk" :dataList="dataList"></spotcheck-modal> -->
+    <!-- 第三版 -->
+    <spotcheck-modal ref="modalForm" @ok="modalFormOk"></spotcheck-modal>
   </a-card>
 </template>
 
@@ -270,20 +273,42 @@
       },
       // 新增
       handleAdd: function () {
-        console.log(this.queryParam.equipmentid)
-        if (this.selectData.id == undefined) {
-          this.$message.warning("请先选择设备");
-        } else {
-          getAction(`/cmmsSpotcheck/cmmsSpotcheck/getInfoByEquipmentid/${this.selectData.id}`).then((res) => {
-            console.log("000",res)
-            this.dataList = res.result
-            console.log(1111,this.dataList)
-            this.$refs.modalForm.add();
-            this.$refs.modalForm.title = "新增";
-            this.$refs.modalForm.disableSubmit = false;
-          })
-        }
-        
+        // 第一版
+        // if (this.selectData.id == undefined) {
+        //   this.$message.warning("请先选择设备");
+        // } else {
+        //   getAction(`/cmmsSpotcheck/cmmsSpotcheck/getInfoByEquipmentid/${this.selectData.id}`).then((res) => {
+        //     console.log("000",res)
+        //     this.dataList = res.result
+        //     console.log(1111,this.dataList)
+        //     this.$refs.modalForm.add();
+        //     this.$refs.modalForm.title = "新增";
+        //     this.$refs.modalForm.disableSubmit = false;
+        //   })
+        // }
+        // 第二版
+        // if (this.selectData.id == undefined) {
+        //   this.dataList = []
+        //   this.$refs.modalForm.add();
+        //   this.$refs.modalForm.title = "新增";
+        //   this.$refs.modalForm.disableSubmit = false;
+        // } else {
+        //   getAction(`/cmmsSpotcheck/cmmsSpotcheck/getInfoByEquipmentid/${this.selectData.id}`).then((res) => {
+        //     this.dataList = res.result
+        //     this.$refs.modalForm.add();
+        //     this.$refs.modalForm.title = "新增";
+        //     this.$refs.modalForm.disableSubmit = false;
+        //   })
+        // }
+        // 第三版
+        this.$refs.modalForm.add();
+        this.$refs.modalForm.title = "新增";
+        this.$refs.modalForm.disableSubmit = false;
+      },
+      handleEdit: function (record) {
+        this.$refs.modalForm.edit(record);
+        this.$refs.modalForm.title = "编辑";
+        this.$refs.modalForm.disableSubmit = false;
       },
       initDictConfig(){
       },

+ 69 - 23
src/views/module_cmms/spotcheck/modules/SpotcheckForm.vue

@@ -10,13 +10,13 @@
             </a-form-model-item>
           </a-col> -->
           <a-col :span="12">
-            <a-form-model-item label="点检内容名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contentname">
-              <a-input v-model="model.contentname" placeholder="请输入所属点检内容名称"  ></a-input>
+            <a-form-model-item label="设备名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentid">
+              <j-search-select-tag v-model="model.equipmentid" dict="tpm_equipment,equipmentname,id" placeholder="请选择设备" @change="handleChange"/>
             </a-form-model-item>
           </a-col>
           <a-col :span="12">
-            <a-form-model-item label="设备名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentid">
-              <j-search-select-tag v-model="model.equipmentid" dict="tpm_equipment,equipmentname,id"  />
+            <a-form-model-item label="点检内容名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contentname">
+              <a-input v-model="model.contentname" placeholder="请输入所属点检内容名称" :disabled="disableds" ></a-input>
             </a-form-model-item>
           </a-col>
           <!-- <a-col :span="12">
@@ -36,20 +36,27 @@
           </a-col>
           <a-col :span="12">
             <a-form-model-item label="点检描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="description">
-              <a-input v-model="model.description" placeholder="请输入点检描述"  ></a-input>
+              <!-- <a-input v-model="model.description" placeholder="请输入点检描述"  ></a-input> -->
+              <a-textarea v-model="model.description" placeholder="请输入点检描述" :auto-size="{ minRows: 2, maxRows: 3 }" />
             </a-form-model-item>
           </a-col>
           <a-col :span="12">
             <a-form-model-item label="点检备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
-              <a-input v-model="model.remark" placeholder="请输入点检备注"  ></a-input>
+              <!-- <a-input v-model="model.remark" placeholder="请输入点检备注"  ></a-input> -->
+              <a-textarea v-model="model.remark" placeholder="请输入点检备注" :auto-size="{ minRows: 2, maxRows: 3 }" />
+            </a-form-model-item>
+          </a-col>
+          <a-col :span="12">
+            <a-form-model-item label="故障照片" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
+              <j-image-upload text="上传" v-model="model.files" isMultiple></j-image-upload>
             </a-form-model-item>
           </a-col>
         </a-row>
         <div class="cmms-dialog-item-title u-flex-jab">
           <div>点检列表</div>
           <div>
-            <a-button type="link">一键正常</a-button>
-            <a-button type="link">一键异常</a-button>
+            <a-button @click="allT" type="link">一键正常</a-button>
+            <a-button @click="allF" type="link">一键异常</a-button>
           </div>
         </div>
         <a-table
@@ -66,10 +73,10 @@
           <template slot="iresult" slot-scope="text, record,index">
               <a-form-model-item :prop="'cmmsSpotcheckTitemList.'+index+'.iresult'" :rules="validatorRules.iresult" style="margin-bottom: 0px;">
                   <a-radio-group name="radioGroup" v-model="record.iresult">
-                    <a-radio :value="0">
+                    <a-radio value="0">
                       正常
                     </a-radio>
-                    <a-radio :value="1">
+                    <a-radio value="1">
                       异常
                     </a-radio>
                   </a-radio-group>
@@ -102,18 +109,20 @@
         default: false,
         required: false
       },
-      dataList: {
-        type: Object,
-        default: function(){
-            return {} // 使用工厂函数返回默认值
-        }
-      },
+      // dataList: {
+      //   type: Object,
+      //   default: function(){
+      //       return {} // 使用工厂函数返回默认值
+      //   }
+      // },
     },
     data () {
       return {
         model:{
           cmmsSpotcheckTitemList: []
         },
+        // 单个禁填
+        disableds: false,
         labelCol: {
           xs: { span: 24 },
           sm: { span: 5 },
@@ -194,13 +203,25 @@
     },
     methods: {
       add () {
-        // this.edit(this.modelDefault);
-        console.log(222,this.dataList)
-        this.model = this.dataList
+        this.edit(this.modelDefault);
+        this.model.id = ""
+        this.disableds = true
+        // 第二版
+        // this.model = this.dataList
+        // this.model.id = ""
       },
       edit (record) {
-        this.model = Object.assign({}, record);
-        this.visible = true;
+        this.disableds = true
+        getAction(`/cmmsSpotcheck/cmmsSpotcheck/getInfoBySpotcheckid/${record.id}`).then((res) => {
+            this.model = res.result
+            const b = res.result.files.map((res) => {
+              return res.url
+            })
+            this.model.files = b.join(',')
+            this.visible = true;
+        })
+        // this.model = Object.assign({}, record);
+        // this.visible = true;
       },
       submitForm () {
         const that = this;
@@ -217,7 +238,13 @@
               httpurl+=this.url.edit;
                method = 'put';
             }
-            console.log(99,this.model)
+            const a  = this.model.files.split(',')
+            this.model.files = a.map((res) => {
+              return {
+                url: res
+              }
+            })
+            console.log(88,this.model)
             httpAction(httpurl,this.model,method).then((res)=>{
               if(res.success){
                 that.$message.success(res.message);
@@ -229,9 +256,28 @@
               that.confirmLoading = false;
             })
           }
-
         })
       },
+      handleChange(value){
+        console.log(value)
+        getAction(`/cmmsSpotcheck/cmmsSpotcheck/getInfoByEquipmentid/${value}`).then((res) => {
+          this.model = res.result
+        })
+      },
+      allT() {
+        this.model.cmmsSpotcheckTitemList = this.model.cmmsSpotcheckTitemList.map((res) => {
+          var data = res
+          data.iresult = "0"
+          return data
+        })
+      },
+      allF() {
+        this.model.cmmsSpotcheckTitemList = this.model.cmmsSpotcheckTitemList.map((res) => {
+          var data = res
+          data.iresult = "1"
+          return data
+        })
+      }
     }
   }
 </script>

+ 10 - 7
src/views/module_cmms/spotcheck/modules/SpotcheckModal.vue

@@ -8,7 +8,10 @@
     :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
     @cancel="handleCancel"
     cancelText="关闭">
-    <spotcheck-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit" :dataList="dataList"></spotcheck-form>
+    <!-- 第二版 -->
+    <!-- <spotcheck-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit" :dataList="dataList"></spotcheck-form> -->
+    <!-- 第三版 -->
+    <spotcheck-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit"></spotcheck-form>
   </u-modal>
 </template>
 
@@ -21,12 +24,12 @@
         SpotcheckForm
     },
     props: {
-      dataList: {
-        type: Object,
-        default: function(){
-            return {} // 使用工厂函数返回默认值
-        }
-      },
+      // dataList: {
+      //   type: Object,
+      //   default: function(){
+      //       return {} // 使用工厂函数返回默认值
+      //   }
+      // },
     },
     data () {
       return {