408249787 4 mesi fa
parent
commit
01ec4584b2
1 ha cambiato i file con 156 aggiunte e 148 eliminazioni
  1. 156 148
      src/views/check/checkstandard/modules/BaseForm.vue

+ 156 - 148
src/views/check/checkstandard/modules/BaseForm.vue

@@ -1,29 +1,16 @@
 <template>
-  <a-modal
-    :title="modalTitle"
-    :width="1200"
-    :visible="visible"
-    :confirmLoading="confirmLoading"
-    @cancel="handleCancel"
-  >
+  <a-modal :title="modalTitle" :width="1200" :visible="visible" :confirmLoading="confirmLoading" @cancel="handleCancel">
     <a-form :form="form">
-
       <a-form-item v-show="false">
-        <a-input v-decorator="['id']" type="hidden"/>
-        <a-input v-decorator="['sbId']" type="hidden"/>
-        <a-input v-decorator="['part']" type="hidden"/>
+        <a-input v-decorator="['id']" type="hidden" />
+        <a-input v-decorator="['sbId']" type="hidden" />
+        <a-input v-decorator="['part']" type="hidden" />
       </a-form-item>
 
       <row-list :col="2">
         <row-item>
-          <a-form-item
-            label="编码"
-            :labelCol="BaseTool.Constant.labelCol"
-            :wrapperCol="BaseTool.Constant.wrapperCol"
-          >
-            <a-input
-              disabled
-              v-decorator="['no', {rules: [{required: false, message: '编码不能为空'}]}]"/>
+          <a-form-item label="编码" :labelCol="BaseTool.Constant.labelCol" :wrapperCol="BaseTool.Constant.wrapperCol">
+            <a-input disabled v-decorator="['no', { rules: [{ required: false, message: '编码不能为空' }] }]" />
           </a-form-item>
         </row-item>
         <row-item>
@@ -35,7 +22,8 @@
             <a-input
               disabled
               style="width: 80%"
-              v-decorator="['sbNo', {rules: [{required: false, message: '请选择设备'}]}]"/>
+              v-decorator="['sbNo', { rules: [{ required: false, message: '请选择设备' }] }]"
+            />
             <a-button type="primary" style="width: 20%" @click="handleSbSelect">选择</a-button>
           </a-form-item>
         </row-item>
@@ -55,10 +43,7 @@
             :labelCol="BaseTool.Constant.labelCol"
             :wrapperCol="BaseTool.Constant.wrapperCol"
           >
-            <a-input
-              disabled
-              style="width: 80%"
-              v-decorator="['partName']"/>
+            <a-input disabled style="width: 80%" v-decorator="['partName']" />
             <a-button type="primary" style="width: 20%" @click="handlePartSelect">选择</a-button>
           </a-form-item>
         </row-item>
@@ -70,13 +55,11 @@
           >
             <a-select
               @change="changeLevel"
-              v-decorator="['level', {rules: [{required: true, message: '维护等级不能为空'}]}]"
-              placeholder="请选择">
-              <a-select-option
-                v-for="(label,value) in levelMap"
-                :key="value"
-                :label="label"
-                :value="parseInt(value)">{{ label }}
+              v-decorator="['level', { rules: [{ required: true, message: '维护等级不能为空' }] }]"
+              placeholder="请选择"
+            >
+              <a-select-option v-for="(label, value) in levelMap" :key="value" :label="label" :value="parseInt(value)"
+                >{{ label }}
               </a-select-option>
             </a-select>
           </a-form-item>
@@ -88,14 +71,15 @@
             :wrapperCol="BaseTool.Constant.wrapperCol"
           >
             <a-select
-              disabled
-              v-decorator="['checkUserType', {rules: [{required: true, message: '执行人方式不能为空'}]}]"
-              placeholder="请选择">
+              v-decorator="['checkUserType', { rules: [{ required: true, message: '执行人方式不能为空' }] }]"
+              placeholder="请选择"
+            >
               <a-select-option
-                v-for="(label,value) in checkUserTypeMap"
+                v-for="(label, value) in checkUserTypeMap"
                 :key="value"
                 :label="label"
-                :value="parseInt(value)">{{ label }}
+                :value="parseInt(value)"
+                >{{ label }}
               </a-select-option>
             </a-select>
           </a-form-item>
@@ -111,19 +95,20 @@
               <a-input-number
                 style="width: 100%"
                 :min="1"
-                v-decorator="['period', {rules: [{required: true, message: '计划周期不能为空'}]}]"/>
+                v-decorator="['period', { rules: [{ required: true, message: '计划周期不能为空' }] }]"
+              />
             </a-form-item>
-            <a-form-item
-              :style="{ display: 'inline-block', width: '30%' }"
-            >
+            <a-form-item :style="{ display: 'inline-block', width: '30%' }">
               <a-select
-                v-decorator="['periodType', {rules: [{required: true, message: '周期类型不能为空'}]}]"
-                placeholder="请选择">
+                v-decorator="['periodType', { rules: [{ required: true, message: '周期类型不能为空' }] }]"
+                placeholder="请选择"
+              >
                 <a-select-option
-                  v-for="(label,value) in periodTypeMap"
+                  v-for="(label, value) in periodTypeMap"
                   :key="value"
                   :label="label"
-                  :value="parseInt(value)">{{ label }}
+                  :value="parseInt(value)"
+                  >{{ label }}
                 </a-select-option>
               </a-select>
             </a-form-item>
@@ -135,9 +120,7 @@
             :labelCol="BaseTool.Constant.labelCol"
             :wrapperCol="BaseTool.Constant.wrapperCol"
           >
-            <a-input
-              v-decorator="['standardHours']"
-              suffix="小时"/>
+            <a-input v-decorator="['standardHours']" suffix="小时" />
           </a-form-item>
         </row-item>
         <!--        <row-item>
@@ -161,14 +144,11 @@
           </a-form-item>
         </row-item>-->
         <row-item>
-          <a-form-item
-            label="排序"
-            :labelCol="BaseTool.Constant.labelCol"
-            :wrapperCol="BaseTool.Constant.wrapperCol"
-          >
+          <a-form-item label="排序" :labelCol="BaseTool.Constant.labelCol" :wrapperCol="BaseTool.Constant.wrapperCol">
             <a-input-number
               :step="1"
-              v-decorator="['sort', {initialValue: 1,rules: [{required: true, message: '排序不能为空'}]}]"/>
+              v-decorator="['sort', { initialValue: 1, rules: [{ required: true, message: '排序不能为空' }] }]"
+            />
           </a-form-item>
         </row-item>
         <row-item>
@@ -178,13 +158,18 @@
             :wrapperCol="BaseTool.Constant.wrapperCol"
           >
             <a-select
-              v-decorator="['actionType', {initialValue: 1,rules: [{required: true, message: '是否启用不能为空'}]}]"
-              placeholder="请选择">
+              v-decorator="[
+                'actionType',
+                { initialValue: 1, rules: [{ required: true, message: '是否启用不能为空' }] }
+              ]"
+              placeholder="请选择"
+            >
               <a-select-option
-                v-for="(label,value) in actionTypeMap"
+                v-for="(label, value) in actionTypeMap"
                 :key="value"
                 :label="label"
-                :value="parseInt(value)">{{ label }}
+                :value="parseInt(value)"
+                >{{ label }}
               </a-select-option>
             </a-select>
           </a-form-item>
@@ -219,7 +204,8 @@
             <a-date-picker
               style="width: 100%"
               :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
-              v-decorator="['lastDate']" />
+              v-decorator="['lastDate']"
+            />
           </a-form-item>
         </row-item>
         <row-item>
@@ -232,7 +218,8 @@
               disabled
               style="width: 100%"
               :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
-              v-decorator="['nextDate']" />
+              v-decorator="['nextDate']"
+            />
           </a-form-item>
         </row-item>
       </row-list>
@@ -245,7 +232,8 @@
           >
             <a-textarea
               :rows="4"
-              v-decorator="['requirement', {rules: [{required: true, message: '检查项目不能为空'}]}]"/>
+              v-decorator="['requirement', { rules: [{ required: true, message: '检查项目不能为空' }] }]"
+            />
           </a-form-item>
         </row-item>
         <row-item>
@@ -256,17 +244,14 @@
           >
             <a-textarea
               :rows="4"
-              v-decorator="['remark', {rules: [{required: false, message: '操作说明及标准不能为空'}]}]"/>
+              v-decorator="['remark', { rules: [{ required: false, message: '操作说明及标准不能为空' }] }]"
+            />
           </a-form-item>
         </row-item>
       </row-list>
       <row-list :col="2">
         <row-item>
-          <a-form-item
-            label="图片"
-            :labelCol="BaseTool.Constant.labelCol"
-            :wrapperCol="BaseTool.Constant.wrapperCol"
-          >
+          <a-form-item label="图片" :labelCol="BaseTool.Constant.labelCol" :wrapperCol="BaseTool.Constant.wrapperCol">
             <a-upload
               :action="uploadUrl"
               :multiple="true"
@@ -281,11 +266,7 @@
           </a-form-item>
         </row-item>
         <row-item>
-          <a-form-item
-            label="文件"
-            :labelCol="BaseTool.Constant.labelCol"
-            :wrapperCol="BaseTool.Constant.wrapperCol"
-          >
+          <a-form-item label="文件" :labelCol="BaseTool.Constant.labelCol" :wrapperCol="BaseTool.Constant.wrapperCol">
             <a-upload
               :action="uploadUrl"
               :multiple="true"
@@ -302,11 +283,11 @@
     <title-divider title="关联备件" width="100px"></title-divider>
     <div class="table-operator">
       <a-button style="margin-left:8px;" type="primary" @click="handleSpareSelect">
-        <a-icon type="plus"/>
+        <a-icon type="plus" />
         添加
       </a-button>
       <a-button class="margin-left8" size="small" type="danger" @click="handleDel">
-        <a-icon type="delete"/>
+        <a-icon type="delete" />
         删除
       </a-button>
     </div>
@@ -317,10 +298,15 @@
       ref="table"
       tableLayout="auto"
       :row-selection="rowSelection"
-      rowKey="bomId">
+      rowKey="bomId"
+    >
       <template slot="num" slot-scope="text, record">
         <div class="editable-cell-input-wrapper">
-          <a-input :value="text" :id="record.spareId + ',num'" @change="$event => onQuantityChange($event, record.id, 'num')" />
+          <a-input
+            :value="text"
+            :id="record.spareId + ',num'"
+            @change="$event => onQuantityChange($event, record.id, 'num')"
+          />
         </div>
       </template>
       <span slot="action" slot-scope="record">
@@ -336,9 +322,9 @@
     <template slot="footer">
       <a-button :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
     </template>
-    <part-info-select-modal ref="partInfoSelectModal" @selected="handlePartSelected"/>
-    <sb-info-select-modal ref="sbInfoSelectModal" @selected="handleSbSelectd"/>
-    <spare-part-info-select-modal-sb-info :type="'checkbox'" ref="spareSelectModal" @selected="handleSpareSelected"/>
+    <part-info-select-modal ref="partInfoSelectModal" @selected="handlePartSelected" />
+    <sb-info-select-modal ref="sbInfoSelectModal" @selected="handleSbSelectd" />
+    <spare-part-info-select-modal-sb-info :type="'checkbox'" ref="spareSelectModal" @selected="handleSpareSelected" />
   </a-modal>
 </template>
 
@@ -363,7 +349,7 @@ export default {
     PartInfoSelectModal,
     SparePartInfoSelectModalSbInfo
   },
-  data () {
+  data() {
     return {
       confirmLoading: false,
       modalTitle: null,
@@ -440,7 +426,7 @@ export default {
       default: 2
     }
   },
-  created () {
+  created() {
     // 下拉框map
     this.paramTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_STANDARD_PARAM_TYPE)
     this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_STANDARD_TYPE)
@@ -451,7 +437,7 @@ export default {
     this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_LEVEL)
   },
   methods: {
-    base (record, sbId, sbNo) {
+    base(record, sbId, sbNo) {
       this.visible = true
       this.selectedRowKeys = []
       this.selectedRows = []
@@ -466,7 +452,9 @@ export default {
         this.cacheData = []
         if (sbId != null) {
           this.sbId = sbId
-          const { form: { setFieldsValue } } = this
+          const {
+            form: { setFieldsValue }
+          } = this
           // 日期处理
           this.$nextTick(() => {
             setFieldsValue({ sbId: sbId, sbNo: sbNo })
@@ -489,17 +477,13 @@ export default {
       if (record.lastDate != null) {
         record.lastDate = this.BaseTool.Moment(record.lastDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
         this.$nextTick(() => {
-          setFieldsValue(Object.assign(pick(record, [
-            'lastDate'
-          ])))
+          setFieldsValue(Object.assign(pick(record, ['lastDate'])))
         })
       }
       if (record.nextDate != null) {
         record.nextDate = this.BaseTool.Moment(record.nextDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
         this.$nextTick(() => {
-          setFieldsValue(Object.assign(pick(record, [
-            'nextDate'
-          ])))
+          setFieldsValue(Object.assign(pick(record, ['nextDate'])))
         })
       }
       if (this.checkImgList == null) {
@@ -508,35 +492,43 @@ export default {
       if (this.checkImgList == null) {
         this.defaultCheckFileList = this.BaseTool.UPLOAD.transImg(this.checkFileList)
       }
-      const { form: { setFieldsValue } } = this
+      const {
+        form: { setFieldsValue }
+      } = this
       // 日期处理
       this.$nextTick(() => {
-        setFieldsValue(Object.assign(pick(record, [
-          'id',
-          'sbId',
-          'sbNo',
-          'name',
-          // 'no',
-          // 'type',
-          'period',
-          'level',
-          'part',
-          'partName',
-          'checkUserType',
-          'checkUserId',
-          'periodType',
-          'standardHours',
-          // 'actionType',
-          // 'enable',
-          'requirement',
-          'nextDate',
-          'lastDate',
-          'remark'
-        ])))
+        setFieldsValue(
+          Object.assign(
+            pick(record, [
+              'id',
+              'sbId',
+              'sbNo',
+              'name',
+              // 'no',
+              // 'type',
+              'period',
+              'level',
+              'part',
+              'partName',
+              'checkUserType',
+              'checkUserId',
+              'periodType',
+              'standardHours',
+              // 'actionType',
+              // 'enable',
+              'requirement',
+              'nextDate',
+              'lastDate',
+              'remark'
+            ])
+          )
+        )
       })
     },
-    save () {
-      const { form: { validateFieldsAndScroll } } = this
+    save() {
+      const {
+        form: { validateFieldsAndScroll }
+      } = this
       this.confirmLoading = true
       validateFieldsAndScroll((errors, values) => {
         if (errors) {
@@ -546,8 +538,12 @@ export default {
         // 上传文件
         values.checkImgList = this.checkImgList
         values.checkFileList = this.checkFileList
-        values.nextDate = values.nextDate ? this.BaseTool.Date.formatter(values.nextDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
-        values.lastDate = values.lastDate ? this.BaseTool.Date.formatter(values.lastDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) : null
+        values.nextDate = values.nextDate
+          ? this.BaseTool.Date.formatter(values.nextDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
+          : null
+        values.lastDate = values.lastDate
+          ? this.BaseTool.Date.formatter(values.lastDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
+          : null
 
         // 备件列表
         values.detailList = this.data
@@ -555,20 +551,22 @@ export default {
           addCheckStandard(values)
             .then(() => {
               this.handleCancel(values)
-            }).catch(() => {
+            })
+            .catch(() => {
               this.confirmLoading = false
             })
         } else {
           updateCheckStandard(values)
             .then(() => {
               this.handleCancel(values)
-            }).catch(() => {
+            })
+            .catch(() => {
               this.confirmLoading = false
             })
         }
       })
     },
-    handleCancel (values) {
+    handleCancel(values) {
       this.visible = false
       this.data = []
       this.confirmLoading = false
@@ -579,51 +577,59 @@ export default {
         this.$emit('ok', values)
       }
     },
-    handleSbSelect () {
+    handleSbSelect() {
       this.$refs.sbInfoSelectModal.base()
     },
-    handleSbSelectd (keys, rows) {
-      const [ key ] = keys
-      const [ row ] = rows
-      const { form: { setFieldsValue } } = this
+    handleSbSelectd(keys, rows) {
+      const [key] = keys
+      const [row] = rows
+      const {
+        form: { setFieldsValue }
+      } = this
       this.sbId = key
       // 日期处理
       this.$nextTick(() => {
-        setFieldsValue(Object.assign({
-          'sbId': key,
-          'sbNo': row.no,
-          'part': null,
-          'partName': null
-        }))
+        setFieldsValue(
+          Object.assign({
+            sbId: key,
+            sbNo: row.no,
+            part: null,
+            partName: null
+          })
+        )
       })
     },
-    handlePartSelect () {
+    handlePartSelect() {
       const sbId = this.form.getFieldValue('sbId')
       if (this.BaseTool.Object.isBlank(sbId)) {
         this.$message.error('请先选择设备')
       }
       this.$refs.partInfoSelectModal.base({ sbId })
     },
-    handlePartSelected (keys, rows) {
-      const [ key ] = keys
-      const [ row ] = rows
-      const { form: { setFieldsValue } } = this
+    handlePartSelected(keys, rows) {
+      const [key] = keys
+      const [row] = rows
+      const {
+        form: { setFieldsValue }
+      } = this
       this.$nextTick(() => {
-        setFieldsValue(Object.assign({
-          'part': key,
-          'partName': row.name
-        }))
+        setFieldsValue(
+          Object.assign({
+            part: key,
+            partName: row.name
+          })
+        )
       })
     },
-    handleCheckImgChange (info) {
+    handleCheckImgChange(info) {
       this.defaultCheckImgList = info.fileList
       this.checkImgList = this.setFileList(info, 1)
     },
-    handleCheckFileChange (info) {
+    handleCheckFileChange(info) {
       this.defaultCheckFileList = info.fileList
       this.checkFileList = this.setFileList(info, 2)
     },
-    setFileList (info, type) {
+    setFileList(info, type) {
       const file = info.file
       const fileList = info.fileList
       if (file.status === 'done') {
@@ -635,10 +641,10 @@ export default {
         return null
       }
     },
-    handleSpareSelect () {
+    handleSpareSelect() {
       this.$refs.spareSelectModal.base(null, { sbId: this.sbId })
     },
-    handleSpareSelected (record, keys, rows) {
+    handleSpareSelected(record, keys, rows) {
       const addData = []
       for (let i = 0; i < rows.length; i++) {
         addData.push({ sbId: this.sbId, spareId: rows[i].id, spareName: rows[i].name, num: 1 })
@@ -664,7 +670,7 @@ export default {
         }
       }
     },
-    handleDel () {
+    handleDel() {
       const data = [...this.data]
       if (this.selectedRowKeys.length === 0) {
         this.$message.error('请至少选择一条数据')
@@ -672,19 +678,21 @@ export default {
       }
       this.data = data.filter(item => !this.selectedRowKeys.includes(item.bomId))
     },
-    handleDelOne (record) {
+    handleDelOne(record) {
       const data = [...this.data]
       this.data = data.filter(item => record.bomId !== item.bomId)
     },
-    changeLevel (value) {
+    changeLevel(value) {
       this.level = value
-      const { form: { setFieldsValue } } = this
+      const {
+        form: { setFieldsValue }
+      } = this
       // 日期处理
       this.$nextTick(() => {
         setFieldsValue({ checkUserType: value })
       })
     },
-    onQuantityChange (e, id, attr) {
+    onQuantityChange(e, id, attr) {
       const value = e.target.value
       console.log(value)
       if (value !== 0 && !value) {