From f058c1e6949fb494214f006c5770187efc5f5ab1 Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期二, 29 四月 2025 13:30:36 +0800
Subject: [PATCH] art: 设备管理-设备台账-设备工艺参数添加

---
 src/views/eam/equipment/modules/EamEquipmentProcessList.vue |  278 ++++++++++++++++++++++++++++++++++++++++++++++
 src/views/eam/equipment/EamEquipmentList.vue                |   55 +++++++--
 2 files changed, 321 insertions(+), 12 deletions(-)

diff --git a/src/views/eam/equipment/EamEquipmentList.vue b/src/views/eam/equipment/EamEquipmentList.vue
index e136054..410007b 100644
--- a/src/views/eam/equipment/EamEquipmentList.vue
+++ b/src/views/eam/equipment/EamEquipmentList.vue
@@ -85,10 +85,10 @@
       <a-button type="primary" icon="download" @click="handleTemplateXlsDownload">瀵煎叆妯℃澘涓嬭浇</a-button>
       <a-dropdown v-if="selectedRowKeys.length > 0">
         <a-menu slot="overlay">
-          <a-menu-item key="1" @click="handleOpenNameplateModal(selectionRows)">
-            <a-icon type="printer"/>
-            鎵撳嵃閾墝
-          </a-menu-item>
+<!--          <a-menu-item key="1" @click="handleOpenNameplateModal(selectionRows)">-->
+<!--            <a-icon type="printer"/>-->
+<!--            鎵撳嵃閾墝-->
+<!--          </a-menu-item>-->
           <a-menu-item key="2" @click="batchDel" v-if="isShowAuth('eam:equipment:delete')">
             <a-icon type="delete"/>
             鍒犻櫎
@@ -143,9 +143,9 @@
           <a-dropdown>
             <a class="ant-dropdown-link">鏇村 <a-icon type="down"/></a>
             <a-menu slot="overlay">
-              <a-menu-item>
-                <a href="javascript:;" @click="handleOpenNameplateModal([record])">閾墝</a>
-              </a-menu-item>
+<!--              <a-menu-item>-->
+<!--                <a href="javascript:;" @click="handleOpenNameplateModal([record])">閾墝</a>-->
+<!--              </a-menu-item>-->
               <a-menu-item>
                 <a href="javascript:;" @click="handleOpenResumeDrawer(record)">灞ュ巻</a>
               </a-menu-item>
@@ -181,6 +181,12 @@
       <a-tab-pane tab="淇濆吇鏍囧噯" :key="5">
         <eam-maintenance-standard-list ref="tabPaneTableListRef5" :isDisplayOperation="false"/>
       </a-tab-pane>
+      <a-tab-pane tab="宸ヨ壓鍙傛暟" :key="6" v-if="isOpenProcess">
+        <eam-equipment-process-list ref="tabPaneTableListRef6" :isDisplayOperation="false"/>
+      </a-tab-pane>
+      <a-tab-pane tab="璁惧绮惧害" :key="7" v-if="isOpenPrecision">
+        <eam-equipment-process-list ref="tabPaneTableListRef7" :isDisplayOperation="false"/>
+      </a-tab-pane>
     </a-tabs>
 
     <!-- 琛ㄥ崟鍖哄煙 -->
@@ -205,6 +211,7 @@
   import EamInspectionOrderList from '../maintenance/EamInspectionOrderList'
   import EamEquipmentAttachmentList from '@views/eam/equipment/EamEquipmentAttachmentList.vue'
   import EamWeekMaintenanceOrderList from '@views/eam/maintenance/EamWeekMaintenanceOrderList.vue'
+  import EamEquipmentProcessList from '@views/eam/equipment/modules/EamEquipmentProcessList.vue'
 
   export default {
     name: 'EamEquipmentList',
@@ -217,7 +224,8 @@
       NameplateModal,
       EamEquipmentModal,
       EamEquipmentAttachmentList,
-      EamWeekMaintenanceOrderList
+      EamWeekMaintenanceOrderList,
+      EamEquipmentProcessList
     },
     data() {
       return {
@@ -474,13 +482,15 @@
         printedRows: [],
         activeTabKey: 1,
         appHomeUrl: '',
-        currentTableRowRecord: {}
+        currentTableRowRecord: {},
+        isOpenProcess: false,
+        isOpenPrecision: false,
       }
     },
     computed: {
       importExcelUrl: function() {
         return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
-      }
+      },
     },
     created() {
       this.loadAllProductionTree()
@@ -567,7 +577,27 @@
         this.$refs['tabPaneTableListRef' + this.activeTabKey].queryParam.equipmentId = null
         this.$refs['tabPaneTableListRef' + this.activeTabKey].dataSource = []
         this.$refs['tabPaneTableListRef' + this.activeTabKey].onClearSelected()
-        if (selectedRowKeys.length === 1) this.loadTabPaneTableData(selectedRowKeys[0])
+        if (selectedRowKeys.length === 1) {
+          let row = this.dataSource.find(row => row.id === selectedRowKeys[0]);
+          if(row) {
+            this.isOpenProcess = (row.processParametersFlag === '1')
+            this.isOpenPrecision = (row.precisionParametersFlag === '1')
+          }else {
+            this.isOpenProcess = false
+            this.isOpenPrecision = false
+          }
+          this.loadTabPaneTableData(selectedRowKeys[0])
+        }else {
+          this.isOpenProcess = false
+          this.isOpenPrecision = false
+        }
+        //tab鏍囩琚攢姣佷簡锛岃繑鍥炵涓�涓猼ab
+        if(!this.isOpenProcess && this.activeTabKey === 6) {
+          this.activeTabKey = 1;
+        }
+        if(!this.isOpenPrecision && this.activeTabKey === 7) {
+          this.activeTabKey = 1;
+        }
       },
 
       handleTemplateXlsDownload() {
@@ -581,7 +611,8 @@
             this.appHomeUrl = res.result.settingValue
           }
         })
-      }
+      },
+
     }
   }
 </script>
diff --git a/src/views/eam/equipment/modules/EamEquipmentProcessList.vue b/src/views/eam/equipment/modules/EamEquipmentProcessList.vue
new file mode 100644
index 0000000..5087fbf
--- /dev/null
+++ b/src/views/eam/equipment/modules/EamEquipmentProcessList.vue
@@ -0,0 +1,278 @@
+<template>
+  <a-spin :spinning="confirmLoading">
+    <vxe-toolbar>
+      <template v-slot:buttons>
+        <vxe-button status="primary" @click="insertEvent()">鏂板</vxe-button>
+        <vxe-button status="danger" @click="handleBatchRemove()">鎵归噺鍒犻櫎</vxe-button>
+      </template>
+    </vxe-toolbar>
+    <vxe-table
+      ref="editableDetailTable"
+      border
+      resizable
+      show-overflow
+      keep-source
+      :height="300"
+      :loading="confirmLoading"
+      :data="dataSource"
+      :edit-rules="validRules"
+      :edit-config="{trigger: 'manual', mode: 'row', showStatus: true}"
+      style="margin-top: 8px;">
+      <vxe-table-column type="checkbox" width="60"></vxe-table-column>
+      <vxe-table-column type="seq" width="60"></vxe-table-column>
+      <vxe-table-column title="ID" field="id" :visible="false"></vxe-table-column>
+      <vxe-table-column title="equipmentId" field="equipmentId" :visible="false"></vxe-table-column>
+      <vxe-table-column title="鍙傛暟鍚嶇О" field="parameterId" align="center"
+                        :edit-render="{name : '$select', options: processParameterList, optionProps: {label:'parameterName', value:'id'}, props: {clearable:true}, events: {change:handleParamSelectChange}}"></vxe-table-column>
+      <vxe-table-column title="鍙傛暟缂栫爜" field="parameterCode" align="center"></vxe-table-column>
+      <vxe-table-column title="璁¢噺鍗曚綅" field="parameterUnit" align="center"></vxe-table-column>
+      <vxe-table-column title="鍙傛暟鑼冨洿" field="parameterPeriod" align="center"
+                        :edit-render="{name : '$input'}"></vxe-table-column>
+      <vxe-table-column title="鎿嶄綔" width="160">
+        <template v-slot="{row}">
+          <template v-if="hasEditStatus(row)">
+            <vxe-button @click="saveRowEvent(row)">淇濆瓨</vxe-button>
+            <vxe-button @click="cancelRowEvent(row)">鍙栨秷</vxe-button>
+          </template>
+          <template v-else>
+            <vxe-button @click="editRowEvent(row)">缂栬緫</vxe-button>
+            <vxe-button @click="handleRemove(row)">鍒犻櫎</vxe-button>
+          </template>
+
+        </template>
+      </vxe-table-column>
+    </vxe-table>
+  </a-spin>
+</template>
+
+<script>
+import { deleteAction, getAction, httpAction } from '@/api/manage'
+
+export default {
+  name: 'EamEquipmentProcessModal',
+  data() {
+    return {
+      title: '鎿嶄綔',
+      confirmLoading: false,
+      url: {
+        add: '/eam/equipmentProcessParameters/add',
+        edit: '/eam/equipmentProcessParameters/edit',
+        list: '/eam/equipmentProcessParameters/list',
+        delete: '/eam/equipmentProcessParameters/delete',
+        deleteBatch: '/eam/equipmentProcessParameters/deleteBatch',
+        processParamList: '/eam/processParameters/listAll'
+      },
+      /* 鍒嗛〉鍙傛暟 */
+      ipagination: {
+        current: 1,
+        pageSize: 10,
+        pageSizeOptions: ['10', '20', '30'],
+        showTotal: (total, range) => {
+          return range[0] + '-' + range[1] + ' 鍏�' + total + '鏉�'
+        },
+        showQuickJumper: true,
+        showSizeChanger: true,
+        total: 0
+      },
+      dataSource: [],
+      processParameterList: [],
+      queryParam: {
+        equipmentId: '-1'
+      },
+      validRules: {
+        parameterId: [
+          { required: true, message: '璇烽�夋嫨鍙傛暟锛�' }
+        ],
+        parameterPeriod: [
+          { required: true, message: '璇疯緭鍏ュ弬鏁拌寖鍥达紒' }
+        ]
+      }
+    }
+  },
+  created() {
+    this.loadProcessParameterList()
+  },
+  methods: {
+    handleParamSelectChange($event, value) {
+      let parameter = this.processParameterList.find(item => item.id === value.value)
+      if (parameter) {
+        $event.row.parameterUnit = parameter.parameterUnit
+        $event.row.parameterCode = parameter.parameterCode
+      } else {
+        $event.row.parameterUnit = undefined
+        $event.row.parameterCode = undefined
+      }
+    },
+    loadProcessParameterList() {
+      getAction(this.url.processParamList).then(res => {
+        if (res.success) {
+          this.processParameterList = [...res.result]
+        }
+      })
+    },
+    onClearSelected() {
+      this.dataSource = []
+      this.queryParam.equipmentId = '-1'
+      this.ipagination.current = 1
+      this.ipagination.total = 0
+    },
+    loadData(args) {
+      if (!this.url.list) {
+        this.$message.error('璇疯缃畊rl.list灞炴��!')
+        return
+      }
+      if (args === 1) {
+        this.ipagination.current = 1
+      }
+      // 灏佽鏌ヨ鏉′欢
+      let formData = {
+        pageNo: args,
+        pageSize: this.ipagination.pageSize,
+        equipmentId: this.queryParam.equipmentId
+      }
+      // 璋冪敤鏌ヨ鏁版嵁鎺ュ彛
+      this.confirmLoading = true
+      getAction(this.url.list, formData).then(res => {
+        if (res.success) {
+          // 鍚庡彴鏌ヨ鍥炴潵鐨� total锛屾暟鎹�绘暟閲�
+          this.dataSource = res.result.records || res.result
+          if (res.result.total) {
+            this.ipagination.total = res.result.total
+          } else {
+            this.ipagination.total = 0
+          }
+        } else {
+          this.$message.warning(res.message)
+        }
+      }).finally(() => {
+        // 杩欓噷鏄棤璁烘垚鍔熸垨澶辫触閮戒細鎵ц鐨勬柟娉曪紝鍦ㄨ繖閲屽叧闂璴oading
+        this.confirmLoading = false
+      })
+    },
+    async insertEvent() {
+      let record = { equipmentId: this.queryParam.equipmentId }
+      let { row: newRow } = await this.$refs.editableDetailTable.insert(record)
+      await this.$refs.editableDetailTable.setActiveCell(newRow, 'parameterId')
+    },
+    async saveRowEvent(row) {
+      let that = this
+      const errMap = await that.$refs.editableDetailTable.validate().catch(errMap => errMap)
+      if (errMap) {
+        that.$message.warning('鏍¢獙涓嶉�氳繃,璇疯ˉ鍏呭繀濉」锛�')
+        return
+      }
+      that.confirmLoading = true
+      let httpurl = ''
+      let method = ''
+      if (!row.id) {
+        httpurl += that.url.add
+        method = 'post'
+      } else {
+        httpurl += that.url.edit
+        method = 'put'
+      }
+      let res = await httpAction(httpurl, row, method)
+      if (res.success) {
+        that.$message.success(res.message)
+        that.loadData(that.ipagination.current)
+        await that.$refs.editableDetailTable.clearActived()
+      } else {
+        that.$message.warning(res.message)
+      }
+      that.confirmLoading = false
+    },
+    handleRemove(row) {
+      let xTable = this.$refs.editableDetailTable
+      let that = this
+      this.$confirm({
+        content: `纭瑕佸垹闄ゅ悧锛焋,
+        onOk: () => {
+          if (row.id) {
+            //鍚庣鍒犻櫎
+            deleteAction(that.url.delete, { id: row.id }).then((res) => {
+              if (res.success) {
+                that.reCalculatePage(1)
+                that.$message.success(res.message)
+                that.loadData(that.ipagination.current)
+              } else {
+                that.$message.warning(res.message)
+              }
+            })
+          } else {
+            //鍓嶇鍒犻櫎
+            xTable.remove(row)
+          }
+        },
+        onCancel: () => {
+          xTable.setActiveCell(row, 'parameterId')
+        }
+      })
+    },
+    handleBatchRemove(){
+      let xTable = this.$refs.editableDetailTable
+      let that = this
+      let checkboxRecords = xTable.getCheckboxRecords();
+      if(checkboxRecords && checkboxRecords.length > 0) {
+        let ids = checkboxRecords.map(record => record.id);
+        this.$confirm({
+          title: "纭鍒犻櫎",
+          content: "鏄惁鍒犻櫎閫変腑鏁版嵁?",
+          onOk: function () {
+            that.confirmLoading = true;
+            deleteAction(that.url.deleteBatch, {ids: ids.join(',')}).then((res) => {
+              if (res.success) {
+                //閲嶆柊璁$畻鍒嗛〉闂
+                that.reCalculatePage(checkboxRecords.length)
+                that.$message.success(res.message);
+                that.loadData(that.ipagination.current);
+              } else {
+                that.$message.warning(res.message);
+              }
+            }).finally(() => {
+              that.confirmLoading = false;
+            });
+          }
+        });
+      } else {
+        that.$message.warning('璇峰厛閫変腑鏁版嵁琛岋紒');
+      }
+    },
+    editRowEvent(row) {
+      this.$refs.editableDetailTable.setActiveRow(row)
+    },
+    cancelRowEvent(row) {
+      let xTable = this.$refs.editableDetailTable
+      this.$confirm({
+        content: `纭瑕佹斁寮冪紪杈戝悧锛焋,
+        onOk: () => {
+          xTable.revertData()
+        },
+        onCancel: () => {
+          xTable.setActiveCell(row, 'parameterId')
+        }
+      })
+    },
+    hasEditStatus(row) {
+      const $table = this.$refs.editableDetailTable
+      if ($table) {
+        return $table.isActiveByRow(row)
+      }
+      return false
+    },
+    reCalculatePage(count) {
+      //鎬绘暟閲�-count
+      let total = this.ipagination.total - count
+      //鑾峰彇鍒犻櫎鍚庣殑鍒嗛〉鏁�
+      let currentIndex = Math.ceil(total / this.ipagination.pageSize)
+      //鍒犻櫎鍚庣殑鍒嗛〉鏁�<鎵�鍦ㄥ綋鍓嶉〉
+      if (currentIndex < this.ipagination.current) {
+        this.ipagination.current = currentIndex
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less" scoped>
+
+</style>
\ No newline at end of file

--
Gitblit v1.9.3