lyh
17 小时以前 50e9a40ac746c7d46bd0b9f74e98d4d478cf5e64
src/views/eam/base/EamMaintenanceStandardList.vue
@@ -44,29 +44,31 @@
      <!-- 操作按钮区域 -->
      <div class="table-operator">
        <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
        <a-button v-has="'standard:add'" @click="handleAdd" type="primary" icon="plus">新增</a-button>
        <a-upload name="file" :showUploadList="false" :multiple="true" :headers="tokenHeader"
                  :action="inspectionImportExcel"
                  @change="handleImportExcel">
          <a-button type="primary" icon="import">点检标准导入</a-button>
          <a-button v-has="'standard:pointInspection'" type="primary" icon="import">点检标准导入</a-button>
        </a-upload>
        <a-button type="primary" icon="download" @click="handleTemplateXlsDownload(url.inspectionXlsDownloadUrl)">
        <a-button v-has="'standard:pointInspectionDownload'" type="primary" icon="download"
                  @click="handleTemplateXlsDownload(url.inspectionXlsDownloadUrl)">
          点检标准模板下载
        </a-button>
        <a-upload name="file" :showUploadList="false" :multiple="true" :headers="tokenHeader"
                  :action="secondMaintenanceImportExcel"
                  @change="handleImportExcel">
          <a-button type="primary" icon="import">二保标准导入</a-button>
          <a-button v-has="'standard:secondMaintenance'" type="primary" icon="import">二保标准导入</a-button>
        </a-upload>
        <a-button type="primary" icon="download"
        <a-button v-has="'standard:secondMaintenanceDownload'" type="primary" icon="download"
                  @click="handleTemplateXlsDownload(url.secondMaintenanceXlsDownloadUrl)">二保标准模板下载
        </a-button>
        <a-upload name="file" :showUploadList="false" :multiple="true" :headers="tokenHeader"
                  :action="thirdMaintenanceImportExcel"
                  @change="handleImportExcel">
          <a-button type="primary" icon="import">三保标准导入</a-button>
          <a-button v-has="'standard:ThirdMaintenance'" type="primary" icon="import">三保标准导入</a-button>
        </a-upload>
        <a-button type="primary" icon="download" @click="handleTemplateXlsDownload(url.thirdMaintenanceXlsDownloadUrl)">
        <a-button v-has="'standard:ThirdMaintenanceDownload'" type="primary" icon="download"
                  @click="handleTemplateXlsDownload(url.thirdMaintenanceXlsDownloadUrl)">
          三保标准模板下载
        </a-button>
        <a-dropdown v-if="selectedRowKeys.length > 0">
@@ -91,27 +93,52 @@
      </div>
      <a-table ref="table" size="middle" bordered rowKey="id" :columns="columns" :dataSource="dataSource"
               :pagination="ipagination" :loading="loading" class="j-table-force-nowrap"
               :pagination="ipagination" :loading="loading" :scroll="{x:'max-content'}"
               :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" :customRow='clickThenSelect'
               @change="handleTableChange">
        <!--使用部门-->
        <template slot="factoryOrgCode" slot-scope="text,record">
          {{[record.zxfactoryOrgCode_dictText].filter(item=>item).join('/')}}
        </template>
        <span slot="action" slot-scope="text, record">
          <a v-if="record.standardStatus === 'START'" @click.stop="handleUpgrade(record)">升版</a>
          <a v-has="'standard:upgrade'" v-if="record.standardStatus === 'START'"
             @click.stop="handleUpgrade(record)">升版</a>
          <a-divider v-has="'standard:add:upgrade'" v-if="record.standardStatus === 'START'" type="vertical"/>
          <a v-has="'standard:add:upgrade'" v-if="record.standardStatus === 'START'" @click="handleAddUpgrade(record.id)" >升版导入</a>
          <template v-if="record.standardStatus === 'WAIT_SUBMIT'">
              <a @click.stop="handleEdit(record)">编辑</a>
              <a v-has="'standard:edit'" @click.stop="handleEdit(record)">编辑</a>
              <a-divider type="vertical"/>
              <a-divider v-has="'standard:edit'" type="vertical"/>
              <a-popconfirm title="确定发起流程吗?" @confirm="() => startProcess(record.id)">
                  <a @click.stop="event=>event.stopPropagation()">发起流程</a>
              <a-popconfirm title="确定提交吗?" @confirm="() => startProcess(record.id)">
                  <a v-has="'standard:saveFlow'" @click.stop="event=>event.stopPropagation()">提交</a>
              </a-popconfirm>
              <a-divider type="vertical"/>
              <a-divider v-has="'standard:saveFlow'" type="vertical"/>
              <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a @click.stop="event=>event.stopPropagation()">删除</a>
                  <a v-has="'standard:del'" @click.stop="event=>event.stopPropagation()">删除</a>
              </a-popconfirm>
          </template>
          <template v-if="record.standardStatus !== 'WAIT_SUBMIT'">
            <a-divider v-has="'standard:delete'" type="vertical" v-if="record.standardStatus=='START'"/>
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a v-has="'standard:delete'" @click.stop="event=>event.stopPropagation()">删除</a>
          </a-popconfirm>
          </template>
          <template>
            <a-divider type="vertical"/>
            <a @click.stop="handleDetail(record)">详情</a>
          </template>
        </span>
      </a-table>
@@ -149,6 +176,12 @@
    <!-- 表单区域 -->
    <eamMaintenanceStandard-modal ref="modalForm" @ok="modalFormOk"/>
    <!--审批窗口-->
    <maintenance-standard-approval-modal ref="maintenanceStandardApprovalModal" :selectShenpiData="selectedRowData"/>
    <!--导入文件-->
    <MaintenanceStandardImportModule ref="fileImportModule" @ok="getTreeDataByApi" />
  </a-card>
</template>
@@ -159,6 +192,9 @@
  import EamMaintenanceStandardDetailList from '@views/eam/base/modules/EamMaintenanceStandardDetailList'
  import { deleteAction, getAction, templateXlsDownload } from '@api/manage'
  import LxSearchEquipmentSelect from '@views/eam/equipment/modules/LxSearchEquipmentSelect.vue'
  import MaintenanceStandardApprovalModal
    from '../../flowable/workflow/MaintenanceStandard/MaintenanceStandardApprovalModal'
  import MaintenanceStandardImportModule from "@views/base/modules/file/MaintenanceStandardImportModule.vue";
  export default {
@@ -171,6 +207,8 @@
      }
    },
    components: {
      MaintenanceStandardImportModule,
      MaintenanceStandardApprovalModal,
      LxSearchEquipmentSelect,
      EamMaintenanceStandardModal,
      EamMaintenanceStandardDetailList
@@ -179,22 +217,33 @@
      return {
        description: '保养规范页面',
        disableMixinCreated: true,
        selectedRowData: {},
        // 表头
        columns: [
          {
            title: '统一编码',
            align: 'center',
            dataIndex: 'equipmentCode'
            dataIndex: 'equipmentCode',
          },
          {
            title: '设备名称',
            align: 'center',
            dataIndex: 'equipmentName'
            dataIndex: 'equipmentName',
          },
          {
            title: '设备型号',
            align: 'center',
            dataIndex: 'equipmentModel'
            dataIndex: 'equipmentModel',
          },
          {
            title: '使用部门',
            align: 'center',
            scopedSlots: { customRender: 'factoryOrgCode' },
          },
          {
            title: '规范状态',
            align: 'center',
            dataIndex: 'standardStatus_dictText',
          },
          {
            title: '保养分类',
@@ -217,30 +266,21 @@
            title: '保养周期',
            align: 'center',
            dataIndex: 'maintenancePeriod',
            width: 100
          },
          {
            title: '保养周期单位',
            align: 'center',
            dataIndex: 'periodUnit',
            width: 120
          },
          {
            title: '初始日期',
            align: 'center',
            dataIndex: 'initialDate',
            width: 100
          },
          {
            title: '规范状态',
            align: 'center',
            dataIndex: 'standardStatus_dictText'
          },
          {
            title: '规范版本',
            align: 'center',
            dataIndex: 'standardVersion',
            width: 100
          }
        ],
        url: {
@@ -252,7 +292,7 @@
          inspectionImportExcel: '/eam/maintenanceStandard/importPointInspection',
          secondMaintenanceImportExcel: '/eam/maintenanceStandard/importSecondMaintenanceStandard',
          thirdMaintenanceImportExcel: '/eam/maintenanceStandard/importThirdMaintenanceStandard',
          inspectionXlsDownloadUrl: '导入模板/设备点检标准导入模板.xlsx',
          inspectionXlsDownloadUrl: '导入模板/设备点检标准导入模板.xls',
          secondMaintenanceXlsDownloadUrl: '导入模板/生产设备二级保养规范.docx',
          thirdMaintenanceXlsDownloadUrl: '导入模板/生产设备三级保养规范.docx'
        },
@@ -278,7 +318,8 @@
        title: '操作',
        dataIndex: 'action',
        align: 'center',
        scopedSlots: { customRender: 'action' }
        scopedSlots: { customRender: 'action' },
        fixed: 'right'
      }
      this.columns = [...this.columns, operationColumn]
      this.loadData(1)
@@ -344,13 +385,115 @@
          })
      },
      /**
       * 点击升版时触发时触发
       * @param record
       */
      handleUpgrade(record) {
        //升版
        this.$refs.modalForm.upgrade(record)
        this.$refs.modalForm.title = '升版'
        this.$refs.modalForm.disableSubmit = false
      },
      /**
       * 点击详情时触发时触发
       * @param record
       */
      handleDetail(record) {
        this.selectedRowData = Object.assign({}, record)
        this.$refs.maintenanceStandardApprovalModal.title = '详情'
        this.$refs.maintenanceStandardApprovalModal.disableSubmit = true
        this.$refs.maintenanceStandardApprovalModal.visible = true
        this.$refs.maintenanceStandardApprovalModal.handleDetail(record)
      },
      /**
       * 点击升版导入时触发时触发
       * @param record
       */
      handleAddUpgrade(id){
        this.$refs.fileImportModule.upload(id);
        this.$refs.fileImportModule.title="升版导入"
      },
      getTreeDataByApi(){
        this.loadData();
      },
      /* 导入 */
      handleImportExcel(info) {
        this.loading = true;
        if (info.file.status === 'done') {
          this.loading = false;
          // 检查响应内容是否为CSV格式(包含未找到的设备编码)
          if (info.file.response && typeof info.file.response === 'string' &&
            info.file.response.includes('未找到的设备编码')) {
            // 创建CSV文件并下载
            const blob = new Blob([info.file.response], { type: 'text/csv;charset=utf-8' });
            const downloadUrl = window.URL.createObjectURL(blob);
            const link = document.createElement('a');
            link.href = downloadUrl;
            link.setAttribute('download', '未找到的设备编码.csv');
            document.body.appendChild(link);
            link.click();
            document.body.removeChild(link);
            window.URL.revokeObjectURL(downloadUrl);
            // 显示提示信息
            this.$notification.warning({
              message: '导入完成',
              description: '导入成功但存在未找到的设备编码,已下载未找到的设备编码列表'
            });
            this.loadData();
            return;
          }
          // 处理常规JSON响应
          if (info.file.response && info.file.response.success) {
            this.$notification.success({
              message: '导入成功',
              description: info.file.response.message || `${info.file.name} 文件上传成功`
            });
            this.loadData();
          } else {
            const fileName = info.file.name || '未知文件';
            const errorMessage = info.file.response && info.file.response.message
              ? info.file.response.message
              : '导入失败,未知错误';
            this.$notification.error({
              message: '导入失败',
              description: `${fileName} ${errorMessage}`
            });
          }
        } else if (info.file.status === 'error') {
          this.loading = false;
          const fileName = info.file.name || '未知文件';
          let errorMessage = '上传失败,未知错误';
          if (info.file.response) {
            if (info.file.response.message) {
              errorMessage = info.file.response.message;
            } else if (info.file.response.error) {
              errorMessage = info.file.response.error;
            }
          } else if (info.file.error) {
            errorMessage = info.file.error.message || info.file.error;
          }
          this.$notification.error({
            message: '上传失败',
            description: `${fileName} ${errorMessage}`
          });
        }
      },
      batchDel() {
        var ids = ''
        for (var a = 0; a < this.selectedRowKeys.length; a++) {