|
@@ -0,0 +1,427 @@
|
|
|
|
|
+<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"
|
|
|
|
|
+ :before-close="handleClose"
|
|
|
|
|
+ width="60%"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-tabs v-model="reportWorkType" type="card">
|
|
|
|
|
+ <el-tab-pane
|
|
|
|
|
+ v-for="i in tabPaneList"
|
|
|
|
|
+ :label="i.dictValue"
|
|
|
|
|
+ :name="i.dictCode"
|
|
|
|
|
+ :key="i.dictCode"
|
|
|
|
|
+ ></el-tab-pane>
|
|
|
|
|
+ </el-tabs>
|
|
|
|
|
+ <div style="margin: 10px 0"></div>
|
|
|
|
|
+ <ele-pro-table
|
|
|
|
|
+ ref="table"
|
|
|
|
|
+ :columns="bankColumns"
|
|
|
|
|
+ :datasource="datasource"
|
|
|
|
|
+ :need-page="false"
|
|
|
|
|
+ class="table_list"
|
|
|
|
|
+ row-key="id"
|
|
|
|
|
+ cache-key="user-setting-matter-2510241427"
|
|
|
|
|
+ @refresh="getMatterList"
|
|
|
|
|
+ >
|
|
|
|
|
+ <template v-slot:toolbar>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ icon="el-icon-plus"
|
|
|
|
|
+ class="ele-btn-icon"
|
|
|
|
|
+ @click="openAddMatter"
|
|
|
|
|
+ >
|
|
|
|
|
+ 新建
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 操作列 -->
|
|
|
|
|
+ <template v-slot:action="{ row }">
|
|
|
|
|
+ <el-popconfirm
|
|
|
|
|
+ class="ele-action"
|
|
|
|
|
+ title="确定要删除此事项吗?"
|
|
|
|
|
+ @confirm="delMatter(row)"
|
|
|
|
|
+ >
|
|
|
|
|
+ <template v-slot:reference>
|
|
|
|
|
+ <el-link type="danger" :underline="false" icon="el-icon-delete">
|
|
|
|
|
+ 删除
|
|
|
|
|
+ </el-link>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-popconfirm>
|
|
|
|
|
+
|
|
|
|
|
+ <el-link
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ :underline="false"
|
|
|
|
|
+ icon="el-icon-view"
|
|
|
|
|
+ @click="openEditMatter(row)"
|
|
|
|
|
+ >
|
|
|
|
|
+ 详情
|
|
|
|
|
+ </el-link>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </ele-pro-table>
|
|
|
|
|
+
|
|
|
|
|
+ <template v-slot:footer>
|
|
|
|
|
+ <el-button type="primary" @click="saveMatterList" :loading="butLoading">
|
|
|
|
|
+ 确定
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+
|
|
|
|
|
+ <el-button @click="handleClose">取消</el-button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+
|
|
|
|
|
+ <userSettingMatterAdd
|
|
|
|
|
+ ref="userSettingMatterAddRef"
|
|
|
|
|
+ @addMatter="addMatter"
|
|
|
|
|
+ @editMatter="editMatter"
|
|
|
|
|
+ />
|
|
|
|
|
+ </ele-modal>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<script>
|
|
|
|
|
+ import {
|
|
|
|
|
+ produceTaskRecordRules,
|
|
|
|
|
+ produceTaskRecordRulesBatchSave
|
|
|
|
|
+ } from '@/api/producetaskrecordrules';
|
|
|
|
|
+ import tableColumnsMixin from '@/mixins/tableColumnsMixin';
|
|
|
|
|
+ import dictMixins from '@/mixins/dictMixins';
|
|
|
|
|
+ import userSettingMatterAdd from './user-setting-matter-add.vue';
|
|
|
|
|
+ import { mapGetters } from 'vuex';
|
|
|
|
|
+ import { addMaterial } from '@/api/material/list';
|
|
|
|
|
+
|
|
|
|
|
+ export default {
|
|
|
|
|
+ name: 'UserSettingMatter',
|
|
|
|
|
+ mixins: [dictMixins, tableColumnsMixin],
|
|
|
|
|
+ components: { userSettingMatterAdd },
|
|
|
|
|
+ data() {
|
|
|
|
|
+ return {
|
|
|
|
|
+ visible: false,
|
|
|
|
|
+ // 记录规则报工类型 产前、过程、产后
|
|
|
|
|
+ reportWorkType: '1',
|
|
|
|
|
+ // 事项列表
|
|
|
|
|
+ matterList: [],
|
|
|
|
|
+ // 表格列
|
|
|
|
|
+ bankColumns: [
|
|
|
|
|
+ {
|
|
|
|
|
+ columnKey: 'index',
|
|
|
|
|
+ type: 'index',
|
|
|
|
|
+ width: 45,
|
|
|
|
|
+ align: 'center'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ prop: 'produceTaskName',
|
|
|
|
|
+ label: '工序名称',
|
|
|
|
|
+ align: 'center'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ prop: 'itemType',
|
|
|
|
|
+ label: '类型',
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ formatter: (row) => {
|
|
|
|
|
+ return this.getDictValue('记录规则事项类型', row.itemType);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ prop: 'executeMethod',
|
|
|
|
|
+ label: '配置执行方式',
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ formatter: (row) => {
|
|
|
|
|
+ return this.getDictValue('记录规则执行方式', row.executeMethod);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ prop: 'rulesName',
|
|
|
|
|
+ label: '名称',
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ formatter: (row) => {
|
|
|
|
|
+ return row.rulesName || row.itemTaskName || row.planConfigName;
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ columnKey: 'action',
|
|
|
|
|
+ label: '操作',
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ slot: 'action'
|
|
|
|
|
+ }
|
|
|
|
|
+ ],
|
|
|
|
|
+ // 配置工序数据
|
|
|
|
|
+ currentRows: [],
|
|
|
|
|
+ // 添加事项列表
|
|
|
|
|
+ addPOs: [],
|
|
|
|
|
+ deletedIds: [],
|
|
|
|
|
+ updatePOs: [],
|
|
|
|
|
+ butLoading: false,
|
|
|
|
|
+ tabList: [
|
|
|
|
|
+ {
|
|
|
|
|
+ dictValue: '生产计划',
|
|
|
|
|
+ dictCode: '1'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ dictValue: '生产订单',
|
|
|
|
|
+ dictCode: '2'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ dictValue: '生产工单',
|
|
|
|
|
+ dictCode: '3'
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ };
|
|
|
|
|
+ },
|
|
|
|
|
+ computed: {
|
|
|
|
|
+ ...mapGetters(['dict']),
|
|
|
|
|
+ // 根据报工类型过滤事项
|
|
|
|
|
+ datasource() {
|
|
|
|
|
+ return this.matterList.filter(
|
|
|
|
|
+ (item) => item.reportWorkType == this.reportWorkType
|
|
|
|
|
+ );
|
|
|
|
|
+ },
|
|
|
|
|
+ tabPaneList() {
|
|
|
|
|
+ return this.tabList;
|
|
|
|
|
+ // const list = this.dict['record_rules_report_work_type'] || [];
|
|
|
|
|
+ // // 排除过程控制
|
|
|
|
|
+ // return list.filter(
|
|
|
|
|
+ // (item) => item.dictCode != '2' && item.dictCode != '4'
|
|
|
|
|
+ // );
|
|
|
|
|
+ // return list;
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ created() {},
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ updateVisible(val) {
|
|
|
|
|
+ this.visible = val;
|
|
|
|
|
+ },
|
|
|
|
|
+ openSetting(rows) {
|
|
|
|
|
+ console.log('rows', rows);
|
|
|
|
|
+
|
|
|
|
|
+ if (Array.isArray(rows)) {
|
|
|
|
|
+ this.currentRows = rows;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.currentRows = [rows];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.visible = true;
|
|
|
|
|
+ this.getMatterList();
|
|
|
|
|
+ // if (rows.length > 1) {
|
|
|
|
|
+ // this.bankColumns.splice(1, 0, {
|
|
|
|
|
+ // prop: 'produceTaskName',
|
|
|
|
|
+ // label: '工序名称',
|
|
|
|
|
+ // align: 'center'
|
|
|
|
|
+ // });
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // this.bankColumns = this.bankColumns.filter(
|
|
|
|
|
+ // (col) => col.prop !== 'produceTaskName'
|
|
|
|
|
+ // );
|
|
|
|
|
+ // }
|
|
|
|
|
+ },
|
|
|
|
|
+ // 查询事项数据
|
|
|
|
|
+ async getMatterList() {
|
|
|
|
|
+ const { list } = await produceTaskRecordRules({
|
|
|
|
|
+ produceTaskIds: this.currentRows.map((row) => row.id),
|
|
|
|
|
+ pageNum: 1,
|
|
|
|
|
+ size: 9999,
|
|
|
|
|
+ reportWorkTypes: [1, 3]
|
|
|
|
|
+ });
|
|
|
|
|
+ console.log('list', list);
|
|
|
|
|
+ // 表格数据
|
|
|
|
|
+ this.matterList = list;
|
|
|
|
|
+ },
|
|
|
|
|
+ // 删除事项
|
|
|
|
|
+ async delMatter(row) {
|
|
|
|
|
+ if (row.isUsing) {
|
|
|
|
|
+ return this.$message.warning('事项正在使用中,无法删除');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 事项列表过滤
|
|
|
|
|
+ this.matterList = this.matterList.filter((item) => item.id !== row.id);
|
|
|
|
|
+ // 如果是临时id,直接前端删除
|
|
|
|
|
+ if (row.id.includes('tem')) {
|
|
|
|
|
+ this.addPOs = this.addPOs.filter((item) => item.id !== row.id);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.deletedIds.push(row.id);
|
|
|
|
|
+ }
|
|
|
|
|
+ // updatePOs 过滤
|
|
|
|
|
+ this.updatePOs = this.updatePOs.filter((item) => item.id !== row.id);
|
|
|
|
|
+ },
|
|
|
|
|
+ // 打开添加事项
|
|
|
|
|
+ openAddMatter() {
|
|
|
|
|
+ this.$refs.userSettingMatterAddRef.openAdd(this.reportWorkType);
|
|
|
|
|
+ },
|
|
|
|
|
+ openEditMatter(row) {
|
|
|
|
|
+ this.$refs.userSettingMatterAddRef.openEdit(row, 'details');
|
|
|
|
|
+ },
|
|
|
|
|
+ addMatter(matter) {
|
|
|
|
|
+ console.log('matter', matter);
|
|
|
|
|
+ const id = 'tem' + new Date().getTime();
|
|
|
|
|
+
|
|
|
|
|
+ const msgList = [];
|
|
|
|
|
+ const className = this.getDictValue(
|
|
|
|
|
+ '记录规则类型',
|
|
|
|
|
+ matter.recordRulesClassify
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ // 添加事项
|
|
|
|
|
+ this.currentRows.forEach((task) => {
|
|
|
|
|
+ // 判断是否存在同一分类
|
|
|
|
|
+ const exists = this.matterList
|
|
|
|
|
+ .filter((item) => item.reportWorkType == this.reportWorkType)
|
|
|
|
|
+ .some((item) => {
|
|
|
|
|
+ if (item.itemType == 1) {
|
|
|
|
|
+ return (
|
|
|
|
|
+ item.planConfigId == matter.planConfigId &&
|
|
|
|
|
+ item.produceTaskId == task.id
|
|
|
|
|
+ );
|
|
|
|
|
+ } else if (item.itemType == 2 && item.executeMethod == 2) {
|
|
|
|
|
+ return (
|
|
|
|
|
+ item.recordRulesClassify == matter.recordRulesClassify &&
|
|
|
|
|
+ item.produceTaskId == task.id
|
|
|
|
|
+ );
|
|
|
|
|
+ } else if (item.itemType == 2 && item.executeMethod == 1) {
|
|
|
|
|
+ return (
|
|
|
|
|
+ item.planConfigId == matter.planConfigId &&
|
|
|
|
|
+ item.produceTaskId == task.id
|
|
|
|
|
+ );
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return (
|
|
|
|
|
+ item.itemTaskName == matter.itemTaskName &&
|
|
|
|
|
+ item.produceTaskId == task.id
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 记录规则不能重复 计划规则 和 任务确认可以重复
|
|
|
|
|
+ if (!exists) {
|
|
|
|
|
+ this.matterList.push({
|
|
|
|
|
+ ...matter,
|
|
|
|
|
+ id: id + task.id,
|
|
|
|
|
+ produceTaskId: task.id,
|
|
|
|
|
+ produceTaskName: task.name,
|
|
|
|
|
+ reportWorkType: this.reportWorkType
|
|
|
|
|
+ });
|
|
|
|
|
+ this.addPOs.push({
|
|
|
|
|
+ ...matter,
|
|
|
|
|
+ id: id + task.id,
|
|
|
|
|
+ produceTaskId: task.id,
|
|
|
|
|
+ produceTaskName: task.name,
|
|
|
|
|
+ reportWorkType: this.reportWorkType
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ let msg = '';
|
|
|
|
|
+ if (matter.itemType == 1) {
|
|
|
|
|
+ msg = `计划规则【${matter.planConfigName}】`;
|
|
|
|
|
+ } else if (matter.itemType == 2 && matter.executeMethod == 2) {
|
|
|
|
|
+ msg = `分类规则【${className || ''}】`;
|
|
|
|
|
+ } else if (matter.itemType == 2 && matter.executeMethod == 1) {
|
|
|
|
|
+ msg = `记录计划【${matter.planConfigName}】`;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ msg = `任务确认【${matter.itemTaskName}】`;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 记录重复信息
|
|
|
|
|
+ msgList.push({ taskName: task.name, msg: msg });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ if (msgList.length > 0) {
|
|
|
|
|
+ this.$message.warning(`部分工序已存在${msgList[0].msg}`);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.handleSort();
|
|
|
|
|
+ },
|
|
|
|
|
+ editMatter(matter) {
|
|
|
|
|
+ console.log('matter', matter);
|
|
|
|
|
+ // 编辑事项
|
|
|
|
|
+ this.matterList = this.matterList.map((item) => {
|
|
|
|
|
+ if (item.id === matter.id) {
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ ...matter
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+ return item;
|
|
|
|
|
+ });
|
|
|
|
|
+ // 如果不是临时id,加入updatePOs
|
|
|
|
|
+ if (!matter.id.includes('tem')) {
|
|
|
|
|
+ // 先过滤掉之前的
|
|
|
|
|
+ this.updatePOs = this.updatePOs.filter(
|
|
|
|
|
+ (item) => item.id !== matter.id
|
|
|
|
|
+ );
|
|
|
|
|
+ this.updatePOs.push({
|
|
|
|
|
+ ...matter
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 如果是临时id,直接更新addPOs
|
|
|
|
|
+ this.addPOs = this.addPOs.map((item) => {
|
|
|
|
|
+ if (item.id === matter.id) {
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ ...matter
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+ return item;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ this.handleSort();
|
|
|
|
|
+ },
|
|
|
|
|
+ // 事项排序 根据matterList的顺序
|
|
|
|
|
+ handleSort() {
|
|
|
|
|
+ this.matterList = this.matterList.map((item, index) => {
|
|
|
|
|
+ item.sortNum = index;
|
|
|
|
|
+ return item;
|
|
|
|
|
+ });
|
|
|
|
|
+ this.addPOs = this.addPOs.map((item) => {
|
|
|
|
|
+ const matter = this.matterList.find((m) => m.id === item.id);
|
|
|
|
|
+ if (matter) {
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ sortNum: matter.sortNum
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+ return item;
|
|
|
|
|
+ });
|
|
|
|
|
+ this.updatePOs = this.updatePOs.map((item) => {
|
|
|
|
|
+ const matter = this.matterList.find((m) => m.id === item.id);
|
|
|
|
|
+ if (matter) {
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ sortNum: matter.sortNum
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+ return item;
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ // 确定保存事项
|
|
|
|
|
+ async saveMatterList() {
|
|
|
|
|
+ console.log('this.matterList', this.matterList);
|
|
|
|
|
+ try {
|
|
|
|
|
+ this.butLoading = true;
|
|
|
|
|
+
|
|
|
|
|
+ await produceTaskRecordRulesBatchSave({
|
|
|
|
|
+ addPOs: this.addPOs,
|
|
|
|
|
+ deletedIds: this.deletedIds,
|
|
|
|
|
+ updatePOs: this.updatePOs
|
|
|
|
|
+ });
|
|
|
|
|
+ this.$message.success('保存成功');
|
|
|
|
|
+ this.handleClose();
|
|
|
|
|
+ this.butLoading = false;
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ this.butLoading = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ // 关闭弹窗、清空数据
|
|
|
|
|
+ handleClose() {
|
|
|
|
|
+ this.visible = false;
|
|
|
|
|
+ this.matterList = [];
|
|
|
|
|
+ this.addPOs = [];
|
|
|
|
|
+ this.deletedIds = [];
|
|
|
|
|
+ this.updatePOs = [];
|
|
|
|
|
+ this.butLoading = false;
|
|
|
|
|
+ this.reportWorkType = '1';
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
|
|
+<style scoped></style>
|