CustomerDetailDialog.vue 8.03 KB
<!-- 客户详情 -->
<template>
  <div>
    <d2-dialog title="详情" :is-visible="detailVisible" class="stockMonthDailog" width="1080px" :no-cancel="true"
      btn-ok-label="关闭" @closeDialog="handleClose" @confirmDialog="handleClose">
      <el-tabs v-model="activeTab" class="detail-dialog-tabs">
        <el-tab-pane label="门店详情" name="store">
          <potential-customer-store-detail-section v-if="recordInfo && recordInfo.id != null" :record-id="recordInfo.id"
            :show-visit-record="true" :show-section-title="false" />
        </el-tab-pane>
        <el-tab-pane label="商户信息" name="merchant">
          <div v-loading="merchantLoading" class="detail-info merchant-info-pane">
            <glsx-combi-form class="edit-form-container" ref="merchantFormRef" :label-width="labelWidth"
              :form-obj="merchantInfo" :form-data="merchantFormData" />
          </div>
        </el-tab-pane>
      </el-tabs>
    </d2-dialog>
  </div>
</template>

<script>
import PotentialCustomerStoreDetailSection from './PotentialCustomerStoreDetailSection.vue'
import { potentialCustomersVerificationDetail } from '@api/salesManagement'
import { buildMerchantVerifyEchoDisplay } from '@/components/merchantVerify/merchantVerifyDisplay'

function extractMerchantInfo(res) {
  if (!res) return null
  if (res.merchantInfo != null && typeof res.merchantInfo === 'object') return res.merchantInfo
  if (res.data != null && res.data.merchantInfo != null && typeof res.data.merchantInfo === 'object') {
    return res.data.merchantInfo
  }
  return null
}

export default {
  name: 'CustomerDetailDialog',
  components: {
    PotentialCustomerStoreDetailSection
  },
  data() {
    const editItemStyle = {
      width: '50%',
      marginRight: '0px'
    }
    const contentStyle = {
      width: '358px',
      display: 'inline-block',
      'word-break': 'break-all',
      'white-space': 'pre-wrap'
    }
    return {
      labelWidth: '140px',
      activeTab: 'store',
      merchantLoading: false,
      merchantInfo: {},
      /** 与示意图一致:左列 商户类型/账户等级/渠道/商户名称/商户地址/主营品牌/登录账号;右列 上级商户/开通模式/电话/密码 */
      merchantFormData: [{
        label: '商户类型',
        name: 'merchantType',
        type: 'showTxt',
        style: editItemStyle,
        txtStyle: contentStyle
      }, {
        label: '上级商户',
        name: 'parentMerchantName',
        type: 'showTxt',
        style: editItemStyle,
        txtStyle: contentStyle
      }, {
        label: '账户等级',
        name: 'accountLevel',
        type: 'showTxt',
        style: editItemStyle,
        txtStyle: contentStyle
      }, {
        label: '选择开通模式',
        name: 'openMode',
        type: 'showTxt',
        style: editItemStyle,
        txtStyle: contentStyle
      }, {
        label: '渠道',
        name: 'superChannel',
        type: 'showTxt',
        style: editItemStyle,
        txtStyle: contentStyle
      }, {
        label: '联系电话',
        name: 'contactPhone',
        type: 'showTxt',
        style: editItemStyle,
        txtStyle: contentStyle
      }, {
        label: '商户名称',
        name: 'merchantName',
        type: 'showTxt',
        style: editItemStyle,
        txtStyle: contentStyle
      }, {
        label: '登录密码',
        name: 'loginPasswordMasked',
        type: 'showTxt',
        style: editItemStyle,
        txtStyle: contentStyle,
        formatter: (formObj) => {
          return formObj.loginPasswordMasked != null && formObj.loginPasswordMasked !== ''
            ? formObj.loginPasswordMasked
            : '-'
        }
      }, {
        label: '商户地址',
        name: 'merchantAddress',
        type: 'showTxt',
        style: { width: '100%', marginRight: '0px' },
        txtStyle: { ...contentStyle, width: '890px' }
      }, {
        label: '主营品牌',
        name: 'mainBrands',
        type: 'showTxt',
        style: editItemStyle,
        txtStyle: contentStyle
      }, {
        label: '',
        name: '_emptyRightMainBrand',
        type: 'showTxt',
        style: editItemStyle,
        txtStyle: contentStyle,
        formatter: () => ''
      }, {
        label: '登录账号',
        name: 'loginAccount',
        type: 'showTxt',
        style: editItemStyle,
        txtStyle: contentStyle
      }, {
        label: '',
        name: '_emptyRightLoginAccount',
        type: 'showTxt',
        style: editItemStyle,
        txtStyle: contentStyle,
        formatter: () => ''
      }]
    }
  },

  props: {
    detailVisible: {
      type: Boolean,
      default: false,
    },
    recordInfo: {
      type: Object,
      default: () => { },
    },
  },

  watch: {
    detailVisible(val) {
      if (val && this.recordInfo && this.recordInfo.id != null && this.recordInfo.id !== '') {
        this.activeTab = 'store'
        this.fetchMerchantVerificationDetail()
      } else if (!val) {
        this.resetMerchantInfoDisplay()
      }
    },
    'recordInfo.id'(id) {
      if (this.detailVisible && id != null && id !== '') {
        this.fetchMerchantVerificationDetail()
      }
    }
  },

  created() {
    this.resetMerchantInfoDisplay()
  },

  mounted() {
    if (this.detailVisible && this.recordInfo && this.recordInfo.id != null && this.recordInfo.id !== '') {
      this.fetchMerchantVerificationDetail()
    }
  },

  methods: {
    handleClose() {
      this.$emit('dialogClose')
    },

    resetMerchantInfoDisplay() {
      this.merchantInfo = {
        merchantType: '-',
        accountLevel: '-',
        superChannel: '-',
        merchantName: '-',
        merchantAddress: '-',
        mainBrands: '-',
        loginAccount: '-',
        parentMerchantName: '-',
        openMode: '-',
        contactPhone: '-',
        loginPasswordMasked: '-',
        _emptyRightMainBrand: '',
        _emptyRightLoginAccount: ''
      }
    },

    applyMerchantInfo(mi) {
      const built = buildMerchantVerifyEchoDisplay(mi)
      this.merchantInfo = {
        ...built,
        _emptyRightMainBrand: '',
        _emptyRightLoginAccount: ''
      }
    },

    fetchMerchantVerificationDetail() {
      const rawId = this.recordInfo && this.recordInfo.id
      if (rawId === null || rawId === undefined || rawId === '') {
        this.resetMerchantInfoDisplay()
        return
      }
      const id = typeof rawId === 'number' ? rawId : parseInt(rawId, 10)
      if (Number.isNaN(id)) {
        this.resetMerchantInfoDisplay()
        return
      }
      this.merchantLoading = true
      potentialCustomersVerificationDetail({ id })
        .then((res) => {
          const mi = extractMerchantInfo(res)
          if (mi) {
            this.applyMerchantInfo(mi)
          } else {
            this.resetMerchantInfoDisplay()
          }
        })
        .catch(() => {
          this.resetMerchantInfoDisplay()
        })
        .finally(() => {
          this.merchantLoading = false
        })
    }
  }
}
</script>
<style lang="scss" scoped>
::v-deep .el-dialog__body {
  padding: 0 20px 20px;
}

::v-deep .el-dialog__header {
  color: #333333;
  font-size: 20px;
  font-weight: bold;
  border-bottom: 1px solid #e5e5e5;
}

::v-deep .el-form-item--small .el-form-item__label,
::v-deep .el-form-item--small .el-form-item__content {
  line-height: 20px;
}

.detail-dialog-tabs {
  ::v-deep .el-tabs__header {
    margin: 0 0 8px;
    border-bottom: 1px solid #e5e5e5;

    .el-tabs__nav-wrap::after {
      height: 0;
    }
  }

  ::v-deep .el-tabs__nav-wrap {
    padding: 0;
  }

  ::v-deep .el-tabs__item {
    height: 48px;
    line-height: 48px;
    font-size: 16px;
  }

  ::v-deep .el-tab-pane {
    min-height: 200px;
  }
}

.merchant-info-pane {
  padding-top: 8px;
  min-height: 120px;
}

.detail-info {
  span {
    color: #333333ff;
  }

  .add-btn {
    font-size: 14px;
    color: #5850ff;
    cursor: pointer;
  }
}

.deliveryCardCon {
  max-height: 60vh;
  overflow: auto;
}

.lookNumber {
  cursor: pointer;
  margin-left: 8px;
}

.table-wrap {
  border: 1px solid #e5e5e5;
  padding: 16px;
  box-sizing: border-box;
  margin-top: 16px;
}
</style>