增加出入口贮存

This commit is contained in:
2026-06-02 21:54:41 +08:00
parent b271b84f70
commit b13668095d
4 changed files with 127 additions and 23 deletions
+56 -2
View File
@@ -19,12 +19,13 @@
<view class="form-value">{{ formData.entryDateTime }}</view>
</view>
<!-- <view class="form-item">
<view class="form-item">
<text class="form-label required">贮存设施</text>
<picker class="form-value" :range="storageFacilities" range-key="label" :value="storageFacilityIndex" @change="onStorageFacilityChange">
<text>{{ formData.storageFacilityName || '选择贮存设施' }}</text>
<uni-icons type="right" size="14" color="#cccccc"></uni-icons>
</picker>
</view> -->
</view>
<view class="form-item">
<text class="form-label required">贮存经办人</text>
@@ -110,6 +111,8 @@ export default {
formData: {
digitalId: '', // 数字识别码(扫码或手动输入)
entryDateTime: '', // 入库时间
storageFacility: '', // 贮存设施 code(提交用)
storageFacilityName: '', // 贮存设施名称(显示用)
storageManagerId: '', // 贮存经办人 id
storageManagerName: '', // 贮存经办人姓名
storageManagerCode: '', // 贮存经办人编码
@@ -117,6 +120,9 @@ export default {
transportManagerName: '', // 运送经办人姓名
transportManagerCode: '' // 运送经办人编码
},
// 贮存设施选项列表
storageFacilities: [],
storageFacilityIndex: 0, // 当前选中的贮存设施下标
// 操作人员选项
operators: [
// { id: 1, name: '李伟', code: 'H_ZC_001' },
@@ -158,6 +164,7 @@ export default {
async initData() {
await this.getInRecords()
await this.getOperators()
await this.getFacilitys()
},
// 获取入库历史记录
async getInRecords() {
@@ -165,6 +172,43 @@ export default {
return res.data.list
})
},
async getFacilitys() {
const res = await api.facility()
console.log('facility', res)
if (res.code == 1000) {
// 解析 list 字符串数组为对象数组
this.storageFacilities = res.data.list.map(item => {
const obj = {}
item.split('; ').forEach(pair => {
const [key, val] = pair.split('=')
obj[key] = val
})
return {
sfid: obj.sfid,
label: obj.alias,
code: obj.code,
order: parseInt(obj.order) || 999
}
}).sort((a, b) => a.order - b.order)
// 设置默认值(从 default 字段解析)
if (res.data.default) {
const defaultObj = {}
res.data.default.split('; ').forEach(pair => {
const [key, val] = pair.split('=')
defaultObj[key] = val
})
const defaultIndex = this.storageFacilities.findIndex(
f => f.code === defaultObj.code
)
if (defaultIndex !== -1) {
this.storageFacilityIndex = defaultIndex
this.formData.storageFacility = this.storageFacilities[defaultIndex].code
this.formData.storageFacilityName = this.storageFacilities[defaultIndex].label
}
}
}
},
// 获取经办人
async getOperators() {
// 1.产生,2.贮存,3.运送,4.出库
@@ -279,6 +323,13 @@ export default {
this.formData.transportManagerName = operator.name
this.formData.transportManagerCode = operator.code
},
/** 贮存设施 picker 变更 */
onStorageFacilityChange(e) {
this.storageFacilityIndex = e.detail.value
const facility = this.storageFacilities[e.detail.value]
this.formData.storageFacility = facility.code
this.formData.storageFacilityName = facility.label
},
// ==================== 入库记录 ====================
/** 添加一条入库记录(最多保留 10 条) */
@@ -308,6 +359,7 @@ export default {
const submitData = {
code: this.formData.digitalId,
time: this.formData.entryDateTime,
storage_facility: this.formData.storageFacility,
storage_handler: this.formData.storageManagerCode,
transport_handler: this.formData.transportManagerCode
}
@@ -337,6 +389,8 @@ export default {
this.formData = {
digitalId: '',
entryDateTime: '',
storageFacility: '',
storageFacilityName: '',
storageManagerId: '',
storageManagerName: '',
storageManagerCode: '',