-
admin
2024-06-06 019f1c8bac7e8986d299aff70c123dedc1747d72
jcdm-ui/src/views/main/em/inspectionPlan/machinery.vue
@@ -11,26 +11,24 @@
          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>
    <MachinerySelect ref="machinerySelect" @onSelected="onMachineryAdd"></MachinerySelect>
    <el-table v-loading="loading" :data="checkmachineryList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
    <MachinerySelect ref="machinerySelect" @onSelected="onMachineryAdd" ></MachinerySelect>
    <el-table v-loading="loading" :data="checkmachineryList" >
      <el-table-column label="设备编码" align="center" prop="equipmentCode" />
      <el-table-column label="设备名称" align="center" prop="equipmentName" />
      <el-table-column label="品牌" align="center" prop="equipmentBrand" />
      <el-table-column label="规格型号" align="center" prop="equipmentSpec" />
      <el-table-column label="备注" align="center" prop="remark" />
      <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
@@ -49,10 +47,10 @@
export default {
  name: "Checkmachinery",
  components:{MachinerySelect},
  props:{
    planId: null,
    optType: null
  },
  props:{ id: null,
          optType: null,
          planCode: null,
        },
  data() {
    return {
      // 遮罩层
@@ -70,7 +68,7 @@
      total: 0,
      // 点检设备表格数据
      checkmachineryList: [],
      // 弹出层标题
        // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
@@ -93,47 +91,44 @@
    this.getList();
  },
  methods: {
    /** 查询点检设备列表 */
    clearCheckmachineryList() {
      this.checkmachineryList = [];
    },
    deleteSelectedColumns(row) {
      const index = this.checkmachineryList.findIndex(item => item.id === row.id);
      if (index !== -1) {
        this.checkmachineryList.splice(index, 1);
      } else {
        this.$message({
          message: '未找到具有该ID的项目',
          type: 'warning'
        });
      }
      this.$emit('inSelected',this.checkmachineryList);
    },
  /** 查询点检设备列表 */
    getList() {
      this.loading = true;
      this.checkmachineryList =this.machineryList;
      listInspectionPlanArchives(this.queryParams).then(response => {
        this.checkmachineryList = response.rows;
        // this.checkmachineryList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.recordId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
    handleAdd(){
      this.$refs.machinerySelect.showFlag = true;
    },
      //设备资源选择回调
    onMachineryAdd(rows){
      if(rows !=null && rows.length >0){
         rows.forEach(row => {
            row.planId = this.planId;
           addInspectionPlanArchives(row).then(response =>{
              this.getList();
            });
         });
    onMachineryAdd(selectedRows){
      if(selectedRows !=null && selectedRows.length >0){
        this.checkmachineryList = selectedRows
      }
      this.$emit('inSelected',this.checkmachineryList);
      console.log(this.checkmachineryList)
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const recordIds = row.recordId || this.ids;
      this.$modal.confirm('是否确认删除点检设备编号为"' + recordIds + '"的数据项?').then(function() {
        return delInspectionPlanArchives(recordIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    }
  }
};
</script>