directorReview.vue 11.8 KB
<!-- 采购审核-总监审核 -->
<template>
  <d2-container class="container">
    <div class="header" slot="header">
      <d2-search ref="showSearch" class="show-search" :search-form="searchForm" :form-data="showFormData">
      </d2-search>
      <div class="up-btns">
        <el-button :id="tableParams.btnId" size="small" type="primary" handle>
          查询
        </el-button>
        <el-button size="small" @click="handleReset">
          重置
        </el-button>
      </div>
    </div>
    <div class="d2-container-content">
      <d2-table-header>
        <auth-button category="Button" :show-btn-ids="['9090801']" />
      </d2-table-header>
      <d2-table ref="purchasementReviewTable" :search-form="tableSearchForm" :table-params="tableParams" :table-data="tableData" :get-list-api="getListApi" :before-search-fn="beforeSearchFn">
        <auth-button slot="auth-button" slot-scope="scope" :data="scope.scope" />
      </d2-table>
    </div>
    <orderDeatilDialog :visible.sync="detailVisible" v-if="detailVisible" :params-obj="paramsObj"></orderDeatilDialog>
    <CheckDialog :check-visible="checkVisible" v-if="checkVisible" :params-obj="paramsObj" @dialogClose="dialogClose">
    </CheckDialog>
    <rejectDialog :reject-visible="rejectVisible" v-if="rejectVisible" :params-obj="paramsObj" :filter-reject-list="[1]" @dialogClose="dialogClose">
    </rejectDialog>
  </d2-container>
</template>

<script>
import { createProductIdFilter } from "@/common/productId";
import { Util, deepClone } from '@/common/util'
import { director_statusOptions, defaultDeliveryStatusOptions, defaultPutStatusOptions, purchasingPatternOptions, director_statusOptions_table } from './constant'
import { mapActions, mapState } from 'vuex'
import { getPurchaseOrderList, getMerchantList, purchaseOrderCancelOrCheck, directorReviewPage, operatorreviewOperatorAudit } from '@/api/purchaseShopping.js'
import orderDeatilDialog from './components/orderDetailDialog'
import rejectDialog from './components/rejectDialog'
import CheckDialog from './components/CheckDialog'
export default {
  name: 'PurchaseOrder',
  components: {
    orderDeatilDialog,
    rejectDialog,
    CheckDialog
  },
  data() {
    return {
      searchForm: {
        status: '',
        deliveryStatus: '',
        putStatus: '',
        // merchantId: '',
        merchantName: '',
        sortType: 2,
        orderTimeStr: [],
				purchasingPattern: "",
				commodityCode: "",
      },
      tableSearchForm: {},
      tableData: [],
      showFormData: [
        {
          label: '订单编号',
          name: 'orderCode',
          type: 'input',
          isClear: true
        },
				createProductIdFilter(),
        {
          label: '下单时间',
          name: 'placeOrderTimeStr',
          type: 'datePicker',
          isClear: true,
          pickerOptions: 'rangePickerOptions'
        },
        {
          label: '下单商户',
          name: 'merchantName',
          type: 'input',
          isClear: true
        },
        {
          label: '订单状态',
          name: 'statuses',
          type: 'select',
          optionList: [],
          optionId: 'id',
          optionLabel: 'label',
          optionsName: 'director_statusOptions'
        },
        {
          label: '发货状态',
          name: 'deliveryStatus',
          type: 'select',
          optionList: [],
          optionId: 'id',
          optionLabel: 'label',
          optionsName: 'defaultDeliveryStatusOptions'
        },
        {
          label: '采购模式',
          name: 'purchasingPattern',
          type: 'select',
          optionList: [],
          optionId: 'id',
          optionLabel: 'label',
          optionsName: 'purchasingPatternOptions'
        },
        {
          label: '发货主体',
          name: 'sendOutMerchantName',
          type: 'input',
          isClear: true,
          maxlength: 50
        }
      ],
      getListApi: directorReviewPage,
      // 表格参数
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableOption: true,
        tableColumns: [
          {
            label: '订单编号',
            prop: 'orderCode',
            width: 150
          },
          {
            label: '订单总价/元',
            prop: 'totalPrice',
            formatter: (cellValue) => {
              return "¥" + cellValue.totalPrice
            }
          },
          {
            label: '下单时间',
            prop: 'orderTime',
            formatter: (cellValue) => {
              return cellValue.orderTime ? Util.dateFormate(cellValue.orderTime, 'YYYY-MM-DD HH:mm:ss') : '--'
            },
            width: 150
          },
          {
            label: '下单门店',
            prop: 'merchantName'
          },
          {
            label: '收货人',
            prop: 'contactName'
          },
          {
            label: '收货人电话',
            prop: 'contactPhone'
          },
          {
            label: '收货地址',
            prop: 'contactAddress'
          },
          {
            label: '采购模式',
            prop: 'purchasingPattern',
            formatter: (cellValue) => {
              return purchasingPatternOptions.find(item => item.id == cellValue.purchasingPattern)?.label || '-'
            }
          },
          {
            label: '发货主体',
            prop: 'sendOutMerchantName',
            formatter: (cellValue) => {
              return cellValue.sendOutMerchantName ? cellValue.sendOutMerchantName : '-'
            }
          },
          {
            label: '发货状态',
            prop: 'deliveryStatus',
            formatter: (cellValue) => {
              return defaultDeliveryStatusOptions.find(item => item.id == cellValue.deliveryStatus)?.label || '-'
            },
            className: (cellValue) => {
              return {
                1: 'ashSpot',
                2: 'greenSpot',
                3: 'yellowSpot',
                4: 'redSpot'
              }[cellValue.deliveryStatus]
            }
          },
          {
            label: '订单状态',
            prop: 'status',
            formatter: (cellValue) => {
              return director_statusOptions_table.find(item => item.id == cellValue.status)?.label || '-'
            },
            className: (cellValue) => {
              return {
				// 待审核
                10: 'yellowSpot',
				// 已审核
                5: 'greenSpot',
				8: 'greenSpot',
				// 已驳回
                6: 'redSpot',
                7: 'redSpot',
                9: 'redSpot',
              }[cellValue.status]
            }
          }
        ]
      },
      // 查看门店
      detailVisible: false,
      // 驳回
      rejectVisible: false,
      checkVisible: false,
      // 基本数据
      baseData: {
        director_statusOptions: [],
        defaultDeliveryStatusOptions: [],
        defaultPutStatusOptions: [],
        director_statusOptions_table: []
      },
      paramsObj: {}
    }
  },
  computed: {
    ...mapState({
      dowloadList: (state) => state.d2admin.user.dowloadList
    })
  },

  mounted() {
    getMerchantList({}).then(res => {
      const opt = {
        merchantNo: '',
        merchantName: '全部'
      }
      res.unshift(opt)
      this.getBaseData(res)
    })
  },

  methods: {
    ...mapActions('d2admin/user', ['actionSetDownloadList']),
    getBaseData(res) {
      const allOpt = {
        id: '',
        label: '全部'
      }
      this.baseData = {
        director_statusOptions: deepClone(director_statusOptions),
        defaultDeliveryStatusOptions: deepClone(defaultDeliveryStatusOptions),
        defaultPutStatusOptions: deepClone(defaultPutStatusOptions),
        purchasingPatternOptions: deepClone(purchasingPatternOptions),
        director_statusOptions_table: deepClone(director_statusOptions_table)
      }
      this.showFormData.forEach((item, index) => {
        if (item.type === 'select' && this.baseData[item.optionsName]) {
          this.baseData[item.optionsName].unshift(allOpt)
          this.$set(this.showFormData[index], 'optionList', this.baseData[item.optionsName])
        }
        if (item.type === 'select' && (item.name === 'merchantId')) {
          this.$set(this.showFormData[index], 'optionList', res)
        }
      })
    },
    // 根据所选场景获取类目
    // handleChangeSelect(value) {
    //   this.searchForm.goodsType = ''
    //   this.baseData.productTypeList = []
    //   getProductTypeBySceneId({ sceneType: value }).then(res => {
    //     this.baseData.productTypeList = res
    //     this.getBaseData()
    //   })
    // },
    // selectableFn(row, index) {
    //   return row.status == 1 && row.sendOutMerchantId != null
    // },

    beforeSearchFn() {
      return new Promise(resolve => {
        this.filterSearchTime()
        resolve()
      })
    },
    filterSearchTime() {
      this.tableSearchForm = deepClone(this.searchForm)
      if (this.tableSearchForm.placeOrderTimeStr) {
        this.tableSearchForm.orderTimeStr[0] = new Date(this.tableSearchForm.placeOrderTimeStr[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
        this.tableSearchForm.orderTimeStr[1] = new Date(this.tableSearchForm.placeOrderTimeStr[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
      }
      delete this.tableSearchForm.placeOrderTimeStr
      if (this.tableSearchForm.statuses) {
        if (this.tableSearchForm.statuses == 5) {
          this.tableSearchForm.statuses = [5, 8]
        } else if (this.tableSearchForm.statuses == 6) {
          this.tableSearchForm.statuses = [6, 7, 9]
        } else {
          this.tableSearchForm.statuses = [this.tableSearchForm.statuses]
        }
      }
    },
    handleReset() {
      for (const key in this.searchForm) {
        this.searchForm[key] = ''
      }
      this.searchForm.sortType = 2
      this.searchForm.orderTimeStr = []
      this.$refs.purchasementReviewTable.refreshTable()
    },
    handleExport() {
      this.filterSearchTime()
      var params = this.tableSearchForm
      // 处理查询条件时间
      for (const key in params) {
        if (key == 'orderTimeStr' || key == 'statuses') {
          if (params[key]) {
            params[key].forEach((v, index) => {
              params[`${key}[${index}]`] = v
            })
          }
          delete params[key]
        }
      }
      params.method = 'dj.api.life.directorreview.exportExcel.async'
      const list = [
        ...this.dowloadList,
        {
          // name: '采购审核',
          name: '总监审核',
          exportParam: JSON.stringify(params),
          status: 'waiting',
          timeid: new Date().getTime()
        }
      ]
      this.actionSetDownloadList({ list, type: 'dowloadList' })
    },
    // 审核
    handleCheck(row) {
      // this.checkVisible = !this.checkVisible
      // this.paramsObj = row
      this.$router.push({
        path: '/directorReview/singleCheck',
        query: {
          fromPage: 'directorReview',
          pageType: 'check',
          paramsObj: row
        }
      })
    },
    // 查看详情
    handleDetail(row) {
      this.paramsObj = {
        orderCode: row.orderCode,
        merchantName: row.merchantName,
        purchaseType: row.purchaseType
      }
      this.detailVisible = true
    },
    // 驳回
    handleReject(row) {
      // this.paramsObj = {
      //   orderCode: row.orderCode,
      //   type: 'operator'
      // }
      // this.rejectVisible = true
      this.$router.push({
        path: '/directorReview/singleReject',
        query: {
          fromPage: 'directorReview',
          pageType: 'reject',
          paramsObj: row
        }
      })
    },
    dialogClose(obj) {
      this[obj.attrName] = !this[obj.attrName]
      if (obj.flag) {
        this.$refs.purchasementReviewTable.refreshTable()
      }
    }
  }
}
</script>
<style lang="scss" scoped></style>