procurementBusiness.vue 11.8 KB
<!-- 采购审核-商务审核 -->
<template>
  <d2-container class="container">
    <div class="header"
         slot="header">
      <d2-search ref="showSearch"
                 class="show-search"
                 :search-form="searchForm"
                 @handleChangeSelect="handleChangeSelect"
                 :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>
        <!-- <span slot="left"> -->
          <!-- <auth-button category="Button" /> -->
          <!-- <auth-button category="Button" />
        </span> -->
        <span>
          <!-- <el-button type="primary"
                     size="mini"
                     @click="handleExport">
            导出
          </el-button> -->
          <auth-button category="Button" :show-btn-ids="['9090605']" />
        </span>
      </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"
                 from-page="procurementBusiness"
                 @dialogClose="dialogClose">
    </CheckDialog>
    <rejectDialog :reject-visible="rejectVisible"
                  v-if="rejectVisible"
                  :params-obj="paramsObj"
                  @dialogClose="dialogClose">
    </rejectDialog>
  </d2-container>
</template>

<script>
import { Util, deepClone } from '@/common/util'
import { business_statusOptions, defaultDeliveryStatusOptions, defaultPutStatusOptions, purchasingPatternOptions, business_statusOptions_table } from './constant'
import { mapActions, mapState } from 'vuex'
import { getPurchaseOrderList, getMerchantList, purchaseOrderCancelOrCheck, businessreviewPage, businessreviewBusinessAudit } 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: ''
      },
      tableSearchForm: {},
      tableData: [],
      showFormData: [
        {
          label: '订单编号',
          name: 'orderCode',
          type: 'input',
          isClear: true
        },
        {
          label: '下单时间',
          name: 'placeOrderTimeStr',
          type: 'datePicker',
          isClear: true,
          pickerOptions: 'rangePickerOptions'
        },
        // {
        //   label: '下单门店',
        //   name: 'merchantId',
        //   type: 'select',
        //   optionList: [],
        //   optionId: 'merchantNo',
        //   optionLabel: 'merchantName',
        //   optionsName: 'merchantName'
        // },
        {
          label: '下单商户',
          name: 'merchantName',
          type: 'input',
          isClear: true
        },
        {
          label: '状态',
          name: 'statuses',
          type: 'select',
          optionList: [],
          optionId: 'id',
          optionLabel: 'label',
          optionsName: 'business_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: getPurchaseOrderList,
      getListApi: businessreviewPage,
      // 表格参数
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableOption: true,
        tableColumns: [
          {
            label: '订单编号',
            prop: 'orderCode'
          },
          {
            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'
          },
          {
            label: '发货状态',
            prop: 'deliveryStatus',
            formatter: (cellValue) => {
              return defaultDeliveryStatusOptions.find(item => item.id == cellValue.deliveryStatus)?.label || '-'
            },
            className: (cellValue) => {
              return {
                1: 'yellowSpot',
                2: 'greenSpot',
                3: 'yellowSpot',
                4: 'redSpot'
              }[cellValue.deliveryStatus]
            }
          },
          {
            label: '状态',
            prop: 'status',
            formatter: (cellValue) => {
              return business_statusOptions_table.find(item => item.id == cellValue.status)?.label || '-'
            },
            className: (cellValue) => {
              return {
                2: 'yellowSpot',
                5: 'greenSpot',
                6: 'redSpot',
                7: 'redSpot'
              }[cellValue.status]
            }
          }
        ]
      },
      // 查看门店
      detailVisible: false,
      // 驳回
      rejectVisible: false,
      checkVisible: false,
      // 基本数据
      baseData: {
        business_statusOptions: [],
        defaultDeliveryStatusOptions: [],
        defaultPutStatusOptions: [],
        business_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 = {
        business_statusOptions: deepClone(business_statusOptions),
        defaultDeliveryStatusOptions: deepClone(defaultDeliveryStatusOptions),
        defaultPutStatusOptions: deepClone(defaultPutStatusOptions),
        purchasingPatternOptions: deepClone(purchasingPatternOptions),
        business_statusOptions_table: deepClone(business_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()
      })
    },

    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 == 6) {
          this.tableSearchForm.statuses = [6, 7]
        } 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') {
          params[key].forEach((v, index) => {
            params[`${key}[${index}]`] = v
          })
          delete params[key]
        }
      }
      params.method = 'dj.api.life.businessreview.exportExcel.async'
      const list = [
        ...this.dowloadList,
        {
          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
    },
    // 查看详情
    handleDetail(row) {
      this.paramsObj = {
        orderCode: row.orderCode,
        merchantName: row.merchantName,
        purchaseType: row.purchaseType
      }
      this.detailVisible = true
    },
    // 驳回
    handleReject(row) {
      this.paramsObj = {
        orderCode: row.orderCode,
        type: 'business'
      }
      this.rejectVisible = true
    },
    dialogClose(obj) {
      this[obj.attrName] = !this[obj.attrName]
      if (obj.flag) {
        this.$refs.purchasementReviewTable.refreshTable()
      }
    }
  }
}
</script>
<style lang="scss" scoped></style>