<!--成品调拨-->
|
|
|
<script setup>
|
|
import {onMounted, reactive, ref} from "vue";
|
import {useRouter} from 'vue-router'
|
import request from "@/utils/request"
|
import deepClone from "@/utils/deepClone"
|
import userInfo from '@/stores/userInfo'
|
import useUserInfoStore from "@/stores/userInfo";
|
import {ElMessage} from "element-plus";
|
import {addListener,toolbarButtonClickEvent} from "@/hook/mouseMove";
|
import { useI18n } from 'vue-i18n'
|
|
//语言获取
|
const { t } = useI18n()
|
|
const userStore = useUserInfoStore()
|
const username = userStore.user.userName
|
const userid = userStore.user.userId
|
let router=useRouter()
|
let produceList = ref([])
|
let cellArea = ref()
|
const getTableRow = (row,type) =>{
|
switch (type) {
|
case 'edit' :{
|
alert('我接收到子组件传送的编辑信息')
|
// router.push({path: '/main/productStock/OrderAllocation', query: { id: row.id }})
|
break
|
}
|
case 'back':{
|
router.push({path: '/main/productStock/FinishedProductRework', query: { id: row.id }})
|
break
|
}
|
case 'out' :{
|
//alert('我接收到子组件传送的编辑信息')
|
router.push({path: '/main/productStock/FinishedGoodsIssue', query: { id: row.id }})
|
break
|
}
|
}
|
}
|
|
const hasDecimal=(value)=>{
|
const regex=/\./ // 定义正则表达式,查找小数点
|
return regex.test(value) //返回true/false
|
}
|
|
const hasDecimalhtml=(item,row)=>{
|
let aa=item.split('.').length
|
if (aa===2){
|
return row[item.split('.')[0]][item.split('.')[1]]
|
}else if(aa===3){
|
return row[item.split('.')[0]][item.split('.')[1]][item.split('.')[2]]
|
}
|
|
|
}
|
|
//筛选条件,有外键需要先定义明细里面的数据
|
let filterData = ref({
|
finishedGoodsInventory:{
|
orderNumber:'',
|
orderId:'',
|
quantityAvailable:'',
|
actualSignalArea:'',
|
area:'',
|
storageRegion:''
|
},
|
order:{
|
project:'',
|
customerId:'',
|
customerName:''
|
|
}
|
})
|
let pageNum=ref(1)
|
let total = reactive({
|
pageTotal : 0,
|
dataTotal : 0,
|
pageSize : 10
|
})
|
|
//第一次调用1
|
request.post(`/FinishedGoodsInventory/getSelectAllocate/1/${total.pageSize}`,filterData.value).then((res) => {
|
|
if(res.code==200){
|
total.dataTotal = res.data.total.total*1
|
total.pageTotal= res.data.total.pageTotal
|
pageNum.value=1
|
produceList = deepClone(res.data.data)
|
xGrid.value.loadData(produceList)
|
gridOptions.loading=false
|
}else{
|
ElMessage.warning(res.msg)
|
router.push("/login")
|
}
|
})
|
|
|
|
let pageState = null
|
|
/*使用筛选,后端获取数据*/
|
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
|
}
|
request.post(`/FinishedGoodsInventory/getSelectAllocate/1/${total.pageSize}`,filterData.value).then((res) => {
|
|
if(res.code==200){
|
total.dataTotal = res.data.total.total*1
|
total.pageTotal= res.data.total.pageTotal
|
pageNum.value=1
|
produceList = deepClone(res.data.data)
|
xGrid.value.loadData(produceList)
|
gridOptions.loading=false
|
}else{
|
ElMessage.warning(res.msg)
|
router.push("/login")
|
}
|
})
|
}
|
|
|
const selectOrderList = ()=>{
|
|
request.post(`/FinishedGoodsInventory/getSelectAllocate/${pageNum.value}/${total.pageSize}`,filterData.value).then((res) => {
|
|
if(res.code==200){
|
produceList = deepClone(res.data.data)
|
xGrid.value.loadData(produceList)
|
gridOptions.loading=false
|
}else{
|
ElMessage.warning(res.msg)
|
router.push("/login")
|
}
|
})
|
}
|
//页脚跳转
|
const handlePageChange = ({ currentPage, pageSize }) => {
|
total.pageTotal = pageSize
|
pageNum.value=currentPage
|
|
selectOrderList()
|
}
|
|
|
//子组件接收参数
|
|
const gridOptions = reactive({
|
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,
|
menuConfig: {
|
body: {
|
options: [
|
[
|
{ code: 'copyChecked', name: t('basicData.selectSame'), prefixIcon: 'vxe-icon-copy', visible: true, disabled: false },
|
]
|
]
|
}
|
},
|
columnConfig: {
|
resizable: true,
|
useKey: true
|
},
|
filterConfig: { //筛选配置项
|
remote: true
|
},
|
customConfig: {
|
storage: true
|
},
|
editConfig: {
|
trigger: 'click',
|
mode: 'row',
|
showStatus: true
|
},//表头参数
|
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: '80' },
|
// {title: '操作', width: '80', slots: { default: 'button_slot' },fixed:"left"},
|
{field: 'finishedGoodsInventory.orderId', width: '150',title: t('order.orderId'),showOverflow:"ellipsis" ,filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
|
{field: 'order.project', width: '120',title: t('order.project'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
|
{field: 'finishedGoodsInventory.orderNumber', width: '120',title: t('order.OrderNum'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
|
{field: 'finishedGoodsInventory.quantityAvailable',width: '140', title: t('productStock.totalNumberOfOrders')},
|
{field: 'orderId', width: '150',title: t('productStock.newOrderId'),editRender: { name: 'input', attrs: { placeholder: '' } }, showOverflow:"ellipsis" ,filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
|
{field: 'orderNumber', width:'150', title: t('productStock.newOrderNumber'), editRender: { name: 'input', attrs: { placeholder: '' } } },
|
{field: 'quantity',width: '120', title: t('productStock.transferQuantity'),editRender: { name: 'input', attrs: { placeholder: '' } }},
|
{field: 'productId', width: '120',title: t('order.productId')},
|
{field: 'productName',width: '140', title: t('order.product')},
|
{field: 'order.customerId', width: '100',title: t('customer.customerNumber')},
|
{field: 'order.customerName',width: '140', title: t('customer.customerName')},
|
{field: 'width', width: '100',title: t('order.width')},
|
{field: 'height',width: '100', title: t('order.height')},
|
{field: 'finishedGoodsInventory.actualSignalArea',width: '140', title: t('productStock.singlePieceArea')},
|
{field: 'finishedGoodsInventory.area',width: '100', title: t('productStock.totalArea')},
|
{field: 'finishedGoodsInventory.storageRegion',width: '100', title: t('productStock.inventoryArea')},
|
],//表头按钮
|
toolbarConfig: {
|
buttons: [
|
{'name': t('productStock.confirmTransfer'),status: 'primary','code':'edit'},
|
{'name': t('productStock.transferRecords'),'code':'record'}
|
],
|
/*import: false,
|
export: true,
|
print: true,*/
|
zoom: true,
|
custom: true
|
},
|
//table body实际数据
|
footerMethod ({ columns, data }) {//页脚函数
|
return[
|
columns.map((column, columnIndex) => {
|
if (columnIndex === 0) {
|
return t('basicData.total')
|
}
|
// if (props.tableProp.footList.includes(column.field)) {
|
// return sumNum(data, column.field)
|
// }
|
return ''
|
})
|
]
|
}
|
|
})
|
|
const xGrid = ref();
|
const gridEvents = {
|
async toolbarButtonClick({code}) {
|
const $grid = xGrid.value
|
if ($grid) {
|
switch (code) {
|
case 'edit': {
|
|
const selectRecords = $grid.getCheckboxRecords()
|
|
if (selectRecords.length > 0) {
|
const errMap = await $grid.validate(selectRecords)
|
if (errMap) {
|
ElMessage.warning(t('productStock.dataVerificationFailed'))
|
return
|
}
|
} else {
|
ElMessage.warning(t('productStock.unselectedData'))
|
return
|
}
|
|
let flowData = ref({
|
|
userId: userid,
|
userName: username,
|
orderDetail: selectRecords
|
})
|
request.post("/FinishedGoodsInventory/updateFinishedGoodsInventoryAllocate", flowData.value).then((res) => {
|
if (res.code == 200) {
|
|
ElMessage.success(t('productStock.transferSuccessful'))
|
router.push({path:'/main/productStock/OrderAllocation',query:{random:Math.random()}})
|
} else {
|
ElMessage.warning(res.msg)
|
router.push("/login")
|
}
|
})
|
|
return;
|
}
|
case 'record': {
|
router.push({path: '/main/productStock/TransferRecord'});
|
return;
|
}
|
case 'rework': {
|
router.push({path: '/main/productStock/FinishedProductRework'});
|
return;
|
break;
|
}
|
}
|
}
|
},
|
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(result.cell.indexOf('.')>-1){
|
const columnArr = result.cell.split('.')
|
item[columnArr[0]][columnArr[1]] = firstVal
|
}else{
|
item[result.cell] = firstVal
|
}
|
|
}
|
})
|
}
|
break
|
}
|
|
}
|
}
|
}
|
}
|
|
|
/*数据校验*/
|
const validRules = ref({
|
orderId: [
|
{ required: true, message: t('productStock.pleaseEnterTheOrderIdForTheTransfer') }
|
],
|
orderNumber: [
|
{ required: true, message: t('productStock.pleaseEnterTheOrderNumberForTheTransfer') }
|
],
|
quantity: [{
|
validator (e) {
|
if (e.row.quantity > e.row.finishedGoodsInventory.quantityAvailable) {
|
return new Error(t('productStock.theTransferQuantityCannotBeGreaterThanTheOrderQuantity'))
|
}else if (e.row.quantity ==="") {
|
return new Error(t('productStock.transferQuantityCannotBeEmptyOr0'))
|
}
|
const regex = /^[1-9]\d*$/g
|
if ( !regex.test(e.row.quantity) ) {
|
return new Error(t('productStock.pleaseEnterAPositiveInteger'))
|
}
|
|
}
|
|
}]
|
|
})
|
|
onMounted(()=>{
|
addListener(xGrid.value,gridOptions,cellArea.value)
|
})
|
|
|
|
</script>
|
|
<template>
|
<div class="main-div-customer">
|
<vxe-grid
|
max-height="100%"
|
@filter-change="filterChanged"
|
class="mytable-scrollbar"
|
ref="xGrid"
|
v-bind="gridOptions"
|
v-on="gridEvents"
|
:edit-rules="validRules"
|
>
|
<!-- @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)">{{ hasDecimalhtml(item.field,row) }}</span>
|
<span v-else>{{ row[item.field] }}</span>
|
</li>
|
</ul>
|
</template>
|
|
<!--左边固定显示的插槽-->
|
<template #button_slot="{ row }">
|
<el-button @click="getTableRow(row,'edit')" link type="primary" size="small">{{ $t('basicData.edit') }}</el-button>
|
<!-- <el-button @click="getTableRow(row,'out')" link type="primary" size="small">成品领出</el-button>-->
|
<!-- <el-button @click="getTableRow(row,'back')" link type="primary" size="small">成品返工</el-button>-->
|
</template>
|
|
<template #num1_filter="{ column, $panel }">
|
<div>
|
<div v-for="(option, index) in column.filters" :key="index">
|
<input type="type" v-model="option.data" @input="changeFilterEvent($event, option, $panel)"/>
|
</div>
|
</div>
|
</template>
|
<template #pager>
|
<!--使用 pager 插槽-->
|
<vxe-pager
|
@page-change="handlePageChange"
|
:layouts="[ 'PrevPage', 'Jump','PageCount', 'NextPage', 'Total']"
|
v-model:current-page="pageNum"
|
v-model:page-size="total.pageSize"
|
v-model:pager-count="total.pageTotal"
|
:total="total.dataTotal"
|
>
|
</vxe-pager>
|
</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%;
|
}
|
.vxe-grid {
|
/* 禁用浏览器默认选中 */
|
-webkit-user-select: none;
|
-moz-user-select: none;
|
-ms-user-select: none;
|
user-select: none;
|
}
|
</style>
|