|
|
@@ -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>
|