add:增加子卷装箱页面功能。

This commit is contained in:
2024-03-11 17:42:45 +08:00
parent 207dac2778
commit ff1e3c8dcb
18 changed files with 1182 additions and 34 deletions

View File

@@ -0,0 +1,399 @@
<template>
<el-dialog
append-to-body
:visible.sync="dialogVisible"
destroy-on-close
:show-close="false"
fullscreen
@close="close"
>
<span slot="title" class="dialog-footer">
<div class="crud-opts2">
<span class="el-dialog__title2">木箱分配</span>
</div>
<div class="crud-opts-right2" style="display: flex; justify-content: flex-end; align-items: center;">
<!--左侧插槽-->
<slot name="left" />
<el-button type="info" @click="dialogVisible = false">关闭</el-button>
</div>
</span>
<div class="crud-opts2">
<span class="role-span">分配方案</span>
</div>
<el-card class="box-card" shadow="never" :body-style="{padding:'0'}">
<!--表格1渲染-->
<el-table
ref="dtl_table"
:data="openParam"
style="width: 100%;"
max-height="300"
border
highlight-current-row
:row-class-name="tableRowClassName"
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
:row-key="row => row.name"
:span-method="handleSpanMethod"
@row-click="handleRowClick"
>
<!-- 列的定义... -->
<!-- <el-table-column prop="box_group" label="木箱组 " align="center" width="120">-->
<!-- <template slot-scope="scope">-->
<!-- {{ '' }}-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column show-overflow-tooltip prop="box_group" label="木箱组" align="center" />
<el-table-column show-overflow-tooltip prop="quanlity_in_box" label="箱内子卷数" align="center" />
<el-table-column show-overflow-tooltip prop="container_name" label="子卷号" align="center" />
<el-table-column show-overflow-tooltip prop="sap_pcsn" label="sap批次" align="center" />
</el-table>
</el-card>
<div style="margin-bottom: 20px;" />
<div>
<span class="role-span">调整分配</span>
</div>
<div style="margin-bottom: 10px;" />
<div class="search-box">
<el-input
v-model="searchText"
placeholder="请输入子卷号"
class="search-input"
clearable
@clear="handleInput"
@input="handleSearch"
/>
<span class="crud-opts-right2">
<el-button
slot="left"
class="filter-item"
type="success"
icon="el-icon-circle-close"
size="mini"
@click="clearSearch()"
>
清空
</el-button>
</span>
<span class="crud-opts-right2" style="margin-left: 15px;">
<el-button
slot="left"
class="filter-item"
type="primary"
icon="el-icon-plus"
size="mini"
@click="divStruct()"
>
分配
</el-button>
</span>
</div>
<el-card class="box-card" shadow="never" :body-style="{padding:'0'}">
<el-table
ref="dis_table"
:data="filteredData"
style="width: 100%;"
max-height="300"
border
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
:row-style="table2RowStyle"
@selection-change="handleSelectionChange"
>
<!-- 列的定义-->
<el-table-column type="selection" width="55" />
<el-table-column show-overflow-tooltip prop="box_group" label="木箱组" align="center" width="130" />
<el-table-column show-overflow-tooltip prop="container_name" label="子卷号" align="center" />
<el-table-column show-overflow-tooltip prop="sap_pcsn" label="sap批次" align="center" />
</el-table>
</el-card>
<MaterDiv ref="child" :dialog-show.sync="structShow" :sect-prop="sectProp" @tableChanged="tableChanged" />
</el-dialog>
</template>
<script>
import CRUD, { crud } from '@crud/crud'
import MaterDiv from '@/views/wms/pdm/sub/MaterDialog.vue'
import crudPackagerelation from '@/views/wms/pdm/sub/packagerelation'
import crudSubpackagerelation from '@/views/wms/pdm/sub/packagerelation'
export default {
name: 'DivDialog',
components: { MaterDiv },
mixins: [crud()],
dicts: ['io_bill_status'],
props: {
props: {
parentMethod: {
type: Function,
default: () => {
}
}
},
dialogShow: {
type: Boolean,
default: false
},
openParam: {
type: Array,
default: () => {
return []
}
},
saleOrderName: {
type: String,
default: null
},
billType: {
type: String,
default: null
}
},
data() {
return {
searchText: '',
// 存储搜索前的选中状态
previousSelection: [],
// 存储搜索后的选中状态
currentSelection: [],
// 取消选中
cancelSelection: [],
multipleSelection: [],
dialogVisible: false,
stor_id: '',
sect_id: '',
sectProp: null,
bucketProp: {},
structShow: false,
bucketObj: null,
bucketShow: false,
sects: [],
sect_val: null,
form: {
checked: null,
sale_order_name: null,
tableMater: []
},
storlist: [],
pointlist: [],
rules: {}
}
},
computed: {
filteredData() {
if (this.searchText.trim() === '') {
return this.openParam
} else {
// 过滤数据
return this.openParam.filter(row =>
row.container_name.toLowerCase().includes(this.searchText.toLowerCase())
)
}
}
},
watch: {
dialogShow: {
handler(newValue, oldValue) {
this.dialogVisible = newValue
}
}
},
methods: {
handleSearch() {
this.multipleSelection = this.multipleSelection.filter(i => { return this.$refs.dis_table.selection.includes(i) })
this.currentSelection = [...this.$refs.dis_table.selection]
},
handleSelectionChange(selection) {
if (selection.length > 0) {
this.currentSelection = selection
if (!this.searchText) {
this.previousSelection = selection
}
} else {
if (!this.searchText) {
this.cancelSelection = []
this.cancelSelection = [...this.currentSelection]
this.table2RowStyle({ row: this.currentSelection })
}
}
},
// 处理清除搜索条件事件
clearSearch() {
this.searchText = ''
this.currentSelection.push(...this.previousSelection)
this.multipleSelection.push(...this.currentSelection)
this.multipleSelection = this.getMultipleSelection(this.multipleSelection)
console.log('multipleSelection1:', this.multipleSelection)
this.multipleSelection.forEach(row => {
this.table2RowStyle(row)
})
console.log('multipleSelection2:', this.multipleSelection)
const table2 = this.$refs.dis_table
table2.clearSelection()
const selectedRows = this.multipleSelection
selectedRows.forEach(row => {
debugger
table2.toggleRowSelection(row)
})
// this.$refs.dis_table.clearSelection()
// this.multipleSelection.forEach(row => {
// this.$refs.dis_table.toggleRowSelection(row,true);
// });
},
clearSearch1() {
console.log('dis_table1:', this.$refs.dis_table)
console.log('dis_table2:', this.$refs['dis_table'])
console.log('multipleSelection:', this.currentSelection)
const table2 = this.$refs.dis_table
table2.clearSelection()
const selectedRows = this.multipleSelection
selectedRows.forEach(row => table2.toggleRowSelection(row))
// this.$refs.dis_table.clearSelection()
// this.multipleSelection.forEach(row => {
// this.$refs.dis_table.toggleRowSelection(row,true);
// });
},
handleInput(value) {
this.clearSearch1()
},
table2RowStyle({ row }) {
// if(this.cancelSelection.includes(row))
// {
// return {background: 'white'}; // 修改颜色
// }
if (this.currentSelection.includes(row)) {
return { background: 'orange' } // 修改颜色
}
if (this.multipleSelection.includes(row)) {
return { background: 'orange' } // 修改颜色
}
return {}
},
getMultipleSelection(multipleSelection) {
return multipleSelection.reduce((acc, item) => {
debugger
const existingItem = acc.find(existing => existing.container_name === item.container_name)
if (!existingItem) {
acc.push(item)
}
return acc
}, [])
},
// 表格1的分组处理
handleSpanMethod({ row, columnIndex }) {
if (columnIndex === 0 || columnIndex === 1) {
if (row.box_group !== null) {
const sortedData = [...this.openParam].sort((a, b) => a.box_group.localeCompare(b.box_group))
const currentIndex = sortedData.findIndex(item => item === row)
const isFirstRow = currentIndex === 0 || sortedData[currentIndex - 1].box_group !== row.box_group
return {
rowspan: isFirstRow ? sortedData.filter(item => item.box_group === row.box_group).length : 0,
colspan: 1
}
} else {
return { rowspan: 1, colspan: 1 }
}
}
},
// 表格1的行点击事件
handleRowClick(scope) {
debugger
const table2 = this.$refs.dis_table
const table2Data = Array.from(this.openParam)
const groupValue = scope.box_group === 0 ? scope.container_name : scope.box_group
const selectedRows = table2Data.filter(row => row.box_group === groupValue && row.box_group !== null && row.box_group !== 0)
table2.clearSelection()
selectedRows.forEach(row => table2.toggleRowSelection(row))
},
toDelete(data) {
this.$set(data, 'pop', true)
// data.pop = true
},
close() {
this.clearSelection()
this.form.tableMater = []
this.form.dtl_row = null
this.sectProp = null
this.$emit('update:dialogShow', false)
this.$emit('AddChanged')
this.crud.refresh()
this.$refs['form2'].resetFields()
},
// 清除选中项
clearSelection() {
this.previousSelection = []
this.multipleSelection = []
this.currentSelection = []
},
tableRowClassName({ row, rowIndex }) {
row.index = rowIndex
},
tableChanged(row) {
this.form.tableMater = this.currentSelection
this.form.checked = row.material_code
this.form.sale_order_name = this.sale_order_name
crudPackagerelation.updateEntityList(this.form).then(res => {
crudSubpackagerelation.queryContainerization({ 'sale_order_name': this.sale_order_name }).then(res => {
this.openParam = res.content
this.$emit('childEvent')
this.clearSelection()
})
this.form.tableMater = []
this.crud.notify('操作成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
})
},
divStruct() {
debugger
if (this.currentSelection.length > 0 && this.$refs.dis_table.selection.length > 0) {
debugger
this.structShow = true
this.$refs.child.getMsg(false)
} else {
this.crud.notify('请确认并勾选子卷信息!', CRUD.NOTIFICATION_TYPE.INFO)
}
},
doCancel(data) {
this.$set(data, 'pop', false)
// data.pop = false
}
}
}
</script>
<style>
.crud-opts2 {
padding: 0;
display: -webkit-flex;
display: flex;
align-items: center;
}
.crud-opts2 .el-dialog__title2 {
line-height: 24px;
font-size: 20px;
color: #303133;
}
.search-box {
margin-bottom: 10px;
}
.search-input {
width: 200px;
}
.clear-icon {
cursor: pointer;
}
.crud-opts2 .role-span {
padding: 10px 0px 10px 0px;
}
.crud-opts2 .crud-opts-form {
padding: 10px 0px 0px 20px;
}
.input-with-select {
background-color: #fff;
}
</style>

View File

@@ -0,0 +1,183 @@
<template>
<el-dialog
title="木箱选择"
append-to-body
:visible.sync="dialogVisible"
destroy-on-close
width="1000px"
@close="close"
@open="open"
>
<!-- 搜索 -->
<el-row>
<el-col :span="6">
<el-input
v-model="query.search"
clearable
style="width: 200px"
size="mini"
placeholder="输入木箱物料名称"
prefix-icon="el-icon-search"
class="filter-item"
/> </el-col>
<el-col :span="6">
<rrOperation />
</el-col>
</el-row>
<div style="margin-bottom: 10px" />
<!--表格渲染-->
<el-table
ref="table"
v-loading="crud.loading"
:data="crud.data"
style="width: 100%;"
border
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
@select="handleSelectionChange"
@select-all="onSelectAll"
>
<el-table-column type="selection" width="55" />
<el-table-column prop="material_code" label="木箱规格" />
<el-table-column prop="material_name" label="物料名称" />
</el-table>
<!--分页组件-->
<pagination />
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="submit"> </el-button>
</span>
</el-dialog>
</template>
<script>
import CRUD, { header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import pagination from '@crud/Pagination'
import crudMaterattr from '@/views/wms/pdm/sub/materattr'
export default {
name: 'MaterDialog',
components: { rrOperation, pagination },
cruds() {
return CRUD({
title: '木箱规格',
optShow: {},
url: 'api/Materialbase',
idField: 'material_id',
sort: 'material_id,desc',
query: { search: '', material_id: '' },
crudMethod: { ...crudMaterattr }
})
},
mixins: [presenter(), header()],
props: {
dialogShow: {
type: Boolean,
default: false
},
sectProp: {
type: Object
}
},
data() {
return {
classes: [],
dialogVisible: false,
sect: {},
checkrow: {},
rows: [],
dialogDis: true,
lock: ''
}
},
watch: {
dialogShow: {
handler(newValue, oldValue) {
this.dialogVisible = newValue
}
},
sectProp: {
handler(newValue, oldValue) {
this.sect = newValue
}
}
},
methods: {
/**
* 接受父组件传值
* @param msg
*/
getMsg(msg) {
this.dialogDis = msg
this.lock = '00'
},
[CRUD.HOOK.beforeRefresh]() {
this.query.lock = this.lock
return true
},
open() {
if (this.sect) {
this.query.sect = this.sect
if (this.sect.length === 1) {
this.query.stor_id = this.sect[0]
this.query.sect_id = ''
}
if (this.sect.length === 0) {
this.query.sect_id = ''
this.query.stor_id = ''
}
if (this.sect.length === 2) {
this.query.stor_id = this.sect[0]
this.query.sect_id = this.sect[1]
}
}
this.query.is_lock = '1'
this.query.lock = this.lock
this.query.is_used = '1'
this.crud.toQuery()
},
handleSelectionChange(val, row) {
if (val.length > 1) {
this.$refs.table.clearSelection()
this.$refs.table.toggleRowSelection(val.pop())
} else {
this.checkrow = row
}
},
sectQueryChange(val) {
if (val.length === 1) {
this.crud.query.stor_id = val[0]
this.crud.query.sect_id = ''
}
if (val.length === 0) {
this.crud.query.sect_id = ''
this.crud.query.stor_id = ''
}
if (val.length === 2) {
this.crud.query.stor_id = val[0]
this.crud.query.sect_id = val[1]
}
},
onSelectAll() {
this.$refs.table.clearSelection()
},
close() {
this.crud.resetQuery()
this.query.sect = null
this.$emit('update:dialogShow', false)
},
submit() {
debugger
this.rows = this.$refs.table.selection
if (this.rows.length <= 0) {
this.$message('请先选择木箱信息')
return
}
this.$emit('update:dialogShow', false)
this.$emit('tableChanged', this.checkrow)
}
}
}
</script>

View File

@@ -0,0 +1,304 @@
<template>
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<div v-if="crud.props.searchToggle">
<!-- 搜索 -->
<el-form
:inline="true"
class="demo-form-inline"
label-position="right"
label-width="115px"
label-suffix=":"
>
<el-form-item label="订单号">
<el-input
v-model="query.sale_order_name"
clearable
placeholder="输入订单号"
style="width: 185px;"
class="filter-item"
@keyup.enter.native="crud.toQuery"
/>
</el-form-item>
<el-form-item label="客户名称">
<el-input
v-model="query.customer_description"
clearable
placeholder="输入客户名称"
style="width: 185px;"
class="filter-item"
@keyup.enter.native="crud.toQuery"
/>
</el-form-item>
<el-form-item label="客户编码">
<el-input
v-model="query.customer_name"
clearable
placeholder="输入客户编码"
style="width: 185px;"
class="filter-item"
@keyup.enter.native="crud.toQuery"
/>
</el-form-item>
<!-- <el-form-item label="状态">-->
<!-- <el-select-->
<!-- v-model="query.status"-->
<!-- clearable-->
<!-- size="mini"-->
<!-- placeholder="请选择"-->
<!-- class="filter-item"-->
<!-- @change="hand"-->
<!-- >-->
<!-- <el-option label="未分配" value="99" />-->
<!-- <el-option label="已分配" value="0" />-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<rrOperation :crud="crud" />
</el-form>
</div>
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation :permission="permission">
<el-button
slot="right"
class="filter-item"
type="success"
:disabled="dis_flag"
icon="el-icon-position"
size="mini"
@click="divOpen1"
>
分配
</el-button>
</crudOperation>
<!--表格渲染-->
<el-tabs v-model="activeName" class="custom-tabs" @tab-click="handleClick">
<el-tab-pane label="未分配" name="first" />
<el-tab-pane label="已分配" name="second" />
</el-tabs>
<el-table
ref="table"
v-loading="crud.loading"
height
style="width: 100%"
:data="crud.data"
size="mini"
@select="handleSelectionChange"
@selection-change="crud.selectionChangeHandler"
@row-dblclick="handleRowDblClick"
>
<el-table-column type="selection" />
<el-table-column
prop="sale_order_name"
label="销售订单及行号"
:min-width="flexWidth('sale_order_name',crud.data,'销售订单及行号')"
/>
<el-table-column
prop="customer_name"
label="客户编码"
:min-width="flexWidth('customer_name',crud.data,'客户编码')"
/>
<el-table-column
prop="customer_description"
label="客户名称"
:min-width="flexWidth('customer_description',crud.data,'客户名称')"
/>
<el-table-column prop="status" label="状态" :min-width="flexWidth('status', crud.data, '状态')">
<template slot-scope="scope">
{{ scope.row.status === "99" ? '未分配' : '已分配' }}
</template>
</el-table-column>
<el-table-column prop="create_name" label="创建人" :min-width="flexWidth('create_name',crud.data,'创建人')" />
<el-table-column
prop="create_time"
label="创建时间"
:min-width="flexWidth('create_time',crud.data,'创建时间')"
/>
<el-table-column
prop="sale_order_description"
label="销售订单描述"
:min-width="flexWidth('sale_order_description',crud.data,'销售订单描述')"
/>
<!-- <el-table-column prop="remark" label="备注" :min-width="flexWidth('remark',crud.data,'备注')"/>-->
</el-table>
<!--分页组件-->
<pagination />
</div>
<DivDialog :dialog-show.sync="divShow" :open-param="openParam" :sale_order_name="sale_order_name" @childEvent="handleChildEvent" @AddChanged="querytable" />
</div>
</template>
<script>
import crudSubpackagerelation from './packagerelation'
import CRUD, { crud, form, header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import { download } from '@/api/data'
import { downloadFile } from '@/utils'
import DivDialog from '@/views/wms/pdm/sub/DivDialog.vue'
const defaultForm = {
workorder_id: null,
package_box_sn: null,
quanlity_in_box: null,
box_weight: null,
quality_guaran_period: null,
sale_order_name: null,
customer_name: null,
customer_description: null,
product_name: null,
product_description: null,
date_of_fg_inbound: null,
container_name: null,
width: null,
thickness: null,
mass_per_unit_area: null,
net_weight: null,
length: null,
date_of_production: null,
is_un_plan_production: null,
un_plan_product_property1: null,
un_plan_product_property2: null,
un_plan_product_property3: null,
box_type: null,
sap_pcsn: null,
remark: null,
create_id: null,
create_name: null,
create_time: null,
status: '99',
isreprintpackageboxlabel: null,
isunpackbox: null,
thickness_request: null,
width_standard: null
}
export default {
name: 'Packagerelation',
dicts: ['sub_package_relation', 'IS_OR_NOT'],
components: { pagination, crudOperation, rrOperation, udOperation, DivDialog },
mixins: [presenter(), header(), form(defaultForm), crud()],
cruds() {
return CRUD({
title: '子卷装箱',
optShow: { add: false, edit: false, del: false },
url: 'api/pdmBiSubpackagerelation/queryContainerization',
crudMethod: { ...crudSubpackagerelation }
})
},
data() {
return {
activeName: 'first',
divShow: false,
openParam: [],
sale_order_name: null,
bussConfig: null,
currentRow: null,
dis_flag: true,
permission: {
add: ['admin', 'sub:add'],
edit: ['admin', 'sub:edit'],
del: ['admin', 'sub:del']
},
isPlanProducList: [
{ 'label': '是', 'value': '1' },
{ 'label': '否', 'value': '0' }
]
}
},
methods: {
// 钩子在获取表格数据之前执行false 则代表不获取数据
[CRUD.HOOK.beforeRefresh]() {
return true
},
// 标签页点击
handleClick(tab) {
this.query.status = tab.name === 'first' ? '99' : '0'
this.crud.toQuery()
},
// 表格双击事件
handleRowDblClick(row, column, event) {
// 双击事件的处理逻辑
this.divOpen(row)
},
// 双击
divOpen(row) {
this.sale_order_name = row.sale_order_name
crudSubpackagerelation.queryContainerization({ 'sale_order_name': row.sale_order_name }).then(res => {
this.openParam = res.content
this.divShow = true
})
},
divOpen1() {
this.sale_order_name = this.currentRow.sale_order_name
crudSubpackagerelation.queryContainerization({ 'sale_order_name': this.currentRow.sale_order_name }).then(res => {
this.openParam = res.content
this.divShow = true
})
},
querytable() {
this.onSelectAll()
this.crud.toQuery()
},
handleChildEvent() {
this.divOpen()
},
handleSelectionChange(val, row) {
if (val.length > 1) {
this.$refs.table.clearSelection()
this.$refs.table.toggleRowSelection(val.pop())
this.buttonChange(row)
} else if (val.length === 1) {
this.buttonChange(row)
} else {
this.handleCurrentChange(null)
}
},
buttonChange(currentRow) {
if (currentRow !== null) {
this.currentRow = currentRow
this.dis_flag = false
}
},
onSelectAll() {
this.$refs.table.clearSelection()
this.handleCurrentChange(null)
},
handleCurrentChange(currentRow) {
if (currentRow === null) {
this.dis_flag = true
this.currentRow = {}
}
},
hand(value) {
this.crud.toQuery()
},
downdtl() {
if (this.currentRow !== null) {
crud.downloadLoading = true
download('/api/packagerelation/download', this.crud.query).then(result => {
debugger
downloadFile(result, '子卷包装', 'xlsx')
crud.downloadLoading = false
}).catch(() => {
crud.downloadLoading = false
})
}
}
}
}
</script>
<style scoped>
.custom-tabs {
margin-bottom: 0px; /* 调整垂直间距,根据需要调整数值 */
}
.custom-table {
margin-top: 0px; /* 调整垂直间距,根据需要调整数值 */
}
.tableAuto.el-table .cell {
white-space: nowrap;
}
</style>

View File

@@ -0,0 +1,27 @@
import request from '@/utils/request'
export function add(data) {
return request({
url: 'api/structattr',
method: 'post',
data
})
}
export function del(ids) {
return request({
url: 'api/structattr/',
method: 'delete',
data: ids
})
}
export function edit(data) {
return request({
url: 'api/structattr',
method: 'put',
data
})
}
export default { add, edit, del }

View File

@@ -0,0 +1,43 @@
import request from '@/utils/request'
export function add(data) {
return request({
url: 'api/subpackagerelation',
method: 'post',
data
})
}
export function del(ids) {
return request({
url: 'api/pdmBiSubpackagerelation/',
method: 'delete',
data: ids
})
}
export function edit(data) {
return request({
url: 'api/pdmBiSubpackagerelation',
method: 'put',
data
})
}
export function queryContainerization(params) {
return request({
url: '/api/pdmBiSubpackagerelation/queryContainerNameBySaleOrder',
method: 'get',
params
})
}
export function updateEntityList(data) {
return request({
url: '/api/pdmBiSubpackagerelation/updateEntityList',
method: 'post',
data
})
}
export default { add, edit, del, queryContainerization, updateEntityList }