扫码枪对接
This commit is contained in:
parent
73df90e8ae
commit
b9fefb123a
@ -3,21 +3,21 @@
|
|||||||
<div>
|
<div>
|
||||||
<a-form :model="formData" name="basic" layout="horizontal" labelWrap>
|
<a-form :model="formData" name="basic" layout="horizontal" labelWrap>
|
||||||
<a-form-item label="申请人" name="applicant">
|
<a-form-item label="申请人" name="applicant">
|
||||||
<a-input v-model:value="formData.applicant" style="width: 40%;" />
|
<a-input :value="formData.applicant" style="width: 40%;" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
<a-form-item label="申请类型" name="applyType">
|
<a-form-item label="申请类型" name="applyType">
|
||||||
<a-radio-group v-model:value="formData.applyType" button-style="solid" style="width: 40%;">
|
<a-radio-group v-model:value="formData.applyType" button-style="solid" style="width: 40%;">
|
||||||
<a-radio-button value=1>采购入库</a-radio-button>
|
<a-radio-button value='1'>采购入库</a-radio-button>
|
||||||
<a-radio-button value=2>归还入库</a-radio-button>
|
<a-radio-button value='2'>归还入库</a-radio-button>
|
||||||
</a-radio-group>
|
</a-radio-group>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="申请日期" name="applyDate" style="width: 40%;">
|
<a-form-item label="申请日期" name="applyDate" style="width: 40%;" >
|
||||||
<a-date-picker />
|
<a-date-picker v-model:value="formData.applyDate" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="入库物料" name="selected">
|
<a-form-item label="入库物料" name="selected">
|
||||||
<a-select v-model:value="formData.slectedList" mode="multiple" bordered placeholder="请选择入库物料"
|
<a-select v-model:value="formData.slectedList" mode="multiple" bordered placeholder="请选择入库物料"
|
||||||
style="width: 40%;" showArrow :options="options" @deselect="removeEvent"
|
style="width: 40%;" showArrow :options="options" @deselect="removeEvent"
|
||||||
@select="insertEvent"></a-select>
|
@select="insertEvent"></a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
@ -25,45 +25,24 @@
|
|||||||
|
|
||||||
<!-- vxe-table -->
|
<!-- vxe-table -->
|
||||||
<div>
|
<div>
|
||||||
<vxe-table border show-overflow ref="tableRef" max-height="500" :column-config="{ resizable: true }"
|
<vxe-table border show-overflow ref="tableRef" max-height="500" size="medium" v-model:data="tableData"
|
||||||
size="medium" :data="tableData" empty-text="请先选择入库物料" :edit-config="{ trigger: 'click', mode: 'cell' }"
|
empty-text="请先选择入库物料" :edit-config="{ trigger: 'click', mode: 'cell', autoFocus: true }">
|
||||||
:checkbox-config="{ trigger: 'row', highlight: true }">
|
|
||||||
<vxe-column type="seq" title="序号" width="60"></vxe-column>
|
|
||||||
<vxe-column field="id" title="物料id" :visible="false"></vxe-column>
|
|
||||||
<vxe-column field="role" title="物料名称" beforeEditMethod="false">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<span>{{ row.name }}</span>
|
|
||||||
</template>
|
|
||||||
</vxe-column>
|
|
||||||
<vxe-column field="code" title="编码" beforeEditMethod="false">
|
|
||||||
<template #edit="{ row }">
|
|
||||||
<vxe-input v-model="row.code" type="text"></vxe-input>
|
|
||||||
</template>
|
|
||||||
</vxe-column>
|
|
||||||
|
|
||||||
<vxe-column field="spec" title="规格" beforeEditMethod="false">
|
<vxe-column type="seq" title="序号" width="60" />
|
||||||
<template #edit="{ row }">
|
<vxe-column field="id" title="物料id" :visible="false" />
|
||||||
<vxe-input v-model="row.spec" type="text" transfer></vxe-input>
|
<vxe-column field="name" title="物料名称" />
|
||||||
</template>
|
<vxe-column field="code" title="编码" />
|
||||||
</vxe-column>
|
<vxe-column field="spec" title="规格" />
|
||||||
<vxe-column field="type" title="类型" beforeEditMethod="false">
|
<vxe-column field="type" title="类型" />
|
||||||
<template #edit="{ row }">
|
<vxe-column field="assignRule" title="赋码规则" />
|
||||||
<vxe-input v-model="row.type" type="text" transfer>
|
<vxe-column field="quantity" title="申请数量(点击修改)" :edit-render="{ name: 'input', autoSelect: true }"
|
||||||
</vxe-input>
|
keyboard-config="{edit: true, del: true}" cell-type="number">
|
||||||
</template>
|
|
||||||
</vxe-column>
|
|
||||||
<vxe-column field="assignRule" title="赋码规则" beforeEditMethod="false">
|
|
||||||
<template #edit="{ row }">
|
|
||||||
<vxe-input v-model="row.assignRule" type="text" transfer>
|
|
||||||
</vxe-input>
|
|
||||||
</template>
|
|
||||||
</vxe-column>
|
|
||||||
<vxe-column field="quantity" title="申请数量" :edit-render="{}">
|
|
||||||
<template #edit="{ row }">
|
<template #edit="{ row }">
|
||||||
<vxe-number-input v-model="row.quantity" type="integer"></vxe-number-input>
|
<vxe-number-input v-model="row.quantity" type="integer"></vxe-number-input>
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</vxe-column>
|
||||||
<vxe-column field="oprator" title="操作" beforeEditMethod="false">
|
|
||||||
|
<vxe-column field="oprator" title="操作">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<vxe-button mode="text" status="error" @click="removeRow(row)">删除</vxe-button>
|
<vxe-button mode="text" status="error" @click="removeRow(row)">删除</vxe-button>
|
||||||
</template>
|
</template>
|
||||||
@ -77,19 +56,21 @@
|
|||||||
import { VxeTableInstance } from 'vxe-table'
|
import { VxeTableInstance } from 'vxe-table'
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
|
import dayjs,{Dayjs} from 'dayjs';
|
||||||
|
|
||||||
|
|
||||||
interface FormData {
|
interface FormData {
|
||||||
applicant: string; // 申请人
|
applicant: string; // 申请人
|
||||||
applyDate: Date; // 申请日期
|
applyDate: Dayjs; // 申请日期
|
||||||
applyType: number; // 申请类型
|
applyType: string; // 申请类型
|
||||||
slectedList: string[]; // 入库物料
|
slectedList: number[]; // 入库物料
|
||||||
}
|
}
|
||||||
|
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const formData = ref<FormData>({
|
const formData = ref<FormData>({
|
||||||
applicant: userStore.userName,
|
applicant: userStore.userName,
|
||||||
applyDate: new Date(),
|
applyDate: dayjs(),
|
||||||
applyType: 1, // 1: 采购入库 2: 归还入库 3: 出库外借
|
applyType: '1', // 1: 采购入库 2: 归还入库 3: 出库外借
|
||||||
slectedList: []
|
slectedList: []
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -124,33 +105,33 @@ const getMaterialList = async () => {
|
|||||||
getMaterialList()
|
getMaterialList()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 选中时在末尾新增一行
|
// 选中时在末尾新增一行
|
||||||
// value: number, option: { label: string, value: number }
|
// value: number, option: { label: string, value: number }
|
||||||
const insertEvent = (value: string) => {
|
const insertEvent = (value: string) => {
|
||||||
|
|
||||||
window.console.log('insertEvent', tableData.value)
|
|
||||||
|
|
||||||
// 根据value找到对应的物料信息
|
// 根据value找到对应的物料信息
|
||||||
const material = materialList.value.find((item) => item.id === (value ? parseInt(value) : -1))
|
const m = materialList.value.find((item) => item.id === (value ? parseInt(value) : -1))
|
||||||
if (material) {
|
if (m) {
|
||||||
const row: RowVO = {
|
const row: RowVO = {
|
||||||
id: material.id ? material.id : -1,
|
id: m.id ? m.id : -1,
|
||||||
name: material.name ? material.name : '未知',
|
name: m.name ? m.name : '未知',
|
||||||
code: material.code ? material.code : '未知',
|
code: m.code ? m.code : '未知',
|
||||||
spec: material.spec ? material.spec : '未知',
|
spec: m.spec ? m.spec : '未知',
|
||||||
type: material.type ? material.type : '未知',
|
type: m.type ? m.type : '未知',
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
assignRule: material.assignRule ? material.assignRule : 1,
|
assignRule: m.assignRule ? m.assignRule : 1,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
checked: false
|
checked: false
|
||||||
}
|
}
|
||||||
const $table = tableRef.value
|
const $table = tableRef.value
|
||||||
if ($table) {
|
if ($table) {
|
||||||
$table.insertAt(row, -1)
|
$table.insertAt(row, -1)
|
||||||
|
window.console.log('表数据1:', tableData.value)
|
||||||
|
window.console.log('表数据2:', $table.getTableData().fullData)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消选中时,删除table中的行
|
// 取消选中时,删除table中的行
|
||||||
@ -183,4 +164,3 @@ const removeRow = async (row: RowVO) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -14,11 +14,6 @@
|
|||||||
<scan-form></scan-form>
|
<scan-form></scan-form>
|
||||||
</div>
|
</div>
|
||||||
<!-- 按钮 -->
|
<!-- 按钮 -->
|
||||||
<a-space wrap class="fixed-button-container">
|
|
||||||
<a-button type="default" @click="current = current - 1" v-if="current > 0">上一步</a-button>
|
|
||||||
<a-button type="primary" @click="current = current + 1" v-if="current < 2">下一步</a-button>
|
|
||||||
<a-button type="primary" @click="btnClick" v-if="current === 2">提交</a-button>
|
|
||||||
</a-space>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@ -31,9 +26,6 @@ import scanForm from '../component/scanForm.vue';
|
|||||||
const current = ref<number>(0)
|
const current = ref<number>(0)
|
||||||
const items = [{ title: '录入申请' }, { title: '扫码点货' }, { title: '人工确认' }]
|
const items = [{ title: '录入申请' }, { title: '扫码点货' }, { title: '人工确认' }]
|
||||||
|
|
||||||
const btnClick = () => {
|
|
||||||
console.log('提交')
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -1,51 +1,35 @@
|
|||||||
<template>
|
<template>
|
||||||
<a-button type="primary" @click="autoInsertOneRow">开始扫码</a-button>
|
<a-button type="primary" @click="beiginScan">开始扫码</a-button>
|
||||||
<a-button type="primary" danger style="left: 20px;">重新扫码</a-button>
|
<a-button type="primary" danger style="left: 20px;">重新扫码</a-button>
|
||||||
<vxe-table border stripe show-overflow ref="applyDetailTableRef" max-height="500"
|
<a-input bordered size="large"
|
||||||
:column-config="{ resizable: true }" :keyboard-config="{ isEsc: true, isEnter: true }" size="medium"
|
ref="snInput" v-model:value="value" placeholder="输入条形码" @pressEnter="autoInsertOneRow" style="margin-top: 20px; margin-bottom: 20px;"/>
|
||||||
empty-text="请先扫码物料体条码" :edit-config="{ trigger: 'click', mode: 'cell', autoFocus: true}">
|
<!-- Esc键退出编辑功能 -->
|
||||||
|
<vxe-table border stripe show-overflow ref="applyDetailTableRef" max-height="500"
|
||||||
|
:column-config="{ resizable: true }" :keyboard-config="{ isEsc: true }" size="medium" empty-text="请先扫码物料体条码"
|
||||||
|
:edit-config="{ trigger: 'click', mode: 'cell' }">
|
||||||
|
|
||||||
<vxe-column type="seq" title="序号" width="60"></vxe-column>
|
<vxe-column type="seq" title="序号" width="60"></vxe-column>
|
||||||
<vxe-column field="id" title="物料id" :visible="false"></vxe-column>
|
<vxe-column field="id" title="物料id" :visible="false"></vxe-column>
|
||||||
<vxe-column field="barcode" title="物料条码" :edit-render="{ name: 'input', autoSelect: true }">
|
<vxe-column field="barcode" title="物料条码" :edit-render="{ name: 'input', autoFocus: true, immediate: true }" />
|
||||||
<template #edit="{ row }">
|
<vxe-column field="role" title="物料名称" />
|
||||||
<vxe-input v-model="row.barcode" type="text" class="my-input" transfer></vxe-input>
|
<vxe-column field="code" title="编码" />
|
||||||
</template>
|
<vxe-column field="spec" title="规格" />
|
||||||
</vxe-column>
|
<vxe-column field="type" title="类型" />
|
||||||
<vxe-column field="role" title="物料名称" beforeEditMethod="false">
|
<vxe-column field="oprator" title="操作">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<span>{{ row.name }}</span>
|
<vxe-button mode="text" status="error" @click="removeStep2Row(row)">删除</vxe-button>
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</vxe-column>
|
||||||
<vxe-column field="code" title="编码" beforeEditMethod="false">
|
|
||||||
<template #edit="{ row }">
|
|
||||||
<vxe-input v-model="row.code" type="text"></vxe-input>
|
|
||||||
</template>
|
|
||||||
</vxe-column>
|
|
||||||
|
|
||||||
<vxe-column field="spec" title="规格" beforeEditMethod="false">
|
</vxe-table>
|
||||||
<template #edit="{ row }">
|
|
||||||
<vxe-input v-model="row.spec" type="text" transfer></vxe-input>
|
|
||||||
</template>
|
|
||||||
</vxe-column>
|
|
||||||
<vxe-column field="type" title="类型" beforeEditMethod="false">
|
|
||||||
<template #edit="{ row }">
|
|
||||||
<vxe-input v-model="row.type" type="text" transfer>
|
|
||||||
</vxe-input>
|
|
||||||
</template>
|
|
||||||
</vxe-column>
|
|
||||||
<vxe-column field="oprator" title="操作" beforeEditMethod="false">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<vxe-button mode="text" status="error" @click="removeStep2Row(row)">删除</vxe-button>
|
|
||||||
</template>
|
|
||||||
</vxe-column>
|
|
||||||
|
|
||||||
</vxe-table>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { VxeTableInstance } from 'vxe-table'
|
import { VxeTableInstance } from 'vxe-table'
|
||||||
|
import { useTemplateRef } from 'vue'
|
||||||
|
//扫码的条形码字符串
|
||||||
|
const value = ref('')
|
||||||
|
const input = useTemplateRef('snInput');
|
||||||
|
|
||||||
interface Step2RowVO {
|
interface Step2RowVO {
|
||||||
barcode: string
|
barcode: string
|
||||||
@ -66,26 +50,34 @@ const removeStep2Row = async (row: Step2RowVO) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function beiginScan() {
|
||||||
|
input.value?.focus()
|
||||||
|
}
|
||||||
|
|
||||||
// 点击开始扫码按钮,自动新增一行 或者 扫码结束后也自动新增一行
|
// 点击开始扫码按钮,自动新增一行 或者 扫码结束后也自动新增一行
|
||||||
const autoInsertOneRow = async () => {
|
const autoInsertOneRow = async () => {
|
||||||
const $table = applyDetailTableRef.value
|
const $table = applyDetailTableRef.value
|
||||||
|
const sn = value.value.trim();
|
||||||
|
/**
|
||||||
|
* 1. 判断sn是否合法
|
||||||
|
* 2. 判断sn是否已经存在于表格中,需要缓存sn列表
|
||||||
|
* 3. 根据sn获取物料信息,并新增一行到表格中,需要缓存物料信息
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
// // 获取表格的最后一行,判断是否有数据
|
// // 获取表格的最后一行,判断是否有数据
|
||||||
// const fullData = $table?.getTableData().fullData;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($table) {
|
if ($table) {
|
||||||
const row: Step2RowVO = {
|
const row: Step2RowVO = {
|
||||||
barcode: '',
|
barcode: sn,
|
||||||
name: '',
|
name: '',
|
||||||
code: '',
|
code: '',
|
||||||
spec: '',
|
spec: '',
|
||||||
type: '',
|
type: '',
|
||||||
times: new Date()
|
times: new Date()
|
||||||
}
|
}
|
||||||
$table.insertAt(row, -1)
|
$table.insert(row)
|
||||||
|
// 添加后就清空输入框
|
||||||
|
value.value = ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -25,16 +25,10 @@
|
|||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
import { IPage } from '@/api/api'
|
import { IPage } from '@/api/api'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const searchKey = ref('')
|
const searchKey = ref('')
|
||||||
const pagedata = ref<IPage<material.ApplyForm>>()
|
const pagedata = ref<IPage<material.ApplyForm>>()
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 加载数据的方法
|
// 加载数据的方法
|
||||||
const loadData = async (page = 1, size = 10) => {
|
const loadData = async (page = 1, size = 10) => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user