<template>
  <div class="app-container">

    <el-table v-loading="loading" :data="inspectinstancedetailprojectList" @selection-change="handleSelectionChange">
<!--      <el-table-column type="selection" width="55" align="center" />-->
<!--      <el-table-column label="项目信息ID" align="center" prop="instanceDetailProjectId" />-->
      <el-table-column label="巡检项目名称" align="center" prop="inspectProjectName" />
<!--      <el-table-column label="点巡检工单明细ID" align="center" prop="instanceDetailId" />-->
<!--      <el-table-column label="巡检项目ID，关联dms_base_inspect_project主键" align="center" prop="inspectProjectId" />-->
<!--      <el-table-column label="巡检结果(1正常,0异常)" align="center" prop="inspectProjectStatus" />-->
      <el-table-column label="巡检结果" align="center" prop="repairType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.inspect_project_status" :value="scope.row.inspectProjectStatus"/>
        </template>
      </el-table-column>
      <el-table-column label="巡检值" align="center" prop="inspectProjectResult" />
      <el-table-column label="巡检顺序" align="center" prop="projectStepOrder" />
      <el-table-column label="标准值" align="center" prop="standardValue" />
<!--      <el-table-column label="巡检项目属性(1定性,2定量),冗余字段" align="center" prop="inspectProjectProperty" />-->
      <el-table-column label="巡检项目属性" align="center" prop="inspectProjectProperty">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.inspect_check_project_property" :value="scope.row.inspectProjectProperty"/>
        </template>
      </el-table-column>
      <el-table-column label="上差值" align="center" prop="upLimit" />
      <el-table-column label="下差值" align="center" prop="lowLimit" />
<!--      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
<!--        <template slot-scope="scope">-->
<!--          <el-button-->
<!--            size="mini"-->
<!--            type="text"-->
<!--            icon="el-icon-edit"-->
<!--            @click="handleUpdate(scope.row)"-->
<!--            v-hasPermi="['dms:inspectinstancedetailproject:edit']"-->
<!--          >修改</el-button>-->
<!--          <el-button-->
<!--            size="mini"-->
<!--            type="text"-->
<!--            icon="el-icon-delete"-->
<!--            @click="handleDelete(scope.row)"-->
<!--            v-hasPermi="['dms:inspectinstancedetailproject:remove']"-->
<!--          >删除</el-button>-->
<!--        </template>-->
<!--      </el-table-column>-->
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改点巡检工单明细项目信息;质检检查每个项目的质检结果详情对话框 -->
<!--    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>-->
<!--      <el-form ref="form" :model="form" :rules="rules" label-width="80px">-->
<!--        <el-form-item label="点巡检工单明细ID，关联dms_inspect_instance_detail主键" prop="instanceDetailId">-->
<!--          <el-input v-model="form.instanceDetailId" placeholder="请输入点巡检工单明细ID，关联dms_inspect_instance_detail主键" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="巡检项目ID，关联dms_base_inspect_project主键" prop="inspectProjectId">-->
<!--          <el-input v-model="form.inspectProjectId" placeholder="请输入巡检项目ID，关联dms_base_inspect_project主键" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="巡检结果,具体值" prop="inspectProjectResult">-->
<!--          <el-input v-model="form.inspectProjectResult" placeholder="请输入巡检结果,具体值" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="巡检顺序" prop="projectStepOrder">-->
<!--          <el-input v-model="form.projectStepOrder" placeholder="请输入巡检顺序" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="标准值" prop="standardValue">-->
<!--          <el-input v-model="form.standardValue" placeholder="请输入标准值" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="巡检项目名称" prop="inspectProjectName">-->
<!--          <el-input v-model="form.inspectProjectName" placeholder="请输入巡检项目名称" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="巡检项目属性(1定性,2定量),冗余字段" prop="checkProjectProperty">-->
<!--          <el-input v-model="form.checkProjectProperty" placeholder="请输入巡检项目属性(1定性,2定量),冗余字段" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="上差值，检验时从检验项目复制过来的值" prop="upLimit">-->
<!--          <el-input v-model="form.upLimit" placeholder="请输入上差值，检验时从检验项目复制过来的值" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="下差值，检验时从检验项目复制过来的值" prop="lowLimit">-->
<!--          <el-input v-model="form.lowLimit" placeholder="请输入下差值，检验时从检验项目复制过来的值" />-->
<!--        </el-form-item>-->
<!--      </el-form>-->
<!--      <div slot="footer" class="dialog-footer">-->
<!--        <el-button type="primary" @click="submitForm">确 定</el-button>-->
<!--        <el-button @click="cancel">取 消</el-button>-->
<!--      </div>-->
<!--    </el-dialog>-->
  </div>
</template>

<script>
import { listInspectinstancedetailproject, getInspectinstancedetailproject, delInspectinstancedetailproject, addInspectinstancedetailproject, updateInspectinstancedetailproject ,selectDmsInspectInstanceDetailProjectByInspectInstanceId  } from "@/api/dms/inspectinstancedetailproject";

export default {
  name: "Inspectinstancedetailproject",
  dicts:['inspect_project_status','inspect_check_project_property'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 点巡检工单明细项目信息;质检检查每个项目的质检结果详情表格数据
      inspectinstancedetailprojectList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        instanceDetailId: null,
        inspectProjectId: null,
        inspectProjectStatus: null,
        inspectProjectResult: null,
        projectStepOrder: null,
        standardValue: null,
        inspectProjectName: null,
        checkProjectProperty: null,
        upLimit: null,
        lowLimit: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        instanceDetailId: [
          { required: true, message: "点巡检工单明细ID，关联dms_inspect_instance_detail主键不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    console.log(this.$route.query)
    // this.getInspectInstanceDetails();
    this.getList();
  },
  methods: {
    /** 查询点巡检工单明细项目信息;质检检查每个项目的质检结果详情列表 */
    getList() {
      this.loading = true;
      selectDmsInspectInstanceDetailProjectByInspectInstanceId(this.$route.query.inspectInstanceId,this.$route.query.lineStep).
      then(response=>{
        console.log(response)
        this.inspectinstancedetailprojectList = response.rows;
        this.total = response.total;
        this.loading = false;
      })
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        instanceDetailProjectId: null,
        instanceDetailId: null,
        inspectProjectId: null,
        inspectProjectStatus: null,
        inspectProjectResult: null,
        projectStepOrder: null,
        standardValue: null,
        inspectProjectName: null,
        checkProjectProperty: null,
        upLimit: null,
        lowLimit: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.instanceDetailProjectId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加点巡检工单明细项目信息;质检检查每个项目的质检结果详情";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const instanceDetailProjectId = row.instanceDetailProjectId || this.ids
      getInspectinstancedetailproject(instanceDetailProjectId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改点巡检工单明细项目信息;质检检查每个项目的质检结果详情";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.instanceDetailProjectId != null) {
            updateInspectinstancedetailproject(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addInspectinstancedetailproject(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const instanceDetailProjectIds = row.instanceDetailProjectId || this.ids;
      this.$modal.confirm('是否确认删除点巡检工单明细项目信息;质检检查每个项目的质检结果详情编号为"' + instanceDetailProjectIds + '"的数据项？').then(function() {
        return delInspectinstancedetailproject(instanceDetailProjectIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('dms/inspectinstancedetailproject/export', {
        ...this.queryParams
      }, `inspectinstancedetailproject_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
