hdy
2024-03-19 c92f19bea0eab25cfc6b9ee6c338e62dde4b44da
jcdm-ui/src/views/main/em/inspectionPlan/subject.vue
@@ -11,21 +11,9 @@
          v-hasPermi="['mes:dv:checkplan:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['mes:dv:checkplan:remove']"
        >删除</el-button>
      </el-col>
    </el-row>
    <DvsubjectSelect ref="subjectSelect"  @onSelected="onSubjectSelected"></DvsubjectSelect>
    <el-table v-loading="loading" :data="checksubjectList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
    <el-table v-loading="loading" :data="checksubjectList" >
      <el-table-column label="项目编码" align="center" prop="itemsCode" />
      <el-table-column label="项目名称" align="center" prop="itemsName" />
      <el-table-column label="项目类型" align="center" prop="itemsType">
@@ -35,6 +23,16 @@
      </el-table-column>
      <el-table-column label="项目内容" align="center" width="300px" prop="itemsContent" />
      <el-table-column label="标准" align="center" width="300px" prop="standard" />
      <el-table-column label="操作" align="center" >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="danger"
            icon="el-icon-delete"
            @click="deleteSelectedColumns(scope.row)"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
@@ -98,45 +96,39 @@
    this.getList();
  },
  methods: {
    deleteSelectedColumns(row) {
      const index = this.checksubjectList.findIndex(item => item.id === row.id);
      if (index !== -1) {
        this.checksubjectList.splice(index, 1);
      } else {
        this.$message({
          message: '未找到具有该ID的项目',
          type: 'warning'
        });
      }
      this.$emit('subSelected',this.checksubjectList);
    },
    /** 查询点检项目列表 */
    getList() {
      this.loading = true;
      listInspectionPlanItems(this.queryParams).then(response => {
        this.checksubjectList = response.rows;
        // this.checksubjectList = response.rows;
        this.total = response.total;
        this.loading = false;
        // console.log(response.rows)
      });
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.recordId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
        this.$refs.subjectSelect.showFlag = true;
    },
    onSubjectSelected(rows){
        if(rows != null && rows.length >0){
            rows.forEach(row => {
                row.planId= this.planId;
              addInspectionPlanItems(row).then(response => {
                    this.getList();
                });
            });
        }
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const recordIds = row.recordId || this.ids;
      this.$modal.confirm('是否确认删除点检项目编号为"' + recordIds + '"的数据项?').then(function() {
        return delInspectionPlanItems(recordIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    onSubjectSelected(selectedRows){
      if(selectedRows !=null && selectedRows.length >0){
        this.checksubjectList = selectedRows
      }
      this.$emit('subSelected',this.checksubjectList);
      console.log(this.checksubjectList)
    },
  }