financialRulesDetail.vue 8.52 KB
<!-- 历史财务规则 -->
<template>
  <div class="account-detail" ref="accountDetail">
    <!--      v-resize="resetTableHeight"
         :ref="'resize' + index" -->
    <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.updatedBy }} 操作时间: {{ 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>
          <viewDetail :is-get-detail="false" v-if="formItem.show" :merchant-info="formItem"
                      :view-detail-visible="formItem.show" />
        </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>
</template>

<script>
import dayjs from 'dayjs'
import { getHistoryRecord } from '@api/publicAccount'
import viewDetail from './viewDetail'
import resize from '@/common/resize'
export default {
  name: 'FinancialRulesDetail',
  // 在vue自定义指令中添加该指令
  directives: {
    resize
  },
  components: {
    // Collapse
    viewDetail
  },
  props: {
    accountDetailVisible: {
      type: Boolean,
      default: false
    },
    merchantId: {
      type: [String, Number],
      default: '44209883'
    },
    merchantRow: {
      type: Object,
      default: () => { }
    }
  },
  data() {
    return {
      formArray: []

    }
  },

  watch: {
    accountDetailVisible(newVal) {
      if (newVal) {
        this.merchantId = this.merchantRow.merchantId
        // this.getDetail()
      }
    }
  },

  mounted() {
    this.getDetail()
  },

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

        // }
        // let financialRulesList = res
        // 财务规则有三个模式 待生效 生效中 历史
        // 根据effectEndDate 和 effectStartDate
        // console.log(res)
        this.formArray = res.map((item) => {
          const format = 'YYYY/MM/DD HH:mm'
          const createdDate = 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 = false
          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)
    }

  }
}

</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;
}

// .account-detail .detail-img:hover {
//   margin-right: 0px;
//   width: 90%;
//   height: 90%;
// }
// .account-detail .detail-img:hover + .imageLabel {
//   width: 90%;
// }
.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;
}

/* .transition-box {
  margin-bottom: 10px;
  width: 200px;
  height: 100px;
  border-radius: 4px;
  background-color: #409eff;
  text-align: center;
  color: #fff;
  padding: 40px 20px;
  box-sizing: border-box;
  margin-right: 20px;
} */
.link {
  color: blue;
  cursor: pointer;
  // /* 鼠标样式*/
}

.link:link {
  color: #06f;
  text-decoration: none;
  // /* 未访问的链接 */
}

.link:visited {
  color: #999;
  text-decoration: line-through;
  // /* 已访问的链接 */
}

.link:hover {
  color: #f00;
  //* 鼠标移动到链接上 */
  text-decoration: underline;
}

.link:active {
  // /* 选定的链接 */
  color: #f0f;
}

.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;
  }
}</style>