Przeglądaj źródła

feat(规则管理): 新增记录计划分类和关联对象功能,支持车间和设备两种关联类型

yusheng 4 miesięcy temu
rodzic
commit
85db73fa3d

+ 137 - 8
src/views/rulesManagement/recordPlan/components/programRulesDialog.vue

@@ -39,6 +39,22 @@
           </el-form-item>
         </el-col>
 
+        <el-col :span="8">
+          <el-form-item label="记录计划分类" prop="planType">
+            <el-select
+              v-model="addForm.planType"
+              size="small"
+              style="width: 100%"
+            >
+              <el-option :value="1" label="车间检查记录"></el-option>
+              <el-option :value="2" label="生产记录"></el-option>
+              <el-option :value="3" label="注汽检查记录"></el-option>
+              <el-option :value="4" label="固废记录"></el-option>
+              <el-option :value="5" label="蒸汽质量检查记录"></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+
         <el-col :span="8">
           <el-form-item label="自动派单" prop="autoOrder">
             <el-select
@@ -152,6 +168,18 @@
             </DictSelection>
           </el-form-item>
         </el-col>
+        <el-col :span="8">
+          <el-form-item label="关联对象" prop="associatedObject">
+            <el-select
+              v-model="addForm.associatedObject"
+              size="small"
+              style="width: 100%"
+            >
+              <el-option :value="1" label="车间"></el-option>
+              <el-option :value="2" label="设备"></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
         <el-col :span="8">
           <el-form-item label="状态" prop="status">
             <el-switch
@@ -163,6 +191,7 @@
             />
           </el-form-item>
         </el-col>
+
         <el-col :span="16">
           <el-form-item label="备注" prop="remark">
             <el-input
@@ -197,21 +226,25 @@
           :label="item.ruleName"
           :name="item.ruleId"
         >
-          <header-title title="车间区域" style="margin-top: 20px">
+          <header-title
+            title="车间区域"
+            style="margin-top: 20px"
+            v-if="addForm.associatedObject == 1"
+          >
             <el-button
               type="primary"
               size="mini"
               icon="el-icon-plus"
-              @click="openWorkShops"
+              @click="openWorkShops(1)"
               >新增</el-button
             >
           </header-title>
 
           <ele-pro-table
             ref="table"
+            v-if="addForm.associatedObject == 1"
             :columns="workshopsColumns"
             :datasource="item.workshops"
-            cache-key="workshopsColumns-main-2511201143"
             :need-page="false"
           >
             <template v-slot:action="{ row }">
@@ -226,7 +259,41 @@
               </el-link>
             </template>
           </ele-pro-table>
+          <header-title
+            title="设备"
+            style="margin-top: 20px"
+            v-if="addForm.associatedObject == 2"
+          >
+            <el-button
+              type="primary"
+              size="mini"
+              icon="el-icon-plus"
+              @click="openWorkShops(2)"
+              >新增</el-button
+            >
+          </header-title>
 
+          <ele-pro-table
+            ref="table"
+            v-if="addForm.associatedObject == 2"
+            :columns="equipmentColumns"
+            :datasource="item.deviceInfo"
+            :need-page="false"
+          >
+            <template v-slot:action="{ row }">
+              <el-link
+                v-if="type != 'detail'"
+                type="danger"
+                :underline="false"
+                icon="el-icon-delete"
+                @click="
+                  item.deviceInfo.splice(item.deviceInfo.indexOf(row), 1)
+                "
+              >
+                删除
+              </el-link>
+            </template>
+          </ele-pro-table>
           <header-title title="规则明细" style="margin-top: 20px">
           </header-title>
 
@@ -567,6 +634,9 @@
     />
 
     <toolModal ref="toolModalRef" @chooseModal="chooseModal" />
+    <!-- 新增设备 -->
+    <MaterialAdd ref="productRefs" @chooseEquipment="chooseEquipment">
+    </MaterialAdd>
   </ele-modal>
 </template>
 
@@ -584,15 +654,16 @@
     recordrulesPlanConfigSaveOrUpdate
   } from '@/api/recordrules/index';
   import toolModal from '@/views/rulesManagement/releaseRules/components/toolModal.vue';
+  import MaterialAdd from '@/views/rulesManagement/components/MaterialAdd.vue';
   import { getteampage } from '@/api/workforceManagement/team';
-
   export default {
     mixins: [dictMixins, tableColumnsMixin],
     components: {
       deptSelect,
       selectReleaseRules,
       selectWorkshop,
-      toolModal
+      toolModal,
+      MaterialAdd
     },
     data() {
       const formBaseData = {
@@ -603,6 +674,8 @@
         configType: 1,
         createUserName: '',
         duration: null,
+        associatedObject: 1,
+        planType: 1,
         executeUsers: [
           // {
           //   groupId: 0,
@@ -692,6 +765,37 @@
       loginUser() {
         return this.$store.state.user?.info;
       },
+      equipmentColumns() {
+        return [
+          {
+            width: 45,
+            type: 'index',
+            columnKey: 'index',
+            align: 'center'
+          },
+          {
+            prop: 'name',
+            label: '设备名称'
+          },
+          {
+            label: '设备编号',
+            prop: 'codeNumber'
+          },
+          {
+            label: '固资编码',
+            prop: 'fixCode'
+          },
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 110,
+            align: 'center',
+            resizable: false,
+            slot: 'action',
+            fixed: 'right'
+          }
+        ];
+      },
       workshopsColumns() {
         return [
           {
@@ -959,12 +1063,24 @@
 
             // 判断 每个规则的车间区域
             for (const rule of this.addForm.children) {
-              if (rule.workshops.length == 0) {
+              if (
+                rule.workshops.length == 0 &&
+                this.addForm.associatedObject == '1'
+              ) {
                 this.$message.warning(
                   `规则【${rule.ruleName}】请至少添加一个车间区域`
                 );
                 return;
               }
+              if (
+                rule.deviceInfo.length == 0 &&
+                this.addForm.associatedObject == '2'
+              ) {
+                this.$message.warning(
+                  `规则【${rule.ruleName}】请至少添加一个设备`
+                );
+                return;
+              }
             }
 
             this.butLoading = true;
@@ -1099,6 +1215,7 @@
           details: data.details,
           children: [],
           workshops: [],
+          deviceInfo: [],
           classify: rules.classify,
           recordTemplateStyle: rules.recordTemplateStyle,
           reportWorkType: rules.reportWorkType
@@ -1109,8 +1226,20 @@
         }
       },
       // 打开选择车间弹窗
-      openWorkShops() {
-        this.$refs.selectWorkshopRef.open();
+      openWorkShops(type) {
+        if (type == 1) {
+          this.$refs.selectWorkshopRef.open();
+        } else {
+          this.$refs.productRefs.open([]);
+        }
+      },
+      chooseEquipment(data) {
+        const currentTab = this.addForm.children.find(
+          (item) => item.ruleId === this.tabsValue
+        );
+        if (currentTab) {
+          currentTab.deviceInfo = [...currentTab.deviceInfo, ...data];
+        }
       },
       confirmWorkshops(list) {
         console.log('list', list);