提交 玻璃优化右键设置磨量可以在原料部分右键选择单独选中统一修改
| | |
| | | body: { |
| | | options: [ |
| | | [ |
| | | {code: 'selectTrimming', name: '设置统一修边',}, |
| | | {code: 'selectTrimming', name: '设置统一修边',prefixIcon: 'vxe-icon-edit'}, |
| | | {code: 'Exports', name: '数据导出', prefixIcon: 'vxe-icon-download', visible: true, disabled: false}, |
| | | {code: 'addRow', name: t('basicData.add'), prefixIcon: 'vxe-icon-square-plus', visible: true, disabled: true }, |
| | | ], |
| | |
| | | gridRef: xGrid, |
| | | requiresRow: false, |
| | | openTrimming: async () => { |
| | | emit ( 'select-trimming', true) |
| | | // 获取当前选中的记录 |
| | | const selectedRecords = xGrid.value.getCheckboxRecords(); |
| | | // 发送事件给父组件,包含选中的数据 |
| | | emit('select-trimming', { |
| | | action: 'open-trimming-dialog', |
| | | selectedData: selectedRecords && selectedRecords.length > 0 ? selectedRecords : null, |
| | | timestamp: Date.now() |
| | | }); |
| | | } |
| | | }, |
| | | { |
| | |
| | | } |
| | | return; |
| | | } |
| | | |
| | | |
| | | if (config.code === 'selectTrimming') { |
| | | config.openTrimming(); |
| | | return; |
| | | } |
| | | // 添加确认提示弹窗,询问用户是否进行当前操作 |
| | | ElMessageBox.confirm('是否进行当前操作?', '确认操作', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning' |
| | | }).then(() => { |
| | | if (config.code === 'selectTrimming') { |
| | | config.openTrimming(); |
| | | ElMessage.success(config.successMsg); |
| | | } |
| | | // if (config.code === 'selectTrimming') { |
| | | // config.openTrimming(); |
| | | // ElMessage.success(config.successMsg); |
| | | // } |
| | | }).catch(() => { |
| | | // 用户点击取消后执行的逻辑 |
| | | ElMessage.info('已取消操作'); |
| | |
| | | const data = gridOptions.data; |
| | | if (data) { |
| | | try { |
| | | const updatedData = []; |
| | | for (let i = 0; i < data.length; i++) { |
| | | const item = data[i]; |
| | | const updatedItem = { |
| | | // 检查是否只对选中的项目应用修边 |
| | | const shouldApplyToSelectedOnly = receivedData.selectedItemsOnly; |
| | | let targetData = data; |
| | | |
| | | if (shouldApplyToSelectedOnly) { |
| | | // 只对选中的数据应用修边 |
| | | targetData = receivedData.selectedGlassData || []; |
| | | if (!targetData || targetData.length === 0) { |
| | | ElMessage.warning('未选择任何项目,修边未应用'); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | const updatedData = data.map(item => { |
| | | // 如果只对选中项应用,检查当前项是否在选中列表中 |
| | | if (shouldApplyToSelectedOnly) { |
| | | const isSelected = targetData.some(selectedItem => selectedItem.id === item.id); |
| | | if (!isSelected) { |
| | | return item; // 不在选中列表中,不修改 |
| | | } |
| | | } |
| | | |
| | | // 应用修边值 |
| | | return { |
| | | ...item, |
| | | // 从 receivedData 中获取对应的值来更新表格数据项 |
| | | leftTrim: Number(receivedData.quicksetLeft), |
| | | downTrim: Number(receivedData.quicksetBottom), |
| | | rightTrim: Number(receivedData.quicksetRight), |
| | | upTrim: Number(receivedData.quicksetTop), |
| | | }; |
| | | updatedData.push(updatedItem); |
| | | } |
| | | }); |
| | | |
| | | gridOptions.data = updatedData; |
| | | xGrid.value.loadData(updatedData); |
| | | } catch (error) { |
| | |
| | | |
| | | //右键菜单统一修边 |
| | | const props = defineProps({ |
| | | TrimmingDialogVisible: Boolean, |
| | | CheckboxChangeData: null |
| | | TrimmingDialogVisible: { |
| | | type: [Boolean, Object], |
| | | required: false, |
| | | default: null |
| | | }, |
| | | CheckboxChangeData: { |
| | | type: Array, |
| | | required: false, |
| | | default: null |
| | | } |
| | | }); |
| | | |
| | | |
| | | const selectedGlassDataForTrimming = ref([]); |
| | | |
| | | /*watch(() => props.TrimmingDialogVisible, (newValue) => { |
| | | if (newValue === true) { |
| | | dialogVisible.value[3] = newValue; |
| | |
| | | });*/ |
| | | |
| | | watch( |
| | | ()=> [props.TrimmingDialogVisible,props.CheckboxChangeData], |
| | | ([newValue, oldValue])=> { |
| | | if (props.TrimmingDialogVisible!=null){ |
| | | dialogVisible.value[3] = newValue; |
| | | () => props.TrimmingDialogVisible, |
| | | (newVal, oldVal) => { |
| | | // 处理打开修边对话框的逻辑 |
| | | if (newVal != null && typeof newVal === 'object' && newVal.action === 'open-trimming-dialog') { |
| | | dialogVisible.value[3] = true; |
| | | |
| | | // 更新选中的玻璃数据 |
| | | if (newVal.selectedData && newVal.selectedData.length > 0) { |
| | | selectedGlassDataForTrimming.value = newVal.selectedData; |
| | | } else { |
| | | selectedGlassDataForTrimming.value = []; |
| | | } |
| | | } |
| | | if (props.CheckboxChangeData!=null && props.CheckboxChangeData.length>0){ |
| | | } |
| | | ); |
| | | |
| | | // 单独处理选中原片数据的逻辑 |
| | | watch( |
| | | () => props.CheckboxChangeData, |
| | | (newData, oldData) => { |
| | | // 只有当有选中数据时才处理 |
| | | if (newData != null && newData.length > 0) { |
| | | optimizeData.value.materialDetails = []; |
| | | props.CheckboxChangeData.forEach(items=>{ |
| | | const detail={ |
| | | width :null, |
| | | height :null, |
| | | stockCode :null, |
| | | quantity :null, |
| | | upTrim :null, |
| | | downTrim :null, |
| | | leftTrim :null, |
| | | rightTrim:null, |
| | | priority:0 |
| | | newData.forEach(items => { |
| | | const detail = { |
| | | width: null, |
| | | height: null, |
| | | stockCode: null, |
| | | quantity: null, |
| | | upTrim: null, |
| | | downTrim: null, |
| | | leftTrim: null, |
| | | rightTrim: null, |
| | | priority: 0 |
| | | } |
| | | detail.width=items.width |
| | | detail.height=items.height |
| | | detail.stockCode=items.id |
| | | detail.quantity=items.available_quantity |
| | | detail.upTrim=items.upTrim |
| | | detail.downTrim=items.downTrim |
| | | detail.leftTrim=items.leftTrim |
| | | detail.rightTrim=items.rightTrim |
| | | detail.width = items.width |
| | | detail.height = items.height |
| | | detail.stockCode = items.id |
| | | detail.quantity = items.available_quantity |
| | | detail.upTrim = items.upTrim |
| | | detail.downTrim = items.downTrim |
| | | detail.leftTrim = items.leftTrim |
| | | detail.rightTrim = items.rightTrim |
| | | |
| | | optimizeData.value.materialDetails.push(detail) |
| | | }) |
| | | dialogVisible.value[4] = true; |
| | | }else{ |
| | | } else if (newData !== null && newData.length === 0) { |
| | | // 只有当明确传入空数组时才提示选择原片 |
| | | ElMessage.warning('请选择原片'); |
| | | } |
| | | console.log(optimizeData.value) |
| | | }); |
| | | } |
| | | ); |
| | | |
| | | |
| | | const route = useRoute(); |
| | |
| | | <el-button id="button" type="primary" @click="openDialog(3)">设置修边</el-button> |
| | | <el-dialog v-model="dialogVisible[3]" title="设置修边(mm)" destroy-on-close |
| | | style="width: 35%;height:80%;margin-top: 3vh;"> |
| | | <set-trimming :closeDialog="closeDialog" @send-data-event="handleTrimmingData"/> |
| | | <set-trimming |
| | | :closeDialog="closeDialog" |
| | | :selected-glass-data="selectedGlassDataForTrimming" |
| | | @send-data-event="handleTrimmingData"/> |
| | | </el-dialog> |
| | | <el-button id="button" type="primary" @click="saveOptimizeData()">保存</el-button> |
| | | <el-button id="button" type="primary" @click="openDialog(4)">优化</el-button> |
| | |
| | | |
| | | const emit = defineEmits(['send-data-event',]); |
| | | const props = defineProps({ |
| | | closeDialog: Function |
| | | closeDialog: { |
| | | type: Function, |
| | | required: true |
| | | }, |
| | | selectedGlassData: { |
| | | type: Array, |
| | | required: false, |
| | | default: () => [] |
| | | } |
| | | }); |
| | | |
| | | const setTrimming = () => { |
| | |
| | | quicksetTop: quicksetTop.value, |
| | | quicksetRight: quicksetRight.value, |
| | | quicksetBottom: quicksetBottom.value, |
| | | quicksetLeft: quicksetLeft.value |
| | | quicksetLeft: quicksetLeft.value, |
| | | selectedItemsOnly: props.selectedGlassData && props.selectedGlassData.length > 0, |
| | | selectedGlassData: props.selectedGlassData |
| | | }; |
| | | emit('send-data-event', dataToSend); |
| | | props.closeDialog(3); |