<script setup>
|
import {nextTick, onMounted, reactive, ref, watch,onBeforeUnmount } from "vue";
|
import {useI18n} from "vue-i18n";
|
import {Folder, Plus, Setting, Operation,} from "@element-plus/icons-vue";
|
import OptimizeCompute from "@/views/pp/glassOptimize/page/OptimizeCompute.vue";
|
import SetAmount from "@/views/pp/glassOptimize/page/SetAmount.vue";
|
import SetTrimming from "@/views/pp/glassOptimize/page/SetTrimming.vue";
|
import CheckInventory from "@/views/pp/glassOptimize/page/CheckInventory.vue";
|
import request from "@/utils/request";
|
import {ElMessage, ElMessageBox} from "element-plus";
|
import {useRoute} from 'vue-router';
|
|
|
const {t} = useI18n()
|
|
const xGrid = ref()
|
const gridOptions = reactive({
|
height: '100%',
|
loading: false,
|
border: "full",//表格加边框
|
keepSource: true,//保持源数据
|
align: 'center',//文字居中
|
stripe: true,//斑马纹
|
rowConfig: {isCurrent: true, isHover: true, height: 30, useKey: true},//鼠标移动或选择高亮
|
id: 'ProjectDetail',
|
scrollX: {enabled: true},
|
scrollY: {enabled: true, gt: 0},//开启虚拟滚动
|
showOverflow: true,
|
columnConfig: {
|
resizable: true,
|
useKey: true
|
},
|
filterConfig: { //筛选配置项
|
remote: true
|
},
|
customConfig: {
|
storage: true
|
},
|
editConfig: {
|
trigger: 'click',
|
mode: 'row',
|
showStatus: true
|
},
|
|
columns: [
|
{type: 'seq', fixed: "left", title: ' ', slots: {content: 'content'}, width: 50},
|
{field: 'order_number', title: '订序', width: 70},
|
{field: 'child_width',
|
width: 100,
|
title: t('order.width'),
|
sortable: true
|
},
|
{
|
field: 'child_height',
|
width: 100,
|
title: t('order.height'),
|
sortable: true
|
},
|
{
|
field: 'quantity',
|
width: 150,
|
title: t('order.quantity'),
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
sortable: true
|
},
|
{
|
field: 'longGrind1',
|
width: 150,
|
title: '长磨1',
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
sortable: true
|
},
|
{
|
field: 'longGrind2',
|
width: 150,
|
title: '长磨2',
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
sortable: true
|
},
|
{
|
field: 'shortGrind1',
|
width: 150,
|
title: '短磨1',
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
sortable: true
|
},
|
{
|
field: 'shortGrind2',
|
width: 150,
|
title: '短磨2',
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
sortable: true
|
},
|
{
|
field: 'shape',
|
width: 150,
|
title: t('order.shape'),
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
sortable: true
|
},
|
{
|
field: 'process_cards',
|
width: 150,
|
title: '流程卡号',
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
sortable: true
|
},
|
{
|
field: 'product_name',
|
width: 150,
|
title: t('order.product'),
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
sortable: true
|
},
|
{
|
field: 'price',
|
width: 150,
|
title: t('单价'),
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
sortable: true
|
},
|
{
|
field: 'remark',
|
width: 150,
|
title: t('basicData.remarks'),
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
sortable: true
|
},
|
{
|
field: 'building_number',
|
width: 150,
|
title: '楼层号',
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
sortable: true
|
},
|
{
|
field: 'perimeter',
|
width: 150,
|
title: t('order.perimeter'),
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
sortable: true
|
},
|
{
|
field: 'area',
|
width: 150,
|
title: t('order.grossArea'),
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
sortable: true
|
},
|
|
{
|
field: 'shelf_number',
|
width: 150,
|
title: '架号',
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
sortable: true
|
},
|
{
|
field: 'technology_number',
|
width: 150,
|
title: '层',
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
sortable: true
|
},
|
{
|
field: 'glass_child',
|
width: 150,
|
title: '单片名称',
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
sortable: true
|
},
|
{
|
field: 'icon',
|
width: 150,
|
title: '印标类型',
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
sortable: true
|
},
|
],//表头参数
|
data: null,//表格数据
|
toolbarConfig: {
|
buttons: [
|
],
|
import: false,
|
// export: true,
|
// print: true,
|
zoom: true,
|
custom: true
|
},
|
//右键菜单
|
menuConfig: {
|
body: {
|
options: [
|
[
|
{code: 'setAmount', name: '设置统一磨量',},
|
{code: 'displayProcessCard', name: '显示流程卡',},
|
{code: 'hideProcessCard', name: '隐藏流程卡',},
|
{code: 'setShape', name: '设置图形',},
|
{code: 'Export', name: '数据导出', prefixIcon: 'vxe-icon-download', visible: true, disabled: false},
|
{code: 'safeDXF', name: '图形另存为DXF',},
|
{code: 'exportOPTIMA', name: '导出数据到OPTIMA',},
|
],
|
[]
|
]
|
},
|
},
|
})
|
const processCardColumns = reactive({
|
columns:[
|
{field: 'process_id', title: '流程卡', width: 200, align: 'center'},
|
{field: 'project', title: '项目名', width: 150, align: 'center'},
|
{field: 'order_number', title: '订序', width: 100, align: 'center'},
|
{field: 'sizes', title: '尺寸', width: 200, align: 'center'},
|
{field: 'layer', title: '层', width: 100, align: 'center'},
|
{field: 'quantity', title: '数量', width: 100, align: 'center'}
|
],
|
toolbarConfig: {
|
buttons: [
|
],
|
import: false,
|
// export: true,
|
// print: true,
|
|
},
|
});
|
|
// 右键菜单
|
const operationConfigs = [
|
{
|
code: 'setAmount', // 设置统一磨量
|
successMsg: '已打开!',
|
gridRef: xGrid,
|
requiresRow: false,
|
openAmount: async () => {
|
dialogVisible.value[2] = true;
|
}
|
},
|
{
|
code: 'displayProcessCard',
|
successMsg: '操作成功!',
|
gridRef: xGrid,
|
requiresRow: false,
|
displayProcess: () => {
|
getProcessCard();
|
// 显示流程卡时,将 left-table 宽度改为 50%
|
leftTableWidth.value = 60;
|
showProcessCardTable.value = true;
|
}
|
},
|
{
|
code: 'hideProcessCard',
|
successMsg: '操作成功!',
|
gridRef: xGrid,
|
requiresRow: false,
|
hideProcess: () => {
|
leftTableWidth.value = 100;
|
showProcessCardTable.value = false;
|
}
|
},
|
{
|
code: 'setShape',
|
successMsg: '操作成功!',
|
gridRef: xGrid,
|
requiresRow: false,
|
showMessage: () => {
|
ElMessage.info('此功能暂未完善,暂时无法执行设置图形操作。');
|
}
|
},
|
{
|
code: 'Export', // 导出文件操作的配置
|
successMsg: '文件导出成功!',
|
gridRef: xGrid,
|
requiresRow: false,
|
},
|
{
|
code: 'safeDXF',
|
successMsg: '操作成功!',
|
gridRef: xGrid,
|
requiresRow: false,
|
showMessage: () => {
|
ElMessage.info('此功能暂未完善,暂时无法执行图形另存为DXF操作。');
|
}
|
},
|
{
|
code: 'exportOPTIMA',
|
successMsg: '操作成功!',
|
gridRef: xGrid,
|
requiresRow: false,
|
showMessage: () => {
|
ElMessage.info('此功能暂未完善,暂时无法执行导出数据到OPTIMA操作。');
|
}
|
},
|
]
|
|
// 右键菜单点击逻辑
|
const gridEvents = {
|
menuClick({menu}) {
|
const $grid = xGrid.value;
|
if ($grid) {
|
const config = operationConfigs.find(c => c.code === menu.code);
|
if (config) {
|
if (config.code === 'Export') {
|
config.gridRef.value.exportData();
|
ElMessage.success(config.successMsg);
|
return;
|
}
|
// 添加确认提示弹窗,询问用户是否进行当前操作
|
ElMessageBox.confirm('是否进行当前操作?', '确认操作', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
if (config.code === 'setAmount') {
|
config.openAmount();
|
ElMessage.success(config.successMsg);
|
} else if (config.code === 'displayProcessCard') {
|
config.displayProcess();
|
ElMessage.success(config.successMsg);
|
} else if (config.code === 'hideProcessCard') {
|
config.hideProcess();
|
ElMessage.success(config.successMsg);
|
} else if (['setShape', 'safeDXF', 'exportOPTIMA'].includes(config.code)) {
|
config.showMessage();
|
}
|
}).catch(() => {
|
// 用户点击取消后执行的逻辑
|
ElMessage.info('已取消操作');
|
});
|
} else {
|
console.error(`未找到操作选项 ${menu.code} 对应的配置,请检查配置项`);
|
}
|
}
|
},
|
};
|
|
const handleCommand = async (command) => {
|
await emit('changeDialog', command)
|
}
|
|
//优化计算
|
const dialogVisible = ref({});
|
const openDialog = (index) => {
|
dialogVisible.value[index] = true;
|
};
|
//关闭弹窗
|
const closeDialog = (index) => {
|
dialogVisible.value[index] = false;
|
};
|
|
//右键菜单统一修边
|
const props = defineProps({
|
TrimmingDialogVisible: Boolean
|
});
|
watch(() => props.TrimmingDialogVisible, (newValue) => {
|
if (newValue === true) {
|
dialogVisible.value[3] = newValue;
|
}
|
});
|
|
const route = useRoute();
|
//工程号
|
const projectNo = ref(route.params.projectNo);
|
const projectName = ref('');
|
onBeforeUnmount(() => {
|
localStorage.setItem('projectNo', projectNo.value);
|
});
|
|
const fetchData = () => {
|
request.post(`/glassOptimize/projectInfo/${projectNo.value}`).then((res) => {
|
if ((Number(res.code) === 200)) {
|
const data = res.data.data;
|
data.forEach(item => {
|
item.longGrind1 = 0;
|
item.longGrind2 = 0;
|
item.shortGrind1 = 0;
|
item.shortGrind2 = 0;
|
item.shelf_number = 0;
|
});
|
xGrid.value.loadData(res.data.data);
|
gridOptions.data = res.data.data;
|
projectName.value = res.data.data[0].project_name;
|
} else {
|
ElMessage.warning(res.msg);
|
}
|
}).catch((error) => {
|
console.error("获取数据出错:", error);
|
});
|
};
|
onMounted(() => {
|
if (projectNo.value) {
|
fetchData();
|
}
|
});
|
|
// 流程卡 宽度
|
const leftTableWidth = ref(100);
|
const showProcessCardTable = ref(false);
|
// 用于存储流程卡数据
|
const processCardData = ref(null);
|
//流程卡
|
const getProcessCard = () => {
|
request.post(`/glassOptimize/getProcessCard/${projectNo.value}`).then((res) => {
|
if (Number(res.code) === 200) {
|
processCardData.value = res.data.data;
|
} else {
|
ElMessage.warning(res.msg);
|
}
|
});
|
};
|
|
|
// 从子组件SetAmount获取磨量值,并更新表格数据
|
const Amount = (amountData) => {
|
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,
|
longGrind1: Number(amountData.quicksetTop),
|
longGrind2: Number(amountData.quicksetRight),
|
shortGrind1: Number(amountData.quicksetBottom),
|
shortGrind2: Number(amountData.quicksetLeft)
|
};
|
updatedData.push(updatedItem);
|
}
|
gridOptions.data = updatedData;
|
xGrid.value.loadData(updatedData);
|
} catch (error) {
|
console.error('更新表格数据时出错:', error);
|
// 这里可以根据实际需求添加一些回滚操作或者提示用户的逻辑,比如显示一个错误提示框等
|
ElMessage.error('更新磨量数据时出现错误,请检查输入或联系管理员');
|
}
|
} else {
|
console.warn('表格数据为空,无法更新磨量值');
|
}
|
});
|
};
|
|
//中转站接受SetTrimming的值(设置修边)
|
const emit = defineEmits([
|
'changeDialog',
|
'forward-data-to-grandparent',
|
'send-inventory-to-op'
|
]);
|
|
const handleTrimmingData = (data) => {
|
emit('forward-data-to-grandparent', data);
|
};
|
|
//中转站接受CheckInventory的值(查询库存)
|
const handleInventory = (selectedLabel1, selectedLabel2) => {
|
emit('send-inventory-to-op', selectedLabel1, selectedLabel2);
|
}
|
|
</script>
|
|
<template>
|
<div style="width: 100%;height: 85%;">
|
<!-- 头部 -->
|
<div id="header" >
|
<!--工程文件菜单-->
|
<el-dropdown @command="handleCommand">
|
<el-button type="primary" :icon="Folder" style="margin-top: 8px; margin-left: 5px">
|
工程文件
|
</el-button>
|
<template #dropdown>
|
<el-dropdown-menu>
|
<el-dropdown-item :command="1" :icon="Plus">创建工程</el-dropdown-item>
|
<el-dropdown-item :command="2" :icon="Setting">工程管理</el-dropdown-item>
|
<el-dropdown-item :command="3" :icon="Operation">模拟计算</el-dropdown-item>
|
</el-dropdown-menu>
|
</template>
|
</el-dropdown>
|
|
<div id="title">
|
<span>工程编号:</span>
|
<el-input readonly placeholder="" style="width: 150px" v-model="projectNo"></el-input>
|
<span>工程名称:</span>
|
<el-input readonly placeholder="" style="width: 150px; margin-right: 340px;" v-model="projectName" ></el-input>
|
<el-button id="checkinventory" type="primary" @click="openDialog(1)">查询库存</el-button>
|
<el-dialog v-model="dialogVisible[1]" title="查询库存" destroy-on-close style="width: 35%;height:35%;">
|
<check-inventory :closeDialog="closeDialog" @send-data-inventory="handleInventory"/>
|
</el-dialog>
|
<el-button id="button" type="primary" @click="openDialog(2)">设置磨量</el-button>
|
<el-dialog v-model="dialogVisible[2]" title="设置磨量(mm)" destroy-on-close
|
style="width: 35%;height:80%;margin-top: 3vh;">
|
<set-amount :closeDialog="closeDialog" @set-amount="Amount"/>
|
</el-dialog>
|
<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"/>
|
</el-dialog>
|
<el-button id="button" type="primary">保存</el-button>
|
<el-button id="button" type="primary" @click="openDialog(4)">优化</el-button>
|
<el-dialog v-model="dialogVisible[4]" title="优化计算" destroy-on-close
|
style="width: 75%;height:90%;margin-top: 3vh;">
|
<optimize-compute/>
|
</el-dialog>
|
</div>
|
</div>
|
|
<!-- 表格容器 -->
|
<div class="table-container">
|
<vxe-grid
|
class="left-table"
|
@filter-change="filterChanged"
|
height="100%"
|
ref="xGrid"
|
v-bind="gridOptions"
|
v-on="gridEvents"
|
v-bind:style="{ width: leftTableWidth + '%' }"
|
>
|
<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>
|
|
<!-- 流程卡表格 -->
|
<vxe-grid
|
height="100%"
|
class="right-table"
|
:data="processCardData"
|
v-bind="processCardColumns"
|
v-if="showProcessCardTable"
|
:header-cell-style="{'height': '51.9px'}"
|
>
|
</vxe-grid>
|
|
</div>
|
</div>
|
</template>
|
|
<style scoped>
|
.table-container {
|
width: 100%;
|
height: 100%;
|
flex: 1;
|
display: flex;
|
}
|
|
.left-table {
|
float: left;
|
}
|
|
.right-table {
|
width: 40%;
|
}
|
|
:deep(.vxe-toolbar){
|
height: 40px;
|
}
|
|
#header {
|
height: 50px;
|
display: flex;
|
|
}
|
|
#title {
|
margin: 8px 5px;
|
width: 1240px;
|
}
|
|
#button {
|
margin-left: 10px;
|
}
|
|
</style>
|