<template>
  <div class="app-container" id="acceptDetail">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="90px"
    >
      <el-form-item  prop="dateRange">
          <el-date-picker
            v-model="queryParams.time"
            type="month"
            placeholder="请选择月份">
          </el-date-picker>
      </el-form-item>
      <el-form-item  prop="keyWord">
          <el-input
              v-model="queryParams.keyWord"
              placeholder="请输入关键词"
              clearable
              @keyup.enter.native="handleQuery"
              maxlength="20"
          />
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >查询</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          size="mini"
          icon="el-icon-back"
          @click="jumpList"
          >报废台账</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          >导出数据</el-button
        >
      </el-col>

    </el-row>

    <el-table
      v-loading="loading"
      :data="tableList"
      ref="multipleTable"
      row-key="partId"
    >
      <el-table-column label="序号" align="center" width="80" type="index">
      </el-table-column>
      <el-table-column label="类型名称" align="center" prop="maName" :show-overflow-tooltip="true" />
      <el-table-column label="规格型号" align="center" prop="maTypeName" :show-overflow-tooltip="true" />
      <el-table-column label="计量单位" align="center" prop="partName" :show-overflow-tooltip="true" />
      <el-table-column label="报废数量" align="center" prop="purchaseNum" :show-overflow-tooltip="true" />
      <el-table-column label="报废费用(万元)" align="center" prop="unitName" :show-overflow-tooltip="true" />
      <el-table-column label="报废类型" align="center" prop="productionTime" :show-overflow-tooltip="true" />
      <el-table-column label="损坏类型" align="center" prop="productionTime" :show-overflow-tooltip="true" />
      <el-table-column label="审核人" align="center" prop="productionTime" :show-overflow-tooltip="true" />
      <el-table-column label="审核日期" align="center" prop="productionTime" :show-overflow-tooltip="true" />
      <el-table-column label="备注" align="center" prop="status" :show-overflow-tooltip="true" />
    </el-table>
  </div>
</template>

  <script>
import { getManufacturerSelect } from "@/api/ma/supplier";
import {
  acceptInnerVerifyer,
  getPurchaseFileList,
  uploadPurchaseFile,
  } from "@/api/purchase/goodsAccept";
import { getPartType,partTypeWarehouse,partTypeReject,innerVerify } from '@/api/part/partAccept';
import { getPartTypeCheckInfo,getPartTypeFileList } from '@/api/part/partArrived';
import { downloadFile } from "@/utils/download";
import { getToken } from "@/utils/auth";
export default {
  name: "ScrapLedgerDetail",
  data() {
    return {
      Id: "",
      taskId: "",
      // 遮罩层
      loading: false,
      dialogLoading: false,
      isView: false,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      showHouse: false,
      materialModelList: [], //规格型号下拉
      supplierList: [], //厂家下拉
      ids: [],
      infos: [],
      checkList: [],
      // 总条数
      total: 0,
      //表格数据
      tableList: [],
      fixCodeList: ["否", "是"],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      rowData: {},
      fileDataList: [
        { dictLabel: "合格证", fileType: "0", name: "", url: "" },
        { dictLabel: "型式试验报告", fileType: "1", name: "", url: "" },
        { dictLabel: "出厂检测报告", fileType: "2", name: "", url: "" },
        { dictLabel: "第三方监测报告", fileType: "3", name: "", url: "" },
        { dictLabel: "其他", fileType: "4", name: "", url: "" },
      ],
      // 查询参数
      queryParams: {
        // pageNum: 1,
        // pageSize: 10,
        partId: undefined,
        supplierId: undefined,
        productionTime: undefined,
      },
      //确认弹窗
      confirmShow: false,
      taskStatus: "", //3合格、1不合格
      checkResult: "",
      verifyPass: true, //true合格、false不合格
      //图片查看弹窗
      dialogImageUrl: "",
      dialogVisible: false,
      //上传
      upload: {
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/file/upload",
      },
      fileListInfo:[],
      dialogVisibleFile: false,
    };
  },
  mounted() {
    const taskId = this.$route.query && this.$route.query.taskId;
    const Id = this.$route.query && this.$route.query.Id;
    const isView = this.$route.query && this.$route.query.isView;
    this.taskId = taskId;
    this.Id = Id;
    if (isView == "true") {
      this.isView = true;
    } else {
      this.isView = false;
    }
    this.getPartType();
    console.log(this.isView);
    this.getList();
  },
  methods: {

    // 返回列表页
    jumpList() {
      const obj = { path: "/repair/scrapLedger" };
      this.$tab.closeOpenPage(obj);
    },
    getPartType() {
      getPartType({ level: 3 }).then((response) => {
        let matModelRes = response.data;
        this.materialModelList = matModelRes.map((item) => {
          return {
            label: item.partName,
            value: item.partId,
          };
        });
      });
    },
    getSupplierList() {
      getManufacturerSelect().then((response) => {
        let arrRes = response.rows;
        this.supplierList = arrRes.map((item) => {
          return {
            label: item.supplier,
            value: item.supplierId,
          };
        });
      });
    },
    /** 查询列表 */
    getList() {
      this.loading = true;
      this.queryParams.id = this.Id;
      this.queryParams.taskId = this.taskId;
      getPartTypeCheckInfo(this.queryParams).then((response) => {
        this.tableList = response.data.partTypeCheckDetailsList;
        // this.total = response.total;
        this.loading = false;
      });
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.keyWord = null;
      this.handleQuery();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },

   
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "/material/part_arrived/exportDetails",
        { taskId: this.taskId },
        `新购到货详情_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
  <style lang="scss" scoped>
.uploadImg {
  padding-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.deviceCode {
  margin-top: 10px;
  padding-bottom: 20px;
  font-size: 18px;
}
::v-deep.el-table .fixed-width .el-button--mini {
  width: 60px !important;
  margin-bottom: 10px;
}
//隐藏图片上传框的css
::v-deep.disabled {
  .el-upload--picture-card {
    display: none;
  }
}
</style>
