辅助条码关联包装单位
This commit is contained in:
1 parent
4d8e3b9a33
commit
cf76c55690
3 files changed
+29
-6
No files matched your search
@@ -31,9 +31,22 @@
|
|||||||
>
|
>
|
||||||
<vxe-column type="checkbox" width="40" fixed="left" />
|
<vxe-column type="checkbox" width="40" fixed="left" />
|
||||||
<vxe-column type="seq" width="50" fixed="left" />
|
<vxe-column type="seq" width="50" fixed="left" />
|
||||||
<vxe-column field="barCode" title="条码" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
<vxe-column field="unit" title="单位" :edit-render="{}">
|
||||||
<template #edit="{ row }">
|
<template #edit="{ row }">
|
||||||
<el-input v-model.trim="row.barCode" />
|
<el-select v-model="row.unit">
|
||||||
|
<div v-for="item in smErpUnitEntityList">
|
||||||
|
<el-option v-if="item.unit !== ''" :label="item.unit" :value="item.unit" />
|
||||||
|
</div>
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
<template #default="{ row }">
|
||||||
|
<span v-if="row.unit">{{ row.unit }}</span>
|
||||||
|
<span v-else style="color: #c0c4cf">请选择</span>
|
||||||
|
</template>
|
||||||
|
</vxe-column>
|
||||||
|
<vxe-column field="barCode" title="条码">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ smErpUnitEntityList?.find((item: any) => item.unit == row.unit)?.barCode }}
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</vxe-column>
|
||||||
</vxe-table>
|
</vxe-table>
|
||||||
@@ -47,20 +60,27 @@ const supermarketAuxiliaryCodeEntityList = defineModel("supermarketAuxiliaryCode
|
|||||||
default: [
|
default: [
|
||||||
{
|
{
|
||||||
id: nanoid(5),
|
id: nanoid(5),
|
||||||
|
unit: "",
|
||||||
barCode: "",
|
barCode: "",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
smErpUnitEntityList: any[]
|
||||||
|
}>()
|
||||||
|
|
||||||
const editableTableRef = ref()
|
const editableTableRef = ref()
|
||||||
const validRules = {
|
const validRules = {
|
||||||
barCode: [{ required: true, message: "条码不能为空", trigger: "blur" }],
|
unit: [{ required: true, message: "包装单位不能为空", trigger: "blur" }],
|
||||||
|
// barCode: [{ required: true, message: "条码不能为空", trigger: "blur" }],
|
||||||
}
|
}
|
||||||
|
|
||||||
// 底部表格行新增
|
// 底部表格行新增
|
||||||
const pushEvent = () => {
|
const pushEvent = () => {
|
||||||
const newRow: any = {
|
const newRow: any = {
|
||||||
id: nanoid(5),
|
id: nanoid(5),
|
||||||
|
unit: "",
|
||||||
barCode: "",
|
barCode: "",
|
||||||
isNew: true,
|
isNew: true,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
<el-input v-model.trim="row.unit" />
|
<el-input v-model.trim="row.unit" />
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</vxe-column>
|
||||||
<vxe-column field="status" title="状态" :edit-render="{ autoFocus: 'input', placeholder: '请选择' }">
|
<vxe-column field="status" title="状态" :edit-render="{}">
|
||||||
<template #edit="{ row }">
|
<template #edit="{ row }">
|
||||||
<el-select v-model="row.status">
|
<el-select v-model="row.status">
|
||||||
<el-option label="正常" :value="0" />
|
<el-option label="正常" :value="0" />
|
||||||
|
|||||||
@@ -138,6 +138,7 @@
|
|||||||
<el-tab-pane label="辅助条码" name="辅助条码" style="overflow-y: auto; height: 60vh">
|
<el-tab-pane label="辅助条码" name="辅助条码" style="overflow-y: auto; height: 60vh">
|
||||||
<supermarket-auxiliaryCode
|
<supermarket-auxiliaryCode
|
||||||
ref="supermarketAuxiliaryCodeEntityList"
|
ref="supermarketAuxiliaryCodeEntityList"
|
||||||
|
:smErpUnitEntityList="form.smErpUnitEntityList"
|
||||||
v-model:supermarketAuxiliaryCodeEntityList="form.smErpAuxiliaryCodeEntityList"
|
v-model:supermarketAuxiliaryCodeEntityList="form.smErpAuxiliaryCodeEntityList"
|
||||||
/>
|
/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
@@ -330,6 +331,8 @@ const useHandleUnit = () => {
|
|||||||
// 整理辅助条码列表
|
// 整理辅助条码列表
|
||||||
const useHandleAuxiliaryCode = () => {
|
const useHandleAuxiliaryCode = () => {
|
||||||
return form.smErpAuxiliaryCodeEntityList.map((item: any) => {
|
return form.smErpAuxiliaryCodeEntityList.map((item: any) => {
|
||||||
|
const barCode = form.smErpUnitEntityList.find((item2: any) => item2.unit === item.unit).barCode
|
||||||
|
item.barCode = barCode
|
||||||
if (item.isNew) {
|
if (item.isNew) {
|
||||||
item.id = ""
|
item.id = ""
|
||||||
delete item.isNew
|
delete item.isNew
|
||||||
@@ -340,8 +343,6 @@ const useHandleAuxiliaryCode = () => {
|
|||||||
|
|
||||||
// 提交
|
// 提交
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
console.log("提交的数据", form)
|
|
||||||
|
|
||||||
const valid = await dataFormRef.value.validate().catch(() => {})
|
const valid = await dataFormRef.value.validate().catch(() => {})
|
||||||
if (!valid) return useMessage().warning("基础信息必填项未填写完整")
|
if (!valid) return useMessage().warning("基础信息必填项未填写完整")
|
||||||
if (!form.smErpUnitEntityList || form.smErpUnitEntityList.length <= 0) return useMessage().warning("请添加包装单位")
|
if (!form.smErpUnitEntityList || form.smErpUnitEntityList.length <= 0) return useMessage().warning("请添加包装单位")
|
||||||
@@ -353,6 +354,8 @@ const onSubmit = async () => {
|
|||||||
|
|
||||||
const handleUnit = useHandleUnit()
|
const handleUnit = useHandleUnit()
|
||||||
const handleAuxiliaryCode = useHandleAuxiliaryCode()
|
const handleAuxiliaryCode = useHandleAuxiliaryCode()
|
||||||
|
console.log("提交的数据", { ...form, smErpUnitEntityList: handleUnit, smErpAuxiliaryCodeEntityList: handleAuxiliaryCode })
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
const _pa = { ...form, smErpUnitEntityList: handleUnit, smErpAuxiliaryCodeEntityList: handleAuxiliaryCode }
|
const _pa = { ...form, smErpUnitEntityList: handleUnit, smErpAuxiliaryCodeEntityList: handleAuxiliaryCode }
|
||||||
|
|||||||
Reference in new issue
Block a user