优化序列号和批次商品的逻辑

This commit is contained in:
季圣华 2021-09-29 19:45:20 +08:00
parent ecb0edca29
commit 7ae0c1585c
18 changed files with 345 additions and 22 deletions

View File

@ -61,6 +61,7 @@ const addSerialNumber = (params)=>postAction("/serialNumber/add",params);
const editSerialNumber = (params)=>putAction("/serialNumber/update",params);
const checkSerialNumber = (params)=>getAction("/serialNumber/checkIsNameExist",params);
const batAddSerialNumber = (params)=>postAction("/serialNumber/batAddSerialNumber",params);
const getEnableSerialNumberList = (params)=>getAction("/serialNumber/getEnableSerialNumberList",params);
//多属性
const addMaterialAttribute = (params)=>postAction("/materialAttribute/add",params);
const editMaterialAttribute = (params)=>putAction("/materialAttribute/update",params);
@ -149,6 +150,7 @@ export {
editSerialNumber,
checkSerialNumber,
batAddSerialNumber,
getEnableSerialNumberList,
addMaterialAttribute,
editMaterialAttribute,
checkMaterialAttribute,

View File

@ -8,16 +8,18 @@
</a-input-search>
<j-select-material-modal v-if="kind === 'material'" ref="selectModal" :modal-width="modalWidth" :rows="rows" :multi="multi" :bar-code="value" @ok="selectOK" @initComp="initComp"/>
<j-select-batch-modal v-if="kind === 'batch'" ref="selectModal" :modal-width="modalWidth" :rows="rows" :multi="multi" :bar-code="value" @ok="selectOK" @initComp="initComp"/>
<j-select-sn-modal v-if="kind === 'sn'" ref="selectModal" :modal-width="modalWidth" :rows="rows" :multi="multi" :bar-code="value" @ok="selectOK" @initComp="initComp"/>
</div>
</template>
<script>
import JSelectMaterialModal from './modal/JSelectMaterialModal'
import JSelectBatchModal from './modal/JSelectBatchModal'
import JSelectSnModal from './modal/JSelectSnModal'
export default {
name: 'JSelectList',
components: {JSelectMaterialModal, JSelectBatchModal},
components: {JSelectMaterialModal, JSelectBatchModal, JSelectSnModal},
props: {
modalWidth: {
type: Number,

View File

@ -58,6 +58,14 @@
:loading="loading"
:customRow="rowAction"
@change="handleTableChange">
<template slot="customRenderEnableSerialNumber" slot-scope="enableSerialNumber">
<a-tag v-if="enableSerialNumber==1" color="green"></a-tag>
<a-tag v-if="enableSerialNumber==0" color="orange"></a-tag>
</template>
<template slot="customRenderEnableBatchNumber" slot-scope="enableBatchNumber">
<a-tag v-if="enableBatchNumber==1" color="green"></a-tag>
<a-tag v-if="enableBatchNumber==0" color="orange"></a-tag>
</template>
</a-table>
</div>
</a-col>
@ -94,14 +102,20 @@
categoryTree:[],
columns: [
{dataIndex: 'mBarCode', title: '条码', width: 100, align: 'left'},
{dataIndex: 'name', title: '名称', width: 100},
{dataIndex: 'name', title: '名称', width: 120},
{dataIndex: 'categoryName', title: '类别', width: 80},
{dataIndex: 'standard', title: '规格', width: 80},
{dataIndex: 'model', title: '型号', width: 80},
{dataIndex: 'unit', title: '单位', width: 60},
{dataIndex: 'sku', title: '多属性', width: 100},
{dataIndex: 'stock', title: '库存', width: 100},
{dataIndex: 'expand', title: '扩展信息', width: 80}
{dataIndex: 'sku', title: '多属性', width: 80},
{dataIndex: 'stock', title: '库存', width: 60},
{dataIndex: 'expand', title: '扩展信息', width: 80},
{dataIndex: 'enableSerialNumber', title: '序列号', width: 60, align: "center",
scopedSlots: { customRender: 'customRenderEnableSerialNumber' }
},
{dataIndex: 'enableBatchNumber', title: '批号', width: 60, align: "center",
scopedSlots: { customRender: 'customRenderEnableBatchNumber' }
}
],
scrollTrigger: {},
dataSource: [],

View File

@ -0,0 +1,265 @@
<template>
<a-modal
:width="modalWidth"
:visible="visible"
:title="title"
@ok="handleSubmit"
@cancel="close"
cancelText="关闭"
style="top:5%;height: 100%;overflow-y: hidden"
wrapClassName="ant-modal-cust-warp"
>
<a-row :gutter="10" style="padding: 10px; margin: -10px">
<a-col :md="24" :sm="24">
<!-- 查询区域 -->
<div class="table-page-search-wrapper">
<!-- 搜索区域 -->
<a-form layout="inline" @keyup.enter.native="onSearch">
<a-row :gutter="24">
<a-col :md="6" :sm="8">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="序列号">
<a-input placeholder="请输入序列号" v-model="queryParam.name"></a-input>
</a-form-item>
</a-col>
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
<a-col :md="6" :sm="24">
<a-button type="primary" @click="onSearch">查询</a-button>
<a-button style="margin-left: 8px" @click="searchReset(1)">重置</a-button>
</a-col>
</span>
</a-row>
</a-form>
<a-table
ref="table"
:scroll="scrollTrigger"
size="middle"
rowKey="id"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange,type: getType}"
:loading="loading"
:customRow="rowAction"
@change="handleTableChange">
</a-table>
</div>
</a-col>
</a-row>
</a-modal>
</template>
<script>
import { getAction } from '@/api/manage'
import {getEnableSerialNumberList} from '@/api/api'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
export default {
name: 'JSelectSnModal',
mixins:[JeecgListMixin],
components: {},
props: ['modalWidth', 'rows', 'multi', 'barCode'],
data() {
return {
queryParam: {
name: "",
depotId: '',
barCode: ''
},
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
categoryTree:[],
columns: [
{dataIndex: 'serialNumber', title: '序列号', width: 100, align: 'left'}
],
scrollTrigger: {},
dataSource: [],
selectedRowKeys: [],
selectRows: [],
selectIds: [],
title: '选择序列号',
ipagination: {
current: 1,
pageSize: 10,
pageSizeOptions: ['10', '20', '30', '100', '200'],
showTotal: (total, range) => {
return range[0] + '-' + range[1] + ' ' + total + '条'
},
showQuickJumper: true,
showSizeChanger: true,
total: 0
},
isorter: {
column: 'createTime',
order: 'desc'
},
departTree: [],
depotList: [],
visible: false,
form: this.$form.createForm(this),
loading: false,
expandedKeys: [],
}
},
computed: {
// 计算属性的 getter
getType: function () {
return this.multi == true ? 'checkbox' : 'radio';
}
},
watch: {
barCode: {
immediate: true,
handler() {
this.initBarCode()
}
},
},
created() {
this.loadData()
},
methods: {
initBarCode() {
if (this.barCode) {
this.$emit('initComp', this.barCode)
} else {
// JSelectUserByDep组件bug issues/I16634
this.$emit('initComp', '')
}
},
async loadData(arg) {
if(this.rows) {
if(JSON.parse(this.rows).depotId && JSON.parse(this.rows).barCode ){
this.queryParam.depotId = JSON.parse(this.rows).depotId-0
this.queryParam.barCode = JSON.parse(this.rows).barCode
}
}
if (arg === 1) {
this.ipagination.current = 1;
}
this.loading = true
let params = this.getQueryParams()//查询条件
await getEnableSerialNumberList(params).then((res) => {
if (res && res.code === 200) {
this.dataSource = res.data.rows
this.ipagination.total = res.data.total
}
}).finally(() => {
this.loading = false
})
},
showModal() {
this.visible = true;
this.loadData();
this.form.resetFields();
},
getQueryParams() {
let param = Object.assign({}, this.queryParam, this.isorter);
param.page = this.ipagination.current;
param.rows = this.ipagination.pageSize;
return param;
},
getQueryField() {
let str = 'id,';
for (let a = 0; a < this.columns.length; a++) {
str += ',' + this.columns[a].dataIndex;
}
return str;
},
searchReset(num) {
let that = this;
if (num !== 0) {
if(this.rows) {
this.queryParam.name=''
if(JSON.parse(this.rows).depotId && JSON.parse(this.rows).barCode ){
this.queryParam.depotId = JSON.parse(this.rows).depotId-0
this.queryParam.barCode = JSON.parse(this.rows).barCode
}
}
that.loadData(1);
}
that.selectedRowKeys = [];
that.selectIds = [];
},
close() {
this.searchReset(0);
this.visible = false;
},
handleTableChange(pagination, filters, sorter) {
if (Object.keys(sorter).length > 0) {
this.isorter.column = sorter.field;
this.isorter.order = 'ascend' === sorter.order ? 'asc' : 'desc';
}
this.ipagination = pagination;
this.loadData();
},
handleSubmit() {
let that = this;
this.getSelectRows();
that.$emit('ok', that.selectRows, that.selectIds);
that.searchReset(0)
that.close();
},
//获取选择信息
getSelectRows(rowId) {
let dataSource = this.dataSource;
let ids = "";
this.selectRows = [];
for (let i = 0, len = dataSource.length; i < len; i++) {
if (this.selectedRowKeys.includes(dataSource[i].id)) {
this.selectRows.push(dataSource[i]);
ids = ids + "," + dataSource[i].serialNumber
}
}
this.selectIds = ids.substring(1);
},
onSelectChange(selectedRowKeys, selectionRows) {
this.selectedRowKeys = selectedRowKeys;
this.selectionRows = selectionRows;
},
onSearch() {
this.loadData(1);
},
modalFormOk() {
this.loadData();
},
rowAction(record, index) {
return {
on: {
click: () => {
let arr = []
arr.push(record.id)
this.selectedRowKeys = arr
},
dblclick: () => {
let arr = []
arr.push(record.id)
this.selectedRowKeys = arr
this.handleSubmit()
}
}
}
}
}
}
</script>
<style scoped>
.ant-table-tbody .ant-table-row td {
padding-top: 10px;
padding-bottom: 10px;
}
#components-layout-demo-custom-trigger .trigger {
font-size: 18px;
line-height: 64px;
padding: 0 24px;
cursor: pointer;
transition: color .3s;
}
</style>

View File

@ -104,7 +104,21 @@ export const BillModalMixin = {
for(let i=0; i<columns.length; i++){
if(columns[i].key === key) {
if(type){
columns[i].type = FormTypes.input //显示
if(key === 'snList' || key === 'batchNumber') {
if(this.prefixNo === 'XSCK' || this.prefixNo === 'CGTH') {
columns[i].type = FormTypes.popupJsh //显示
} else {
columns[i].type = FormTypes.input //显示
}
} else if(key === 'expirationDate') {
if(this.prefixNo === 'CGRK' || this.prefixNo === 'XSTH') {
columns[i].type = FormTypes.date //显示
} else {
columns[i].type = FormTypes.input //显示
}
} else {
columns[i].type = FormTypes.input //显示
}
} else {
columns[i].type = FormTypes.hidden //隐藏
}
@ -240,6 +254,13 @@ export const BillModalMixin = {
if(mInfo.sku) {
this.changeFormTypes(this.materialTable.columns, 'sku', 1)
}
if(mInfo.enableSerialNumber === "1") {
this.changeFormTypes(this.materialTable.columns, 'snList', 1)
}
if(mInfo.enableBatchNumber === "1") {
this.changeFormTypes(this.materialTable.columns, 'batchNumber', 1)
this.changeFormTypes(this.materialTable.columns, 'expirationDate', 1)
}
let mObj = this.parseInfoToObj(mInfo)
mObj.depotId = mInfo.depotId
mObj.stock = mInfo.stock
@ -261,6 +282,13 @@ export const BillModalMixin = {
if(mInfo.sku) {
this.changeFormTypes(this.materialTable.columns, 'sku', 1)
}
if(mInfo.enableSerialNumber === "1") {
this.changeFormTypes(this.materialTable.columns, 'snList', 1)
}
if(mInfo.enableBatchNumber === "1") {
this.changeFormTypes(this.materialTable.columns, 'batchNumber', 1)
this.changeFormTypes(this.materialTable.columns, 'expirationDate', 1)
}
let mObj = {
rowKey: row.id,
values: this.parseInfoToObj(mInfo)

View File

@ -103,7 +103,7 @@
{ title: '仓库名称', key: 'depotId', width: '7%', type: FormTypes.select, placeholder: '请选择${title}', options: [],
allowSearch:true, validateRules: [{ required: true, message: '${title}不能为空' }]
},
{ title: '条码', key: 'barCode', width: '8%', type: FormTypes.popupJsh, multi: true,
{ title: '条码', key: 'barCode', width: '8%', type: FormTypes.popupJsh, kind: 'material', multi: true,
validateRules: [{ required: true, message: '${title}不能为空' }]
},
{ title: '名称', key: 'name', width: '6%', type: FormTypes.input, readonly: true },

View File

@ -105,7 +105,7 @@
{ title: '仓库名称', key: 'depotId', width: '7%', type: FormTypes.select, placeholder: '请选择${title}', options: [],
allowSearch:true, validateRules: [{ required: true, message: '${title}不能为空' }]
},
{ title: '条码', key: 'barCode', width: '8%', type: FormTypes.popupJsh, multi: true,
{ title: '条码', key: 'barCode', width: '8%', type: FormTypes.popupJsh, kind: 'material', multi: true,
validateRules: [{ required: true, message: '${title}不能为空' }]
},
{ title: '名称', key: 'name', width: '6%', type: FormTypes.input, readonly: true },

View File

@ -105,7 +105,7 @@
{ title: '仓库名称', key: 'depotId', width: '7%', type: FormTypes.select, placeholder: '请选择${title}', options: [],
allowSearch:true, validateRules: [{ required: true, message: '${title}不能为空' }]
},
{ title: '条码', key: 'barCode', width: '8%', type: FormTypes.popupJsh, multi: true,
{ title: '条码', key: 'barCode', width: '8%', type: FormTypes.popupJsh, kind: 'material', multi: true,
validateRules: [{ required: true, message: '${title}不能为空' }]
},
{ title: '名称', key: 'name', width: '6%', type: FormTypes.input, readonly: true },

View File

@ -112,7 +112,7 @@
{ title: '仓库名称', key: 'depotId', width: '7%', type: FormTypes.select, placeholder: '请选择${title}', options: [],
allowSearch:true, validateRules: [{ required: true, message: '${title}不能为空' }]
},
{ title: '条码', key: 'barCode', width: '8%', type: FormTypes.popupJsh, multi: true,
{ title: '条码', key: 'barCode', width: '8%', type: FormTypes.popupJsh, kind: 'material', multi: true,
validateRules: [{ required: true, message: '${title}不能为空' }]
},
{ title: '名称', key: 'name', width: '6%', type: FormTypes.input, readonly: true },

View File

@ -112,7 +112,7 @@
{ title: '仓库名称', key: 'depotId', width: '7%', type: FormTypes.select, placeholder: '请选择${title}', options: [],
allowSearch:true, validateRules: [{ required: true, message: '${title}不能为空' }]
},
{ title: '条码', key: 'barCode', width: '8%', type: FormTypes.popupJsh, multi: true,
{ title: '条码', key: 'barCode', width: '8%', type: FormTypes.popupJsh, kind: 'material', multi: true,
validateRules: [{ required: true, message: '${title}不能为空' }]
},
{ title: '名称', key: 'name', width: '6%', type: FormTypes.input, readonly: true },

View File

@ -172,7 +172,7 @@
{ title: '仓库名称', key: 'depotId', width: '7%', type: FormTypes.select, placeholder: '请选择${title}', options: [],
allowSearch:true, validateRules: [{ required: true, message: '${title}不能为空' }]
},
{ title: '条码', key: 'barCode', width: '8%', type: FormTypes.popupJsh, multi: true,
{ title: '条码', key: 'barCode', width: '8%', type: FormTypes.popupJsh, kind: 'material', multi: true,
validateRules: [{ required: true, message: '${title}不能为空' }]
},
{ title: '名称', key: 'name', width: '6%', type: FormTypes.input, readonly: true },
@ -181,9 +181,9 @@
{ title: '扩展信息', key: 'materialOther', width: '5%', type: FormTypes.input, readonly: true },
{ title: '库存', key: 'stock', width: '5%', type: FormTypes.input, readonly: true },
{ title: '单位', key: 'unit', width: '4%', type: FormTypes.input, readonly: true },
{ title: '序列号', key: 'snList', width: '5%', type: FormTypes.input },
{ title: '批号', key: 'batchNumber', width: '5%', type: FormTypes.input },
{ title: '有效期', key: 'expirationDate',width: '7%', type: FormTypes.input },
{ title: '序列号', key: 'snList', width: '7%', type: FormTypes.popupJsh, kind: 'sn', multi: true },
{ title: '批号', key: 'batchNumber', width: '7%', type: FormTypes.popupJsh, kind: 'batch', multi: false },
{ title: '有效期', key: 'expirationDate',width: '5%', type: FormTypes.input, readonly: true },
{ title: '多属性', key: 'sku', width: '4%', type: FormTypes.input, readonly: true },
{ title: '数量', key: 'operNumber', width: '5%', type: FormTypes.inputNumber, statistics: true,
validateRules: [{ required: true, message: '${title}不能为空' }]
@ -227,6 +227,9 @@
methods: {
//调用完edit()方法之后会自动调用此方法
editAfter() {
this.changeFormTypes(this.materialTable.columns, 'snList', 0)
this.changeFormTypes(this.materialTable.columns, 'batchNumber', 0)
this.changeFormTypes(this.materialTable.columns, 'expirationDate', 0)
if (this.action === 'add') {
this.addInit(this.prefixNo)
this.fileList = []

View File

@ -230,6 +230,9 @@
methods: {
//调用完edit()方法之后会自动调用此方法
editAfter() {
this.changeFormTypes(this.materialTable.columns, 'snList', 0)
this.changeFormTypes(this.materialTable.columns, 'batchNumber', 0)
this.changeFormTypes(this.materialTable.columns, 'expirationDate', 0)
this.changeFormTypes(this.materialTable.columns, 'preNumber', 0)
this.changeFormTypes(this.materialTable.columns, 'finishNumber', 0)
if (this.action === 'add') {

View File

@ -112,7 +112,7 @@
dataSource: [],
columns: [
{ title: '仓库名称', key: 'depotId', width: '7%', type: FormTypes.hidden },
{ title: '条码', key: 'barCode', width: '8%', type: FormTypes.popupJsh, multi: true,
{ title: '条码', key: 'barCode', width: '8%', type: FormTypes.popupJsh, kind: 'material', multi: true,
validateRules: [{ required: true, message: '${title}不能为空' }]
},
{ title: '名称', key: 'name', width: '6%', type: FormTypes.input, readonly: true },

View File

@ -155,7 +155,7 @@
{ title: '仓库名称', key: 'depotId', width: '7%', type: FormTypes.select, placeholder: '请选择${title}', options: [],
allowSearch:true, validateRules: [{ required: true, message: '${title}不能为空' }]
},
{ title: '条码', key: 'barCode', width: '12%', type: FormTypes.popupJsh, multi: true,
{ title: '条码', key: 'barCode', width: '12%', type: FormTypes.popupJsh, kind: 'material', multi: true,
validateRules: [{ required: true, message: '${title}不能为空' }]
},
{ title: '名称', key: 'name', width: '9%', type: FormTypes.input, readonly: true },

View File

@ -157,7 +157,7 @@
{ title: '仓库名称', key: 'depotId', width: '7%', type: FormTypes.select, placeholder: '请选择${title}', options: [],
allowSearch:true, validateRules: [{ required: true, message: '${title}不能为空' }]
},
{ title: '条码', key: 'barCode', width: '12%', type: FormTypes.popupJsh, multi: true,
{ title: '条码', key: 'barCode', width: '12%', type: FormTypes.popupJsh, kind: 'material', multi: true,
validateRules: [{ required: true, message: '${title}不能为空' }]
},
{ title: '名称', key: 'name', width: '9%', type: FormTypes.input, readonly: true },

View File

@ -177,7 +177,7 @@
{ title: '仓库名称', key: 'depotId', width: '7%', type: FormTypes.select, placeholder: '请选择${title}', options: [],
allowSearch:true, validateRules: [{ required: true, message: '${title}不能为空' }]
},
{ title: '条码', key: 'barCode', width: '8%', type: FormTypes.popupJsh, multi: true,
{ title: '条码', key: 'barCode', width: '8%', type: FormTypes.popupJsh, kind: 'material', multi: true,
validateRules: [{ required: true, message: '${title}不能为空' }]
},
{ title: '名称', key: 'name', width: '6%', type: FormTypes.input, readonly: true },
@ -188,7 +188,7 @@
{ title: '单位', key: 'unit', width: '4%', type: FormTypes.input, readonly: true },
{ title: '序列号', key: 'snList', width: '5%', type: FormTypes.input },
{ title: '批号', key: 'batchNumber', width: '5%', type: FormTypes.input },
{ title: '有效期', key: 'expirationDate',width: '7%', type: FormTypes.input },
{ title: '有效期', key: 'expirationDate',width: '7%', type: FormTypes.date },
{ title: '多属性', key: 'sku', width: '4%', type: FormTypes.input, readonly: true },
{ title: '数量', key: 'operNumber', width: '5%', type: FormTypes.inputNumber, statistics: true,
validateRules: [{ required: true, message: '${title}不能为空' }]
@ -232,6 +232,9 @@
methods: {
//调用完edit()方法之后会自动调用此方法
editAfter() {
this.changeFormTypes(this.materialTable.columns, 'snList', 0)
this.changeFormTypes(this.materialTable.columns, 'batchNumber', 0)
this.changeFormTypes(this.materialTable.columns, 'expirationDate', 0)
if (this.action === 'add') {
this.addInit(this.prefixNo)
this.personList.value = ''

View File

@ -115,7 +115,7 @@
dataSource: [],
columns: [
{ title: '仓库名称', key: 'depotId', width: '7%', type: FormTypes.hidden },
{ title: '条码', key: 'barCode', width: '8%', type: FormTypes.popupJsh, multi: true,
{ title: '条码', key: 'barCode', width: '8%', type: FormTypes.popupJsh, kind: 'material', multi: true,
validateRules: [{ required: true, message: '${title}不能为空' }]
},
{ title: '名称', key: 'name', width: '6%', type: FormTypes.input, readonly: true },

View File

@ -186,7 +186,7 @@
{ title: '扩展信息', key: 'materialOther', width: '5%', type: FormTypes.input, readonly: true },
{ title: '库存', key: 'stock', width: '5%', type: FormTypes.input, readonly: true },
{ title: '单位', key: 'unit', width: '4%', type: FormTypes.input, readonly: true },
{ title: '序列号', key: 'snList', width: '5%', type: FormTypes.input },
{ title: '序列号', key: 'snList', width: '7%', type: FormTypes.popupJsh, kind: 'sn', multi: true },
{ title: '批号', key: 'batchNumber', width: '7%', type: FormTypes.popupJsh, kind: 'batch', multi: false },
{ title: '有效期', key: 'expirationDate',width: '5%', type: FormTypes.input, readonly: true },
{ title: '多属性', key: 'sku', width: '4%', type: FormTypes.input, readonly: true },
@ -234,6 +234,9 @@
methods: {
//调用完edit()方法之后会自动调用此方法
editAfter() {
this.changeFormTypes(this.materialTable.columns, 'snList', 0)
this.changeFormTypes(this.materialTable.columns, 'batchNumber', 0)
this.changeFormTypes(this.materialTable.columns, 'expirationDate', 0)
this.changeFormTypes(this.materialTable.columns, 'preNumber', 0)
this.changeFormTypes(this.materialTable.columns, 'finishNumber', 0)
if (this.action === 'add') {