| | |
| | | <script setup> |
| | | import {reactive, ref} from "vue"; |
| | | import {computed, reactive, ref} from "vue"; |
| | | import {useI18n} from "vue-i18n"; |
| | | import deepClone from "@/utils/deepClone" |
| | | import {Search} from "@element-plus/icons-vue"; |
| | |
| | | import useOrderInfoStore from "@/stores/sd/order/orderInfo"; |
| | | import useUserInfoStore from "@/stores/userInfo"; |
| | | import userInfo from "@/stores/userInfo"; |
| | | import {VxeUI} from 'vxe-pc-ui' |
| | | import GlassComputed from "@/views/pp/glassOptimize/GlassComputed.vue"; |
| | | |
| | | const {t} = useI18n() |
| | | const userStore = useUserInfoStore() |
| | |
| | | {field: 'modifyTime', width: 100, title: '修改时间',}, |
| | | ],//表头参数 |
| | | data: null,//表格数据 |
| | | //右键菜单选项 |
| | | menuConfig: { |
| | | body: { |
| | | options: [ |
| | | [ |
| | | {code: 'openproject', name: '打开工程', prefixIcon: 'vxe-icon-folder-open'}, |
| | | {code: 'compute', name: '模拟计算', prefixIcon: 'vxe-icon-subtable'}, |
| | | {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: '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}, |
| | | |
| | | ], |
| | | [] |
| | | ] |
| | | }, |
| | | }, |
| | | toolbarConfig: { |
| | | buttons: [], |
| | | slots: { |
| | |
| | | }, |
| | | |
| | | }) |
| | | |
| | | |
| | | //定义模拟计算弹窗默认隐藏 |
| | | const optimizecompute = ref(false) |
| | | const Mange = ref(true) |
| | | //右键菜单点击事件 |
| | | const gridEvents = { |
| | | menuClick({menu, row, column}) { |
| | | const $grid = xGrid.value |
| | | if ($grid) { |
| | | switch (menu.code) { |
| | | case 'copy': |
| | | if (row && column) { |
| | | if (VxeUI.clipboard.copy(row[column.field])) { |
| | | VxeUI.modal.message({content: '已复制到剪贴板!', status: 'success'}) |
| | | } |
| | | } |
| | | break |
| | | case 'compute': |
| | | optimizecompute.value = true; |
| | | Mange.value = false; |
| | | break |
| | | case 'Export': |
| | | $grid.exportData() |
| | | break |
| | | case 'undocompute': |
| | | if (!row) { |
| | | ElMessage.warning('未选中工程,请选中工程后再进行当前操作!'); |
| | | return; |
| | | } |
| | | if (String(row.state) === '10') { |
| | | row.state = '2'; |
| | | const index = produceList.value.findIndex(item => item === row); |
| | | if (index!== -1) { |
| | | produceList.value.splice(index, 1, {...row }); |
| | | xGrid.value.reloadData(produceList.value); |
| | | } |
| | | const projectNumber = row.projectNumber; |
| | | const state = 2; // 明确定义要更新的状态值为2 |
| | | const updateParams = { |
| | | projectNumber: projectNumber, |
| | | stateToUpdate: state |
| | | }; |
| | | request.post(`/glassOptimize/updateProjectState/${projectNumber}/${state}`, updateParams, { |
| | | headers: { |
| | | 'Content-Type': 'application/json' |
| | | } |
| | | }).then((res) => { |
| | | if (res.code === 200 && res.data && res.data.success) { // 假设后端返回的data里有success字段表示操作是否成功,根据后端实际返回结构调整 |
| | | ElMessage.success('撤销模拟计算成功,数据已更新!'); |
| | | } else { |
| | | console.log('撤销模拟计算失败,后端返回的详细信息:', res); |
| | | const errorMsg = res.data? res.data.errorMessage : '撤销模拟计算失败,未获取到具体原因,请联系管理员'; // 尝试获取后端返回的详细错误消息,如果没有则显示通用提示 |
| | | ElMessage.error(`撤销模拟计算失败,原因: ${errorMsg}`); |
| | | row.state = '10'; |
| | | const rollbackIndex = produceList.value.findIndex(item => item === row); |
| | | if (rollbackIndex!== -1) { |
| | | produceList.value.splice(rollbackIndex, 1, {...row }); |
| | | xGrid.value.reloadData(produceList.value); |
| | | } |
| | | } |
| | | }).catch((error) => { |
| | | console.error('请求出错,撤销模拟计算未完成,详细错误信息:', error); |
| | | const errorMsg = error.message || '请求出错,未获取到具体原因,请联系管理员'; |
| | | ElMessage.error(`请求出错,撤销模拟计算未完成,原因: ${errorMsg}`); |
| | | row.state = '10'; |
| | | const rollbackIndex = produceList.value.findIndex(item => item === row); |
| | | if (rollbackIndex!== -1) { |
| | | produceList.value.splice(rollbackIndex, 1, {...row }); |
| | | xGrid.value.reloadData(produceList.value); |
| | | } |
| | | }); |
| | | } else { |
| | | ElMessage.warning('当前工程状态不符合撤销模拟计算条件,请确认工程状态后再操作!'); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //定义工程状态 |
| | | const optionVal = ref('') |
| | | const optionVal = ref('all') |
| | | const options = [ |
| | | { |
| | | value: '0', |
| | | value: 'all', |
| | | label: '全部', |
| | | }, |
| | | { |
| | |
| | | label: '第一次优化', |
| | | }, |
| | | { |
| | | value: '3', |
| | | value: '10', |
| | | label: '模拟计算保存', |
| | | }, |
| | | { |
| | | value: '4', |
| | | value: '20', |
| | | label: '优化保存', |
| | | }, |
| | | { |
| | | value: '5', |
| | | value: '100', |
| | | label: '完成优化', |
| | | }, |
| | | { |
| | | value: '6', |
| | | value: '200', |
| | | label: '已领取', |
| | | }, |
| | | ] |
| | | |
| | | //工程状态函数 |
| | | function handleOptionChange() { |
| | | if (optionVal.value === 'all') { |
| | | // 清空工程状态相关的已有筛选条件 |
| | | delete filterData.value['state']; |
| | | } else { |
| | | filterData.value['state'] = optionVal.value; // 明确添加选择的工程状态值到筛选条件中 |
| | | } |
| | | getWorkOrder(); |
| | | } |
| | | |
| | | //公共函数 |
| | | function buildRequestParams() { |
| | |
| | | |
| | | //筛选条件 |
| | | let filterData = ref({ |
| | | projectNumber: '', |
| | | projectNumber: '', |
| | | }) |
| | | // 定义数据返回结果,使用ref创建响应式数据,初始化为空数组 |
| | | let produceList = ref([]) |
| | | |
| | | // 获取七天前到当前时间 |
| | | // 获取15天前到当前时间 |
| | | function getNowTime() { |
| | | const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 15) |
| | | .toISOString() |
| | | .replace('T', ' ') |
| | | .slice(0, 10) //默认开始时间7天前 |
| | | .slice(0, 10) //默认开始时间15天前 |
| | | const end = new Date(new Date().getTime()) |
| | | .toISOString() |
| | | .replace('T', ' ') |
| | |
| | | return [start, end] |
| | | } |
| | | |
| | | // 初始化时间范围,若为空则设为近七天时间 |
| | | // 初始化时间范围,若为空则设为近15天时间 |
| | | if (orderInfo.workOrderDate[0] === "" && orderInfo.workOrderDate[1] === "") { |
| | | orderInfo.workOrderDate = getNowTime(); |
| | | } |
| | |
| | | //筛选条件发生变化条件发生变化 |
| | | let value = column.datas[0] != undefined ? column.datas[0] : '' |
| | | value = value.trim(); |
| | | //判断是否存在外键 |
| | | if (column.property.indexOf('.') > -1) { |
| | | const columnArr = column.property.split('.') |
| | | filterData.value[columnArr[0]] = { |
| | | [columnArr[1]]: value |
| | | //判断是否为工程状态列的筛选改变(假设工程状态字段名为'state',可根据实际情况调整) |
| | | if (column.property === 'state') { |
| | | if (value === 'all') { |
| | | // 如果选择的是全部,从筛选数据中删除此条件,避免传递给后端干扰获取全部数据 |
| | | delete filterData.value['state']; |
| | | } else { |
| | | filterData.value['state'] = value; |
| | | } |
| | | } else { |
| | | filterData.value[column.property] = value |
| | | //判断是否存在外键 |
| | | if (column.property.indexOf('.') > -1) { |
| | | const columnArr = column.property.split('.'); |
| | | filterData.value[columnArr[0]] = { |
| | | [columnArr[1]]: value, |
| | | }; |
| | | } else { |
| | | filterData.value[column.property] = value; |
| | | } |
| | | } |
| | | |
| | | const params = buildRequestParams(); |
| | | console.log('即将发送给后端的筛选参数:', filterData.value); |
| | | request.post(`/glassOptimize/optimizeProjectMange/${params.startSelectTime}/${params.endSelectTime}`, filterData.value).then((res) => { |
| | | console.log('已收到服务器响应,响应码:', res.code); |
| | | console.log('响应数据:', res.data); |
| | | if (res.code == 200) { |
| | | produceList = deepClone(res.data.data) |
| | | produceList.value = deepClone(res.data.data); |
| | | xGrid.value.reloadData(produceList) |
| | | gridOptions.loading=false |
| | | gridOptions.loading = false |
| | | } else { |
| | | ElMessage.warning(res.msg) |
| | | } |
| | |
| | | } |
| | | }); |
| | | }; |
| | | // 计算小片数量 |
| | | const smallPieceQuantityInput = computed(() => { |
| | | return produceList.value.reduce((acc, item) => acc + item.quantity, 0); |
| | | }); |
| | | // 计算小片面积 |
| | | const smallPieceAreaInput = computed(() => { |
| | | const sum = produceList.value.reduce((acc, item) => acc + item.area, 0); |
| | | return Number(sum.toFixed(2)); // 先使用toFixed保留两位小数,再转换回数值类型(因为toFixed返回字符串) |
| | | }); |
| | | |
| | | // 计算原片数量 |
| | | const originalPieceQuantityInput = computed(() => { |
| | | return produceList.value.reduce((acc, item) => acc + item.usingQuantity, 0); |
| | | }); |
| | | |
| | | // 原片面积固定为0,直接返回0 |
| | | const originalPieceAreaInput = 0; |
| | | |
| | | |
| | | </script> |
| | | |
| | | <template> |
| | | <div id="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" |
| | | /> |
| | | <!-- <vxe-input--> |
| | | <!-- style="margin-left:10px; "--> |
| | | <!-- placeholder="输入工程号或流程卡号"--> |
| | | <!-- >--> |
| | | <!-- </vxe-input>--> |
| | | |
| | | <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="getWorkOrder" |
| | | > |
| | | |
| | | <el-option |
| | | v-for="item in options" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | <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" |
| | | /> |
| | | </el-select> |
| | | <!--查询--> |
| | | <el-button |
| | | style="margin-left:10px;margin-top: -5px" |
| | | :icon="Search" |
| | | type="primary" |
| | | @click="getWorkOrder">{{ $t('basicData.search') }} |
| | | </el-button> |
| | | </div> |
| | | <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" |
| | | @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> |
| | | <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> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | </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)"/> |
| | | <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> |
| | | </div> |
| | | </template> |
| | | </vxe-grid> |
| | | <div id="last"> |
| | | <span> |
| | | 小片数<vxe-input size="small" class="input" disabled></vxe-input> |
| | | 小片面<vxe-input size="small" class="input" disabled></vxe-input> |
| | | 原片数<vxe-input size="small" class="input" disabled></vxe-input> |
| | | 原片面<vxe-input size="small" class="input" disabled></vxe-input> |
| | | </span> |
| | | </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> |
| | | </div> |
| | | </template> |
| | |
| | | |
| | | .input { |
| | | width: 80px; |
| | | margin-left: 15px; |
| | | margin-left: 10px; |
| | | } |
| | | </style> |