吴羡
10 小时以前 a1faa94fbf85553f22da934a1abc745d89dd8667
src/views/CNAS/resourceDemand/device/component/operationInstruction.vue
@@ -17,11 +17,12 @@
      <el-table-column label="设备编号" min-width="150" prop="deviceNumber"></el-table-column>
      <el-table-column label="设备型号" min-width="150" prop="deviceModel"></el-table-column>
      <el-table-column label="文件编号" min-width="150" prop="documentNumber"></el-table-column>
      <el-table-column label="文件名字" min-width="150" prop="fileName"></el-table-column>
      <el-table-column label="文件名称" min-width="150" prop="fileName"></el-table-column>
      <el-table-column label="文档说明" min-width="150" prop="documentNote"></el-table-column>
      <el-table-column label="上传人" min-width="150" prop="uploaderName"></el-table-column>
      <el-table-column label="上传时间" min-width="150" prop="updateTime"></el-table-column>
      <el-table-column label="生效时间" min-width="150" prop="entryIntoForceTime"></el-table-column>
      <el-table-column label="上传时间" min-width="150" prop="updateTime" :formatter="formatDateCell"></el-table-column>
      <el-table-column label="生效时间" min-width="150" prop="entryIntoForceTime"
        :formatter="formatDateCell"></el-table-column>
      <el-table-column label="审批人" min-width="150" prop="approverName"></el-table-column>
      <el-table-column label="审批状态" min-width="150" prop="status">
        <template v-slot="scope">
@@ -31,14 +32,16 @@
      <el-table-column label="操作" min-width="180" fixed="right" prop="name">
        <template v-slot="scope">
          <el-button link type="primary" size="small" @click="downloadFile(scope.row.fileSystemName)">下载</el-button>
          <el-button link type="primary" size="small" style="color: red;"
          <el-button link type="primary" size="small" style="color: red;" :disabled="scope.row.status === true"
            @click="deleteHomeworkGuidebook(scope.row)">删除</el-button>
          <el-button link type="primary" size="small" @click="instructionEditFun(scope.row)">编辑</el-button>
          <el-button link type="primary" size="small" @click="approval(scope.row)">审批</el-button>
          <el-button link type="primary" size="small" :disabled="scope.row.status === true"
            @click="instructionEditFun(scope.row)">编辑</el-button>
          <el-button link type="primary" size="small" :disabled="scope.row.status === true"
            @click="approval(scope.row)">审批</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="1"
    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="search.current"
      :page-sizes="[10, 20, 30, 50, 100]" :page-size="search.size" layout="->,total, sizes, prev, pager, next, jumper"
      :total="search.total" background>
    </el-pagination>
@@ -82,7 +85,7 @@
        <el-table :data="documentTableData" border style="width: 100%;" tooltip-effect="dark" :row-key="getRowKey"
          @selection-change="handleSelectionChange" height="29em">
          <el-table-column type="selection" width="55%">
          <el-table-column type="selection" width="55">
          </el-table-column>
          <el-table-column label="序号" prop="id" type="index" width="60"></el-table-column>
          <el-table-column label="设备名称" prop="deviceName" show-overflow-tooltip min-width="125"></el-table-column>
@@ -91,7 +94,8 @@
          <el-table-column label="文档编号" prop="documentNumber" show-overflow-tooltip min-width="125"></el-table-column>
          <el-table-column label="文件名称" prop="fileName" show-overflow-tooltip min-width="125"></el-table-column>
          <el-table-column label="上传人" prop="author" show-overflow-tooltip min-width="125"></el-table-column>
          <el-table-column label="上传时间" prop="updateTime" show-overflow-tooltip min-width="125"></el-table-column>
          <el-table-column label="上传时间" prop="updateTime" show-overflow-tooltip min-width="125"
            :formatter="formatDateCell"></el-table-column>
          <el-table-column min-width="100" label="操作" fixed="right">
            <template v-slot="scope">
              <el-button link type="primary" size="small" @click="downloadFile(scope.row.fileSystemName)">下载</el-button>
@@ -188,6 +192,7 @@
  pageByPageQueryOfHomeworkInstructions,
  selectDeviceParameter,
} from '@/api/cnas/resourceDemand/device.js'
import { formatListDate } from './dateFormat'
export default {
  props: {
    clickNodeVal: {
@@ -266,6 +271,9 @@
    }
  },
  methods: {
    formatDateCell(row, column, cellValue) {
      return formatListDate(cellValue)
    },
    approval(row) {
      this.$confirm('是否审批通过!', '提示', {
        confirmButtonText: '通过',
@@ -273,8 +281,11 @@
        type: 'warning'
      }).then(() => {
        this.approvalFun(row.id, true)
      }).catch(() => {
        this.approvalFun(row.id, false)
      }).catch((action) => {
        // 只有点击“不通过”才提交驳回,点右上角关闭/Esc 视为放弃操作
        if (action === 'cancel') {
          this.approvalFun(row.id, false)
        }
      });
    },
    approvalFun(id, status) {
@@ -329,9 +340,9 @@
      homeworkGuidebookEditor({ instructionId: row.instructionId }).then(res => {
        if (res.code == 200) {
          this.instructionForm = res.data.instruction;
          if (this.instructionForm.fileSystemName) {
            this.fileList1.push({ name: this.instructionForm.fileName })
          }
          this.fileList1 = this.instructionForm.fileSystemName
            ? [{ name: this.instructionForm.fileName }]
            : []
          this.documentTableData = res.data.list;
          // 删除用
          this.documentTableData.forEach((v, k) => {
@@ -402,6 +413,7 @@
            this.$message.success('修改成功');
            console.log('this.documentTableData---edit', this.documentTableData[this.tableDataIndex])
          } else {
            this.form.index = this.getNextRowIndex();
            this.documentTableData.push(this.form);
            this.dialogVisible1 = false;
            this.$message.success('添加成功');
@@ -423,12 +435,17 @@
    editFun(row, index) {
      this.form = { ...row }
      this.tableDataIndex = index;
      console.log('this.tableDataIndex', this.tableDataIndex)
      // 回显列表
      // 回显列表前先清空,避免重复显示上一次的附件
      this.fileList = []
      if (this.form.fileSystemName) {
        this.fileList.push({ name: this.form.fileName })
      }
      this.dialogVisible1 = true
    },
    getNextRowIndex() {
      return this.documentTableData.reduce((max, item) => {
        return typeof item.index === 'number' && item.index > max ? item.index : max
      }, -1) + 1
    },
    closeDia() {
      this.dialogVisible1 = false
@@ -443,22 +460,24 @@
        this.$message.error('请选择要删除的选项');
        return;
      }
      // 删除保存好的数据
      let ids = this.selectedRow
      const selectedIndexes = this.selectedRow.map(item => item.index);
      // 删除已保存的数据;本次新加、尚未落库的行没有 id,不调接口
      const ids = this.selectedRow
        .filter(item => item.id !== undefined)
        .map(item => item.id).join(',');
      //有错误
      const res = await deleteHomeworkGuidebook({ ids });
      if (res.code === 200) {
        // 删除视图的数据
        for (const resKey in this.selectedRow) {
          this.documentTableData = this.documentTableData.filter(item => item.index === this.selectedRow[resKey].index)
      if (ids) {
        const res = await deleteHomeworkGuidebook({ ids });
        if (res.code !== 200) {
          return;
        }
        this.$message.success({
          message: '删除成功',
          type: 'success'
        });
      }
      // 一次性过滤掉所有选中行,保留其余数据
      this.documentTableData = this.documentTableData.filter(item => !selectedIndexes.includes(item.index))
      this.selectedRow = []
      this.$message.success({
        message: '删除成功',
        type: 'success'
      });
    },
    onSuccess(response, file, fileList) {
      this.form.fileName = file.name;
@@ -476,8 +495,8 @@
      this.form.fileSystemName = ''
    },
    handleRemove1(file, fileList) {
      this.form.fileName = ''
      this.form.fileSystemName = ''
      this.instructionForm.fileName = ''
      this.instructionForm.fileSystemName = ''
    },
    beforeRemove(file) {
      return this.$confirm(`确定移除 ${file.name}?`)
@@ -486,7 +505,12 @@
      this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件。`);
    },
    getList() {
      pageByPageQueryOfHomeworkInstructions({ ...this.search }).then(res => {
      const params = { ...this.search }
      // 选中具体设备时只查该设备的作业指导书
      if (this.clickNodeVal && this.clickNodeVal.value) {
        params.deviceId = this.clickNodeVal.value
      }
      pageByPageQueryOfHomeworkInstructions(params).then(res => {
        if (res.code == 200) {
          this.tableData = res.data.records;
          this.search.total = res.data.total