<template>
  <div>
    <el-form
      :model="maForm"
      ref="maForm"
      size="small"
      :rules="rules"
      :inline="true"
      label-width="120px"
    >
      <el-form-item label="退料单位" prop="leaseUnitId">
        <el-input
          v-model="maForm.leaseUnitId"
          placeholder="请输入退料单位"
          clearable
          maxlength="50"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
          disabled
        />
      </el-form-item>
      <el-form-item label="工程名称" prop="leaseProjectId">
        <el-input
          v-model="maForm.leaseProjectId"
          placeholder="请输入工程名称"
          clearable
          maxlength="50"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
          disabled
        />
      </el-form-item>
      <el-form-item label="维修单号" prop="leasePerson">
        <el-input
          v-model="maForm.leasePerson"
          placeholder="请输入维修单号"
          clearable
          maxlength="50"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
          disabled
        />
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handlePassAll"
          >合格</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleFailAll"
          >驳回</el-button
        >
      </el-col>
    </el-row>
    <el-table v-loading="loading" :data="equipmentList">
      <el-table-column label="序号" align="center" type="index" />
      <el-table-column
        label="类型名称"
        align="center"
        prop="maTypeName"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="规格型号"
        align="center"
        prop="typeName"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="计量单位"
        align="center"
        prop="unitName"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
      <el-table-column
        label="退料数量"
        align="center"
        prop="storageNum"
        :show-overflow-tooltip="true"
      >
      </el-table-column>
      <el-table-column
        label="已修数量"
        align="center"
        prop="preNum"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="待修数量"
        align="center"
        prop="alNum"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="管理模式"
        align="center"
        prop="alNum"
        :show-overflow-tooltip="true"
      />
      <el-table-column label="操作" align="center" width="300">
        <template slot-scope="scope">
          <el-button
            size="mini"
            style="margin-bottom: 10px"
            type="primary"
            @click="handlePass(scope.row)"
            v-if="scope.row.status != '2'"
            >通过
          </el-button>

          <el-button
            size="mini"
            type="danger"
            @click="handleFail(scope.row)"
            v-if="scope.row.status == '0'"
            >驳回
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getPurchaseCheckInfo } from "@/api/purchase/goodsArrived";
import {
  uploadPurchaseFile,
  getPurchaseFileList,
} from "@/api/purchase/goodsAccept";
import { getApplyInfo, getListProject, getListUnite } from "@/api/lease/apply";
import { getToken } from "@/utils/auth";
export default {
  name: "QueryTools",
  components: {
    // UploadImg,
  },
  props: {
    isView: {
      type: Boolean,
      default: () => {
        return false;
      },
    },
    queryTaskId: {
      type: [String, Number],
      default: () => {
        return "";
      },
    },
    queryId: {
      type: [String, Number],
      default: () => {
        return "";
      },
    },
  },
  data() {
    return {
      //任务ID
      taskId: "",
      // 遮罩层
      loading: true,
      //租赁单位
      uniteList: [],
      //租赁工程
      projectList: [],
      // 表格数据
      equipmentList: [],
      // 是否显示弹出层
      open: false,
      rowData: {},
      maForm: {
        leaseUnitId: undefined,
        leaseProjectId: undefined,
      },
    };
  },
  computed: {},
  mounted() {
    this.taskId = this.queryTaskId;
    this.id = this.queryId;
    this.projectInfoList();
    this.getTaskInfo();
  },
  methods: {
    /** 租赁单位和工程-下拉选 */
    projectInfoList() {
      getListUnite({ id: null }).then((response) => {
        this.uniteList = response.data;
      });
      getListProject({ id: null }).then((response) => {
        this.projectList = response.data;
      });
    },
    //获取任务详情-列表数据
    getTaskInfo() {
      this.loading = true;
      getApplyInfo(this.id).then((response) => {
        this.maForm = response.data.leaseApplyInfo;
        this.equipmentList = response.data.leaseApplyDetailsList;

        this.loading = false;
      });
    },
    // /** 导出按钮操作 */
    // handleExport() {
    //   this.download(
    //     "/material/purchase_check_info/exportDetails",
    //     { taskId: this.taskId },
    //     `领料申请详情_${new Date().getTime()}.xlsx`
    //   );
    // },
  },
};
</script>
<style lang="scss" scoped>
::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;
  }
}
.custom-textarea {
  width: 300px;
  height: 100px;
}
.accept-img {
  color: #409eff;

  .a-two {
    margin-left: 20px;
  }
}

.left-tip {
  font-size: 16px;
  letter-spacing: 1px;
}
</style>
