lyh
5 天以前 9d783b455d6d704281ca2743ae45113e23422aad
升版导入
已添加1个文件
已修改2个文件
179 ■■■■■ 文件已修改
src/views/base/modules/file/MaintenanceStandardImportModule.vue 155 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/eam/base/EamMaintenanceStandardList.vue 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/eam/equipment/modules/EamEquipmentModal.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/base/modules/file/MaintenanceStandardImportModule.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,155 @@
<template>
  <a-modal :title="title" :visible="visible" @cancel="handleModalClose" :maskClosable="false">
    <a-upload :multiple="true" :file-list="fileList" :remove="handleRemove" :before-upload="beforeUpload" >
      <a-button type="primary" :disabled="uploading">
        <a-icon type="import"/>
        é€‰å–文件
      </a-button>
    </a-upload>
    <template slot="footer">
      <a-button @click="handleModalClose">取消</a-button>
      <a-button
        id="custom-upload-button"
        type="primary"
        :disabled="fileList.length === 0"
        :loading="uploading"
        @click="handleUpload"
      >
        ç¡®è®¤
      </a-button>
    </template>
  </a-modal>
</template>
<script>
import JUpload from '@/components/jeecg/JUpload'
import { getAction, postAction, uploadAction } from '@/api/manage'
export default {
  name: 'MaintenanceStandardImportModule',
  components: {
    JUpload,
  },
  data() {
    return {
      visible: false,
      title: '',
      id:'',
      fileList: [],
      uploadParams: {},
      uploading: false,
      isUploadMultiple: true,
      currentDeviceDocClassCode: 'SEND',
      currentTitleAfterClass: '',
      url: {
        add: "/eam/maintenanceStandard/importUpgrade",
      },
    }
  },
  created() {
  },
  methods: {
    /**
     * é€‰æ‹©å¥½æ–‡ä»¶ç‚¹å‡»ç¡®å®šåŽ
     * @param file æ–‡ä»¶å¯¹è±¡
     */
    beforeUpload(file) {
      if (this.isUploadMultiple) {
        if (!this.fileList.find(item => item.name === file.name)) this.fileList = [...this.fileList, file]
      } else this.fileList.splice(0, 1, file)
      return false
    },
    /**
     * åˆ é™¤æ–‡ä»¶åˆ—表项时触发
     * @param file æ–‡ä»¶å¯¹è±¡
     */
    handleRemove(file) {
      const index = this.fileList.indexOf(file)
      const newFileList = this.fileList.slice()
      newFileList.splice(index, 1)
      this.fileList = newFileList
    },
    // æŽ§åˆ¶æ–‡ä»¶ä¸Šä¼ çª—口关闭并清空文件列表
    handleModalClose() {
      this.visible = false
      this.fileList = []
    },
    upload(id){
      console.log("id",id)
      this.id = id
      this.isUploadMultiple = true
      this.visible = true
    },
    handleUpload() {
      const { fileList, $notification, handleModalClose} = this
      this.uploading = true
      let uploadedFileCount = 0
      let uploadSuccessFileCount = 0
      if (this.fileList.length === 0) {
        this.$message.info("请上传文件")
        this.uploading = false;
      }
      fileList.forEach((file, index) => {
        const formData = new FormData()
        formData.append('file', file)
        formData.append('id',this.id)
        uploadAction(this.url.add, formData).then(res => {
          if (res.success) {
            file.status = 'done'
            uploadSuccessFileCount++
            $notification.success({
              message: '消息',
              description: res.message
            })
          } else {
            file.status = 'error'
            $notification.error({
              message: '消息',
              description: res.message
            })
          }
        })
          .catch(err => {
            file.status = 'error'
          })
          .finally(() => {
            uploadedFileCount++
            fileList.splice(index, 1, file)
            if (uploadedFileCount === fileList.length) {
              if (uploadSuccessFileCount > 0) {
                this.$emit('ok')
              }
              // å½“文件全部上传完成后
              if (uploadSuccessFileCount === fileList.length) {
                handleModalClose();
              }
              this.uploading = false
            }
          })
      })
    }
  }
}
</script>
<style scoped lang="less">
/deep/ .ant-btn-primary#custom-upload-button {
  color: #fff;
  background-color: #67C23A;
  border-color: #67C23A;
  &[disabled] {
    color: rgba(0, 0, 0, 0.25);
    background-color: #f5f5f5;
    border-color: #d9d9d9;
  }
}
</style>
src/views/eam/base/EamMaintenanceStandardList.vue
@@ -100,6 +100,10 @@
          <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 v-has="'standard:edit'" @click.stop="handleEdit(record)">编辑</a>
@@ -170,6 +174,9 @@
    <!--审批窗口-->
    <maintenance-standard-approval-modal ref="maintenanceStandardApprovalModal" :selectShenpiData="selectedRowData"/>
    <!--导入文件-->
    <MaintenanceStandardImportModule ref="fileImportModule" @ok="getTreeDataByApi" />
  </a-card>
</template>
@@ -182,6 +189,7 @@
  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 {
@@ -194,6 +202,7 @@
      }
    },
    components: {
      MaintenanceStandardImportModule,
      MaintenanceStandardApprovalModal,
      LxSearchEquipmentSelect,
      EamMaintenanceStandardModal,
@@ -389,6 +398,19 @@
        this.$refs.maintenanceStandardApprovalModal.handleDetail(record)
      },
      /**
       * ç‚¹å‡»å‡ç‰ˆå¯¼å…¥æ—¶è§¦å‘时触发
       * @param record
       */
      handleAddUpgrade(id){
        this.$refs.fileImportModule.upload(id);
        this.$refs.fileImportModule.title="导入"
      },
      getTreeDataByApi(){
        this.loadData();
      },
      batchDel() {
        var ids = ''
        for (var a = 0; a < this.selectedRowKeys.length; a++) {
src/views/eam/equipment/modules/EamEquipmentModal.vue
@@ -36,7 +36,7 @@
                <a-col :span="customSpan">
                  <a-form-model-item prop="factoryOrgCode" label="使用部门">
                    <a-tree-select v-model="model.factoryOrgCode" style="width: 100%" show-search
                                   :tree-data="productionTreeData" :disabled="!editable"
                                   :tree-data="productionTreeData"
                                   :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
                                   placeholder="请选择使用部门" allow-clear treeNodeFilterProp="title"
                                   :replaceFields="{key:'orgCode',value:'orgCode'}"