<template>
  <div>
    <div class="sty">
      <el-page-header @back="goBack"> </el-page-header>
    </div>
    <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="searchForm.billType" 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="searchForm.code" 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="searchForm.source" 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="searchForm.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="searchForm.endTime" 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="searchForm.totalAmount" 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="searchForm.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="searchForm.createTime" 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="searchForm.examineStatus" 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="searchForm.remark" placeholder=""></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <span>明细</span>
    <el-divider></el-divider>
    <!-- 列表 -->
    <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" type="index" width="100" show-overflow-tooltip></el-table-column>
          <el-table-column align="left" label="经销商编号" prop="customerNumber" min-width="160" show-overflow-tooltip>
            <template slot-scope="scope">
              <CopyButton :copyText="scope.row.customerNumber" />
              <span>{{scope.row.customerNumber}}</span>
            </template>
          </el-table-column>
          <el-table-column align="left" label="经销商名称" prop="customerName" min-width="260" show-overflow-tooltip>
            <template slot-scope="scope">
              <CopyButton :copyText="scope.row.customerName" />
              <span>{{scope.row.customerName}}</span>
            </template>
          </el-table-column>
          <el-table-column align="left" label="*费用项目编码" prop="projectCode" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="left" label="项目费用名称" prop="projectName" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="left" label="*费用承担部门" prop="departmentId" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="left" label="*收入部门" prop="incomeDept" min-width="160" 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="invoiceType" min-width="160" show-overflow-tooltip>
            <template slot-scope="scope">
              <el-select disabled filterable v-model="scope.row.invoiceType" placeholder="请选择">
                <el-option label="普通发票" value=""> </el-option>
                <el-option label="增值税发票" value="1"> </el-option>
                <el-option label="机票" value="P"> </el-option>
                <el-option label="火车票" value="R"> </el-option>
                <el-option label="其他运输票" value="O"> </el-option>
                <el-option label="其他" value="E"> </el-option>
              </el-select>
            </template>
          </el-table-column>
          <!-- <el-table-column
            align="left"
            label="不含税金额"
            prop="afterTaxAmount"
            min-width="160"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            align="left"
            label="税额"
            prop="tax"
            min-width="160"
            show-overflow-tooltip
          ></el-table-column> -->
          <el-table-column align="right" label="总金额" prop="totalAmount" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="left" label="备注" prop="remark" min-width="160" show-overflow-tooltip></el-table-column>
        </el-table>
      </div>
    </div>

    <span>审批信息</span>
    <el-divider></el-divider>
    <div class="diy-table-1">
      <el-row :gutter="0">
        <el-col :span="12" class="item">
          <div class="label">审批人</div>
          <div class="value">{{ this.name }}</div>
        </el-col>
        <el-col :span="12" class="item">
          <div class="label">审批结果</div>
          <div class="value">
            <div class="value">
              <el-radio v-model="examineStatus" label="OK">通过</el-radio>
              <el-radio v-model="examineStatus" label="FAIL">驳回</el-radio>
            </div>
          </div>
        </el-col>
        <el-col :span="24" class="item">
          <div class="label">审批说明</div>
          <div class="value">
            <el-input v-model="examineRemark" 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="btnOK">提交审批</el-button>
        <el-button type="primary" size="small" @click="resetFn">重置</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import {
  getFinanceOtherReceDetail,
  getFinanceOtherReceExamine,
} from "@/api/finance/receivable_list";
import { mapGetters } from "vuex";
export default {
  props: {
    approvalId: {
      type: String,
      required: true,
    },
  },
  data() {
    return {
      examineRemark: "",
      examineStatus: "OK",
      dataList: [],
      listLoading: false, // 列表加载loading
      searchForm: {
        billType: "",
        code: "",
        source: "",
        theTime: "",
        endTime: "",
        totalAmount: "",
        create: "",
        createTime: "",
        examineStatus: "",
        remark: "",
      },
    };
  },
  computed: { ...mapGetters(["name"]) },
  created() {
    this.getDataList();
  },
  methods: {
    //重置
    resetFn() {
      this.examineRemark = "";
      this.examineStatus = "";
    },
    //审核
    async btnOK() {
      await getFinanceOtherReceExamine({
        id: this.approvalId,
        examineRemark: this.examineRemark,
        examineStatus: this.examineStatus,
      });
      this.$emit("updateList");
      this.$parent.showPage = 1;
      this.$message.success("审核成功");
    },
    async getDataList() {
      const res = await getFinanceOtherReceDetail({ id: this.approvalId });
      console.log(res);
      this.searchForm = {
        billType: res.data.billType,
        code: res.data.code,
        source: res.data.source,
        theTime: res.data.theTime,
        endTime: res.data.endTime,
        totalAmount: res.data.totalAmount,
        createBy: res.data.createBy,
        createTime: res.data.createTime,
        examineStatus: res.data.examineStatus == "WAIT" ? "待审核" : "",
        remark: res.data.remark,
      };
      this.dataList = res.data.items;
    },
    goBack() {
      this.$parent.showPage = 1;
    },
  },
};
</script>

<style></style>
