Parcourir la source

产前过程产后 事项规则改计划规则

lucw il y a 7 mois
Parent
commit
addef3045d

+ 282 - 0
src/components/selectPlanRules/selectPlanRules.vue

@@ -0,0 +1,282 @@
+<template>
+  <ele-modal
+    :visible="visible"
+    :append-to-body="true"
+    :close-on-click-modal="false"
+    custom-class="ele-dialog-form"
+    title="选择计划规则"
+    @update:visible="updateVisible"
+    :maxable="true"
+    width="90%"
+    :before-close="handleClose"
+  >
+    <el-card shadow="never" v-loading="loading">
+      <seekPage :seekList="seekList" @search="reload" :maxLength="4"></seekPage>
+      <ele-pro-table
+        ref="tableRef"
+        :columns="columns"
+        :datasource="datasource"
+        :selection.sync="selection"
+        cache-key="select-plan-rules-table-2511141448"
+      >
+        <!-- 单选列 -->
+        <template v-slot:radio="{ row }">
+          <el-radio
+            class="radio"
+            v-model="currentRowId"
+            :label="row.id"
+            @change="radioChange($event, row)"
+            ><i></i
+          ></el-radio>
+        </template>
+      </ele-pro-table>
+    </el-card>
+    <template v-slot:footer>
+      <el-button type="primary" @click="confirmSelection"> 选择 </el-button>
+
+      <el-button @click="visible = false">关闭</el-button>
+    </template>
+  </ele-modal>
+</template>
+
+<script>
+  import tabMixins from '@/mixins/tableColumnsMixin';
+  import dictMixins from '@/mixins/dictMixins';
+  import { planConfigPage } from '@/api/ruleManagement/plan.js';
+
+  export default {
+    components: {},
+    mixins: [tabMixins, dictMixins],
+    props: {
+      // 是否多选
+      multiple: {
+        type: Boolean,
+        default: false
+      },
+      // 默认 筛选条件
+      where: {
+        type: Object,
+        default: () => ({
+          // 生效
+          status: 1
+        })
+      },
+      // 1巡点检 2保养
+      ruleType: {
+        type: Number,
+        default: 1
+      }
+    },
+    computed: {
+      columns() {
+        const list = [
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            showOverflowTooltip: true,
+            fixed: 'left'
+          },
+          {
+            prop: 'code',
+            label: '计划配置单号',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            slot: 'code'
+          },
+          {
+            prop: 'name',
+            label: '计划配置名称',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          ...[
+            this.ruleType == 1
+              ? {
+                  prop: 'groupName',
+                  label: '巡点检部门',
+                  align: 'center',
+                  showOverflowTooltip: true,
+                  minWidth: 110,
+                  slot: 'groupName'
+                }
+              : {
+                  prop: 'groupName',
+                  label: '部门',
+                  align: 'center',
+                  showOverflowTooltip: true,
+                  minWidth: 110,
+                  slot: 'groupName'
+                }
+          ],
+          {
+            prop: 'categoryName',
+            label: '设备分类',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'ruleName',
+            label: '规则名称',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'autoOrder',
+            label: '自动派单',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            formatter: (_row) => {
+              let autoOrder =
+                _row.autoOrder == 1 ? '是' : _row.autoOrder == 0 ? '否' : '-';
+              return autoOrder;
+            }
+          },
+          {
+            //修改此prop名称时,请同步修改columnKey属性和下方selectType方法
+            prop: 'status',
+            label: '状态',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            formatter: (_row) => {
+              return this.getDictValue('规则状态', _row.status);
+            },
+            filters: [
+              { value: 1, text: '生效' },
+              { value: 0, text: '失效' }
+            ],
+            filterMultiple: false,
+            columnKey: 'status'
+          },
+          {
+            prop: 'createUserName',
+            label: '创建人',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'createTime',
+            label: '创建时间',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            formatter: (_row, _column, cellValue) => {
+              return this.$util.toDateString(cellValue);
+            }
+          }
+        ];
+
+        if (this.multiple) {
+          list.unshift({
+            type: 'selection',
+            width: 50,
+            align: 'center',
+            fixed: 'left'
+          });
+        } else {
+          list.unshift({
+            prop: 'radio',
+            width: 50,
+            align: 'center',
+            fixed: 'left',
+            slot: 'radio'
+          });
+        }
+
+        return list;
+      },
+      seekList() {
+        return [
+          {
+            label: '规则名称:',
+            value: 'name',
+            type: 'input',
+            placeholder: '规则名称'
+          },
+          {
+            label: '规则编码:',
+            value: 'code',
+            type: 'input',
+            placeholder: '规则编码'
+          }
+        ];
+      }
+    },
+    data() {
+      return {
+        loading: false,
+        visible: false,
+        selection: [],
+        produceTaskId: '',
+        reportWorkType: '', // 事项报工类型 产前、过程、产后
+        currentRowId: null,
+        currentRow: null
+      };
+    },
+    created() {
+      this.requestDict('事项类型');
+      this.requestDict('规则周期');
+    },
+    methods: {
+      open() {
+        this.visible = true;
+        this.reload(); // 刷新表格
+      },
+      updateVisible(val) {
+        this.visible = val;
+      },
+      /* 表格数据源 */
+      datasource({ page, limit, where }) {
+        return planConfigPage({
+          pageNum: page,
+          size: limit,
+          ...where,
+          ...this.where,
+          ruleType: this.ruleType
+        });
+      },
+      /* 刷新表格 */
+      reload(where = {}) {
+        this.$refs.tableRef?.reload({
+          page: 1, // 已发布
+          where
+        });
+      },
+      confirmSelection() {
+        if (this.multiple && this.selection.length === 0) {
+          this.$message.warning('请先选择事项');
+          return;
+        }
+
+        if (!this.multiple && !this.currentRow) {
+          this.$message.warning('请先选择事项');
+          return;
+        }
+
+        this.$emit(
+          'chooseRules',
+          this.multiple ? this.selection : this.currentRow
+        );
+        this.handleClose();
+      },
+      radioChange(_, row) {
+        this.currentRow = row;
+      },
+      handleClose() {
+        this.selection = [];
+        this.currentRowId = null;
+        this.currentRow = null;
+        this.visible = false;
+      }
+    }
+  };
+</script>

+ 42 - 34
src/views/technology/production/components/user-setting-matter-add.vue

@@ -39,26 +39,6 @@
         </DictSelection>
         </DictSelection>
       </el-form-item>
       </el-form-item>
 
 
-      <el-form-item
-        v-if="formData.itemType == '1'"
-        label="选择设备"
-        required
-        prop="deviceName"
-      >
-        <div class="mask-box" @click="selectDeviceId">
-          <el-input
-            v-model="formData.deviceName"
-            placeholder="请选择设备"
-            size="small"
-            :readonly="true"
-          >
-            <template #append>
-              <el-button size="small">选择设备</el-button>
-            </template>
-          </el-input>
-        </div>
-      </el-form-item>
-
       <el-form-item
       <el-form-item
         v-if="formData.itemType == '3'"
         v-if="formData.itemType == '3'"
         label="关联任务"
         label="关联任务"
@@ -108,14 +88,14 @@
 
 
       <el-form-item
       <el-form-item
         v-if="formData.itemType == '1'"
         v-if="formData.itemType == '1'"
-        label="关联事项规则"
+        label="关联计划规则"
         required
         required
-        prop="rulesId"
+        prop="planConfigName"
       >
       >
         <div class="mask-box" @click="selectRulesId">
         <div class="mask-box" @click="selectRulesId">
           <el-input
           <el-input
-            v-model="formData.rulesName"
-            placeholder="请选择设备有关计划规则,如保养规则,巡点检规则"
+            v-model="formData.planConfigName"
+            placeholder="请选择设备有关计划规则,巡点检规则"
             size="small"
             size="small"
             :readonly="true"
             :readonly="true"
           >
           >
@@ -140,17 +120,16 @@
       :multiple="false"
       :multiple="false"
     ></material-add>
     ></material-add>
 
 
-    <selectMatterRules
-      ref="selectMatterRulesRef"
-      @chooseRules="chooseRules"
-      :filterType="[1, 2, 5]"
-    ></selectMatterRules>
-
     <selectReleaseRules
     <selectReleaseRules
       ref="selectReleaseRulesRef"
       ref="selectReleaseRulesRef"
       @chooseRules="chooseReleaseRules"
       @chooseRules="chooseReleaseRules"
       :notProduceTaskConfig="notProduceTaskConfig"
       :notProduceTaskConfig="notProduceTaskConfig"
     ></selectReleaseRules>
     ></selectReleaseRules>
+
+    <selectPlanRules
+      ref="selectPlanRulesRef"
+      @chooseRules="choosePlanRules"
+    ></selectPlanRules>
   </ele-modal>
   </ele-modal>
 </template>
 </template>
 
 
@@ -161,6 +140,7 @@
   import MaterialAdd from '@/views/rulesManagement/components/MaterialAdd.vue';
   import MaterialAdd from '@/views/rulesManagement/components/MaterialAdd.vue';
   import selectMatterRules from '@/components/selectMatterRules/select-matter-rules.vue';
   import selectMatterRules from '@/components/selectMatterRules/select-matter-rules.vue';
   import selectReleaseRules from '@/components/selectReleaseRules/select-release-rules.vue';
   import selectReleaseRules from '@/components/selectReleaseRules/select-release-rules.vue';
+  import selectPlanRules from '@/components/selectPlanRules/selectPlanRules.vue';
 
 
   export default {
   export default {
     name: 'UserSettingMatter',
     name: 'UserSettingMatter',
@@ -176,7 +156,8 @@
     components: {
     components: {
       MaterialAdd,
       MaterialAdd,
       selectMatterRules,
       selectMatterRules,
-      selectReleaseRules
+      selectReleaseRules,
+      selectPlanRules
     },
     },
     data() {
     data() {
       const formBaseData = {
       const formBaseData = {
@@ -202,7 +183,9 @@
         itemTaskName: '',
         itemTaskName: '',
         // 是否执行中
         // 是否执行中
         isUsing: 0,
         isUsing: 0,
-        recordRulesClassify: '' // 记录规则分类
+        recordRulesClassify: '', // 记录规则分类
+        planConfigId: null, // 计划配置id
+        planConfigName: '' // 计划配置名称
       };
       };
 
 
       return {
       return {
@@ -232,6 +215,14 @@
             },
             },
             { required: true, message: '请选择关联事项规则', trigger: 'blur' }
             { required: true, message: '请选择关联事项规则', trigger: 'blur' }
           ],
           ],
+          planConfigName: [
+            {
+              required: true,
+              message: '请选择关联计划规则',
+              trigger: 'change'
+            },
+            { required: true, message: '请选择关联计划规则', trigger: 'blur' }
+          ],
           itemTaskName: [
           itemTaskName: [
             {
             {
               required: true,
               required: true,
@@ -260,6 +251,8 @@
         this.formData.executeMethod = this.formData.itemType;
         this.formData.executeMethod = this.formData.itemType;
         this.formData.rulesId = null;
         this.formData.rulesId = null;
         this.formData.rulesName = '';
         this.formData.rulesName = '';
+        this.formData.planConfigId = null;
+        this.formData.planConfigName = '';
 
 
         this.$nextTick(() => {
         this.$nextTick(() => {
           this.$refs.formRef.clearValidate();
           this.$refs.formRef.clearValidate();
@@ -306,12 +299,12 @@
         this.formData.deviceId = data?.id || null;
         this.formData.deviceId = data?.id || null;
         this.formData.deviceName = data?.name || '';
         this.formData.deviceName = data?.name || '';
       },
       },
-      // 去选择事项规则
+      // 去选择计划规则
       selectRulesId() {
       selectRulesId() {
         if (this.type == 'details') {
         if (this.type == 'details') {
           return;
           return;
         }
         }
-        this.$refs.selectMatterRulesRef.open();
+        this.$refs.selectPlanRulesRef.open();
       },
       },
       confirm() {
       confirm() {
         console.log('this.formData', this.formData);
         console.log('this.formData', this.formData);
@@ -360,10 +353,25 @@
       // 选择记录规则
       // 选择记录规则
       chooseReleaseRules(rules) {
       chooseReleaseRules(rules) {
         console.log('rules', rules);
         console.log('rules', rules);
+
         this.ruleInfo = rules;
         this.ruleInfo = rules;
         this.formData.rulesId = rules.id || null;
         this.formData.rulesId = rules.id || null;
         this.formData.rulesName = rules.name || '';
         this.formData.rulesName = rules.name || '';
         this.formData.recordRulesClassify = rules.classify;
         this.formData.recordRulesClassify = rules.classify;
+      },
+      // 打开选择计划规则
+      openSelectPlanRules() {
+        if (this.type == 'details') {
+          return;
+        }
+        this.$refs.selectPlanRulesRef.open();
+      },
+      // 选择计划规则
+      choosePlanRules(rules) {
+        console.log('rules', rules);
+        this.ruleInfo = rules;
+        this.formData.planConfigId = rules.id || null;
+        this.formData.planConfigName = rules.name || '';
       }
       }
     }
     }
   };
   };

+ 30 - 2
src/views/technology/production/components/user-setting-matter-process.vue

@@ -165,7 +165,7 @@
             label: '名称',
             label: '名称',
             align: 'center',
             align: 'center',
             formatter: (row) => {
             formatter: (row) => {
-              return row.rulesName || row.itemTaskName;
+              return row.rulesName || row.itemTaskName || row.planConfigName;
             }
             }
           },
           },
           {
           {
@@ -343,7 +343,21 @@
         this.handleSort();
         this.handleSort();
       },
       },
       // 校验事项是否重复
       // 校验事项是否重复
-      validateMatter(matter, rules, currentId) {
+      validateMatter(matter, rules, currentId = '') {
+        // 计划规则
+        if (matter.itemType == '1') {
+          const exists = this.matterList
+            .filter((i) => i.id !== currentId)
+            .some((i) => i.planConfigId == matter.planConfigId);
+
+          if (exists) {
+            this.$message.warning(
+              `计划规则“${matter.planConfigName}”已存在,请勿重复添加`
+            );
+            return false;
+          }
+        }
+
         if (matter.itemType == '2') {
         if (matter.itemType == '2') {
           const any = this.matterList
           const any = this.matterList
             .filter((i) => i.id !== currentId)
             .filter((i) => i.id !== currentId)
@@ -396,6 +410,20 @@
             return false;
             return false;
           }
           }
         }
         }
+
+        if (matter.itemType == '3') {
+          const exists = this.matterList
+            .filter((i) => i.id !== currentId)
+            .some((i) => i.itemTaskName == matter.itemTaskName);
+
+          if (exists) {
+            this.$message.warning(
+              `任务确认“${matter.itemTaskName}”已存在,请勿重复添加`
+            );
+            return false;
+          }
+        }
+
         return true;
         return true;
       },
       },
       // 事项排序 根据matterList的顺序
       // 事项排序 根据matterList的顺序

+ 30 - 8
src/views/technology/production/components/user-setting-matter.vue

@@ -138,7 +138,7 @@
             label: '名称',
             label: '名称',
             align: 'center',
             align: 'center',
             formatter: (row) => {
             formatter: (row) => {
-              return row.rulesName || row.itemTaskName;
+              return row.rulesName || row.itemTaskName || row.planConfigName;
             }
             }
           },
           },
           {
           {
@@ -253,12 +253,26 @@
           // 判断是否存在同一分类
           // 判断是否存在同一分类
           const exists = this.matterList
           const exists = this.matterList
             .filter((item) => item.reportWorkType == this.reportWorkType)
             .filter((item) => item.reportWorkType == this.reportWorkType)
-            .some(
-              (item) =>
-                item.recordRulesClassify == matter.recordRulesClassify &&
-                task.id == item.produceTaskId
-            );
+            .some((item) => {
+              if (item.itemType == 1) {
+                return (
+                  item.planConfigId == matter.planConfigId &&
+                  item.produceTaskId == task.id
+                );
+              } else if (item.itemType == 2) {
+                return (
+                  item.recordRulesClassify == matter.recordRulesClassify &&
+                  item.produceTaskId == task.id
+                );
+              } else {
+                return (
+                  item.itemTaskName == matter.itemTaskName &&
+                  item.produceTaskId == task.id
+                );
+              }
+            });
 
 
+          // 记录规则不能重复 计划规则 和 任务确认可以重复
           if (!exists) {
           if (!exists) {
             this.matterList.push({
             this.matterList.push({
               ...matter,
               ...matter,
@@ -275,13 +289,21 @@
               reportWorkType: this.reportWorkType
               reportWorkType: this.reportWorkType
             });
             });
           } else {
           } else {
+            let msg = '';
+            if (matter.itemType == 1) {
+              msg = `计划规则【${matter.planConfigName}】`;
+            } else if (matter.itemType == 2) {
+              msg = `分类规则【${className}】`;
+            } else {
+              msg = `任务确认【${matter.itemTaskName}】`;
+            }
             // 记录重复信息
             // 记录重复信息
-            msgList.push({ taskName: task.name });
+            msgList.push({ taskName: task.name, msg: msg });
           }
           }
         });
         });
 
 
         if (msgList.length > 0) {
         if (msgList.length > 0) {
-          this.$message.warning(`部分工序已存在该分类规则:${className}`);
+          this.$message.warning(`部分工序已存在${msgList[0].msg}`);
         }
         }
 
 
         this.handleSort();
         this.handleSort();

+ 2 - 2
vue.config.js

@@ -43,8 +43,8 @@ module.exports = {
         // target: 'http://192.168.1.116:18086',
         // target: 'http://192.168.1.116:18086',
         // target: 'http://192.168.1.251:18086',
         // target: 'http://192.168.1.251:18086',
 
 
-        target: 'http://192.168.1.11:18086', // 开发
-        // target: 'http://192.168.1.116:18086', // 赵沙金
+        // target: 'http://192.168.1.11:18086', // 开发
+        target: 'http://192.168.1.116:18086', // 赵沙金
 
 
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
         pathRewrite: {
         pathRewrite: {