feat(pda): 添加坯布出仓单功能和扫码设置界面
- 新增坯布出仓单相关API接口,包括列表、详情、新增、审核等功能 - 添加营销体系、往来单位、字典明细等基础数据接口 - 在用户中心添加扫描设置入口,支持PDA扫码枪配置 - 创建扫描设置页面,支持选择PDA品牌并配置广播动作和数据标签 - 重构扫码混入逻辑,支持远程配置和本地配置合并 - 添加扫码配置存储和读取功能,支持配置持久化 - 优化扫码广播注册流程,优先使用用户配置的扫码枪设置
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
<u-cell-item icon="question-circle" :iconStyle="{ color: '#ff8d06' }" title="常见问题" @click="navTo('problem')"></u-cell-item>
|
||||
<u-cell-item icon="kefu-ermai" :iconStyle="{ color: '#5f8dff' }" title="意见反馈" @click="navTo('comment')"></u-cell-item>
|
||||
<u-cell-item icon="map" :iconStyle="{ color: '#316ede' }" title="账号安全" @click="navTo('pwd')"></u-cell-item>
|
||||
<u-cell-item icon="scan" :iconStyle="{ color: '#36cfc9' }" title="扫描设置" @click="navTo('scan-settings')"></u-cell-item>
|
||||
<u-cell-item icon="order" :iconStyle="{ color: '#59bdf9' }" title="清除缓存" @click="navTo('clear-cache')"></u-cell-item>
|
||||
<!--<u-cell-item icon="account" :iconStyle="{ color: '#27c0dc' }" title="关于我们" @click="navTo('about')"></u-cell-item>
|
||||
<u-cell-item icon="kefu-ermai" :iconStyle="{ color: '#ff8a00' }" title="联系客服" @click="navTo('service')"></u-cell-item>!-->
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
<template>
|
||||
<view class="wrap">
|
||||
<common-navbar title="扫描设置"></common-navbar>
|
||||
<u-gap height="20" bg-color="#f5f5f5"></u-gap>
|
||||
<u-cell-group :border="false">
|
||||
<u-cell-item title="PDA品牌" :value="form.name || '请选择'" @click="brandSelectShow = true"></u-cell-item>
|
||||
<u-cell-item title="广播动作" :arrow="false">
|
||||
<u-input
|
||||
slot="right-icon"
|
||||
v-model="form.action"
|
||||
placeholder="请输入广播动作"
|
||||
input-align="right"
|
||||
:clearable="false"
|
||||
></u-input>
|
||||
</u-cell-item>
|
||||
<u-cell-item title="数据标签" :arrow="false">
|
||||
<u-input
|
||||
slot="right-icon"
|
||||
v-model="form.dataKey"
|
||||
placeholder="请输入数据标签"
|
||||
input-align="right"
|
||||
:clearable="false"
|
||||
></u-input>
|
||||
</u-cell-item>
|
||||
</u-cell-group>
|
||||
<view class="form-footer">
|
||||
<u-button type="primary" :loading="submitting" @click="submit">确定</u-button>
|
||||
</view>
|
||||
<u-select v-model="brandSelectShow" :list="brandSelectList" @confirm="onBrandConfirm"></u-select>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CommonNavbar from '@/components/common-navbar/index';
|
||||
import scanMixin from '@/common/scanMixin.js';
|
||||
import { getScanConfig, DICTIONARY_TYPE_SCANNER, mapDictionaryToScannerConfig, saveScanConfig } from '@/common/scanConfig.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
CommonNavbar,
|
||||
},
|
||||
mixins: [scanMixin],
|
||||
data() {
|
||||
return {
|
||||
brandSelectShow: false,
|
||||
submitting: false,
|
||||
configList: [],
|
||||
form: {
|
||||
brand: '',
|
||||
name: '',
|
||||
action: '',
|
||||
dataKey: '',
|
||||
needSetup: false,
|
||||
setupAction: '',
|
||||
setupParams: null,
|
||||
},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
brandSelectList() {
|
||||
return this.configList.map((item) => ({
|
||||
value: item.brand,
|
||||
label: item.name,
|
||||
}));
|
||||
},
|
||||
},
|
||||
onLoad() {
|
||||
this.loadConfigList();
|
||||
},
|
||||
methods: {
|
||||
async loadConfigList() {
|
||||
try {
|
||||
const res = await this.$u.api.dictionary.getDetailEnumList({
|
||||
dictionary_id: DICTIONARY_TYPE_SCANNER,
|
||||
});
|
||||
const list = Array.isArray(res) ? res : [];
|
||||
const builtinConfigs = this.getScannerConfigs();
|
||||
if (list.length) {
|
||||
this.configList = list
|
||||
.map((item) => mapDictionaryToScannerConfig(item, builtinConfigs))
|
||||
.filter(Boolean);
|
||||
this.remoteScannerConfigs = this.configList;
|
||||
} else {
|
||||
this.useFallbackConfigList();
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('获取扫码枪字典配置失败,使用内置配置', error);
|
||||
this.useFallbackConfigList();
|
||||
}
|
||||
this.initFormFromSaved();
|
||||
},
|
||||
useFallbackConfigList() {
|
||||
this.configList = this.getScannerConfigs();
|
||||
this.remoteScannerConfigs = [];
|
||||
},
|
||||
initFormFromSaved() {
|
||||
const savedConfig = getScanConfig();
|
||||
if (savedConfig) {
|
||||
this.applyConfig(savedConfig);
|
||||
return;
|
||||
}
|
||||
if (this.configList.length) {
|
||||
this.applyConfig(this.configList[0]);
|
||||
}
|
||||
},
|
||||
applyConfig(config) {
|
||||
this.form = {
|
||||
brand: config.brand || '',
|
||||
name: config.name || '',
|
||||
action: config.action || '',
|
||||
dataKey: config.dataKey || '',
|
||||
needSetup: !!config.needSetup,
|
||||
setupAction: config.setupAction || '',
|
||||
setupParams: config.setupParams || null,
|
||||
};
|
||||
},
|
||||
onBrandConfirm(selected) {
|
||||
const brand = selected[0]?.value;
|
||||
const config = this.configList.find((item) => item.brand === brand);
|
||||
if (config) {
|
||||
this.applyConfig(config);
|
||||
}
|
||||
},
|
||||
submit() {
|
||||
const action = (this.form.action || '').trim();
|
||||
const dataKey = (this.form.dataKey || '').trim();
|
||||
|
||||
if (!this.form.brand) {
|
||||
this.$u.toast('请选择PDA品牌');
|
||||
return;
|
||||
}
|
||||
if (!action) {
|
||||
this.$u.toast('请输入广播动作');
|
||||
return;
|
||||
}
|
||||
if (!dataKey) {
|
||||
this.$u.toast('请输入数据标签');
|
||||
return;
|
||||
}
|
||||
|
||||
const payload = {
|
||||
...this.form,
|
||||
action,
|
||||
dataKey,
|
||||
};
|
||||
|
||||
this.submitting = true;
|
||||
if (!saveScanConfig(payload)) {
|
||||
this.submitting = false;
|
||||
this.$u.toast('保存失败');
|
||||
return;
|
||||
}
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
this.unregisterScanBroadcast();
|
||||
const registered = this.registerScanBroadcastByConfig(payload);
|
||||
if (!registered) {
|
||||
this.submitting = false;
|
||||
this.$u.toast('保存成功,但广播注册失败');
|
||||
return;
|
||||
}
|
||||
// #endif
|
||||
|
||||
this.submitting = false;
|
||||
this.$u.toast('保存成功');
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 500);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.form-footer {
|
||||
padding: 40rpx 30rpx;
|
||||
}
|
||||
|
||||
::v-deep .u-cell_title {
|
||||
color: #202328;
|
||||
}
|
||||
|
||||
::v-deep .u-input__input {
|
||||
min-width: 360rpx;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user