<script setup>
|
|
import request from "@/utils/request"
|
import deepClone from "@/utils/deepClone"
|
import {ElDatePicker, ElMessage} from "element-plus"
|
import useProductGlassTypeStore from "@/stores/sd/product/productGlassType"
|
import {nextTick, onMounted, onUnmounted, reactive, ref, watch} from "vue"
|
import {Search} from "@element-plus/icons-vue"
|
import GlassType from "@/components/sd/product/GlassType.vue"
|
import {useRouter} from 'vue-router'
|
import Sortable from 'sortablejs'
|
import BasicTable from '@/components/sd/product/BasicTable.vue'
|
import {VXETable} from "vxe-table";
|
import useUserInfoStore from "@/stores/userInfo";
|
import {addListener, toolbarButtonClickEvent} from "@/hook/mouseMove";
|
import {useI18n} from 'vue-i18n'
|
import footSum from "@/hook/footSum"
|
import useOrderInfoStore from "@/stores/sd/order/orderInfo"
|
|
//语言获取
|
const {t} = useI18n()
|
|
let router = useRouter()
|
const userStore = useUserInfoStore()
|
const username = userStore.user.userName
|
const orderInfo = useOrderInfoStore()
|
|
const getTableRow = (row, type) => {
|
switch (type) {
|
case 'edit' : {
|
//alert('我接收到子组件传送的编辑信息')
|
router.push({path: '/main/processCard/PrintFlowCard', query: {id: row.id}})
|
break
|
}
|
|
}
|
}
|
|
|
//工序
|
const processVal = ref(t('machine.cutting'))
|
|
|
//排产状态
|
const stateValue = ref('1')
|
const stateOptions = [
|
{
|
value: '2',
|
label: t('processCard.ProductionSchedulingOk'),
|
},
|
{
|
value: '1',
|
label: t('processCard.ProductionSchedulingNo'),
|
},
|
]
|
|
//定义表单值
|
const form = reactive({
|
date1: '',
|
orderId: ''
|
})
|
|
//定义接收加载表头下拉数据
|
const titleSelectJson = ref({
|
processType: [],
|
})
|
|
|
//筛选条件,有外键需要先定义明细里面的数据
|
let filterData = ref({
|
order: {
|
project: ''
|
},
|
orderDetail: {
|
productId: '',
|
productName: '',
|
computeGrossArea: '',
|
processingNote: '',
|
}
|
|
})
|
//定义页面总页数
|
let pageTotal = ref('')
|
//定义数据返回结果
|
let produceList = ref([])
|
//定义当前页数
|
let pageNum = ref(1)
|
let pageState = null
|
let total = reactive({
|
pageTotal: 0,
|
dataTotal: 0,
|
pageSize: 100
|
})
|
|
//获取七天前到当前时间
|
function getNowTime() {
|
const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 15)
|
.toISOString()
|
.replace('T', ' ')
|
.slice(0, 10) //默认开始时间3天前
|
const end = new Date(new Date().getTime())
|
.toISOString()
|
.replace('T', ' ')
|
.slice(0, 10)//默认结束时间当前时间
|
return [start, end]
|
}
|
|
onMounted(() => {
|
//启用表格拖动选中
|
addListener(xGrid.value, gridOptions)
|
})
|
|
//第一次加载获取近3天时间和默认状态
|
if (orderInfo.workOrderDate[0]=="" && orderInfo.workOrderDate[1]==""){
|
orderInfo.workOrderDate=getNowTime()
|
}
|
let startTime = orderInfo.workOrderDate[0]
|
let endTime = orderInfo.workOrderDate[1]
|
let selectProcesses = processVal.value
|
let inputVal = form.orderId
|
if (inputVal == '') {
|
inputVal = null
|
}
|
if (selectProcesses == '') {
|
selectProcesses = null
|
}
|
//第一次加载数据
|
request.post(`/productionScheduling/selectLastScheduling/${startTime}/${endTime}/${selectProcesses}/${inputVal}`, filterData.value).then((res) => {
|
|
if (res.code == 200) {
|
pageTotal.value = res.data.total
|
produceList = produceList.value.concat(deepClone(res.data.data))
|
titleSelectJson.value.processType = res.data.process
|
|
gridOptions.loading = false
|
//禁用删除、审核按钮
|
gridOptions.toolbarConfig.buttons[0].disabled = true
|
gridOptions.toolbarConfig.buttons[1].disabled = true
|
gridOptions.toolbarConfig.buttons[2].disabled = true
|
} else {
|
ElMessage.warning(res.msg)
|
}
|
})
|
|
//点击时查询
|
const getWorkOrder = () => {
|
let startTime = orderInfo.workOrderDate[0]
|
let endTime = orderInfo.workOrderDate[1]
|
let selectProcesses = processVal.value
|
let selectState = stateValue.value
|
let inputVal = form.orderId
|
if (inputVal == '') {
|
inputVal = null
|
}
|
if (selectProcesses == '') {
|
selectProcesses = null
|
}
|
//根据工序查询未排产数据
|
request.post(`/productionScheduling/selectScheduling/${pageNum.value}/${total.pageSize}/${startTime}/${endTime}/${inputVal}/${selectProcesses}/${selectState}`, filterData.value).then((res) => {
|
if (res.code == 200) {
|
total.dataTotal = res.data.total.total * 1
|
total.pageTotal = res.data.total.pageTotal
|
pageTotal.value = res.data.total
|
xGrid.value.loadData(res.data.data)
|
gridOptions.loading = false
|
if (selectState==1){
|
//禁用删除、审核按钮
|
gridOptions.toolbarConfig.buttons[0].disabled = true
|
gridOptions.toolbarConfig.buttons[1].disabled = true
|
gridOptions.toolbarConfig.buttons[2].disabled = true
|
//启用保存
|
gridOptions.toolbarConfig.buttons[3].disabled = false
|
}else{
|
//启用删除、审核按钮
|
gridOptions.toolbarConfig.buttons[0].disabled = false
|
gridOptions.toolbarConfig.buttons[1].disabled = false
|
gridOptions.toolbarConfig.buttons[2].disabled = false
|
//禁用保存
|
gridOptions.toolbarConfig.buttons[3].disabled = true
|
|
}
|
} else {
|
ElMessage.warning(res.msg)
|
}
|
})
|
|
|
}
|
|
/*使用筛选,后端获取数据*/
|
const changeFilterEvent = (event, option, $panel,) => {
|
// 手动触发筛选
|
$panel.changeOption(event, !!option.data, option)
|
}
|
|
function filterChanged(column) {
|
gridOptions.loading = true
|
//筛选条件发生变化条件发生变化
|
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
|
}
|
} else {
|
filterData.value[column.property] = value
|
}
|
|
//获取选中时间
|
let startTime = orderInfo.workOrderDate[0]
|
let endTime = orderInfo.workOrderDate[1]
|
let selectProcesses = processVal.value
|
let selectState = stateValue.value
|
let inputVal = form.orderId
|
if (inputVal == '') {
|
inputVal = null
|
}
|
if (selectProcesses == '') {
|
selectProcesses = null
|
}
|
request.post(`/productionScheduling/selectScheduling/1/${total.pageSize}/${startTime}/${endTime}/${inputVal}/${selectProcesses}/${selectState}`, filterData.value).then((res) => {
|
if (res.code == 200) {
|
total.dataTotal = res.data.total.total * 1
|
total.pageTotal = parseInt(res.data.total)
|
pageNum.value = 1
|
xGrid.value.loadData(res.data.data)
|
gridOptions.loading = false
|
} else {
|
ElMessage.warning(res.msg)
|
}
|
})
|
}
|
|
/*后端返回结果多层嵌套展示*/
|
const hasDecimal = (value) => {
|
const regex = /\./; // 定义正则表达式,查找小数点
|
return regex.test(value); // 返回true/false
|
}
|
|
|
//子组件接收参数
|
const xGrid = ref()
|
const gridOptions = reactive({
|
loading: true,
|
border: "full",//表格加边框
|
keepSource: true,//保持源数据
|
align: 'center',//文字居中
|
stripe: true,//斑马纹
|
rowConfig: {isCurrent: true, isHover: true, height: 30},//鼠标移动或选择高亮
|
id: 'productionScheduling',
|
showFooter: true,//显示脚
|
printConfig: {},
|
importConfig: {},
|
exportConfig: {},
|
scrollY: {enabled: true},//开启虚拟滚动
|
showOverflow: true,
|
columnConfig: {
|
resizable: true,
|
useKey: true
|
},
|
filterConfig: { //筛选配置项
|
remote: true
|
},
|
customConfig: {
|
storage: true
|
},
|
editConfig: {
|
trigger: 'dblclick',
|
mode: 'row',
|
showStatus: 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
|
},
|
{
|
code: 'clearChecked',
|
name: t('basicData.clearSelection'),
|
prefixIcon: 'vxe-icon-indicator',
|
visible: true,
|
disabled: false
|
},
|
]
|
]
|
}
|
},
|
//表头参数
|
columns: [
|
{type: 'expand',fixed: "left", slots: {content: 'content'}, width: 50},
|
{type: 'seq', fixed: "left", title: t('basicData.Number'), width: 50},
|
{type: 'checkbox', fixed: "left", title: t('basicData.check'), width: 80},
|
{
|
field: 'scheduledStartTime',
|
width: 130,
|
editRender: {name: 'input', attrs: {placeholder: '', type: 'date'},},
|
title: t('processCard.scheduledStartTime')
|
},
|
{
|
field: 'planEndTime',
|
width: 130,
|
editRender: {name: 'input', attrs: {placeholder: '', type: 'date'}},
|
title: t('processCard.planEndTime')
|
},
|
{
|
field: 'schedulingQuantity',
|
width: 120,
|
editRender: {name: 'input', attrs: {placeholder: ''}},
|
title: t('processCard.productionSchedulingQuantity'),
|
sortable: true
|
},
|
{field: 'notes', title: t('processCard.notes'), editRender: {name: 'input', attrs: {placeholder: ''}}, width: 120},
|
|
// {field: '排产编号', title: '排产编号', width: 120 },
|
{
|
field: 'order.orderId',
|
title: t('order.orderId'),
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
width: 110,
|
},
|
{
|
field: 'order.customerName',
|
title: t('processCard.customerName'),
|
width: 110,
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
},
|
{
|
field: 'order.project',
|
title: t('order.project'),
|
width: 100,
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
},
|
{
|
field: 'orderNumber',
|
title: t('order.OrderNum'),
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
width: 100,
|
},
|
{
|
field: 'technologyNumber',
|
title: t('processCard.technologyNumber'),
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
width: 100,
|
},
|
{
|
field: 'orderGlassDetail.childWidth',
|
title: t('order.width'),
|
width: 60,
|
},
|
{
|
field: 'orderGlassDetail.childHeight',
|
title: t('order.height'),
|
width: 60,
|
},
|
{field: 'orderDetail.quantity', title: t('processCard.orderQuantity'), width: 90},
|
{field: 'orderGlassDetail.area', title: t('processCard.orderArea'), width: 90},
|
|
{field: 'pendingProductionQuantity', title: t('processCard.quantityToScheduled'), width: 100},
|
{field: 'pendingProductionArea', title: t('processCard.areaToScheduled'), width: 100},
|
{field: 'productionScheduledQuantity', title: t('processCard.plannedProductionQuantity'), width: 100},
|
{field: 'productionScheduledArea', title: t('processCard.plannedProductionArea'), width: 100},
|
{field: 'reviewStatus', title: t('processCard.reviewedState'), width: 80},
|
{field: 'reviewer', title: t('processCard.reviewed'), width: 80},
|
{field: 'orderDetail.productName', title: t('order.product'), width: 140},
|
{field: 'orderDetail.shape', title: t('order.shape'), width: 80},
|
{field: 'schedulingId', title: t('processCard.schedulingId'), width: 120},
|
],//表头按钮
|
|
toolbarConfig: {
|
buttons: [
|
{code: 'delete', name: t('basicData.delete'), status: 'primary'},
|
{code: 'review', name: t('basicData.review'), status: 'primary'},
|
{code: 'cancelReview', name: t('basicData.cancelReview'), status: 'primary'},
|
{code: 'save', name: t('processCard.scheduling'), status: 'primary', icon: 'vxe-icon-save'},
|
],
|
import: false,
|
// export: true,
|
// print: true,
|
zoom: true,
|
custom: true
|
},
|
data: [],//table body实际数据
|
//脚部求和
|
footerMethod({columns, data}) {//页脚函数
|
return [
|
columns.map((column, columnIndex) => {
|
if (columnIndex === 0) {
|
return t('basicData.total')
|
}
|
const List =
|
["orderDetail.quantity", 'orderGlassDetail.area', 'pendingProductionQuantity',
|
'pendingProductionArea', 'productionScheduledQuantity', 'productionScheduledArea']
|
if (List.includes(column.field)) {
|
return footSum(data, column.field)
|
}
|
return ''
|
})
|
]
|
}
|
|
})
|
|
//表格按钮
|
const gridEvents = {
|
async toolbarButtonClick({code}) {
|
const $grid = xGrid.value
|
if ($grid) {
|
switch (code) {
|
case 'save': {
|
const $table = xGrid.value
|
if ($table) {
|
const selectRecords = $table.getCheckboxRecords()
|
if (selectRecords.length == 0) {
|
ElMessage.warning(t('processCard.checkProductionScheduling'))
|
return;
|
}
|
for (let i = 0; i < selectRecords.length; i++) {
|
let start = selectRecords[i].scheduledStartTime
|
let end = selectRecords[i].planEndTime
|
let number = selectRecords[i].schedulingQuantity
|
//计划开始、结束时间,排产数量不能为空
|
if (start == null || end == null || number == null) {
|
ElMessage.warning(t('processCard.saveCorrespondingValues'))
|
return;
|
}
|
}
|
let selectProcesses = processVal.value
|
if (selectProcesses == null || selectProcesses == "") {
|
ElMessage.warning(t('processCard.selectProductionSchedulingProcess'))
|
return;
|
}
|
|
let schedulingData = ref({
|
scheduling: selectRecords,
|
processes: selectProcesses,//工序
|
userName: username//审核人
|
})
|
//禁用保存
|
gridOptions.toolbarConfig.buttons[2].disabled = true
|
//保存排产数据
|
request.post("/productionScheduling/addScheduling", schedulingData.value).then((res) => {
|
if (res.code == 200) {
|
ElMessage.success(t('basicData.msg.saveSuccess'))
|
// 启用保存
|
gridOptions.toolbarConfig.buttons[2].disabled = false
|
router.push({
|
path: '/main/processCard/ProductionScheduling',
|
query: {random: Math.random()}
|
})
|
} else {
|
// 启用保存
|
gridOptions.toolbarConfig.buttons[2].disabled = false
|
ElMessage.warning(res.msg)
|
|
}
|
})
|
|
}
|
return;
|
|
}
|
|
case 'delete': {
|
const $table = xGrid.value
|
const selectRecords = $table.getCheckboxRecords()
|
if ($table) {
|
if (selectRecords.length == 0) {
|
ElMessage.warning(t('processCard.checkProductionScheduling'))
|
return;
|
}
|
|
const type = await VXETable.modal.confirm(t('processCard.deleteThisData'))
|
if (type === 'confirm') {
|
let schedulingData = ref({
|
scheduling: selectRecords,
|
})
|
|
request.post("/productionScheduling/deleteScheduling", schedulingData.value).then((res) => {
|
if (res.code == 200) {
|
ElMessage.success(t('basicData.msg.deleteSuccess'))
|
location.reload();
|
} else {
|
ElMessage.warning(res.msg)
|
|
}
|
})
|
}
|
}
|
return;
|
}
|
case 'review': {
|
const $table = xGrid.value
|
const selectRecords = $table.getCheckboxRecords()
|
let date = form.date1
|
let selectProcesses = processVal.value
|
let selectState = stateValue.value
|
let inputVal = form.orderId
|
if ($table) {
|
if (selectRecords.length == 0) {
|
ElMessage.warning(t('processCard.checkProductionScheduling'))
|
return;
|
}
|
let schedulingData = ref({
|
scheduling: selectRecords,
|
userName: username//审核人
|
})
|
request.post("/productionScheduling/examineScheduling", schedulingData.value).then((res) => {
|
if (res.code == 200) {
|
ElMessage.success(t('basicData.msg.ReviewSuccess'))
|
router.push({
|
path: '/main/processCard/ProductionScheduling',
|
query: {random: Math.random()}
|
})
|
} else {
|
ElMessage.warning(res.msg)
|
|
}
|
})
|
|
}
|
return;
|
}
|
case 'cancelReview': {
|
const $table = xGrid.value
|
const selectRecords = $table.getCheckboxRecords()
|
if ($table) {
|
if (selectRecords.length == 0) {
|
ElMessage.warning(t('processCard.checkProductionScheduling'))
|
return;
|
}
|
let schedulingData = ref({
|
scheduling: selectRecords,
|
userName: username//审核人
|
})
|
request.post("/productionScheduling/cancelReviewScheduling", schedulingData.value).then((res) => {
|
if (res.code == 200) {
|
ElMessage.success(t('basicData.msg.cancelReviewSuccess'))
|
location.reload();
|
} else {
|
ElMessage.warning(res.msg)
|
|
}
|
})
|
|
}
|
return;
|
}
|
}
|
}
|
},
|
menuClick({menu, row, column}) {
|
const $grid = xGrid.value
|
if ($grid) {
|
switch (menu.code) {
|
case 'copyChecked' : {
|
let result = toolbarButtonClickEvent()
|
if (result.cell === "scheduledStartTime" || result.cell === "planEndTime" || result.cell === "schedulingQuantity"){
|
if (result) {
|
const dataList = xGrid.value.getTableData().visibleData
|
const val = dataList[result.start][result.cell]
|
dataList.forEach((item, index) => {
|
if (index >= result.start && index <= result.end) {
|
item[result.cell] = val
|
}
|
})
|
}
|
}
|
|
break
|
}
|
case 'copyAll' : {
|
let result = toolbarButtonClickEvent()
|
if (result.cell === "scheduledStartTime" || result.cell === "planEndTime"|| result.cell === "schedulingQuantity") {
|
if (result) {
|
const dataList = xGrid.value.getTableData().visibleData
|
const val = dataList[result.start][result.cell]
|
dataList.forEach((item, index) => {
|
if (index >= result.start) {
|
item[result.cell] = val
|
}
|
})
|
}
|
}
|
break
|
}
|
case 'clearChecked' : {
|
let result = toolbarButtonClickEvent()
|
if (result.cell === "scheduledStartTime" || result.cell === "planEndTime"|| result.cell === "schedulingQuantity") {
|
if (result) {
|
const dataList = xGrid.value.getTableData().visibleData
|
dataList.forEach((item, index) => {
|
if (index >= result.start && index <= result.end) {
|
item[result.cell] = ''
|
}
|
})
|
}
|
}
|
break
|
}
|
}
|
}
|
},
|
}
|
|
const determineNum = () => {
|
const $grid = xGrid.value
|
const table = $grid.getTableData().fullData
|
const selectRecords = $grid.getCheckboxRecords()
|
let selectState = stateValue.value
|
selectRecords.forEach((selectRecords) => {
|
if (selectRecords.schedulingQuantity > selectRecords.pendingProductionQuantity) {
|
ElMessage.warning(ElMessage.warning(t('processCard.schedulingQuantityNoQuantityScheduled')))
|
//禁用保存按钮
|
//gridOptions.toolbarConfig.buttons[2].disabled = true
|
}
|
})
|
}
|
const checkBoxConfig = {
|
checkMethod: ({ row }) => {
|
if (row['reviewStatus']==="已审核"){
|
return row.disable
|
}else{
|
return !row.disable
|
}
|
|
},
|
reserve:true
|
|
}
|
|
</script>
|
|
<template>
|
<div style="width: 100%;height: 100%">
|
<div class="head">
|
<el-date-picker
|
v-model="orderInfo.workOrderDate"
|
:default-time="defaultTime"
|
:start-placeholder="$t('basicData.startDate')"
|
:end-placeholder="$t('basicData.endDate')"
|
format="YYYY/MM/DD"
|
type="daterange"
|
value-format="YYYY-MM-DD"
|
|
/>
|
|
<el-input v-model="form.orderId" :placeholder="$t('order.orderId')" clearable style="width: 110px"></el-input>
|
|
<el-select v-model="processVal" clearable default-value="default_city" style="width: 120px">
|
<el-option
|
v-for="item in titleSelectJson['processType']"
|
:key="item.id"
|
:label="item.basic_name"
|
:value="item.basic_name"
|
/>
|
</el-select>
|
|
<el-select v-model="stateValue" class="m-2" :placeholder="$t('processCard.whetherToScheduleProduction')" style="width: 120px">
|
<el-option
|
v-for="item in stateOptions"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
|
<el-button
|
id="select"
|
:icon="Search"
|
type="primary" @click="getWorkOrder">{{ $t('basicData.search') }}
|
</el-button>
|
|
</div>
|
<div class="main-table">
|
<vxe-grid
|
ref="xGrid"
|
class="mytable-scrollbar"
|
height="100%"
|
v-bind="gridOptions"
|
v-on="gridEvents"
|
@filter-change="filterChanged"
|
|
|
>
|
<!-- :checkbox-config="checkBoxConfig" @checkbox-change="determineNum"-->
|
<!-- 下拉显示所有信息插槽-->
|
<template #content="{ row }">
|
<ul class="expand-wrapper">
|
<li v-for="(item,index) in gridOptions.columns" v-show="item.field!=undefined ">
|
<span style="font-weight: bold">{{ item.title + ': ' }}</span>
|
<span v-if="hasDecimal(item.field)">{{ row[item.field.split('.')[0]][item.field.split('.')[1]] }}</span>
|
<span v-else>{{ row[item.field] }}</span>
|
|
</li>
|
</ul>
|
</template>
|
<template #num1_filter="{ column, $panel }">
|
<div>
|
<div v-for="(option, index) in column.filters" :key="index">
|
<input v-model="option.data" type="type"
|
@keyup.enter.native="$panel.confirmFilter()"
|
@input="changeFilterEvent($event, option, $panel)"/>
|
</div>
|
</div>
|
</template>
|
<template #pager>
|
<!--使用 pager 插槽-->
|
<!-- 'PrevJump','NextJump', -->
|
<vxe-pager
|
v-model:current-page="pageNum"
|
v-model:page-size="total.pageSize"
|
v-model:pager-count="total.pageTotal"
|
:layouts="[ 'PrevPage', 'Jump','PageCount', 'NextPage', 'Total']"
|
:total="total.dataTotal"
|
@page-change="handlePageChange"
|
>
|
</vxe-pager>
|
</template>
|
|
</vxe-grid>
|
</div>
|
</div>
|
|
</template>
|
|
<style scoped>
|
.head{
|
width: 100%;
|
height: 35px;
|
}
|
|
.main-table{
|
width: 100%;
|
height: calc(100% - 35px);
|
}
|
|
.vxe-grid {
|
/* 禁用浏览器默认选中 */
|
-webkit-user-select: none;
|
-moz-user-select: none;
|
-ms-user-select: none;
|
user-select: none;
|
}
|
</style>
|