carDialog.vue 7.45 KB
<!-- 新车交付明细弹窗 -->
<template>
  <d2-dialog
    title="新车交付明细"
    :is-visible="detailVisible"
    :no-cancel="true"
    class="stockMonthDailog"
    width="70%"
    :is-show-footer="false"
    @closeDialog="handleClose"
    @confirmDialog="handleClose"
  >
    <div>
      <div class="header">
        <d2-search
          :search-form="searchForm"
          class="show-search"
          label-width="140px"
          :search-select-obj="searchSelectObj"
          :form-data="showFormData"
        >
          <template slot="reportDate">
            <el-date-picker
              size="mini"
              v-model="searchForm.reportDate"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd"
              :picker-options="pickerOptions"
            />
          </template>
          <div class="up-btns">
            <el-button :id="tableParams.btnId" size="small" type="primary">
              查询
            </el-button>
            <el-button size="small" @click="handleReset"> 重置 </el-button>
          </div>
        </d2-search>
      </div>
      <div class="d2-container-content">
        <div class="table-header">
          <div class="table-title">{{ merchantName }}</div>
          <!-- <el-button
            class="default-blue-btn"
            type="primary"
            @click="handleDetailExport"
            >导出</el-button
          > -->
          <auth-button category="Button" :show-btn-ids="['9070402']" />
        </div>
        <d2-table
          ref="recordTable"
          :get-list-api="getListApi"
          :table-data="tableData"
          :search-form="searchFormSearch"
          :table-params="tableParams"
          :before-search-fn="beforeSearchFn"
        >
        </d2-table>
      </div>
    </div>
  </d2-dialog>
</template>

<script>
import { Util, deepClone } from "@/common/util"
import { permeabilityDetail } from "@/api/permeation.js"
import { mapActions, mapState } from "vuex"
import dayjs from "dayjs"
export default {
  name: "DetailDialog",
  components: {},
  data() {
    let timeOptionRange = null
    return {
      getListApi: permeabilityDetail,
      countObj: {},
      searchForm: {
        createdDate: ""
      },
      searchFormSearch: {},
      searchSelectObj: {},
      showFormData: [
        {
          label: "员工姓名",
          name: "staffName",
          type: "input"
        },
        {
          label: "填报日期",
          name: "createdDate",
          type: "datePicker",
          valueFormat: "yyyy-MM-dd"
        },
        {
          label: "日报时间",
          name: "reportDate",
          addHtml: 'reportDate'
        }
      ],
      // getListApi: getReportByGoods,
      tableData: [],
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: "list",
        // singleSelectUniqueKey: 'id',
        tableOption: false,
        tableColumns: [
          {
            label: "员工名称",
            prop: "staffName"
          },
          {
            label: "填报交付数",
            prop: "deliveryCount",
            formatter: (cellValue) => {
              return (cellValue.deliveryCount ?? '') === '' ? '-' : cellValue.deliveryCount
            }
          },
          {
            label: "填报时间",
            prop: "createdDate"
          },
          {
            label: "日报时间",
            prop: "reportDate"
          }
        ]
      },
      baseData: {},
      pickerOptions: {
        disabledDate: (time) => {
          // 可选范围是今天及之前且最大可选跨度是31天
          const secondNum = 30 * 24 * 60 * 60 * 1000;
          const today = new Date();
          const [year, month, date] = [today.getFullYear(), today.getMonth(), today.getDate()]
          const yesterdayStamp = new Date(year, month, date).getTime()
          if (timeOptionRange) {
            return time.getTime() > timeOptionRange.getTime() + secondNum || time.getTime() < timeOptionRange.getTime() - secondNum || time.getTime() > yesterdayStamp
          } else {
            return time.getTime() > yesterdayStamp
          }
        },
        onPick: (dateRange) => {
          if (dateRange.minDate && !dateRange.maxDate) {
            timeOptionRange = dateRange.minDate
          }
          if (dateRange.maxDate) {
            timeOptionRange = null
          }
        }
      }
    }
  },

  props: {
    detailVisible: {
      type: Boolean,
      default: false
    },
    selectDate: {
      type: Array,
      default: []
    },
    merchantId: {
      type: Number,
      default: ""
    },
    merchantName: {
      type: String,
      default: ""
    },
    sceneType: {
      type: String,
      default: '0'
    }
  },

  computed: {
    ...mapState({
      dowloadList: (state) => state.d2admin.user.dowloadList
    })
  },
  mounted() {
    this.searchForm.merchantId = this.merchantId
  },

  methods: {
    ...mapActions("d2admin/user", ["actionSetDownloadList"]),
    beforeSearchFn() {
      return new Promise((resolve) => {
        this.searchFormSearch = this.getParams()
        resolve()
      })
    },
    getParams() {
      this.searchFormSearch = deepClone(this.searchForm)
      console.log(this.searchForm)
      if (this.searchFormSearch.createdDate) {
        this.searchFormSearch.createdStartDate =
          dayjs(this.searchFormSearch.createdDate[0]).format("YYYY-MM-DD") +
          " 00:00:00"
        this.searchFormSearch.createdEndDate =
          dayjs(this.searchFormSearch.createdDate[1]).format("YYYY-MM-DD") +
          " 23:59:59"
      }
      if (this.searchFormSearch.reportDate) {
        this.searchFormSearch.reportStartDate =
          dayjs(this.searchFormSearch.reportDate[0]).format("YYYY-MM-DD")
        this.searchFormSearch.reportEndDate =
          dayjs(this.searchFormSearch.reportDate[1]).format("YYYY-MM-DD")
      }
      this.searchFormSearch.sceneType = this.sceneType
      return this.searchFormSearch
    },
    handleDetailExport() {
      var params = this.getParams()
      params.method =
        "dj.api.smartcarlife.permeability.report.detail.exportAsync"
      const list = [
        ...this.dowloadList,
        {
          name: "新车交付明细",
          exportParam: JSON.stringify(params),
          status: "waiting",
          timeid: new Date().getTime()
        }
      ]
      this.actionSetDownloadList({ list, type: "dowloadList" })
    },
    handleReset() {
      this.searchForm = {
        merchantId: this.merchantId
      }
      this.$refs.recordTable.refreshTable()
    },
    handleClose() {
      this.$emit("dialogClose")
    }
  }
}
</script>
<style lang="scss" scoped>
.header {
  display: flex;
  align-items: center;
  ::v-deep {
    .el-date-editor {
      width: 220px;
    }
  }
}
.table-header {
  display: flex;
  justify-content: space-between;
  .table-title {
    font-size: 16px;
    color: #333333;
    font-weight: 600;
  }
}
.count-txt {
  font-weight: 700;
  color: #2a58ad;
  margin: 0 2px;
}

.stockMonthDailog .el-dialog {
  margin-top: 20vh !important;
  min-width: 700px;
}

.stockMonthDailog .btn-tips img {
  width: 18px;
  height: 15px;
  margin-right: 9px;
  vertical-align: bottom;
}

.stockMonthDailog .btn-tips {
  display: inline-block;
  font-size: 12px;
  height: 14px;
  line-height: 14px;
  background-color: #fff2e5;
  color: #999999;
  margin-right: 24px;
  padding: 6.5px 10px;
}
</style>