detail.vue 12.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436
<!-- 盘点详情弹窗弹窗 -->
<template>
  <GLDialog bigTitle="详细信息" :visible.sync="isVisible" :hasFooter="false" :before-close="handleClose" class="points" mode="big" okText="关闭" @onCancel="handleClose" @onOk="handleClose">
    <div class="wrap edit-box">
      <div>
        <p class="edit-title">订单信息</p>
        <el-form label-width="150px" :inline="true">
          <el-row v-for="(item, index) in withdrawDataRow" :key="index">
            <el-form-item v-for="(subItem, subIndex) in item.rowList" :key="subIndex" :label="subItem.label + ':'" class="row-item">
              <span v-if="subItem.addHtml">
                {{ subItem.addHtml(recordInfo) }}
              </span>
              <span v-else class="detail-txt ellipsis-1" :title="recordInfo[subItem.name]">{{ recordInfo[subItem.name] ? recordInfo[subItem.name] + (subItem.suffix || '') : '--' }}</span>
            </el-form-item>
          </el-row>
        </el-form>
      </div>
      <div>
        <p class="edit-title">付款信息</p>
        <el-form label-width="154px" :inline="true">
          <el-row v-for="(item, index) in paymentDataRow" :key="index">
            <el-form-item v-for="(subItem, subIndex) in item.rowList" :key="subIndex" :label="subItem.label + ':'" class="row-item">
              <span v-if="subItem.addHtml">
                {{ subItem.addHtml(recordInfo) }}
              </span>
              <span v-else-if="subItem.addStyle" class="flex_sc">
                <div class="table_point" :style="{ background: subItem.addStyle(recordInfo).color }"></div>
                {{ subItem.addStyle(recordInfo).status }}
              </span>
              <span v-else class="detail-txt ellipsis-1" :title="recordInfo[subItem.name]">{{ recordInfo[subItem.name] ? recordInfo[subItem.name] + (subItem.suffix || '') : '--' }}</span>
            </el-form-item>
          </el-row>
          <el-row v-if="this.recordInfo.status == 4">
            <el-form-item label="失败原因:">
              <span>{{ recordInfo.errorMessage }}</span>
              <span class="copy" @click="handleCopy">复制</span>
            </el-form-item>
          </el-row>
        </el-form>
      </div>
      <div v-if="recordInfo.operationList && recordInfo.operationList.length">
        <p class="edit-title">操作记录</p>
        <template v-for="(record, recordIdx) in recordInfo.operationList">
          <el-form label-width="154px" :inline="true" :key="recordIdx">
            <el-row v-for="(item, index) in operationDataRow" :key="index">
              <el-form-item v-for="(subItem, subIndex) in item.rowList" :key="subIndex" :label="subItem.label(record) + ':'" class="row-item">
                <span v-if="subItem.addHtml" class="flex_sc">
                  <div class="table_point" :style="{ background: subItem.addHtml(record).color }"></div>
                  {{ subItem.addHtml(record).status }}
                </span>
                <span v-else class="detail-txt ellipsis-1" :title="record[subItem.name]">{{ record[subItem.name] ? record[subItem.name] + (subItem.suffix || '') : '--' }}</span>
              </el-form-item>
            </el-row>
          </el-form>
        </template>
      </div>
    </div>
  </GLDialog>
</template>
  <script>
const tableStatus = ['待审核', '已审核', '第三方处理', '成功', '失败', '驳回', '受理失败', '批次处理中', '签约中']
const colors = ['#FDB757', '#2CCA74', '#5850FF', '#2CCA74', '#999999', '#EB4E4E', '#2CCA74', '#F59619FF', '#F59619']

import { sourceList } from '@/utils/constants.js'
export default {
  name: 'DetailDialog',
  data() {
    return {
      recordInfo: {},
      withdrawDataRow: [],
      paymentDataRow: [],
      operationDataRow: [],
      withdrawData: [],
      paymentData: [],
      operationData: [],
      isVisible: this.detailVisible,
      sourceList: sourceList,
      baseData: {
        channelList: []
      }
    }
  },
  props: {
    detailVisible: {
      type: Boolean,
      default: false
    },
    id: {
      type: Number,
      default: 0
    }
  },
  watch: {
    detailVisible(newVal) {
      this.isVisible = newVal
      this.getDetails()
    }
  },
  computed: {},
  mounted() {
    this.getChannelTree()
  },
  methods: {
    removeEmptyChild(arr) {
      return arr.map(item => {
        // 如果有 child 字段,递归处理
        if (item.child) {
          item.child = this.removeEmptyChild(item.child)
        }

        // 移除 child 为 null 或空数组的情况
        if (item.child === null || (Array.isArray(item.child) && item.child.length === 0)) {
          delete item.child
        }

        return item
      })
    },
    getChannelTree() {
      this.$apis.withdraw.getChannelTree({}).then(res => {
        this.baseData.channelList = this.removeEmptyChild(res)
      })
    },
    findChannelByCode(list, code) {
      for (let item of list) {
        // 如果当前项的 code 匹配,直接返回该项
        if (item.code === code) {
          return item
        }

        // 如果有 child 字段且不为空数组,递归查找
        if (item.child && item.child.length > 0) {
          const found = this.findChannelByCode(item.child, code)
          if (found) {
            return found
          }
        }
      }

      // 没有找到匹配项时返回 null
      return null
    },
    handleCopy() {
      const text = this.recordInfo.errorMessage
      const input = document.createElement('input')
      input.value = text
      // 将临时输入框添加到页面中
      document.body.appendChild(input)
      // 选中临时输入框的内容
      input.select()

      const isSuccessful = document.execCommand('copy')
      document.body.removeChild(input)
      if (isSuccessful) {
        this.$message.success('复制成功')
      }
    },
    getDetails() {
      this.$apis.withdraw.getDetails({ id: this.id }).then(res => {
        this.recordInfo = res
        this.getConfig()
      })
    },
    getConfig() {
      this.withdrawData = [
        {
          label: '提现单号',
          name: 'outSettleOrderId'
        },
        {
          label: '提现类型',
          name: 'transferType',
          addHtml: obj => {
            return obj.transferType == 0 ? '积分提现' : obj.transferType == 1 ? '普通提现' : '阳光激励'
          }
        },
        {
          label: '提现方式',
          name: 'mode',
          addHtml: obj => {
            return obj.mode === 1 ? '微信' : obj.mode === 0 ? '银行卡' : '--'
          }
        },
        {
          label: '提现金额',
          name: 'payAmount',
          addHtml: obj => {
            return obj.payAmount ? (obj.payAmount / 100).toFixed(2) : '--'
          }
        },
        {
          label: '客户名称',
          name: 'customerName'
        },
        {
          label: '客户手机',
          name: 'customerPhone'
        },
        {
          label: '提现积分',
          name: 'integralAmount'
        },

        {
          label: '所属门店',
          name: 'merchantName'
        },
        {
          label: '平台方',
          name: 'realityMerchantName'
        },
        {
          label: '申请时间',
          name: 'createdDate'
        },
        {
          label: '来源',
          name: 'withdrawalSource',
          addHtml: obj => {
            let arr = this.sourceList.filter(item => item.confId == obj.withdrawalSource)
            return arr.length > 0 ? arr[0].confLabel : '--'
          }
        }
      ]
      this.paymentData = [
        {
          label: '收款人姓名',
          name: 'name'
        },
        {
          label: '收款人身份证',
          name: 'idCardNo'
        },
        {
          label: '收款银行卡号',
          name: 'recvBankCardNo'
        },
        {
          label: '收款银行',
          name: 'recvBank'
        },
        {
          label: '收款手机号',
          name: 'mobile'
        },
        {
          label: '微信openid',
          name: 'customerOpenId'
        },
        {
          label: '付款渠道',
          name: 'channel',
          addHtml: obj => {
            let item = this.findChannelByCode(this.baseData.channelList, obj.channel)
            return item ? item.name : '--'
          }
        },
        {
          label: '付款主体',
          name: 'paymentEntityName'
        },
        {
          label: '代征主体',
          name: 'levyName'
        },
         {
          label: '银行渠道',
          name: 'levyChannelName'
        },
        {
          label: '结算金额',
          name: 'settleAmount',
          addHtml: obj => {
            return obj.settleAmount ? (obj.settleAmount / 100).toFixed(2) : '--'
          }
        },
        {
          label: '到账时间',
          name: 'receiptDate'
        },
        {
          label: '状态',
          name: 'status',
          addStyle: obj => {
            return {
              status: tableStatus[obj.status],
              color: colors[obj.status]
            }
          }
        }
        // {
        //   label: '失败原因',
        //   name: 'errorMessage'
        // }
      ]
      this.operationData = [
        {
          label: obj => {
            return ['审核', '付款', '受理'][obj.type]
          },
          name: 'type',
          addHtml: obj => {
            let status = '--',
              color
            if (obj.result == 0) {
              status = '通过'
              color = '#2CCA74'
            } else if (obj.result == 1) {
              status = '驳回'
              color = '#EB4E4E'
            } else if (obj.result == 2) {
              status = '失败'
              color = '#999999'
            }
            return {
              status,
              color
            }
          }
        },
        {
          // label: ['审核人', '付款人', '操作人'],
          label: obj => {
            let arr = ['审核人', '付款人', '受理人'],
              label
            if (obj.result == 0) {
              label = arr[obj.type]
            } else if (obj.result == 1) {
              label = '操作人'
            } else {
              label = arr[obj.type]
            }
            return label
          },
          name: 'createdBy'
        },
        {
          label: obj => {
            let arr = ['审核时间', '付款时间', '受理时间'],
              label
            if (obj.result == 0) {
              label = arr[obj.type]
            } else if (obj.result == 1) {
              label = '操作时间'
            } else {
              label = arr[obj.type]
            }
            return label
          },
          name: 'createdDate'
        },
        {
          label: () => {
            return '备注'
          },
          name: 'remark'
        }
      ]
      // if () {
      //   this.handleJudgment(this.paymentData, 'errorMessage')
      // }
      this.formToRow('withdrawData')
      this.formToRow('operationData')
      this.formToRow('paymentData')
    },

    handleJudgment(target, key) {
      let arr = target,
        len = arr.length,
        item
      for (let i = 0; i < len; i++) {
        item = arr[i]
        if (item.name == key) {
          arr.splice(i, 1)
        }
      }
    },
    formToRow(formName, numOfRow = 3) {
      var rowNum = Math.ceil(this[formName].length / numOfRow)
      for (var i = 0; i < rowNum; i++) {
        for (var j = 0; j < numOfRow; j++) {
          if (j == 0) {
            this[formName + 'Row'][i] = {
              rowList: []
            }
          }
          if (i * numOfRow + j < this[formName].length) {
            this[formName + 'Row'][i].rowList.push(this[formName][i * numOfRow + j])
          }
        }
      }
    },
    handleClose() {
      this.isVisible = false
      this.$emit('dialogClose')
    }
  }
}
</script>
  <style scoped lang="scss">
.edit-box .row-item {
  width: 30%;
  /deep/ {
    .el-form-item__content {
      height: 30px;
    }
  }
}
.detail-txt {
  display: inline-block;
  width: 136px;
}
.edit-title {
  font-weight: 600;
  font-size: 16px;
  color: #000000d9;
  line-height: 24px;
}
.m-b-20 {
  margin-top: 20px;
}
/deep/ .el-form-item {
  margin-bottom: 0;
}
.table_point {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 8px;
}
.copy {
  color: #5850ff;
  margin-left: 20px;
  cursor: pointer;
}
</style>