| | |
| | | <script setup> |
| | | import {onMounted, reactive, ref} from "vue"; |
| | | import {nextTick, onMounted, reactive, ref, watch} from "vue"; |
| | | import {useI18n} from "vue-i18n"; |
| | | import request from "@/utils/request"; |
| | | import {ElMessage} from "element-plus"; |
| | | import {ElMessage, ElMessageBox} from "element-plus"; |
| | | import {useRoute} from "vue-router"; |
| | | const { t } = useI18n() |
| | | |
| | |
| | | {field: 'model', title: t('warehouseBasicData.type'),}, |
| | | {field: 'leftTrim', title: '左修边',}, |
| | | {field: 'downTrim', title: '下修边',}, |
| | | {field: 'rigthTrim', title: '右修边',}, |
| | | {field: 'rightTrim', title: '右修边',}, |
| | | {field: 'upTrim', title: '上修边',}, |
| | | {field: 'available_quantity', title: '库存数量',}, |
| | | {field: '', title: '加工数量',}, |
| | | {field: 'processingQuantity', title: '加工数量',}, |
| | | {field: 'name', title: '名称',}, |
| | | {field: 'producer', title: '供应商',} |
| | | ],//表头参数 |
| | | data:null,//表格数据 |
| | | //右键菜单 |
| | | menuConfig: { |
| | | body: { |
| | | options: [ |
| | | [ |
| | | {code: 'selectTrimming', name: '设置统一修边',}, |
| | | {code: 'Exports', name: '数据导出', prefixIcon: 'vxe-icon-download', visible: true, disabled: false}, |
| | | ], |
| | | [] |
| | | ] |
| | | }, |
| | | }, |
| | | toolbarConfig: { |
| | | buttons: [], |
| | | slots:{ |
| | |
| | | }, |
| | | }) |
| | | |
| | | const emit = defineEmits(['select-trimming']); |
| | | // 右键菜单 |
| | | const operationConfigs = [ |
| | | { |
| | | code: 'selectTrimming', // 设置统一修边 |
| | | successMsg: '已打开!', |
| | | gridRef: xGrid, |
| | | requiresRow: false, |
| | | openTrimming: async () => { |
| | | emit ( 'select-trimming', true) |
| | | } |
| | | }, |
| | | { |
| | | code: 'Exports', // 导出文件操作的配置 |
| | | successMsg: '文件导出成功!', |
| | | gridRef: xGrid, |
| | | requiresRow: false, |
| | | }, |
| | | ] |
| | | |
| | | // 右键菜单点击逻辑 |
| | | const gridEvents = { |
| | | menuClick({menu}) { |
| | | const $grid = xGrid.value; |
| | | if ($grid) { |
| | | const config = operationConfigs.find(c => c.code === menu.code); |
| | | if (config) { |
| | | if (config.code === 'Exports') { |
| | | config.gridRef.value.exportData(); |
| | | ElMessage.success(config.successMsg); |
| | | return; |
| | | } |
| | | // 添加确认提示弹窗,询问用户是否进行当前操作 |
| | | ElMessageBox.confirm('是否进行当前操作?', '确认操作', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning' |
| | | }).then(() => { |
| | | if (config.code === 'selectTrimming') { |
| | | config.openTrimming(); |
| | | ElMessage.success(config.successMsg); |
| | | } |
| | | }).catch(() => { |
| | | // 用户点击取消后执行的逻辑 |
| | | ElMessage.info('已取消操作'); |
| | | }); |
| | | } else { |
| | | console.error(`未找到操作选项 ${menu.code} 对应的配置,请检查配置项`); |
| | | } |
| | | } |
| | | }, |
| | | }; |
| | | |
| | | |
| | | const route = useRoute(); |
| | | |
| | | const thickness = ref(route.query.thickNess); |
| | | const model = ref(route.query.model); |
| | | const thickness = ref(route.params.thickNess); |
| | | const model = ref(route.params.model); |
| | | let projectNo = ref(null); |
| | | |
| | | |
| | | const selectMaterialStore = () =>{ |
| | | request.post(`/glassOptimize/materialStore/${thickness.value}/${model.value}`).then((res) => { |
| | | const selectMaterialStore = async () =>{ |
| | | request.post(`/glassOptimize/materialStore/${thickness.value}/${model.value}/${projectNo}`).then((res) => { |
| | | if (Number(res.code) === 200) { |
| | | const rawData = res.data.data; |
| | | const edgeTrimming = res.data.edgeTrimming; |
| | | if (Array.isArray(rawData) && rawData.length > 0) { |
| | | const formattedData = rawData.map(item => { |
| | | const formattedItem = {}; |
| | |
| | | } |
| | | return formattedItem; |
| | | }); |
| | | const data = formattedData; |
| | | data.forEach(item => { |
| | | item.leftTrim = 0; |
| | | item.downTrim = 0; |
| | | item.rigthTrim = 0; |
| | | item.upTrim = 0; |
| | | }); |
| | | if(edgeTrimming!=null){ |
| | | const edgeTrimmingData = edgeTrimming.map(item => { |
| | | const edgeTrimmingItem = {}; |
| | | for (const key in item) { |
| | | if (typeof item[key] === 'string') { |
| | | //去除字符串属性值开头和结尾的双引号 |
| | | edgeTrimmingItem[key] = item[key].replace(/^\"|\"$/g, ''); |
| | | } else { |
| | | edgeTrimmingItem[key] = item[key]; |
| | | } |
| | | } |
| | | return edgeTrimmingItem; |
| | | }); |
| | | console.log(edgeTrimmingData) |
| | | formattedData.forEach(item => { |
| | | item.leftTrim = edgeTrimmingData[0].leftTrim; |
| | | item.downTrim = edgeTrimmingData[0].downTrim; |
| | | item.rightTrim = edgeTrimmingData[0].rightTrim; |
| | | item.upTrim = edgeTrimmingData[0].upTrim; |
| | | }); |
| | | } |
| | | |
| | | xGrid.value.loadData(formattedData); |
| | | gridOptions.data = formattedData; |
| | | } else { |
| | | console.error('返回数据格式不符合预期,不是有效的对象数组格式'); |
| | | } |
| | | } else { |
| | | ElMessage.warning(res.msg); |
| | |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | selectMaterialStore(); |
| | | if(route.params.projectNo!=null){ |
| | | projectNo=route.params.projectNo |
| | | selectMaterialStore(); |
| | | } |
| | | |
| | | }); |
| | | |
| | | watch(() => props.receivedData, (newData) => { |
| | | if (newData) { |
| | | Trimming(newData); |
| | | } |
| | | }, { immediate: true }); |
| | | |
| | | watch(() => props.InventoryData, (newInventoryData) => { |
| | | if (newInventoryData) { |
| | | thickness.value = newInventoryData.selectedLabel1; |
| | | model.value = newInventoryData.selectedLabel2; |
| | | // 由于 thickness 和 model 的值改变了,更新表格,调用 selectMaterialStore 重新获取数据 |
| | | selectMaterialStore(); |
| | | } |
| | | }); |
| | | |
| | | const props = defineProps({ |
| | | receivedData : { |
| | | type: Object, |
| | | required: false, |
| | | properties: { |
| | | quicksetLeft: { type: Number }, |
| | | quicksetBottom: { type: Number }, |
| | | quicksetRight: { type: Number }, |
| | | quicksetTop: { type: Number } |
| | | } |
| | | }, |
| | | InventoryData : { |
| | | type: Object, |
| | | required: false, |
| | | properties: { |
| | | selectedLabel1: { type: String }, |
| | | selectedLabel2: { type: String }, |
| | | } |
| | | } |
| | | }); |
| | | |
| | | //接受SetTrimming的值 (修边) |
| | | const Trimming = (receivedData) => { |
| | | nextTick(() => { |
| | | const data = gridOptions.data; |
| | | if (data) { |
| | | try { |
| | | const updatedData = []; |
| | | for (let i = 0; i < data.length; i++) { |
| | | const item = data[i]; |
| | | const updatedItem = { |
| | | ...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) { |
| | | console.error('更新表格数据时出错:', error); |
| | | ElMessage.error('更新表格数据时出现错误,请检查输入或联系管理员'); |
| | | } |
| | | } else { |
| | | console.warn('表格数据为空,无法更新磨量值'); |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | |
| | | </script> |
| | | |
| | | <template> |
| | | <div style="width: 100%;height: 100%"> |
| | | <vxe-grid |
| | | @filter-change="filterChanged" |
| | | height="100%" |
| | | class="mytable-scrollbar" |
| | | ref="xGrid" |