<template>
  <div>
    <div class="sty">
      <el-page-header @back="goBack" content="审批"> </el-page-header>
    </div>
    <el-divider></el-divider>

    <h3>工程项目信息</h3>
    <el-divider></el-divider>
    <div class="diy-table-1">
      <el-row :gutter="0">
        <el-col :xs="12" :sm="8" :lg="8" class="item">
          <div class="label">工程登录编码</div>
          <div class="value">{{ detailList.refEnginRecordNo }}</div>
        </el-col>
        <el-col :xs="12" :sm="8" :lg="8" class="item">
          <div class="label">工程名称(项目名称)</div>
          <div class="value">{{ detailList.refProjectName }}</div>
        </el-col>
        <el-col :xs="12" :sm="8" :lg="8" class="item">
          <div class="label">工程编号</div>
          <div class="value">{{ detailList.refProjectNo }}</div>
        </el-col>
        <el-col :xs="24" :sm="24" :lg="8" class="item">
          <div class="label">经销商名称</div>
          <div class="value">{{ detailList.customerName }}</div>
        </el-col>
        <el-col :xs="24" :sm="24" :lg="8" class="item">
          <div class="label">经销商编码</div>
          <div class="value">{{ detailList.customerId }}</div>
        </el-col>
        <!-- <el-col :xs="24" :sm="24" :lg="8" class="item">
          <div class="label">经销商二级代码</div>
          <div class="value">{{detailList.}}</div>
        </el-col> -->
        <el-col :xs="24" :sm="24" :lg="8" class="item">
          <div class="label">工程登录类型</div>
          <div class="value">{{ detailList.refPromiseStatus }}</div>
        </el-col>
        <el-col :xs="24" :sm="24" :lg="8" class="item">
          <div class="label">联系人</div>
          <div class="value">{{ detailList.refLinkman }}</div>
        </el-col>
        <el-col :xs="24" :sm="24" :lg="8" class="item">
          <div class="label">固定电话</div>
          <div class="value">{{ detailList.refTel }}</div>
        </el-col>
        <el-col :xs="24" :sm="24" :lg="8" class="item">
          <div class="label">厂工程编码(G编码)</div>
          <div class="value">
            <el-input v-model="detailList.refFactoryNo"></el-input>
          </div>
        </el-col>
        <!-- <el-col :xs="24" :sm="24" :lg="8" class="item">
          <div class="label">押金比例</div>
          <div class="value">{{detailList.}}</div>
        </el-col> -->
        <el-col :xs="24" :sm="24" :lg="8" class="item">
          <div class="label">移动电话</div>
          <div class="value">{{ detailList.refPhone }}</div>
        </el-col>
        <el-col :xs="24" :sm="24" :lg="8" class="item">
          <div class="label">押金总额</div>
          <div class="value">{{ detailList.depositAmount }}</div>
        </el-col>
        <el-col :xs="24" :sm="24" :lg="8" class="item">
          <div class="label">工程价差总额</div>
          <div class="value">{{ detailList.depositDiffAmount }}</div>
        </el-col>
        <el-col :xs="24" :sm="24" :lg="8" class="item">
          <div class="label">使用单位</div>
          <div class="value">{{ detailList.refUseUnit }}</div>
        </el-col>
        <el-col :xs="24" :sm="24" :lg="8" class="item">
          <div class="label">寄厂日期</div>
          <div class="value">
            <el-date-picker
              class="selectStyle"
              v-model="detailList.sendFactoryDate"
              type="datetime"
              placeholder=""
              default-time="00:00:00"
              value-format="yyyy-MM-dd HH:mm:ss"
            >
            </el-date-picker>
          </div>
        </el-col>
        <!-- <el-col :xs="24" :sm="24" :lg="8" class="item">
          <div class="label">提货日期</div>
          <div class="value">{{detailList.}}</div>
        </el-col> -->
        <el-col :xs="24" :sm="24" :lg="8" class="item">
          <div class="label">安装时间</div>
          <div class="value">
            <el-date-picker
              class="selectStyle"
              v-model="detailList.installDate"
              type="datetime"
              placeholder=""
              default-time="00:00:00"
              value-format="yyyy-MM-dd HH:mm:ss"
            >
            </el-date-picker>
          </div>
        </el-col>
      </el-row>
    </div>
    <h3>货品信息</h3>
    <el-divider></el-divider>
    <!-- 列表 -->
    <div class="mymain-container">
      <div class="table">
        <el-table
          v-loading="listLoading"
          :data="detailList.items"
          element-loading-text="Loading"
          border
          fit
          highlight-current-row
          stripe
        >
          <el-table-column
            align="center"
            label="物料编码"
            prop="materialOldNumber"
            min-width="160"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            align="center"
            label="产品编码"
            prop="materialNumber"
            min-width="160"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            align="center"
            label="产品名称"
            prop="materialName"
            min-width="160"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            align="center"
            label="规格型号"
            prop="specification"
            min-width="160"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            align="center"
            label="单价"
            prop="price"
            min-width="160"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            align="center"
            label="数量"
            prop="qty"
            min-width="160"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            align="center"
            label="金额"
            prop="totalAmount"
            min-width="160"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            align="center"
            label="发货数量"
            prop="hasSendQty"
            min-width="160"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            align="center"
            label="上传资料"
            prop="dataQty"
            min-width="160"
            show-overflow-tooltip
          >
            <template slot-scope="scope">
              <el-input v-model="scope.row.dataQty"></el-input>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            label="收差金额"
            prop="diffAmount"
            min-width="160"
            show-overflow-tooltip
          >
            <template slot-scope="scope">
              <el-input v-model="scope.row.diffAmount"></el-input>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <h3>工程资料</h3>
    <el-divider></el-divider>
    <!-- 列表 -->
    <div class="mymain-container">
      <div class="table">
        <el-table
          v-loading="listLoading"
          :data="detailList.dataList"
          element-loading-text="Loading"
          border
          fit
          highlight-current-row
          stripe
        >
          <el-table-column
            align="center"
            label="资料描述"
            prop="dataDescribe"
            min-width="160"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            align="center"
            label="原文件名"
            prop="fileName"
            min-width="160"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            align="center"
            label="缩略图"
            prop="fileUrl"
            min-width="160"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            align="center"
            label="下载文件名称"
            prop="fileName"
            min-width="160"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            align="center"
            label="操作"
            min-width="160"
            show-overflow-tooltip
          >
            <template slot-scope="">
              <el-button type="text" class="textColor" slot="reference"
                >下载</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <el-divider></el-divider>
    <div class="diy-table-1">
      <el-row :gutter="0">
        <el-col :xs="12" :sm="12" :lg="12" class="item">
          <div class="label">申请人</div>
          <div class="value">{{ detailList.createBy }}</div>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="12" class="item">
          <div class="label">申请日期</div>
          <div class="value">{{ detailList.createTime }}</div>
        </el-col>
        <el-col :xs="12" :sm="24" :lg="24" class="item">
          <div class="label">申请退押金</div>
          <div class="value">{{ detailList.applyNote }}</div>
        </el-col>
      </el-row>
    </div>
    <h3>审批</h3>
    <el-divider></el-divider>
    <div class="diy-table-1">
      <el-row :gutter="0">
        <el-col :xs="12" :sm="12" :lg="12" class="item">
          <div class="label">验收人</div>
          <div class="value">{{ this.checkBy }}</div>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="12" class="item">
          <div class="label">验收日期</div>
          <div class="value">
            <el-date-picker
              class="selectStyle"
              v-model="checkDate"
              type="datetime"
              placeholder=""
              default-time="00:00:00"
              value-format="yyyy-MM-dd HH:mm:ss"
            >
            </el-date-picker>
          </div>
        </el-col>
        <el-col :xs="12" :sm="24" :lg="24" class="item">
          <div class="label">是否退押</div>
          <div class="value">
            <el-radio-group v-model="isRefundDeposit">
              <el-radio :label="true">是</el-radio>
              <el-radio :label="false">否</el-radio>
            </el-radio-group>
          </div>
        </el-col>
        <el-col :xs="12" :sm="24" :lg="24" class="item">
          <div class="label">验收说明</div>
          <div class="value">
            <el-input v-model="checkNote" 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="adoptFn"
          >审批通过</el-button
        >
        <el-button type="primary" size="small" @click="rejectFn"
          >审批驳回</el-button
        >
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import {
  getDepositManageDetail,
  getDepositManageExamine,
} from "@/api/engin_deposit/refund_list";
export default {
  props: {
    detailId: {
      type: String,
      required: true,
    },
  },
  computed: {
    ...mapGetters(["name"]),
  },
  data() {
    return {
      listLoading: false, // 列表加载loading
      dataList: [], // 列表数据
      detailList: {},
      checkBy: "",
      checkDate: null,
      isRefundDeposit: true,
      checkNote: "",
    };
  },
  created() {
    this.checkBy = this.name;
    this.getData({ id: this.detailId });
  },
  methods: {
    //审批驳回
    async rejectFn() {
      let data = {
        ...this.detailList,
        checkBy: this.checkBy,
        checkDate: this.checkDate,
        isRefundDeposit: this.isRefundDeposit,
        checkNote: this.checkNote,
        examineResult: 0,
      };
      await getDepositManageExamine(data);
    },
    //审批通过
    async adoptFn() {
      let data = {
        ...this.detailList,
        checkBy: this.checkBy,
        checkDate: this.checkDate,
        isRefundDeposit: this.isRefundDeposit,
        checkNote: this.checkNote,
        examineResult: 1,
      };
      await getDepositManageExamine(data);
    },
    async getData(data) {
      const res = await getDepositManageDetail(data);
      console.log(res);
      this.detailList = res.data;
    },
    goBack() {
      this.$parent.showSurrender = true;
    },
  },
};
</script>

<style lang="scss" scoped>
.dateStyle {
  width: 100%;
}
.label {
  width: 150px !important;
}
</style>
