| | |
| | | import {nextTick, onMounted, reactive, ref, watch} from "vue"; |
| | | import request from "@/utils/request"; |
| | | import {useI18n} from "vue-i18n"; |
| | | import {ElMessage} from "element-plus"; |
| | | import deepClone from "@/utils/deepClone"; |
| | | import {addListener, toolbarButtonClickEvent} from "@/hook/mouseMove"; |
| | | const { t } = useI18n() |
| | | |
| | | const xGrid = ref() |
| | |
| | | scrollX:{enabled: true}, |
| | | scrollY:{ enabled: true ,gt:0},//开启虚拟滚动 |
| | | showOverflow:true, |
| | | menuConfig: { |
| | | body: { |
| | | options: [ |
| | | [ |
| | | { code: 'copyChecked', name: t('basicData.selectSame'), prefixIcon: 'vxe-icon-copy', visible: true, disabled: false }, |
| | | { code: 'copyAll', name: t('basicData.sameAfterwards'), prefixIcon: 'vxe-icon-feedback', visible: true, disabled: false }, |
| | | ] |
| | | ] |
| | | } |
| | | }, |
| | | columnConfig: { |
| | | resizable: true, |
| | | useKey: true |
| | |
| | | |
| | | columns:[ |
| | | {type: 'seq', title: t('basicData.Number'), width: 80}, |
| | | {field: "mq", title: '幕墙模式', width: 80, slots: { default: 'state' }}, |
| | | {field: "hp", title: '允许横排', width: 80, slots: { default: 'state' }}, |
| | | {field: "tempering", title: '钢化', width: 80, slots: { default: 'state' }}, |
| | | {field: 'curtain_wall',title: '幕墙模式',width: 80, slots: { default: 'state1' }}, |
| | | {field: "allow_rotate", title: '允许横排', width: 80, slots: { default: 'state2' }}, |
| | | {field: "tempering", title: '钢化', width: 80, slots: { default: 'state3' }}, |
| | | |
| | | {field: 'process_id',width: 150, title: t('processCard.processId'), sortable: true}, |
| | | {field: 'technology_number',width: 70, title: '层', sortable: true}, |
| | | {field: 'TotalFloors',width: 150, title: '总层数', sortable: true}, |
| | | {field: 'processId',width: 150, title: t('processCard.processId'), sortable: true}, |
| | | {field: 'technologyNumber',width: 70, title: '层', sortable: true}, |
| | | {field: 'total_layers',width: 150, title: '总层数', sortable: true}, |
| | | {field: 'TotalNumber',width: 150, title: '规格', sortable: true}, |
| | | {field: 'quantity',width: 150, title: t('order.quantity'), sortable: true}, |
| | | {field: 'total_num',width: 150, title: t('order.quantity'), sortable: true}, |
| | | {field: 'glass_child',width: 150, title: t('order.product'), sortable: true}, |
| | | {field: 'project', width:150, title: t('order.project'), showOverflow: "ellipsis"}, |
| | | {field: 'area',width: 150, title: t('order.area'), sortable: true}, |
| | | {field: 'total_area',width: 150, title: t('order.area'), sortable: true}, |
| | | |
| | | |
| | | ],//表头参数 |
| | |
| | | ]); |
| | | |
| | | |
| | | |
| | | const selectFullData = () => { |
| | | return xGrid.value.getTableData().fullData |
| | | } |
| | | |
| | | |
| | | const props = defineProps({ |
| | |
| | | processId: null, |
| | | technologyNumber: null, |
| | | patchState: null, |
| | | glassThickness: String, // 添加玻璃厚度属性 |
| | | glassType: String // 添加玻璃类型属性 |
| | | }); |
| | | |
| | | |
| | | |
| | | |
| | | watch(() => props.tableData, async (newData) => { |
| | | if (Array.isArray(newData)) { |
| | | gridOptions.data = newData; |
| | | await nextTick(); |
| | | if (xGrid.value) { |
| | | const grid = xGrid.value; |
| | | if (typeof grid.refresh === 'function') { |
| | | grid.refresh(); |
| | | } |
| | | |
| | | |
| | | // 提取所有唯一的process_id |
| | | const processIds = Array.from(new Set(newData.map(item => item.process_id))); |
| | | |
| | | /*const requests = newData.map(item => |
| | | request.post(`/glassOptimize/selectComputeDetail/${item.process_id}/${item.technologyNumber}/${item.patchState}`) |
| | | );*/ |
| | | |
| | | /*try { |
| | | const responses = await Promise.all(requests); |
| | | |
| | | // 整合数据 |
| | | const processData = responses.reduce((acc, res, index) => { |
| | | const processId = processIds[index]; |
| | | |
| | | // 检查res.data是否为对象,并且包含'data'字段 |
| | | if (typeof res.data === 'object' && res.data !== null && 'data' in res.data) { |
| | | const data = res.data.data; |
| | | |
| | | // 检查data是否为数组 |
| | | if (!Array.isArray(data)) { |
| | | console.error(`响应数据中的'data'字段不是数组,process_id: ${processId}`); |
| | | return acc; |
| | | } |
| | | |
| | | // 获取对应process_id的newData条目 |
| | | const relatedNewData = newData.filter(item => item.process_id === processId); |
| | | |
| | | // 初始化process_card对象 |
| | | const processCard = { |
| | | process_no: processId, |
| | | layers: relatedNewData.technology_number, |
| | | total_layers: relatedNewData.TotalNumber, |
| | | total_num: relatedNewData.quantity, |
| | | total_area: relatedNewData.area, |
| | | is_must: true, |
| | | allow_rotate: relatedNewData.check === 1 ? true : false, |
| | | priority_level: 0, |
| | | tempering: relatedNewData.check === 2 ? true : false, |
| | | curtain_wall: relatedNewData.check === 3 ? true : false, |
| | | patch_state: 0, |
| | | merge: 0, |
| | | glass_details: [] |
| | | }; |
| | | |
| | | |
| | | // 整合glass_details |
| | | data.forEach(detail => { |
| | | const matchedNewData = relatedNewData.find( |
| | | item => item.technology_number === detail.technology_number |
| | | ); |
| | | |
| | | processCard.glass_details.push({ |
| | | process_id: processId, |
| | | technology_number: detail.technology_number, |
| | | order_number: detail.order_number, |
| | | layers_number: detail.layers_number, |
| | | max_width: detail.width, |
| | | max_height: detail.height, |
| | | child_width: detail.child_width, |
| | | child_height: detail.child_height, |
| | | quantity: matchedNewData ? matchedNewData.quantity : 0, |
| | | patch_state: 0 |
| | | }); |
| | | }); |
| | | |
| | | // 将processCard添加到acc中 |
| | | if (!acc.process_cards) { |
| | | acc.process_cards = []; |
| | | } |
| | | acc.process_cards.push(processCard); |
| | | // 设置其他字段的值 |
| | | |
| | | } else { |
| | | console.error(`响应数据格式不正确,process_id: ${processId}`); |
| | | } |
| | | return acc; |
| | | }, {}); |
| | | if (newData.length > 0) { |
| | | // 假设所有条目的thickness和glassType相同 |
| | | processData.glass_thickness = newData[0].thickness; |
| | | processData.glass_type = newData[0].glassType; |
| | | } else { |
| | | processData.glass_thickness = ""; |
| | | processData.glass_type = ""; |
| | | } |
| | | |
| | | |
| | | |
| | | // 发送整合后的数据到父组件 |
| | | emit('sendData', processData); |
| | | } catch (error) { |
| | | console.error('请求失败:', error); |
| | | }*/ |
| | | } |
| | | } else { |
| | | console.error('传递给表格的数据格式不符合要求,期望是数组格式'); |
| | | addListener(xGrid.value,gridOptions) |
| | | console.log(newData) |
| | | xGrid.value.loadData(deepClone(newData)) |
| | | const data = xGrid.value.getTableData().fullData |
| | | data.forEach(item => { |
| | | item.tempering = item.tempering === 1; |
| | | item.allow_rotate = item.allow_rotate === 1; |
| | | item.curtain_wall = item.curtain_wall === 1; |
| | | }) |
| | | } |
| | | }); |
| | | |
| | |
| | | cellClick({row}) { |
| | | rowClickIndex.value = row |
| | | // Emit 事件将更新后的值传递给父组件 |
| | | emit('upProcessId', rowClickIndex.value.process_id,rowClickIndex.value.patch_state,rowClickIndex.value.technology_number); |
| | | emit('updateTechnologyNumber', rowClickIndex.value.process_id,rowClickIndex.value.patch_state,rowClickIndex.value.technology_number); |
| | | emit('upProcessId', rowClickIndex.value.processId,rowClickIndex.value.patch_state,rowClickIndex.value.technologyNumber); |
| | | emit('updateTechnologyNumber', rowClickIndex.value.processId,rowClickIndex.value.patch_state,rowClickIndex.value.technologyNumber); |
| | | }, |
| | | menuClick ({ menu, row, column }) { |
| | | const $grid = xGrid.value |
| | | if ($grid) { |
| | | switch (menu.code) { |
| | | |
| | | case 'copyChecked' :{ |
| | | let result = toolbarButtonClickEvent() |
| | | if(result){ |
| | | const dataList = xGrid.value.getTableData().visibleData |
| | | let firstVal=null; |
| | | if(result.cell.indexOf('.')>-1){ |
| | | firstVal = eval("dataList["+result.start +"]."+result.cell) |
| | | }else { |
| | | firstVal=dataList[result.start][result.cell]; |
| | | } |
| | | dataList.forEach((item,index) =>{ |
| | | if(index>=result.start && index<=result.end){ |
| | | //取消选中 |
| | | if(parseInt(firstVal)<=0){ |
| | | xGrid.value.setCheckboxRow(item, false); |
| | | } |
| | | if(result.cell.indexOf('.')>-1){ |
| | | const columnArr = result.cell.split('.') |
| | | item[columnArr[0]][columnArr[1]] = firstVal |
| | | }else{ |
| | | item[result.cell] = firstVal |
| | | } |
| | | |
| | | } |
| | | }) |
| | | } |
| | | break |
| | | } |
| | | case 'copyAll' :{ |
| | | let result = toolbarButtonClickEvent() |
| | | if(result){ |
| | | const dataList = xGrid.value.getTableData().visibleData |
| | | let firstVal=null; |
| | | if(result.cell.indexOf('.')>-1){ |
| | | firstVal = eval("dataList["+result.start +"]."+result.cell) |
| | | }else { |
| | | firstVal=dataList[result.start][result.cell]; |
| | | } |
| | | dataList.forEach((item,index) =>{ |
| | | if(index>=result.start){ |
| | | //取消选中 |
| | | if(parseInt(firstVal)<=0){ |
| | | xGrid.value.setCheckboxRow(item, false); |
| | | } |
| | | if(result.cell.indexOf('.')>-1){ |
| | | const columnArr = result.cell.split('.') |
| | | item[columnArr[0]][columnArr[1]] = firstVal |
| | | }else{ |
| | | item[result.cell] = firstVal |
| | | } |
| | | |
| | | } |
| | | }) |
| | | } |
| | | break |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | defineExpose({selectFullData}) |
| | | </script> |
| | | |
| | | <template> |
| | |
| | | </div> |
| | | </template> |
| | | |
| | | <template #state="{ row,column}"> |
| | | <template #state1="{ row,column}"> |
| | | <el-checkbox |
| | | v-if="row[column.field] === 1" |
| | | :checked="true"/> |
| | | v-model="row.curtain_wall"/> |
| | | </template> |
| | | <template #state2="{ row,column}"> |
| | | <el-checkbox |
| | | v-else |
| | | :checked="false"/> |
| | | v-model="row.allow_rotate"/> |
| | | </template> |
| | | <template #state3="{ row,column}"> |
| | | <el-checkbox |
| | | v-model="row.tempering"/> |
| | | </template> |
| | | </vxe-grid> |
| | | </div> |
| | |
| | | height: 20px; |
| | | margin-top: -20px; |
| | | } |
| | | .vxe-grid { |
| | | /* 禁用浏览器默认选中 */ |
| | | -webkit-user-select: none; |
| | | -moz-user-select: none; |
| | | -ms-user-select: none; |
| | | user-select: none; |
| | | } |
| | | |
| | | </style> |