index.vue 9.15 KB
<!-- 嘀加上架 -->
<template>
  <d2-container class="shelfManage">
    <div class="header" slot="header">
      <d2-search ref="showSearch" class="show-search" :search-form="searchForm" :label-width="'100px'"
        :form-data="showFormData">
      </d2-search>
      <div class="up-btns">
        <el-button :id="tableParams.btnId" size="small" type="primary">
          查询
        </el-button>
        <el-button size="small" @click="handleReset"> 重置 </el-button>
      </div>
    </div>
    <div class="d2-container-content">
      <d2-table-header>
        <span slot="left">
          <!-- 嘀加上架与销售合同 -->
          <span style="display: inline-block; margin-right: 10px">
            <auth-button category="Button" :show-btn-ids="['9031301']" />
          </span>
          <!-- 嘀加上架修改 -->
          <auth-button style="display: inline-block" category="Button" :show-btn-ids="['9031303']" />
        </span>
      </d2-table-header>
      <d2-table ref="packageIndexTable" :search-form="searchForm" :table-params="tableParams" :get-list-api="getListApi"
        :before-search-fn="beforeSearchFn">
        <div slot="auth-button" slot-scope="scope">
          <!-- 查看 - 查看合同 -->
          <span style="margin-right: 10px">
            <auth-button :data="scope.scope" :show-btn-ids="['9031304']" />
          </span>
          <!-- 确认 - 编辑合同 -->
          <span style="margin-right: 10px" v-if="scope.scope.systemStatus == 1">
            <auth-button :data="scope.scope" :show-btn-ids="['9031306']" />
          </span>
          <!-- 驳回 -->
          <span style="margin-right: 10px" v-if="scope.scope.systemStatus == 1">
            <auth-button :data="scope.scope" :show-btn-ids="['9031308']" />
          </span>
          <!-- 重新发起 -->
          <span style="margin-right: 10px" v-if="
            scope.scope.systemStatus == 4 ||
            scope.scope.approveStatus == 3 ||
            scope.scope.approveStatus == 4
          ">
            <auth-button :data="scope.scope" :show-btn-ids="['9031309']" />
          </span>
        </div>
      </d2-table>
    </div>
    <!-- 驳回 -->
    <reject-dialog :reject-visible="rejectVisible" :params-obj="recordInfo" v-if="rejectVisible"
      @dialogClose="rejectDialogClose" />
  </d2-container>
</template>
<script>
import { Util, deepClone } from "@/common/util"
import { mapActions } from "vuex"
import {
  approveTypeOpt,
  systemStatusOpt,
  approveStatusOpt
} from "@/common/constants.js"
import rejectDialog from "./components/common/rejectDialog.vue"
import { getPage } from "@api/shelfManage.js"
export default {
  name: "ShelfManage",
  components: {
    rejectDialog
  },
  data() {
    return {
      searchForm: {
        businessCode: "",
        workWechatApproveCode: "",
        approveType: "",
        systemStatus: "",
        approveStatus: ""
      },
      searchFormSearch: {},
      showFormData: [
        {
          label: "单据编号",
          name: "businessCode",
          type: "input",
          maxlength: "20",
          isClear: true
        },
        {
          label: "审批编号",
          name: "workWechatApproveCode",
          type: "input",
          maxlength: "20",
          isClear: true
        },
        {
          label: "审批类型",
          name: "approveType",
          type: "select",
          isClear: true,
          optionList: [],
          optionId: "confId",
          optionLabel: "confValue",
          optionsName: "approveTypeOpt"
        },
        {
          label: "系统状态",
          name: "systemStatus",
          type: "select",
          isClear: true,
          optionList: [],
          optionId: "confId",
          optionLabel: "confValue",
          optionsName: "systemStatusOpt"
        },
        {
          label: "审批状态",
          name: "approveStatus",
          type: "select",
          isClear: true,
          optionList: [],
          optionId: "confId",
          optionLabel: "confValue",
          optionsName: "approveStatusOpt"
        }
      ],
      getListApi: getPage,
      // 表格参数
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: "list",
        tableOption: {
          width: "170"
        },
        tableColumns: [
          {
            label: "单据编号",
            prop: "businessCode"
          },
          {
            label: "审批类型",
            prop: "approveType",
            width: "150px",
            formatter: (cellValue) => {
              return this.baseData.approveTypeOpt.find(
                (item) => item.confId === cellValue.approveType
              )?.confValue
            }
          },
          {
            label: "审批编号",
            prop: "workWechatApproveCode"
          },
          {
            label: "提交时间",
            prop: "createdDate",
            width: "160px",
            formatter: (cellValue) => {
              return cellValue.createdDate
                ? Util.dateFormate(cellValue.createdDate, "YYYY-MM-DD HH:mm:ss")
                : "-"
            }
          },
          {
            label: "提交人",
            prop: "committer"
          },
          {
            label: "系统状态",
            prop: "systemStatus",
            width: "100px",
            formatter: (cellValue) => {
              return this.baseData.systemStatusOpt.find(
                (item) => item.confId === cellValue.systemStatus
              )?.confValue
            }
          },
          {
            label: "审批状态",
            prop: "approveStatus",
            width: "100px",
            formatter: (cellValue) => {
              return this.baseData.approveStatusOpt.find(
                (item) => item.confId === cellValue.approveStatus
              )?.confValue
            },
            className: (cellValue) => {
              return {
                1: "yellowSpot",
                2: "greenSpot",
                3: "redSpot",
                4: "ashSpot"
              }[cellValue.approveStatus]
            }
          }
        ]
      },
      // 基本数据
      baseData: {
        approveTypeOpt: deepClone(approveTypeOpt),
        systemStatusOpt: deepClone(systemStatusOpt),
        approveStatusOpt: deepClone(approveStatusOpt)
      },
      recordInfo: {},
      rejectVisible: false
    }
  },
  mounted() {
    this.getBaseData()
  },
  methods: {
    ...mapActions({
      close: "d2admin/page/close"
    }),
    async getBaseData() {
      this.getOptionsList()
    },
    getOptionsList() {
      this.showFormData.forEach((item, index) => {
        if (item.type === "select") {
          if (
            this.baseData[item.optionsName].length &&
            this.baseData[item.optionsName][0][
            this.showFormData[index].optionLabel
            ] !== "全部"
          ) {
            const temp = {}
            temp[this.showFormData[index].optionId] = ""
            temp[this.showFormData[index].optionLabel] = "全部"
            this.baseData[item.optionsName].unshift(temp)
          }
          this.$set(
            this.showFormData[index],
            "optionList",
            this.baseData[item.optionsName]
          )
        }
      })
    },
    getShelfManageList() { },
    beforeSearchFn() {
      return new Promise((resolve) => {
        this.searchFormSearch = deepClone(this.searchForm)
        resolve()
      })
    },
    handleReset() {
      this.searchForm = {
        businessCode: "",
        workWechatApproveCode: "",
        approveType: "",
        systemStatus: "",
        approveStatus: ""
      }
      this.$refs.packageIndexTable.refreshTable(false, true)
    },

    // 确认 - 编辑合同
    handleEditContract(row) {
      this.close({ tagName: "/editContract" })
      this.$router.push({
        name: "editContract",
        query: {
          id: row.id,
          businessCode: row.businessCode
        }
      })
    },
    // 查看 - 查看合同
    handleContractDetail(row) {
      this.close({ tagName: "/contractDetail" })
      this.$router.push({
        name: "contractDetail",
        params: {
          id: row.id
        }
      })
    },

    // 驳回
    handleReject(row) {
      this.recordInfo = row
      this.rejectVisible = !this.rejectVisible
    },
    // 关闭驳回弹窗
    rejectDialogClose(obj) {
      this[obj.attrName] = !this[obj.attrName]
      if (obj.flag) {
        this.$refs.packageIndexTable.refreshTable()
      }
    },

    // 嘀加上架与销售合同
    handleAdd() {
      this.close({ tagName: "/editShelf" })
      this.$router.push({
        name: "editShelf",
        params: {
          operate: "add",
          type: 1
        }
      })
    },

    // 嘀加上架修改
    handleEdit() {
      this.close({ tagName: "/editShelf" })
      this.$router.push({
        name: "editShelf",
        params: {
          operate: "edit",
          type: 2
        }
      })
    },

    // 重新发起
    handleAgain(row) {
      this.close({ tagName: "/editShelf" })
      this.$router.push({
        name: "editShelf",
        params: {
          operate: "again",
          recordId: row.id
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped></style>