From 0d626ae57149d5ed40a32bd8b808ca6069aa6d5e Mon Sep 17 00:00:00 2001
From: gaosp <gaosp>
Date: 星期日, 14 一月 2024 16:35:08 +0800
Subject: [PATCH] update

---
 src/container/maintenance/dailyMAdd.vue |  237 ++++++++++++++++++++++-------------------------------------
 1 files changed, 89 insertions(+), 148 deletions(-)

diff --git a/src/container/maintenance/dailyMAdd.vue b/src/container/maintenance/dailyMAdd.vue
index 13ae2c0..3213798 100644
--- a/src/container/maintenance/dailyMAdd.vue
+++ b/src/container/maintenance/dailyMAdd.vue
@@ -7,37 +7,17 @@
         :visible.sync="dialogVisibleAdd" class="role-select">
          <!-- 鏌ヨ琛ㄥ崟 -->
         <el-form :model="dataForm" ref="dataForm" label-width="150px" style="margin-top:10px;">
-            <el-row :gutter="20">
-                <el-col :xs="24":sm="6":md="6":lg="6":xl="6">
-                    <el-form-item label="缁熶竴缂栧彿" prop="uuid">
-                        <el-input type="text" v-model="dataForm.uuid" autocomplete="off"></el-input>
-                    </el-form-item>
-                </el-col>
+            <el-row :gutter="24">
                 <el-col :xs="24":sm="6":md="6":lg="6":xl="6">
                     <el-form-item label="璁惧鍚嶇О" prop="machineName">
-                        <el-select v-model="dataForm.machineName" placeholder="---璇烽�夋嫨---">
+                        <el-select v-model="dataForm.machineId" placeholder="---璇烽�夋嫨---">
                             <el-option
-                            v-for="item in machineName"
+                            v-for="item in machineList"
                             :key="item.id"
-                            :label="item.label"
-                            :value="item.value">
+                            :label="item.name"
+                            :value="item.id">
                             </el-option>
                         </el-select>
-                    </el-form-item>
-                </el-col>
-                <el-col :xs="24":sm="6":md="6":lg="6":xl="6">
-                    <el-form-item label="璁惧鍨嬪彿" prop="type">
-                        <el-input size="mini" type="text" v-model="dataForm.type"></el-input>
-                    </el-form-item>
-                </el-col>
-                <el-col :xs="24":sm="6":md="6":lg="6":xl="6">
-                    <el-form-item label="璁惧瑙勬牸" prop="specification">
-                        <el-input size="mini" type="text" v-model="dataForm.specification" @input="getMachineInfo"></el-input>
-                    </el-form-item>
-                </el-col>
-                <el-col :xs="24":sm="6":md="6":lg="6":xl="6">
-                    <el-form-item label="瀹夎鍦扮偣" prop="location">
-                        <el-input size="mini" type="text" v-model="dataForm.location"></el-input>
                     </el-form-item>
                 </el-col>
                 <el-col :xs="24":sm="6":md="6":lg="6":xl="6">
@@ -56,32 +36,12 @@
                     <el-form-item label="淇濆吇鑰�" prop="maintainPerson">
                         <el-select v-model="dataForm.maintainPerson" placeholder="---璇烽�夋嫨---" clearable >
                             <el-option
-                            v-for="item in maintainPerson"
+                            v-for="item in userList"
                             :key="item.id"
                             :label="item.label"
                             :value="item.value">
                             </el-option>
                         </el-select>
-                    </el-form-item>
-                </el-col>
-                <!-- <el-col :xs="24":sm="6":md="6":lg="6":xl="6">
-                    <el-form-item label="淇濆吇鍛ㄦ湡" prop="maintainPeriod">
-                        <el-input size="mini" type="text" v-model="dataForm.maintainPeriod"></el-input>
-                    </el-form-item>
-                </el-col>
-                <el-col :xs="24":sm="6":md="6":lg="6":xl="6">
-                    <el-form-item label="鎶曚骇鏃ユ湡" prop="productionDate">
-                        <el-input size="mini" type="text" v-model="dataForm.productionDate"></el-input>
-                    </el-form-item>
-                </el-col>
-                <el-col :xs="24":sm="6":md="6":lg="6":xl="6">
-                    <el-form-item label="鐢熶骇鍘傚" prop="manufacturer">
-                        <el-input size="mini" type="text" v-model="dataForm.manufacturer"></el-input>
-                    </el-form-item>
-                </el-col> -->
-                <el-col :xs="24":sm="6":md="6":lg="6":xl="6">
-                    <el-form-item label="璁″垝鐘舵��" prop="planStatus">
-                        <el-input size="mini" type="text" v-model="dataForm.planStatus" readonly></el-input>
                     </el-form-item>
                 </el-col>
                 <el-col :xs="24":sm="6":md="6":lg="6":xl="6">
@@ -97,32 +57,36 @@
                     </el-form-item>
                 </el-col>
                 <el-col :xs="24":sm="6":md="6":lg="6":xl="6">
+                    <el-form-item label="淇濆吇鍐呭涓庡瓨鍦ㄩ棶棰�" prop="detail">
+                        <el-input size="mini" type="text" v-model="dataForm.detail"></el-input>
+                    </el-form-item>
+                </el-col>
+                <el-col :xs="24":sm="6":md="6":lg="6":xl="6">
+                </el-col>
+                <el-col :xs="24":sm="10":md="10":lg="10":xl="10">
                     <el-form-item label="璁″垝寮�濮嬫棩鏈�" prop="planStartDate">
                         <el-date-picker
                         format="yyyy 骞� MM 鏈� dd 鏃�"
                         value-format="yyyy-MM-dd"
                         v-model="dataForm.planStartDate"
                         range-separator="鑷�"
+                        type="daterange"
                         start-placeholder="寮�濮嬫棩鏈�"
                         end-placeholder="缁撴潫鏃ユ湡">
                         </el-date-picker>
                     </el-form-item>
                 </el-col>
-                <el-col :xs="24":sm="6":md="6":lg="6":xl="6">
+                <el-col :xs="24":sm="10":md="10":lg="10":xl="10">
                     <el-form-item label="璁″垝瀹屾垚鏃ユ湡" prop="planFinishDate">
                         <el-date-picker
                         format="yyyy 骞� MM 鏈� dd 鏃�"
                         value-format="yyyy-MM-dd"
                         v-model="dataForm.planFinishDate"
                         range-separator="鑷�"
+                        type="daterange"
                         start-placeholder="寮�濮嬫棩鏈�"
                         end-placeholder="缁撴潫鏃ユ湡">
                         </el-date-picker>
-                    </el-form-item>
-                </el-col>
-                <el-col :xs="24":sm="6":md="6":lg="6":xl="6">
-                    <el-form-item label="淇濆吇鍐呭涓庡瓨鍦ㄩ棶棰�" prop="detail">
-                        <el-input size="mini" type="text" v-model="dataForm.detail"></el-input>
                     </el-form-item>
                 </el-col>
             </el-row>
@@ -140,32 +104,18 @@
 import { getMachineList, maintainCreate, maintainUpdate, userList, departmentGet } from '@/api/MdcApi'
 import { getRequest } from '@/api/Api'
 export default {
-  props: ['styles', 'departmentlist'],
+  props: ['styles', 'departmentlist','machineList','userList'],
   data() {
     return {
       dataForm: {
-        style: '鏃ュ父淇濆吇',
-        state: 1,
-        machineName: '', // 璁惧鍚嶇О
-        uuid: '', // 鍚屾剰缂栫爜
-        type: '', // 璁惧绫诲瀷
-        specification: '', // 璁惧瑙勬牸
-        location: '', // 瀹夎浣嶇疆
-        department: '', // 浣跨敤鍗曚綅
-        maintainPerson: '', // 淇濆吇鑰�
-        productionDate: '', // 鎶曚骇鏃ユ湡
-        manufacturer: '', // 鐢熶骇鍘傚
-        planStatus: '1', // 璁″垝鐘舵��
-        isQualified: '鍚堟牸',
-        planStartDate: '',
-        planFinishDate: '',
-        detail: '' // 淇濆吇鍐呭涓庡瓨鍦ㄩ棶棰�
+        machineId: '',
+        department: '',
+        maintainPerson: '',
+        isQualified: '',
+        detail: '',
       },
       dialogVisibleAdd: false,
       // 涓嬫媺妗�
-      machineName: [], // 璁惧鍚嶇О
-      department: [], // 浣跨敤閮ㄩ棬
-      maintainPerson: [], // 璁惧鍚嶇О
       isQualified: [{ // 鏄惁鍚堟牸
         label: '鍚堟牸',
         value: '鍚堟牸'
@@ -183,42 +133,16 @@
     init(n, data) {
       this.data = data
       this.no = n
-      if (this.styles === '1') {
-        this.dataForm.style = '鏃ュ父淇濆吇'
-      } else if (this.styles === '2') {
-        this.dataForm.style = '涓�绾т繚鍏�'
-      } else if (this.styles === '3') {
-        this.dataForm.style = '浜岀骇淇濆吇'
-      } else {
-        this.dataForm.style = '涓夌骇淇濆吇'
-      }
       if (n === 1) {
-        this.title = '鏂板' + this.dataForm.style
-        this.dataForm.machineName = ''
-        this.dataForm.uuid = ''
-        this.dataForm.type = ''
-        this.dataForm.specification = ''
-        this.dataForm.location = ''
-        this.dataForm.department = ''
-        this.dataForm.maintainPerson = ''
-        this.dataForm.productionDate = ''
-        this.dataForm.manufacturer = ''
-        this.dataForm.planStartDate = ''
-        this.dataForm.planFinishDate = ''
-        this.dataForm.isQualified = '鍚堟牸'
-        this.dataForm.detail = ''
+        this.title = '鏂板' + this.style
+        Object.keys(this.dataForm).forEach(key => {
+          this.dataForm[key] = ''
+        })
       } else {
-        this.title = '淇敼' + this.dataForm.styles
-        this.dataForm.machineName = this.data.machineName
-        this.dataForm.uuid = this.data.uuid
-        this.dataForm.type = this.data.type
-        this.dataForm.specification = this.data.specification
-        this.dataForm.location = this.data.location
-        this.dataForm.department = this.data.department
-        this.dataForm.maintainPerson = this.data.userName
-        this.dataForm.isQualified = this.data.isQualified === '0' ? '涓嶅悎鏍�' : '鍚堟牸'
-        this.dataForm.manufacturer = this.data.manufacturer
-        this.dataForm.detail = this.data.detail
+        this.title = '淇敼' + this.style
+        Object.keys(this.dataForm).forEach(key => {
+          this.dataForm[key] = data[key]
+        })
       }
       this.dialogVisibleAdd = true
       this.machineName = []
@@ -235,48 +159,65 @@
       const completeDateTo = this.dataForm.planFinishDate[1]
       const isQualified = this.dataForm.isQualified === '鍚堟牸' ? 1 : 0
       if (this.no === 1) {
-        getRequest('maintainCreate',{})
-        // maintainCreate(
-        //   this.styles, this.dataForm.uuid, this.dataForm.machineName, this.dataForm.type,
-        //   this.dataForm.specification, this.dataForm.department, this.dataForm.location,
-        //   startDateFrom, startDateTo, completeDateFrom, completeDateTo, isQualified,
-        //   this.dataForm.state, this.dataForm.detail
-        // ).then(res => {
-        //   if (res.result === 'SUCCESS') {
-        //     this.$message({
-        //       type: 'success',
-        //       message: '淇濆瓨鎴愬姛!'
-        //     })
-        //     this.$emit('reflash')
-        //     // const that = this
-        //     this.dialogVisibleAdd = false
-        //   } else {
-        //     this.$message({
-        //       type: 'error',
-        //       message: res.result
-        //     })
-        //   }
-        // })
+        console.log({
+          ...this.dataForm,
+          startDateFrom,
+          startDateTo,
+          completeDateFrom,
+          completeDateTo,
+          isQualified,
+          styles: this.style
+        })
+        // return
+        getRequest('maintainCreate',{
+          ...this.dataForm,
+          startDateFrom,
+          startDateTo,
+          completeDateFrom,
+          completeDateTo,
+          isQualified,
+          styles: this.style
+        }).then(res => {
+          if (res.result === 'SUCCESS') {
+            this.$message({
+              type: 'success',
+              message: '淇濆瓨鎴愬姛!'
+            })
+            this.$emit('reflash')
+            // const that = this
+            this.dialogVisibleAdd = false
+          } else {
+            this.$message({
+              type: 'error',
+              message: res.result
+            })
+          }
+        })
       } else {
-        getRequest('maintainUpdate',{})
-        // 淇敼淇濆瓨
-        // maintainUpdate(this.styles, this.data.id, this.dataForm.uuid, this.dataForm.machineName, this.dataForm.type,
-        //   this.dataForm.specification, this.dataForm.department, this.dataForm.location,
-        //   startDateFrom, startDateTo, completeDateFrom, completeDateTo, isQualified,
-        //   this.dataForm.state, this.dataForm.detail).then(res => {
-        //   if (res.result === 'SUCCESS') {
-        //     this.$message({
-        //       type: 'success',
-        //       message: '淇濆瓨鎴愬姛!'
-        //     })
-        //     this.$emit('reflash')
-        //   } else {
-        //     this.$message({
-        //       type: 'error',
-        //       message: res.result
-        //     })
-        //   }
-        // })
+        getRequest('maintainUpdate',{
+          ...this.dataForm,
+          startDateFrom,
+          startDateTo,
+          completeDateFrom,
+          completeDateTo,
+          isQualified,
+          styles: this.style
+        }).then(res => {
+          if (res.result === 'SUCCESS') {
+            this.$message({
+              type: 'success',
+              message: '淇濆瓨鎴愬姛!'
+            })
+            this.$emit('reflash')
+            // const that = this
+            this.dialogVisibleAdd = false
+          } else {
+            this.$message({
+              type: 'error',
+              message: res.result
+            })
+          }
+        })
       }
     },
     /**
@@ -288,7 +229,7 @@
     }
   },
   created() {
-    this.initDevices()
+    // this.initDevices()
   }
 }
 </script>

--
Gitblit v1.9.3