From a660db06773007b1be690e0674829c00a57aeb7b Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期三, 24 十二月 2025 16:21:23 +0800
Subject: [PATCH] 订单首页流程卡新增楼层编号显示
---
north-glass-erp/northglass-erp/src/views/pp/glassOptimize/ProjectMange.vue | 1067 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 902 insertions(+), 165 deletions(-)
diff --git a/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/ProjectMange.vue b/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/ProjectMange.vue
index 0093d12..53b9c1d 100644
--- a/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/ProjectMange.vue
+++ b/north-glass-erp/northglass-erp/src/views/pp/glassOptimize/ProjectMange.vue
@@ -1,31 +1,44 @@
<script setup>
-import {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";
-import {ElDatePicker} from "element-plus";
+import request from "@/utils/request";
+import {ElDatePicker, ElMessage, ElMessageBox} from "element-plus";
import useOrderInfoStore from "@/stores/sd/order/orderInfo";
+import useUserInfoStore from "@/stores/userInfo";
+import userInfo from "@/stores/userInfo";
+import {useRouter} from 'vue-router';
+import {defineEmits} from 'vue';
+import {changeFilterEvent, filterChanged} from "@/hook";
-const { t } = useI18n()
+
+const {t} = useI18n()
+const userStore = useUserInfoStore()
+const user = userInfo()
+const orderInfo = useOrderInfoStore()
+
+const router = useRouter();
const xGrid = ref()
const gridOptions = reactive({
- height:'100%',
+ height: '100%',
loading: false,
- border: "full",//琛ㄦ牸鍔犺竟妗�
+ border: "full",//琛ㄦ牸鍔犺竟妗�
keepSource: true,//淇濇寔婧愭暟鎹�
align: 'center',//鏂囧瓧灞呬腑
- stripe:true,//鏂戦┈绾�
- rowConfig: {isCurrent: true, isHover: true,height: 30, useKey: true},//榧犳爣绉诲姩鎴栭�夋嫨楂樹寒
+ stripe: true,//鏂戦┈绾�
+ rowConfig: {isCurrent: true, isHover: true, height: 30, useKey: true},//榧犳爣绉诲姩鎴栭�夋嫨楂樹寒
id: 'ProjectMange',
- scrollX:{enabled: true},
- scrollY:{ enabled: true ,gt:0},//寮�鍚櫄鎷熸粴鍔�
- showOverflow:true,
+ scrollX: {enabled: true},
+ scrollY: {enabled: true, gt: 0},//寮�鍚櫄鎷熸粴鍔�
+ showOverflow: true,
columnConfig: {
resizable: true,
useKey: true
},
filterConfig: { //绛涢�夐厤缃」
- remote: true
+ //remote: true
},
customConfig: {
storage: true
@@ -35,199 +48,923 @@
mode: 'row',
showStatus: true
},
- /*formConfig: {
- data: {
- width: '',
- height: '',
- quantity: ''
- },
- items: [
- { field: 'width', title: t('order.width')+':', itemRender: { name: 'VxeInput' } },
- { field: 'height', title: t('order.height')+':', itemRender: { name: 'VxeInput' } },
- { field: 'quantity', title: t('order.quantity')+':', itemRender: { name: 'VxeInput' } },
- {
- itemRender: {
- name: 'VxeButtonGroup',
- options: [
- { type: 'submit', content: t('craft.sure'), status: 'primary' },
- { type: 'reset', content: t('product.msg.reset') }
- ]
- }
- }
- ]
- },*/
- columns:[
- {type:'expand',fixed:"left",slots: { content:'content' },width: 50},
- {field: 'id', width: 100,title: '宸ョ▼鍙�',},
- {field: '',width: 50,title: '鍚嶇О',},
- {field: 'id', width: 50,title: '鑶滅郴',},
- {field: 'id', width: 50,title: '鍘氬害',},
- {field: 'id', width: 50,title: '绫诲瀷',},
- {field: 'id', width: 50,title: '鐘舵��',},
- {field: 'id', width: 50,title: '鏁伴噺',},
- {field: 'id', width: 50,title: '闈㈢Н',},
- {field: 'id', width: 100,title: '娴佺▼鍗℃暟閲�',},
- {field: 'id', width: 100,title: '鍘熺墖浣跨敤鏁�',},
- {field: 'id', width: 70,title: '娴佺▼鍗�',},
- {field: 'id', width: 100,title: '閽㈠寲瑁呰浇鐜�',},
- {field: '',width: 100,title: '閽㈠寲鐐夋暟',},
- {field: '',width: 100,title: '骞冲潎鍒囪鐜�',},
- {field: '',width: 100,title: '鏈夋晥鍒囪鐜�',},
- {field: '',width: 100,title: '灏剧墖鍒囪鐜�',},
- {field: '',width: 100,title: '鍘熸枡浣跨敤鏁�',},
- {field: '',width: 100,title: '骞冲潎鍒囪鐜�',},
- {field: '',width: 50,title: '澶囨敞',},
- {field: '',width: 100,title: '鍒涘缓浜�',},
- {field: '',width: 100,title: '鍒涘缓鏃堕棿',},
- {field: '',width: 100,title: '淇敼鏃堕棿',},
+
+ columns: [
+ {type: 'seq', title: t('basicData.Number'), width: 80},
+ {field: 'projectNumber', width: 100, title: '宸ョ▼鍙�',sortable: true,showOverflow:'ellipsis' ,filters:[{ data: '' }],slots: { filter: 'num1_filter' },filterMethod:filterChanged},
+ {field: 'projectName', width: 50, title: '鍚嶇О',},
+ {field: 'glassType', width: 50, title: '鑶滅郴',},
+ {field: 'thickness', width: 50, title: '鍘氬害',},
+ {field: 'type', width: 50, title: '绫诲瀷',},
+ {field: 'state', width: 50, title: '鐘舵��',},
+ {field: 'temperingState', width: 50, title: '閽㈠寲妯℃嫙', filters: [{data: ''}], slots: {filter: 'select_filter1'},
+ filterMethod:filterChanged, formatter: ({ cellValue }) => cellValue === 1 ? '鏄�' : (cellValue === 0 ? '鍚�' : cellValue)},
+ {field: 'optimizeState', width: 50, title: '浼樺寲璁$畻', filters: [{data: ''}], slots: {filter: 'select_filter1'},
+ filterMethod:filterChanged, formatter: ({ cellValue }) => cellValue === 1 ? '鏄�' : (cellValue === 0 ? '鍚�' : cellValue)},
+ {field: 'quantity', width: 50, title: '鏁伴噺',},
+ {field: 'area', width: 50, title: '闈㈢Н',},
+ {field: 'processCardQuantity', width: 100, title: '娴佺▼鍗℃暟閲�',},
+ {field: 'usingQuantity', width: 100, title: '鍘熺墖浣跨敤鏁�',},
+ {field: 'processCardCollection', width: 70, title: '娴佺▼鍗�',filters: [{data: ''}], slots: {filter: 'num1_filter'},filterMethod:filterChanged},
+ {field: 'temperedLoadingRate', width: 100, title: '閽㈠寲瑁呰浇鐜�',},
+ {field: 'numberOfTemperingFurnaces', width: 100, title: '閽㈠寲鐐夋暟',},
+ {field: 'averageCuttingRate', width: 100, title: '骞冲潎鍒囪鐜�',},
+ {field: 'effectiveCuttingRate', width: 100, title: '鏈夋晥鍒囪鐜�',},
+ {field: 'residueGlassCuttingRate', width: 100, title: '灏剧墖鍒囪鐜�',},
+ {field: 'amountOfOriginalGlassUsage1', width: 100, title: '鍘熸枡浣跨敤鏁�',},
+ // {field: 'averageCuttingRate1', width: 100, title: '骞冲潎鍒囪鐜�',},
+ {field: 'notes', width: 50, title: '澶囨敞',},
+ {field: 'creator', width: 100, title: '鍒涘缓浜�',},
+ {field: 'createTime', width: 100, title: '鍒涘缓鏃堕棿',},
+ {field: 'modifyTime', width: 100, title: '淇敼鏃堕棿',},
],//琛ㄥご鍙傛暟
- data:null,//琛ㄦ牸鏁版嵁
+ data: null,//琛ㄦ牸鏁版嵁
toolbarConfig: {
- buttons: [],
- slots:{
- buttons: "toolbar_buttons"
+ buttons: [
+ ],
+ import: false,
+ // export: true,
+ // print: true,
+ zoom: true,
+ custom: true
+ },
+ //鍙抽敭鑿滃崟閫夐」
+ menuConfig: {
+ body: {
+ options: [
+ [
+ {code: 'openProject', name: '鎵撳紑宸ョ▼', prefixIcon: 'vxe-icon-folder-open'},
+ {code: 'compute', name: '妯℃嫙璁$畻', prefixIcon: 'vxe-icon-subtable'},
+ //{code: 'optimizeTypography', name: '浼樺寲鎺掔増', prefixIcon: 'vxe-icon-menu'},
+ {code: 'production', name: '纭鐢熶骇', prefixIcon: 'vxe-icon-square-checked'},
+ {code: 'novisible', name: '鍙栨秷鐢熶骇', prefixIcon: 'vxe-icon-eye-fill-close'},
+ {code: 'copyproject', name: '澶嶅埢宸ョ▼', prefixIcon: 'vxe-icon-copy'},
+ {code: 'undoOptimize', name: '鎾ら攢浼樺寲', prefixIcon: 'vxe-icon-error-circle-fill'},
+ {code: 'undoCompute', name: '鎾ら攢妯℃嫙璁$畻', prefixIcon: 'vxe-icon-error-circle-fill'},
+ {code: 'InitializeProject', name: '鍒濆鍖栧伐绋�', prefixIcon: 'vxe-icon-undo'},
+ {code: 'delProject', name: '鍒犻櫎宸ョ▼', prefixIcon: 'vxe-icon-delete'},
+ {code: 'viewTempered', name: '鏌ョ湅閽㈠寲鐗堝浘', prefixIcon: 'vxe-icon-custom-column'},
+ {code: 'viewOptimize', name: '鏌ョ湅浼樺寲鐗堝浘', prefixIcon: 'vxe-icon-layout'},
+ {code: 'Export', name: '鏁版嵁瀵煎嚭', prefixIcon: 'vxe-icon-download', visible: true, disabled: false},
+ {code: 'print', name: '鎵撳嵃浼樺寲鎶ュ憡', prefixIcon: 'vxe-icon-layout'},
+ {code: 'print2', name: '鎵撳嵃浼樺寲鐗堝浘鎶ュ憡', prefixIcon: 'vxe-icon-layout'},
+
+ ],
+ []
+ ]
},
},
-
})
-const oderInfo = useOrderInfoStore()
+// 瀹氫箟鎿嶄綔閰嶇疆瀵硅薄鏁扮粍锛岄泦涓鐞嗕笉鍚屾搷浣滈�夐」瀵瑰簲鐨勫弬鏁�
+const operationConfigs = [
+ {
+ code: 'openProject', // 鎵撳紑宸ョ▼
+ initialState: ['1', '100', '200'], //
+ targetState: null,
+ successMsg: '宸叉墦寮�锛�',
+ checkMessage: '褰撳墠宸ョ▼鐘舵�佷笉绗﹀悎鏉′欢锛岃纭宸ョ▼鐘舵�佸悗鍐嶆搷浣滐紒',
+ requiresRow: true,
+ openFile: async ({row}) => {
+ orderInfo.optimizeData.optimalResults=null
+ orderInfo.optimizeData.originalFilm=null
+ const projectNumber = row.projectNumber;
+ const thickness = row.thickness;
+ const glassType = row.glassType;
+ const quantity = row.quantity;
+ const area = row.area;
+ const optimizeState = row.optimizeState;
+ await router.push({
+ name: 'optimizeInfo',
+ params: {
+ projectNo: projectNumber,
+ thickNess: thickness,
+ model: glassType,
+ quantity: quantity,
+ area: area,
+ optimizeState:optimizeState
+ }
+ });
+ }
+ },
+ {
+ code: 'compute', // 鎵撳紑妯℃嫙璁$畻鎿嶄綔
+ initialState: '1',
+ temperingState: '0',
+ targetState: null,
+ successMsg: '妯℃嫙璁$畻宸插惎鍔紒',
+ checkMessage: '褰撳墠宸ョ▼鐘舵�佷笉绗﹀悎妯℃嫙璁$畻鏉′欢锛岃纭宸ョ▼鐘舵�佸悗鍐嶆搷浣滐紒',
+ requiresRow: true,
+ actionFunction: async ({row}) => {
+ const projectNo = row.projectNumber;
+ emit('switch-dialog', row);
+ }
+ },
+ {
+ code: 'print', // 鎵撳嵃
+ initialState: '1',
+ temperingState: '0',
+ targetState: null,
+ successMsg: '妯℃嫙璁$畻宸插惎鍔紒',
+ checkMessage: '褰撳墠宸ョ▼鐘舵�佷笉绗﹀悎妯℃嫙璁$畻鏉′欢锛岃纭宸ョ▼鐘舵�佸悗鍐嶆搷浣滐紒',
+ requiresRow: true,
+ actionFunction: async ({row}) => {
+ const projectNo = row.projectNumber;
+ emit('switch-dialog-print', row);
+ }
+ },
+ {
+ code: 'print2', // 鎵撳嵃
+ initialState: '1',
+ temperingState: '0',
+ targetState: null,
+ successMsg: '妯℃嫙璁$畻宸插惎鍔紒',
+ checkMessage: '褰撳墠宸ョ▼鐘舵�佷笉绗﹀悎妯℃嫙璁$畻鏉′欢锛岃纭宸ョ▼鐘舵�佸悗鍐嶆搷浣滐紒',
+ requiresRow: true,
+ actionFunction: async ({row}) => {
+ const projectNo = row.projectNumber;
+ emit('switch-dialog-print2', row);
+ }
+ },
+ {
+ code: 'optimizeTypography',
+ initialState: ['1','100'], //
+ targetState: null,
+ successMsg: '浼樺寲鎺掔増宸插惎鍔紒',
+ checkMessage: '褰撳墠宸ョ▼鐘舵�佷笉绗﹀悎浼樺寲鎺掔増鏉′欢锛岃纭宸ョ▼鐘舵�佸悗鍐嶆搷浣滐紒',
+ requiresRow: true,
+ Typography: async ({row}) => {
+ const projectNumber = row.projectNumber;
+ const thickness = row.thickness;
+ const glassType = row.glassType;
+ const quantity = row.quantity;
+ const area = row.area;
+ const optimizeState = row.optimizeState;
+ await router.push({
+ name: 'optimizeInfo',
+ params: {
+ projectNo: projectNumber,
+ thickNess: thickness,
+ model: glassType,
+ quantity: quantity,
+ area: area,
+ optimizeState:optimizeState
+ }
+ });
+ }
+ },
+ {
+ code: 'undoCompute',
+ initialState: 1,
+ temperingState: 1,
+ targetState: 0,
+ targetStates: 0,
+ successMsg: '鎾ら攢妯℃嫙璁$畻鎴愬姛锛屾暟鎹凡鏇存柊锛�',
+ checkMessage: '褰撳墠宸ョ▼鐘舵�佷笉绗﹀悎鎾ら攢妯℃嫙璁$畻鏉′欢锛岃纭宸ョ▼鐘舵�佸悗鍐嶆搷浣滐紒',
+ requiresRow: true,
+ },
+ {
+ code: 'undoOptimize',
+ initialState: 1,
+ optimizeState: 1,
+ targetState: 0,
+ targetStates: 0,
+ successMsg: '鎾ら攢浼樺寲鎴愬姛锛屾暟鎹凡鏇存柊锛�',
+ checkMessage: '褰撳墠宸ョ▼鐘舵�佷笉绗﹀悎鎾ら攢浼樺寲鏉′欢锛岃纭宸ョ▼鐘舵�佸悗鍐嶆搷浣滐紒',
+ requiresRow: true,
+ },
+ {
+ code: 'production',
+ initialState: 1,
+ // temperingState: 1,
+ optimizeState: 1,
+ targetState: 100,
+ targetStates: 0,
+ successMsg: '璁剧疆鎴愬姛锛屽厑璁哥敓浜э紒',
+ checkMessage: '褰撳墠宸ョ▼鐘舵�佷笉绗﹀悎鍏佽鐢熶骇鏉′欢锛岃纭宸ョ▼鐘舵�佸悗鍐嶆搷浣滐紒',
+ requiresRow: true,
+ },
+ {
+ code: 'novisible',
+ initialState: 100,
+ // temperingState: 1,
+ optimizeState: 1,
+ targetState: 1,
+ targetStates: 0,
+ successMsg: '璁剧疆鎴愬姛锛岀敓浜т笉鍙锛�',
+ checkMessage: '褰撳墠宸ョ▼鐘舵�佷笉绗﹀悎鐢熶骇涓嶅彲瑙佹潯浠讹紝璇风‘璁ゅ伐绋嬬姸鎬佸悗鍐嶆搷浣滐紒',
+ requiresRow: true,
+ },
+ {
+ code: 'InitializeProject',
+ initialState: '2',
+ targetState: 1,
+ successMsg: '鍒濆鍖栧伐绋嬫垚鍔燂紒',
+ checkMessage: '褰撳墠宸ョ▼鐘舵�佷笉绗﹀悎鍒濆鍖栨潯浠讹紝璇风‘璁ゅ伐绋嬬姸鎬佸悗鍐嶆搷浣滐紒',
+ requiresRow: true,
+ },
+ {
+ code: 'delProject',
+ initialState: ['1', '100'],
+ targetState: null,
+ successMsg: '宸ョ▼鍒犻櫎鎴愬姛锛�',
+ checkMessage: '褰撳墠宸ョ▼鐘舵�佷笉绗﹀悎鍒犻櫎鏉′欢锛岃纭宸ョ▼鐘舵�佸悗鍐嶆搷浣滐紒',
+ },
+ {
+ code: 'Export', // 瀵煎嚭鏂囦欢鎿嶄綔鐨勯厤缃�
+ initialState: [],
+ targetState: null,
+ successMsg: '鏂囦欢瀵煎嚭鎴愬姛锛�',
+ gridRef: xGrid,
+ requiresRow: false,
+ },
+ {
+ code: 'viewTempered',
+ initialState: [],
+ targetState: null,
+ successMsg: '閽㈠寲鐗堝浘宸叉墦寮�锛�',
+ failureMsg: '宸ョ▼鍒犻櫎澶辫触锛岃鑱旂郴绠$悊鍛橈紒',
+ requiresRow: true,
+ },
+ {
+ code: 'viewOptimize',
+ initialState: [],
+ targetState: null,
+ successMsg: '浼樺寲鐗堝浘宸叉墦寮�锛�',
+ failureMsg: '宸ョ▼鍒犻櫎澶辫触锛岃鑱旂郴绠$悊鍛橈紒',
+ requiresRow: true,
+ }
+];
+
+function getOriginalState(targetState) {
+ // 鏍规嵁宸ョ▼鐘舵�佽繑鍥炲搴旂殑鍘熷鐘舵��
+ const stateMapping = {
+ 1: '100',
+ 100: '1'
+ };
+ return stateMapping[targetState] || targetState;
+}
+
+//鍙抽敭鑿滃崟鏉′欢鍒ゆ柇
+function checkOperationCondition(config, row) {
+ if (!config.requiresRow || !row) {
+ return false;
+ }
+ if (Array.isArray(config.initialState)) {
+ return config.initialState.includes(String(row.state));
+ }
+ return config.initialState === String(row.state);
+}
+
+// 鍙抽敭鑿滃崟鐐瑰嚮浜嬩欢
+const gridEvents = {
+ menuClick({menu, row}) {
+ const $grid = xGrid.value;
+ if ($grid) {
+ const config = operationConfigs.find(c => c.code === menu.code);
+ if (config) {
+ if (config.requiresRow && !row) {
+ ElMessage.warning('鏈�変腑宸ョ▼锛岃閫変腑宸ョ▼鍚庡啀杩涜褰撳墠鎿嶄綔锛�');
+ return;
+ }
+ if (config.code === 'Export') {
+ config.gridRef.value.exportData();
+ ElMessage.success(config.successMsg);
+ return;
+ }
+ if (config.code === 'compute') {
+ // 澧炲姞閫昏緫锛氭鏌ラ挗鍖栨ā鎷熷垪鏄惁宸茬粡鏄�"鏄�"
+ if (row.temperingState === 1) {
+ ElMessage.warning('璇ラ」鐩凡妯℃嫙璁$畻');
+ return;
+ }
+ if(row.state===1 && row.temperingState===0){
+ config.actionFunction({row});
+ }else{
+ ElMessage.warning(config.checkMessage);
+ }
+ return;
+ }
+ if (config.code === 'print') {
+ if(row.optimizeState===1 ){
+ config.actionFunction({row});
+ }else{
+ ElMessage.warning(config.checkMessage);
+ }
+ return;
+ }
+ if (config.code === 'print2') {
+ if(row.optimizeState===1 ){
+ config.actionFunction({row});
+ }else{
+ ElMessage.warning(config.checkMessage);
+ }
+ return;
+ }
+ else if (config.code === 'openProject') {
+ handleSameDataOperation(row).then(({isRoutesEqual}) => {
+ if (!isRoutesEqual) {
+ config.openFile({row});
+ ElMessage.success(config.successMsg);
+
+ }
+ });
+ return;
+ }
+ // 娣诲姞纭鎻愮ず寮圭獥锛岃闂敤鎴锋槸鍚﹁繘琛屽綋鍓嶆搷浣�
+ ElMessageBox.confirm('鏄惁杩涜褰撳墠鎿嶄綔锛�', '纭鎿嶄綔', {
+ confirmButtonText: '纭畾',
+ cancelButtonText: '鍙栨秷',
+ type: 'warning'
+ }).then(() => {
+ if (config.code === 'viewTempered') {
+ ElMessageBox.alert('褰撳墠鐐瑰嚮鐨勬槸鏌ョ湅閽㈠寲鐗堝浘鍔熻兘锛岀洰鍓嶆殏鏃朵粎鍋氭彁绀猴紝鏆傛棤瀹為檯鏌ョ湅鎿嶄綔!', '鍔熻兘鎻愮ず', {
+ confirmButtonText: '鎴戠煡閬撲簡'
+ });
+ return;
+ }
+ if (config.code === 'viewOptimize') {
+ (async () => {
+ if (!row) {
+ ElMessage.warning('璇烽�夋嫨瑕佹煡鐪嬬殑宸ョ▼');
+ return;
+ }
+
+ try {
+ await router.push({
+ name: 'optimizeInfo',
+ params: {
+ projectNo: row.projectNumber,
+ thickNess: row.thickness,
+ model: row.glassType,
+ quantity: row.quantity,
+ area: row.area,
+ optimizeState: row.optimizeState
+ },
+ query: {
+ redirect: 'optimizeControl' // 娣诲姞璺宠浆鏍囪瘑
+ }
+ });
+
+ // 鍚屾椂淇濆瓨 projectNo 鍒� localStorage 渚涘悗缁〉闈娇鐢�
+ localStorage.setItem('projectNo', row.projectNumber);
+ console.log("projectNo:", row.projectNumber);
+ } catch (error) {
+ console.error('璺敱璺宠浆澶辫触:', error);
+ ElMessage.error('椤甸潰璺宠浆澶辫触');
+ }
+ })();
+ return;
+ }
+ if (config.code === 'delProject') {
+ if (!row) {
+ ElMessage.warning(config.checkMessage);
+ return;
+ }
+ const isInitialStateMatched = config.initialState.includes(String(row.state));
+ if (!isInitialStateMatched) {
+ ElMessage.warning(config.checkMessage);
+ return;
+ }
+ deleteProject(row.projectNumber, config);
+ }else {
+ if (config.code === 'optimizeTypography') {
+ handleSameDataOperation(row).then(({isRoutesEqual}) => {
+ if (!isRoutesEqual) {
+ config.Typography({row});
+ ElMessage.success(config.successMsg);
+ return;
+ }
+ });
+ }
+ else {
+ let code=0
+
+ if(config.code === 'undoCompute'){
+ if(row.temperingState==1&&row.state===1){
+ row.temperingState = config.targetStates;
+ code=1
+ }else{
+ ElMessage.warning(config.checkMessage);
+ return;
+ }
+ }else if(config.code === 'undoOptimize'){
+ if(row.optimizeState==1&&row.state===1){
+ // 鍏堟洿鏂板墠绔樉绀虹殑鐘舵��
+ row.optimizeState = config.targetStates;
+ code=2;
+
+ // 鏇存柊鍒楄〃涓殑鏁版嵁浠ュ埛鏂版樉绀�
+ const index = produceList.value.findIndex(item => item === row);
+ if (index !== -1) {
+ produceList.value.splice(index, 1, {...row});
+ xGrid.value.reloadData(produceList.value);
+ }
+
+ }else{
+ ElMessage.warning(config.checkMessage);
+ return;
+ }
+ }
+ else if(config.code === 'production'){
+ if(row.optimizeState===1&&row.state===1){
+ row.state = config.targetState;
+ code=3
+ }else{
+ ElMessage.warning(config.checkMessage);
+ return;
+ }
+ }
+ else if(config.code === 'novisible'){
+ if(row.state===100){
+ row.state = config.targetState;
+ code=4
+ }else{
+ ElMessage.warning(config.checkMessage);
+ return;
+ }
+ }
+ const index = produceList.value.findIndex(item => item === row);
+ if (index !== -1) {
+ produceList.value.splice(index, 1, {...row});
+ xGrid.value.reloadData(produceList.value);
+ }
+ updateProjectStateAndHandleResponse(row, row.projectNumber, config.targetState,config.targetStates,code, config.successMsg);
+ }
+ }
+ }).catch(() => {
+ // 鐢ㄦ埛鐐瑰嚮鍙栨秷鍚庢墽琛岀殑閫昏緫
+ ElMessage.info('宸插彇娑堟搷浣�');
+ });
+ } else {
+ console.error(`鏈壘鍒版搷浣滈�夐」 ${menu.code} 瀵瑰簲鐨勯厤缃紝璇锋鏌ラ厤缃」`);
+ }
+ }
+ },
+ cellDblclick: ({row}) => {
+ const menu = {code: 'openProject'};
+ nextTick(() => {
+ handleSameDataOperation(row).then(({isRoutesEqual}) => {
+ if (!isRoutesEqual) {
+ gridEvents.menuClick({menu, row});
+ }
+ });
+ });
+ },
+};
+
+// 鍏叡澶勭悊鍑芥暟锛屽鐞嗙浉鍚屾暟鎹椂鐨勬搷浣滐紝骞惰繑鍥瀟argetRoute瀵硅薄锛堝彸閿彍鍗曞拰鍙屽嚮鎵撳紑锛�
+const handleSameDataOperation = async ({projectNumber, thickness, glassType,quantity,area,optimizeState}) => {
+ const targetRoute = {
+ name: 'optimizeInfo',
+ params: {
+ projectNo: projectNumber,
+ thickNess: String(thickness),
+ model: glassType,
+ quantity: quantity,
+ area: area,
+ optimizeState:optimizeState
+ }
+ };
+ const currentRoute = router.currentRoute.value;
+ console.log(router.currentRoute.value)
+ console.log(targetRoute)
+ const isRoutesEqual = currentRoute.name === targetRoute.name &&
+ currentRoute.params.projectNo === targetRoute.params.projectNo &&
+ parseFloat(currentRoute.params.thickNess) === parseFloat(targetRoute.params.thickNess) &&
+ currentRoute.params.model === targetRoute.params.model &&
+ parseInt(currentRoute.params.quantity) === parseInt(targetRoute.params.quantity) &&
+ parseFloat(currentRoute.params.area) === parseFloat(targetRoute.params.area)&&
+ parseFloat(currentRoute.params.optimizeState) === parseFloat(targetRoute.params.optimizeState);
+ 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) {
+ row.state = getOriginalState(targetState);
+ const rollbackIndex = produceList.value.findIndex(item => item === row);
+ if (rollbackIndex !== -1) {
+ produceList.value.splice(rollbackIndex, 1, {...row});
+ xGrid.value.reloadData(produceList.value);
+ }
+}
+
+function updateProjectStateAndHandleResponse(row, projectNumber, targetState, targetStates, code, successMsg) {
+ const updateParams = {
+ projectNumber: projectNumber,
+ stateToUpdate: targetState,
+ targetStates: targetStates
+ };
+ request.post(`/glassOptimize/updateProjectState/${projectNumber}/${targetState}/${targetStates}/${code}`, updateParams, {
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ }).then((res) => {
+ // 妫�鏌ヤ笟鍔$姸鎬佺爜锛屽鏋滄槸201鍒欐姏鍑洪敊璇互鍦╟atch涓鐞�
+ if (Number(res.code) === 201) {
+ // 鎶涘嚭鑷畾涔夐敊璇璞★紝鍖呭惈鍚庣杩斿洖鐨刴sg淇℃伅
+ throw new Error(res.msg || '鎿嶄綔澶辫触');
+ }
+ if (Number(res.code) === 200 && (res.msg === "" || res.msg === null)) {
+ ElMessage.success(successMsg);
+ } else {
+ console.log('res.code 鐨勫��:', res.code, ', 绫诲瀷:', typeof res.code);
+ console.log('res.msg 鐨勫��:', res.msg, ', 绫诲瀷:', typeof res.msg);
+ const errorMsg = res.data ? res.data.errorMessage : '鎿嶄綔澶辫触锛屾湭鑾峰彇鍒板叿浣撳師鍥狅紝璇疯仈绯荤鐞嗗憳';
+ ElMessage.error(`鎿嶄綔澶辫触锛屽師鍥�: ${errorMsg}`);
+ rollbackStateAndReloadGrid(row, targetState); // 璋冪敤鍥炴粴鍑芥暟
+ }
+ }).catch((error) => {
+ console.error('璇锋眰鍑洪敊锛屾搷浣滄湭瀹屾垚锛岃缁嗛敊璇俊鎭�:', error);
+ //const errorMsg = (res.data && res.data.errorMessage) ? res.data.errorMessage : '鎿嶄綔澶辫触锛屾湭鑾峰彇鍒板叿浣撳師鍥狅紝璇疯仈绯荤鐞嗗憳';
+ ElMessage.error(`璇锋眰鍑洪敊锛屾搷浣滄湭瀹屾垚 `+error);
+ rollbackStateAndReloadGrid(row, targetState); // 璋冪敤鍥炴粴鍑芥暟
+ });
+}
+
+//鍒犻櫎宸ョ▼
+function deleteProject(projectNumber, config) {
+ request.post(`/glassOptimize/deleteProject/${projectNumber}`, {
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ }).then((res) => {
+ if (res.code==200 && res.data===true) {
+ ElMessage.success(config.successMsg);
+ // 浠庡垪琛ㄤ腑绉婚櫎宸插垹闄ょ殑宸ョ▼鏁版嵁
+ const index = produceList.value.findIndex(item => item.projectNumber === projectNumber);
+ if (index !== -1) {
+ produceList.value.splice(index, 1);
+ xGrid.value.reloadData(produceList.value);
+ }
+ } else {
+ console.log('res.code 鐨勫��:', res.code, ', 绫诲瀷:', typeof res.code);
+ console.log('res.msg 鐨勫��:', res.msg, ', 绫诲瀷:', typeof res.msg);
+ const errorMsg = res.data ? res.data.errorMessage : config.failureMsg;
+ ElMessage.error(`鎿嶄綔澶辫触锛屽師鍥�: ${errorMsg}`);
+ }
+ }).catch((error) => {
+ console.error('璇锋眰鍑洪敊锛屽伐绋嬪垹闄ゆ湭瀹屾垚锛岃缁嗛敊璇俊鎭�:', error);
+ const errorMsg = (res.data && res.data.errorMessage) ? res.data.errorMessage : config.failureMsg;
+ ElMessage.error(`璇锋眰鍑洪敊锛屽伐绋嬪垹闄ゆ湭瀹屾垚锛屽師鍥�: ${errorMsg}`);
+ });
+}
+
+//瀹氫箟鍒囨崲妯℃嫙璁$畻寮圭獥
+const emit = defineEmits(['switch-dialog', 'close-detail-page','switch-dialog-print','switch-dialog-print2']);
//瀹氫箟宸ョ▼鐘舵��
-const optionVal = ref('0')
+const optionVal = ref('all')
const options = [
{
- value: '0',
+ value: 'all',
label: '鍏ㄩ儴',
},
{
value: '1',
- label: '1',
+ label: '鍒濆鐘舵�侊紝1',
},
- {
+ /*{
value: '2',
- label: '2',
+ label: '绗竴娆′紭鍖栵紝2',
},
{
- value: '3',
- label: '10',
+ value: '10',
+ label: '妯℃嫙璁$畻锛�10',
},
{
- value: '4',
- label: '20',
+ value: '20',
+ label: '浼樺寲瀹屾垚锛�20',
+ },*/
+ {
+ value: '100',
+ label: '鐢熶骇鍙锛�100',
},
{
- value: '5',
- label: '100',
- },
- {
- value: '6',
- label: '200',
+ value: '200',
+ label: '鐢熶骇棰嗗彇锛�200',
},
]
+//宸ョ▼鐘舵�佸嚱鏁�
+function handleOptionChange() {
+ if (optionVal.value === 'all') {
+ // 娓呯┖宸ョ▼鐘舵�佺浉鍏崇殑宸叉湁绛涢�夋潯浠�
+ delete filterData.value['state'];
+ } else {
+ filterData.value['state'] = optionVal.value; // 鏄庣‘娣诲姞閫夋嫨鐨勫伐绋嬬姸鎬佸�煎埌绛涢�夋潯浠朵腑
+ }
+ getWorkOrder();
+}
+
+//鍏叡鍑芥暟
+function buildRequestParams() {
+ let startSelectTime = orderInfo.workOrderDate[0];
+ let endSelectTime = orderInfo.workOrderDate[1];
+
+ const params = {
+ startSelectTime,
+ endSelectTime,
+ };
+
+ return params;
+}
+
+//绛涢�夋潯浠�
+let filterData = ref({
+ projectNumber: '',
+})
+// 瀹氫箟鏁版嵁杩斿洖缁撴灉锛屼娇鐢╮ef鍒涘缓鍝嶅簲寮忔暟鎹紝鍒濆鍖栦负绌烘暟缁�
+let produceList = ref([])
+
+// 鑾峰彇15澶╁墠鍒板綋鍓嶆椂闂�
+function getNowTime() {
+ const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 70)
+ .toISOString()
+ .replace('T', ' ')
+ .slice(0, 10) //榛樿寮�濮嬫椂闂�15澶╁墠
+ const end = new Date(new Date().getTime())
+ .toISOString()
+ .replace('T', ' ')
+ .slice(0, 10)//榛樿缁撴潫鏃堕棿褰撳墠鏃堕棿
+ return [start, end]
+}
+
+// 鍒濆鍖栨椂闂磋寖鍥达紝鑻ヤ负绌哄垯璁句负杩�15澶╂椂闂�
+if (orderInfo.workOrderDate[0] === "" && orderInfo.workOrderDate[1] === "") {
+ orderInfo.workOrderDate = getNowTime();
+}
+//鑾峰彇閫変腑鏃堕棿
+let startSelectTime = orderInfo.workOrderDate[0]
+let endSelectTime = orderInfo.workOrderDate[1]
+// 棣栨鍔犺浇鏁版嵁
+request.post(`/glassOptimize/optimizeProjectMange/${startSelectTime}/${endSelectTime}`, filterData.value).then((res) => {
+ if (res.code == 200) {
+ produceList.value = produceList.value.concat(deepClone(res.data.data))
+ xGrid.value.reloadData(produceList.value);
+ gridOptions.loading = false;
+ console.log('宸ョ▼绠$悊琛ㄦ牸鏁版嵁',produceList.value);
+ } else {
+ ElMessage.warning(res.msg);
+ }
+})
+
+/*浣跨敤绛涢�夛紝鍚庣鑾峰彇鏁版嵁*/
+/*const changeFilterEvent = (event, option, $panel,) => {
+ // 鎵嬪姩瑙﹀彂绛涢��
+ $panel.changeOption(event, !!option.data, option)
+}
+
+function filterChanged(column) {
+ gridOptions.loading = true;
+ //绛涢�夋潯浠跺彂鐢熷彉鍖栨潯浠跺彂鐢熷彉鍖�
+ let value = column.datas[0] != undefined ? column.datas[0] : ''
+ value = value.trim();
+ //鍒ゆ柇鏄惁涓哄伐绋嬬姸鎬佸垪鐨勭瓫閫夋敼鍙橈紙鍋囪宸ョ▼鐘舵�佸瓧娈靛悕涓�'state'锛屽彲鏍规嵁瀹為檯鎯呭喌璋冩暣锛�
+ if (column.property === 'state') {
+ if (value === 'all') {
+ // 濡傛灉閫夋嫨鐨勬槸鍏ㄩ儴锛屼粠绛涢�夋暟鎹腑鍒犻櫎姝ゆ潯浠讹紝閬垮厤浼犻�掔粰鍚庣骞叉壈鑾峰彇鍏ㄩ儴鏁版嵁
+ delete filterData.value['state'];
+ } else {
+ filterData.value['state'] = value;
+ }
+ } else {
+ //鍒ゆ柇鏄惁瀛樺湪澶栭敭
+ if (column.property.indexOf('.') > -1) {
+ const columnArr = column.property.split('.');
+ filterData.value[columnArr[0]] = {
+ [columnArr[1]]: value,
+ };
+ } else {
+ filterData.value[column.property] = value;
+ }
+ }
+
+ const params = buildRequestParams();
+ request.post(`/glassOptimize/optimizeProjectMange/${params.startSelectTime}/${params.endSelectTime}`, filterData.value).then((res) => {
+ if (res.code == 200) {
+ produceList.value = deepClone(res.data.data);
+ xGrid.value.reloadData(produceList)
+ gridOptions.loading = false
+ } else {
+ ElMessage.warning(res.msg)
+ }
+ });
+}*/
+
+// 鐐瑰嚮鏌ヨ鎸夐挳瑙﹀彂鐨勫嚱鏁帮紝鏍规嵁褰撳墠绛涢�夋潯浠惰幏鍙栨暟鎹苟鍔犺浇鍒拌〃鏍�
+const getWorkOrder = () => {
+ const params = buildRequestParams();
+ request.post(`/glassOptimize/optimizeProjectMange/${params.startSelectTime}/${params.endSelectTime}`, filterData.value).then((res) => {
+ if (res.code == 200) {
+ console.log(res.data.data)
+ produceList.value = deepClone(res.data.data);
+ gridOptions.data = produceList.value;
+ xGrid.value.loadData(produceList.value);
+ gridOptions.loading = false;
+ } else {
+ ElMessage.warning(res.msg);
+ }
+ });
+};
+// 璁$畻灏忕墖鏁伴噺
+const smallPieceQuantityInput = computed(() => {
+ return produceList.value.reduce((acc, item) => acc + item.quantity, 0);
+});
+// 璁$畻灏忕墖闈㈢Н
+const smallPieceAreaInput = computed(() => {
+ const sum = produceList.value.reduce((acc, item) => acc + item.area, 0);
+ return Number(sum.toFixed(2)); // 鍏堜娇鐢╰oFixed淇濈暀涓や綅灏忔暟锛屽啀杞崲鍥炴暟鍊肩被鍨嬶紙鍥犱负toFixed杩斿洖瀛楃涓诧級
+});
+
+// 璁$畻鍘熺墖鏁伴噺
+const originalPieceQuantityInput = computed(() => {
+ return produceList.value.reduce((acc, item) => acc + item.usingQuantity, 0);
+});
+
+// 鍘熺墖闈㈢Н鍥哄畾涓�0锛岀洿鎺ヨ繑鍥�0
+const originalPieceAreaInput = 0;
+
+//鏃ユ湡宸︿晶鏍忓揩鎹烽�夐」
+const shortcuts = [
+ {
+ text: '褰撴棩',
+ value: () => {
+ const end = new Date()
+ const start = new Date(end)
+ start.setHours(0, 0, 0, 0) // 璁剧疆涓哄綋澶╃殑鍑屾櫒 00:00:00
+ return [start, end]
+ }
+ },
+ {
+ text: '杩�1鍛�',
+ value: () => {
+ const end = new Date()
+ const start = new Date()
+ start.setDate(start.getDate() - 7)
+ return [start, end]
+ }
+ },
+
+ {
+ text: '杩�1涓湀',
+ value: () => {
+ const end = new Date()
+ const start = new Date()
+ start.setMonth(start.getMonth() - 1)
+ return [start, end]
+ }
+ },
+ {
+ text: '杩�2涓湀',
+ value: () => {
+ const end = new Date()
+ const start = new Date()
+ start.setMonth(start.getMonth() - 2)
+ return [start, end]
+ }
+ },
+ {
+ text: '杩�3涓湀',
+ value: () => {
+ const end = new Date()
+ const start = new Date()
+ start.setMonth(start.getMonth() - 3)
+ return [start, end]
+ }
+ }
+]
</script>
<template>
- <div id="mange">
- <div id="select">
- <span>浼樺寲鏃ユ湡</span>
- <el-date-picker
- style="margin-left:10px; margin-top: -5px; "
- v-model="oderInfo.mangeDate"
- type="daterange"
- format="YYYY/MM/DD"
- value-format="YYYY-MM-DD"
- :start-placeholder="$t('basicData.startDate')"
- :end-placeholder="$t('basicData.endDate')"
- :default-time="defaultTime"
-
- />
- <el-select
- style="margin-left:10px; margin-top: -5px; "
- :default-first-option="true"
- ref="getSelect"
- v-model="optionVal"
- clearable
- class="m-2"
- @change="getWorkOrder"
- >
-
- <el-option
- v-for="item in options"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
-
- <el-button
- style="margin-left:10px;margin-top: -5px"
- @click="searchByDateRange"
- type="primary" :icon="Search">
- 鏌ヨ
- </el-button>
- </div>
-
- <vxe-grid
- @filter-change="filterChanged"
- height="100%"
- class="mytable-scrollbar"
- ref="xGrid"
- v-bind="gridOptions"
- v-on="gridEvents"
+ <div id="mange">
+ <div id="select" style="">
+ <span>浼樺寲鏃ユ湡</span>
+ <el-date-picker
+ style="margin-left:10px; margin-top: -10px; "
+ v-model="orderInfo.workOrderDate"
+ :default-time="defaultTime"
+ :start-placeholder="$t('basicData.startDate')"
+ :end-placeholder="$t('basicData.endDate')"
+ type="daterange"
+ :shortcuts="shortcuts"
+ showToday
+ format="YYYY/MM/DD"
+ value-format="YYYY-MM-DD"
+ />
+ <span class="input">宸ョ▼鐘舵��</span>
+ <el-select
+ style="margin-left:10px; margin-top: -5px; width: 150px"
+ :default-first-option="true"
+ ref="getSelect"
+ v-model="optionVal"
+ clearable
+ class="m-2"
+ @change="handleOptionChange"
>
- <template #num2_filter="{ column, $panel }">
- <div>
- <div v-for="(option, index) in column.filters" :key="index">
- <vxe-select v-model="option.data" :placeholder="$t('processCard.pleaseSelect')" @change="changeFilterEvent($event, option, $panel)">
- <vxe-option value="0" :label="$t('basicData.unchecked')"></vxe-option>
- <vxe-option value="1" :label="$t('basicData.selected')"></vxe-option>
- </vxe-select>
- </div>
- </div>
- </template>
-
- <template #num1_filter="{ column, $panel }">
- <div>
- <div v-for="(option, index) in column.filters" :key="index">
- <input
- type="type"
- v-model="option.data"
- @keyup.enter.native="$panel.confirmFilter()"
- @input="changeFilterEvent($event, option, $panel)"/>
- </div>
- </div>
- </template>
- </vxe-grid>
- <div id="last">
- <span>
- 灏忕墖鏁�<vxe-input size="small" class="input" disabled></vxe-input>
- 灏忕墖闈�<vxe-input size="small" class="input" disabled></vxe-input>
- 鍘熺墖鏁�<vxe-input size="small" class="input" disabled></vxe-input>
- 鍘熺墖闈�<vxe-input size="small" class="input" disabled></vxe-input>
- </span>
- <span style="float: right">
- <el-button type="primary" class="input">閽㈠寲鐗堝浘</el-button>
- <el-button type="primary" class="input">妯℃嫙璁$畻</el-button>
- <el-button type="primary" class="input">浼樺寲鐗堝浘</el-button>
- <el-button type="primary" class="input">浼樺寲鎺掔増</el-button>
- <el-button type="primary" class="input">鏁版嵁瀵煎嚭</el-button>
- </span>
- </div>
+ <el-option
+ v-for="item in options"
+ :key="item.value"
+ :label="item.label"
+ :value="item.value"
+ />
+ </el-select>
+ <!--鏌ヨ-->
+ <el-button
+ style="margin-left:10px;margin-top: -5px"
+ :icon="Search"
+ type="primary"
+ @click="getWorkOrder">{{ $t('basicData.search') }}
+ </el-button>
</div>
+
+ <vxe-grid
+ height="100%"
+ class="mytable-scrollbar"
+ ref="xGrid"
+ v-bind="gridOptions"
+ v-on="gridEvents"
+ >
+ <template #select_filter="{ column, $panel }">
+ <div>
+ <div v-for="(option, index) in column.filters" :key="index">
+ <vxe-select v-model="option.data" @change="changeFilterEvent($event, option, $panel)">
+ <vxe-option value="0" :label="$t('basicData.unchecked')"></vxe-option>
+ <vxe-option value="1" :label="$t('basicData.selected')"></vxe-option>
+ </vxe-select>
+ </div>
+ </div>
+ </template>
+
+ <template #select_filter1="{ column, $panel }">
+ <div>
+ <div v-for="(option, index) in column.filters" :key="index">
+ <vxe-select v-model="option.data" @change="changeFilterEvent($event, option, $panel)">
+ <vxe-option value="1" label="鏄�"></vxe-option>
+ <vxe-option value="0" label="鍚�"></vxe-option>
+ </vxe-select>
+ </div>
+ </div>
+ </template>
+
+ <template #num1_filter="{ column, $panel }">
+ <div>
+ <div v-for="(option, index) in column.filters" :key="index">
+ <input type="type" v-model="option.data" @keyup.enter.native="$panel.confirmFilter()" @input="changeFilterEvent($event, option, $panel)"/>
+ </div>
+ </div>
+ </template>
+ </vxe-grid>
+ <div id="last">
+ 灏忕墖鏁伴噺
+ <el-input class="input" disabled v-model="smallPieceQuantityInput"></el-input>
+ 灏忕墖闈㈢Н
+ <el-input class="input" disabled v-model="smallPieceAreaInput"></el-input>
+ 鍘熺墖鏁伴噺
+ <el-input class="input" disabled v-model="originalPieceQuantityInput"></el-input>
+ 鍘熺墖闈㈢Н
+ <el-input class="input" disabled v-model="originalPieceAreaInput"></el-input>
+ </div>
+ </div>
</template>
<style scoped>
-#mange{
+#mange {
width: 100%;
height: 85%;
}
+
+:deep(.vxe-button.type--button.is--circle) {
+ margin-top: -20px;
+}
+
#last {
margin-top: 10px;
}
-.input{
+
+.input {
width: 80px;
- margin-left: 15px;
+ margin-left: 10px;
}
</style>
\ No newline at end of file
--
Gitblit v1.8.0