From 86a6a39153a72dbc624e28559aa41b9570a2339e Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期二, 29 四月 2025 14:37:46 +0800
Subject: [PATCH] art: 设备管理-设备台账-设备精度参数添加

---
 src/views/eam/equipment/modules/EamEquipmentPrecisionList.vue |  290 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/views/eam/equipment/EamEquipmentList.vue                  |    6 
 2 files changed, 294 insertions(+), 2 deletions(-)

diff --git a/src/views/eam/equipment/EamEquipmentList.vue b/src/views/eam/equipment/EamEquipmentList.vue
index 410007b..61012f2 100644
--- a/src/views/eam/equipment/EamEquipmentList.vue
+++ b/src/views/eam/equipment/EamEquipmentList.vue
@@ -185,7 +185,7 @@
         <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"/>
+        <eam-equipment-precision-list ref="tabPaneTableListRef7" :isDisplayOperation="false"/>
       </a-tab-pane>
     </a-tabs>
 
@@ -212,6 +212,7 @@
   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'
+  import EamEquipmentPrecisionList from '@views/eam/equipment/modules/EamEquipmentPrecisionList.vue'
 
   export default {
     name: 'EamEquipmentList',
@@ -225,7 +226,8 @@
       EamEquipmentModal,
       EamEquipmentAttachmentList,
       EamWeekMaintenanceOrderList,
-      EamEquipmentProcessList
+      EamEquipmentProcessList,
+      EamEquipmentPrecisionList
     },
     data() {
       return {
diff --git a/src/views/eam/equipment/modules/EamEquipmentPrecisionList.vue b/src/views/eam/equipment/modules/EamEquipmentPrecisionList.vue
new file mode 100644
index 0000000..5b8aa0e
--- /dev/null
+++ b/src/views/eam/equipment/modules/EamEquipmentPrecisionList.vue
@@ -0,0 +1,290 @@
+<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: precisionParameterList, 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="鍏佸樊鍊�(mm)" field="parameterValue" align="center"
+                        :edit-render="{name : '$input'}"></vxe-table-column>
+      <vxe-table-column title="瀹為檯鍊�" field="actualValue" align="center"></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-pagination
+      v-bind="ipagination"
+      @change="handlePageChange"
+      @showSizeChange="handleShowSizeChange"
+    />
+  </a-spin>
+</template>
+
+<script>
+import { deleteAction, getAction, httpAction } from '@/api/manage'
+
+export default {
+  name: 'EamEquipmentPrecisionList',
+  data() {
+    return {
+      title: '鎿嶄綔',
+      confirmLoading: false,
+      url: {
+        add: '/eam/equipmentPrecisionParameters/add',
+        edit: '/eam/equipmentPrecisionParameters/edit',
+        list: '/eam/equipmentPrecisionParameters/list',
+        delete: '/eam/equipmentPrecisionParameters/delete',
+        deleteBatch: '/eam/equipmentPrecisionParameters/deleteBatch',
+        precisionParamList: '/eam/precisionParameters/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,
+        size: 'small'
+      },
+      dataSource: [],
+      precisionParameterList: [],
+      queryParam: {
+        equipmentId: '-1'
+      },
+      validRules: {
+        parameterId: [
+          { required: true, message: '璇烽�夋嫨鍙傛暟锛�' }
+        ],
+        parameterValue: [
+          { required: true, message: '璇疯緭鍏ュ厑宸�硷紒' }
+        ]
+      }
+    }
+  },
+  created() {
+    this.loadPrecisionParameterList()
+  },
+  methods: {
+    handleParamSelectChange($event, value) {
+      let parameter = this.precisionParameterList.find(item => item.id === value.value)
+      if (parameter) {
+        $event.row.parameterCode = parameter.parameterCode
+      } else {
+        $event.row.parameterCode = undefined
+      }
+    },
+    loadPrecisionParameterList() {
+      getAction(this.url.precisionParamList).then(res => {
+        if (res.success) {
+          this.precisionParameterList = [...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
+      }
+    },
+    handlePageChange(current, pageSize){
+      this.$set(this.ipagination, 'current', current)
+      this.$emit('change', {current, pageSize})
+    },
+    handleShowSizeChange(current, pageSize){
+      this.$set(this.ipagination, 'pageSize', pageSize)
+      this.$emit('change', {current, pageSize})
+    },
+  }
+}
+</script>
+
+<style lang="less" scoped>
+
+</style>
\ No newline at end of file

--
Gitblit v1.9.3