zenglf
2023-09-18 92ff846fb659c62037a32b1d8c15eae9df9d9b54
src/views/eam/modules/equipment/EquipmentAccount2List.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,938 @@
<template>
  <a-card
    :bordered="false"
    class="card-area"
  >
    <template slot="title">
      <i
        class="action-jeecg actionsite2"
        style="font-size: 18px;"
      />
      è®¾å¤‡ä¿¡æ¯
    </template>
    <!-- æŸ¥è¯¢åŒºåŸŸ -->
    <div class="table-page-search-wrapper">
      <!-- æœç´¢åŒºåŸŸ -->
      <a-form
        layout="inline"
        @keyup.enter.native="searchQuery"
      >
        <a-row :gutter="24">
          <a-col
            :md="8"
            :sm="8"
          >
            <a-form-item label="设备编号">
              <a-input
                placeholder="请输入设备编号查询"
                v-model="queryParam.num"
              ></a-input>
            </a-form-item>
          </a-col>
          <a-col
            :md="8"
            :sm="8"
          >
            <a-form-item label="设备名称">
              <a-input
                placeholder="请输入设备名称查询"
                v-model="queryParam.name"
              ></a-input>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- æ“ä½œæŒ‰é’®åŒºåŸŸ -->
    <div
      class="table-operator"
      style="margin-top: 5px"
    >
      <a-button
        type="primary"
        @click="searchQuery"
        icon="search"
      >查询</a-button>
      <a-button
        @click="searchReset"
        icon="reload"
      >重置</a-button>
      <a-button
        @click="handleAdd"
        type="primary"
        icon="plus"
        :hidden="disabled"
      >新增</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <a-button
        type="primary"
        icon="download"
        @click="handleExportXls('???')"
      >导出</a-button>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-button style="margin-left: 8px">
          æ‰¹é‡æ“ä½œ
          <a-icon type="down" />
        </a-button>
        <a-menu slot="overlay">
          <a-menu-item @click="batchDel">
            <a-icon type="delete" />删除
          </a-menu-item>
        </a-menu>
      </a-dropdown>
    </div>
    <a-table
      ref="table"
      bordered
      size="middle"
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      :rowSelection="rowSelection"
      @change="handleTableChange"
      :scroll="{ x: 'calc(4000px + 50%)', y: 900 }"
      :customRow="clickThenSelect"
    >
      <span
        slot="equipmentPhoto"
        slot-scope="text,record"
      >
        <Tooltip
          placement="top"
          title="预览图片"
        >
          <span
            v-if="!text"
            style="font-size: 12px;font-style: italic;"
          >无图片</span>
          <img
            v-else
            :src="getImgView(text)"
            :preview="record.id"
            height="25px"
            alt=""
            style="max-width:80px;font-size: 12px;font-style: italic;"
          />
        </Tooltip>
      </span>
      <!--工艺参数个性展示-->
      <span
        slot="processParameters"
        slot-scope="text,record"
      >
        <a-badge
          v-if="record.processParameters==1"
          status="success"
        />
        <span
          v-if="record.processParameters==1"
          class="success"
        >是</span>
        <a-badge
          v-if="record.processParameters==0"
          status="error"
        />
        <span
          v-if="record.processParameters==0"
          class="error"
        >否</span>
      </span>
      <span
        slot="processParameters"
        slot-scope="text,record"
      >
        <a-badge
          v-if="record.processParameters==1"
          status="success"
        />
        <span
          v-if="record.processParameters==1"
          class="success"
        >是</span>
        <a-badge
          v-if="record.processParameters==0"
          status="error"
        />
        <span
          v-if="record.processParameters==0"
          class="error"
        >否</span>
      </span>
      <span
        slot="precisionParameters"
        slot-scope="text,record"
      >
        <a-badge
          v-if="record.precisionParameters==1"
          status="success"
        />
        <span
          v-if="record.precisionParameters==1"
          class="success"
        >是</span>
        <a-badge
          v-if="record.precisionParameters==0"
          status="error"
        />
        <span
          v-if="record.precisionParameters==0"
          class="error"
        >否</span>
      </span>
      <span
        slot="verification"
        slot-scope="text,record"
      >
        <a-badge
          v-if="record.verification==1"
          status="success"
        />
        <span
          v-if="record.verification==1"
          class="success"
        >是</span>
        <a-badge
          v-if="record.verification==0"
          status="error"
        />
        <span
          v-if="record.verification==0"
          class="error"
        >否</span>
      </span>
      <span
        slot="action"
        slot-scope="text, record"
      >
        <!-- class="table-operation" -->
        <!-- <a
          href="javascript:;"
          @click="equipmentStructuresShow(record)"
        >设备结构</a>
        <a-divider type="vertical" /> -->
        <a
          href="javascript:;"
          @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 @click="equipmentResumeShow(record)">设备履历</a>
            </a-menu-item>
            <a-menu-item>
              <a @click="handleEdit(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>
    <a-tabs
      type="card"
      defaultActiveKey="1"
    >
      <a-tab-pane key="1">
        <span slot="tab">
          <a-badge v-if="showTabsFlag">工艺参数&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a-badge>
          <a-badge
            v-if="!showTabsFlag"
            :count="5"
            show-zero
            :number-style="{ backgroundColor: '#52c41a' }"
          >工艺参数&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a-badge>
        </span>
        <div
          class="table-operator"
          style="margin-top: 0px"
        >
          <process-parameters-list ref="ProcessParametersList"></process-parameters-list>
        </div>
      </a-tab-pane>
      <a-tab-pane
        key="2"
        forceRender
      >
        <span slot="tab">
          <a-badge v-if="showTabsFlag">设备精度&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a-badge>
          <a-badge
            v-if="!showTabsFlag"
            :count="5"
            show-zero
            :number-style="{ backgroundColor: '#52c41a' }"
          >设备精度&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a-badge>
        </span>
        <div
          class="table-operator"
          style="margin-top: 0px"
        >
          <precision-parameters-list ref="PrecisionParametersList"></precision-parameters-list>
        </div>
      </a-tab-pane>
      <a-tab-pane
        key="3"
        forceRender
      >
        <span slot="tab">
          <a-badge v-if="showTabsFlag">设备文档&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a-badge>
          <a-badge
            v-if="!showTabsFlag"
            :count="5"
            show-zero
            :number-style="{ backgroundColor: '#52c41a' }"
          >设备文档&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a-badge>
        </span>
        <div
          class="table-operator"
          style="margin-top: 0px"
        >
          <equipment-file-list ref="EquipmentFileList"></equipment-file-list>
        </div>
      </a-tab-pane>
    </a-tabs>
    <equipment-model
      ref="modalForm"
      @ok="modalFormOk"
    ></equipment-model>
    <equipment-structure-drawer
      ref="EquipmentStructureDrawer"
      @ok="modalFormOk"
    ></equipment-structure-drawer>
    <equipment-resume-drawer
      ref="EquipmentResumeDrawer"
      @ok="modalFormOk"
    ></equipment-resume-drawer>
  </a-card>
</template>
<script>
import { requestPut, deleteAction, getFileAccessHttpUrl, getAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import EquipmentModel from './EquipmentModel.vue'
import JInput from '@/components/jeecg/JInput'
import JEllipsis from '@/components/jeecg/JEllipsis'
import Tooltip from 'ant-design-vue/es/tooltip'
import Vue from 'vue'
import ProcessParametersList from './ProcessParametersList'
import PrecisionParametersList from './PrecisionParametersList'
import EquipmentFileList from './EquipmentFileList'
import EquipmentStructureDrawer from './EquipmentStructureDrawer'
import EquipmentResumeDrawer from './EquipmentResume/EquipmentResumeDrawer'
export default {
  name: 'EquipmentCategory2List.',
  mixins: [JeecgListMixin],
  components: {
    EquipmentModel,
    JInput,
    JEllipsis,
    ProcessParametersList,
    PrecisionParametersList,
    EquipmentFileList,
    Tooltip,
    EquipmentStructureDrawer,
    EquipmentResumeDrawer
  },
  props: {
    nodeSelected: {
      type: Object,
      default: {}
    }
  },
  data() {
    return {
      showTabsFlag: true,
      disabled: true,
      ipagination: {
        current: 1,
        pageSize: 5,
        pageSizeOptions: ['5', '10', '20'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " å…±" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      selectedRowKeys: [],
      selectionRows: [],
      //默认排序
      isorter: {
        column: 'num',
        order: 'asc',
      },
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
          width: 50,
        },
        {
          title: '统一编码',
          align: "center",
          dataIndex: 'num',
        },
        {
          title: '设备名称',
          align: "center",
          dataIndex: 'name',
        },
        {
          title: '型号',
          align: "center",
          dataIndex: 'model',
        },
        {
          title: '规格',
          align: "center",
          dataIndex: 'specification',
        },
        // {
        //   title: '资产编码',
        //   align: "center",
        //   dataIndex: 'assetNumber',
        // },
        {
          title: '总功率',
          align: "center",
          dataIndex: 'gpo',
        },
        {
          title: '使用部门',
          align: "center",
          dataIndex: 'useId_dictText',
        },
        {
          title: '工区',
          align: "center",
          dataIndex: 'equipmentUda1',
        },
        {
          title: '维护部门',
          align: "center",
          dataIndex: 'manageId_dictText',
        },
        {
          title: '维修班组',
          align: "center",
          dataIndex: 'teamId_dictText',
        },
        {
          title: 'ABC标识',
          align: "center",
          dataIndex: 'equipmentImportanceId_dictText',
        },
        {
          title: '关键设备标识',
          align: "center",
          dataIndex: 'keyEquipmentIdentification',
        },
        {
          title: '安全配置',
          align: "center",
          dataIndex: 'securityConfiguration',
        },
        {
          title: '冷却系统',
          align: "center",
          dataIndex: 'coolingSystem',
        },
        {
          title: '灭火器',
          align: "center",
          dataIndex: 'fireExtinguisher',
        },
        {
          title: '灭火器有效期',
          align: "center",
          dataIndex: 'fireExtinguisherValidityPeriod',
        },
        {
          title: '操作系统',
          align: "center",
          dataIndex: 'operatingSystem',
        },
        {
          title: '系统',
          align: "center",
          dataIndex: 'system',
        },
        {
          title: '设备端口',
          align: "center",
          dataIndex: 'port',
        },
        {
          title: '坐标数量',
          align: "center",
          dataIndex: 'coordinateNum',
        },
        {
          title: '设备状态',
          align: "center",
          dataIndex: 'equipmentStatus_dictText',
        },
        {
          title: '重量',
          align: "center",
          dataIndex: 'equipmentUda3',
        },
        {
          title: '重量计量单位',
          align: "center",
          dataIndex: 'equipmentUda4_dictText',
        },
        {
          title: '功能位置',
          align: "center",
          dataIndex: 'equipmentUda5',
        },
        {
          title: '安装位置',
          align: "center",
          dataIndex: 'equipmentUda2',
        },
        {
          title: '出厂日期',
          align: "center",
          dataIndex: 'leaveFactoryDate',
        },
        {
          title: '立项卡号',
          align: "center",
          dataIndex: 'projectApprovalNo',
        },
        {
          title: '资金来源',
          align: "center",
          dataIndex: 'fundSource',
        },
        {
          title: '验收日期',
          align: "center",
          dataIndex: 'acceptanceCheckDate',
        },
        {
          title: '出厂编号',
          align: "center",
          dataIndex: 'factoryNo',
        },
        {
          title: '资产制造商',
          align: "center",
          dataIndex: 'constructorId_dictText',
        },
        {
          title: '资产的来源国家',
          align: "center",
          dataIndex: 'sourceCountry',
        },
        // {
        //   title: '技术状态',
        //   align: "center",
        //   dataIndex: 'technologyStatus_dictText',
        // },
        // {
        //   title: '特种设备',
        //   align: "center",
        //   dataIndex: 'specificEquipment_dictText',
        // },
        // {
        //   title: '设备图片',
        //   align: "center",
        //   dataIndex: 'equipmentPhoto',
        //   scopedSlots: { customRender: 'equipmentPhoto' },
        // },
        // {
        //   title: '供应商',
        //   align: "center",
        //   dataIndex: 'supplierId_dictText',
        // },
        // {
        //   title: '出厂编号',
        //   align: "center",
        //   dataIndex: 'factoryNumber',
        // },
        // {
        //   title: '出厂日期',
        //   align: "center",
        //   dataIndex: 'leaveFactoryDate',
        // },
        // {
        //   title: '验收日期',
        //   align: "center",
        //   dataIndex: 'acceptanceCheckDate',
        // },
        // // {
        // //   title: '所有组织',
        // //   align: "center",
        // //   dataIndex: 'affiliationId_dictText',
        // // },
        // {
        //   title: '管理人员',
        //   align: "center",
        //   dataIndex: 'manager_dictText',
        // },
        // {
        //   title: '使用部门',
        //   align: "center",
        //   dataIndex: 'useId_dictText',
        // },
        // {
        //   title: '责任人',
        //   align: "center",
        //   dataIndex: 'functionary_dictText',
        // },
        // {
        //   title: '位置',
        //   align: "center",
        //   dataIndex: 'location',
        // },
        {
          title: '工艺参数管理',
          align: "center",
          dataIndex: 'processParameters',
          scopedSlots: { customRender: 'processParameters' },
        },
        {
          title: '工艺参数模板',
          align: "center",
          dataIndex: 'processParametersTemplateName',
        },
        // {
        //   title: '设备精度管理',
        //   align: "center",
        //   dataIndex: 'precisionParameters',
        //   scopedSlots: { customRender: 'precisionParameters' },
        // },
        // {
        //   title: '精度参数模板',
        //   align: "center",
        //   dataIndex: 'precisionParametersTemplateName',
        // },
        // // {
        // //   title: '检定管理',
        // //   align: "center",
        // //   dataIndex: 'verification',
        // //   scopedSlots: { customRender: 'verification' },
        // // },
        // // {
        // //   title: '检定周期/月',
        // //   align: "center",
        // //   dataIndex: 'verificationPeriod',
        // // },
        // // {
        // //   title: '上次检定日期',
        // //   align: "center",
        // //   dataIndex: 'lastVerificationDate',
        // // },
        // // {
        // //   title: '下次检定日期',
        // //   align: "center",
        // //   dataIndex: 'nextVerificationDate',
        // // },
        // // {
        // //   title: '状态',
        // //   align: 'center',
        // //   dataIndex: 'status',
        // //   width: 100,
        // // },
        {
          title: '备注',
          align: "center",
          dataIndex: 'remark',
        },
        {
          title: '操作',
          align: "center",
          dataIndex: 'action',
          scopedSlots: {
            customRender: 'action',
          },
          width: 200,
          fixed: 'right',
        },
      ],
      url: {
        list: "/eam/equipment/list",
        delete: "/eam/equipment/delete",
        deleteBatch: "/eam/equipment/deleteBatch",
        active: "/eam/equipment/active",
        exportXlsUrl: '/eam/equipment/exportXls',
        importExcelUrl: "/eam/equipment/importExcel",
        // importExcelUrl: 'base/site/importExcel',
      },
      //新增、编辑、删除、批量删除操作改变数据后刷新关联的组件的监听属性
      alterFlag: "",
      equipmentRecord: {},
      // parentNum: "-1",
      // parentName: "设备分类",
    };
  },
  computed: {
    rowSelection() {
      return {
        type: 'checkbox',
        onChange: (selectedRowKeys, selectedRows) => {
          this.selectedRowKeys = selectedRowKeys;
          this.onSelectChange(selectedRowKeys, selectedRows);
        },
        getCheckboxProps(record) {
          return ({
            props: {
              // disabled: !(record.equipmentCategoryDtlList.length == 0),
            }
          })
        },
        selectedRowKeys: this.selectedRowKeys,
      };
    },
    importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
  methods: {
    clickThenSelect(record) {
      return {
        on: {
          click: () => {
            this.onSelectChange(record.id.split(","), [record]);
          }
        }
      }
    },
    onSelectChange(selectedRowKeys, selectionRows) {
      if (selectedRowKeys.length == 1) {
        this.$refs.ProcessParametersList.equipmentId = selectedRowKeys[0]
        this.$refs.EquipmentFileList.equipmentId = selectedRowKeys[0]
        this.$refs.PrecisionParametersList.equipmentId = selectedRowKeys[0]
      } else {
        this.$refs.ProcessParametersList.equipmentId = '-1'
        this.$refs.PrecisionParametersList.equipmentId = '-1'
        this.$refs.EquipmentFileList.equipmentId = '-1'
      }
      this.selectedRowKeys = selectedRowKeys;
      this.selectionRows = selectionRows;
    },
    //禁用状态样式
    tableRowClass(record, index) {
      if (record.status != "1") {
        return "frozenRowClass";
      }
      return "";
    },
    handleActive(id) {
      let that = this;
      requestPut(that.url.active, {}, { id: id }).then((res) => {
        if (res.success) {
          that.$message.success(res.message);
          that.loadData();
        } else {
          that.$message.warning(res.message);
        }
      });
    },
    handleAdd: function () {
      this.$refs.modalForm.add({ processParameters: '1', precisionParameters: '1', verification: '1' });
      this.$refs.modalForm.title = "新增";
      this.$refs.modalForm.disableSubmit = false;
      this.$refs.modalForm.equipmentCategoryId = this.nodeSelected.key;
    },
    handleDelete: function (id) {
      if (!this.url.delete) {
        this.$message.error("请设置url.delete属性!")
        return
      }
      var that = this;
      deleteAction(that.url.delete, { id: id }).then((res) => {
        if (res.success) {
          //重新计算分页问题
          that.reCalculatePage(1)
          that.$message.success(res.message);
          that.loadData();
          that.alterFlag = new Date();
        } else {
          that.$message.warning(res.message);
        }
      });
    },
    batchDel: function () {
      if (!this.url.deleteBatch) {
        this.$message.error("请设置url.deleteBatch属性!")
        return
      }
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('请选择一条记录!');
        return;
      } else {
        var ids = "";
        for (var a = 0; a < this.selectedRowKeys.length; a++) {
          ids += this.selectedRowKeys[a] + ",";
        }
        var that = this;
        this.$confirm({
          title: "确认删除",
          content: "是否删除选中数据?",
          onOk: function () {
            that.loading = true;
            deleteAction(that.url.deleteBatch, { ids: ids }).then((res) => {
              if (res.success) {
                //重新计算分页问题
                that.reCalculatePage(that.selectedRowKeys.length)
                that.$message.success(res.message);
                that.loadData();
                that.onClearSelected();
                that.alterFlag = new Date();
              } else {
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.loading = false;
            });
          }
        });
      }
    },
    equipmentStructuresShow(record) {
      this.$refs.EquipmentStructureDrawer.visible = true
      this.$refs.EquipmentStructureDrawer.title = '设备结构'
      setTimeout(() => {
        this.$bus.$emit('equipmentRecord', record)
        this.$bus.$emit('equipmentStructureId', '-1')
      }, 200)
    },
    equipmentResumeShow(record) {
      this.$refs.EquipmentResumeDrawer.visible = true
      this.$refs.EquipmentResumeDrawer.title = '设备履历'
      this.$refs.EquipmentResumeDrawer.handleShow(record)
    },
    searchReset() {
      this.queryParam = {};
      if (this.nodeSelected.key != -1) {
        this.disabled = false;
        this.queryParam.equipmentCategoryId = this.nodeSelected.key;
      } else {
        this.disabled = true;
      }
      this.selectedRowKeys = []
      this.selectionRows = []
      // this.$refs.ProcessParametersList.equipmentId = '-1'
      this.$refs.PrecisionParametersList.equipmentId = '-1'
      this.$refs.EquipmentFileList.equipmentId = '-1'
      this.loadData(1);
    },
    searchQuery() {
      this.selectedRowKeys = []
      this.selectionRows = []
      // this.$refs.ProcessParametersList.equipmentId = '-1'
      this.$refs.PrecisionParametersList.equipmentId = '-1'
      this.$refs.EquipmentFileList.equipmentId = '-1'
      this.loadData(1);
    },
    modalFormOk() {
      // æ–°å¢ž/修改 æˆåŠŸæ—¶ï¼Œé‡è½½åˆ—è¡¨
      this.loadData()
      //清空列表选中
      this.onClearSelected()
      // this.$refs.ProcessParametersList.equipmentId = '-1'
      this.$refs.PrecisionParametersList.equipmentId = '-1'
      this.$refs.EquipmentFileList.equipmentId = '-1'
    },
  },
  watch: {
    alterFlag() {
      this.$bus.$emit('queryTreeData');
    },
    selectionRows() {
      this.$bus.$emit('equipmentSelectionRows', this.selectionRows);
    },
    nodeSelected() {
      this.queryParam = {};
      if (this.nodeSelected.key != -1) {
        this.disabled = false;
        this.queryParam.equipmentCategoryId = this.nodeSelected.key;
      } else {
        this.disabled = true;
      }
      this.selectedRowKeys = []
      this.selectionRows = []
      // this.$refs.ProcessParametersList.equipmentId = '-1'
      this.$refs.PrecisionParametersList.equipmentId = '-1'
      this.$refs.EquipmentFileList.equipmentId = '-1'
      this.loadData(1);
    },
  },
  created() {
    this.queryParam = {};
    this.queryParam.equipmentCategoryId = this.nodeSelected.key;
    this.selectedRowKeys = []
    this.selectionRows = []
    this.loadData(1);
  }
}
</script>
<style>
@import '~@assets/less/common.less';
.frozenRowClass {
  color: #c9c9c9;
}
.success {
  color: green;
}
.error {
  color: red;
}
.fontweight {
  font-weight: bold;
}
</style>