src/views/standard/standardLibrary/audit.vue
@@ -1,34 +1,222 @@
<template>
  <div class="capacity-scope">
    <div class="search">
      <div>
        <el-form :model="queryParams" ref="queryParams" size="small" :inline="true">
          <el-form-item label="模板名称" prop="name">
            <el-input v-model="queryParams.name" clearable placeholder="请输入" size="small"
              @keyup.enter.native="refreshTable()"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" size="mini" @click="refreshTable">查询</el-button>
            <el-button size="mini" @click="refresh">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
      <el-form :model="queryParams" ref="queryParams" size="small" :inline="true">
        <el-form-item label="更新人" prop="createUserName">
          <el-input v-model="queryParams.createUserName" clearable placeholder="请输入" size="small"
            @keyup.enter.native="refreshTable()"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" size="mini" @click="refreshTable">查询</el-button>
          <el-button size="mini" @click="refresh">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <lims-table :tableData="tableData" :column="column" :page="page" :tableLoading="tableLoading"
      :height="'calc(100vh - 250px)'" @pagination="pagination"></lims-table>
  </div>
</template>
<script>
import {
  standardProductListRecordPage,
  productListCheck,
} from "@/api/standard/standardLibrary";
import limsTable from "@/components/Table/lims-table.vue";
export default {
  components: {
    limsTable,
  },
  data() {
    return {
      queryParams: {}
      queryParams: {},
      tableData: [],
      column: [
        { label: "更新原因", prop: "remark" },
        { label: "更新时间", prop: "updateTime" },
        { label: "更新人", prop: "createUserName" },
        {
          label: "状态", prop: "checkStatus",
          dataType: "tag",
          formatData: (params) => {
            let obj = this.checkStatusList.find((m) => m.value == params)
            if (obj) {
              return obj.label
            }
          },
          formatType: (params) => {
            let obj = this.checkStatusList.find((m) => m.value == params)
            if (obj) {
              return obj.type
            }
          }
        },
        {
          dataType: "action",
          label: "操作",
          operation: [
            {
              name: "上传",
              type: "upload",
              accept: '.jpg,.jpeg,.png,.gif,.doc,.docx,.xls,.xlsx,.pdf',
              url: '/updateRecord/uploadRecordFile',
              uploadIdFun: (row) => {
                return row.id
              },
              handleSuccessUp: () => {
                this.getList()
              },
              disabled: (row) => {
                return row.checkStatus > 1;
              },
            },
            {
              name: "审批",
              type: "text",
              clickFun: (row) => {
                this.handleCheck(row);
              },
              disabled: (row) => {
                return row.checkStatus > 1;
              },
            },
            {
              name: "查看",
              type: "text",
              clickFun: (row) => {
                this.$tab.closeRightPage();
                this.$router.push({
                  path: "/audit/auditDetail", query: {
                    auditId: row.id
                  }
                });
              },
            },
            {
              name: "下载附件",
              type: "text",
              clickFun: (row) => {
                this.handleDown(row);
              },
            },
          ],
        },
      ],
      page: {
        total: 0,
        size: 10,
        current: 0,
      },
      tableLoading: false,
      checkStatusList: [
        {
          value: 0,
          label: '未提交',
          type: 'danger'
        },
        {
          value: 1,
          label: '待审核',
          type: 'warning'
        },
        {
          value: 2,
          label: '通过',
          type: 'success'
        },
        {
          value: 3,
          label: '不通过',
          type: 'danger'
        },
      ],
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    refreshTable() { },
    refresh() { }
    getList() {
      this.tableLoading = true;
      let param = { ...this.queryParams, ...this.page };
      delete param.total;
      standardProductListRecordPage({ ...param })
        .then((res) => {
          this.tableLoading = false;
          if (res.code === 200) {
            this.tableData = res.data.records;
            this.page.total = res.data.total;
          }
        })
        .catch((err) => {
          this.tableLoading = false;
        });
    },
    pagination({ page, limit }) {
      this.page.current = page;
      this.page.size = limit;
      this.getList();
    },
    refreshTable(e) {
      this.page.current = 1;
      this.getList();
    },
    refresh() {
      this.queryParams = {};
      this.page.current = 1;
      this.getList();
    },
    // 审核
    handleCheck(row) {
      this.$confirm("是否审核通过?", "审核", {
        confirmButtonText: "通过",
        cancelButtonText: "不通过",
        type: "warning",
        closeOnClickModal: false, // 禁止点击遮罩层关闭
        distinguishCancelAndClose: true,
        beforeClose: (action, instance, done) => {
          if (action === 'confirm') {
            // 通过
            productListCheck({
              checkStatus: 2,
              id: row.id
            }).then(res => {
              if (res.code == 200) {
                this.refresh()
                done();
              }
            })
          } else if (action === 'cancel') {
            // 不通过
            productListCheck({
              checkStatus: 3,
              id: row.id
            }).then(res => {
              if (res.code == 200) {
                this.refresh()
                done();
              }
            })
          } else if (action === 'close') {
            // 点击“×”按钮,不允许关闭
            done();
            console.log("×按钮点击事件,不关闭弹框");
          }
        }
      })
    },
    // 下载附件
    handleDown(row) {
      this.$download.saveAs(row.filePath, row.fileName);
    },
  }
}
</script>
<style scoped></style>
<style scoped>
.search {
  height: 46px;
  display: flex;
  justify-content: space-between;
}
</style>