<template>
  <div>
    <div class="sty">
      <el-page-header @back="goBack" content="修改"> </el-page-header>
    </div>
    <br />
    <br />
    <span>返利互转单</span>
    <el-divider></el-divider>
    <!-- 筛选条件 -->
    <div>
      <el-form ref="searchForm" :model="searchForm" label-width="100px" size="small" label-position="left">
        <el-row :gutter="20">
          <el-col :xs="24" :sm="12" :lg="6">
            <el-form-item label="返利互转单号" prop="">
              <el-input disabled v-model="detailList.id" placeholder=""></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :lg="6">
            <el-form-item label="单据日期" prop="">
              <el-input disabled v-model="detailList.theTime" placeholder=""></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :lg="6">
            <el-form-item label="制单人" prop="">
              <el-input disabled v-model="detailList.createBy" placeholder=""></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :lg="6">
            <el-form-item label="经销商编号" prop="">
              <el-input disabled v-model="detailList.customerNumber" placeholder=""></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :lg="6">
            <el-form-item label="经销商名称" prop="">
              <el-input disabled v-model="detailList.customerName" placeholder=""></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :lg="6">
            <el-form-item label="备注信息" prop="">
              <el-input v-model="detailList.remark" placeholder=""></el-input>
            </el-form-item>
          </el-col>
          <el-col v-if="detailList.examineStatus == 'FAIL_ONE'" :xs="24" :sm="12" :lg="6">
            <el-form-item label="审核人" prop="">
              <el-input disabled v-model="detailList.examineBy" placeholder=""></el-input>
            </el-form-item>
          </el-col>
          <el-col v-if="detailList.examineStatus == 'FAIL_ONE'" :xs="24" :sm="12" :lg="6">
            <el-form-item label="审核日期" prop="">
              <el-input disabled v-model="detailList.examineTime" placeholder=""></el-input>
            </el-form-item>
          </el-col>
          <!-- <el-col :xs="24" :sm="12" :lg="6">
            <el-form-item label="复核人" prop="">
              <el-input placeholder="请输入"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :lg="6">
            <el-form-item label="复核日期" prop="">
              <el-input placeholder="请输入"></el-input>
            </el-form-item>
          </el-col> -->
        </el-row>
      </el-form>
    </div>
    <!-- 列表 -->
    <div class="mymain-container">
      <div class="table">
        <el-table v-loading="listLoading" :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe>
          <el-table-column label="序号" align="left" width="100" type="index" show-overflow-tooltip></el-table-column>
          <el-table-column align="left" label="返利类型" prop="customerWalletName" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="left" label="返利金额" prop="amount" min-width="160" show-overflow-tooltip>
            <template slot-scope="scope">
              <el-input v-model="scope.row.amount"></el-input>
            </template>
          </el-table-column>
          <el-table-column align="left" label="备注" prop="remark" min-width="160" show-overflow-tooltip>
            <template slot-scope="scope">
              <el-input v-model="scope.row.remark"></el-input>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <!-- <div class="diy-table-1">
      <el-row :gutter="0">
        <el-col :span="12" class="item">
          <div class="label">复核人</div>
          <div class="value">2022123233435342</div>
        </el-col>
        <el-col :span="12" class="item">
          <div class="label">复核结果</div>
          <div class="value">
            <el-radio-group>
              <el-radio :label="true">通过</el-radio>
              <el-radio :label="false">驳回</el-radio>
            </el-radio-group>
          </div>
        </el-col>
        <el-col :span="24" class="item">
          <div class="label">审批说明</div>
          <div class="value">
            <el-input placeholder="请输入内容"></el-input>
          </div>
        </el-col>
      </el-row>
    </div> -->
    <br />
    <!-- 按钮 -->
    <div class="btn-group clearfix">
      <div class="fl">
        <el-button type="primary" size="small" @click="btnFn">确定</el-button>
        <el-button type="primary" size="small" @click="resetFn">重置</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import { getTransferEdit } from "@/api/finance/change_list";
export default {
  props: {
    detailList: {
      type: Object,
      required: true,
    },
  },
  data() {
    return {
      dataList: [], // 列表数据
      searchForm: {}, //搜索表单
      listLoading: false, // 列表加载loading
    };
  },
  created() {
    this.getList();
  },
  methods: {
    //重置
    resetFn() {
      this.getList();
    },

    //数据初始化
    getList() {
      this.dataList = [
        {
          initiatorWalletRebateId: this.detailList.initiatorCustomerWalletId,
          customerWalletName: this.detailList.initiatorCustomerWalletName,
          remark: this.detailList.initiatorRemark,
          amount: -this.detailList.amount,
        },
        {
          receiverWalletRebateId: this.detailList.receiverCustomerWalletId,
          customerWalletName: this.detailList.receiverCustomerWalletName,
          remark: this.detailList.receiverRemark,
          amount: this.detailList.amount,
        },
      ];
    },
    //确定
    async btnFn() {
      console.log(this.detailList);
      let receiverWalletRebateId;
      let initiatorWalletRebateId;
      let initiatorRemark;
      let receiverRemark;
      let amount;

      initiatorWalletRebateId = this.dataList[0].initiatorWalletRebateId;
      receiverWalletRebateId = this.dataList[1].receiverWalletRebateId;
      initiatorRemark = this.dataList[0].remark;
      receiverRemark = this.dataList[1].remark;
      amount = this.dataList[1].amount;
      await getTransferEdit({
        id: this.detailList.id,
        receiverWalletRebateId,
        initiatorWalletRebateId,
        receiverRemark,
        initiatorRemark,
        amount: amount * 1,
      });
      this.$message.success("修改成功");
      this.goBack();
    },
    goBack() {
      this.$emit("refresh");
      this.$parent.showPage = 1;
    },
  },
};
</script>

<style lang="scss" scoped>
</style>
