cuijian
2025-07-28 accebdce93486d3b4f26e55ffdea047549cce20c
src/views/mdc/base/EquipmentList.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,440 @@
<template>
  <a-card :bordered="false">
    <!-- æŸ¥è¯¢åŒºåŸŸ -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="4" :sm="4">
            <a-form-item label="设备编号">
              <a-input placeholder="请输入设备编号" v-model="queryParam.equipmentId"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="4" :sm="4">
            <a-form-item label="设备名称">
              <a-input placeholder="请输入设备名称" v-model="queryParam.equipmentName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="4" :sm="4">
            <a-form-item label="车间名称">
              <!--<a-input placeholder="请输入车间名称" v-model="queryParam.productionName"></a-input>-->
              <a-tree-select v-model="queryParam.productionName" :treeData="workshopTreeData" placeholder="请选择车间"
                             :treeDefaultExpandedKeys="treeDefaultExpandedKeys"></a-tree-select>
            </a-form-item>
          </a-col>
          <a-col :md="4" :sm="4">
            <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
            <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- æ“ä½œæŒ‰é’®åŒºåŸŸ -->
    <div class="table-operator" style="border-top: 5px">
      <a-button @click="handleAdd" type="primary" icon="plus">添加设备</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('设备信息')">导出</a-button>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay" @click="handleMenuClick">
          <a-menu-item key="1">
            <a-icon type="delete" @click="batchDel"/>
            åˆ é™¤
          </a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px">
          æ‰¹é‡æ“ä½œ
          <a-icon type="down"/>
        </a-button>
      </a-dropdown>
    </div>
    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i>已选择&nbsp;<a style="font-weight: 600">{{
        selectedRowKeys.length }}</a>项&nbsp;&nbsp;
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>
      <a-table
        ref="table"
        bordered
        size="middle"
        rowKey="id"
        :scroll="{x:'max-content',y:465}"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical"/>
          <a-dropdown>
            <a class="ant-dropdown-link">
              æ›´å¤š <a-icon type="down"/>
            </a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a href="javascript:;" @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </a-table>
    </div>
    <!-- table区域-end -->
    <user-modal ref="modalForm" @ok="modalFormOk"></user-modal>
  </a-card>
</template>
<script>
  import UserModal from './modules/EquipmentList/UserModal'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { queryProductionTreeListByMdc } from '@/api/api'
  import { mapActions } from 'vuex'
  export default {
    name: 'EquipmentList',
    mixins: [JeecgListMixin],
    components: {
      UserModal
    },
    data() {
      return {
        description: '这是设备管理页面',
        queryParam: {},
        recycleBinVisible: false,
        /* åˆ†é¡µå‚æ•° */
        ipagination: {
          current: 1,
          pageSize: 30,
          pageSizeOptions: ['30', '50', '100'],
          showTotal: (total, range) => {
            return range[0] + '-' + range[1] + ' å…±' + total + '条'
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0
        },
        columns: [
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function(t, r, index) {
              return parseInt(index) + 1
            }
          },
          {
            title: '设备编号',
            align: 'center',
            dataIndex: 'equipmentId',
            width: 200
          },
          {
            title: '设备名称',
            align: 'center',
            width: 200,
            dataIndex: 'equipmentName'
          },
          {
            title: '车间',
            align: 'center',
            width: 200,
            dataIndex: 'productionName'
          },
          {
            title: '设备类型',
            align: 'center',
            width: 200,
            dataIndex: 'equipmentType'
          },
          {
            title: '驱动类型',
            align: 'center',
            width: 200,
            dataIndex: 'driveType'
          },
          {
            title: '机床IP',
            align: 'center',
            width: 200,
            dataIndex: 'equipmentIp'
          },
          {
            title: '设备功率',
            align: 'center',
            width: 200,
            dataIndex: 'devicePower'
          },
          {
            title: '部门',
            align: 'center',
            width: 200,
            dataIndex: 'orgCodeTxt'
          },
          {
            title: '系统版本',
            align: 'center',
            width: 200,
            dataIndex: 'systemVersion'
          },
          {
            title: '操作',
            dataIndex: 'action',
            scopedSlots: { customRender: 'action' },
            align: 'center',
            width: 150,
            fixed: 'right'
          }
        ],
        url: {
          list: '/mdc/mdcEquipment/list',
          delete: '/mdc/mdcEquipment/delete',
          deleteBatch: '/mdc/mdcEquipment/deleteBatch',
          exportXlsUrl: '/mdc/mdcEquipment/exportXls'
        },
        isDepartType: '',
        workshopTreeData: [],
        treeDefaultExpandedKeys: []
      }
    },
    created() {
      this.queryTreeData()
      this.getWorkshopListByApi()
    },
    methods: {
      ...mapActions(['QueryDepartTree']),
      queryTreeData() {
        this.QueryDepartTree().then(res => {
          if (res.success) {
            this.isDepartType = res.result[0].value
            if (this.isDepartType == -1) {
              this.columns = [
                {
                  title: '#',
                  dataIndex: '',
                  key: 'rowIndex',
                  width: 60,
                  align: 'center',
                  customRender: function(t, r, index) {
                    return parseInt(index) + 1
                  }
                },
                {
                  title: '设备编号',
                  align: 'center',
                  dataIndex: 'equipmentId',
                  width: 200
                  // sorter: true
                },
                {
                  title: '设备名称',
                  align: 'center',
                  dataIndex: 'equipmentName',
                  width: 200
                  // sorter: true
                },
                {
                  title: '安装位置',
                  align: 'center',
                  width: 200,
                  dataIndex: 'equipmentAddress'
                },
                {
                  title: '车间',
                  align: 'center',
                  width: 200,
                  dataIndex: 'productionName'
                },
                {
                  title: '设备类型',
                  align: 'center',
                  width: 200,
                  dataIndex: 'equipmentType'
                },
                {
                  title: '驱动类型',
                  align: 'center',
                  width: 200,
                  dataIndex: 'driveType'
                  // sorter: true
                },
                {
                  title: '机床IP',
                  align: 'center',
                  width: 200,
                  dataIndex: 'equipmentIp'
                },
                {
                  title: '设备功率',
                  align: 'center',
                  width: 200,
                  dataIndex: 'devicePower'
                },
                {
                  title: '系统版本',
                  align: 'center',
                  width: 200,
                  dataIndex: 'systemVersion'
                },
                {
                  title: '操作',
                  dataIndex: 'action',
                  scopedSlots: { customRender: 'action' },
                  align: 'center',
                  width: 150,
                  fixed: 'right'
                }
              ]
            } else {
              this.columns = [
                {
                  title: '#',
                  dataIndex: '',
                  key: 'rowIndex',
                  width: 60,
                  align: 'center',
                  customRender: function(t, r, index) {
                    return parseInt(index) + 1
                  }
                },
                {
                  title: '设备编号',
                  align: 'center',
                  dataIndex: 'equipmentId',
                  width: 200
                  // sorter: true
                },
                {
                  title: '设备名称',
                  align: 'center',
                  width: 200,
                  dataIndex: 'equipmentName'
                },
                {
                  title: '车间',
                  align: 'center',
                  width: 200,
                  dataIndex: 'productionName'
                },
                {
                  title: '设备类型',
                  align: 'center',
                  width: 200,
                  dataIndex: 'equipmentType'
                },
                {
                  title: '驱动类型',
                  align: 'center',
                  width: 200,
                  dataIndex: 'driveType'
                  // sorter: true
                },
                {
                  title: '机床IP',
                  align: 'center',
                  width: 200,
                  dataIndex: 'equipmentIp'
                },
                {
                  title: '设备功率',
                  align: 'center',
                  width: 200,
                  dataIndex: 'devicePower'
                },
                {
                  title: '部门',
                  align: 'center',
                  width: 200,
                  dataIndex: 'orgCodeTxt'
                },
                {
                  title: '系统版本',
                  align: 'center',
                  width: 200,
                  dataIndex: 'systemVersion'
                },
                {
                  title: '操作',
                  dataIndex: 'action',
                  scopedSlots: { customRender: 'action' },
                  align: 'center',
                  width: 150,
                  fixed: 'right'
                }
              ]
            }
          } else {
            // this.$message.warn(res.message)
            this.$notification.warning({
              message: '消息',
              description: res.message
            })
          }
        }).finally(() => {
        })
      },
      /**
       * è°ƒç”¨æŽ¥å£èŽ·å–æŸ¥è¯¢åŒºåŸŸè½¦é—´æ ‘åˆ—è¡¨
       */
      getWorkshopListByApi() {
        queryProductionTreeListByMdc().then(res => {
          if (res.success) {
            this.workshopTreeData = res.result
            this.treeDefaultExpandedKeys = [...res.result].map(item => item.key)
          }
        })
      },
      handleEdit: function(record) {
        this.$refs.modalForm.edit(record)
        this.$refs.modalForm.title = '编辑'
        this.$refs.modalForm.disableSubmit = false
        this.$refs.modalForm.disSeach = true
        // è°ƒç”¨æŠ½å±‰è¡¨å•组件中的清除表单验证方法
        this.$refs.modalForm.removeValidate()
      },
      handleAdd: function() {
        this.$refs.modalForm.add()
        this.$refs.modalForm.title = '新增'
        this.$refs.modalForm.disableSubmit = false
        this.$refs.modalForm.disSeach = false
      },
      handleMenuClick(e) {
        if (e.key == 1) {
          this.batchDel()
        }
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>