| | |
| | | <script setup> |
| | | import {computed, reactive, ref} from "vue"; |
| | | import {computed, nextTick, reactive, ref} from "vue"; |
| | | import {useI18n} from "vue-i18n"; |
| | | import deepClone from "@/utils/deepClone" |
| | | import {Search} from "@element-plus/icons-vue"; |
| | |
| | | code: 'openProject', // 打开工程 |
| | | initialState: ['10', '20', '100', '200'], // |
| | | targetState: null, |
| | | successMsg: '已打开工程!', |
| | | successMsg: '已打开!', |
| | | checkMessage: '当前工程状态不符合条件,请确认工程状态后再操作!', |
| | | requiresRow: true, |
| | | openFile: async ({row}) => { |
| | |
| | | actionFunction: async ({row}) => { |
| | | const projectNumber = row.projectNumber; |
| | | emit('switch-dialog', projectNumber); |
| | | } |
| | | } |
| | | }, |
| | | { |
| | | code: 'undoCompute', |
| | |
| | | return; |
| | | } else { |
| | | if (config.code === 'openProject') { |
| | | config.openFile({row}); |
| | | ElMessage.success(config.successMsg); |
| | | }else |
| | | if (config.code === 'compute') { |
| | | handleSameDataOperation(row).then(({isRoutesEqual}) => { |
| | | if (!isRoutesEqual) { |
| | | config.openFile({row}); |
| | | ElMessage.success(config.successMsg); |
| | | } |
| | | }); |
| | | } else if (config.code === 'compute') { |
| | | config.actionFunction({row}); |
| | | } |
| | | else { |
| | | } else { |
| | | row.state = config.targetState; |
| | | const index = produceList.value.findIndex(item => item === row); |
| | | if (index !== -1) { |
| | |
| | | } |
| | | } |
| | | }, |
| | | cellDblclick: ({ row }) => { |
| | | const menu = { code: 'openProject' }; |
| | | gridEvents.menuClick({ menu, row }); // 直接通过gridEvents对象调用menuClick |
| | | } |
| | | cellDblclick: ({row}) => { |
| | | const menu = {code: 'openProject'}; |
| | | nextTick(() => { |
| | | handleSameDataOperation(row).then(({isRoutesEqual}) => { |
| | | if (!isRoutesEqual) { |
| | | gridEvents.menuClick({menu, row}); |
| | | } |
| | | }); |
| | | }); |
| | | }, |
| | | }; |
| | | |
| | | // 公共处理函数,处理相同数据时的操作,并返回targetRoute对象(右键菜单和双击打开) |
| | | const handleSameDataOperation = async ({projectNumber, thickness, glassType}) => { |
| | | const targetRoute = { |
| | | name: 'optimizeInfo', |
| | | params: { |
| | | projectNo: projectNumber, |
| | | thickNess: String(thickness), |
| | | model: glassType |
| | | } |
| | | }; |
| | | const currentRoute = router.currentRoute.value; |
| | | console.log('当前路由信息:', currentRoute); |
| | | const isRoutesEqual = currentRoute.name === targetRoute.name && |
| | | currentRoute.params.projectNo === targetRoute.params.projectNo && |
| | | currentRoute.params.thickNess === targetRoute.params.thickNess && |
| | | currentRoute.params.model === targetRoute.params.model; |
| | | if (isRoutesEqual) { |
| | | handleConfirm(); |
| | | } |
| | | return {isRoutesEqual}; |
| | | }; |
| | | //选中相同数据时弹窗提示 |
| | | const handleConfirm = () => { |
| | | const currentRoute = router.currentRoute.value; |
| | | const projectNumber = currentRoute.params.projectNo; |
| | | ElMessageBox.confirm(`当前工程(工程号:${projectNumber})已打开,是否重新打开?`, '确认操作', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning' |
| | | }) |
| | | .then(() => { |
| | | emit('close-detail-page'); |
| | | ElMessage.success('已打开!'); |
| | | }) |
| | | .catch(() => { |
| | | ElMessage.info('已取消操作'); |
| | | }); |
| | | }; |
| | | |
| | | |
| | | // 封装发送右键菜单请求、处理响应以及错误回滚等逻辑的函数 |
| | | function rollbackStateAndReloadGrid(row, targetState) { |
| | |
| | | } |
| | | |
| | | //定义切换模拟计算弹窗 |
| | | const emit = defineEmits(['switch-dialog']); |
| | | const emit = defineEmits(['switch-dialog', 'close-detail-page']); |
| | | |
| | | //定义工程状态 |
| | | const optionVal = ref('all') |
| | |
| | | |
| | | // 获取15天前到当前时间 |
| | | function getNowTime() { |
| | | const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 15) |
| | | const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 70) |
| | | .toISOString() |
| | | .replace('T', ' ') |
| | | .slice(0, 10) //默认开始时间15天前 |