index.vue 9.3 KB
<!-- 有效引荐数 -->
<template>
  <d2-container class="layout m-t-40">
    <div class="header">
      <d2-search
        ref="showSearch"
        :search-form="searchForm"
        :form-data="showFormData"
        label-width="100px"
        :selectPopperAppendToBody="false"
        class="d2-search"
      >
      </d2-search>
      <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>
        <el-button
          size="small"
          type="primary"
          @click="handleExport"
          class="exprot"
        >
          导出
        </el-button>
      </d2-table-header>
      <d2-table
        ref="tableRef"
        :search-form="searchFormSearch"
        :table-params="tableParams"
        :get-list-api="getListApi"
        :before-search-fn="beforeSearchFn"
      >
        <div slot="imageUrls" slot-scope="scope" class="coverImage-preview">
          <glsx-preview
            :image-url-arr="
              scope.scope.imageUrls
                ? formatterImg(scope.scope.imageUrls)
                : [noDataUrl]
            "
            :pic-options="picOptions"
            limit="1"
          ></glsx-preview>
        </div>
        <template slot="remark" slot-scope="scope">
					<template v-if="scope.scope.remark">
						<el-popover
							placement="top"
							width="fit-content"
							trigger="hover"
						>
							<div class="tags-popover">
								{{ scope.scope.remark || "-" }}
							</div>
							<span class="tag" slot="reference">{{
								scope.scope.remark || "-"
							}}</span>
						</el-popover>
					</template>
					<template v-else>-</template>
				</template>
				<template slot="merchantName" slot-scope="scope">
					<template v-if="scope.scope.merchantName">
						<el-popover
							placement="top"
							width="fit-content"
							trigger="hover"
						>
							<div class="tags-popover">
								{{ scope.scope.merchantName || "-" }}
							</div>
							<span class="tag" slot="reference">{{
								scope.scope.merchantName || "-"
							}}</span>
						</el-popover>
					</template>
					<template v-else>-</template>
				</template>
      </d2-table>
    </div>
  </d2-container>
</template>

<script type="text/ecmascript-6">
import {
  Util,
  deepClone,
  getStatusItem,
  getOptionsList
} from "@/common/util"
import { listShop4sByRef } from "@api/merchant"
import {
  getEffectiveReferralList
} from "@api/shopConfig"
import { mapActions, mapState } from "vuex"
import dayjs from "dayjs"
export default {
  name: "",
  data() {
    return {
      id: "",
      replyVisible: false,
      noDataUrl: require("@/assets/noData.png"),
      searchForm: {
        merchantId: "",
        managerName: "",
        sceneType: ""
      },
      searchFormSearch: {},
      showFormData: [
        {
          label: "门店名称",
          name: "merchantName",
          type: "input",
          isClear: true
        },
        {
          label: "区域运营",
          name: "managerName",
          type: "input",
          isClear: true
        },
        {
          label: "业务场景",
          name: "sceneType",
          type: "select",
          isClear: true,
          optionList: [],
          optionId: "confId",
          optionLabel: "confValue",
          optionsName: "businessTypeOpts"
        }
      ],
      getListApi: getEffectiveReferralList,
      // 表格参数
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: "list",
        tableColumns: [
          {
            label: "门店名称",
            prop: "merchantName",
            minWidth: "200",
            addHtml: "merchantName"
          },
          {
            label: "系统交车数",
            prop: "totalDeliveryCount",
            minWidth: "150",
            formatter:(cellValue)=>{
                return cellValue.totalDeliveryCount===0||cellValue.totalDeliveryCount?cellValue.totalDeliveryCount:'-'
            }
          },
          {
            label: "区域有效引荐数",
            prop: "areaEffectiveCount",
            minWidth: "150",
            formatter:(cellValue)=>{
                return cellValue.areaEffectiveCount===0||cellValue.areaEffectiveCount?cellValue.areaEffectiveCount:'-'
            }
          },
          {
            label: "运营修正有效引荐数",
            prop: "reviewedEffectiveCount",
            minWidth: "150",
            formatter:(cellValue)=>{
                return cellValue.reviewedEffectiveCount===0||cellValue.reviewedEffectiveCount?cellValue.reviewedEffectiveCount:'-'
            }
          },

          {
            label: "业务场景",
            prop: "sceneType",
            minWidth: "100",
            formatter: (cellValue) => {
              return getStatusItem(
                this.baseData,
                "businessTypeOpts",
                cellValue,
                "sceneType"
              )
            }
          },
          {
            label: "车辆品牌",
            prop: "brandName"
          },

          {
            label: "上传凭证",
            prop: "imageUrls",
            width: "138px",
            addHtml: "imageUrls"
          },
          {
            label: "备注",
            minWidth: "150",
            prop: "remark",
            addHtml: "remark"
          },
          {
            label: "区域运营",
            minWidth: "150",
            prop: "managerName"
          },
          {
            label: "运营复核人",
            minWidth: "150",
            prop: "reviewedName"
          },
          {
            label: "核查月份",
            prop: "reviewMonth",
            // formatter: (cellValue) => {
            //   // 生效月份(格式:yyyy-MM)转成-月
            //   if (!cellValue.reviewMonth) return "-"
            //   const [year, month] = cellValue.reviewMonth.split("-")
            //   return `${parseInt(month)}月`
            // },

          }
        ]
      },
      picOptions: {
        width: "138px",
        height: "54px",
        isClose: false
      },
      baseData: {
        businessTypeOpts: [
          {
            confId: 3,
            confValue: "单延保"
          },
          {
            confId: 2,
            confValue: "广联权益"
          },
          {
            confId: 1,
            confValue: "轻改"
          }
        ]
      }
    }
  },
  mounted() {
    getOptionsList(this, "showFormData", true)
    // this.fetchOnboardingPlans()
  },
  computed: {
    ...mapState({
      dowloadList: (state) => state.d2admin.user.dowloadList
    })
  },
  methods: {
    ...mapActions('d2admin/user', ['actionSetDownloadList']),
    formatterImg(val) {
        if (!val) return []
     let arr =  val.split(',')
      return arr
    },
    async fetchOnboardingPlans() {
      try {
        const [merchantIdList] = await Promise.all([
          listShop4sByRef({
            yqMerchantId: ""
          })
        ])
        // 处理返回的数据
        this.baseData.merchantIdList = merchantIdList
        getOptionsList(this, "showFormData", true)
      } catch (error) {
        console.error(error)
      }
    },
    beforeSearchFn() {
      return new Promise((resolve) => {
        this.searchFormSearch = deepClone(this.searchForm)
        resolve()
      })
    },
    formatDate(date) {
      return dayjs(date).format("YYYY-MM-DD")
    },
    handleReset() {
      this.searchForm = this.$options.data.call(this).searchForm
      this.search()
    },
    handleExport() {
        let params = this.searchFormSearch
        params.moduleName = "STAFF"
      params.pageNum = 1
      params.method =
        "dj.staff.api.effective.referral.export.async"
      const list = [
        ...this.dowloadList,
        {
          name: "有效引荐数列表",
          exportParam: JSON.stringify(params),
          status: "waiting",
          timeid: new Date().getTime()
        }
      ]
      this.actionSetDownloadList({ list, type: "dowloadList" })
    },
    search() {
      this.$refs.tableRef.refreshTable(false, true)
    },
    handleToReply(data) {
      this.id = data.id
      this.replyVisible = !this.replyVisible
    }
  }
}
</script>

<style scoped lang="scss">
.m-t-40 {
  margin-top: 40px;
}
.layout {
  .d2-search {
    ::v-deep.el-select-dropdown,
    .el-popper {
      width: 300px !important;
    }
  }
  .header {
    background: #fff;
  }
  .content {
    position: absolute;
    left: 20px;
    width: calc(100% - 40px);
    padding: 0 20px 36px;
    background: #fff;
    margin-top: 14px;
    height: calc(100% - 110px);
    box-sizing: border-box;
    overflow-y: auto;
    .top {
      height: 52px;
      color: #333333;
      font-size: 32rpx;
      font-weight: 500;
      display: flex;
      align-items: center;
      .exprot {
        margin-left: auto;
      }
    }
  }
  .tag {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    padding: 0 10px;
    display: block;
  }
}
.coverImage-preview {
  width: 138px;
  height: 54px;
  ::v-deep .photo-activity {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: static !important;
  }
}
::v-deep.tags-popover {
  max-width: 50vw;
}
</style>