ManageReceiptDailog.vue 7.76 KB
<template>
  <baseDialog :title="title" :config="config" :dialog-config="dialogConfig" :is-show.sync="visibility" width="50%"
    btn-ok-label="确定" @confirmDialog="handleSelectGoodsConfirm" @closeDialog="handleSelectGoodsClose"
    class="selectGoods">
    <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 type="primary" @click="handleReset" size="small">重置</el-button>
      <!-- <el-button type="primary"></el-button> -->
    </div>
    <d2-table-header>
      <div class="btns flex">
        <span data-event-code="prepaymentManage_TrafficFee">
          <auth-button category="Button" :show-btn-ids="['9051607']" />
        </span>
        <span data-event-code="prepaymentManage_Export">
          <auth-button category="Button" :show-btn-ids="['9051606']" />
        </span>
      </div>

    </d2-table-header>
    <d2-table maxHeight="350px" ref="groundingIndexTable" :search-form="searchForm" :table-params="tableParams"
      :get-list-api="getListApi" :before-search-fn="beforeSearchFn" @setTableFinishFun="setTableFinishFun">
    </d2-table>
    <addDialog v-if="addVisible" :addVisible.sync="addVisible" @addDialogClose="addDialogClose"
      @addDialogSuccess="addDialogSuccess" />
  </baseDialog>
</template>

<script>
import { mapActions, mapState } from "vuex"
import { advancePaymentTradePage } from "@api/prepaymentManage"
import { tradeTypeList } from "@/common/constant/vehicle"
import dayjs from "dayjs"
import addDialog from "./addDialog.vue"
import reportTrackPageMixin from "@/mixins/reportTrackPageMixin"
import { formatThousand } from "@/common/format"

export default {
  name: 'ManageReceiptDailog',
  mixins: [reportTrackPageMixin],
  props: {
    title: {
      type: String,
      default: "管理收款"
    },
    manageReceiptDialogVisible: {
      type: Boolean,
      default: false
    }
  },
  components: {
    addDialog
  },
  data() {
    return {
      addVisible: false,
      dialogConfig: {
        title: "管理收款",
        width: "900px",
        hideConfirmBtn: true,
        cancel_name: "关闭"
      },
      config: {
        showClose: true,
        appendToBody: false, // 是否将自身插入至 body 元素,有嵌套的弹窗时一定要设置
        isShowFooter: true,
        hideConfirmBtn: true,
        cancel_name: "关闭"
      },
      tradeTypeList,
      getListApi: advancePaymentTradePage,
      showFormData: [{
        label: '门店名称',
        name: 'merchantName',
        type: 'input',
        maxlength: 50,
        isClear: true
      },
      {
        type: 'datePicker',
        label: '收款日期',
        name: 'paymentDate',
        width: '260px'
      }
      ],
      searchForm: {
        merchantName: '',
        paymentDate: '',
        managerType: 1
      },
      tempGoodsType: [],
      baseData: {
        productTypeList: [],
        productList: []
      },
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableColumns: [

          // {
          //   label: '序号',
          //   prop: 'ownSerialNum',
          //   type: 'ownSerialNum',
          //   width: '60'
          // },
          {
            label: '金额',
            prop: 'tradeAmount',
            width: 110,
            formatter: (row) => formatThousand(row.tradeAmount)
          }, {
            label: '收款类型',
            prop: 'tradeType',
            // width: 120,
            // width: 180,
            formatter: (cellValue) => {
              return tradeTypeList.find(v => v.id == cellValue.tradeType)?.label || '-'
            }
          }, {
            label: '收款日期',
            prop: 'tradeTime',
            width: 170,
            formatter: (cellValue) => {
              return cellValue?.tradeTime ? dayjs(cellValue.tradeTime).format('YYYY-MM-DD HH:mm:ss') : '-'
            }
          }, {
            label: '门店',
            prop: 'merchantName',
            width: 140,
            // formatter: (cellValue) => {
            //   return cellValue?.thirdPartyCode || '-'
            // }
          },
          {
            label: '操作人',
            prop: 'createdBy',
            // formatter: (cellValue) => {
            //   return cellValue?.goodsInfo?.goodsName || '-'
            // },
            width: 100
          }, {
            label: '操作日期',
            prop: 'createdDate',
            width: 170,
            formatter: (cellValue) => {
              return cellValue?.createdDate ? dayjs(cellValue.createdDate).format('YYYY-MM-DD HH:mm:ss') : '-'
            }
          }]
      }
    }
  },
  computed: {
    visibility: {
      get() {
        return this.manageReceiptDialogVisible
      },
      set(value) {
        this.$emit('update:manageReceiptDialogVisible', value)
      }
    },
    ...mapState({
      dowloadList: (state) => state.d2admin.user.dowloadList
    })
  },
  mounted() {
  },
  methods: {
    ...mapActions("d2admin/user", ["actionSetDownloadList"]),
    handleExport() {
      const params = {
        method: "dj.api.smartcarlife.advancePayment.tradePage.export.async",
        ...this.getParams()
      }
      Object.keys(params).forEach((key) => {
        if (params[key] == null || params[key] == "") {
          delete params[key]
        }
      })
      const list = [
        ...this.dowloadList,
        {
          name: "收款管理记录列表",
          exportParam: JSON.stringify(params),
          status: "waiting",
          timeid: new Date().getTime()
        }
      ]
      this.actionSetDownloadList({ list, type: "dowloadList" })
    },
    getParams() {
      if (this.searchForm.paymentDate?.length > 0) {
        const [start, end] = this.searchForm.paymentDate
        this.searchForm.startTradeTime = dayjs(start).format('YYYY-MM-DD') + ' 00:00:00'
        this.searchForm.endTradeTime = dayjs(end).format('YYYY-MM-DD') + ' 23:59:59'
      }
      return {
        ...this.searchForm
      }
    },
    handleAddReceipt() {
      this.addVisible = true
    },
    addDialogClose() {
      this.addVisible = false
    },
    addDialogSuccess() {
      // this.addVisible = false
      // 重新查询
      this.$refs.groundingIndexTable.refreshTable(false, true)
    },
    // resetSearchForm() {
    //   this.searchForm = this.$options.data.call(this).searchForm
    //   this.$refs.showSearch.resetForm()
    // },
    setTableFinishFun(data) {
      this.tableData = data
    },
    beforeSearchFn() {
      return new Promise(resolve => {
        this.getParams()
        resolve()
      })
    },
    handleSelectGoodsConfirm() {
      // const selectData = this.tableData?.find(v => v.id == this.selectedRowId)
      // if (!selectData) return this.$message.warning('请选择商品')
      this.$emit('handleSelectGoodsConfirm', selectData)
    },
    handleSelectGoodsClose() {
      this.$emit('handleSelectGoodsClose')
    },
    handleReset() {
      this.searchForm = this.$options.data.call(this).searchForm
      // 重新查询
      this.$refs.groundingIndexTable.refreshTable(true, true)
    }
  }
}
</script>
<style lang="scss" scoped>
.selectGoods {
  ::v-deep .el-dialog__body {
    // padding: 0;
    border-bottom: 1px solid #e4e7ed;
  }
}

// .show-search {
//   // height: 32px;
// }
.up-btns {
  padding-top: 0;
}

.flex {
  display: flex;
  align-items: center;
}

.btns {
  margin-left: auto;
  gap: 10px;

  // 最后一个span元素添加右边距
  >span:last-child {
    padding-right: 20px;
    // margin-left: 0;
  }
}

.show-search {
  ::v-deep .d2-search-block {
    padding: 0;
  }
}

.table {
  border-bottom: 1px solid #e4e7ed;
}
</style>