From 92ff846fb659c62037a32b1d8c15eae9df9d9b54 Mon Sep 17 00:00:00 2001
From: zenglf <18502938215@163.com>
Date: 星期一, 18 九月 2023 13:24:30 +0800
Subject: [PATCH] Merge branch 'develop' of http://117.34.109.166:18448/r/vue_mdc_430

---
 src/views/eam/modules/equipmentDisposal/EquipmentDisposalForm.vue |  532 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 532 insertions(+), 0 deletions(-)

diff --git a/src/views/eam/modules/equipmentDisposal/EquipmentDisposalForm.vue b/src/views/eam/modules/equipmentDisposal/EquipmentDisposalForm.vue
new file mode 100644
index 0000000..3397507
--- /dev/null
+++ b/src/views/eam/modules/equipmentDisposal/EquipmentDisposalForm.vue
@@ -0,0 +1,532 @@
+<template>
+  <a-spin :spinning="confirmLoading">
+    <j-form-container :disabled="formDisabled">
+      <!-- 涓昏〃鍗曞尯鍩� -->
+      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
+        <a-row>
+          <a-col :span="24">
+            <a-form-model-item label="鍗曟嵁鍙�" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="num">
+              <a-input v-model="model.num" placeholder="璇疯緭鍏ュ崟鎹彿"></a-input>
+            </a-form-model-item>
+          </a-col>
+          <!--          (灏佸瓨-seal锛屽惎灏�-unseal,鎶ュ簾-scrap锛屽缃�-disposal)-->
+          <!--          type ="hidden"-->
+          <a-col :span="24" hidden>
+            <a-form-model-item label="鍙樺姩鏂瑰紡" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="changeMethod">
+              <a-input v-model="model.changeMethod" defaultValue="disposal"></a-input>
+            </a-form-model-item>
+          </a-col>
+          <a-col :span="24">
+            <a-form-model-item label="澶囨敞" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
+              <a-textarea v-model="model.remark" rows="4" placeholder="璇疯緭鍏ュ娉�" />
+            </a-form-model-item>
+          </a-col>
+        </a-row>
+      </a-form-model>
+    </j-form-container>
+    <!--    <a-button-->
+    <!--      type="primary"-->
+    <!--      :style="{ marginRight: '8px',marginBottom:'8px' }"-->
+    <!--      :loading="confirmLoading"-->
+    <!--      @click="selectEquipmentList()"-->
+    <!--    >閫夋嫨璁惧-->
+    <!--    </a-button>-->
+    <!-- 瀛愯〃鍗曞尯鍩� -->
+    <a-tabs v-model="activeKey" @change="handleChangeTabs">
+      <a-tab-pane tab="璁惧澶勭疆鏄庣粏" :key="refKeys[0]" :forceRender="true">
+        <j-vxe-table
+          keep-source
+          :ref="refKeys[0]"
+          :loading="equipmentDisposalDetailTable.loading"
+          :columns="equipmentDisposalDetailTable.columns"
+          :dataSource="equipmentDisposalDetailTable.dataSource"
+          :maxHeight="800"
+          :disabled="formDisabled"
+          :rowNumber="true"
+          :rowSelection="true"
+          :bordered="true"
+          :alwaysEdit="true"
+          :toolbar="true"
+          :toolbarConfig="toolbarConfig"
+        >
+
+        <!-- 璁惧鍥剧墖鎻掓Ы -->
+        <template v-slot:equipmentPhoto='props'>
+            <Tooltip
+          placement="top"
+          title="棰勮鍥剧墖"
+          >
+            <span v-if="!text" style="font-size: 12px;font-style: italic;">鏃犲浘鐗�</span>
+            <img v-else :src="getImgView(text)" :preview="props.rowId" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
+          </Tooltip>
+          </template>
+          <template v-slot:action="props">
+            <a-popconfirm title="纭畾鍒犻櫎鍚楋紵" @confirm="handleDL(props)">
+              <a>鍒犻櫎</a>
+            </a-popconfirm>
+          </template>
+          <template slot="toolbarPrefix">
+            <a-button type="primary" @click="selectEquipmentList" :disabled="formDisabled">閫夋嫨璁惧
+            </a-button>
+          </template>
+        </j-vxe-table>
+      </a-tab-pane>
+    </a-tabs>
+
+    <equipment-select-modal ref="EquipmentSelectModal"></equipment-select-modal>
+  </a-spin>
+</template>
+
+<script>
+
+import { getAction } from '@/api/manage'
+import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js'
+import { JVXETypes } from '@/components/jeecg/JVxeTable'
+import { getRefPromise, VALIDATE_FAILED } from '@/components/jeecg/JVxeTable/utils/vxeUtils.js'
+import { validateDuplicateValue } from '@/utils/util'
+import JFormContainer from '@/components/jeecg/JFormContainer'
+import EquipmentSelectModal from '../equipmentScrap/EquipmentSelectModal.vue'
+
+export default {
+  name: 'EquipmentDisposalForm',
+  mixins: [JVxeTableModelMixin],
+  components: {
+    JFormContainer,
+    EquipmentSelectModal
+  },
+  data() {
+    return {
+      changeMethod: 'disposal',
+      toolbarConfig: {
+        // prefix 鍓嶇紑锛泂uffix 鍚庣紑
+        slot: ['prefix', 'suffix'],
+        // add 鏂板鎸夐挳锛況emove 鍒犻櫎鎸夐挳锛沜learSelection 娓呯┖閫夋嫨鎸夐挳
+        btn: ['remove', 'clearSelection']
+      },
+      labelCol: {
+        xs: { span: 24 },
+        sm: { span: 5 }
+      },
+      wrapperCol: {
+        xs: { span: 24 },
+        sm: { span: 16 }
+      },
+      model: {},
+      // 鏂板鏃跺瓙琛ㄩ粯璁ゆ坊鍔犲嚑琛岀┖鏁版嵁
+      addDefaultRowNum: 0,
+      validatorRules: {
+        num: [
+          { required: true, message: '璇疯緭鍏ュ崟鎹彿!' },
+          { validator: (rule, value, callback) => validateDuplicateValue('mom_eam_equipment_change', 'num', value, this.model.id, callback) }
+        ],
+        remark: [
+          { required: false, message: '璇疯緭鍏ュ娉�!' }
+        ]
+      },
+      refKeys: ['equipmentDisposalDetail'],
+      tableKeys: ['equipmentDisposalDetail'],
+      activeKey: 'equipmentDisposalDetail',
+      // 璁惧澶勭疆鏄庣粏
+      equipmentDisposalDetailTable: {
+        loading: false,
+        dataSource: [],
+        columns: [
+          {
+            title: '璁惧澶勭疆鏄庣粏id',
+            key: 'id',
+            type: JVXETypes.hidden,
+            width: '100px',
+            align:"center",
+          },
+          {
+            title: '璁惧鍙樺姩鍗昳d',
+            key: 'equipmentChangeId',
+            type: JVXETypes.hidden,
+            width: '200px',
+            placeholder: '璇疯緭鍏�${title}',
+            align:"center",
+            defaultValue: ''
+          },
+          {
+            title: '璁惧ID',
+            key: 'equipmentId',
+            type: JVXETypes.hidden,
+            disabled: true,
+            width: '60px',
+            placeholder: '璇疯緭鍏�${title}',
+            align:"center",
+            defaultValue: ''
+          },
+          {
+            title: '璁惧缂栫爜',
+            key: 'equipmentNum',
+            type: JVXETypes.normal,
+            disabled: true,
+            width: '200px',
+            align:"center",
+            defaultValue: '',
+          },
+          {
+            title: '璁惧鍚嶇О',
+            key: 'equipmentName',
+            type: JVXETypes.normal,
+            disabled: true,
+            width: '200px',
+            align:"center",
+            defaultValue: '',
+            // fixed: 'left'
+          },
+          {
+            title: '璁惧鍨嬪彿',
+            key: 'model',
+            type: JVXETypes.normal,
+            disabled: true,
+            width: '200px',
+            align:"center",
+            defaultValue: ''
+          },
+          {
+            title: '璁惧瑙勬牸',
+            key: 'specification',
+            type: JVXETypes.normal,
+            disabled: true,
+            width: '200px',
+            align:"center",
+            defaultValue: ''
+          },
+          {
+            title: '璁惧鐘舵��',
+            key: 'equipmentStatus_dictText',
+            type: JVXETypes.normal,
+            disabled: true,
+            width: '195px',
+            align:"center",
+            defaultValue: ''
+          },
+          {
+            title: '璁惧浣嶇疆',
+            key: 'location',
+            type: JVXETypes.normal,
+            disabled: true,
+            width: '195px',
+            align:"center",
+            defaultValue: ''
+          },
+          {
+            title: '鐗圭璁惧',
+            key: 'specificEquipment',
+            type: JVXETypes.hidden,
+            align:"center",
+            disabled: true,
+            width: '200px',
+            // placeholder: '璇疯緭鍏�${title}',
+            defaultValue: ''
+          },
+          {
+            title: '鐗圭璁惧',
+            key: 'specificEquipment_dictText',
+            type: JVXETypes.normal,
+            disabled: true,
+            width: '200px',
+            align:"center",
+            defaultValue: ''
+          },
+          {
+            title: '璧勪骇缂栫爜',
+            key: 'assetNumber',
+            type: JVXETypes.normal,
+            disabled: true,
+            width: '195px',
+            align:"center",
+            defaultValue: '',
+          },
+          {
+            title: '澶勭疆鍘熷洜',
+            key: 'disposalReason',
+            type: JVXETypes.input,
+            align:"center",
+            width: '195px',
+            placeholder: '璇疯緭鍏�${title}',
+            defaultValue: '',
+            validateRules: [
+              {
+                required: true, // 蹇呭~
+                message: '璇疯緭鍏�${title}' // 鏄剧ず鐨勬枃鏈�
+              }]
+          },
+          {
+            title: '澶勭疆鏃ユ湡',
+            key: 'disposalDate',
+            type: JVXETypes.datetime,
+            align:"center",
+            width: '200px',
+            placeholder: '璇疯緭鍏�${title}',
+            defaultValue: '',
+            validateRules: [
+              {
+                required: true // 蹇呭~
+                // message: '璇疯緭鍏�${title}' // 鏄剧ず鐨勬枃鏈�
+              }
+              // {
+              //   // 鑷畾涔夊嚱鏁版牎楠� handler
+              //   handler(type, value, row, column, callback, target) {
+              //     // type 瑙﹀彂鏍¢獙鐨勭被鍨嬶紙input銆乧hange銆乥lur銆乬etValues锛�
+              //     // value 褰撳墠鏍¢獙鐨勫��
+              //     // callback(flag, message) 鏂规硶蹇呴』鎵ц涓斿彧鑳芥墽琛屼竴娆�
+              //     //          flag = 鏄惁閫氳繃浜嗘牎楠岋紝涓嶅~鍐欐垨鑰呭~鍐� null 浠h〃涓嶈繘琛屼换浣曟搷浣�
+              //     //          message = 鎻愮ず鐨勬秷鎭紝榛樿浣跨敤閰嶇疆鐨� message
+              //     // target 琛岀紪杈戠殑瀹炰緥瀵硅薄
+              //
+              //     if (type === 'blur' || type === 'getValues') {
+              //       let { values } = target.getValuesSync({ validate: false })
+              //       // let count = 0
+              //       // for (let val of values) {
+              //       //   if (val['dbFieldName'] === value) {
+              //       //     if (++count >= 2) {
+              //       //       callback(false, '${title}涓嶈兘閲嶅')
+              //       //       return
+              //       //     }
+              //       //   }
+              //       // }
+              //       callback(true) // true = 閫氳繃楠岃瘉
+              //     } else {
+              //       callback() // 涓嶅~鍐欐垨鑰呭~鍐� null 浠h〃涓嶈繘琛屼换浣曟搷浣�
+              //     }
+              //   },
+              //   message: '${title}榛樿鎻愮ず'
+              // }
+            ]
+          },
+          {
+            title: '鍑忓皯鏂瑰紡',
+            key: 'reduceMethod',
+            type: JVXETypes.selectDictSearch,
+            disabled: true,
+            width: '200px',
+            align:"center",
+            defaultValue: '',
+            dict:'mom_eam_transfer_method,name,id'
+          },
+          // {
+          //   title: '鐗圭璁惧',
+          //   key: 'specificEquipment',
+          //   type: JVXETypes.select,
+          //   options: [],
+          //   dictCode: 'specific_equipment',
+          //   disabled: true,
+          //   width: '200px',
+          //   // placeholder: '璇疯緭鍏�${title}',
+          //   defaultValue: ''
+          // },
+          // {
+          //   title: '璁惧鐘舵��',
+          //   key: 'equipmentStatus',
+          //   type: JVXETypes.select,
+          //   options: [],
+          //   dictCode: 'equipment_status',
+          //   disabled: true,
+          //   width: '200px',
+          //   // placeholder: '璇疯緭鍏�${title}',
+          //   defaultValue: ''
+          // },
+          {
+            title: '鎶�鏈姸鎬�',
+            key: 'technologyStatus_dictText',
+            type: JVXETypes.normal,
+            disabled: true,
+            width: '200px',
+            align:"center",
+            defaultValue: ''
+          },
+          // {
+          //   title: '鎶�鏈姸鎬�',
+          //   key: 'technologyStatus',
+          //   type: JVXETypes.select,
+          //   options: [],
+          //   dictCode: 'technology_status',
+          //   disabled: true,
+          //   width: '200px',
+          //   // placeholder: '璇疯緭鍏�${title}',
+          //   defaultValue: ''
+          // },
+          {
+            title: '閲嶈搴�',
+            key: 'equipmentImportanceId_dictText',
+            type: JVXETypes.normal,
+            disabled: true,
+            width: '195px',
+            align:"center",
+            defaultValue: ''
+          },
+         
+          // {
+          //   title: '閲嶈搴�',
+          //   key: 'equipmentImportanceId',
+          //   type: JVXETypes.input,
+          //   disabled: true,
+          //   width: '200px',
+          //   // placeholder: '璇疯緭鍏�${title}',
+          //   defaultValue: ''
+          // },
+          // {
+          //   title: '璁惧鍥剧墖',
+          //   key: 'equipmentPhoto',
+          //   type: JVXETypes.normal,
+          //   width: '200px',
+          //   // placeholder: '璇疯緭鍏�${title}',
+          //   defaultValue: ''
+          // }
+          // {
+          //   title: '璁惧鍥剧墖',
+          //   key: 'equipmentPhoto',
+          //   type: JVXETypes.slot,
+          //   disabled: true,
+          //   width: '120px',
+          //   slotName:'equipmentPhoto'
+
+          // },
+          // {
+          //   title: '鎿嶄綔',
+          //   key: 'action',
+          //   type: JVXETypes.slot,
+          //   disabled: true,
+          //   width: '100px',
+          //   align:"center",
+          //   slotName: 'action',
+          // },
+
+        ]
+      },
+      url: {
+        add: '/eam/equipmentDisposal/add',
+        edit: '/eam/equipmentDisposal/edit',
+        queryById: '/eam/equipmentDisposal/queryById',
+        equipmentDisposalDetail: {
+          list: '/eam/equipmentDisposal/listEquipmentDisposalDetailByMainId'
+        }
+      }
+    }
+  },
+  props: {
+    //琛ㄥ崟绂佺敤
+    disabled: {
+      type: Boolean,
+      default: false,
+      required: false
+    }
+  },
+  computed: {
+    formDisabled() {
+      return this.disabled
+    }
+  },
+  mounted() {
+    this.$bus.$on('selectionRows', (data) => {
+      // 澧炲姞閫変腑鐨勮澶囧埌鍒楄〃涓�
+      this.addSelectedEquipments(data)
+
+    })
+  },
+  created() {
+  },
+  methods: {
+
+    //閫夋嫨璁惧
+    selectEquipmentList() {
+      let ids = []
+      let tableData = this.$refs.equipmentDisposalDetail.getTableData()
+      let deleteData = this.$refs.equipmentDisposalDetail.getDeleteData()
+      for (let i = 0; i < tableData.length; i++) {
+        ids.push(tableData[i].equipmentId)
+      }
+      this.$refs.EquipmentSelectModal.showModals(ids)
+      this.$refs.EquipmentSelectModal.title = '閫夋嫨璁惧'
+      this.$refs.EquipmentSelectModal.disableSubmit = false
+    },
+    addSelectedEquipments(data) {
+      let tableData = this.$refs.equipmentDisposalDetail.getTableData()
+      // const seletedEquipmentIds = tableData.
+      var tableStr = JSON.stringify(tableData)
+      const addRows = []
+      for (let i = 0; i < data.length; i++) {
+        var scrapDetail = {}
+        if (tableStr.indexOf(data[i].id)==-1) {
+          scrapDetail = {
+            equipmentId: data[i].id,
+            equipmentNum: data[i].num,
+            equipmentName: data[i].name,
+            assetNumber: data[i].assetNumber,
+            specificEquipment_dictText: data[i].specificEquipment_dictText,
+            specificEquipment: data[i].specificEquipment,
+            model: data[i].model,
+            specification: data[i].specification,
+            equipmentStatus_dictText: data[i].equipmentStatus_dictText,
+            equipmentStatus: data[i].equipmentStatus,
+            technologyStatus_dictText: data[i].technologyStatus_dictText,
+            technologyStatus: data[i].technologyStatus,
+            equipmentPhoto: data[i].equipmentPhoto,
+            location: data[i].location,
+            equipmentImportanceId_dictText: data[i].equipmentImportanceId_dictText,
+            equipmentImportanceId: data[i].equipmentImportanceId
+          }
+        }
+        addRows.push(scrapDetail)
+      }
+
+      this.$refs.equipmentDisposalDetail.pushRows(addRows)
+    },
+    handleDL(props) {
+        // 璋冪敤鍒犻櫎鏂规硶
+        props.target.removeRows(props.row)
+      },
+    addBefore() {
+      this.equipmentDisposalDetailTable.dataSource = []
+    },
+    getAllTable() {
+      let values = this.tableKeys.map(key => getRefPromise(this, key))
+      return Promise.all(values)
+    },
+    /** 璋冪敤瀹宔dit()鏂规硶涔嬪悗浼氳嚜鍔ㄨ皟鐢ㄦ鏂规硶 */
+    editAfter() {
+      this.$nextTick(() => {
+      })
+      // 鍔犺浇瀛愯〃鏁版嵁
+      if (this.model.id) {
+        let params = { equipmentChangeId: this.model.id }
+        this.requestSubTableData(this.url.equipmentDisposalDetail.list, params, this.equipmentDisposalDetailTable)
+      }
+    },
+    //鏍¢獙鎵�鏈変竴瀵逛竴瀛愯〃琛ㄥ崟
+    validateSubForm(allValues) {
+      return new Promise((resolve, reject) => {
+        Promise.all([]).then(() => {
+          resolve(allValues)
+        }).catch(e => {
+          if (e.error === VALIDATE_FAILED) {
+            // 濡傛灉鏈夋湭閫氳繃琛ㄥ崟楠岃瘉鐨勫瓙琛紝灏辫嚜鍔ㄨ烦杞埌瀹冩墍鍦ㄧ殑tab
+            this.activeKey = e.index == null ? this.activeKey : this.refKeys[e.index]
+          } else {
+            console.error(e)
+          }
+        })
+      })
+    },
+    /** 鏁寸悊鎴恌ormData */
+    classifyIntoFormData(allValues) {
+      let main = Object.assign(this.model, allValues.formValue)
+      // this.main.changeMethod = this.changeMethod
+      return {
+        ...main, // 灞曞紑
+        equipmentDisposalDetailList: allValues.tablesValue[0].tableData
+      }
+    },
+    validateError(msg) {
+      this.$message.error(msg)
+    }
+
+  }
+}
+</script>
+
+<style scoped>
+</style>
\ No newline at end of file

--
Gitblit v1.9.3