referralDialog.vue 6.85 KB
<!-- 复核有效引荐数/查看有效引荐数 -->
<!-- 只有待复核的数据,才显示复核按钮,已复核和已失效,只显示查看按钮
 -->
<template>
  <baseDialog
    :dialog-config="dialogConfig"
    :is-show.sync="visible"
    class="accountDailog"
    :config="approveConfig"
    @handleClick="handleClick"
  >
    <div class="reply-dialog" v-loading="loading">
      <template v-if="detailInfo">
        <detailComp
          ref="detailComp"
          :configData="configData"
          :detailInfo="detailInfo"
          labelWidth="190px"
          :rules="rules"
        ></detailComp>
      </template>
    </div>
  </baseDialog>
</template>

<script>
import {
  effectiveReferralStoreAudit,
  getEffectiveReferralStoreDetail
} from "@api/order"
import detailComp from "../../residentManage/salaryPerformance/components/detailComp.vue"
import { Util, deepClone, getStatusItem } from "@/common/util"
export default {
  name: "approvalView",
  components: {
    detailComp
  },
  data() {
    return {
      detailInfo: {},
      dialogConfig: {
        title: "复核有效引荐数",
        width: "540px"
      },
      loading: false,
      isShow: true,
      approveConfig: {
        isShowFooter: false,
        cancel_name: "取 消",
        confirm_name: "确 定"
      },
      configData: [
        {
          childRef: "referralComp",
          infoData: [
            {
              title: "门店名称",
              key: "merchantName",
              col: 24
            },
            {
              title: "业务场景",
              key: "sceneType",
              col: 24,
              formatter: (cellValue) => {
                return getStatusItem(
                  this.baseData,
                  "businessTypeOpts",
                  cellValue,
                  "sceneType"
                )
              }
            },
            {
              title: "车辆品牌",
              key: "brandName",
              col: 24
            },
            {
              title: "系统交车数",
              key: "totalDeliveryCount",
              col: 24,
              formatter: (val) => {
                return val.totalDeliveryCount || val.totalDeliveryCount === 0
                  ? val.totalDeliveryCount
                  : "-"
              }
            },
            {
              title: "区域有效引荐数",
              key: "areaEffectiveCount",
              col: 24,
              formatter: (val) => {
                return val.areaEffectiveCount || val.areaEffectiveCount === 0
                  ? val.areaEffectiveCount
                  : "-"
              }
            },
            {
              title: "运营修正实际有效引荐数",
              key: "reviewedEffectiveCount",
              isEdit: true,
              col: 24,
              type: "input",
              isDisabled: false
            }
          ]
        }
      ],
      rules: {
        // reviewedEffectiveCount: [
        //   { required: true, message: "请填写修正实际有效引荐数" },
        //   {
        //     validator: (rule, value, callback) => {
        //       const s = String(value == null ? "" : value).trim()
        //       if (!/^\d+$/.test(s)) {
        //         callback(new Error("仅支持输入整数"))
        //         return
        //       }
        //       const n = Number(s)
        //       if (n < 0 || n > 100000000) {
        //         callback(new Error("范围应为 0-100000000"))
        //         return
        //       }
        //       callback()
        //     },
        //     trigger: ["blur", "change"]
        //   }
        // ]
      },
      baseData: {
        businessTypeOpts: [
          {
            confId: 3,
            confValue: "单延保"
          },
          {
            confId: 2,
            confValue: "广联权益"
          },
          {
            confId: 1,
            confValue: "轻改"
          }
        ]
      }
    }
  },

  props: {
    detailVisible: {
      type: Boolean,
      default: false
    },
    id: {
      type: Number,
      default: ""
    }
  },
  computed: {
    visible: {
      get() {
        return this.detailVisible
      },

      set(newVal) {
        this.$emit("dialogClose", { flag: newVal, attrName: "detailVisible" })
      }
    }
  },
  watch: {
    detailVisible: {
      handler(val) {
        this.getDetail()
      },
      immediate: true
    }
  },
  created() {},
  mounted() {},

  methods: {
    async getDetail() {
      let result = await getEffectiveReferralStoreDetail({ id: this.id })

      this.dialogConfig.title =
        result.isReviewed == 0 ? "复核有效引荐数" : "查看有效引荐数"
      this.approveConfig.isShowFooter = result.isReviewed == 0 ? true : false
      //   申诉类型(1:考勤,2:平板录音)
      this.configData[0].infoData[
        this.findAttrIdx("infoData", "reviewedEffectiveCount")
      ].isDisabled = result.isReviewed == 0 ? false : true
      this.detailInfo = result
    },
    formatterImg(val) {
      if (!val) return []
      let arr = val.split(",")
      return arr
    },
    validateBeforeSave() {
      if (!this.detailInfo.reviewedEffectiveCount) {
        this.$message.error("请输入运营修正实际有效引荐数")
        return false
      }

      const v = this.detailInfo.reviewedEffectiveCount
      const s = String(v).trim()
      if (!/^\d+$/.test(s)) {
        this.$message.error("运营修正实际有效引荐数需为整数")
        return false
      }
      if (
        this.detailInfo.reviewedEffectiveCount < 0 ||
        this.detailInfo.reviewedEffectiveCount > 100000000
      ) {
        this.$message.error("范围应为 0-100000000")
        return false
      }
      this.detailInfo.reviewedEffectiveCount = Number(s)

      return true
    },
    async handleClick() {
      if (!this.validateBeforeSave()) return

      let params = {
        id: this.detailInfo.id,
        reviewedEffectiveCount: this.detailInfo.reviewedEffectiveCount
      }

      effectiveReferralStoreAudit(params)
        .then((res) => {
          if (res) {
            this.$message.success("操作成功")
          }
        })
        .finally((err) => {
          this.visible = false
        })
    },
    handleClose() {
      console.log("handleClose")
    },
    findAttrIdx(formName, name) {
      var index = this.configData[0][formName].findIndex((k) => k.key == name)
      return index || 0
    }
  }
}
</script>
<style lang="scss" scoped>
@import "../../residentManage/salaryPerformance/components/detail.scss";
::v-deep .el-dialog__body {
  padding: 12px 20px !important;
}
::v-deep .el-dialog__footer {
  border-top: 1px solid #e5e5e5;
  padding: 14px 20px !important;
  .dialog-footer {
    border-top: 0px solid #fff !important;
  }
}
::v-deep .el-dialog__header {
  padding: 16px 20px !important;
  color: #333333;
  font-size: 20px;
  font-weight: bold;
}
</style>