chooseRuleDialog.vue 10.7 KB
<!-- 选择财务规则弹窗 -->
<template>
  <d2-dialog title="选择财务规则"
             :is-visible="ruleVisible"
             class="chooseRuleDialog"
             width="65%"
             @closeDialog="handleClose"
             @confirmDialog="handleAddConfirm">
    <!-- <div>
      <span>订单所属商户:{{recordInfo.merchantName}}</span><span>主订单编号:{{recordInfo.inputtedOrderCode}}</span><span>订单金额:{{recordInfo.totalFee ? '¥' + recordInfo.totalFee / 100 : ''}}</span><span>支付时间:{{recordInfo.accountDate}}</span>
    </div> -->
    <el-form class="rule-form"
             label-width="110px"
             :inline="true">
      <el-form-item class="d2-drawer-item"
                    label="订单所属商户:">
        <span>{{ recordInfo.merchantName }}</span>
      </el-form-item>
      <el-form-item class="d2-drawer-item"
                    label="主订单编号:">
        <!-- <span>{{ recordInfo.inputtedOrderCode }}</span> -->
        <span>{{ recordInfo.orderCode }}</span>
      </el-form-item>
      <el-form-item class="d2-drawer-item"
                    label="订单金额:">
        <!-- <span>{{ recordInfo.totalFee ? '¥' + recordInfo.totalFee / 100 : '' }}</span> -->
        <span>{{ recordInfo.totalPrice ? '¥' + recordInfo.totalPrice : '' }}</span>
      </el-form-item>
      <el-form-item class="d2-drawer-item"
                    label="支付时间:">
        <!-- <span>{{ recordInfo.accountDate }}</span> -->
        <span>{{ recordInfo.paySuccessDate }}</span>
      </el-form-item>
    </el-form>
    <div class="fontD">请选择要应用的分账规则:</div>
    <div>
      <div class="merchant-checkrecord">
        <div class="account-detail"
             ref="accountDetail">
          <div v-if="formArray && formArray.length > 0">
            <div v-for="(formItem, index) in formArray"
                 :ref="'resize' + index"
                 :key="index">
              <p class="sub-title"
                 :class="{ 'sub-border': !formItem.show }">
                <el-radio v-model="radio"
                          :label="formItem.id">
                  <i></i>
                </el-radio>
                <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>
              </p>
            </div>
          </div>

          <div v-else
               class="nothingtips">
            <img style="height: 109px; width: 109px"
                 src="../systemConfig/merchant/images/empty.png" />
            <p class="title">暂无分账规则</p>
            <p class="tips">快去设置看看~</p>
          </div>
        </div>
      </div>
    </div>
    <div class="fontD">请选择要应用的对账规则:</div>
    <div>
      <div class="merchant-checkrecord">
        <div class="account-detail"
             ref="accountDetail">
          <div v-if="formArray2 && formArray2.length > 0">
            <div v-for="(formItem, index) in formArray2"
                 :ref="'resize' + index"
                 :key="index">
              <p class="sub-title"
                 :class="{ 'sub-border': !formItem.show }">
                <el-radio v-model="radio2"
                          :label="formItem.id">
                  <i></i>
                </el-radio>
                <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>
              </p>
            </div>
          </div>

          <div v-else
               class="nothingtips">
            <img style="height: 109px; width: 109px"
                 src="../systemConfig/merchant/images/empty.png" />
            <p class="title">暂无对账规则</p>
            <p class="tips">快去设置看看~</p>
          </div>
        </div>
      </div>
    </div>
  </d2-dialog>
</template>

<script>
import dayjs from "dayjs"
// import { Util, deepClone } from '@/common/util'
// import { getHistoryRecord } from "@api/publicAccount"
// import {
//   getLedgerHistoryRecordApi,
// } from "@api/merchant"
import { getHistoryEffectRecord, manualDivision } from '@api/order'
export default {
  name: "ChooseRuleDialog",
  props: {
    ruleVisible: {
      type: Boolean,
      default: false
    },
    recordInfo: {
      type: Object,
      default: () => { }
    }
  },
  components: {

  },
  computed: {},
  data() {
    return {
      formArray: [],
      formArray2: [],
      radio: '',
      radio2: ''
    }
  },
  created() {

  },
  mounted() {
    // this.recordInfo.accountDate = this.recordInfo.accountDate ? Util.dateFormate(this.recordInfo.accountDate, 'YYYY-MM-DD HH:mm:ss') : ''
    this.getLedgerHistoryRecord()
  },
  methods: {
    // 分账
    async getLedgerHistoryRecord() {
      const merchantId = this.recordInfo.merchantId
      const sceneType = this.recordInfo.sceneType
      const params = {
        merchantId,
        sceneType
      }
      const res = await getHistoryEffectRecord(params)

      if (res) {
        const settleDistributeRuleEffectiveList = res.settleDistributeRuleEffectiveList // 分账规则
        const reconciliationRuleEffectiveList = res.reconciliationRuleEffectiveList // 对账规则
        const format = "YYYY/MM/DD HH:mm"
        if (settleDistributeRuleEffectiveList.length > 0) {
          this.formArray = settleDistributeRuleEffectiveList.map(item => {
            item.formatEffectEndDate = item.effectEndDate
              ? dayjs(item.effectEndDate).format(format)
              : ""
            item.formatEffectStartDate = item.effectStartDate
              ? dayjs(item.effectStartDate).format(format)
              : ""
            item.formatUpdatedDate = dayjs(item.updatedDate).format(format)
            item.show = false
            return item
          })
        } else {
          this.formArray = []
        }
        if (reconciliationRuleEffectiveList.length > 0) {
          this.formArray2 = reconciliationRuleEffectiveList.map(item => {
            item.formatEffectEndDate = item.effectEndDate
              ? dayjs(item.effectEndDate).format(format)
              : ""
            item.formatEffectStartDate = item.effectStartDate
              ? dayjs(item.effectStartDate).format(format)
              : ""
            item.formatUpdatedDate = dayjs(item.updatedDate).format(format)
            item.show = false
            return item
          })
        } else {
          this.formArray2 = []
        }
      }
    },

    handleAddConfirm() {
      if (!this.radio) {
        this.notice.warningTips('请选择分账规则')
        return
      }
      if (!this.radio2) {
        this.notice.warningTips('请选择对账规则')
        return
      }
      var params = {}
      params.outTradeNo = this.recordInfo.outTradeNo
      params.inputtedOrderCode = this.recordInfo.orderCode
      params.settleDistributeEffectRuleId = this.radio
      params.reconciliationRuleEffectRuleId = this.radio2
      // return console.log('params', params)

      this.$confirm("确定分账后,当前订单会以选择的分账规则进行分账,且不可撤回;是否确定分账?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          manualDivision(params).then(res => {
            this.notice.okTips('发起分账成功')
            this.handleClose(true)
          })
        })
        .catch((err) => {
          console.log(err)
        })
    },

    handleClose(flag) {
      this.$emit('dialogClose', flag)
    }
  }
}
</script>
<style lang="scss" scoped>
$color: #2a58ad;
.merchant-checkrecord {
  padding-left: 20px;
  padding-right: 16px;
  padding-bottom: 20px;
  .account-detail {
    // height: 400px;
    // height: calc(100vh - 200px);
    padding-right: 15px;
    overflow-y: scroll;
    overflow-x: hidden;
  }
  .sub-title {
    font-weight: 700;
    color: #333333;
    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;
    }
  }
  .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;
    }
  }
  .title {
  }
  .type {
    margin-top: 6px;
    display: flex;
    .btn {
      width: 96px;
      height: 40px;
      background: #f8f8f8;
      border-radius: 4px 4px 0 0;
      line-height: 40px;
      text-align: center;
      cursor: pointer;
    }
    .act {
      font-weight: 500;
      color: $color;
      background: #fff;
    }
  }
}
.rule-form {
  // border-bottom: 1px solid #e7eaec;
  padding: 0 20px 20px;
  margin-bottom: 20px;
  background: #ffffff;
  margin: 0 0 0 10px;
}
.rule-form .d2-drawer-item {
  font-family: PingFangSC-Regular;
  font-size: 14px;
  color: #333333;
  font-weight: 400;
  width: 25%;
  margin: 0 0 0 0;
}
.fontD {
  margin: 10px 20px 15px;
}
</style>