From b13668095d135977874f05c79deb2a905603e3d7 Mon Sep 17 00:00:00 2001 From: zhangzhen Date: Tue, 2 Jun 2026 21:54:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=87=BA=E5=85=A5=E5=8F=A3?= =?UTF-8?q?=E8=B4=AE=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/index.js | 6 ++-- manifest.json | 4 +-- pages/inout/in.vue | 58 ++++++++++++++++++++++++++++++-- pages/inout/out.vue | 82 +++++++++++++++++++++++++++++++++++---------- 4 files changed, 127 insertions(+), 23 deletions(-) diff --git a/api/index.js b/api/index.js index 9aa4a38..39e154f 100644 --- a/api/index.js +++ b/api/index.js @@ -152,9 +152,11 @@ export const api = { // 贮存设施列表 facility: (params) => request({ - url: path + 'facility_list', - data: params + // url: path + 'facility_list', + url: path + 'sync_params', + data: { ...params, dict: 'storage_facilities' } }), + // 生产设施列表 prodFacility: (params) => request({ url: path + 'prod_facility_list', diff --git a/manifest.json b/manifest.json index e74b2a1..17fa965 100644 --- a/manifest.json +++ b/manifest.json @@ -2,8 +2,8 @@ "name" : "危废数据终端", "appid" : "__UNI__F18DD0A", "description" : "", - "versionName" : "1.0.3", - "versionCode" : 103, + "versionName" : "1.0.4", + "versionCode" : 104, "transformPx" : false, /* 5+App特有相关 */ "app-plus" : { diff --git a/pages/inout/in.vue b/pages/inout/in.vue index 55abea4..7d04272 100644 --- a/pages/inout/in.vue +++ b/pages/inout/in.vue @@ -19,12 +19,13 @@ {{ formData.entryDateTime }} - + 贮存经办人 @@ -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: '', diff --git a/pages/inout/out.vue b/pages/inout/out.vue index 761d4f4..8dd2c09 100644 --- a/pages/inout/out.vue +++ b/pages/inout/out.vue @@ -22,12 +22,13 @@ - + 出库时间 @@ -94,7 +95,9 @@ export default { digital_id: '', destination: '', direction_name: '', - time: '' + time: '', + storage_facility: '', // 贮存设施 code(提交用) + storage_facility_name: '' // 贮存设施名称(显示用) }, directionOptions: [ { value: 'wwlycz', label: '委外利用处置' }, @@ -102,6 +105,9 @@ export default { { value: 'zxlycz', label: '自行利用处置' } ], directionIndex: 0, + // 贮存设施选项列表 + storageFacilities: [], + storageFacilityIndex: 0, // 当前选中的贮存设施下标 outRecords: [], default: {}, dict: {} @@ -140,6 +146,7 @@ export default { await this.getOutRecords() await this.getOperators() + await this.getFacilitys() await this.getDefault() }, /** 获取出库历史记录 */ @@ -162,16 +169,52 @@ export default { // 获取经办人 async getOperators() { // 1.产生,2.贮存,3.运送,4.出库 - const res = await api.handler({ type: 4 }) - console.log('handler', res) + const res = await api.handler({ type: 4 }) + console.log('handler', res) + if (res.code == 1000) { + this.operators = res.data.map(res => { + return { + id: res.handler_code, + name: res.handler_name, + code: res.handler_code + } + }) + } + }, + // 获取贮存设施 + async getFacilitys() { + const res = await api.facility() + console.log('facility', res) if (res.code == 1000) { - this.operators = res.data.map(res => { + this.storageFacilities = res.data.list.map(item => { + const obj = {} + item.split('; ').forEach(pair => { + const [key, val] = pair.split('=') + obj[key] = val + }) return { - id: res.handler_code, - name: res.handler_name, - code: res.handler_code + sfid: obj.sfid, + label: obj.alias, + code: obj.code, + order: parseInt(obj.order) || 999 } - }) + }).sort((a, b) => a.order - b.order) + + 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.storage_facility = this.storageFacilities[defaultIndex].code + this.formData.storage_facility_name = this.storageFacilities[defaultIndex].label + } + } } }, @@ -244,6 +287,13 @@ export default { this.formData.destination = selected.value this.formData.direction_name = selected.label }, + /** 贮存设施 picker 变更 */ + onStorageFacilityChange(e) { + this.storageFacilityIndex = e.detail.value + const facility = this.storageFacilities[e.detail.value] + this.formData.storage_facility = facility.code + this.formData.storage_facility_name = facility.label + }, onAutoOutboundSwitchChange(e) { this.autoOutboundSwitch = e.detail.value }, @@ -254,14 +304,10 @@ export default { } try { const submitData = { - // 扫码值(危废标签二维码或数字识别码) code: this.formData.digital_id, - // 出库时间 yyyy-MM-dd HH:mm:ss time: this.formData.time, - // 去向 destination: this.formData.destination, - // 贮存设施编码(可选) - // storage_facility: this.formData.storage_facility + storage_facility: this.formData.storage_facility } const res = await api.deviceHwOut(submitData) uni.showToast({ title: '出库成功', icon: 'success' }) @@ -287,7 +333,9 @@ export default { digital_id: '', destination: '', direction_name: '', - time: getDateTime() + time: getDateTime(), + storage_facility: '', + storage_facility_name: '' } this.directionIndex = 0 },