Forráskód Böngészése

记录规则修改

lucw 1 éve
szülő
commit
724e61f80d

+ 9 - 0
src/api/recordrules/index.js

@@ -107,3 +107,12 @@ export async function recordrulesGetAllUpVersionById(id) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// /main/recordrules/getById/{id} 查看详情
+export async function recordrulesGetById(id) {
+  const res = await request.get(`/main/recordrules/getById/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 223 - 0
src/components/selectProduct/ProductModal.vue

@@ -0,0 +1,223 @@
+<template>
+  <el-dialog
+    title="选择产品"
+    :visible.sync="visible"
+    :before-close="handleClose"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    append-to-body
+    width="80%"
+  >
+    <el-card shadow="never">
+      <seekPage :seekList="seekList" @search="reload" />
+      <ele-split-layout
+        width="244px"
+        allow-collapse
+        :right-style="{ overflow: 'hidden' }"
+      >
+        <div class="ele-border-lighter split-layout-right-content">
+          <AssetTree
+            ref="assetTreeRef"
+            id="9"
+            @handleNodeClick="handleNodeClick"
+          />
+        </div>
+        <!-- 表格 -->
+        <template v-slot:content>
+          <ele-pro-table
+            ref="table"
+            :columns="columns"
+            :datasource="datasource"
+            height="calc(100vh - 450px)"
+            class="dict-table"
+            :selection.sync="selection"
+            @cell-click="cellClick"
+          >
+          </ele-pro-table>
+        </template>
+      </ele-split-layout>
+    </el-card>
+    <div class="btns">
+      <el-button type="primary" size="small" @click="selected">选择</el-button>
+      <el-button size="small" @click="handleClose">关闭</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+  import AssetTree from '@/components/AssetTree';
+
+  import { getList } from '@/api/classifyManage/itemInformation';
+  export default {
+    components: { AssetTree },
+    props: {
+      // 是否 多选
+      multiple: {
+        type: Boolean,
+        default: false
+      }
+    },
+    computed: {
+      seekList() {
+        return [
+          {
+            label: '产品编码',
+            value: 'code',
+            type: 'input',
+            placeholder: '请输入'
+          },
+          {
+            label: '产品名称',
+            value: 'name',
+            type: 'input',
+            placeholder: '请输入'
+          },
+          {
+            label: '型号',
+            value: 'modelType',
+            type: 'input',
+            placeholder: '请输入'
+          }
+        ];
+      }
+    },
+    data() {
+      return {
+        visible: false,
+        // 表格列配置
+        columns: [
+          {
+            width: 45,
+            type: 'selection',
+            columnKey: 'selection',
+            align: 'center'
+          },
+          {
+            columnKey: 'index',
+            type: 'index',
+            width: 45,
+            align: 'center',
+            reserveSelection: true
+          },
+          {
+            prop: 'code',
+            label: '产品编码'
+          },
+          {
+            prop: 'name',
+            label: '产品名称',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'brandNum',
+            label: '牌号'
+          },
+          {
+            prop: 'modelType',
+            label: '型号'
+          },
+          {
+            prop: 'measuringUnit',
+            label: '计量单位'
+          },
+          {
+            prop: 'packingUnit',
+            label: '包装单位'
+          }
+        ],
+        categoryLevelId: '9',
+        // 表格选中数据
+        selection: []
+      };
+    },
+    watch: {},
+    methods: {
+      /* 表格数据源 */
+      datasource({ page, where, limit }) {
+        return getList({
+          ...where,
+          pageNum: page,
+          size: limit,
+          categoryLevelId: this.categoryLevelId,
+          isProduct: true
+        });
+      },
+      handleNodeClick(data) {
+        this.categoryLevelId = data.id;
+        this.reload();
+      },
+      /* 刷新表格 */
+      reload(where = {}) {
+        this.$refs.table.reload({ page: 1, where: where });
+      },
+      open(rows) {
+        console.log('rows', rows);
+        this.visible = true;
+        if (rows) {
+          this.selection = rows;
+          this.$nextTick(() => {
+            this.$refs.table.setSelectedRows(rows);
+          });
+        } else {
+          this.selection = [];
+          this.$nextTick(() => {
+            this.$refs.table.setSelectedRows([]);
+          });
+        }
+        console.log('this.selection', this.selection);
+      },
+      handleClose() {
+        this.visible = false;
+        this.selection = [];
+      },
+      selected() {
+        console.log('this.selection', this.selection);
+        if (!this.selection.length) {
+          return this.$message.warning('请选择产品');
+        }
+
+        if (!this.multiple && this.selection.length > 1) {
+          return this.$message.warning('只能选择一个产品');
+        }
+
+        this.$emit(
+          'changeProduct',
+          this.multiple ? this.selection : this.selection[0]
+        );
+        this.handleClose();
+      },
+      cellClick(row) {
+        console.log('cellClick', row);
+        this.selection.push(row);
+        this.$refs.table.setSelectedRows(this.selection);
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped>
+  .tree_col {
+    border: 1px solid #eee;
+    padding: 10px 0;
+    box-sizing: border-box;
+    height: 500px;
+    overflow: auto;
+  }
+  .table_col {
+    padding-left: 10px;
+    ::v-deep .el-table th.el-table__cell {
+      background: #f2f2f2;
+    }
+  }
+  .pagination {
+    text-align: right;
+    padding: 10px 0;
+  }
+  .btns {
+    text-align: center;
+    padding: 10px 0;
+  }
+  .topsearch {
+    margin-bottom: 15px;
+  }
+</style>

+ 0 - 185
src/views/rulesManagement/releaseRules/components/ProductModal.vue

@@ -1,185 +0,0 @@
-<template>
-  <el-dialog
-    title="选择产品"
-    :visible.sync="visible"
-    :before-close="handleClose"
-    :close-on-click-modal="false"
-    :close-on-press-escape="false"
-    append-to-body
-    width="80%"
-  >
-    <el-card shadow="never">
-      <ProductSearch @search="reload" />
-      <ele-split-layout
-        width="244px"
-        allow-collapse
-        :right-style="{ overflow: 'hidden' }"
-      >
-        <div class="ele-border-lighter split-layout-right-content">
-          <AssetTree
-            ref="assetTreeRef"
-            id="9"
-            @handleNodeClick="handleNodeClick"
-          />
-        </div>
-        <!-- 表格 -->
-        <template v-slot:content>
-          <ele-pro-table
-            ref="table"
-            :columns="columns"
-            :datasource="datasource"
-            height="calc(100vh - 350px)"
-            class="dict-table"
-            @cell-click="cellClick"
-          >
-            <!-- 表头工具栏 -->
-            <template v-slot:action="{ row }">
-              <el-radio class="radio" v-model="radio" :label="row.id"><i></i></el-radio>
-            </template>
-          </ele-pro-table>
-        </template>
-      </ele-split-layout>
-    </el-card>
-    <div class="btns">
-      <el-button type="primary" size="small" @click="selected">选择</el-button>
-      <el-button size="small" @click="handleClose">关闭</el-button>
-    </div>
-  </el-dialog>
-</template>
-
-<script>
- import AssetTree from '@/components/AssetTree';
- import ProductSearch from './product-search.vue'
- import { getList } from '@/api/classifyManage/itemInformation';
-export default {
-   components: { AssetTree, ProductSearch },
-  data () {
-    return {
-      visible: false,
-      // 表格列配置
-      columns: [
-        {
-          columnKey: 'index',
-          type: 'index',
-          width: 45,
-          align: 'center',
-          reserveSelection: true
-        },
-        {
-          prop: 'code',
-          label: '产品编码'
-        },
-        {
-          prop: 'name',
-          label: '产品名称',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'brandNum',
-          label: '牌号'
-        },
-        {
-          prop: 'modelType',
-          label: '型号'
-        },
-        {
-          prop: 'measuringUnit',
-          label: '计量单位'
-        },
-        {
-          prop: 'packingUnit',
-          label: '包装单位'
-        },
-        {
-          action: 'action',
-          slot: 'action',
-          align: 'center',
-          label: '选择'
-        }
-      ],
-      categoryLevelId: '9',
-      radio:null
-    }
-  },
-
-  watch: {
-
-  },
-  methods: {
-    /* 表格数据源 */
-    datasource ({ page, where, limit }) {
-      return getList({
-        ...where,
-        pageNum: page,
-        size: limit,
-        categoryLevelId: this.categoryLevelId,
-        isProduct:true
-      });
-    },
-    handleNodeClick (data) {
-      this.categoryLevelId = data.id;
-      this.reload();
-    },
-    /* 刷新表格 */
-    reload () {
-      this.$refs.table.reload();
-    },
-    open(item){
-      if(item){
-        this.current = {
-          id:item.categoryId,
-          name: item.categoryName,
-          code:item.categoryCode
-        }
-        this.radio = item.categoryId
-      }
-      this.visible = true
-    },
-
-    // 单击获取id
-    cellClick (row) {
-        this.current = row
-        this.radio = row.id
-    },
-    handleClose () {
-      this.visible = false
-      this.current = null
-      this.radio = ''
-    },
-    selected(){
-       if(!this.current){
-         return this.$message.warning('请选择工作中心')
-       }
-       this.$emit('changeProduct',this.current)
-       this.handleClose()
-    },
-  }
-}
-</script>
-
-<style lang="scss" scoped>
-.tree_col {
-  border: 1px solid #eee;
-  padding: 10px 0;
-  box-sizing: border-box;
-  height: 500px;
-  overflow: auto;
-}
-.table_col {
-  padding-left: 10px;
-  ::v-deep .el-table th.el-table__cell {
-    background: #f2f2f2;
-  }
-}
-.pagination {
-  text-align: right;
-  padding: 10px 0;
-}
-.btns {
-  text-align: center;
-  padding: 10px 0;
-}
-.topsearch{
-	margin-bottom:15px;
-}
-</style>

+ 523 - 148
src/views/rulesManagement/releaseRules/components/permitAdd.vue

@@ -8,12 +8,14 @@
     width="80%"
     :maxable="true"
     append-to-body
+    destroy-on-close
   >
     <el-form
       label-width="115px"
       :model="formData"
       :rules="formRules"
       ref="formRef"
+      v-loading="loading"
     >
       <el-row style="margin-bottom: 10px">
         <el-col :span="8">
@@ -37,7 +39,6 @@
           <el-form-item label="记录规则编码" prop="code">
             <el-input
               v-model="formData.code"
-              size="small"
               :disabled="true"
               placeholder="系统自动生成"
             ></el-input>
@@ -47,7 +48,6 @@
           <el-form-item label="记录规则版本" prop="version">
             <el-input
               :value="versionText"
-              size="small"
               disabled
               placeholder="系统自动生成"
             ></el-input>
@@ -57,11 +57,7 @@
       <el-row style="margin-bottom: 10px">
         <el-col :span="8">
           <el-form-item label="记录规则名称" prop="name">
-            <el-input
-              v-model="formData.name"
-              placeholder="请输入"
-              size="small"
-            ></el-input>
+            <el-input v-model="formData.name" placeholder="请输入"></el-input>
           </el-form-item>
         </el-col>
 
@@ -71,7 +67,6 @@
               v-model="formData.startDate"
               type="date"
               placeholder="请选择启用日期"
-              size="small"
               style="width: 100%"
             ></el-date-picker>
           </el-form-item>
@@ -83,7 +78,6 @@
               v-model="formData.stopDate"
               type="date"
               placeholder="请选择停用日期"
-              size="small"
               style="width: 100%"
             />
           </el-form-item>
@@ -93,13 +87,10 @@
             <el-input
               v-model="formData.deviceName"
               placeholder="请选择设备"
-              size="small"
               :readonly="true"
             >
               <template #append>
-                <el-button size="small" @click="selectDeviceId"
-                  >选择设备</el-button
-                >
+                <el-button @click="selectDeviceId">选择设备</el-button>
               </template>
             </el-input>
           </el-form-item>
@@ -116,6 +107,66 @@
             ></dict-selection>
           </el-form-item>
         </el-col>
+        <el-col v-if="formData.reportWorkType == 2" :span="8">
+          <el-form-item label="关联工序">
+            <el-input
+              v-model="formData.produceTaskConfigBatchSavePo.produceTaskName"
+              @click.native="openProduceTaskDialog"
+              readonly
+              placeholder="关联工序"
+            >
+            </el-input>
+          </el-form-item>
+        </el-col>
+        <el-col v-if="formData.reportWorkType == 2" :span="8">
+          <el-form-item label="是否有执行方式" label-width="130px">
+            <el-radio-group
+              v-model="formData.isExecuteMethod"
+              @change="executeMethodChange"
+            >
+              <el-radio :label="1">是</el-radio>
+              <el-radio :label="0">否</el-radio>
+            </el-radio-group>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row style="margin-bottom: 10px">
+        <el-col v-if="formData.reportWorkType == 2" :span="8">
+          <el-form-item
+            label="关联产品方式"
+            required
+            prop="relateProductMethod"
+          >
+            <el-select
+              v-model="formData.relateProductMethod"
+              placeholder="请选择关联产品方式"
+              style="width: 100%"
+            >
+              <el-option
+                v-for="item in relateProductMethodOpeions"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+
+        <el-col v-if="formData.relateProductMethod == 1" :span="8">
+          <el-form-item label="关联产品分类" required>
+            <ele-tree-select
+              multiple
+              clearable
+              :data="productCategory"
+              v-model="formData.categoryLevels"
+              placeholder="请选择关联产品分类"
+              default-expand-all
+              labelKey="name"
+              valueKey="id"
+            />
+          </el-form-item>
+        </el-col>
       </el-row>
       <el-row style="margin-bottom: 10px">
         <el-col :span="24">
@@ -123,22 +174,73 @@
             <rule-cycle
               ref="cycleMultipleRef"
               :formData="formData"
-              pageType="add"
+              :pageType="type"
             />
           </el-form-item>
         </el-col>
       </el-row>
+
+      <template v-if="formData.relateProductMethod == 2">
+        <div style="margin-bottom: 20px">
+          <header-title title="关联产品">
+            <el-button
+              size="mini"
+              type="primary"
+              icon="el-icon-plus"
+              class="ele-btn-icon"
+              @click="relateProductSelect"
+            >
+              添加产品
+            </el-button>
+          </header-title>
+
+          <ele-pro-table
+            ref="productTableRef"
+            :columns="productColumns"
+            :datasource="formData.categories"
+            :needPage="false"
+            row-key="id"
+          >
+          </ele-pro-table>
+        </div>
+      </template>
+
+      <header-title v-if="formData.isExecuteMethod" title="执行方式">
+        <el-button type="primary" @click="addExecuteMethod"
+          >添加执行方式</el-button
+        >
+      </header-title>
+
+      <div v-if="formData.isExecuteMethod" class="executeMethodlist">
+        <div
+          class="executeMethodItem"
+          v-for="i in formData.executeMethodList"
+          :key="i"
+          :class="{
+            executeMethodItemActive: i == formData.executeMethodTitle
+          }"
+          @click="formData.executeMethodTitle = i"
+        >
+          <span> {{ i }}</span>
+          <i
+            class="el-icon-error"
+            size="24"
+            @click="deleteExecuteMethod(i)"
+          ></i>
+        </div>
+      </div>
+
+      <header-title title="规则明细"></header-title>
       <ele-pro-table
         ref="table"
         :columns="bankColumns"
-        :datasource="formData.recordRulesDetailList"
+        :datasource="formData.details"
         :need-page="false"
         row-key="id"
         class="table_list"
       >
         <template v-slot:toolbar>
           <el-button
-            size="small"
             type="primary"
             icon="el-icon-plus"
             class="ele-btn-icon"
@@ -174,13 +276,13 @@
             style="cursor: pointer"
           >
             <div class="ele-cell">
-              <div @click="selectProduct(row)">
+              <div @click="selectChooseModalProduct(row)">
                 {{ row.productName ? row.productName : '请选择产品' }}
               </div>
               <i
                 v-if="row.tools.length == 0"
                 class="el-icon-arrow-down"
-                @click="selectProduct(row)"
+                @click="selectChooseModalProduct(row)"
               ></i>
               <i v-else class="el-icon-close" @click="clearProduct(row)"></i>
             </div>
@@ -332,6 +434,8 @@
 
     <toolModal ref="toolModalRef" @chooseModal="chooseModal" />
 
+    <toolModal ref="toolModalTowRef" @chooseModal="chooseModalProduct" />
+
     <MaterialAdd
       ref="deviceSelectDialog"
       selectType="single"
@@ -342,6 +446,17 @@
       ref="ProductModalRef"
       @changeProduct="changeProduct"
     ></ProductModal>
+
+    <ProductModal
+      ref="ProductModalCorrelationRef"
+      @changeProduct="changeRelateProduct"
+      multiple
+    ></ProductModal>
+
+    <processModal
+      ref="processModalRef"
+      @chooseProcess="processChooseProcess"
+    ></processModal>
   </ele-modal>
 </template>
 
@@ -361,9 +476,12 @@
     recordrulesPublish,
     recordrulesSaveAndPublish,
     recordrulesUpdateVersion,
-    recordrulesCyclePage
+    recordrulesCyclePage,
+    recordrulesGetById
   } from '@/api/recordrules/index';
-  import ProductModal from './ProductModal.vue';
+  import ProductModal from '@/components/selectProduct/ProductModal.vue';
+  import { getTreeByPid } from '@/api/classifyManage';
+  import processModal from './processModal.vue';
 
   export default {
     components: {
@@ -372,7 +490,8 @@
       Details,
       ProductModal,
       MaterialAdd,
-      toolModal
+      toolModal,
+      processModal
     },
     mixins: [dictMixins],
     computed: {
@@ -385,6 +504,12 @@
             align: 'center',
             label: '序号'
           },
+          // {
+          //   prop: 'executeMethodTitle',
+          //   label: '执行方式',
+          //   align: 'center',
+          //   minWidth: 110
+          // },
           {
             prop: 'paramType',
             label: '参数类型',
@@ -454,7 +579,8 @@
             width: 110,
             align: 'center',
             resizable: false,
-            slot: 'action'
+            slot: 'action',
+            fixed: 'right'
           }
         ];
       },
@@ -462,6 +588,42 @@
         return this.formData.version
           ? `V${this.formData.version.toFixed(1)}`
           : 'V1.0';
+      },
+      productColumns() {
+        return [
+          {
+            columnKey: 'index',
+            type: 'index',
+            width: 45,
+            align: 'center',
+            reserveSelection: true
+          },
+          {
+            prop: 'code',
+            label: '产品编码'
+          },
+          {
+            prop: 'name',
+            label: '产品名称',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'brandNum',
+            label: '牌号'
+          },
+          {
+            prop: 'modelType',
+            label: '型号'
+          },
+          {
+            prop: 'measuringUnit',
+            label: '计量单位'
+          },
+          {
+            prop: 'packingUnit',
+            label: '包装单位'
+          }
+        ];
       }
     },
     data() {
@@ -473,22 +635,7 @@
         frequencyUnit: 2,
         frequencyValue: null,
         name: '',
-        recordRulesDetailList: [
-          {
-            id: 0,
-            defaultValue: '',
-            maxValue: null,
-            minValue: null,
-            paramType: null,
-            paramValue: null,
-            remark: '',
-            symbol: null,
-            tools: [],
-            unitName: null,
-            productName: '',
-            productCode: ''
-          }
-        ],
+        details: [],
         recordRulesCycleList: [],
         startDate: null,
         stopDate: null,
@@ -496,7 +643,30 @@
         code: '',
         fromId: null,
         // 模块分类 参考字典项:record_rules_report_work_type
-        reportWorkType: '1'
+        reportWorkType: '1',
+        // 关联产品方式,0-不关联,1-关联分类,2-关联产品
+        relateProductMethod: 0,
+        // 关联 ids {categoryLevelId || productId} 根据关联类型来
+        products: [],
+        // 关联分类
+        categoryLevels: [],
+        // 关联产品
+        categories: [],
+        // 执行方式
+        isExecuteMethod: 0,
+        produceTaskConfigs: null,
+        // 关联工序
+        produceTaskConfigBatchSavePo: {
+          addPOs: [],
+          deletedIds: null,
+          produceTaskId: '',
+          produceTaskName: '',
+          updatePOs: []
+        },
+        // 执行方式列表
+        executeMethodList: [],
+        // 执行方式 活跃项
+        executeMethodTitle: ''
       };
 
       return {
@@ -543,47 +713,34 @@
         showEdit: false,
         btnLoading: false,
         currentRow: null,
-        type: ''
+        type: '',
+        relateProductMethodOpeions: [
+          { label: '不关联', value: 0 },
+          { label: '关联分类', value: 1 },
+          { label: '关联产品', value: 2 }
+        ],
+        // 产品分类
+        productCategory: [],
+        loading: false
       };
     },
     mounted() {
       this.getByCodeData();
+      this.getProductCategory();
+      console.log('this.formData 2233', this.formData);
     },
     methods: {
       open(row, type, title) {
-        this.visible = true;
         this.dialogTitle = title;
         this.type = type;
         console.log('type', type, row);
 
         if (type == 'edit' || type == 'detail') {
-          this.$util.assignObject(this.formData, row);
-
-          this.formData.startDate = new Date(row.startDate);
-          this.formData.stopDate = new Date(row.stopDate);
-          this.formData.classify = this.formData.classify + '';
-          this.formData.reportWorkType = this.formData.reportWorkType + '';
-
-          this.recordrulesDetailPage(row);
-          this.recordrulesCyclePage(row);
-
-          console.log('this.formData', this.formData, this.formData.version);
+          this.getDetils(row.id);
         }
 
         if (type == 'clone') {
-          this.$util.assignObject(this.formData, row);
-
-          this.formData.name = this.formData.name + '-副本';
-          this.formData.version += 1;
-
-          this.formData.fromId = row.id;
-          this.formData.id = null;
-          this.formData.startDate = new Date(row.startDate);
-          this.formData.stopDate = new Date(row.stopDate);
-          this.formData.classify = this.formData.classify + '';
-
-          this.recordrulesDetailPage(row);
-          this.recordrulesCyclePage(row);
+          this.getDetils(row.id);
         }
 
         if (type == 'add') {
@@ -594,6 +751,64 @@
           // 停用日期 默认为 2099-12-31
           this.formData.stopDate = new Date('2099-12-31 00:00:00');
         }
+
+        this.visible = true;
+
+        console.log('this.formData', this.formData);
+      },
+      async getDetils(id) {
+        this.loading = true;
+        try {
+          const data = await recordrulesGetById(id);
+
+          if (data.categoryLevels) {
+            data.categoryLevels = data.categoryLevels.map((i) => i.id);
+          } else {
+            data.categoryLevels = [];
+          }
+
+          data.produceTaskConfigBatchSavePo = {
+            addPOs: [],
+            deletedIds: null,
+            produceTaskId: data.produceTaskConfigs.produceTaskId,
+            produceTaskName: data.produceTaskConfigs.produceTaskName,
+            updatePOs: []
+          };
+
+          if (data.isExecuteMethod) {
+            data.executeMethodList = Object.keys(data.detailMap);
+            data.details = Object.values(data.detailMap).flat();
+            data.executeMethodTitle = data.executeMethodList[0] || '';
+          } else {
+            data.executeMethodList = [];
+            data.details = data.details || [];
+            data.executeMethodTitle = '';
+          }
+
+          this.$util.assignObject(this.formData, data);
+
+          this.$nextTick(() => {
+            this.$refs.cycleMultipleRef.setRecordRulesCycleList(
+              this.formData.recordRulesCycleList
+            );
+          });
+
+          this.formData.startDate = new Date(data.startDate);
+          this.formData.stopDate = new Date(data.stopDate);
+          this.formData.classify = this.formData.classify + '';
+          this.formData.reportWorkType = this.formData.reportWorkType + '';
+
+          if (this.type == 'clone') {
+            this.formData.name = this.formData.name + '-副本';
+            this.formData.version += 1;
+
+            this.formData.fromId = row.id;
+            this.formData.id = null;
+          }
+          this.loading = false;
+        } catch (error) {
+          this.loading = false;
+        }
       },
       async getByCodeData() {
         let res = await getByCode('record_sheet');
@@ -607,17 +822,17 @@
         this.recordSheet = list;
       },
       itemDel(index) {
-        this.formData.recordRulesDetailList.splice(index, 1);
+        this.formData.details.splice(index, 1);
       },
       /* 打开操作手册编辑款 */
       openOperationGuideDialogDialog(row, index) {
         this.$refs.operationGuideDialog.open(row, index);
       },
       handleClose() {
-        this.visible = false;
-        this.$refs['formRef'].resetFields();
         // 清空表单数据
         this.formData = JSON.parse(JSON.stringify(this.formDateBase));
+        this.$refs['formRef'].resetFields();
+        this.visible = false;
       },
       // 保存
       confirm() {
@@ -628,50 +843,34 @@
           if (!valid) {
             return false;
           }
-          if (this.formData.recordRulesDetailList.length == 0) {
+          if (this.formData.details.length == 0) {
             return this.$message.warning('至少条件一条规则项');
           }
 
           try {
-            this.btnLoading = true;
+            if (this.formData.isExecuteMethod) {
+              // 判断 formData.executeMethodList中的item 是否在details中有一条executeMethodTitle的数据
 
-            this.formData.recordRulesCycleList =
-              this.$refs.cycleMultipleRef.recordRulesCycleList
-                .map((i) => {
-                  // 根据月日时分排序计算权重排序
-                  let sortNum = 0;
-                  if (i.month) {
-                    sortNum += i.month * 60 * 24 * 30;
-                  }
-                  if (i.day) {
-                    sortNum += i.day * 60 * 24;
-                  }
-                  if (i.hour) {
-                    sortNum += i.hour * 60;
-                  }
-
-                  if (i.minute) {
-                    sortNum += i.minute * 1;
-                  }
-
-                  return { ...i, sortNum };
-                })
-                .sort((a, b) => a.sortNum - b.sortNum)
-                .map((i, index) => {
-                  return { ...i, sortNum: index + 1 };
-                });
-
-            const body = { ...this.formData };
-
-            body.startDate = this.$util.toDateString(
-              body.startDate,
-              'yyyy-MM-dd HH:mm:ss'
-            );
+              if (this.formData.executeMethodList.length == 0) {
+                return this.$message.warning(`请添加执行方式`);
+              }
 
-            body.stopDate = this.$util.toDateString(
-              body.stopDate,
-              'yyyy-MM-dd HH:mm:ss'
-            );
+              for (const item of this.formData.executeMethodList) {
+                const exists = this.formData.details.some(
+                  (detail) => detail.executeMethodTitle === item
+                );
+                if (!exists) {
+                  this.$message.warning(
+                    `请为执行方式 "${item}" 添加至少一条规则项`
+                  );
+                  return false;
+                }
+              }
+            }
+
+            this.btnLoading = true;
+
+            const body = this.formatBody();
 
             if (this.type == 'add') {
               await recordrulesSave(body);
@@ -700,49 +899,34 @@
           if (!valid) {
             return false;
           }
-          if (this.formData.recordRulesDetailList.length == 0) {
+          if (this.formData.details.length == 0) {
             return this.$message.warning('至少条件一条规则项');
           }
 
           try {
+            if (this.formData.isExecuteMethod) {
+              // 判断 formData.executeMethodList中的item 是否在details中有一条executeMethodTitle的数据
+
+              if (this.formData.executeMethodList.length == 0) {
+                return this.$message.warning(`请添加执行方式`);
+              }
+
+              for (const item of this.formData.executeMethodList) {
+                const exists = this.formData.details.some(
+                  (detail) => detail.executeMethodTitle === item
+                );
+                if (!exists) {
+                  this.$message.warning(
+                    `请为执行方式 "${item}" 添加至少一条规则项`
+                  );
+                  return false;
+                }
+              }
+            }
+
             this.btnLoading = true;
-            this.formData.recordRulesCycleList =
-              this.$refs.cycleMultipleRef.recordRulesCycleList
-                .map((i) => {
-                  // 根据月日时分排序计算权重排序
-                  let sortNum = 0;
-                  if (i.month) {
-                    sortNum += i.month * 60 * 24 * 30;
-                  }
-                  if (i.day) {
-                    sortNum += i.day * 60 * 24;
-                  }
-                  if (i.hour) {
-                    sortNum += i.hour * 60;
-                  }
-
-                  if (i.minute) {
-                    sortNum += i.minute * 1;
-                  }
-
-                  return { ...i, sortNum };
-                })
-                .sort((a, b) => a.sortNum - b.sortNum)
-                .map((i, index) => {
-                  return { ...i, sortNum: index + 1 };
-                });
-
-            const body = { ...this.formData };
-
-            body.startDate = this.$util.toDateString(
-              body.startDate,
-              'yyyy-MM-dd HH:mm:ss'
-            );
 
-            body.stopDate = this.$util.toDateString(
-              body.stopDate,
-              'yyyy-MM-dd HH:mm:ss'
-            );
+            const body = this.formatBody();
 
             await recordrulesSaveAndPublish(body);
 
@@ -756,6 +940,85 @@
           }
         });
       },
+      // 数据格式化
+      formatBody() {
+        this.formData.recordRulesCycleList =
+          this.$refs.cycleMultipleRef.recordRulesCycleList
+            .map((i) => {
+              // 根据月日时分排序计算权重排序
+              let sortNum = 0;
+              if (i.month) {
+                sortNum += i.month * 60 * 24 * 30;
+              }
+              if (i.day) {
+                sortNum += i.day * 60 * 24;
+              }
+              if (i.hour) {
+                sortNum += i.hour * 60;
+              }
+
+              if (i.minute) {
+                sortNum += i.minute * 1;
+              }
+
+              return { ...i, sortNum };
+            })
+            .sort((a, b) => a.sortNum - b.sortNum)
+            .map((i, index) => {
+              return { ...i, sortNum: index + 1 };
+            });
+        // 处理关联产品 关联分类
+        if (this.formData.relateProductMethod == 1) {
+          this.formData.products = this.formData.categoryLevels.map((i) => {
+            return {
+              categoryLevelId: i
+            };
+          });
+        } else if (this.formData.relateProductMethod == 2) {
+          this.formData.products = this.formData.categories.map((i) => {
+            return {
+              productId: i.id
+            };
+          });
+        } else {
+          this.formData.products = [];
+        }
+
+        const body = { ...this.formData };
+
+        body.startDate = this.$util.toDateString(
+          body.startDate,
+          'yyyy-MM-dd HH:mm:ss'
+        );
+
+        body.stopDate = this.$util.toDateString(
+          body.stopDate,
+          'yyyy-MM-dd HH:mm:ss'
+        );
+
+        // if (this.type == 'edit') {
+        //   body.produceTaskConfigBatchSavePo.updatePOs.push({
+        //     id: body.produceTaskConfigs[0]?.id,
+        //     executeMethod: 2,
+        //     itemType: 2,
+        //     produceTaskId: body.produceTaskConfigBatchSavePo.produceTaskId,
+        //     produceTaskName: body.produceTaskConfigBatchSavePo.produceTaskName,
+        //     reportWorkType: this.formData.reportWorkType
+        //   });
+        //   body.produceTaskConfigBatchSavePo.addPOs = [];
+        // } else {
+        //   body.produceTaskConfigBatchSavePo.addPOs.push({
+        //     executeMethod: 2,
+        //     itemType: 2,
+        //     produceTaskId: body.produceTaskConfigBatchSavePo.produceTaskId,
+        //     produceTaskName: body.produceTaskConfigBatchSavePo.produceTaskName,
+        //     reportWorkType: this.formData.reportWorkType
+        //   });
+        //   body.produceTaskConfigBatchSavePo.updatePOs = [];
+        // }
+
+        return body;
+      },
       // startDate 启用日期要大于当前时间
       validateStartDate(rule, value, callback) {
         const startDate = this.formData.startDate;
@@ -798,7 +1061,14 @@
       },
       // 添加
       addRow() {
-        this.formData.recordRulesDetailList.push({
+        if (
+          this.formData.isExecuteMethod &&
+          !this.formData.executeMethodTitle
+        ) {
+          return this.$message.warning('请先选择执行方式');
+        }
+
+        this.formData.details.push({
           id: new Date().getTime(),
           defaultValue: '',
           maxValue: null,
@@ -810,13 +1080,14 @@
           tools: [],
           unitName: null,
           productName: '',
-          productCode: ''
+          productCode: '',
+          executeMethodTitle: this.formData.executeMethodTitle
         });
       },
       deleteRow(row) {
-        const index = this.formData.recordRulesDetailList.indexOf(row);
+        const index = this.formData.details.indexOf(row);
         if (index !== -1) {
-          this.formData.recordRulesDetailList.splice(index, 1);
+          this.formData.details.splice(index, 1);
         }
       },
       handleAdd(row) {
@@ -843,7 +1114,7 @@
           size: 9999
         });
         console.log('list 数据', list);
-        this.formData.recordRulesDetailList = list;
+        this.formData.details = list;
       },
       // 清空工具
       clearTool(row) {
@@ -874,10 +1145,90 @@
         this.currentRow.productName = current.name;
         this.currentRow.productCode = current.code;
       },
+      // 选择物品 产品、物料等
+      selectChooseModalProduct(row) {
+        this.currentRow = row;
+        this.$refs.toolModalTowRef.open([], '选择物品');
+      },
+      chooseModalProduct(current) {
+        console.log('current', current);
+        this.currentRow.productName = current[0].name;
+        this.currentRow.productCode = current[0].code;
+        console.log('this.currentRow', this.currentRow);
+      },
       // 清空产品
       clearProduct(row) {
         row.productName = '';
         row.productCode = '';
+      },
+      // 关联产品
+      relateProductSelect() {
+        this.$refs.ProductModalCorrelationRef.open(this.formData.categories);
+      },
+      changeRelateProduct(array) {
+        console.log('this.formData.categories ', array);
+        this.formData.categories = array;
+      },
+      /// 获取产品分类
+      async getProductCategory() {
+        let { data } = await getTreeByPid(9);
+        console.log('产品分类', data);
+        this.productCategory = data;
+      },
+      // 选择工序
+      openProduceTaskDialog() {
+        this.$refs.processModalRef.open();
+      },
+      // 工序
+      processChooseProcess(process) {
+        console.log('选择的工序', process);
+        this.formData.produceTaskConfigBatchSavePo.produceTaskId = process.id;
+        this.formData.produceTaskConfigBatchSavePo.produceTaskName =
+          process.name;
+      },
+      // 添加执行方式
+      addExecuteMethod() {
+        this.$prompt('', '请输入执行方式', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消'
+        })
+          .then(({ value }) => {
+            if (this.formData.executeMethodList.includes(value)) {
+              return this.$message.warning('执行方式已存在!');
+            }
+            this.formData.executeMethodList.push(value);
+
+            if (this.formData.executeMethodList.length == 1) {
+              // 默认高亮
+              this.formData.executeMethodTitle = value;
+            }
+          })
+          .catch((err) => {});
+      },
+      // 删除执行方式
+      deleteExecuteMethod(item) {
+        // 如果this.formData.details总包含item 则不能删除
+        const exists = this.formData.details.some(
+          (detail) => detail.executeMethodTitle === item
+        );
+        if (exists) {
+          return this.$message.warning(
+            `执行方式 "${item}" 已被规则项使用,不能删除`
+          );
+        }
+        this.formData.executeMethodList =
+          this.formData.executeMethodList.filter((i) => i != item);
+      },
+      // 是否有执行方式改变
+      executeMethodChange() {
+        if (!this.formData.isExecuteMethod) {
+          this.formData.details = this.formData.details.map((i) => {
+            return {
+              ...i,
+              executeMethodTitle: ''
+            };
+          });
+        }
       }
     }
   };
@@ -919,4 +1270,28 @@
       }
     }
   }
+
+  .executeMethodlist {
+    display: flex;
+    flex-flow: row wrap;
+    margin-bottom: 20px;
+    gap: 20px;
+
+    .executeMethodItem {
+      border: 1px solid #333;
+      padding: 10px 10px;
+      display: flex;
+      gap: 4px;
+      align-items: center;
+      justify-content: space-between;
+      background: #fff;
+      cursor: pointer;
+
+      &Active {
+        border-color: #409eff;
+        background: #409eff;
+        color: #fff;
+      }
+    }
+  }
 </style>

+ 170 - 0
src/views/rulesManagement/releaseRules/components/processModal.vue

@@ -0,0 +1,170 @@
+<template>
+  <el-dialog
+    :title="title"
+    :visible.sync="visible"
+    :before-close="handleClose"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    append-to-body
+    width="70%"
+  >
+    <el-card shadow="never">
+      <user-search @search="reload" />
+
+      <!-- 数据表格 -->
+      <ele-pro-table
+        ref="table"
+        :columns="columns"
+        :datasource="datasource"
+        :selection.sync="selection"
+        row-key="id"
+      >
+      </ele-pro-table>
+    </el-card>
+
+    <div class="btns">
+      <el-button type="primary" size="small" @click="selected">选择</el-button>
+      <el-button size="small" @click="handleClose">关闭</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+  import producetask from '@/api/technology/production';
+  import userSearch from '@/views/technology/production/components/user-search.vue';
+  export default {
+    components: {
+      userSearch
+    },
+    props: {
+      // 支撑多选
+      multiple: {
+        type: Boolean,
+        default: false
+      }
+    },
+    data() {
+      return {
+        visible: false,
+        title: '选择工序',
+
+        // 表格列配置
+        columns: [
+          {
+            columnKey: 'selection',
+            type: 'selection',
+            width: 45,
+            align: 'center',
+            reserveSelection: true,
+            fixed: 'left'
+          },
+
+          {
+            prop: 'code',
+            label: '工序编码',
+            // sortable: 'custom',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            prop: 'name',
+            label: '工序名称',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 110
+          },
+          {
+            align: 'center',
+            prop: 'controlName',
+            label: '工序控制码',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'workCenterName',
+            label: '所属工作中心',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          }
+        ],
+
+        // 表格选中数据
+        selection: []
+      };
+    },
+
+    watch: {},
+    methods: {
+      /* 表格数据源 */
+      async datasource({ page, limit, where, order }) {
+        const res = await parameter.list({
+          ...where,
+          ...order,
+          pageNum: page,
+          size: limit
+        });
+        return res;
+      },
+
+      open(item) {
+        if (item) {
+          this.selection = item;
+          this.$nextTick(() => {
+            this.$refs.table.setSelectedRows(item);
+          });
+        } else {
+          this.selection = [];
+          this.$nextTick(() => {
+            this.$refs.table.setSelectedRows([]);
+          });
+        }
+        this.visible = true;
+      },
+
+      /* 表格数据源 */
+      async datasource({ page, limit, where, order }) {
+        const res = await producetask.list({
+          ...where,
+          ...order,
+          pageNum: page,
+          size: limit
+        });
+        return res;
+      },
+
+      /* 刷新表格 */
+      reload(where) {
+        this.$refs.table.reload({ page: 1, where: where });
+      },
+
+      handleClose() {
+        this.$refs.table.setSelectedRows([]);
+        this.selection = [];
+        this.visible = false;
+      },
+      selected() {
+        if (!this.selection.length) {
+          this.$message.warning('请选择工序');
+          return;
+        }
+        if (!this.multiple && this.selection.length > 1) {
+          return this.$message.warning('只能选择一项');
+        }
+        this.$emit(
+          'chooseProcess',
+          this.multiple ? this.selection : this.selection[0]
+        );
+        this.handleClose();
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped>
+  .btns {
+    text-align: center;
+    padding: 10px 0;
+  }
+</style>

+ 1 - 11
src/views/rulesManagement/releaseRules/components/rule-cycle.vue

@@ -347,19 +347,9 @@
         ]
       };
     },
-    watch: {
-      formData: {
-        handler(val) {
-          if (val.recordRulesCycleList) {
-            this.recordRulesCycleList = val.recordRulesCycleList;
-          }
-        }
-        // deep: true,
-        // immediate: true
-      }
-    },
     methods: {
       setRecordRulesCycleList(list) {
+        console.log('list', list);
         this.recordRulesCycleList = list;
       },
       // 巡点检周期输入数量

+ 28 - 3
src/views/rulesManagement/releaseRules/components/toolModal.vue

@@ -31,9 +31,9 @@
 
         <!-- 数据表格 -->
         <template v-slot:content>
-          <ProductSearch @search="reload" ref="searchRef" />
+          <seekPage :seekList="seekList" @search="reload" />
           <ele-pro-table
-            style="min-height: 400px"
+            height="calc(100vh - 480px)"
             ref="table"
             :columns="columns"
             :datasource="datasource"
@@ -59,6 +59,30 @@
     components: {
       ProductSearch
     },
+    computed: {
+      seekList() {
+        return [
+          {
+            label: '编码',
+            value: 'code',
+            type: 'input',
+            placeholder: '请输入'
+          },
+          {
+            label: '名称',
+            value: 'name',
+            type: 'input',
+            placeholder: '请输入'
+          },
+          {
+            label: '型号',
+            value: 'modelType',
+            type: 'input',
+            placeholder: '请输入'
+          }
+        ];
+      }
+    },
     data() {
       return {
         visible: false,
@@ -155,8 +179,9 @@
         return res;
       },
 
-      open(item) {
+      open(item, title) {
         this.processData = item || [];
+        this.title = title || '选择工具';
         this.visible = true;
 
         this.getTreeData();

+ 4 - 0
src/views/technology/production/components/user-setting-matter-process.vue

@@ -218,12 +218,14 @@
           ...matter,
           id: id,
           produceTaskId: this.currentRow.id,
+          produceTaskName: this.currentRow.name,
           reportWorkType: this.reportWorkType
         });
         this.addPOs.push({
           ...matter,
           id: id,
           produceTaskId: this.currentRow.id,
+          produceTaskName: this.currentRow.name,
           reportWorkType: this.reportWorkType
         });
         this.handleSort();
@@ -249,6 +251,7 @@
           this.updatePOs.push({
             ...matter,
             produceTaskId: this.currentRow.id,
+            produceTaskName: this.currentRow.name,
             reportWorkType: this.reportWorkType
           });
         } else {
@@ -302,6 +305,7 @@
             addPOs: this.addPOs,
             deletedIds: this.deletedIds,
             produceTaskId: this.currentRow.id,
+            produceTaskName: this.currentRow.name,
             updatePOs: this.updatePOs
           });
           this.$message.success('保存成功');

+ 4 - 0
src/views/technology/production/components/user-setting-matter.vue

@@ -219,12 +219,14 @@
           ...matter,
           id: id,
           produceTaskId: this.currentRow.id,
+          produceTaskName: this.currentRow.name,
           reportWorkType: this.reportWorkType
         });
         this.addPOs.push({
           ...matter,
           id: id,
           produceTaskId: this.currentRow.id,
+          produceTaskName: this.currentRow.name,
           reportWorkType: this.reportWorkType
         });
         this.handleSort();
@@ -250,6 +252,7 @@
           this.updatePOs.push({
             ...matter,
             produceTaskId: this.currentRow.id,
+            produceTaskName: this.currentRow.name,
             reportWorkType: this.reportWorkType
           });
         } else {
@@ -303,6 +306,7 @@
             addPOs: this.addPOs,
             deletedIds: this.deletedIds,
             produceTaskId: this.currentRow.id,
+            produceTaskName: this.currentRow.name,
             updatePOs: this.updatePOs
           });
           this.$message.success('保存成功');

+ 2 - 2
vue.config.js

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