优化单据的序列号录入和选择功能

This commit is contained in:
季圣华
2022-09-30 00:21:33 +08:00
parent 5c02964145
commit c1c92d3479
8 changed files with 147 additions and 76 deletions

View File

@@ -1,10 +1,11 @@
<template> <template>
<div> <div>
<a-input-search v-if="kind === 'material'" v-model="names" placeholder="条码或名称" @pressEnter="onPressEnter" @search="onSearch"></a-input-search> <a-input-search v-if="kind === 'material'" v-model="names" placeholder="条码或名称" @pressEnter="onPressEnter" @search="onSearch"></a-input-search>
<a-input-search v-if="kind === 'batch'||kind === 'sn'" v-model="names" placeholder="选择" readOnly @search="onSearch"></a-input-search> <a-input-search v-if="kind === 'batch'||kind === 'sn'||kind === 'snAdd'" v-model="names" placeholder="点开弹窗" readOnly @search="onSearch"></a-input-search>
<j-select-material-modal v-if="kind === 'material'" ref="selectModal" :rows="rows" :multi="multi" :bar-code="value" @ok="selectOK" @initComp="initComp"/> <j-select-material-modal v-if="kind === 'material'" ref="selectModal" :rows="rows" :multi="multi" :bar-code="value" @ok="selectOK" @initComp="initComp"/>
<j-select-batch-modal v-if="kind === 'batch'" ref="selectModal" :rows="rows" :multi="multi" :bar-code="value" @ok="selectOK" @initComp="initComp"/> <j-select-batch-modal v-if="kind === 'batch'" ref="selectModal" :rows="rows" :multi="multi" :bar-code="value" @ok="selectOK" @initComp="initComp"/>
<j-select-sn-modal v-if="kind === 'sn'" ref="selectModal" :rows="rows" :multi="multi" :bar-code="value" @ok="selectOK" @initComp="initComp"/> <j-select-sn-modal v-if="kind === 'sn'" ref="selectModal" :rows="rows" :multi="multi" :bar-code="value" @ok="selectOK" @initComp="initComp"/>
<j-select-sn-add-modal v-if="kind === 'snAdd'" ref="selectModal" :rows="rows" :multi="multi" :bar-code="value" @ok="selectOK" @initComp="initComp"/>
</div> </div>
</template> </template>
@@ -12,13 +13,14 @@
import JSelectMaterialModal from './modal/JSelectMaterialModal' import JSelectMaterialModal from './modal/JSelectMaterialModal'
import JSelectBatchModal from './modal/JSelectBatchModal' import JSelectBatchModal from './modal/JSelectBatchModal'
import JSelectSnModal from './modal/JSelectSnModal' import JSelectSnModal from './modal/JSelectSnModal'
import JSelectSnAddModal from './modal/JSelectSnAddModal'
import { getMpListShort } from "@/utils/util" import { getMpListShort } from "@/utils/util"
import {getMaterialByBarCode} from '@/api/api' import {getMaterialByBarCode} from '@/api/api'
import Vue from 'vue' import Vue from 'vue'
export default { export default {
name: 'JSelectList', name: 'JSelectList',
components: {JSelectMaterialModal, JSelectBatchModal, JSelectSnModal}, components: {JSelectMaterialModal, JSelectBatchModal, JSelectSnModal, JSelectSnAddModal},
props: { props: {
value: { value: {
type: String, type: String,

View File

@@ -18,13 +18,14 @@
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :md="12" :sm="24"> <a-col :md="12" :sm="24">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="批号"> <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="批号">
<a-input placeholder="请输入批号" v-model="queryParam.name"></a-input> <a-input ref="name" placeholder="请输入批号" v-model="queryParam.name"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons"> <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
<a-col :md="12" :sm="24"> <a-col :md="12" :sm="24">
<a-button type="primary" @click="onSearch">查询</a-button> <a-button type="primary" @click="loadData(1)">查询</a-button>
<a-button style="margin-left: 8px" @click="searchReset(1)">重置</a-button> <a-button style="margin-left: 8px" @click="searchReset(1)">重置</a-button>
<span style="margin-left: 20px">提示:双击行可以直接选中</span>
</a-col> </a-col>
</span> </span>
</a-row> </a-row>
@@ -127,7 +128,7 @@
this.$emit('initComp', '') this.$emit('initComp', '')
} }
}, },
async loadData(arg) { loadData(arg) {
if(this.rows) { if(this.rows) {
if(JSON.parse(this.rows).depotId && JSON.parse(this.rows).barCode ){ if(JSON.parse(this.rows).depotId && JSON.parse(this.rows).barCode ){
let depotItemId = JSON.parse(this.rows).id let depotItemId = JSON.parse(this.rows).id
@@ -143,7 +144,7 @@
} }
this.loading = true this.loading = true
let params = this.getQueryParams()//查询条件 let params = this.getQueryParams()//查询条件
await getBatchNumberList(params).then((res) => { getBatchNumberList(params).then((res) => {
if (res && res.code === 200) { if (res && res.code === 200) {
this.dataSource = res.data.rows this.dataSource = res.data.rows
this.ipagination.total = res.data.total this.ipagination.total = res.data.total
@@ -153,9 +154,10 @@
}) })
}, },
showModal() { showModal() {
this.visible = true; this.visible = true
this.loadData(); this.$nextTick(() => this.$refs.name.focus())
this.form.resetFields(); this.loadData()
this.form.resetFields()
}, },
getQueryParams() { getQueryParams() {
let param = Object.assign({}, this.queryParam, this.isorter); let param = Object.assign({}, this.queryParam, this.isorter);
@@ -216,7 +218,18 @@
this.selectionRows = selectionRows; this.selectionRows = selectionRows;
}, },
onSearch() { onSearch() {
this.loadData(1); if(this.dataSource && this.dataSource.length===1) {
if(this.queryParam.name === this.dataSource[0].batchNumber) {
let arr = []
arr.push(this.dataSource[0].id)
this.selectedRowKeys = arr
this.handleSubmit()
} else {
this.loadData(1)
}
} else {
this.loadData(1)
}
}, },
modalFormOk() { modalFormOk() {
this.loadData(); this.loadData();

View File

@@ -7,10 +7,9 @@
@cancel="close" @cancel="close"
cancelText="关闭" cancelText="关闭"
style="top:5%;height: 100%;overflow-y: hidden" style="top:5%;height: 100%;overflow-y: hidden"
wrapClassName="ant-modal-cust-warp" wrapClassName="ant-modal-cust-warp">
>
<a-row :gutter="10" style="padding: 10px; margin: -10px"> <a-row :gutter="10" style="padding: 10px; margin: -10px">
<a-col :md="24" :sm="24"> <a-col :md="16" :sm="24">
<!-- 查询区域 --> <!-- 查询区域 -->
<div class="table-page-search-wrapper"> <div class="table-page-search-wrapper">
<!-- 搜索区域 --> <!-- 搜索区域 -->
@@ -18,32 +17,59 @@
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :md="12" :sm="24"> <a-col :md="12" :sm="24">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="序列号"> <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="序列号">
<a-input placeholder="请输入序列号" v-model="queryParam.name"></a-input> <a-input ref="name" placeholder="请输入序列号并回车" v-model="queryParam.name"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons"> <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
<a-col :md="12" :sm="24"> <a-col :md="12" :sm="24">
<a-button type="primary" @click="onSearch">查询</a-button> <a-button type="primary" @click="onSearch">查询</a-button>
<a-button style="margin-left: 8px" type="primary" @click="checkAll">全选</a-button>
<a-button style="margin-left: 8px" @click="searchReset(1)">重置</a-button> <a-button style="margin-left: 8px" @click="searchReset(1)">重置</a-button>
</a-col> </a-col>
</span> </span>
</a-row> </a-row>
</a-form> </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> </div>
</a-col> </a-col>
<a-col :md="8" :sm="24">
<span style="font-size: 16px;font-weight: bold;">此处为已选中的序列号列表</span>
<a-button style="margin-left: 8px" @click="clearAllSn">清空</a-button>
</a-col>
</a-row>
<a-row :gutter="10" style="padding: 10px; margin: -10px">
<a-col :md="16" :sm="24">
<a-table
ref="table"
style="width:95%"
:scroll="scrollTrigger"
size="middle"
rowKey="id"
:columns="leftColumns"
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
@change="handleTableChange">
<span slot="action" slot-scope="text, record">
<a @click="checkSn(record)">选中</a>
</span>
</a-table>
</a-col>
<a-col :md="8" :sm="24">
<a-table
ref="table"
:scroll="scrollTrigger"
size="middle"
rowKey="id"
:columns="rightColumns"
:dataSource="checkDataSource"
:pagination="false"
:loading="loading"
@change="handleTableChange">
<span slot="action" slot-scope="text, record">
<a @click="removeSn(record)">移除</a>
</span>
</a-table>
</a-col>
</a-row> </a-row>
</a-modal> </a-modal>
</template> </template>
@@ -60,7 +86,7 @@
props: ['rows', 'multi', 'barCode'], props: ['rows', 'multi', 'barCode'],
data() { data() {
return { return {
modalWidth: 800, modalWidth: 1000,
queryParam: { queryParam: {
name: "", name: "",
depotItemId: '', depotItemId: '',
@@ -76,13 +102,19 @@
sm: { span: 16 }, sm: { span: 16 },
}, },
categoryTree:[], categoryTree:[],
columns: [ leftColumns: [
{dataIndex: 'serialNumber', title: '序列号', width: 100, align: 'left'}, {dataIndex: 'serialNumber', title: '序列号', width: 100, align: 'left'},
{dataIndex: 'inBillNo', title: '入库单号', width: 100, align: 'left'}, {dataIndex: 'inBillNo', title: '入库单号', width: 100, align: 'left'},
{dataIndex: 'createTimeStr', title: '创建时间', width: 100, align: 'left'}, {dataIndex: 'createTimeStr', title: '创建时间', width: 100, align: 'left'},
{dataIndex: 'action', title: '操作', align:"center", width: 50, scopedSlots: { customRender: 'action' }}
], ],
scrollTrigger: {}, rightColumns: [
{dataIndex: 'serialNumber', title: '序列号', width: 100, align: 'left'},
{tdataIndex: 'action', title: '操作', align:"center", width: 50, scopedSlots: { customRender: 'action' }}
],
scrollTrigger: {y: 460},
dataSource: [], dataSource: [],
checkDataSource: [],
selectedRowKeys: [], selectedRowKeys: [],
selectRows: [], selectRows: [],
selectIds: [], selectIds: [],
@@ -132,11 +164,10 @@
if (this.barCode) { if (this.barCode) {
this.$emit('initComp', this.barCode) this.$emit('initComp', this.barCode)
} else { } else {
// JSelectUserByDep组件bug issues/I16634
this.$emit('initComp', '') this.$emit('initComp', '')
} }
}, },
async loadData(arg) { loadData(arg) {
if(this.rows) { if(this.rows) {
if(JSON.parse(this.rows).depotId && JSON.parse(this.rows).barCode ){ if(JSON.parse(this.rows).depotId && JSON.parse(this.rows).barCode ){
let depotItemId = JSON.parse(this.rows).id let depotItemId = JSON.parse(this.rows).id
@@ -152,19 +183,30 @@
} }
this.loading = true this.loading = true
let params = this.getQueryParams()//查询条件 let params = this.getQueryParams()//查询条件
await getEnableSerialNumberList(params).then((res) => { getEnableSerialNumberList(params).then((res) => {
if (res && res.code === 200) { if (res && res.code === 200) {
this.dataSource = res.data.rows this.dataSource = res.data.rows
this.ipagination.total = res.data.total this.ipagination.total = res.data.total
if(res.data.total ===1) {
if(this.queryParam.name === this.dataSource[0].serialNumber) {
let obj = {
id: this.dataSource[0].id,
serialNumber: this.dataSource[0].serialNumber
}
this.checkSn(obj)
this.queryParam.name = ''
}
}
} }
}).finally(() => { }).finally(() => {
this.loading = false this.loading = false
}) })
}, },
showModal() { showModal() {
this.visible = true; this.visible = true
this.loadData(); this.$nextTick(() => this.$refs.name.focus())
this.form.resetFields(); this.loadData()
this.form.resetFields()
}, },
getQueryParams() { getQueryParams() {
let param = Object.assign({}, this.queryParam, this.isorter); let param = Object.assign({}, this.queryParam, this.isorter);
@@ -179,6 +221,20 @@
} }
return str; return str;
}, },
checkAll() {
this.checkDataSource = []
let data = this.dataSource
for (let i = 0; i < data.length; i++) {
let checkObj = {
id: data[i].id,
serialNumber: data[i].serialNumber
}
this.checkDataSource.push(checkObj)
}
},
clearAllSn() {
this.checkDataSource = []
},
searchReset(num) { searchReset(num) {
let that = this; let that = this;
if (num !== 0) { if (num !== 0) {
@@ -217,18 +273,43 @@
that.searchReset(0) that.searchReset(0)
that.close(); that.close();
}, },
//获取选择信息 checkSn(record) {
getSelectRows(rowId) { let checkObj = {
let dataSource = this.dataSource; id: record.id,
let ids = ""; serialNumber: record.serialNumber
this.selectRows = []; }
for (let i = 0, len = dataSource.length; i < len; i++) { let data = this.checkDataSource
if (this.selectedRowKeys.includes(dataSource[i].id)) { let isExist = false
this.selectRows.push(dataSource[i]); for (let i = 0; i < data.length; i++) {
ids = ids + "," + dataSource[i].serialNumber if(data[i].serialNumber === record.serialNumber) {
isExist = true
} }
} }
this.selectIds = ids.substring(1); if(isExist) {
this.$message.warning('抱歉,此序列号已经选择过!');
} else {
this.checkDataSource.push(checkObj)
}
},
removeSn(record) {
let oldArr = this.checkDataSource
let newArr = []
for (let i = 0; i < oldArr.length; i++) {
if(oldArr[i].id !== record.id) {
newArr.push(oldArr[i])
}
}
this.checkDataSource = newArr
},
//获取选择信息
getSelectRows() {
let ids = ""
this.selectRows = this.checkDataSource
let data = this.checkDataSource
for (let i = 0; i < data.length; i++) {
ids = ids + "," + data[i].serialNumber
}
this.selectIds = ids.substring(1)
}, },
onSelectChange(selectedRowKeys, selectionRows) { onSelectChange(selectedRowKeys, selectionRows) {
this.selectedRowKeys = selectedRowKeys; this.selectedRowKeys = selectedRowKeys;
@@ -239,23 +320,6 @@
}, },
modalFormOk() { modalFormOk() {
this.loadData(); 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()
}
}
}
} }
} }
} }

View File

@@ -125,7 +125,7 @@ export const BillModalMixin = {
columns[i].type = FormTypes.popupJsh //显示 columns[i].type = FormTypes.popupJsh //显示
} else { } else {
if(key === 'snList') { if(key === 'snList') {
columns[i].type = FormTypes.input_pop //显示 columns[i].type = FormTypes.popupJsh //显示
} else { } else {
columns[i].type = FormTypes.input //显示 columns[i].type = FormTypes.input //显示
} }

View File

@@ -172,9 +172,7 @@
{ title: '扩展信息', key: 'materialOther', width: '5%', type: FormTypes.normal }, { title: '扩展信息', key: 'materialOther', width: '5%', type: FormTypes.normal },
{ title: '库存', key: 'stock', width: '5%', type: FormTypes.normal }, { title: '库存', key: 'stock', width: '5%', type: FormTypes.normal },
{ title: '单位', key: 'unit', width: '4%', type: FormTypes.normal }, { title: '单位', key: 'unit', width: '4%', type: FormTypes.normal },
{ title: '序列号', key: 'snList', width: '12%', type: FormTypes.input, placeholder: '多个序列号用逗号隔开请少于100个字符', { title: '序列号', key: 'snList', width: '12%', type: FormTypes.popupJsh, kind: 'snAdd', multi: true },
validateRules: [{ pattern: /^.{1,100}$/, message: '请小于100位字符' }]
},
{ title: '批号', key: 'batchNumber', width: '7%', type: FormTypes.input }, { title: '批号', key: 'batchNumber', width: '7%', type: FormTypes.input },
{ title: '有效期', key: 'expirationDate',width: '7%', type: FormTypes.date }, { title: '有效期', key: 'expirationDate',width: '7%', type: FormTypes.date },
{ title: '多属性', key: 'sku', width: '9%', type: FormTypes.normal }, { title: '多属性', key: 'sku', width: '9%', type: FormTypes.normal },

View File

@@ -269,9 +269,7 @@
{ title: '扩展信息', key: 'materialOther', width: '5%', type: FormTypes.normal }, { title: '扩展信息', key: 'materialOther', width: '5%', type: FormTypes.normal },
{ title: '库存', key: 'stock', width: '5%', type: FormTypes.normal }, { title: '库存', key: 'stock', width: '5%', type: FormTypes.normal },
{ title: '单位', key: 'unit', width: '4%', type: FormTypes.normal }, { title: '单位', key: 'unit', width: '4%', type: FormTypes.normal },
{ title: '序列号', key: 'snList', width: '12%', type: FormTypes.input, placeholder: '多个序列号用逗号隔开请少于100个字符', { title: '序列号', key: 'snList', width: '12%', type: FormTypes.popupJsh, kind: 'snAdd', multi: true },
validateRules: [{ pattern: /^.{1,100}$/, message: '请小于100位字符' }]
},
{ title: '批号', key: 'batchNumber', width: '7%', type: FormTypes.input }, { title: '批号', key: 'batchNumber', width: '7%', type: FormTypes.input },
{ title: '有效期', key: 'expirationDate',width: '7%', type: FormTypes.date }, { title: '有效期', key: 'expirationDate',width: '7%', type: FormTypes.date },
{ title: '多属性', key: 'sku', width: '9%', type: FormTypes.normal }, { title: '多属性', key: 'sku', width: '9%', type: FormTypes.normal },

View File

@@ -231,9 +231,7 @@
{ title: '扩展信息', key: 'materialOther', width: '7%', type: FormTypes.normal }, { title: '扩展信息', key: 'materialOther', width: '7%', type: FormTypes.normal },
{ title: '库存', key: 'stock', width: '5%', type: FormTypes.normal }, { title: '库存', key: 'stock', width: '5%', type: FormTypes.normal },
{ title: '单位', key: 'unit', width: '5%', type: FormTypes.normal }, { title: '单位', key: 'unit', width: '5%', type: FormTypes.normal },
{ title: '序列号', key: 'snList', width: '12%', type: FormTypes.input, placeholder: '多个序列号用逗号隔开请少于100个字符', { title: '序列号', key: 'snList', width: '12%', type: FormTypes.popupJsh, kind: 'snAdd', multi: true },
validateRules: [{ pattern: /^.{1,100}$/, message: '请小于100位字符' }]
},
{ title: '批号', key: 'batchNumber', width: '8%', type: FormTypes.input }, { title: '批号', key: 'batchNumber', width: '8%', type: FormTypes.input },
{ title: '有效期', key: 'expirationDate',width: '9%', type: FormTypes.date }, { title: '有效期', key: 'expirationDate',width: '9%', type: FormTypes.date },
{ title: '多属性', key: 'sku', width: '9%', type: FormTypes.normal }, { title: '多属性', key: 'sku', width: '9%', type: FormTypes.normal },

View File

@@ -247,9 +247,7 @@
{ title: '扩展信息', key: 'materialOther', width: '5%', type: FormTypes.normal }, { title: '扩展信息', key: 'materialOther', width: '5%', type: FormTypes.normal },
{ title: '库存', key: 'stock', width: '5%', type: FormTypes.normal }, { title: '库存', key: 'stock', width: '5%', type: FormTypes.normal },
{ title: '单位', key: 'unit', width: '4%', type: FormTypes.normal }, { title: '单位', key: 'unit', width: '4%', type: FormTypes.normal },
{ title: '序列号', key: 'snList', width: '12%', type: FormTypes.input, placeholder: '多个序列号用逗号隔开请少于100个字符', { title: '序列号', key: 'snList', width: '12%', type: FormTypes.popupJsh, kind: 'snAdd', multi: true },
validateRules: [{ pattern: /^.{1,100}$/, message: '请小于100位字符' }]
},
{ title: '批号', key: 'batchNumber', width: '7%', type: FormTypes.input }, { title: '批号', key: 'batchNumber', width: '7%', type: FormTypes.input },
{ title: '有效期', key: 'expirationDate',width: '7%', type: FormTypes.date }, { title: '有效期', key: 'expirationDate',width: '7%', type: FormTypes.date },
{ title: '多属性', key: 'sku', width: '9%', type: FormTypes.normal }, { title: '多属性', key: 'sku', width: '9%', type: FormTypes.normal },