sparkles: 人工盘点功能,待完善
All checks were successful
Release / lint (push) Successful in 52s
Release / Release (push) Successful in 1m56s

This commit is contained in:
my_ong 2025-03-09 15:55:23 +08:00
parent 90da064f25
commit 15cbb02e50
4 changed files with 236 additions and 2 deletions

View File

@ -3976,6 +3976,21 @@
"enum": [],
"typeProperties": []
}
},
{
"description": "是否赋码",
"required": false,
"in": "query",
"name": "assignRule",
"dataType": {
"typeArgs": [],
"typeName": "boolean",
"isDefsType": false,
"templateIndex": -1,
"compileTemplateKeyword": "#/definitions/",
"enum": [],
"typeProperties": []
}
}
]
},

View File

@ -6,6 +6,8 @@ import type { AxiosResponse } from 'axios'
export interface Params {
/** 类型 */
type?: string
/** 是否赋码 */
assignRule?: boolean
}
export default async function (

View File

@ -0,0 +1,207 @@
<template>
<a-form name="basic" layout="horizontal" label-wrap>
<a-form-item label="选择物料" name="selected">
<div style="display: flex; justify-content: space-between">
<a-tree-select
v-model:value="typeVal"
show-search
style="width: 49%"
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
placeholder="请选择物料类型"
allow-clear
:tree-data="types"
tree-node-filter-prop="label"
/>
<a-select
v-model:value="slectedList"
mode="multiple"
bordered
placeholder="请选择物料"
style="width: 49%"
show-search
:options="options"
:filter-option="filterOption"
@deselect="removeEvent($event)"
@select="insertEvent($event)"
></a-select>
</div>
</a-form-item>
</a-form>
<!-- vxe-table -->
<div>
<vxe-table
ref="tableRef"
v-model:data="tableData"
border
show-overflow
max-height="500"
size="medium"
empty-text="请先选择物料"
:edit-config="{ trigger: 'click', mode: 'cell', autoFocus: true }"
>
<vxe-column type="seq" title="序号" width="60" />
<vxe-column field="id" title="物料id" :visible="false" />
<vxe-column field="name" title="物料名称" />
<vxe-column field="code" title="编码" />
<vxe-column field="spec" title="规格" />
<vxe-column field="price" title="价格" />
<vxe-column field="typeName" title="类型" />
<vxe-column field="stock" title="库存数量" />
<vxe-column
field="manualStock"
title="手动何时数量"
:edit-render="{ name: 'input', autoSelect: true }"
keyboard-config="{edit: true, del: true}"
cell-type="number"
>
<template #edit="{ row }">
<vxe-number-input v-model="row.manualStock" type="integer"></vxe-number-input>
</template>
</vxe-column>
<vxe-column field="oprator" title="操作">
<template #default="{ row }">
<vxe-button mode="text" status="error" @click="removeRow(row)">删除</vxe-button>
</template>
</vxe-column>
</vxe-table>
</div>
</template>
<script lang="ts" setup>
import api from '@/api'
import { TreeDataNode } from 'ant-design-vue/es/vc-tree-select/interface'
import dayjs, { Dayjs } from 'dayjs'
import { VxeTableInstance } from 'vxe-table'
import { LabeledValue, DefaultOptionType } from 'ant-design-vue/es/select'
import { SelectHandler } from 'ant-design-vue/es/vc-select/Select'
const typeVal = ref('')
const slectedList = ref<number[]>([])
//
const options = ref<{ label: string; value: number }[]>([])
const materialList = ref<material.Material[]>([])
const getMaterialList = async () => {
await api.materialApi.material.all({ type: typeVal.value, assignRule: false }, (data) => {
materialList.value = data
})
options.value = materialList.value.map((item) => {
return { label: item.name ? item.name : '未知', value: item.id ? item.id : -1 }
})
}
watch(
typeVal,
(newVal) => {
if (newVal !== '') {
getMaterialList()
}
},
{ immediate: true, deep: true },
)
//
const types = ref<Array<TreeDataNode>>([])
api.materialApi.type.trees((data) => {
types.value = children(data)
})
const children = (res: Array<material.TypeTree>): Array<TreeDataNode> => {
return res.map((areaTree) => ({
label: areaTree.label,
value: areaTree.value,
children: areaTree.children ? children(areaTree.children) : [],
key: areaTree.value,
}))
}
//
const filterOption = (input: string, option: { label: string; value: number }) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
// vxe-table
export interface RowVO {
id: number
name: string
code: string
spec: string
type: string
typeName: string
quantity: number
disabled: boolean
checked: boolean
price: number
assignRule: boolean
}
// vxe
const tableRef = ref<VxeTableInstance<RowVO>>()
// vxe-table
const tableData = ref<Array<RowVO>>([])
interface FormData {
applicant: string //
applyDate: Dayjs //
slectedList: number[] //
reviewer: string //
}
const formData = ref<FormData>({
applicant: '',
applyDate: dayjs(),
slectedList: [],
reviewer: '',
})
// table
const removeRow = async (row: RowVO) => {
//tableData
const $table = tableRef.value
if ($table) {
// row.id
formData.value.slectedList.forEach((item, index) => {
if (item.toString() === row.id.toString()) {
formData.value.slectedList.splice(index, 1)
}
})
$table.remove(row)
}
}
// table
type Insert = SelectHandler<LabeledValue, DefaultOptionType> | undefined
const removeEvent = (value: Insert) => {
const $table = tableRef.value
// value
if ($table) {
$table.getTableData().fullData.forEach((item) => {
if (item.id === value) {
$table.remove(item)
}
})
}
}
const insertEvent = (value: Insert) => {
// value
const m = materialList.value.find((item) => item.id === value)
if (m) {
const row: RowVO = {
id: m.id ? m.id : -1,
name: m.name ? m.name : '',
code: m.code ? m.code : '',
spec: m.spec ? m.spec : '',
typeName: m.typeName ? m.typeName : '',
type: m.type ? m.type : '',
price: m.price ? m.price : 0,
quantity: 1,
assignRule: m.assignRule ? m.assignRule : false,
disabled: false,
checked: false,
}
const $table = tableRef.value
if ($table) {
$table.insertAt(row, -1)
}
}
}
</script>

View File

@ -108,6 +108,10 @@
>
<result-form ref="handleResultRef" :apply-id="applyIdRef"></result-form>
</a-modal>
<!-- 手动盘点弹窗 -->
<a-modal v-model:open="openManual" title="手动盘点" width="80%" :confirm-loading="confirmLoading" @ok="manualHandle">
<manual-form ref="manualFormRef" :apply-id="applyIdRef"></manual-form>
</a-modal>
</template>
<script setup lang="ts">
@ -121,6 +125,7 @@
import scanForm from '../component/scan-form.vue'
import resultForm from './result-form.vue'
import { TreeDataNode } from 'ant-design-vue/es/vc-tree-select/interface'
import manualForm from '../component/manual-form.vue'
const searchKey = ref('')
const userStore = useUserStore()
@ -305,9 +310,15 @@
}
}
//
//
const openManual = ref<boolean>(false)
const showManualModal = (applyId: number) => {
console.log('点击传参' + applyId)
openManual.value = true
}
const manualHandle = () => {
openManual.value = false
//
}
//
@ -321,7 +332,6 @@
data.forEach((item) => (totalValue.value += item.count || 0))
msg.value = m
})
window.console.log(m)
msg.value = m
}