| | |
| | | import useOrderInfoStore from "@/stores/sd/order/orderInfo"; |
| | | import useUserInfoStore from "@/stores/userInfo"; |
| | | import userInfo from "@/stores/userInfo"; |
| | | import GlassComputed from "@/views/pp/glassOptimize/GlassComputed.vue"; |
| | | import {useRouter} from 'vue-router'; |
| | | import {defineEmits} from 'vue'; |
| | | |
| | | |
| | | const {t} = useI18n() |
| | | const userStore = useUserInfoStore() |
| | | const user = userInfo() |
| | | const orderInfo = useOrderInfoStore() |
| | | |
| | | const router = useRouter(); |
| | | |
| | | const xGrid = ref() |
| | | const gridOptions = reactive({ |
| | |
| | | body: { |
| | | options: [ |
| | | [ |
| | | {code: 'openproject', name: 'æå¼å·¥ç¨', prefixIcon: 'vxe-icon-folder-open'}, |
| | | {code: 'openProject', name: 'æå¼å·¥ç¨', prefixIcon: 'vxe-icon-folder-open'}, |
| | | {code: 'compute', name: '模æè®¡ç®', prefixIcon: 'vxe-icon-subtable'}, |
| | | {code: 'optimizetypography', name: 'ä¼åæç', prefixIcon: 'vxe-icon-menu'}, |
| | | {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: '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}, |
| | |
| | | // å®ä¹æä½é
置对象æ°ç»ï¼éä¸ç®¡çä¸åæä½é项对åºçåæ° |
| | | const operationConfigs = [ |
| | | { |
| | | code: 'openProject', // æå¼å·¥ç¨ |
| | | initialState: ['10', '20', '100', '200'], // |
| | | targetState: null, |
| | | successMsg: 'å·²æå¼å·¥ç¨ï¼', |
| | | checkMessage: 'å½åå·¥ç¨ç¶æä¸ç¬¦åæ¡ä»¶ï¼è¯·ç¡®è®¤å·¥ç¨ç¶æååæä½ï¼', |
| | | requiresRow: true, |
| | | openFile: async ({row}) => { |
| | | const projectNumber = row.projectNumber; |
| | | await router.replace({ |
| | | name: 'projectDetail', |
| | | params: { |
| | | projectNo: projectNumber |
| | | } |
| | | }); |
| | | } |
| | | }, |
| | | { |
| | | code: 'compute', // æå¼æ¨¡æè®¡ç®æä½ |
| | | initialState: ['1', '2'], // |
| | | targetState: null, |
| | |
| | | checkMessage: 'å½åå·¥ç¨ç¶æä¸ç¬¦å模æè®¡ç®æ¡ä»¶ï¼è¯·ç¡®è®¤å·¥ç¨ç¶æååæä½ï¼', |
| | | requiresRow: true, |
| | | actionFunction: async ({row}) => { |
| | | console.log('è·åçè¡æ°æ®', row); |
| | | try { |
| | | // ä½¿ç¨æµè§å¨åçClipboard APIå¤å¶å·¥ç¨å· |
| | | await navigator.clipboard.writeText(row.projectNumber); |
| | | console.log('å·¥ç¨å·å·²å¤å¶å°åªè´´æ¿'); |
| | | ElMessage.success('å·¥ç¨å·å·²æåå¤å¶'); |
| | | } catch (error) { |
| | | console.error('å¤å¶å·¥ç¨å·æ¶åºé:', error); |
| | | ElMessage.error('å¤å¶å·¥ç¨å·å¤±è´¥ï¼è¯·ç¨åéè¯'); |
| | | const projectNumber = row.projectNumber; |
| | | emit('switch-dialog', projectNumber); |
| | | } |
| | | optimizeCompute.value = true; |
| | | Mange.value = false; |
| | | } |
| | | }, |
| | | { |
| | | code: 'undocompute', |
| | | code: 'undoCompute', |
| | | initialState: '10', |
| | | targetState: 2, |
| | | successMsg: 'æ¤é模æè®¡ç®æåï¼æ°æ®å·²æ´æ°ï¼', |
| | |
| | | requiresRow: true, |
| | | }, |
| | | { |
| | | code: 'undooptimize', |
| | | code: 'undoOptimize', |
| | | initialState: '20', |
| | | targetState: 10, |
| | | successMsg: 'æ¤éä¼åæåï¼æ°æ®å·²æ´æ°ï¼', |
| | |
| | | requiresRow: true, |
| | | }, |
| | | { |
| | | code: 'Initializeproject', |
| | | code: 'InitializeProject', |
| | | initialState: ['2', '10', '20'], |
| | | targetState: 1, |
| | | successMsg: 'åå§åå·¥ç¨æåï¼', |
| | |
| | | requiresRow: true, |
| | | }, |
| | | { |
| | | code: 'delproject', |
| | | code: 'delProject', |
| | | initialState: ['1', '2', '10', '20', '100'], |
| | | targetState: null, |
| | | successMsg: 'å·¥ç¨å 餿åï¼', |
| | |
| | | failureMsg: 'å·¥ç¨å é¤å¤±è´¥ï¼è¯·è系管çåï¼', |
| | | } |
| | | ]; |
| | | |
| | | function getOriginalState(targetState) { |
| | | // æ ¹æ®å·¥ç¨ç¶æè¿å对åºçåå§ç¶æ |
| | | const stateMapping = { |
| | |
| | | 10: '20', |
| | | 100: '200', |
| | | 200: '100', |
| | | 1:['2', '10', '20'], |
| | | 1: ['2', '10', '20'], |
| | | }; |
| | | return stateMapping[targetState] || targetState; |
| | | } |
| | | |
| | | //å³é®è忡件夿 |
| | | function checkOperationCondition(config, row) { |
| | | if (!config.requiresRow ||!row) { |
| | | if (!config.requiresRow || !row) { |
| | | return false; |
| | | } |
| | | if (Array.isArray(config.initialState)) { |
| | |
| | | } |
| | | return config.initialState === String(row.state); |
| | | } |
| | | |
| | | // å³é®èåç¹å»äºä»¶ |
| | | const gridEvents = { |
| | | menuClick({ menu, row }) { |
| | | menuClick({menu, row}) { |
| | | const $grid = xGrid.value; |
| | | if ($grid) { |
| | | const config = operationConfigs.find(c => c.code === menu.code); |
| | | if (config) { |
| | | if (config.requiresRow &&!row) { |
| | | if (config.requiresRow && !row) { |
| | | ElMessage.warning('æªéä¸å·¥ç¨ï¼è¯·éä¸å·¥ç¨ååè¿è¡å½åæä½ï¼'); |
| | | return; |
| | | } |
| | |
| | | cancelButtonText: 'åæ¶', |
| | | type: 'warning' |
| | | }).then(() => { |
| | | if (config.code === 'viewTempered'){ |
| | | ElMessageBox.alert('å½åç¹å»çæ¯æ¥çé¢åçå¾åè½ï¼ç®åææ¶ä»
åæç¤ºï¼ææ å®é
æ¥çæä½!', 'åè½æç¤º', { |
| | | confirmButtonText: 'æç¥éäº' |
| | | }); |
| | | return; |
| | | } |
| | | if (config.code === 'viewOptimize'){ |
| | | ElMessageBox.alert('å½åç¹å»çæ¯æ¥çé¢åçå¾åè½ï¼ç®åææ¶ä»
åæç¤ºï¼ææ å®é
æ¥çæä½!', 'åè½æç¤º', { |
| | | confirmButtonText: 'æç¥éäº' |
| | | }); |
| | | return; |
| | | } |
| | | if (config.code === 'delproject') { |
| | | if (!row) { |
| | | ElMessage.warning(config.checkMessage); |
| | | if (config.code === 'viewTempered') { |
| | | ElMessageBox.alert('å½åç¹å»çæ¯æ¥çé¢åçå¾åè½ï¼ç®åææ¶ä»
åæç¤ºï¼ææ å®é
æ¥çæä½!', 'åè½æç¤º', { |
| | | confirmButtonText: 'æç¥éäº' |
| | | }); |
| | | return; |
| | | } |
| | | const isInitialStateMatched = config.initialState.includes(String(row.state)); |
| | | if (!isInitialStateMatched) { |
| | | ElMessage.warning(config.checkMessage); |
| | | if (config.code === 'viewOptimize') { |
| | | ElMessageBox.alert('å½åç¹å»çæ¯æ¥çé¢åçå¾åè½ï¼ç®åææ¶ä»
åæç¤ºï¼ææ å®é
æ¥çæä½!', 'åè½æç¤º', { |
| | | confirmButtonText: 'æç¥éäº' |
| | | }); |
| | | return; |
| | | } |
| | | deleteProject(row.projectNumber, config); |
| | | } else if (!checkOperationCondition(config, row)) { |
| | | ElMessage.warning(config.checkMessage); |
| | | return; |
| | | } else { |
| | | if (config.code === 'compute') { |
| | | config.actionFunction({ row }); |
| | | } else { |
| | | row.state = config.targetState; |
| | | const index = produceList.value.findIndex(item => item === row); |
| | | if (index!== -1) { |
| | | produceList.value.splice(index, 1, {...row }); |
| | | xGrid.value.reloadData(produceList.value); |
| | | if (config.code === 'delProject') { |
| | | if (!row) { |
| | | ElMessage.warning(config.checkMessage); |
| | | return; |
| | | } |
| | | updateProjectStateAndHandleResponse(row, row.projectNumber, config.targetState, config.successMsg); |
| | | const isInitialStateMatched = config.initialState.includes(String(row.state)); |
| | | if (!isInitialStateMatched) { |
| | | ElMessage.warning(config.checkMessage); |
| | | return; |
| | | } |
| | | deleteProject(row.projectNumber, config); |
| | | } else if (!checkOperationCondition(config, row)) { |
| | | ElMessage.warning(config.checkMessage); |
| | | return; |
| | | } else { |
| | | if (config.code === 'openProject') { |
| | | config.openFile({row}); |
| | | ElMessage.success(config.successMsg); |
| | | }else |
| | | if (config.code === 'compute') { |
| | | config.actionFunction({row}); |
| | | } |
| | | else { |
| | | row.state = config.targetState; |
| | | 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.successMsg); |
| | | } |
| | | } |
| | | } |
| | | }).catch(() => { |
| | | // ç¨æ·ç¹å»åæ¶åæ§è¡çé»è¾ |
| | | ElMessage.info('已忶æä½'); |
| | |
| | | console.error(`æªæ¾å°æä½é项 ${menu.code} 对åºçé
ç½®ï¼è¯·æ£æ¥é
置项`); |
| | | } |
| | | } |
| | | }, |
| | | cellDblclick: ({ row }) => { |
| | | const menu = { code: 'openProject' }; |
| | | gridEvents.menuClick({ menu, row }); // ç´æ¥éè¿gridEvents对象è°ç¨menuClick |
| | | } |
| | | }; |
| | | |
| | | // å°è£
åéå³é®èå请æ±ãå¤çååºä»¥åéè¯¯åæ»çé»è¾ç彿° |
| | | function rollbackStateAndReloadGrid(row, targetState) { |
| | | row.state = getOriginalState(targetState); |
| | | const rollbackIndex = produceList.value.findIndex(item => item === row); |
| | | if (rollbackIndex!== -1) { |
| | | if (rollbackIndex !== -1) { |
| | | produceList.value.splice(rollbackIndex, 1, {...row}); |
| | | xGrid.value.reloadData(produceList.value); |
| | | } |
| | | } |
| | | |
| | | function updateProjectStateAndHandleResponse(row, projectNumber, targetState, successMsg) { |
| | | const updateParams = { |
| | | projectNumber: projectNumber, |
| | |
| | | } 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 : 'æä½å¤±è´¥ï¼æªè·åå°å
·ä½åå ï¼è¯·è系管çå'; |
| | | 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 : 'æä½å¤±è´¥ï¼æªè·åå°å
·ä½åå ï¼è¯·è系管çå'; |
| | | const errorMsg = (res.data && res.data.errorMessage) ? res.data.errorMessage : 'æä½å¤±è´¥ï¼æªè·åå°å
·ä½åå ï¼è¯·è系管çå'; |
| | | ElMessage.error(`请æ±åºéï¼æä½æªå®æï¼åå : ${errorMsg}`); |
| | | rollbackStateAndReloadGrid(row, targetState); // è°ç¨åæ»å½æ° |
| | | }); |
| | |
| | | ElMessage.success(config.successMsg); |
| | | // ä»å表ä¸ç§»é¤å·²å é¤çå·¥ç¨æ°æ® |
| | | const index = produceList.value.findIndex(item => item.projectNumber === projectNumber); |
| | | if (index!== -1) { |
| | | 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; |
| | | 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; |
| | | const errorMsg = (res.data && res.data.errorMessage) ? res.data.errorMessage : config.failureMsg; |
| | | ElMessage.error(`请æ±åºéï¼å·¥ç¨å 餿ªå®æï¼åå : ${errorMsg}`); |
| | | }); |
| | | } |
| | | |
| | | //å®ä¹æ¨¡æè®¡ç®å¼¹çªé»è®¤éè |
| | | const optimizeCompute = ref(false) |
| | | const Mange = ref(true) |
| | | //å®ä¹åæ¢æ¨¡æè®¡ç®å¼¹çª |
| | | const emit = defineEmits(['switch-dialog']); |
| | | |
| | | //å®ä¹å·¥ç¨ç¶æ |
| | | const optionVal = ref('all') |
| | |
| | | |
| | | <template> |
| | | <div id="mange"> |
| | | <glass-computed v-if="optimizeCompute"/> |
| | | <div style="height: 100%; width: 100%" v-if="Mange"> |
| | | <div id="select"> |
| | | <span>ä¼åæ¥æ</span> |
| | | <el-date-picker |
| | | style="margin-left:10px; margin-top: -5px; " |
| | | v-model="orderInfo.workOrderDate" |
| | | :default-time="defaultTime" |
| | | :start-placeholder="$t('basicData.startDate')" |
| | | :end-placeholder="$t('basicData.endDate')" |
| | | type="daterange" |
| | | 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" |
| | | > |
| | | <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" |
| | | @filter-change="filterChanged" |
| | | <div id="select"> |
| | | <span>ä¼åæ¥æ</span> |
| | | <el-date-picker |
| | | style="margin-left:10px; margin-top: -5px; " |
| | | v-model="orderInfo.workOrderDate" |
| | | :default-time="defaultTime" |
| | | :start-placeholder="$t('basicData.startDate')" |
| | | :end-placeholder="$t('basicData.endDate')" |
| | | type="daterange" |
| | | 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 #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> |
| | | <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> |
| | | |
| | | <template #num1_filter="{ column, $panel }"> |
| | | <div> |
| | | <div v-for="(option, index) in column.filters" :key="index"> |
| | | <input v-model="option.data" type="text" |
| | | @keyup.enter.native="$panel.confirmFilter()" |
| | | @input="changeFilterEvent($event, option, $panel)"/> |
| | | </div> |
| | | <vxe-grid |
| | | height="100%" |
| | | class="mytable-scrollbar" |
| | | ref="xGrid" |
| | | v-bind="gridOptions" |
| | | v-on="gridEvents" |
| | | @filter-change="filterChanged" |
| | | > |
| | | <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> |
| | | </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> |
| | | |
| | | <template #num1_filter="{ column, $panel }"> |
| | | <div> |
| | | <div v-for="(option, index) in column.filters" :key="index"> |
| | | <input v-model="option.data" type="text" |
| | | @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> |