CloseStoreDetailDialog.vue 8.5 KB
<!-- 关店详情弹窗 -->
<template>
  <el-dialog title="详情" class="detail-dialog" :visible.sync="visible" width="1080px" @close="handleClose"
    :close-on-click-modal="false">
    <div class="detail-content" v-loading="loading">

      <!-- 门店详情标题与状态 -->
      <div class="section-header">
        <span class="section-title">门店详情</span>
        <span :class="['status-tag', detailInfo.status == 1 ? 'status-warning' : 'status-success']">
          {{ detailInfo.status == 1 ? '待关店' : (detailInfo.status == 3 ? '已关店' : '') }}
        </span>
      </div>

      <!-- 门店详情表单展示 -->
      <div class="section-body">
        <glsx-combi-form class="show-form-container" ref="showFormRef" :label-width="labelWidth" :form-obj="detailInfo"
          :form-data="showFormData">
          <template slot="brandList" slot-scope="scope">
            <div v-if="detailInfo.mainBrands">
              <el-tooltip effect="dark" placement="top" v-if="detailInfo.mainBrands.length > 30">
                <div slot="content" class="tooltip-content-max">
                  <div>{{ detailInfo.mainBrands }}</div>
                </div>
                <span class="one-line-ellipsis info-text">{{ formatMainBrands(detailInfo.mainBrands)
                }}</span>
              </el-tooltip>
              <span v-else class="info-text">{{ detailInfo.mainBrands }}</span>
            </div>

            <div v-else>-</div>
          </template>
        </glsx-combi-form>
      </div>

      <!-- 关店风险 -->
      <div class="section-header mt-20" v-if="detailInfo.hitRuleTypeName">
        <span class="section-title">关店风险</span>
      </div>
      <div class="section-body">
        <div class="risk-alert">
          <i class="el-icon-warning risk-icon"></i>
          <span class="risk-text">{{ detailInfo.hitRuleTypeName ? handleReplace(detailInfo.hitRuleTypeName) : '-' }}
          </span>
        </div>
      </div>

      <!-- 操作记录 -->
      <template v-if="recordList && recordList.length > 0">
        <div class="section-header mt-20">
          <span class="section-title">操作记录</span>
        </div>
        <div class="section-body">
          <div class="record-list">
            <div class="record-item" v-for="(item, index) in recordList" :key="index">
              <div class="record-col">操作人:<span class="record-val">{{ item.operatedByName || '-' }}</span></div>
              <div class="record-col">操作时间:<span class="record-val">{{ item.operatedTime || '-' }}</span></div>
              <div class="record-col">关店原因:<span class="record-val">{{ item.confirmReason || '-' }}</span></div>
            </div>
          </div>
        </div>
      </template>

    </div>

    <div slot="footer" class="dialog-footer">
      <el-button @click="handleClose">取消</el-button>
      <el-button type="primary" @click="handleClose">确定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { closeStoreDetail, closeStoreOperateLogList } from '@api/salesManagement'
import { busTypeOpt, cooperModeOpt } from '../../constant/baseData'

export default {
  name: 'CloseStoreDetailDialog',
  props: {
    dialogVisible: {
      type: Boolean,
      default: false
    },
    recordInfo: {
      type: Object,
      default: () => null
    }
  },
  data() {
    const editItemStyle = {
      width: "50%",
      marginRight: '0px',
      marginBottom: '10px'
    }
    const contentStyle = {
      width: "180px",
      display: 'inline-block',
      'word-break': 'break-all',
      'white-space': 'pre-wrap',
      color: '#333'
    }

    return {
      loading: false,
      labelWidth: '140px',
      detailInfo: {},
      recordList: [], // 操作记录列表
      showFormData: [
        {
          label: '门店名称',
          name: 'shopMerchantName',
          type: 'showTxt',
          style: editItemStyle,
          txtStyle: contentStyle,

        },
        {
          label: '业务类型',
          name: 'businessTypes',
          type: 'showTxt',
          style: editItemStyle,
          txtStyle: contentStyle,
          formatter: (cellValue) => {
            return cellValue.businessTypes ? (cellValue.businessTypes.split(',') || []).map(item => busTypeOpt.find(opt => opt.confId === item).confLabel).join(',') : '-'
          }
        },
        {
          label: '合作模式',
          name: 'cooperationModeName',
          type: 'showTxt',
          style: editItemStyle,
          txtStyle: contentStyle
        },
        {
          label: '主营品牌',
          name: 'mainBrands',
          type: 'showTxt',
          addHtml: "brandList",
          style: editItemStyle,
          txtStyle: {
            ...contentStyle,
            // width: '500px',
            display: '-webkit-box',
            '-webkit-box-orient': 'vertical',
            '-webkit-line-clamp': 2,
            overflow: 'hidden',
            'text-overflow': 'ellipsis',
            'white-space': 'normal'
          }
        },
        {
          label: '关联商户',
          name: 'relatedMerchant',
          type: 'showTxt',
          style: editItemStyle,
          txtStyle: contentStyle
        },
        {
          label: '所在地区',
          name: 'areaName',
          type: 'showTxt',
          style: editItemStyle,
          txtStyle: contentStyle
        },
        {
          label: '详细地址',
          name: 'address',
          type: 'showTxt',
          style: { width: '100%', marginRight: '0px', marginBottom: '10px' },
          txtStyle: { ...contentStyle, width: '500px' }
        }
      ]
    }
  },
  computed: {
    visible: {
      get() {
        return this.dialogVisible
      },
      set(val) {
        this.$emit('update:dialogVisible', val)
      }
    }
  },
  mounted() {
    this.loading = true
    if (this.visible) {
      this.getDetail()
      this.closeStoreOperateLogList()
    }

  },
  methods: {
    handleReplace(val) {
      return val.replace(/[\n]/g, ';')
    },
    handleClose() {
      this.visible = false
    },
    getDetail() {


      closeStoreDetail({ id: this.recordInfo.id }).then(res => {
        this.loading = false
        if (res) {
          this.detailInfo = res
        }
      }).catch(() => {
        this.loading = false
      })
    },
    closeStoreOperateLogList() {
      closeStoreOperateLogList({ id: this.recordInfo.id }).then(res => {
        if (res) {
          this.recordList = res || []
        }
      })
    },
    formatMainBrands(brands) {
      if (!brands) return ''
      if (brands.length > 35) {
        return brands.slice(0, 35) + '...'
      }
      return brands
    }
  }
}
</script>

<style scoped lang="scss">
.detail-dialog {
  ::v-deep .el-dialog__header {
    border-bottom: 1px solid #e5e5e5;
  }

  ::v-deep .el-dialog__body {
    padding: 20px 30px;
  }

  ::v-deep .el-dialog__footer {
    border-top: 1px solid #e5e5e5;
    padding: 10px 20px;
  }
}

.detail-content {
  .mt-20 {
    margin-top: 20px;
  }

  .section-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;

    .section-title {
      font-size: 16px;
      font-weight: bold;
      color: #333;
      margin-right: 15px;
    }

    .status-tag {
      padding: 2px 8px;
      border-radius: 4px;
      font-size: 12px;
      border: 1px solid transparent;
    }

    .status-warning {
      color: #ff9900;
      background: #fff5e6;
      border-color: #ff9900;
    }

    .status-success {
      color: #19be6b;
      background: #e8f8f0;
      border-color: #19be6b;
    }
  }

  .section-body {
    ::v-deep .el-form-item {
      margin-bottom: 0;
    }

    ::v-deep .el-form-item__label {
      color: #666;
    }

    .risk-alert {
      display: flex;
      align-items: center;
      background-color: #FEF4E8;
      border-radius: 4px;
      padding: 16px 20px;

      .risk-icon {
        color: #ff9900;
        font-size: 24px;
        margin-right: 10px;
      }

      .risk-text {
        color: #333;
        font-size: 14px;
        white-space: pre-wrap;
        word-break: break-all;
      }
    }

    .record-list {
      .record-item {
        display: flex;
        justify-content: space-between;
        margin-bottom: 15px;
        font-size: 14px;

        .record-col {
          color: #666;
          flex: 1;

          .record-val {
            color: #333;
          }
        }
      }
    }
  }
}

.info-text {
  width: 180px;
  display: inline-block;
  word-break: break-all;
  white-space: pre-wrap;
  color: #333;
}
</style>