virtualAccountManagementDetailDialog.vue 9.62 KB
<!-- 历史虚拟操作规则 -->
<template>
  <baseDialog :is-show.sync="visible" :config="dialogConfig.setting" :dialog-config="dialogConfig.config"
              @closeDialog="handleDetailClose">
    <div class="yseUserCode">虚账编码: {{ merchantRow.yseUserCode }}</div>
    <div class="account-detail" ref="accountDetail">
      <div v-if="formArray && formArray.length">
        <div v-for="(formItem, index) in formArray" v-resize="resetTableHeight" :ref="'resize' + index" :key="index">
          <p class="edit-sub-title " :class="{ 'sub-border': !formItem.show }">
            <span class="label">
              <span>{{ formItem.formatEffectStartDate }}</span>
              <span v-if="formItem.formatEffectStartDate"> - </span>
              <span :class="{ 'labelColor': !formItem.formatEffectEndDate }">{{
                formItem.formatEffectStartDate ? formItem.formatEffectEndDate ? formItem.formatEffectEndDate : '生效中' :
                '待生效'
              }}</span>
            </span>
            <span class="updatedInfo">
              操作人: {{ formItem.createdBy }} 操作时间: {{ formItem.formatUpdatedDate }}
            </span>
            <span class="collapse" @click="collapseItem(index)">
              <i :class="{ 'move': !formItem.show }" class="arrow el-icon-arrow-down" />
              {{ formItem.show ? '收起' : '展开' }} </span>
          </p>
          <el-collapse-transition>
            <d2-table v-if="formItem.show" :table-data="formItem.yseMerchantRefs" :table-params="tableDetailParams"
                      :has-page="false"></d2-table>
          </el-collapse-transition>
        </div>
      </div>

      <div v-else class="nothingtips">
        <img style="height: 109px; width: 109px;" src="../../images/empty.png">
        <p class="title">
          暂无操作记录
        </p>
        <p class="tips">
          快去设置看看~
        </p>
      </div>
    </div>
  </baseDialog>
</template>

<script>
import dayjs from 'dayjs'
import { yseMerchantListHistory } from '@api/publicAccount'
import { merchantClassifyList } from '@/common/constants'
// import viewDetail from './viewDetail'
import resize from '@/common/resize'
export default {
  name: 'VirtualAccountManagementDetailDialog',
  // 在vue自定义指令中添加该指令
  directives: {
    resize
  },
  components: {
    // Collapse
    // viewDetail
  },
  props: {
    accountDetailVisible: {
      type: Boolean,
      default: false
    },
    // merchantId: {
    //   type: [String, Number],
    //   default: '44209883'
    // },
    merchantRow: {
      type: Object,
      default: () => { }
    }
  },
  data() {
    return {
      merchantClassifyList,
      formArray: [],
      dialogConfig: {
        setting: {
          showClose: true,
          appendToBody: false,
          // width: '720px',
          btnList: [
          ]
        },
        config: {
          title: '操作记录',
          width: '850px'
        }
      },
      yseUserCode: '',
      tableDetailParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        // tableOption: true,
        tableColumns: [
          {
            label: '商户名称',
            prop: 'merchantName'
          }, {
            label: '商户号',
            prop: 'merchantId'
          },
          {
            label: '商户分类',
            prop: 'merchantType',
            formatter: (cellValue) => {
              return cellValue.merchantType
                ? merchantClassifyList.find(item => item.confId ==
                  cellValue.merchantType).confLabel
                : ''
            }
          }]
      }
    }
  },
  computed: {
    visible: {
      get() {
        return this.accountDetailVisible
      },
      set(newVal) {
        this.$emit('dialogClose')
        // this.$emit('dialogClose', { flag: newVal, attrName: 'addVisible' })
      }
    }
  },
  watch: {
    accountDetailVisible(newVal) {
      console.log(newVal, 'newVal')
      if (newVal) {
        this.yseUserCode = this.merchantRow.id
        this.getDetail()
      }
    }
  },

  mounted() {
  },

  methods: {
    collapseItem(SelectIndex) {
      // return
      this.formArray.forEach((element, index) => {
        if (SelectIndex == index) {
          element.show = !element.show
        } else {
          element.show = false
        }
      })
    },
    getDetail() {
      yseMerchantListHistory({ yseMerchantId: this.yseUserCode }).then(res => {
        // console.log(res)
        // dayjs(this.summaryDate).startOf('month').format('YYYY-MM-DD')
        // const timeLabele = {

        // }
        // let financialRulesList = res
        // 财务规则有三个模式 待生效 生效中 历史
        // 根据effectEndDate 和 effectStartDate
        console.log(res, 'res')
        // return
        this.formArray = res.map((item, index) => {
          const format = 'YYYY/MM/DD HH:mm'
          const createdDate = item.effectStartDate || item.createdDate
          // item.merchant = item?.divisionRule?.realityDivisionMerchant
          // item = Object.assign(item, item.settleRule, item.divisionRule)
          // 这个值强制取item里面的
          item.createdDate = createdDate
          item.formatEffectEndDate = item.effectEndDate ? dayjs(item.effectEndDate).format(format) : ''
          item.formatEffectStartDate = item.effectStartDate ? dayjs(item.effectStartDate).format(format) : ''
          // console.log('item.createdDate', item.createdDate)
          item.formatUpdatedDate = dayjs(item.createdDate).format(format)
          item.show = !index
          return item
        })
      })
    },
    resetTableHeight() {
      function getClientHeight() {
        let clientHeight = 0
        if (document.body.clientHeight && document.documentElement.clientHeight) {
          clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
        } else {
          clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
        }
        return clientHeight
      }

      const windowHeight = getClientHeight() - 221

      const that = this
      // const list = ['resize0', 'resize1', 'resize2', 'resize3']
      const listHeight = this.formArray.reduce((num, item, index) => {
        // console.log(that.$refs[item])
        num = num + (that.$refs[`resize${index}`][0].offsetHeight) || 0
        return num
      }, 0)

      // console.log(listHeight)
      const height = windowHeight > listHeight ? listHeight : windowHeight
      // console.log(height + 'height')
      this.$refs.accountDetail.style.height = height + 'px'
      // console.log(this.$refs.resize0[0].offsetHeight)
    },
    handleDetailClose(flag = false) {
      this.$emit('dialogClose', flag)
    }

  }
}

</script>
<style scoped lang="scss">
.account-detail {
  // height: 400px;
  // height: calc(100vh - 200px);
  padding-right: 15px;
  overflow-y: scroll;
  overflow-x: hidden;
}

.edit-sub-title {
  padding: 17px 0;
  margin: 0;
  display: flex;
  justify-content: space-between;
  font-size: 14px;

  &::before {
    top: 50%;
    transform: translateY(-50%);
  }

  .label {
    padding-left: 8px;
    width: 37%;
  }

  .labelColor {
    color: #0947c6;
  }

  .updatedInfo {
    width: 40%;
    text-align: left;
  }

  .collapse {
    padding-right: 20px;
    color: #0947c6;
    cursor: pointer;

    .arrow {
      transition: all 1s;
    }

    .move {
      transform: rotate(-180deg);
    }
  }
}

.sub-border {
  animation: border-delay 1s forwards;
}

@keyframes border-delay {
  0% {
    /* opacity: 0; */
    /* right: -100%; */
  }

  100% {
    border-bottom: 1px solid #d8d8d8;
  }
}

.account-detail .detail-img {
  width: 180px;
  height: 104px;
  margin-right: 40px;
  transition: width 0.3s;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  margin-right: 100px;
}

.itemContainer {
  padding: 30px 0;
  background: #f4f6fc;
  border-radius: 2px;
}

.imageContainer {
  //  style="display: inline-block;"
  // max-height: 50%;
  position: relative;
  max-width: 50%;
  box-sizing: border-box;
  display: inline-block;
  // display: flex;
  // flex-wrap: wrap;

  // justify-content: space-between;
}

.imageLabel {
  line-height: 14px;
  width: 137px;
  // width: 50%;
  text-align: center;
  color: #999999;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
}

.img-btns {
  display: none;
  position: absolute;
  width: 180px;
  height: 104px;
  left: 0;
  top: 0;
  z-index: 2;
  color: #fff;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.5);
}

.img-btns .btn-item {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.img-btns .btn-item {
  display: flex;
  width: 70%;
  justify-content: space-around;
}

.imageContainer:hover .img-btns {
  display: block;
}

.nothingtips {
  // align-items: center;
  text-align: center;
  font-size: 16px;
  padding-top: 40px;

  .title {
    font-size: 20px;
    color: #666;
    margin: 16px 0;
  }

  .tips {
    font-size: 12px;
    color: #999;
  }
}

.yseUserCode {
  height: 40px;
  background: #F6F9FF;
  line-height: 40px;
  padding-left: 16px;
  font-family: PingFangSC-Medium;
  font-weight: 500;
}
</style>