invoiceRecord.vue 7.52 KB
<!-- 发货单 -->
<template>
  <div>
    <d2-container>
      <div class="header"
           slot="header"
           style="padding: 10px 20px;">
        <d2-search ref="showSearch"
                   class="show-search"
                   :search-form="searchForm"
                   :form-data="showFormData" />
        <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>
          <auth-button category="Button" />
        </d2-table-header>
        <d2-table ref="recordTable"
                  :get-list-api="getListApi"
                  :search-form="searchFormSearch"
                  :table-params="tableParams"
                  :before-search-fn="beforeSearchFn">
          <auth-button slot="auth-button"
                       slot-scope="scope"
                       :data="scope.scope" />
        </d2-table>
      </div>
    </d2-container>
    <!-- 查看 -->
    <delivery-detail-dialog :detail-visible="detailVisible"
                            :record-info="recordInfo"
                            v-if="detailVisible"
                            @dialogClose="dialogClose" />
  </div>
</template>

<script>
import { Util, deepClone } from '@/common/util'
import { mapActions, mapState } from 'vuex'
import { purchaseOrderDeliveryPage, purchaseOrderDeliveryWithdraw } from '@/api/purchaseShopping.js'
import deliveryDetailDialog from './components/deliveryDetailDialog'
import { invouceType } from '@/common/constants.js'
export default {
  name: 'InvoiceRecord',
  components: {
    deliveryDetailDialog
  },
  data() {
    return {
      userInfo: this.$store.state.d2admin.user.info,
      searchForm: {
        deliveryNumber: '',
        deliveryCompany: '',
        deliveryDate: '',
        orderCode: this.$route.params.orderCode || '',
        merchantName: '',
        putStatus: ''
      },
      searchFormSearch: {},
      showFormData: [{
        label: '承运单号',
        name: 'deliveryNumber',
        type: 'input',
        maxlength: '50',
        isClear: true
      },
      {
        label: '承运公司',
        name: 'deliveryCompany',
        type: 'input',
        maxlength: '20',
        isClear: true
      }, {
        label: '发货时间',
        name: 'deliveryDate',
        type: 'datePicker',
        isClear: true,
        pickerOptions: 'rangePickerOptions'
      }, {
        label: '所属订单',
        name: 'orderCode',
        type: 'input',
        maxlength: '20',
        isClear: true
      }, {
        label: '所属商户',
        name: 'merchantName',
        type: 'input',
        maxlength: '50',
        isClear: true
      }, {
        label: '状态',
        name: 'putStatus',
        type: 'select',
        optionList: [],
        optionId: 'confId',
        optionLabel: 'confName',
        optionsName: 'invouceType'
      }],
      getListApi: purchaseOrderDeliveryPage,
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableOption: true,
        tableColumns: [{
          label: '承运单号',
          prop: 'deliveryNumber',
          width: '200px'
        }, {
          label: '承运公司',
          prop: 'deliveryCompany',
          width: '150px'
        }, {
          label: '发货时间',
          prop: 'deliveryDate',
          width: '150px',
          formatter: (cellValue) => {
            return cellValue.deliveryDate ? Util.dateFormate(cellValue.deliveryDate, 'YYYY-MM-DD HH:mm:ss') : ''
          }
        }, {
          label: '所属订单',
          prop: 'orderCode',
          width: '200px'
        }, {
          label: '所属商户',
          prop: 'merchantName',
          width: '150px'
        }, {
          label: '状态',
          prop: 'putStatus',
          formatter: (cellValue) => {
            return this.baseData.invouceType.find(item => item.confId === cellValue.putStatus)?.confName
          }
        }
        ]
      },
      baseData: {
        invouceType: invouceType
      },

      detailVisible: false,
      recordInfo: null
    }
  },
  computed: {
    ...mapState({
      dowloadList: (state) => state.d2admin.user.dowloadList
    })
  },
  mounted() {
    this.getBaseData()
  },

  methods: {
    ...mapActions({
      get: 'd2admin/base/get',
      close: 'd2admin/page/close'
    }),
    ...mapActions('d2admin/user', ['actionSetDownloadList']),

    async getBaseData() {
      this.getOptionsList()
    },

    beforeSearchFn() {
      return new Promise(resolve => {
        this.searchFormSearch = deepClone(this.searchForm)
        if (this.searchFormSearch.deliveryDate) {
          this.searchFormSearch.deliveryDateStart = Util.dateFormate(this.searchFormSearch.deliveryDate[0], 'YYYY-MM-DD 00:00:00')
          this.searchFormSearch.deliveryDateEnd = Util.dateFormate(this.searchFormSearch.deliveryDate[1], 'YYYY-MM-DD 23:59:59')
          delete this.searchFormSearch.deliveryDate
        }
        resolve()
      })
    },

    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])
        }
      })
    },

    handleSearch() {
      this.$refs.recordTable.refreshTable()
    },
    handleReset() {
      this.searchForm = {
        deliveryNumber: '',
        deliveryCompany: '',
        deliveryDate: '',
        orderCode: '',
        merchantName: '',
        putStatus: ''
      }
      this.$refs.recordTable.refreshTable()
    },

    handleExport() {
      var params = this.searchFormSearch
      params.method = 'dj.api.smarcarlife.purchaseOrder.delivery.export.async'
      const list = [
        ...this.dowloadList,
        {
          name: '发货单',
          exportParam: JSON.stringify(params),
          status: 'waiting',
          timeid: new Date().getTime()
        }
      ]
      this.actionSetDownloadList({ list, type: 'dowloadList' })
    },

    // 查看
    handleLook(row) {
      this.recordInfo = row
      this.detailVisible = true
    },

    dialogClose(flag) {
      this.detailVisible = !this.detailVisible
      // if (flag) {
      //   this.$refs.recordTable.refreshTable()
      // }
    },

    // 撤销
    handleRevoke(row) {
      this.$confirm("发货单撤销后同步删除该发货记录,且无法撤回;是否确定撤销?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          purchaseOrderDeliveryWithdraw({ id: row.id }).then((res) => {
            this.notice.okTips()
            this.$refs.recordTable.refreshTable()
          })
        })
        .catch((err) => {
          console.log(err)
        })
    }

  }
}

</script>
<style scoped>
.count-txt {
  font-weight: 700;
  color: #2a58ad;
  margin: 0 2px;
}

.leftSpan {
  display: inline-block;
  box-sizing: border-box;
  margin-right: 10px;
}
</style>