<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/basic/BasicTable.vue'
|
import {VXETable} from "vxe-table";
|
import useUserInfoStore from "@/stores/userInfo";
|
import {changeFilterEvent, filterChanged} from "@/hook"
|
import {addListener,toolbarButtonClickEvent} from "@/hook/mouseMove";
|
import { useI18n } from 'vue-i18n'
|
//语言获取
|
const { t } = useI18n()
|
|
let router = useRouter()
|
const userStore = useUserInfoStore()
|
const username = userStore.user.userName
|
const getTableRow = (row, type) => {
|
switch (type) {
|
case 'edit' : {
|
//alert('我接收到子组件传送的编辑信息')
|
router.push({path: '/main/processCard/PrintFlowCard', query: {id: row.id}})
|
break
|
}
|
|
case 'setType': {
|
alert('我接收到子组件传送的排版状态')
|
break
|
}
|
}
|
}
|
|
|
//工序
|
const value = ref('切割')
|
|
|
//排产状态
|
const stateValue = ref('1')
|
const stateOptions = [
|
{
|
value: '2',
|
label: t('processCard.ProductionSchedulingOk'),
|
},
|
{
|
value: '1',
|
label: t('processCard.ProductionSchedulingNo'),
|
},
|
]
|
|
function padLeftZero(str) {
|
return ('00' + str).substr(str.length)
|
}
|
|
//定义表单值
|
const form = reactive({
|
date1: '',
|
orderId: ''
|
})
|
|
//定义接收加载表头下拉数据
|
const titleSelectJson = ref({
|
processType: [],
|
})
|
|
|
//表尾求和
|
const sumNum = (list, field) => {
|
let count = 0
|
list.forEach(item => {
|
count += Number(item[field])
|
})
|
return count.toFixed(2)
|
}
|
|
//定义滚动条高度
|
let scrollTop = ref(null)
|
let scrollHeight = ref(null)
|
let clientHeight = ref(null)
|
const scrollEvnt = (row) => {
|
// 内容高度
|
scrollTop.value = row.$event.target.scrollTop
|
scrollHeight.value = row.$event.target.scrollHeight
|
clientHeight.value = row.$event.target.clientHeight
|
}
|
//筛选条件,有外键需要先定义明细里面的数据
|
let filterData = ref({
|
order: {
|
project: ''
|
},
|
orderDetail: {
|
productId: '',
|
productName: '',
|
computeGrossArea: '',
|
processingNote: '',
|
}
|
|
})
|
//定义页面总页数
|
let pageTotal = ref('')
|
//定义数据返回结果
|
let produceList = ref([])
|
//定义当前页数
|
let pageNum = $ref(1)
|
let pageState = null
|
|
|
//获取七天前到当前时间
|
function getNowTime() {
|
const start = new Date(new Date().getTime() - 3600 * 1000 * 24 * 3)
|
.toISOString()
|
.replace('T', ' ')
|
.slice(0, 10) //默认开始时间3天前
|
const end = new Date(new Date().getTime() + 3600 * 1000 * 24)
|
.toISOString()
|
.replace('T', ' ')
|
.slice(0, 10)//默认结束时间当前时间
|
return [start, end]
|
}
|
|
onMounted(()=>{
|
//启用表格拖动选中
|
addListener(xGrid.value,gridOptions)
|
})
|
|
//第一次加载获取近3天时间和默认状态
|
form.date1 = getNowTime()
|
let startTime = form.date1[0]
|
let endTime = form.date1[1]
|
let selectProcesses = value.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
|
xGrid.value.reloadData(produceList)
|
gridOptions.loading = false
|
//禁用删除、保存按钮
|
gridOptions.toolbarConfig.buttons[0].disabled = true
|
gridOptions.toolbarConfig.buttons[1].disabled = true
|
} else {
|
ElMessage.warning(res.msg)
|
}
|
})
|
|
//点击时查询
|
const getWorkOrder = () => {
|
let startTime = form.date1[0]
|
let endTime = form.date1[1]
|
let selectProcesses = value.value
|
let selectState = stateValue.value
|
let inputVal = form.orderId
|
if (inputVal == '') {
|
inputVal = null
|
}
|
if (selectProcesses == '') {
|
selectProcesses = null
|
}
|
if (inputVal == null && selectState == 1) {
|
//根据时间查询未排产数据
|
request.post(`/productionScheduling/selectLastScheduling/${startTime}/${endTime}/${selectProcesses}/${inputVal}`, filterData.value).then((res) => {
|
|
if (res.code == 200) {
|
pageTotal.value = res.data.total
|
xGrid.value.loadData(res.data.data)
|
gridOptions.loading = false
|
//禁用删除、审核按钮
|
gridOptions.toolbarConfig.buttons[0].disabled = true
|
gridOptions.toolbarConfig.buttons[1].disabled = true
|
//启用保存
|
gridOptions.toolbarConfig.buttons[2].disabled = false
|
} else {
|
ElMessage.warning(res.msg)
|
}
|
})
|
} else if (inputVal != null && selectState == 1) {
|
//根据工序查询未排产数据
|
request.post(`/productionScheduling/selectScheduling/${startTime}/${endTime}/${inputVal}/${selectProcesses}/${selectState}`, filterData.value).then((res) => {
|
if (res.code == 200) {
|
pageTotal.value = res.data.total
|
xGrid.value.loadData(res.data.data)
|
gridOptions.loading = false
|
//禁用删除、审核按钮
|
gridOptions.toolbarConfig.buttons[0].disabled = true
|
gridOptions.toolbarConfig.buttons[1].disabled = true
|
//启用保存
|
gridOptions.toolbarConfig.buttons[2].disabled = false
|
} else {
|
ElMessage.warning(res.msg)
|
}
|
})
|
} else if (inputVal == null && selectState == 2) {
|
//根据时间查询已排产数据
|
request.post(`/productionScheduling/selectScheduling/${startTime}/${endTime}/${inputVal}/${selectProcesses}/${selectState}`, filterData.value).then((res) => {
|
if (res.code == 200) {
|
pageTotal.value = res.data.total
|
xGrid.value.loadData(res.data.data)
|
gridOptions.loading = false
|
//启用删除、审核按钮
|
gridOptions.toolbarConfig.buttons[0].disabled = false
|
gridOptions.toolbarConfig.buttons[1].disabled = false
|
//禁用保存
|
gridOptions.toolbarConfig.buttons[2].disabled = true
|
} else {
|
ElMessage.warning(res.msg)
|
}
|
})
|
} else if (inputVal != null && selectState == 2) {
|
//根据订单号查询已排产数据
|
request.post(`/productionScheduling/selectSchedulingNot/${startTime}/${endTime}/${inputVal}/${selectProcesses}/${selectState}`, filterData.value).then((res) => {
|
if (res.code == 200) {
|
pageTotal.value = res.data.total
|
xGrid.value.loadData(res.data.data)
|
gridOptions.loading = false
|
//启用删除、审核按钮
|
gridOptions.toolbarConfig.buttons[0].disabled = false
|
gridOptions.toolbarConfig.buttons[1].disabled = false
|
//禁用保存
|
gridOptions.toolbarConfig.buttons[2].disabled = true
|
} 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: 'CustomerList',
|
showFooter: true,//显示脚
|
printConfig: {},
|
importConfig: {},
|
exportConfig: {},
|
scrollY: {enabled: true},//开启虚拟滚动
|
showOverflow: true,
|
columnConfig: {
|
resizable: true,
|
useKey: true
|
},
|
filterConfig: { //筛选配置项
|
// remote: true
|
},
|
customConfig: {
|
storage: true
|
},
|
|
editConfig: {
|
trigger: 'click',
|
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: 'checkbox', fixed: "left", title: t('basicData.check'), width: 80},
|
{type: 'seq', fixed: "left", title: t('basicData.Number'), width: 50},
|
{
|
field: 'scheduled_start_time',
|
width: 120,
|
editRender: {name: 'input', attrs: {placeholder: '', type: 'date'}},
|
title: t('processCard.scheduledStartTime')
|
},
|
{
|
field: 'plan_end_time',
|
width: 120,
|
editRender: {name: 'input', attrs: {placeholder: '', type: 'date'}},
|
title: t('processCard.planEndTime')
|
},
|
// {field: '排产编号', title: '排产编号', width: 120 },
|
{
|
field: 'order_id',
|
title: t('order.orderId'),
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
width: 100,
|
filterMethod: filterChanged
|
},
|
{
|
field: 'customer_name',
|
title: t('processCard.customerName'),
|
width: 110,
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
filterMethod: filterChanged
|
},
|
{
|
field: 'project',
|
title: t('order.project'),
|
width: 100,
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
filterMethod: filterChanged
|
},
|
{
|
field: 'order_number',
|
title: t('order.OrderNum'),
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
width: 70,
|
filterMethod: filterChanged
|
},
|
{
|
field: 'technology_number',
|
title: t('processCard.technologyNumber'),
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
width: 70,
|
filterMethod: filterChanged
|
},
|
{
|
field: 'child_width',
|
title: t('order.width'),
|
width: 60,
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
filterMethod: filterChanged
|
},
|
{
|
field: 'child_height',
|
title: t('order.height'),
|
width: 60,
|
filters: [{data: ''}],
|
slots: {filter: 'num1_filter'},
|
filterMethod: filterChanged
|
},
|
{field: 'quantity', title: t('processCard.orderQuantity'), width: 70},
|
{field: 'area', title: t('processCard.orderArea'), width: 90},
|
{
|
field: 'scheduling_quantity',
|
width: 120,
|
editRender: {name: 'input', attrs: {placeholder: ''}},
|
title: t('processCard.productionSchedulingQuantity'),
|
sortable: true
|
},
|
{field: 'pendingProductionQuantity', title: t('processCard.quantityToScheduled'), width: 120},
|
{field: 'pendingProductionArea', title: t('processCard.areaToScheduled'), width: 120},
|
{field: 'productionScheduledQuantity', title: t('processCard.plannedProductionQuantity'), width: 120},
|
{field: 'productionScheduledArea', title: t('processCard.plannedProductionArea'), width: 120},
|
{field: 'review_status', title: t('processCard.reviewedState'), width: 140},
|
{field: 'reviewer', title: t('processCard.reviewed'), width: 140},
|
{field: 'glass_child', title: t('order.product'), width: 140},
|
{field: 'shape', title: t('order.shape'), width: 80},
|
{field: 'notes', title: t('processCard.notes'), editRender: {name: 'input', attrs: {placeholder: ''}}, width: 120},
|
{field: 'scheduling_id', 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: '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}) {//页脚函数
|
// let footList = ['数量', '面积', '排产数量', '已排产数量', '已排产面积', '未排产数量', '未排产面积']
|
// return [
|
// columns.map((column, columnIndex) => {
|
// if (columnIndex === 0) {
|
// return '合计:'
|
// }
|
// if (footList.includes(column.field)) {
|
// return sumNum(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("请勾选排产数据")
|
return;
|
}
|
for (let i = 0; i < selectRecords.length; i++) {
|
let start = selectRecords[i].scheduled_start_time
|
let end = selectRecords[i].plan_end_time
|
let number = selectRecords[i].scheduling_quantity
|
//计划开始、结束时间,排产数量不能为空
|
if (start == null || end == null || number == null) {
|
ElMessage.warning("请填入对应的值再进行保存")
|
return;
|
}
|
}
|
let selectProcesses = value.value
|
if (selectProcesses == null || selectProcesses == "") {
|
ElMessage.warning("请选择排产工序")
|
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("保存成功")
|
// 启用保存
|
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("请勾选排产数据")
|
return;
|
}
|
const type = await VXETable.modal.confirm('您确定要删除该数据?')
|
if (type === 'confirm') {
|
let schedulingData = ref({
|
scheduling: selectRecords,
|
})
|
|
request.post("/productionScheduling/deleteScheduling", schedulingData.value).then((res) => {
|
if (res.code == 200) {
|
ElMessage.success("删除成功")
|
location.reload();
|
} else {
|
ElMessage.warning(res.msg)
|
|
}
|
})
|
}
|
}
|
return;
|
}
|
case 'review': {
|
const $table = xGrid.value
|
const selectRecords = $table.getCheckboxRecords()
|
if ($table) {
|
if (selectRecords.length == 0) {
|
ElMessage.warning("请勾选排产数据")
|
return;
|
}
|
let schedulingData = ref({
|
scheduling: selectRecords,
|
userName: username//审核人
|
})
|
request.post("/productionScheduling/examineScheduling", schedulingData.value).then((res) => {
|
if (res.code == 200) {
|
ElMessage.success("审核成功")
|
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 === "scheduled_start_time" ||result.cell === "plan_end_time"){
|
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 === "scheduled_start_time" ||result.cell === "plan_end_time") {
|
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 === "scheduled_start_time" ||result.cell === "plan_end_time") {
|
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
|
table.forEach((selectRecords) => {
|
if (selectRecords.scheduling_quantity > selectRecords.pendingProductionQuantity && selectState==1) {
|
ElMessage.warning("排产数量不能大于待排产数量")
|
//禁用保存按钮
|
//gridOptions.toolbarConfig.buttons[2].disabled = true
|
}
|
|
|
})
|
}
|
|
|
</script>
|
|
<template>
|
<div class="main-div-customer">
|
<div id="selectForm">
|
<el-row :gutter="0">
|
<el-date-picker
|
v-model="form.date1"
|
:default-time="defaultTime"
|
end-placeholder="结束时间"
|
format="YYYY/MM/DD"
|
start-placeholder="开始时间"
|
type="daterange"
|
value-format="YYYY-MM-DD"
|
|
/>
|
|
<el-input v-model="form.orderId" clearable :placeholder="$t('order.orderId')" style="width: 110px"></el-input>
|
|
<el-select v-model="value" 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="是否排产" 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>
|
</el-row>
|
|
</div>
|
<vxe-grid
|
ref="xGrid"
|
class="mytable-scrollbar"
|
height="100%"
|
max-height="100%"
|
v-bind="gridOptions"
|
v-on="gridEvents"
|
@filter-change="filterChanged"
|
@checkbox-change="determineNum"
|
>
|
<!-- @toolbar-button-click="toolbarButtonClickEvent"-->
|
<!-- 下拉显示所有信息插槽-->
|
<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" @input="changeFilterEvent($event, option, $panel)"/>
|
</div>
|
</div>
|
</template>
|
|
|
</vxe-grid>
|
</div>
|
<div class="vxe-table--cell-area" ref="cellArea" >
|
<span class="vxe-table--cell-main-area" ></span>
|
|
<span class="vxe-table--cell-active-area" ></span>
|
</div>
|
</template>
|
|
<style scoped>
|
.main-div-customer {
|
width: 99%;
|
height: 100%;
|
}
|
|
#selectForm {
|
width: 70%;
|
height: 6%;
|
text-align: center;
|
}
|
.vxe-grid {
|
/* 禁用浏览器默认选中 */
|
-webkit-user-select: none;
|
-moz-user-select: none;
|
-ms-user-select: none;
|
user-select: none;
|
}
|
</style>
|