Compare commits

29 Commits
Author SHA1 Message Date
xuan b1648bcb30 feat: 优化手动进仓流程并修复N5S扫码识别升至1.1.26 2026-11-10 18:43:55 +08:00
xuan c0067e3b89 feat: 半屏连续扫与修改密码报错并升至1.1.25 2026-11-10 08:27:17 +08:00
xuan 706fcda5b9 feat: 手机连续扫与出仓汇总表改用t-table并升至1.1.24 2026-11-09 21:53:32 +08:00
xuan fdbd06f5f5 fix: 详情页消审状态判断并升至1.1.23 2026-11-09 12:42:58 +08:00
xuan 0e630d0fb0 fix: 版本更新下载地址改用周尚CDN前缀 2026-11-09 10:07:57 +08:00
xuan 4d3f767e16 feat: 优化手动进仓扫码流程并升至1.1.22 2026-11-08 22:38:49 +08:00
xuan 5b6690b4d8 fix: 修复坯布库存表格在东集上列错位 2026-11-08 18:54:20 +08:00
xuan db12e1a249 fix: 织厂安装包改传到周尚CDN并升至1.1.21 2026-11-06 21:19:34 +08:00
xuan 870f857be8 merge: 合并 origin/zhoushang,保留远程 1.1.20 及相关改动 2026-11-06 15:31:10 +08:00
xuan c390b9f72b feat: 无扫码配置时自动匹配并升至1.1.20 2026-11-04 16:15:52 +08:00
xuan 8315222788 feat: 进仓等级可多选并提示改密,升至1.1.19 2026-11-04 14:50:44 +08:00
xuan 59e699b4f6 feat: 登录默认密码提示改密并可取消,版本升至1.1.19 2026-11-03 16:01:56 +08:00
xuan fdacdfbda0 feat: 无扫码配置时自动匹配,并修复我的页列表样式 2026-11-03 15:39:03 +08:00
xuan 569b671b7b feat: 上传版本包后同步发布latest.apk 2026-11-02 14:27:56 +08:00
xuan 804e1a8f2b feat: 更新出仓扫码页并升至1.1.18 2026-11-02 14:24:06 +08:00
xuan 61bb43f759 fix: 取消更新后登录页不再自动弹框,等级改为非必填并升至1.1.17 2026-11-01 17:54:32 +08:00
xuan 7adec1b960 fix: 修复登录环境选择器选中框错位并升至1.1.16 2026-10-31 22:20:44 +08:00
xuan 640dcf3493 chore: 修正正式环境接口路径并将版本升至1.1.15 2026-10-31 22:12:16 +08:00
xuan b1404fdd89 feat: 更新正式环境API地址并默认选用 2026-10-30 11:59:10 +08:00
xuan a4dbcbe504 chore(manifest): 更新应用版本号至1.1.13 2026-10-26 15:34:58 +08:00
xuan 39e8393fde fix: 修复手动进仓语音乱码 2026-10-26 15:25:52 +08:00
xuan 35fb587e22 chore: 去掉上传脚本的本地配置文件 2026-10-14 09:35:27 +08:00
xuan 83645ccbf6 chore(manifest): 更新应用版本号至1.1.12 2026-10-14 09:35:26 +08:00
xuan 232a3e179a feat: 新增命令行上传PDA安装包 2026-10-13 18:23:13 +08:00
xuan 1c434a608a chore(manifest): 更新应用版本号至1.1.11 2026-10-13 17:35:15 +08:00
xuan f8ec49c79d feat: 我的页显示应用名称和版本 2026-10-13 17:35:15 +08:00
xuan 7b10d36361 feat: 登录页显示应用名称 2026-10-13 17:35:14 +08:00
xuan e8ae05b87b feat: 放大坯布出仓扫码按钮 2026-10-13 17:32:51 +08:00
xuan c4d5db056b feat: 手动进仓增加扫码和进仓成功语音 2026-10-13 17:32:50 +08:00
43 changed files with 3020 additions and 473 deletions
+3 -2
View File
@@ -1,5 +1,6 @@
NODE_ENV = production NODE_ENV = production
VUE_APP_ENV_NAME = zhoushang环境 VUE_APP_ENV_NAME = zhoushang环境
VUE_APP_UPGRADE_NAME = erp_pda_zhoushang_zhichang VUE_APP_UPGRADE_NAME = erp_pda_zhoushang_zhichang
VUE_APP_PRODUCTION_API_URL = https://www.haotopai.com/hcscm_weave/mes/server/pda/v1 VUE_APP_UPGRADE_CDN_PREFIX = https://zsfzcdn.yushangfangzhi.com/version/erp_pda_zhoushang_zhichang
VUE_APP_DEV_API_URL = https://www.haotopai.com/hcscm_weave/mes/server/pda/v1 VUE_APP_PRODUCTION_API_URL = https://zszc.yushangfangzhi.com/hcscm_weave/pda/v1
VUE_APP_DEV_API_URL = https://zszc.yushangfangzhi.com/hcscm_weave/pda/v1
+3 -2
View File
@@ -1,5 +1,6 @@
NODE_ENV = production NODE_ENV = production
VUE_APP_ENV_NAME = zhoushang环境 VUE_APP_ENV_NAME = zhoushang环境
VUE_APP_UPGRADE_NAME = erp_pda_zhoushang_zhichang VUE_APP_UPGRADE_NAME = erp_pda_zhoushang_zhichang
VUE_APP_PRODUCTION_API_URL = https://www.haotopai.com/hcscm_weave/mes/server/pda/v1 VUE_APP_UPGRADE_CDN_PREFIX = https://zsfzcdn.yushangfangzhi.com/version/erp_pda_zhoushang_zhichang
VUE_APP_DEV_API_URL = https://www.haotopai.com/hcscm_weave/mes/server/pda/v1 VUE_APP_PRODUCTION_API_URL = https://zszc.yushangfangzhi.com/hcscm_weave/pda/v1
VUE_APP_DEV_API_URL = https://zszc.yushangfangzhi.com/hcscm_weave/pda/v1
+1
View File
@@ -48,6 +48,7 @@
"dev:quickapp-webview-huawei": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview-huawei vue-cli-service uni-build --watch", "dev:quickapp-webview-huawei": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview-huawei vue-cli-service uni-build --watch",
"dev:quickapp-webview-union": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview-union vue-cli-service uni-build --watch", "dev:quickapp-webview-union": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview-union vue-cli-service uni-build --watch",
"info": "node node_modules/@dcloudio/vue-cli-plugin-uni/commands/info.js", "info": "node node_modules/@dcloudio/vue-cli-plugin-uni/commands/info.js",
"upload:apk": "node scripts/upload-apk.js",
"serve:quickapp-native": "node node_modules/@dcloudio/uni-quickapp-native/bin/serve.js", "serve:quickapp-native": "node node_modules/@dcloudio/uni-quickapp-native/bin/serve.js",
"test:android": "cross-env UNI_PLATFORM=app-plus UNI_OS_NAME=android jest -i", "test:android": "cross-env UNI_PLATFORM=app-plus UNI_OS_NAME=android jest -i",
"test:h5": "cross-env UNI_PLATFORM=h5 jest -i", "test:h5": "cross-env UNI_PLATFORM=h5 jest -i",
+333
View File
@@ -0,0 +1,333 @@
/**
* 上传已打包的 PDA APK,等价于 ERP「开发者资源上传」里的安装包上传。
*
* 用法:
* npm run upload:apk -- --file D:\path\app.apk --target test
* npm run upload:apk -- --file D:\path\app.apk --target prod
* npm run upload:apk -- --file D:\path\app.apk --target test --mode zhisheng
*
* --target 只决定 APK 放到哪套 CDN:
* test 测试 CDN
* prod 正式 CDN
* 两者没有别的差别。生产环境的 PDA 也可以从测试 CDN 下载并安装。
*
* 版本号取 src/manifest.json 的 versionName。
* 场景值取对应 .env 的 VUE_APP_UPGRADE_NAME,拼成 /version/{upgradeName}/{version}.apk。
* 版本包上传成功后,再把同一份安装包上传为 /version/{upgradeName}/latest.apk。
* 运行时输入 ERP 手机号和密码获取 token。多个账套时再选择一次。
*/
const fs = require('fs');
const path = require('path');
const readline = require('readline');
const ROOT = path.resolve(__dirname, '..');
const UPYUN_API = 'https://v0.api.upyun.com';
const DEFAULT_API_BASE = 'https://hcscmtest.zzfzyc.com/hcscm_weave';
const DEFAULT_CDN_HOST = {
test: 'https://testhcscm.cdn.zzfzyc.com',
prod: 'https://hcscm.cdn.zzfzyc.com',
};
/** 织厂环境签到 zhoushang 空间,下载域名与 ERP 相同 */
const MODE_UPLOAD = {
zhoushang: {
apiBase: 'https://zszc.yushangfangzhi.com/hcscm_weave',
cdnHost: 'https://zsfzcdn.yushangfangzhi.com',
status: 1,
},
};
const MODE_ENV = {
zhoushang: '.env.zhoushang',
zhisheng: '.env.zhisheng',
mes: '.env.mes',
cjt: '.env.cjt',
};
function parseArgs(argv) {
const args = { mode: 'zhoushang' };
for (let i = 0; i < argv.length; i += 1) {
const key = argv[i];
const value = argv[i + 1];
if (key === '--file' || key === '--target' || key === '--mode' || key === '--version' || key === '--phone' || key === '--password' || key === '--tenant') {
args[key.slice(2)] = value;
i += 1;
}
}
return args;
}
function readEnvValue(filePath, name) {
const text = fs.readFileSync(filePath, 'utf8');
const line = text.split(/\r?\n/).find((item) => item.trim().startsWith(`${name}`));
if (!line) return '';
const raw = line.slice(line.indexOf('=') + 1).trim();
return raw.replace(/^['"]|['"]$/g, '');
}
function readManifestVersion() {
const manifest = JSON.parse(fs.readFileSync(path.join(ROOT, 'src/manifest.json'), 'utf8'));
return String(manifest.versionName || '').trim();
}
function ask(question) {
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
return new Promise((resolve) => {
rl.question(question, (answer) => {
rl.close();
resolve(String(answer || '').trim());
});
});
}
function askPassword(question) {
return new Promise((resolve) => {
const stdin = process.stdin;
const stdout = process.stdout;
if (!stdin.isTTY || typeof stdin.setRawMode !== 'function') {
ask(question).then(resolve);
return;
}
stdout.write(question);
stdin.setRawMode(true);
stdin.resume();
stdin.setEncoding('utf8');
let value = '';
const onData = (char) => {
switch (char) {
case '\n':
case '\r':
case '\u0004':
stdin.setRawMode(false);
stdin.pause();
stdin.removeListener('data', onData);
stdout.write('\n');
resolve(value);
break;
case '\u0003':
process.exit();
break;
case '\u007f':
case '\b':
value = value.slice(0, -1);
break;
default:
value += char;
break;
}
};
stdin.on('data', onData);
});
}
async function apiJson(apiBase, urlPath, { method = 'GET', token, body } = {}) {
const headers = { Platform: '1' };
if (token) headers.Authorization = token;
if (body) headers['Content-Type'] = 'application/json';
const res = await fetch(`${apiBase}${urlPath}`, {
method,
headers,
body: body ? JSON.stringify(body) : undefined,
});
const data = await res.json().catch(() => ({}));
if (!res.ok || data.code !== 0) {
throw new Error(data.msg || `请求失败(HTTP ${res.status})`);
}
return data.data || {};
}
async function login(apiBase, { phone: phoneArg, password: passwordArg, tenant: tenantArg } = {}) {
const phone = phoneArg || await ask('手机号: ');
const password = passwordArg || await askPassword('密码: ');
if (!phone || !password) {
throw new Error('请输入手机号和密码');
}
console.log('正在登录...');
const first = await apiJson(apiBase, '/admin/v1/login', {
method: 'POST',
body: { phone, password },
});
const tempToken = first.token;
if (!tempToken) throw new Error('登录未返回 token');
const dropdown = await apiJson(apiBase, '/admin/v1/tenantManagement/dropdownList', {
token: tempToken,
});
const tenants = dropdown.list || [];
if (!tenants.length) return tempToken;
let tenant = tenants[0];
if (tenants.length > 1) {
if (tenantArg) {
const picked = Number(tenantArg);
tenant = tenants[picked - 1];
if (!tenant) throw new Error('账套序号无效');
} else {
console.log('请选择账套:');
tenants.forEach((item, index) => {
const name = item.company_name || item.database_name || item.tenant_contacts || item.tenant_management_id;
console.log(` ${index + 1}. ${name}`);
});
const picked = Number(await ask('序号: '));
tenant = tenants[picked - 1];
if (!tenant) throw new Error('账套序号无效');
}
}
const second = await apiJson(apiBase, '/admin/v1/login', {
method: 'POST',
token: tempToken,
body: {
token: tempToken,
tenant_management_id: tenant.tenant_management_id,
},
});
if (!second.token) throw new Error('选择账套后未返回 token');
return second.token;
}
async function getCdnSign({ apiBase, token, saveKey, status }) {
const url = new URL(`${apiBase}/admin/v1/cdn/token`);
url.searchParams.set('method', 'post');
url.searchParams.set('save_key', saveKey);
url.searchParams.set('status', String(status));
const res = await fetch(url, {
headers: {
Authorization: token,
Platform: '1',
},
});
const body = await res.json();
if (!res.ok || body.code !== 0) {
throw new Error(body.msg || `获取签名失败(HTTP ${res.status})`);
}
return body.data || {};
}
async function uploadToUpyun({ bucket, authorization, policy, filePath, fileName }) {
const buf = fs.readFileSync(filePath);
const form = new FormData();
form.append('authorization', authorization);
form.append('policy', policy);
form.append('file', new Blob([buf], { type: 'application/vnd.android.package-archive' }), fileName);
const res = await fetch(`${UPYUN_API}/${bucket}`, {
method: 'POST',
body: form,
});
const text = await res.text();
let body = {};
try {
body = JSON.parse(text);
} catch (e) {
body = { raw: text };
}
if (!res.ok || (body.code != null && Number(body.code) !== 200)) {
throw new Error(body.message || body.msg || body.raw || `上传失败(HTTP ${res.status})`);
}
return body;
}
function toPublicUrl(cdnHost, saveKey, uploaded) {
if (uploaded.url && String(uploaded.url).startsWith('http')) return uploaded.url;
return `${cdnHost}${saveKey}`;
}
async function uploadApkFile({ apiBase, token, apkPath, saveKey, fileName, status }) {
console.log(`场景路径: ${saveKey}`);
console.log('正在获取签名...');
const sign = await getCdnSign({
apiBase,
token,
saveKey,
status,
});
if (!sign.bucket || !sign.authorization || !sign.policy) {
throw new Error('签名返回缺少 bucket、authorization 或 policy');
}
console.log(`空间: ${sign.bucket}`);
console.log(`正在上传 ${fileName}...`);
const uploaded = await uploadToUpyun({
bucket: sign.bucket,
authorization: sign.authorization,
policy: sign.policy,
filePath: apkPath,
fileName,
});
console.log('上传成功');
return uploaded;
}
async function main() {
const args = parseArgs(process.argv.slice(2));
if (!args.file || !args.target) {
console.error('用法: npm run upload:apk -- --file <apk路径> --target test|prod [--mode zhoushang]');
console.error('--target 只切换 APK 的 CDN:test 测试 CDN,prod 正式 CDN。生产环境也可以从测试 CDN 下载安装。');
process.exit(1);
}
if (args.target !== 'test' && args.target !== 'prod') {
console.error('--target 只能是 test 或 prod。两者只是 APK 的 CDN 环境不同,生产环境也可以从测试 CDN 下载安装。');
process.exit(1);
}
const envFile = MODE_ENV[args.mode];
if (!envFile) {
console.error(`不支持的 --mode:${args.mode},可选 zhoushang、zhisheng、mes、cjt`);
process.exit(1);
}
const apkPath = path.resolve(args.file);
if (!fs.existsSync(apkPath)) {
console.error(`找不到 APK:${apkPath}`);
process.exit(1);
}
const version = args.version || readManifestVersion();
if (!version) {
console.error('manifest.json 里没有 versionName');
process.exit(1);
}
const upgradeName = readEnvValue(path.join(ROOT, envFile), 'VUE_APP_UPGRADE_NAME');
if (!upgradeName) {
console.error(`${envFile} 里没有 VUE_APP_UPGRADE_NAME`);
process.exit(1);
}
const modeUpload = MODE_UPLOAD[args.mode];
const status = modeUpload ? modeUpload.status : (args.target === 'prod' ? 2 : 1);
const fileName = `${version}.apk`;
const saveKey = `/version/${upgradeName}/${fileName}`;
const latestFileName = 'latest.apk';
const latestSaveKey = `/version/${upgradeName}/${latestFileName}`;
const apiBase = modeUpload ? modeUpload.apiBase : DEFAULT_API_BASE;
const cdnHost = modeUpload ? modeUpload.cdnHost : DEFAULT_CDN_HOST[args.target];
const token = await login(apiBase, {
phone: args.phone,
password: args.password,
tenant: args.tenant,
});
console.log(`版本号: ${version}`);
console.log(`签名接口: ${apiBase}`);
console.log(`CDN: ${cdnHost}`);
const uploaded = await uploadApkFile({
apiBase,
token,
apkPath,
saveKey,
fileName,
status,
});
console.log(toPublicUrl(cdnHost, saveKey, uploaded));
const latestUploaded = await uploadApkFile({
apiBase,
token,
apkPath,
saveKey: latestSaveKey,
fileName: latestFileName,
status,
});
console.log(toPublicUrl(cdnHost, latestSaveKey, latestUploaded));
}
main().catch((error) => {
console.error(error.message || error);
process.exit(1);
});
+9
View File
@@ -6,6 +6,7 @@ import { audioManager } from '@/utils/audioManager'
import util from '@/common/util.js'; import util from '@/common/util.js';
import md5 from '@/common/md5.js'; import md5 from '@/common/md5.js';
import { ensureScanConfigAfterLogin } from '@/common/scanAutoConfig.js';
export default { export default {
globalData: { globalData: {
AppName: '', AppName: '',
@@ -30,6 +31,14 @@ import { audioManager } from '@/utils/audioManager'
audioManager.init(); audioManager.init();
// 初始化通知系统 // 初始化通知系统
this.$store.dispatch('initNotification'); this.$store.dispatch('initNotification');
// 已登录且本地无扫码配置时,自动匹配一次
const loginData = uni.getStorageSync('RemoteTokenData');
if (loginData && loginData.token && this.$u && this.$u.api) {
ensureScanConfigAfterLogin(this.$u.api).catch((error) => {
console.log('启动时自动匹配扫码设置失败', error);
});
}
} }
} }
</script> </script>
+21 -6
View File
@@ -7,6 +7,7 @@ export const isDevelopment = process.env.NODE_ENV === 'development'
const config = { const config = {
upgradeName: process.env.VUE_APP_UPGRADE_NAME || 'erp_pda', upgradeName: process.env.VUE_APP_UPGRADE_NAME || 'erp_pda',
upgradeCdnPrefix: process.env.VUE_APP_UPGRADE_CDN_PREFIX || '',
// 产品名称 // 产品名称
productName: '浩拓技术', productName: '浩拓技术',
@@ -21,21 +22,35 @@ const config = {
isDevelopment: isDevelopment, isDevelopment: isDevelopment,
// 生产环境API URL(服务名段 hcscm_weave) // 生产环境API URL(服务名段 hcscm_weave)
productionApiUrl: process.env.VUE_APP_PRODUCTION_API_URL || 'https://www.haotopai.com/hcscm_weave/mes/server/pda/v1', productionApiUrl: process.env.VUE_APP_PRODUCTION_API_URL,
// 开发环境API URL选项(仅替换 //域名/ 后第一个路径段 hcscm → hcscm_weave,不改域名) // 开发环境API URL选项(仅替换 //域名/ 后第一个路径段 hcscm → hcscm_weave,不改域名)
devApiUrlOptions: [ devApiUrlOptions: [
{ label: '测试环境', value: 'https://hcscmtest.zzfzyc.com/hcscm_weave/pda/v1' }, { label: '测试环境', value: 'https://hcscmtest.zzfzyc.com/hcscm_weave/pda/v1' },
{ label: '正式环境', value: process.env.VUE_APP_DEV_API_URL || process.env.VUE_APP_PRODUCTION_API_URL || 'https://www.haotopai.com/hcscm_weave/mes/server/pda/v1' }, { label: '正式环境', value: process.env.VUE_APP_PRODUCTION_API_URL },
{ label: '本地环境', value: 'http://192.168.1.66:7010/hcscm_weave/pda/v1' }, { label: '本地环境', value: 'http://192.168.1.97:7010/hcscm_weave/pda/v1' },
{ label: '自定义', value: 'custom' } { label: '自定义', value: 'custom' }
] ]
} }
export function getTestApiUrl() { export function resolveUpgradeDownloadUrl(downloadUrl) {
const test = config.devApiUrlOptions.find(item => item.label === '测试环境'); const raw = String(downloadUrl || '').trim();
return (test && test.value) || 'https://hcscmtest.zzfzyc.com/hcscm_weave/pda/v1'; const prefix = String(config.upgradeCdnPrefix || '').trim().replace(/\/+$/, '');
if (!raw || !prefix) {
return raw;
}
const path = raw.split('?')[0].split('#')[0];
const fileName = path.split('/').filter(Boolean).pop() || '';
if (!fileName || !/\.apk$/i.test(fileName)) {
return raw;
}
return `${prefix}/${fileName}`;
}
export function getDefaultApiUrl() {
const prod = config.devApiUrlOptions.find(item => item.label === '正式环境');
return (prod && prod.value) || config.productionApiUrl || 'https://zszc.yushangfangzhi.com/server/hcscm_weave/pda/v1';
} }
export default config; export default config;
+1 -1
View File
@@ -114,7 +114,7 @@ const install = (Vue, vm) => {
// 个人信息修改 // 个人信息修改
user: { user: {
saveUserInfo: (params = {}) => vm.$u.post(config.productionApiUrl+'/mobile/user/saveUserInfo', params), saveUserInfo: (params = {}) => vm.$u.post(config.productionApiUrl+'/mobile/user/saveUserInfo', params),
infoSavePwd: (params = {}) => vm.$u.put(config.productionApiUrl+'/system/user/profile/updatePwd', params), infoSavePwd: (params = {}) => vm.$u.put('/system/user/profile/updatePwd', params),
infoSavePqa: (params = {}) => vm.$u.post(config.productionApiUrl+'/sys/user/infoSavePqa', params), infoSavePqa: (params = {}) => vm.$u.post(config.productionApiUrl+'/sys/user/infoSavePqa', params),
}, },
+21 -6
View File
@@ -73,18 +73,33 @@ const install = (Vue, vm) => {
return false; return false;
} }
console.log('res',res) console.log('res',res)
if (!(res.data)){ const rejectWithMessage = (message) => {
const text = String(message || '请求失败').trim() || '请求失败';
vm.$u.toast(text);
return Promise.reject(new Error(text));
};
// HTTP 非 200(如 404)时直接报错,避免把字符串/HTML 当业务 data 解析
if (res.statusCode && res.statusCode !== 200) {
let message = `请求失败(${res.statusCode})`;
if (typeof res.data === 'string' && res.data.trim()) {
message = res.data.trim().slice(0, 120);
} else if (res.data && typeof res.data === 'object') {
message = res.data.msg || res.data.message || message;
}
return rejectWithMessage(message);
}
if (res.data === undefined || res.data === null || res.data === '') {
const errMsg = String((res && res.errMsg) || ''); const errMsg = String((res && res.errMsg) || '');
const isNetworkError = res.statusCode === -1 const isNetworkError = res.statusCode === -1
|| /Unable to resolve host|Failed to connect|request:fail|timeout|网络/i.test(errMsg); || /Unable to resolve host|Failed to connect|request:fail|timeout|网络/i.test(errMsg);
const message = isNetworkError ? '当前没有网络,请检查网络后重试' : '未连接到服务器'; const message = isNetworkError ? '当前没有网络,请检查网络后重试' : '未连接到服务器';
vm.$u.toast(message) return rejectWithMessage(message);
return Promise.reject(new Error(message)); }
if (typeof res.data !== 'object') {
return rejectWithMessage(String(res.data).slice(0, 120));
} }
if (res.data.code !== 0) { if (res.data.code !== 0) {
vm.$u.toast(res.data.msg) return rejectWithMessage(res.data.msg || res.data.message || '请求失败');
return Promise.reject(new Error(res.data.msg))
} }
let data = res.data.data; let data = res.data.data;
console.log('data',data) console.log('data',data)
+47
View File
@@ -0,0 +1,47 @@
/**
* 登录后 / 冷启动:拉取扫码字典并在本地无配置时自动匹配写入
*/
import {
DICTIONARY_TYPE_SCANNER,
autoConfigureScanSettings,
} from '@/common/scanConfig.js';
function extractDictionaryList(res) {
if (Array.isArray(res)) return res;
if (res && Array.isArray(res.list)) return res.list;
return [];
}
/**
* @param {object} api - this.$u.api
* @returns {Promise<{saved:boolean,skipped:boolean,config:object|null,reason?:string}>}
*/
export async function ensureScanConfigAfterLogin(api) {
if (!api || !api.dictionary || !api.dictionary.getDetailEnumList) {
return autoConfigureScanSettings({ remoteConfigs: [] });
}
let remoteConfigs = [];
try {
const res = await api.dictionary.getDetailEnumList({
dictionary_id: DICTIONARY_TYPE_SCANNER,
});
remoteConfigs = extractDictionaryList(res);
} catch (error) {
console.log('拉取扫码字典失败,改用内置配置自动匹配', error);
}
const result = autoConfigureScanSettings({ remoteConfigs });
if (result.skipped) {
console.log('本地已有扫码设置,跳过自动匹配', result.config && result.config.name);
} else if (result.saved) {
if (result.reason === 'rematch_n5s_from_seuic') {
console.log('N5S 误识别为东集,已纠正为', result.config && result.config.name);
} else {
console.log('已自动写入扫码设置', result.config && result.config.name);
}
} else {
console.log('自动匹配扫码设置未写入', result.reason);
}
return result;
}
+353
View File
@@ -13,6 +13,117 @@ export const PHONE_SCAN_CONFIG = {
isPhoneScan: true, isPhoneScan: true,
}; };
/** 内置扫码配置:补 needSetup,并在字典拉不到时兜底 */
export const BUILTIN_SCANNER_CONFIGS = [
{
brand: 'seuic',
name: '东大集成(AUTOID)',
action: 'com.android.server.scannerservice.broadcast',
dataKey: 'scannerdata',
needSetup: true,
setupAction: 'com.android.scanner.service_settings',
setupParams: {
barcode_send_mode: 'BROADCAST',
action_barcode_broadcast: 'com.android.server.scannerservice.broadcast',
key_barcode_broadcast: 'scannerdata',
endchar: 'NONE',
},
},
{
brand: 'sunmi',
name: '商米',
action: 'com.sunmi.scanner.ACTION_DATA_CODE_RECEIVED',
dataKey: 'data',
needSetup: false,
},
{
brand: 'urovo',
name: '优博讯',
action: 'android.intent.ACTION_DECODE_DATA',
dataKey: 'barcode_string',
needSetup: false,
},
{
brand: 'nlscan',
name: '新大陆',
action: 'nlscan.action.SCANNER_RESULT',
dataKey: 'SCAN_BARCODE1',
needSetup: false,
},
{
// N5S 部分固件走智联天地兼容广播,而不是 nlscan.action
brand: 'nlscan_compat',
name: '新大陆(兼容广播)',
action: 'android.intent.action.RECEIVE_SCANDATA_BROADCAST',
dataKey: 'android.intent.extra.SCAN_BROADCAST_DATA',
needSetup: false,
},
{ ...PHONE_SCAN_CONFIG },
];
/** 设备关键词 / 常见扫码相关包名,用于自动识别 */
const DETECT_RULES = [
{
matchNames: ['商米'],
matchActions: ['com.sunmi.scanner.ACTION_DATA_CODE_RECEIVED'],
keywords: ['sunmi'],
packages: ['com.sunmi.scanner', 'woyou.aidlservice.jiuiv5'],
},
{
matchNames: ['新大陆', '新大陆(兼容广播)'],
matchActions: [
'nlscan.action.SCANNER_RESULT',
'android.intent.action.RECEIVE_SCANDATA_BROADCAST',
],
// N5S 机型常标成 alps/zltd,不能只靠 newland 关键字
keywords: ['newland', 'nls', 'nlscan', 'n5s', 'zltd'],
models: ['n5s', 'n5'],
packages: [
'com.nlscan.barcodescanner',
'com.newland',
'com.nlscan.android.scan.service',
],
},
{
matchNames: ['优博讯'],
matchActions: ['android.intent.ACTION_DECODE_DATA'],
keywords: ['urovo', 'ubx'],
packages: ['com.urovo', 'com.ubx'],
},
{
matchNames: ['盈达'],
matchActions: ['android.intent.action.SCANRESULT'],
keywords: ['idata', 'yingda'],
packages: ['com.idata'],
},
{
matchNames: ['海雅达'],
matchActions: ['com.android.scanner.broadcast'],
keywords: ['haiyada'],
packages: [],
},
{
matchNames: ['东大集成(AUTOID)', '东大集成', '东集'],
matchActions: ['com.android.server.scannerservice.broadcast'],
keywords: ['seuic', 'autoid', 'eastcom', '东集', '东大'],
packages: ['com.seuic.scanner'],
},
];
const PDA_DEVICE_KEYWORDS = [
'newland', 'nls', 'nlscan', 'n5s', 'zltd', 'sunmi', 'urovo', 'ubx', 'zebra', 'honeywell',
'idata', 'seuic', 'autoid', '东集', '东大',
];
/** 明确机型 → 优先品牌,避免通用东集广播抢分 */
const MODEL_PREFERRED_BRANDS = [
{
models: ['n5s'],
brands: ['nlscan', 'nlscan_compat'],
score: 220,
},
];
const NO_SETUP_HINT_KEY = 'pda_scan_config_hint_shown'; const NO_SETUP_HINT_KEY = 'pda_scan_config_hint_shown';
export function isPhoneScanConfig(config) { export function isPhoneScanConfig(config) {
@@ -152,3 +263,245 @@ export function markNoConfigHintShown() {
console.log('记录扫码枪提示状态失败', e); console.log('记录扫码枪提示状态失败', e);
} }
} }
export function mergeScannerConfigs(remoteConfigs = []) {
const configMap = new Map();
BUILTIN_SCANNER_CONFIGS.forEach((item) => {
if (!isPhoneScanConfig(item)) {
configMap.set(item.action || item.brand, item);
}
});
(remoteConfigs || []).forEach((raw) => {
const normalized = mapDictionaryToScannerConfig(raw, BUILTIN_SCANNER_CONFIGS);
if (!normalized || isPhoneScanConfig(normalized)) return;
configMap.set(normalized.action || normalized.brand, normalized);
});
const list = Array.from(configMap.values());
list.push({ ...PHONE_SCAN_CONFIG });
return list;
}
export function getDeviceIdentity() {
// #ifdef APP-PLUS
try {
const Build = plus.android.importClass('android.os.Build');
return {
manufacturer: String(Build.MANUFACTURER || '').toLowerCase(),
model: String(Build.MODEL || '').toLowerCase(),
brand: String(Build.BRAND || '').toLowerCase(),
};
} catch (e) {
console.log('读取设备信息失败', e);
}
// #endif
return { manufacturer: '', model: '', brand: '' };
}
export function isPdaDevice() {
const identity = getDeviceIdentity();
const text = `${identity.manufacturer} ${identity.model} ${identity.brand}`;
return PDA_DEVICE_KEYWORDS.some((keyword) => text.includes(String(keyword).toLowerCase()));
}
function findDetectRule(config) {
return DETECT_RULES.find((rule) => {
if (rule.matchNames.includes(config.name)) return true;
if (rule.matchActions.includes(config.action)) return true;
return false;
}) || null;
}
function isPackageInstalled(packageName) {
// #ifdef APP-PLUS
try {
const main = plus.android.runtimeMainActivity();
const pm = main.getPackageManager();
plus.android.importClass(pm);
pm.getPackageInfo(packageName, 0);
return true;
} catch (e) {
return false;
}
// #endif
return false;
}
function canResolveBroadcast(action) {
if (!action) return false;
// #ifdef APP-PLUS
try {
const main = plus.android.runtimeMainActivity();
const Intent = plus.android.importClass('android.content.Intent');
const pm = main.getPackageManager();
plus.android.importClass(pm);
const intent = new Intent(action);
const list = pm.queryBroadcastReceivers(intent, 0);
return !!(list && list.size && list.size() > 0);
} catch (e) {
console.log('探测广播接收方失败', action, e);
return false;
}
// #endif
return false;
}
function isModelMatch(identity, models = []) {
const model = String((identity && identity.model) || '').toLowerCase();
if (!model) return false;
return (models || []).some((item) => model === item || model.includes(item));
}
function getModelPreferredBoost(config, identity) {
if (!config || isPhoneScanConfig(config)) {
return 0;
}
const brand = String(config.brand || '');
for (let i = 0; i < MODEL_PREFERRED_BRANDS.length; i += 1) {
const rule = MODEL_PREFERRED_BRANDS[i];
if (!isModelMatch(identity, rule.models)) continue;
if ((rule.brands || []).includes(brand)) {
return Number(rule.score) || 0;
}
}
return 0;
}
/** 新大陆 N5S / 智联天地 N5S:机型名常为 n5s,厂商可能是 newland/zltd/alps */
export function isNewlandN5sDevice(identity = getDeviceIdentity()) {
const model = String((identity && identity.model) || '').toLowerCase();
const text = `${identity.manufacturer || ''} ${identity.brand || ''} ${model}`.toLowerCase();
if (model === 'n5s' || model.includes('n5s')) {
return true;
}
return text.includes('n5s') && (
text.includes('newland')
|| text.includes('zltd')
|| text.includes('nlscan')
|| text.includes('alps')
);
}
function isWrongSeuicOnNewlandDevice(config, identity = getDeviceIdentity()) {
if (!config || isPhoneScanConfig(config)) {
return false;
}
if (!isNewlandN5sDevice(identity) && !isModelMatch(identity, ['n5s'])) {
return false;
}
const brand = String(config.brand || '');
const action = String(config.action || '');
return brand === 'seuic'
|| action.includes('scannerservice.broadcast')
|| String(config.name || '').includes('东集')
|| String(config.name || '').includes('东大');
}
function scoreScannerConfig(config, identity) {
if (!config || isPhoneScanConfig(config)) {
return 0;
}
let score = 0;
const rule = findDetectRule(config);
const deviceText = `${identity.manufacturer} ${identity.model} ${identity.brand}`;
if (canResolveBroadcast(config.action)) {
score += 100;
}
if (rule) {
if ((rule.packages || []).some((pkg) => isPackageInstalled(pkg))) {
score += 60;
}
if ((rule.keywords || []).some((keyword) => deviceText.includes(String(keyword).toLowerCase()))) {
score += 40;
}
if (isModelMatch(identity, rule.models || [])) {
score += 80;
}
}
score += getModelPreferredBoost(config, identity);
// 明确是 N5S 时,压低东集通用广播抢分
if (isNewlandN5sDevice(identity) && (
config.brand === 'seuic'
|| String(config.action || '').includes('scannerservice.broadcast')
)) {
score = Math.min(score, 30);
}
return score;
}
/**
* 在候选配置中选出最匹配当前设备的一项;非 PDA 且无命中则回落手机扫码
*/
export function matchBestScanConfig(candidateConfigs = []) {
const configs = (candidateConfigs || [])
.map((item) => normalizeConfig(item, BUILTIN_SCANNER_CONFIGS))
.filter(Boolean);
const pdaConfigs = configs.filter((item) => !isPhoneScanConfig(item));
const identity = getDeviceIdentity();
let best = null;
let bestScore = 0;
pdaConfigs.forEach((config) => {
const score = scoreScannerConfig(config, identity);
if (score > bestScore) {
bestScore = score;
best = config;
}
});
if (best && bestScore > 0) {
return best;
}
if (!isPdaDevice()) {
return { ...PHONE_SCAN_CONFIG };
}
return pdaConfigs[0] || { ...PHONE_SCAN_CONFIG };
}
/**
* 仅本地没有有效配置时,自动匹配并写入扫描设置。
* 若本地误把 N5S 识别成东集,则强制重配。
* @returns {{ saved: boolean, config: object|null, skipped: boolean, reason?: string }}
*/
export function autoConfigureScanSettings({ remoteConfigs = [] } = {}) {
const existing = getScanConfig(BUILTIN_SCANNER_CONFIGS);
const identity = getDeviceIdentity();
const forceRematch = !!(existing && isWrongSeuicOnNewlandDevice(existing, identity));
if (existing && !forceRematch) {
return {
saved: false,
skipped: true,
config: existing,
reason: 'local_exists',
};
}
const candidates = mergeScannerConfigs(remoteConfigs);
const matched = matchBestScanConfig(candidates);
if (!matched) {
return {
saved: false,
skipped: false,
config: existing || null,
reason: 'no_match',
};
}
const saved = saveScanConfig(matched);
return {
saved,
skipped: false,
config: matched,
reason: saved
? (forceRematch ? 'rematch_n5s_from_seuic' : 'saved')
: 'save_failed',
};
}
+88 -61
View File
@@ -1,19 +1,16 @@
// common/scanMixin.js // common/scanMixin.js
// 多厂商PDA扫码器兼容方案 - 策略模式 + 配置表驱动 // 多厂商PDA扫码器兼容方案 - 策略模式 + 配置表驱动
import { import {
BUILTIN_SCANNER_CONFIGS,
getScanConfig, getScanConfig,
hasShownNoConfigHint, hasShownNoConfigHint,
isPdaDevice as detectPdaDevice,
isPhoneScanConfig, isPhoneScanConfig,
markNoConfigHintShown, markNoConfigHintShown,
normalizeConfig, normalizeConfig,
PHONE_SCAN_CONFIG, PHONE_SCAN_CONFIG,
} from '@/common/scanConfig.js'; } from '@/common/scanConfig.js';
const PDA_DEVICE_KEYWORDS = [
'newland', 'nls', 'nlscan', 'sunmi', 'urovo', 'zebra', 'honeywell',
'idata', 'seuic', 'autoid', '东集', '东大',
];
export default { export default {
data() { data() {
return { return {
@@ -28,46 +25,7 @@ export default {
methods: { methods: {
getScannerConfigs() { getScannerConfigs() {
return [ return BUILTIN_SCANNER_CONFIGS;
{
// 东大集成 SEUIC / AUTOID 系列(如 AUTOID9),勿与新大陆 nlscan 混淆
brand: 'seuic',
name: '东大集成(AUTOID)',
action: 'com.android.server.scannerservice.broadcast',
dataKey: 'scannerdata',
needSetup: true,
setupAction: 'com.android.scanner.service_settings',
setupParams: {
barcode_send_mode: 'BROADCAST',
action_barcode_broadcast: 'com.android.server.scannerservice.broadcast',
key_barcode_broadcast: 'scannerdata',
endchar: 'NONE'
}
},
{
brand: 'sunmi',
name: '商米',
action: 'com.sunmi.scanner.ACTION_DATA_CODE_RECEIVED',
dataKey: 'data',
needSetup: false
},
{
brand: 'urovo',
name: '优博讯',
action: 'android.intent.ACTION_DECODE_DATA',
dataKey: 'barcode_string',
needSetup: false
},
{
// 新大陆 Newland,广播为 nlscan.action.SCANNER_RESULT
brand: 'nlscan',
name: '新大陆',
action: 'nlscan.action.SCANNER_RESULT',
dataKey: 'SCAN_BARCODE1',
needSetup: false
},
{ ...PHONE_SCAN_CONFIG },
];
}, },
getPhoneScanConfig() { getPhoneScanConfig() {
@@ -75,20 +33,7 @@ export default {
}, },
isPdaDevice() { isPdaDevice() {
// #ifdef APP-PLUS return detectPdaDevice();
try {
const Build = plus.android.importClass('android.os.Build');
const manufacturer = String(Build.MANUFACTURER || '').toLowerCase();
const model = String(Build.MODEL || '').toLowerCase();
return PDA_DEVICE_KEYWORDS.some((keyword) => {
return manufacturer.includes(keyword) || model.includes(keyword);
});
} catch (error) {
console.log('检测设备类型失败', error);
return false;
}
// #endif
return false;
}, },
shouldUsePhoneScan() { shouldUsePhoneScan() {
@@ -127,20 +72,63 @@ export default {
return configs.length ? configs[0] : null; return configs.length ? configs[0] : null;
}, },
/** 停止手机连续扫码(含 Ba-Scanner) */
stopPhoneScanContinuous() {
this._phoneScanContinuousActive = false;
// #ifdef APP-PLUS
try {
const scanner = uni.requireNativePlugin('Ba-Scanner');
if (scanner && typeof scanner.onClose === 'function') {
scanner.onClose();
}
} catch (e) {
// 未购买/未打包原生插件时忽略
}
// #endif
},
/**
* 打开手机扫码
* @param {{ continuous?: boolean, callback?: Function, fail?: Function, scanType?: string[], hintText?: string, scanTimeSpace?: number }} options
* continuous=true 时优先用 Ba-Scanner 连续扫;无插件则扫完自动再开相机
*/
openPhoneScan(options = {}) { openPhoneScan(options = {}) {
const callback = options.callback || this._scanCallback; const callback = options.callback || this._scanCallback;
const continuous = !!options.continuous;
this._phoneScanContinuousActive = continuous;
// #ifdef APP-PLUS
if (continuous && this.openBaScannerContinuous(options, callback)) {
return;
}
// #endif
// #ifdef APP-PLUS || MP-WEIXIN // #ifdef APP-PLUS || MP-WEIXIN
uni.scanCode({ uni.scanCode({
scanType: options.scanType || ['qrCode', 'barCode'], scanType: options.scanType || ['qrCode', 'barCode'],
success: (res) => { success: (res) => {
this.handleScanResult(res.result, callback); const result = this.handleScanResult(res.result, callback);
if (!continuous || !this._phoneScanContinuousActive) return;
Promise.resolve(result)
.catch(() => null)
.then(() => {
if (!this._phoneScanContinuousActive || !this.isPageActive) return;
setTimeout(() => {
if (!this._phoneScanContinuousActive || !this.isPageActive) return;
this.openPhoneScan(options);
}, Number(options.scanTimeSpace) > 0 ? Number(options.scanTimeSpace) : 400);
});
}, },
fail: (err) => { fail: (err) => {
console.error('手机扫码失败:', err); console.error('手机扫码失败:', err);
this._phoneScanContinuousActive = false;
if (options.fail) { if (options.fail) {
options.fail(err); options.fail(err);
return; return;
} }
// 用户取消不打扰
const msg = (err && (err.errMsg || err.message)) || '';
if (/cancel|取消/i.test(msg)) return;
uni.showToast({ uni.showToast({
title: '扫码失败', title: '扫码失败',
icon: 'none', icon: 'none',
@@ -158,6 +146,41 @@ export default {
// #endif // #endif
}, },
/**
* Ba-Scanner 连续扫码(插件市场 id=9669)
* @returns {boolean} 是否已成功唤起原生连续扫
*/
openBaScannerContinuous(options = {}, callback) {
// #ifdef APP-PLUS
try {
const scanner = uni.requireNativePlugin('Ba-Scanner');
if (!scanner || typeof scanner.onScan !== 'function') return false;
scanner.onScan(
{
isContinuous: true,
scanTimeSpace: Number(options.scanTimeSpace) > 0 ? Number(options.scanTimeSpace) : 1500,
isShowVibrate: options.isShowVibrate !== false,
isShowBeep: !!options.isShowBeep,
isShowToast: false,
isShowPhotoAlbum: options.isShowPhotoAlbum !== false,
hintText: options.hintText || '扫二维码/条形码,可连续扫',
barcodeFormats: options.barcodeFormats || ['QR Code', 'Code 128', 'Code 39', 'EAN-13', 'EAN-8'],
},
(ret) => {
if (!ret || !ret.result) return;
if (!this._phoneScanContinuousActive) return;
this.handleScanResult(ret.result, callback);
},
);
return true;
} catch (e) {
console.warn('Ba-Scanner 不可用,回退 uni.scanCode', e);
return false;
}
// #endif
return false;
},
triggerScan() { triggerScan() {
if (this.usePhoneScanFallback) { if (this.usePhoneScanFallback) {
this.openPhoneScan(); this.openPhoneScan();
@@ -316,11 +339,12 @@ export default {
console.log("扫码结果:", cleanCode); console.log("扫码结果:", cleanCode);
if (scanCallback) { if (scanCallback) {
scanCallback(cleanCode); return scanCallback(cleanCode);
} }
} catch (error) { } catch (error) {
console.error("处理扫码结果时出错:", error); console.error("处理扫码结果时出错:", error);
} }
return undefined;
}, },
unregisterScanBroadcast() { unregisterScanBroadcast() {
@@ -372,10 +396,13 @@ export default {
onHide() { onHide() {
this.isPageActive = false; this.isPageActive = false;
// 不在 onHide 里关 Ba-Scanner:打开原生扫码页也会触发 hide,误关会打断连续扫
// 无插件回退模式靠 isPageActive 控制是否自动再开相机
}, },
onUnload() { onUnload() {
this.isPageActive = false; this.isPageActive = false;
this.stopPhoneScanContinuous();
this.unregisterScanBroadcast(); this.unregisterScanBroadcast();
} }
} }
+83 -19
View File
@@ -46,12 +46,12 @@ export const FABRIC_INFO_FIELDS = [
/** 细码表格列(不含操作列) */ /** 细码表格列(不含操作列) */
export const FINE_CODE_TABLE_COLUMNS = [ export const FINE_CODE_TABLE_COLUMNS = [
{ label: '序号', key: 'seq', width: 70 }, { label: '序号', key: 'seq', width: 90 },
{ label: '卷号', key: 'roll_no', width: 90 }, { label: '卷号', key: 'roll_no', width: 110 },
{ label: '匹数', key: 'roll', width: 90 }, { label: '匹数', key: 'roll', width: 100 },
{ label: '数量(重量)', key: 'weight', width: 120 }, { label: '数量(重量)', key: 'weight', width: 160 },
{ label: '条码', key: 'bar_code', width: 260 }, { label: '条码', key: 'bar_code', width: 280 },
{ label: '仓位', key: 'position', width: 110 }, { label: '仓位', key: 'position', width: 140 },
]; ];
/** 审核状态变更操作配置(apiKey 对应 gfmOtherDeliveryOrder 下的方法名) */ /** 审核状态变更操作配置(apiKey 对应 gfmOtherDeliveryOrder 下的方法名) */
@@ -61,12 +61,19 @@ export const STATUS_ACTION_CONFIG = {
unapprove: { status: AUDIT_STATUS.PENDING, msg: '确认消审该单据?', apiKey: 'statusWait' }, unapprove: { status: AUDIT_STATUS.PENDING, msg: '确认消审该单据?', apiKey: 'statusWait' },
}; };
/** 审核 / 作废成功后播放的语音文案 */ /** 审核 / 消审 / 作废成功后播放的语音文案 */
export const STATUS_ACTION_VOICE = { export const STATUS_ACTION_VOICE = {
approve: '审核成功', approve: '审核成功',
unapprove: '消审成功',
void: '作废成功', void: '作废成功',
}; };
/** 将接口状态统一为数字,避免字符串导致按钮判断失效 */
export function toAuditStatus(status) {
const n = Number(status);
return Number.isFinite(n) ? n : DRAFT_AUDIT_STATUS;
}
// 出仓类型:当前后端仅提供「坯布其他出货单」一种类型的接口 // 出仓类型:当前后端仅提供「坯布其他出货单」一种类型的接口
export const BILL_TYPES = [ export const BILL_TYPES = [
{ value: 'other', label: '坯布其他出货单' }, { value: 'other', label: '坯布其他出货单' },
@@ -125,12 +132,14 @@ export function getFineCodeDisplayWeight(fineCode) {
*/ */
export function normalizeOrder(order) { export function normalizeOrder(order) {
if (!order) return null; if (!order) return null;
const itemData = groupItemData((order.item_data || []).map((item) => normalizeItem(item))); const normalizedItems = (order.item_data || []).map((item) => normalizeItem(item));
const itemData = groupItemData(normalizedItems);
const auditStatus = toAuditStatus(order.audit_status);
return { return {
id: order.id, id: order.id,
order_no: order.order_no || '', order_no: order.order_no || '',
audit_status: order.audit_status, audit_status: auditStatus,
audit_status_name: order.audit_status_name || AUDIT_STATUS_MAP[order.audit_status] || '', audit_status_name: order.audit_status_name || AUDIT_STATUS_MAP[auditStatus] || '',
// 表头 // 表头
sale_system_id: order.sale_system_id || '', sale_system_id: order.sale_system_id || '',
sale_system_name: order.sale_system_name || '', sale_system_name: order.sale_system_name || '',
@@ -149,10 +158,52 @@ export function normalizeOrder(order) {
total_roll: formatRoll(order.total_roll), total_roll: formatRoll(order.total_roll),
total_weight: formatWeightKg(order.total_weight), total_weight: formatWeightKg(order.total_weight),
item_data: itemData, item_data: itemData,
summary_rows: buildSummaryRows(normalizedItems),
_raw: order, _raw: order,
}; };
} }
/** 扫码区下方汇总表列(与出仓明细表一致,可横向滑动) */
export const SUMMARY_TABLE_COLUMNS = [
{ label: '坯布编号', key: 'grey_fabric_code', width: 200 },
{ label: '坯布名称', key: 'grey_fabric_name', width: 240 },
{ label: '纱批', key: 'yarn_batch', width: 180 },
{ label: '机台号', key: 'machine_number', width: 160 },
{ label: '条数', key: 'roll', width: 140 },
{ label: '重量', key: 'weight', width: 160 },
];
/** 汇总行归类:坯布编号 + 名称 + 纱批 + 机台号 */
export function getSummaryGroupKey(item) {
return [
item.grey_fabric_code || '',
item.grey_fabric_name || '',
item.yarn_batch || '',
item.machine_number || '',
].join('|');
}
/** 按坯布、纱批、机台号汇总条数和重量,供扫码区表格展示 */
export function buildSummaryRows(items) {
const grouped = new Map();
(items || []).forEach((item) => {
const groupKey = getSummaryGroupKey(item);
const existing = grouped.get(groupKey);
if (!existing) {
grouped.set(groupKey, {
...item,
group_key: groupKey,
fine_codes: [...(item.fine_codes || [])],
});
return;
}
existing.fine_codes.push(...(item.fine_codes || []));
existing.roll = Number((Number(existing.roll || 0) + Number(item.roll || 0)).toFixed(2));
existing.weight = Number((Number(existing.weight || 0) + Number(item.weight || 0)).toFixed(2));
});
return Array.from(grouped.values());
}
/** 扫码详情区汇总维度(勾选后随扫码请求把对应 lock 字段传给后端) */ /** 扫码详情区汇总维度(勾选后随扫码请求把对应 lock 字段传给后端) */
export const SCAN_GROUP_OPTIONS = [ export const SCAN_GROUP_OPTIONS = [
{ key: 'produce_order_no', label: '合同' }, { key: 'produce_order_no', label: '合同' },
@@ -389,11 +440,13 @@ export function formatDisplayTime(value, format = 'YYYY-MM-DD') {
} }
export function canScanAtStatus(status) { export function canScanAtStatus(status) {
return [AUDIT_STATUS.PENDING, AUDIT_STATUS.REJECTED].includes(status); const s = toAuditStatus(status);
return s === AUDIT_STATUS.PENDING || s === AUDIT_STATUS.REJECTED;
} }
export function isLockedOrderStatus(status) { export function isLockedOrderStatus(status) {
return [AUDIT_STATUS.APPROVED, AUDIT_STATUS.VOIDED].includes(status); const s = toAuditStatus(status);
return s === AUDIT_STATUS.APPROVED || s === AUDIT_STATUS.VOIDED;
} }
/** 分页拉取全部列表(直至末页) */ /** 分页拉取全部列表(直至末页) */
@@ -408,9 +461,14 @@ export function fetchAllOrderList(listFn, params = {}, pageSize = LIST_PAGE_SIZE
return loadPage(1, []); return loadPage(1, []);
} }
/** 新增/编辑页底部:审核、作废 */ /** 新增/编辑页底部:审核、作废 / 已审核时消审 */
export function getFormStatusActionButtons(headerSaved, orderId, status) { export function getFormStatusActionButtons(headerSaved, orderId, status) {
if (!headerSaved || !orderId || !canScanAtStatus(status)) return []; if (!headerSaved || !orderId) return [];
const s = toAuditStatus(status);
if (s === AUDIT_STATUS.APPROVED) {
return [{ label: '消审', action: 'unapprove' }];
}
if (!canScanAtStatus(s)) return [];
return [ return [
{ label: '审核', action: 'approve' }, { label: '审核', action: 'approve' },
{ label: '作废', action: 'void' }, { label: '作废', action: 'void' },
@@ -419,14 +477,15 @@ export function getFormStatusActionButtons(headerSaved, orderId, status) {
/** 查看页底部:编辑、审核、作废 / 消审 */ /** 查看页底部:编辑、审核、作废 / 消审 */
export function getViewStatusActionButtons(status) { export function getViewStatusActionButtons(status) {
if (status === AUDIT_STATUS.PENDING || status === AUDIT_STATUS.REJECTED) { const s = toAuditStatus(status);
if (s === AUDIT_STATUS.PENDING || s === AUDIT_STATUS.REJECTED) {
return [ return [
{ label: '编辑', action: 'edit' }, { label: '编辑', action: 'edit' },
{ label: '审核', action: 'approve' }, { label: '审核', action: 'approve' },
{ label: '作废', action: 'void' }, { label: '作废', action: 'void' },
]; ];
} }
if (status === AUDIT_STATUS.APPROVED) { if (s === AUDIT_STATUS.APPROVED) {
return [{ label: '消审', action: 'unapprove' }]; return [{ label: '消审', action: 'unapprove' }];
} }
return []; return [];
@@ -441,12 +500,14 @@ export function orderToFormFields(order) {
delivery_time: order.delivery_time, delivery_time: order.delivery_time,
remark: order.remark, remark: order.remark,
item_data: order.item_data, item_data: order.item_data,
summary_rows: order.summary_rows || [],
}; };
} }
export function getFineCodeTableColumns(readonly) { export function getFineCodeTableColumns(readonly) {
const cols = [...FINE_CODE_TABLE_COLUMNS]; const cols = [...FINE_CODE_TABLE_COLUMNS];
if (!readonly) cols.push({ label: '操作', key: 'action', width: 90 }); // 操作列放前面,避免 PDA 小屏横向滚动后才看到删除
if (!readonly) cols.splice(1, 0, { label: '操作', key: 'action', width: 160 });
return cols; return cols;
} }
@@ -472,7 +533,7 @@ export function getFineCodeTableWidth(columns) {
* @param {Vue} vm 页面实例,需有 $u.api 与 showError * @param {Vue} vm 页面实例,需有 $u.api 与 showError
* @param {{ orderId: number, action: string, onSuccess?: Function }} options * @param {{ orderId: number, action: string, onSuccess?: Function }} options
*/ */
export function confirmOrderStatusAction(vm, { orderId, action, onSuccess }) { export function confirmOrderStatusAction(vm, { orderId, action, onSuccess, onCancel }) {
const cfg = STATUS_ACTION_CONFIG[action]; const cfg = STATUS_ACTION_CONFIG[action];
if (!cfg || !orderId) return; if (!cfg || !orderId) return;
const api = vm.$u.api.gfmOtherDeliveryOrder; const api = vm.$u.api.gfmOtherDeliveryOrder;
@@ -482,7 +543,10 @@ export function confirmOrderStatusAction(vm, { orderId, action, onSuccess }) {
title: '提示', title: '提示',
content: cfg.msg, content: cfg.msg,
success: (res) => { success: (res) => {
if (!res.confirm) return; if (!res.confirm) {
if (typeof onCancel === 'function') onCancel();
return;
}
uni.showLoading({ title: '处理中...' }); uni.showLoading({ title: '处理中...' });
requestFn(buildStatusParam(orderId, cfg.status)) requestFn(buildStatusParam(orderId, cfg.status))
.then(() => { .then(() => {
+259
View File
@@ -0,0 +1,259 @@
<template>
<view v-show="visible" class="plus-barcode-panel">
<view class="plus-barcode-panel__toolbar">
<text class="plus-barcode-panel__tip">{{ tipText }}</text>
<text class="plus-barcode-panel__close" @click.stop="close">收起</text>
</view>
<!-- #ifdef APP-PLUS -->
<view :id="holderId" class="plus-barcode-panel__holder" />
<!-- #endif -->
<!-- #ifndef APP-PLUS -->
<view class="plus-barcode-panel__fallback">
<text>当前环境不支持半屏扫码,请使用输入框或系统扫码</text>
</view>
<!-- #endif -->
</view>
</template>
<script>
const DEFAULT_FILTERS = [0, 1, 2, 8, 10]; // QR EAN13 EAN8 CODE39 CODE128
let barcodeSeq = 0;
export default {
name: 'PlusBarcodePanel',
props: {
visible: { type: Boolean, default: false },
hintText: { type: String, default: '将条码放入框内,可连续扫' },
scanTimeSpace: { type: Number, default: 1200 },
filters: { type: Array, default: () => DEFAULT_FILTERS.slice() },
},
data() {
barcodeSeq += 1;
return {
holderId: `plusBarcodeHolder_${barcodeSeq}`,
barcodeViewId: `plusBarcodeView_${barcodeSeq}`,
_barcode: null,
_restartTimer: null,
_active: false,
_creating: false,
};
},
computed: {
tipText() {
return this.hintText || '将条码放入框内,可连续扫';
},
},
watch: {
visible(val) {
if (val) {
this.$nextTick(() => {
this.openNative();
});
} else {
this.destroyNative();
}
},
},
beforeDestroy() {
this.destroyNative();
},
methods: {
open() {
if (this.visible) {
this.$nextTick(() => this.openNative());
return;
}
this.$emit('update:visible', true);
},
close() {
this.destroyNative();
if (this.visible) {
this.$emit('update:visible', false);
}
this.$emit('close');
},
getCurrentWebview() {
// #ifdef APP-PLUS
try {
const pages = getCurrentPages();
const page = pages[pages.length - 1];
if (page && typeof page.$getAppWebview === 'function') {
return page.$getAppWebview();
}
} catch (e) {
console.warn('PlusBarcodePanel getCurrentWebview failed', e);
}
// #endif
return null;
},
openNative() {
// #ifdef APP-PLUS
if (!this.visible || this._creating) return;
if (this._barcode) {
this.resumeScan();
return;
}
this._creating = true;
this._active = true;
// 等占位区域完成布局后再量位置,避免 Android 上 rect 为 0
setTimeout(() => {
if (!this.visible || !this._active) {
this._creating = false;
return;
}
uni.createSelectorQuery()
.in(this)
.select('.plus-barcode-panel__holder')
.boundingClientRect((rect) => {
this._creating = false;
if (!this.visible || !this._active) return;
if (!rect || !rect.width || !rect.height) {
uni.showToast({ title: '扫码区域未就绪', icon: 'none' });
return;
}
this.createBarcode(rect);
})
.exec();
}, 80);
// #endif
},
createBarcode(rect) {
// #ifdef APP-PLUS
const webview = this.getCurrentWebview();
if (!webview || typeof plus === 'undefined' || !plus.barcode) {
uni.showToast({ title: '当前环境不支持扫码', icon: 'none' });
return;
}
this.destroyNative(false);
try {
const barcode = plus.barcode.create(
this.barcodeViewId,
this.filters && this.filters.length ? this.filters : DEFAULT_FILTERS,
{
top: `${Math.round(rect.top)}px`,
left: `${Math.round(rect.left)}px`,
width: `${Math.round(rect.width)}px`,
height: `${Math.round(rect.height)}px`,
position: 'absolute',
background: '#000000',
frameColor: '#2979ff',
scanbarColor: '#2979ff',
},
);
barcode.onmarked = (type, code) => {
this.onMarked(type, code);
};
barcode.onerror = (err) => {
console.error('PlusBarcodePanel onerror', err);
};
webview.append(barcode);
this._barcode = barcode;
this._active = true;
barcode.start({
vibrate: true,
sound: 'default',
});
} catch (e) {
console.error('PlusBarcodePanel create failed', e);
uni.showToast({ title: '打开扫码失败', icon: 'none' });
this._barcode = null;
}
// #endif
},
onMarked(type, code) {
const result = String(code || '').trim();
if (!result || !this._active) return;
try {
if (this._barcode) this._barcode.cancel();
} catch (e) {
// ignore
}
this.$emit('success', result, type);
clearTimeout(this._restartTimer);
const gap = Number(this.scanTimeSpace) > 0 ? Number(this.scanTimeSpace) : 1200;
this._restartTimer = setTimeout(() => {
this.resumeScan();
}, gap);
},
resumeScan() {
// #ifdef APP-PLUS
if (!this.visible || !this._active || !this._barcode) return;
try {
this._barcode.start({
vibrate: true,
sound: 'default',
});
} catch (e) {
console.warn('PlusBarcodePanel resume failed', e);
}
// #endif
},
destroyNative(clearActive = true) {
clearTimeout(this._restartTimer);
this._restartTimer = null;
if (clearActive) this._active = false;
// #ifdef APP-PLUS
const barcode = this._barcode;
this._barcode = null;
if (!barcode) return;
try {
barcode.cancel();
} catch (e) {
// ignore
}
try {
barcode.close();
} catch (e) {
// ignore
}
// #endif
},
},
};
</script>
<style scoped lang="scss">
@import '@/common/pda-typography.scss';
.plus-barcode-panel {
background: #000;
margin-top: 16rpx;
}
.plus-barcode-panel__toolbar {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 72rpx;
padding: 12rpx 26rpx;
background: #1f1f1f;
box-sizing: border-box;
}
.plus-barcode-panel__tip {
flex: 1;
color: #ffffff;
font-size: $pda-font-action;
padding-right: 16rpx;
}
.plus-barcode-panel__close {
color: #2979ff;
font-size: $pda-font-action;
flex-shrink: 0;
}
.plus-barcode-panel__holder {
width: 100%;
height: 420rpx;
background: #000;
}
.plus-barcode-panel__fallback {
display: flex;
align-items: center;
justify-content: center;
height: 420rpx;
padding: 24rpx;
box-sizing: border-box;
background: #333;
color: #fff;
font-size: $pda-font-body;
text-align: center;
}
</style>
+40 -11
View File
@@ -10,14 +10,20 @@
@input="$emit('input', $event.detail.value)" @input="$emit('input', $event.detail.value)"
@confirm="$emit('scan')" @confirm="$emit('scan')"
/> />
<u-icon <view
v-if="showPhoneScan" v-if="scanning"
class="fabric-out-phoneScanIcon" class="fabric-out-scanClose"
name="scan" @click.stop="$emit('phone-scan')"
size="80" >
color="#2979ff" 关闭扫码
@click="$emit('phone-scan')" </view>
/> <view
v-else
class="fabric-out-toolbarIcon"
@click.stop="$emit('phone-scan')"
>
<u-icon name="scan" size="44" color="#595959" />
</view>
<checkbox-group @change="$emit('delete-mode-change', $event)"> <checkbox-group @change="$emit('delete-mode-change', $event)">
<label class="fabric-out-delCheck"> <label class="fabric-out-delCheck">
<checkbox :checked="deleteMode" />删除 <checkbox :checked="deleteMode" />删除
@@ -37,17 +43,40 @@ export default {
deleteMode: { type: Boolean, default: false }, deleteMode: { type: Boolean, default: false },
message: { type: String, default: '' }, message: { type: String, default: '' },
disabledTip: { type: String, default: '当前状态不可扫码' }, disabledTip: { type: String, default: '当前状态不可扫码' },
showPhoneScan: { type: Boolean, default: false }, scanning: { type: Boolean, default: false },
}, },
}; };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import '@/pages/storefabric/storeFabricBusinessOutPage.scss'; @import '@/pages/storefabric/storeFabricBusinessOutPage.scss';
@import '@/common/pda-typography.scss';
.fabric-out-phoneScanIcon { .fabric-out-toolbarIcon {
display: flex;
align-items: center;
justify-content: center;
width: 72rpx;
height: 72rpx;
margin-left: 8rpx; margin-left: 8rpx;
padding: 10rpx 16rpx; border-radius: 8rpx;
border: 1rpx solid #d9d9d9;
background: #f7f7f7;
flex-shrink: 0; flex-shrink: 0;
} }
.fabric-out-scanClose {
display: flex;
align-items: center;
justify-content: center;
margin-left: 8rpx;
padding: 0 16rpx;
height: 72rpx;
border-radius: 8rpx;
border: 1rpx solid #2979ff;
background: #eaf2ff;
color: #2979ff;
font-size: $pda-font-action;
flex-shrink: 0;
white-space: nowrap;
}
</style> </style>
@@ -0,0 +1,140 @@
<template>
<view class="fabric-out-summary">
<scroll-view scroll-x class="fabric-out-summaryScroll">
<view class="fabric-out-summaryInner" :style="{ width: tableWidth }">
<t-table border="1" border-color="#e1e1e1">
<t-tr font-size="18" color="#3e3e3e" align="center">
<t-th
v-for="col in headers"
:key="col.key"
align="center"
>
<view class="fabric-out-th" :style="cellStyle(col)">{{ col.label }}</view>
</t-th>
</t-tr>
<t-tr
v-for="(row, rowIndex) in contents"
:key="row.group_key || rowIndex"
font-size="18"
color="#333"
align="center"
>
<t-td
v-for="col in headers"
:key="col.key"
align="center"
>
<view
class="fabric-out-td"
:style="cellStyle(col)"
@click="onCellClick(col.key, row)"
>{{ formatCell(row, col.key) }}</view>
</t-td>
</t-tr>
</t-table>
</view>
</scroll-view>
<view v-if="!contents.length" class="fabric-out-summaryEmpty">暂无数据~~</view>
</view>
</template>
<script>
import tTable from '@/components/t-table/t-table.vue';
import tTr from '@/components/t-table/t-tr.vue';
import tTh from '@/components/t-table/t-th.vue';
import tTd from '@/components/t-table/t-td.vue';
import { SUMMARY_TABLE_COLUMNS } from '@/common/storeFabricBusinessOut';
export default {
components: { tTable, tTr, tTh, tTd },
props: {
rows: { type: Array, default: () => [] },
},
computed: {
headers() {
return SUMMARY_TABLE_COLUMNS;
},
tableWidth() {
const total = this.headers.reduce((sum, col) => sum + (col.width || 160), 0);
return `${total}rpx`;
},
contents() {
return (this.rows || []).map((row) => ({
...row,
grey_fabric_code: row.grey_fabric_code || '',
grey_fabric_name: row.grey_fabric_name || '',
yarn_batch: row.yarn_batch || '',
machine_number: row.machine_number || '',
roll: row.roll != null && row.roll !== '' ? String(row.roll) : '0',
weight: row.weight != null && row.weight !== '' ? String(row.weight) : '0',
}));
},
},
methods: {
cellStyle(col) {
const width = `${col.width || 160}rpx`;
return {
width,
minWidth: width,
maxWidth: width,
};
},
formatCell(row, key) {
const val = row[key];
if (val === 0) return '0';
return val != null && val !== '' ? val : '-';
},
onCellClick(key, row) {
this.$emit('cell-click', { key, lineData: row });
},
},
};
</script>
<style scoped lang="scss">
@import '@/common/pda-typography.scss';
.fabric-out-summary {
background: #fff;
margin-top: 16rpx;
}
.fabric-out-summaryScroll {
width: 100%;
}
.fabric-out-summaryInner {
min-width: 100%;
}
.fabric-out-summary ::v-deep .t-table {
width: 100%;
}
.fabric-out-summary ::v-deep .t-th,
.fabric-out-summary ::v-deep .t-td {
flex: 0 0 auto;
width: auto;
padding: 0;
min-height: $pda-row-min-height;
box-sizing: border-box;
}
.fabric-out-th,
.fabric-out-td {
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
min-height: $pda-row-min-height;
padding: 16rpx 12rpx;
font-size: $pda-font-body;
word-break: break-all;
text-align: center;
}
.fabric-out-th {
font-weight: bold;
}
.fabric-out-summaryEmpty {
text-align: center;
color: #999;
font-size: $pda-font-body;
line-height: $pda-row-min-height;
background: #fff;
}
</style>
+40 -12
View File
@@ -21,11 +21,17 @@
:class="{ actionCell: col.key === 'action' && !readonly }" :class="{ actionCell: col.key === 'action' && !readonly }"
:style="cellStyle(col)" :style="cellStyle(col)"
@click="onCellTap(col.key, rowIndex)" @click="onCellTap(col.key, rowIndex)"
>{{ row[col.key] }}</view> >
<text
v-if="col.key === 'action' && !readonly"
class="deleteBtn"
>{{ row[col.key] }}</text>
<template v-else>{{ row[col.key] }}</template>
</view>
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
<view v-if="!readonly && list.length" class="tableTip">点击「操作」列删除,将调用扫码删除接口</view> <view v-if="!readonly && list.length" class="tableTip">点击「删除」将调用扫码删除接口</view>
</view> </view>
</u-popup> </u-popup>
</template> </template>
@@ -81,9 +87,11 @@ export default {
}; };
</script> </script>
<style scoped> <style scoped lang="scss">
@import '@/common/pda-typography.scss';
.popupWrap { .popupWrap {
padding: 24rpx 16rpx 30rpx; padding: 28rpx 16rpx 32rpx;
max-height: 80vh; max-height: 80vh;
box-sizing: border-box; box-sizing: border-box;
display: flex; display: flex;
@@ -91,18 +99,18 @@ export default {
overflow: hidden; overflow: hidden;
} }
.popupTitle { .popupTitle {
font-size: 32rpx; font-size: $pda-font-popup-title;
font-weight: bold; font-weight: bold;
text-align: center; text-align: center;
margin-bottom: 20rpx; margin-bottom: 24rpx;
color: #333; color: #333;
flex-shrink: 0; flex-shrink: 0;
} }
.emptyTip { .emptyTip {
text-align: center; text-align: center;
color: #999; color: #999;
padding: 40rpx 0; padding: 48rpx 0;
font-size: 28rpx; font-size: $pda-font-popup-sub;
} }
.tableScroll { .tableScroll {
width: 100%; width: 100%;
@@ -118,6 +126,7 @@ export default {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
flex-wrap: nowrap; flex-wrap: nowrap;
align-items: stretch;
border-bottom: 1rpx solid #e1e1e1; border-bottom: 1rpx solid #e1e1e1;
} }
.tableRow:last-child { .tableRow:last-child {
@@ -131,8 +140,12 @@ export default {
} }
.tableCell { .tableCell {
flex-shrink: 0; flex-shrink: 0;
padding: 12rpx 8rpx; display: flex;
font-size: 22rpx; align-items: center;
justify-content: center;
min-height: $pda-row-min-height;
padding: 16rpx 10rpx;
font-size: $pda-font-popup-item;
color: #333; color: #333;
text-align: center; text-align: center;
border-right: 1rpx solid #e1e1e1; border-right: 1rpx solid #e1e1e1;
@@ -146,13 +159,28 @@ export default {
.headCell { .headCell {
font-weight: bold; font-weight: bold;
color: #3e3e3e; color: #3e3e3e;
min-height: 80rpx;
} }
.actionCell { .actionCell {
padding: 12rpx 8rpx;
}
.deleteBtn {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 120rpx;
min-height: 72rpx;
padding: 0 20rpx;
border-radius: 8rpx;
background: #fff1f0;
border: 1rpx solid #ffa39e;
color: #f5222d; color: #f5222d;
font-size: $pda-font-action;
line-height: 1.2;
} }
.tableTip { .tableTip {
margin-top: 16rpx; margin-top: 20rpx;
font-size: 22rpx; font-size: $pda-font-popup-sub;
color: #999; color: #999;
text-align: center; text-align: center;
flex-shrink: 0; flex-shrink: 0;
@@ -19,9 +19,16 @@
v-for="item in filteredList" v-for="item in filteredList"
:key="String(item.value)" :key="String(item.value)"
class="search-select__item" class="search-select__item"
@click="confirm(item)" :class="{ 'is-selected': multiple && isPicked(item) }"
>{{ item.label }}</view> @click="onItemClick(item)"
>
<text class="search-select__item-label">{{ item.label }}</text>
<text v-if="multiple && isPicked(item)" class="search-select__check">已选</text>
</view>
</scroll-view> </scroll-view>
<view v-if="multiple" class="search-select__footer">
<view class="search-select__ok" @click="confirmMultiple">确定</view>
</view>
</view> </view>
</u-popup> </u-popup>
</template> </template>
@@ -33,12 +40,15 @@ export default {
title: { type: String, default: '请选择' }, title: { type: String, default: '请选择' },
placeholder: { type: String, default: '请输入名称搜索' }, placeholder: { type: String, default: '请输入名称搜索' },
list: { type: Array, default: () => [] }, list: { type: Array, default: () => [] },
multiple: { type: Boolean, default: false },
selected: { type: Array, default: () => [] },
}, },
data() { data() {
return { return {
keyword: '', keyword: '',
panelMaxHeight: 520, panelMaxHeight: 520,
listHeight: 360, listHeight: 360,
picked: [],
}; };
}, },
computed: { computed: {
@@ -56,6 +66,7 @@ export default {
show(val) { show(val) {
if (val) { if (val) {
this.keyword = ''; this.keyword = '';
this.picked = (this.selected || []).map((item) => String(item));
this.calcHeight(); this.calcHeight();
} }
}, },
@@ -70,16 +81,37 @@ export default {
const winH = sys.windowHeight || 600; const winH = sys.windowHeight || 600;
// 弹层约占屏高 65%,列表为弹层去掉标题+搜索后的剩余高度 // 弹层约占屏高 65%,列表为弹层去掉标题+搜索后的剩余高度
this.panelMaxHeight = Math.floor(winH * 0.65); this.panelMaxHeight = Math.floor(winH * 0.65);
this.listHeight = Math.max(220, this.panelMaxHeight - 140); const chrome = this.multiple ? 230 : 140;
this.listHeight = Math.max(220, this.panelMaxHeight - chrome);
} catch (e) { } catch (e) {
this.panelMaxHeight = 520; this.panelMaxHeight = 520;
this.listHeight = 360; this.listHeight = this.multiple ? 280 : 360;
} }
}, },
isPicked(item) {
return this.picked.includes(String(item.value));
},
onItemClick(item) {
if (!this.multiple) {
this.confirm(item);
return;
}
const key = String(item.value);
if (this.picked.includes(key)) {
this.picked = this.picked.filter((value) => value !== key);
return;
}
this.picked = this.picked.concat(key);
},
confirm(item) { confirm(item) {
this.visible = false; this.visible = false;
this.$emit('confirm', item); this.$emit('confirm', item);
}, },
confirmMultiple() {
const selected = (this.list || []).filter((item) => this.isPicked(item));
this.visible = false;
this.$emit('confirm', selected);
},
}, },
}; };
</script> </script>
@@ -126,9 +158,42 @@ export default {
font-size: $pda-font-popup-sub; font-size: $pda-font-popup-sub;
} }
.search-select__item { .search-select__item {
padding: 32rpx 30rpx; display: flex;
align-items: center;
justify-content: space-between;
min-height: $pda-row-min-height;
padding: 20rpx 30rpx;
box-sizing: border-box;
font-size: $pda-font-popup-item; font-size: $pda-font-popup-item;
color: #202328; color: #202328;
border-bottom: 1px solid #f2f2f2; border-bottom: 1px solid #f2f2f2;
} }
.search-select__item-label {
flex: 1;
min-width: 0;
font-size: $pda-font-popup-item;
color: #202328;
}
.search-select__item.is-selected .search-select__item-label {
color: #2f78e6;
}
.search-select__check {
flex-shrink: 0;
margin-left: 16rpx;
font-size: $pda-font-action;
color: #2f78e6;
}
.search-select__footer {
flex-shrink: 0;
padding: 16rpx 30rpx 8rpx;
}
.search-select__ok {
height: $pda-button-height;
line-height: $pda-button-height;
text-align: center;
font-size: $pda-font-button;
color: #fff;
background: #2979ff;
border-radius: 46rpx;
}
</style> </style>
@@ -1,6 +1,5 @@
<template> <template>
<view class="warehouse-table-wrap" :class="{ 'is-auto-height': isAutoHeight }"> <view class="warehouse-table-wrap" :class="{ 'is-auto-height': isAutoHeight }">
<scroll-view scroll-x class="tableScrollX">
<wyb-table <wyb-table
ref="table" ref="table"
:headers="headers" :headers="headers"
@@ -10,7 +9,6 @@
:first-line-fixed="firstLineFixed" :first-line-fixed="firstLineFixed"
@onCellClick="onCellClick" @onCellClick="onCellClick"
/> />
</scroll-view>
</view> </view>
</template> </template>
@@ -24,7 +22,7 @@ export default {
contents: { type: Array, default: () => [] }, contents: { type: Array, default: () => [] },
// auto:高度随内容撑开,纵向滚动交给外层 scroll-view,避免与下拉刷新抢手势 // auto:高度随内容撑开,纵向滚动交给外层 scroll-view,避免与下拉刷新抢手势
height: { type: String, default: 'auto' }, height: { type: String, default: 'auto' },
firstLineFixed: { type: Boolean, default: true }, firstLineFixed: { type: Boolean, default: false },
}, },
computed: { computed: {
isAutoHeight() { isAutoHeight() {
@@ -50,9 +48,6 @@ export default {
width: 100%; width: 100%;
background: #fff; background: #fff;
} }
.tableScrollX {
width: 100%;
}
/* 取消表格内部纵向滚动,只保留横向;纵向由页面 scroll-view 处理 */ /* 取消表格内部纵向滚动,只保留横向;纵向由页面 scroll-view 处理 */
.is-auto-height ::v-deep .wyb-table-scroll-view { .is-auto-height ::v-deep .wyb-table-scroll-view {
height: auto !important; height: auto !important;
+86
View File
@@ -0,0 +1,86 @@
<template>
<view class="t-table" :style="{ 'border-width': border + 'px', 'border-color': borderColor }">
<slot />
</view>
</template>
<script>
export default {
props: {
border: {
type: String,
default: '1'
},
borderColor: {
type: String,
default: '#d0dee5'
},
isCheck: {
type: Boolean,
default: false
}
},
provide() {
return {
table: this
};
},
data() {
return {};
},
created() {
this.childrens = [];
this.index = 0;
},
methods: {
fire(e, index, len) {
let childrens = this.childrens;
console.log(childrens);
// 全选
if (index === 0) {
childrens.map((vm, index) => {
vm.checkboxData.checked = e;
return vm;
});
} else {
let isAll = childrens.find((n, ids) => ids !== 0 && !n.checkboxData.checked);
childrens[0].checkboxData.checked = isAll ? false : true;
}
let fireArr = [];
for (let i = 0; i < childrens.length; i++) {
if (childrens[i].checkboxData.checked && i !== 0) {
fireArr.push(childrens[i].checkboxData.value - 1);
}
}
this.$emit('change', {
detail: fireArr
});
}
}
};
</script>
<style scoped>
.t-table {
width: 100%;
border: 1px #d0dee5 solid;
border-left: none;
border-top: none;
box-sizing: border-box;
}
.t-table>>>t-tr {
display: flex;
}
.t-table>>>t-tr:nth-child(2n) {
background: #f5f5f5;
}
/* #ifdef H5 */
.t-table>>>.t-tr:nth-child(2n) {
background: #f5f5f5;
}
/* #endif */
</style>
+71
View File
@@ -0,0 +1,71 @@
<template>
<view class="t-td" :style="{ 'border-width': thBorder + 'px','border-color':borderColor ,'font-size':fontSize+'px' ,'color':color,'justify-content':tdAlignCpd}">
<slot></slot>
</view>
</template>
<script>
export default {
props: {
align: String
},
data() {
return {
thBorder: '1',
borderColor: '#d0dee5',
fontSize: '14',
color: '#555c60',
tdAlign: 'center'
};
},
inject: ['table', 'tr'],
created() {
this.thBorder = this.table.border;
this.borderColor = this.table.borderColor;
this.fontSize = this.tr.fontSize;
this.color = this.tr.color;
if (this.align) {
this.tdAlign = this.align;
} else {
this.tdAlign = this.tr.align
}
},
computed: {
tdAlignCpd() {
let nameAlign = '';
switch (this.tdAlign) {
case 'left':
nameAlign = 'flex-start'
break;
case 'center':
nameAlign = 'center'
break;
case 'right':
nameAlign = 'flex-end'
break;
default:
nameAlign = 'center'
break;
}
return nameAlign
}
}
};
</script>
<style>
.t-td {
flex: 1;
display: flex;
align-items: center;
width: 100%;
padding: 14upx;
border-top: 1px #d0dee5 solid;
border-left: 1px #d0dee5 solid;
text-align: center;
color: #555c60;
font-size: 28upx;
}
</style>
+71
View File
@@ -0,0 +1,71 @@
<template>
<view class="t-th" :style="{ 'border-width': thBorder + 'px' ,'border-color':borderColor,'font-size':fontSize+'px' ,'color':color,'justify-content':thAlignCpd}">
<slot></slot>
</view>
</template>
<script>
export default {
props: {
align: String,
},
data() {
return {
thBorder: '1',
borderColor: '#d0dee5',
fontSize: '15',
color: '#3b4246',
thAlign: 'center'
};
},
inject: ['table', 'tr'],
created() {
this.thBorder = this.table.border;
this.borderColor = this.table.borderColor;
this.fontSize = this.tr.fontSize;
this.color = this.tr.color;
if (this.align) {
this.thAlign = this.align;
} else {
this.thAlign = this.tr.align
}
},
computed: {
thAlignCpd() {
let nameAlign = '';
switch (this.thAlign) {
case 'left':
nameAlign = 'flex-start'
break;
case 'center':
nameAlign = 'center'
break;
case 'right':
nameAlign = 'flex-end'
break;
default:
nameAlign = 'center'
break;
}
return nameAlign
}
}
};
</script>
<style>
.t-th {
flex: 1;
display: flex;
align-items: center;
font-size: 30upx;
font-weight: bold;
text-align: center;
color: #3b4246;
border-left: 1px #d0dee5 solid;
border-top: 1px #d0dee5 solid;
padding: 15upx;
}
</style>
+81
View File
@@ -0,0 +1,81 @@
<template>
<view class="t-tr">
<view v-if="isCheck" class="t-check-box" :style="{ 'border-width': thBorder + 'px' ,'border-color':borderColor}">
<checkbox-group @change="checkboxChange">
<checkbox :value="checkboxData.value + ''" :checked="checkboxData.checked" />
</checkbox-group>
</view>
<slot></slot>
</view>
</template>
<script>
export default {
props: {
fontSize: String,
color: String,
align: String
},
inject: ['table'],
provide() {
return {
tr: this
};
},
data() {
return {
isCheck: false,
checkboxData: {
value: 0,
checked: false
},
checked: false,
thBorder: '1',
borderColor: '#d0dee5'
};
},
created() {
this.thBorder = this.table.border;
this.borderColor = this.table.borderColor;
this.table.childrens.push(this);
this.checkboxData.value = this.table.index++;
this.isCheck = this.table.isCheck;
},
methods: {
checkboxChange(e) {
this.checkboxData.checked = !this.checkboxData.checked;
this.table.childrens[this.checkboxData.value] = this;
this.table.fire(e.detail.value[0] ? true : false, this.checkboxData.value, this.table.index);
}
}
};
</script>
<style>
.t-tr {
width: 100%;
display: flex;
}
.t-tr t-th,
.t-tr t-td {
display: flex;
flex: 1;
}
.t-tr .t-check-box {
flex-shrink: 0;
display: flex;
justify-content: center;
align-items: center;
width: 80upx;
color: #3b4246;
border-left: 1px #d0dee5 solid;
border-top: 1px #d0dee5 solid;
}
.t-tr .t-check-box checkbox {
transform: scale(0.8);
}
</style>
+589
View File
@@ -0,0 +1,589 @@
<template>
<view class="u-select">
<u-popup :maskCloseAble="maskCloseAble" mode="bottom" :popup="false" v-model="value" length="auto" :safeAreaInsetBottom="safeAreaInsetBottom" @close="close" :z-index="uZIndex">
<view class="u-select">
<view class="u-select__header" @touchmove.stop.prevent="">
<view
class="u-select__header__cancel u-select__header__btn"
:style="{ color: cancelColor }"
hover-class="u-hover-class"
:hover-stay-time="150"
@tap="getResult('cancel')"
>
{{cancelText}}
</view>
<view class="u-select__header__title">
{{title}}
</view>
<view
class="u-select__header__confirm u-select__header__btn"
:style="{ color: moving ? cancelColor : confirmColor }"
hover-class="u-hover-class"
:hover-stay-time="150"
@touchmove.stop=""
@tap.stop="getResult('confirm')"
>
{{confirmText}}
</view>
</view>
<view class="u-select__search" v-if="showSearch" @tap.stop>
<u-icon name="search" size="32" color="#909399"></u-icon>
<input
class="u-select__search__input"
:value="keyword"
:placeholder="searchPlaceholder"
confirm-type="search"
:adjust-position="true"
@input="onSearchInput"
@confirm="onSearchConfirm"
/>
<u-icon
v-if="keyword"
name="close-circle-fill"
size="28"
color="#c0c4cc"
@tap.stop="clearSearch"
></u-icon>
</view>
<view v-if="loading" class="u-select__loading">搜索中...</view>
<view class="u-select__body" :style="hasCustomItemHeight ? bodyStyle : null">
<view v-if="isColumnEmpty && !loading" class="u-select__empty">无匹配选项</view>
<picker-view
v-else-if="value && !isColumnEmpty"
:key="pickerKey"
@change="columnChange"
class="u-select__body__picker-view"
:style="pickerViewStyle"
:indicator-style="indicatorStyle"
:value="defaultSelector"
@pickstart="pickstart"
@pickend="pickend"
>
<picker-view-column v-for="(item, index) in columnData" :key="'col-' + pickerKey + '-' + index">
<view
class="u-select__body__picker-view__item"
:style="hasCustomItemHeight ? itemStyle : null"
v-for="(item1, index1) in item"
:key="item1[valueName] != null ? item1[valueName] : index1"
>
<view class="u-line-1" :style="hasCustomItemHeight ? itemStyle : null">{{ item1[labelName] }}</view>
</view>
</picker-view-column>
</picker-view>
</view>
</view>
</u-popup>
</view>
</template>
<script>
/**
* select 列选择器(本地覆盖:选项支持搜索)
* @description 此选择器用于单列,多列,多列联动的选择场景。
* @tutorial http://uviewui.com/components/select.html
* @property {String} mode 模式选择,"single-column"-单列模式,"mutil-column"-多列模式,"mutil-column-auto"-多列联动模式
* @property {Array} list 列数据,数组形式,见官网说明
* @property {Boolean} v-model 布尔值变量,用于控制选择器的弹出与收起
* @property {Boolean} show-search 是否显示搜索框(默认true)
* @property {String} search-placeholder 搜索框占位文字
* @event {Function} confirm 点击确定按钮,返回当前选择的值
* @example <u-select v-model="show" :list="list"></u-select>
*/
export default {
props: {
list: {
type: Array,
default() {
return [];
}
},
border: {
type: Boolean,
default: true
},
value: {
type: Boolean,
default: false
},
cancelColor: {
type: String,
default: '#606266'
},
confirmColor: {
type: String,
default: '#2979ff'
},
zIndex: {
type: [String, Number],
default: 0
},
safeAreaInsetBottom: {
type: Boolean,
default: false
},
maskCloseAble: {
type: Boolean,
default: true
},
defaultValue: {
type: Array,
default() {
return [0];
}
},
mode: {
type: String,
default: 'single-column'
},
valueName: {
type: String,
default: 'value'
},
labelName: {
type: String,
default: 'label'
},
childName: {
type: String,
default: 'children'
},
title: {
type: String,
default: ''
},
cancelText: {
type: String,
default: '取消'
},
confirmText: {
type: String,
default: '确认'
},
showSearch: {
type: Boolean,
default: true
},
searchPlaceholder: {
type: String,
default: '搜索'
},
remote: {
type: Boolean,
default: false
},
loading: {
type: Boolean,
default: false
},
debounce: {
type: Number,
default: 400
},
/** 选项行高(rpx)。App 端需与 indicator 同步,避免选中框错位 */
itemHeight: {
type: [Number, String],
default: 0
},
/** 可见行数,用于计算滚轮高度;需为奇数,选中行才能居中 */
visibleItemCount: {
type: [Number, String],
default: 5
}
},
data() {
return {
defaultSelector: [0],
columnData: [],
selectValue: [],
lastSelectIndex: [],
columnNum: 0,
moving: false,
keyword: '',
pickerKey: 0,
// 勿用 _ 前缀:Vue2 不会把 data 代理到 this
searchTimer: null,
lastSearchEmit: '',
lastSearchAt: 0
};
},
watch: {
value: {
immediate: true,
handler(val) {
if (val) {
this.keyword = '';
this.applyPickerData();
if (this.remote) this.emitRemoteSearch('');
} else {
this.clearSearchTimer();
this.lastSearchEmit = '';
this.lastSearchAt = 0;
}
}
},
list: {
handler() {
if (!this.value) return;
this.applyPickerData();
},
},
loading(val) {
// loading 从 true→false 时再刷一次滚轮,避免原生 picker-view 漏更
if (!val && this.value && this.remote) this.applyPickerData();
},
},
beforeDestroy() {
this.clearSearchTimer();
},
computed: {
uZIndex() {
return this.zIndex ? this.zIndex : this.$u.zIndex.popup;
},
isColumnEmpty() {
return !this.columnData || !this.columnData.length || !this.columnData[0] || !this.columnData[0].length;
},
hasCustomItemHeight() {
return Number(this.itemHeight) > 0;
},
itemHeightRpx() {
return Number(this.itemHeight) || 70;
},
itemHeightPx() {
return uni.upx2px(this.itemHeightRpx);
},
visibleCount() {
const n = Number(this.visibleItemCount) || 5;
return n % 2 === 0 ? n + 1 : n;
},
indicatorStyle() {
if (!this.hasCustomItemHeight) return '';
return `height: ${this.itemHeightPx}px;`;
},
itemStyle() {
return {
height: `${this.itemHeightPx}px`,
lineHeight: `${this.itemHeightPx}px`,
};
},
pickerViewStyle() {
if (!this.hasCustomItemHeight) return null;
return { height: `${this.itemHeightPx * this.visibleCount}px` };
},
bodyStyle() {
return this.pickerViewStyle;
},
},
methods: {
pickstart() {
// #ifdef MP-WEIXIN
this.moving = true;
// #endif
},
pickend() {
// #ifdef MP-WEIXIN
this.moving = false;
// #endif
},
readInputValue(e) {
if (typeof e === 'string' || typeof e === 'number') return String(e);
if (e && e.detail && e.detail.value != null) return String(e.detail.value);
if (e && e.target && e.target.value != null) return String(e.target.value);
return '';
},
clearSearchTimer() {
if (this.searchTimer) {
clearTimeout(this.searchTimer);
this.searchTimer = null;
}
},
emitRemoteSearch(keyword) {
this.clearSearchTimer();
const key = keyword == null ? '' : String(keyword).trim();
const now = Date.now();
if (key === this.lastSearchEmit && now - this.lastSearchAt < 80) return;
this.lastSearchEmit = key;
this.lastSearchAt = now;
this.$emit('search', key);
},
scheduleRemoteSearch() {
this.clearSearchTimer();
this.searchTimer = setTimeout(() => {
this.emitRemoteSearch(this.keyword);
}, this.debounce);
},
onSearchInput(e) {
this.keyword = this.readInputValue(e);
if (this.remote) this.scheduleRemoteSearch();
else this.applyFilter();
},
onSearchConfirm(e) {
this.keyword = this.readInputValue(e);
if (this.remote) this.emitRemoteSearch(this.keyword);
else this.applyFilter();
},
clearSearch() {
this.keyword = '';
if (this.remote) this.emitRemoteSearch('');
else this.applyFilter();
},
matchKeyword(text) {
const keyword = (this.keyword || '').trim().toLowerCase();
if (!keyword) return true;
return String(text == null ? '' : text).toLowerCase().indexOf(keyword) !== -1;
},
filterItems(list) {
if (!Array.isArray(list)) return [];
if (this.remote) return list.slice();
const keyword = (this.keyword || '').trim();
if (!keyword) return list.slice();
return list.filter(item => {
return this.matchKeyword(item && item[this.labelName]) || this.matchKeyword(item && item[this.valueName]);
});
},
applyPickerData() {
this.init();
this.pickerKey += 1;
},
applyFilter() {
this.applyPickerData();
},
init() {
this.setColumnNum();
this.setDefaultSelector();
this.setColumnData();
this.setSelectValue();
},
setDefaultSelector() {
const columnNum = this.columnNum || 1;
const defaultValue = Array.isArray(this.defaultValue) ? this.defaultValue.slice() : [];
this.defaultSelector = defaultValue.length === columnNum
? defaultValue
: Array(columnNum).fill(0);
this.lastSelectIndex = this.defaultSelector.slice();
},
setColumnNum() {
if(this.mode == 'single-column') this.columnNum = 1;
else if(this.mode == 'mutil-column') this.columnNum = this.list.length;
else if(this.mode == 'mutil-column-auto') {
let num = 1;
let column = this.list;
while(column[0] && column[0][this.childName]) {
column = column[0] ? column[0][this.childName] : {};
num ++;
}
this.columnNum = num;
}
},
setColumnData() {
let data = [];
this.selectValue = [];
if(this.mode == 'mutil-column-auto') {
const sourceList = this.filterItems(this.list);
if (!sourceList.length) {
this.columnData = [[]];
return;
}
let selector = this.defaultSelector.length ? this.defaultSelector[0] : 0;
if (selector >= sourceList.length) selector = 0;
let column = sourceList[selector];
for (let i = 0; i < this.columnNum; i++) {
if (i == 0) {
data[i] = sourceList;
column = column ? column[this.childName] : [];
} else {
data[i] = column || [];
const nextIndex = this.defaultSelector[i] || 0;
column = (column && column[nextIndex]) ? column[nextIndex][this.childName] : [];
}
}
} else if(this.mode == 'single-column') {
data[0] = this.filterItems(this.list);
} else {
data = (this.list || []).map(col => this.filterItems(Array.isArray(col) ? col : []));
}
this.columnData = data.slice();
},
setSelectValue() {
let tmp = null;
for(let i = 0; i < this.columnNum; i++) {
const col = this.columnData[i] || [];
tmp = col[this.defaultSelector[i]];
let data = {
value: tmp ? tmp[this.valueName] : null,
label: tmp ? tmp[this.labelName] : null
};
if(tmp && tmp.extra !== undefined) data.extra = tmp.extra;
this.selectValue.push(data)
}
},
columnChange(e) {
let index = null;
let columnIndex = e.detail.value;
this.selectValue = [];
this.defaultSelector = columnIndex;
if(this.mode == 'mutil-column-auto') {
this.lastSelectIndex.map((val, idx) => {
if (val != columnIndex[idx]) index = idx;
});
for (let i = index + 1; i < this.columnNum; i++) {
this.columnData[i] = this.columnData[i - 1][i - 1 == index ? columnIndex[index] : 0][this.childName];
this.defaultSelector[i] = 0;
}
columnIndex.map((item, idx) => {
let data = this.columnData[idx][columnIndex[idx]];
let tmp = {
value: data ? data[this.valueName] : null,
label: data ? data[this.labelName] : null,
};
if(data && data.extra !== undefined) tmp.extra = data.extra;
this.selectValue.push(tmp);
})
this.lastSelectIndex = columnIndex;
} else if(this.mode == 'single-column') {
let data = this.columnData[0][columnIndex[0]];
let tmp = {
value: data ? data[this.valueName] : null,
label: data ? data[this.labelName] : null,
};
if(data && data.extra !== undefined) tmp.extra = data.extra;
this.selectValue.push(tmp);
} else if(this.mode == 'mutil-column') {
columnIndex.map((item, idx) => {
let data = this.columnData[idx][columnIndex[idx]];
let tmp = {
value: data ? data[this.valueName] : null,
label: data ? data[this.labelName] : null,
};
if(data && data.extra !== undefined) tmp.extra = data.extra;
this.selectValue.push(tmp);
})
}
},
close() {
this.$emit('input', false);
this.$set(this, 'defaultSelector', [0]);
this.keyword = '';
this.lastSearchEmit = '';
this.lastSearchAt = 0;
},
getResult(event = null) {
// #ifdef MP-WEIXIN
if (this.moving) return;
// #endif
if (event === 'confirm' && this.isColumnEmpty) {
this.$u.toast && this.$u.toast('无匹配选项');
return;
}
if (event) this.$emit(event, this.selectValue);
this.close();
},
selectHandler() {
this.$emit('click');
}
}
};
</script>
<style scoped lang="scss">
@import "~uview-ui/libs/css/style.components.scss";
.u-select {
&__action {
position: relative;
line-height: $u-form-item-height;
height: $u-form-item-height;
&__icon {
position: absolute;
right: 20rpx;
top: 50%;
transition: transform .4s;
transform: translateY(-50%);
z-index: 1;
&--reverse {
transform: rotate(-180deg) translateY(50%);
}
}
}
&__hader {
&__title {
color: $u-content-color;
}
}
&--border {
border-radius: 6rpx;
border-radius: 4px;
border: 1px solid $u-form-item-border-color;
}
&__header {
@include vue-flex;
align-items: center;
justify-content: space-between;
height: 80rpx;
padding: 0 40rpx;
}
&__search {
@include vue-flex;
align-items: center;
margin: 0 24rpx 16rpx;
padding: 0 24rpx;
height: 80rpx;
background-color: #f5f5f5;
border-radius: 12rpx;
box-sizing: border-box;
&__input {
flex: 1;
height: 80rpx;
margin-left: 12rpx;
font-size: 30rpx;
color: #303133;
}
}
&__loading {
padding: 0 24rpx 8rpx;
font-size: 26rpx;
color: #909399;
}
&__empty {
@include vue-flex;
align-items: center;
justify-content: center;
height: 100%;
font-size: 30rpx;
color: #909399;
}
&__body {
width: 100%;
height: 500rpx;
overflow: hidden;
background-color: #fff;
&__picker-view {
height: 100%;
box-sizing: border-box;
&__item {
@include vue-flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
color: $u-main-color;
padding: 0 8rpx;
}
}
}
}
</style>
+1 -1
View File
@@ -73,7 +73,7 @@
borderRight: index === headers.length - 1 || (!showVertBorder && index !== 0) ? 'none' : '1px solid' + borderColor, borderRight: index === headers.length - 1 || (!showVertBorder && index !== 0) ? 'none' : '1px solid' + borderColor,
zIndex: index === 0 ? 20 : 0, zIndex: index === 0 ? 20 : 0,
left: index === 0 && firstLineFixed ? (enableCheck ? checkColWidth + 'rpx' : 0) : 'auto', left: index === 0 && firstLineFixed ? (enableCheck ? checkColWidth + 'rpx' : 0) : 'auto',
position: index === 0 ? 'sticky' : 'static'}"> position: index === 0 && firstLineFixed ? 'sticky' : 'static'}">
<text :style="{marginLeft: autoSortShow(index) && textAlign !== 'left' ? fontSize[0] * 0.65 + 'rpx' : 0}"> <text :style="{marginLeft: autoSortShow(index) && textAlign !== 'left' ? fontSize[0] * 0.65 + 'rpx' : 0}">
{{item.label || emptyString}} {{item.label || emptyString}}
</text> </text>
+2 -2
View File
@@ -2,8 +2,8 @@
"name" : "浩拓织厂", "name" : "浩拓织厂",
"appid" : "__UNI__F79F300", "appid" : "__UNI__F79F300",
"description" : "周尚-浩拓织厂", "description" : "周尚-浩拓织厂",
"versionName" : "1.1.10", "versionName" : "1.1.26",
"versionCode" : 110, "versionCode" : 126,
"transformPx" : false, "transformPx" : false,
"app-plus" : { "app-plus" : {
"optimization" : { "optimization" : {
+1
View File
@@ -1,5 +1,6 @@
{ {
"easycom": { "easycom": {
"^u-select$": "@/components/u-select/u-select.vue",
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue" "^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
}, },
"pages": [ "pages": [
@@ -1,126 +1,89 @@
<template> <template>
<view class="fabric-out-page"> <view class="fabric-out-page">
<view v-if="showHeaderToggle" class="fabric-out-headerBar" @click="toggleHeader">
<view class="fabric-out-headerBarMain">
<text class="fabric-out-headerBarTitle">单据信息</text>
<text v-if="form.order_no" class="fabric-out-headerBarSub">{{ form.order_no }}</text>
</view>
<view class="fabric-out-headerBarAction">
<text>{{ headerExpanded ? '收起' : '展开' }}</text>
<u-icon class="fabric-out-headerBarIcon" :name="headerExpanded ? 'arrow-up' : 'arrow-down'" size="32" color="#2979ff"></u-icon>
</view>
</view>
<view v-show="headerExpanded">
<OrderStatusBar class="fabric-out-mt32" :status="displayAuditStatus" :name="displayAuditStatusName" /> <OrderStatusBar class="fabric-out-mt32" :status="displayAuditStatus" :name="displayAuditStatusName" />
<view class="flex-white-plr26 ptb10 bdb_f5"> <view class="flex-white-plr26 ptb10 bdb_f5">
<text class="mr26">出仓单号</text> <text class="mr26">出仓单号</text>
<u-input disabled placeholder="保存后自动生成" v-model="form.order_no" /> <u-input disabled placeholder="保存后自动生成" v-model="form.order_no" />
</view> </view>
<view class="flex-white-plr26 ptb20 bdb_f5"> <view class="flex-white-plr26 ptb20 bdb_f5">
<text class="mr26">出仓类型</text> <text class="mr26">出仓类型</text>
<view>{{ getBillTypeName() }}</view> <view>{{ getBillTypeName() }}</view>
</view> </view>
<view @click="pickerSelectFun('接收单位')" class="flex-white-plr26 ptb20 bdb_f5"> <view @click="pickerSelectFun('接收单位')" class="flex-white-plr26 ptb20 bdb_f5">
<text class="mr26">接收单位<text class="redXingh">*</text></text> <text class="mr26">接收单位<text class="redXingh">*</text></text>
<view :class="form.business_unit_name ? '' : 'cBlack'"> <view :class="form.business_unit_name ? '' : 'cBlack'">
{{ form.business_unit_name || '请选择' }} {{ form.business_unit_name || '请选择' }}
<u-icon v-if="headerEditable" class="ml26" name="arrow-right" size="40" color="#888888"></u-icon> <u-icon v-if="headerEditable" class="ml26" name="arrow-right" size="40" color="#888888"></u-icon>
</view> </view>
</view> </view>
<view class="flex-white-plr26 ptb20 bdb_f5"> <view class="flex-white-plr26 ptb20 bdb_f5">
<text class="mr26">{{ dateLabel }}<text class="redXingh">*</text></text> <text class="mr26">{{ dateLabel }}<text class="redXingh">*</text></text>
<picker mode="date" :value="form.delivery_time" :disabled="!headerEditable" @change="bindDateChange"> <picker mode="date" :value="form.delivery_time" :disabled="!headerEditable" @change="bindDateChange">
<view>{{ form.delivery_time }}</view> <view>{{ form.delivery_time }}</view>
</picker> </picker>
</view> </view>
<view class="flex-white-plr26-column ptb20 mt32"> <view class="flex-white-plr26-column ptb20 mt32">
<view style="margin-bottom: 8rpx;"><text>单据备注</text></view> <view style="margin-bottom: 8rpx;"><text>单据备注</text></view>
<u-input v-model="form.remark" :disabled="!headerEditable" type="textarea" :border="true" :height="100" :auto-height="true" /> <u-input v-model="form.remark" :disabled="!headerEditable" type="textarea" :border="true" :height="100" :auto-height="true" />
</view>
</view> </view>
<view v-if="showScanSection">
<PlusBarcodePanel
<FabricOutDetailList ref="plusBarcodePanel"
:visible.sync="phoneScanPanelOpen"
:list="form.item_data" hint-text="连续扫码出仓,扫完可继续下一条"
:scan-time-space="1200"
@fabric-info="openFabricInfo" @success="onPlusBarcodeSuccess"
/>
@fine-code="openFineCode"
>
<FabricOutScanBar <FabricOutScanBar
slot="before-list"
:can-scan="canScan" :can-scan="canScan"
:value="QRBarCode" :value="QRBarCode"
:delete-mode="BarCodeDelStatus" :delete-mode="BarCodeDelStatus"
:message="BillDataMessage" :message="BillDataMessage"
disabled-tip="请先提交保存后再扫码" disabled-tip="请先提交保存后再扫码"
:show-phone-scan="usePhoneScanFallback" :scanning="phoneScanPanelOpen"
@input="QRBarCode = $event" @input="QRBarCode = $event"
@scan="handleScan" @scan="handleScan"
@phone-scan="handlePhoneScan" @phone-scan="handlePhoneScan"
@delete-mode-change="BarCodeDelChange" @delete-mode-change="BarCodeDelChange"
/> />
<FabricOutScanDetail <FabricOutScanDetail
slot="before-list"
:detail="scanDetail" :detail="scanDetail"
:group-keys="scanGroupKeys" :group-keys="scanGroupKeys"
@group-change="scanGroupKeys = $event" @group-change="scanGroupKeys = $event"
/> />
<FabricOutSummaryTable
</FabricOutDetailList> :rows="form.summary_rows"
@cell-click="onSummaryCellClick"
/>
</view>
<FabricOutFooter <FabricOutFooter
v-if="!headerSaved" v-if="!headerSaved"
:buttons="[{ label: '提交保存', action: 'save' }]" :buttons="[{ label: '提交保存', action: 'save' }]"
single single
@action="submitSave" @action="submitSave"
/> />
<FabricOutFooter <FabricOutFooter
v-else v-else
:buttons="statusActionButtons" :buttons="statusActionButtons"
@action="handleStatusAction" @action="handleStatusAction"
/> />
<search-select-popup <search-select-popup
:show.sync="selectShow" :show.sync="selectShow"
title="选择接收单位" title="选择接收单位"
@@ -128,88 +91,48 @@
:list="selectList" :list="selectList"
@confirm="selectConfirmFun" @confirm="selectConfirmFun"
/> />
<FabricInfoPopup :show.sync="fabricInfoShow" :data="currentFabricInfo" /> <FabricInfoPopup :show.sync="fabricInfoShow" :data="currentFabricInfo" />
<FineCodePopup :show.sync="fineCodeShow" :list="currentFineCodes" :readonly="false" @delete="onDeleteFineCode" /> <FineCodePopup :show.sync="fineCodeShow" :list="currentFineCodes" :readonly="false" @delete="onDeleteFineCode" />
</view> </view>
</template> </template>
<script> <script>
import formMixin from './storeFabricBusinessOutMixin.js'; import formMixin from './storeFabricBusinessOutMixin.js';
import FabricInfoPopup from '@/components/storefabric/FabricInfoPopup.vue'; import FabricInfoPopup from '@/components/storefabric/FabricInfoPopup.vue';
import FineCodePopup from '@/components/storefabric/FineCodePopup.vue'; import FineCodePopup from '@/components/storefabric/FineCodePopup.vue';
import OrderStatusBar from '@/components/storefabric/OrderStatusBar.vue'; import OrderStatusBar from '@/components/storefabric/OrderStatusBar.vue';
import FabricOutDetailList from '@/components/storefabric/FabricOutDetailList.vue';
import FabricOutScanBar from '@/components/storefabric/FabricOutScanBar.vue'; import FabricOutScanBar from '@/components/storefabric/FabricOutScanBar.vue';
import FabricOutScanDetail from '@/components/storefabric/FabricOutScanDetail.vue'; import FabricOutScanDetail from '@/components/storefabric/FabricOutScanDetail.vue';
import FabricOutSummaryTable from '@/components/storefabric/FabricOutSummaryTable.vue';
import FabricOutFooter from '@/components/storefabric/FabricOutFooter.vue'; import FabricOutFooter from '@/components/storefabric/FabricOutFooter.vue';
import SearchSelectPopup from '@/components/storefabric/SearchSelectPopup.vue'; import SearchSelectPopup from '@/components/storefabric/SearchSelectPopup.vue';
import PlusBarcodePanel from '@/components/common/PlusBarcodePanel.vue';
export default { export default {
components: { components: {
FabricInfoPopup, FabricInfoPopup,
FineCodePopup, FineCodePopup,
OrderStatusBar, OrderStatusBar,
FabricOutDetailList,
FabricOutScanBar, FabricOutScanBar,
FabricOutScanDetail, FabricOutScanDetail,
FabricOutSummaryTable,
FabricOutFooter, FabricOutFooter,
SearchSelectPopup, SearchSelectPopup,
PlusBarcodePanel,
}, },
mixins: [formMixin], mixins: [formMixin],
onLoad() { onLoad() {
uni.setNavigationBarTitle({ title: '新增坯布出仓单' }); uni.setNavigationBarTitle({ title: '新增坯布出仓单' });
this.pageMode = 'add'; this.pageMode = 'add';
this.loadBaseDropdowns(); this.loadBaseDropdowns();
}, },
}; };
</script> </script>
<style lang="scss"> <style lang="scss">
@import '@/pages/storefabric/storeFabricBusinessOutPage.scss'; @import '@/pages/storefabric/storeFabricBusinessOutPage.scss';
page { page {
background-color: #F8F8F8; background-color: #F8F8F8;
padding-bottom: 260rpx; padding-bottom: 260rpx;
} }
</style> </style>
@@ -1,7 +1,18 @@
<template> <template>
<view class="fabric-out-page"> <view class="fabric-out-page">
<OrderStatusBar class="fabric-out-mt32" :status="displayAuditStatus" :name="displayAuditStatusName" /> <view v-if="showHeaderToggle" class="fabric-out-headerBar" @click="toggleHeader">
<view class="fabric-out-headerBarMain">
<text class="fabric-out-headerBarTitle">单据信息</text>
<text v-if="form.order_no" class="fabric-out-headerBarSub">{{ form.order_no }}</text>
</view>
<view class="fabric-out-headerBarAction">
<text>{{ headerExpanded ? '收起' : '展开' }}</text>
<u-icon class="fabric-out-headerBarIcon" :name="headerExpanded ? 'arrow-up' : 'arrow-down'" size="32" color="#2979ff"></u-icon>
</view>
</view>
<view v-show="headerExpanded">
<OrderStatusBar class="fabric-out-mt32" :status="displayAuditStatus" :name="displayAuditStatusName" />
<view class="flex-white-plr26 ptb10 bdb_f5"> <view class="flex-white-plr26 ptb10 bdb_f5">
<text class="mr26">出仓单号</text> <text class="mr26">出仓单号</text>
<text>{{ form.order_no }}</text> <text>{{ form.order_no }}</text>
@@ -22,31 +33,37 @@
<text class="mr26">单据备注</text> <text class="mr26">单据备注</text>
<text>{{ form.remark || '-' }}</text> <text>{{ form.remark || '-' }}</text>
</view> </view>
</view>
<FabricOutDetailList <view v-if="showScanSection">
:list="form.item_data" <PlusBarcodePanel
@fabric-info="openFabricInfo" ref="plusBarcodePanel"
@fine-code="openFineCode" :visible.sync="phoneScanPanelOpen"
> hint-text="连续扫码出仓,扫完可继续下一条"
:scan-time-space="1200"
@success="onPlusBarcodeSuccess"
/>
<FabricOutScanBar <FabricOutScanBar
slot="before-list"
:can-scan="canScan" :can-scan="canScan"
:value="QRBarCode" :value="QRBarCode"
:delete-mode="BarCodeDelStatus" :delete-mode="BarCodeDelStatus"
:message="BillDataMessage" :message="BillDataMessage"
:show-phone-scan="usePhoneScanFallback" :scanning="phoneScanPanelOpen"
@input="QRBarCode = $event" @input="QRBarCode = $event"
@scan="handleScan" @scan="handleScan"
@phone-scan="handlePhoneScan" @phone-scan="handlePhoneScan"
@delete-mode-change="BarCodeDelChange" @delete-mode-change="BarCodeDelChange"
/> />
<FabricOutScanDetail <FabricOutScanDetail
slot="before-list"
:detail="scanDetail" :detail="scanDetail"
:group-keys="scanGroupKeys" :group-keys="scanGroupKeys"
@group-change="scanGroupKeys = $event" @group-change="scanGroupKeys = $event"
/> />
</FabricOutDetailList> <FabricOutSummaryTable
:rows="form.summary_rows"
@cell-click="onSummaryCellClick"
/>
</view>
<FabricOutFooter :buttons="statusActionButtons" @action="handleStatusAction" /> <FabricOutFooter :buttons="statusActionButtons" @action="handleStatusAction" />
@@ -67,27 +84,36 @@ import formMixin from './storeFabricBusinessOutMixin.js';
import FabricInfoPopup from '@/components/storefabric/FabricInfoPopup.vue'; import FabricInfoPopup from '@/components/storefabric/FabricInfoPopup.vue';
import FineCodePopup from '@/components/storefabric/FineCodePopup.vue'; import FineCodePopup from '@/components/storefabric/FineCodePopup.vue';
import OrderStatusBar from '@/components/storefabric/OrderStatusBar.vue'; import OrderStatusBar from '@/components/storefabric/OrderStatusBar.vue';
import FabricOutDetailList from '@/components/storefabric/FabricOutDetailList.vue';
import FabricOutScanBar from '@/components/storefabric/FabricOutScanBar.vue'; import FabricOutScanBar from '@/components/storefabric/FabricOutScanBar.vue';
import FabricOutScanDetail from '@/components/storefabric/FabricOutScanDetail.vue'; import FabricOutScanDetail from '@/components/storefabric/FabricOutScanDetail.vue';
import FabricOutSummaryTable from '@/components/storefabric/FabricOutSummaryTable.vue';
import FabricOutFooter from '@/components/storefabric/FabricOutFooter.vue'; import FabricOutFooter from '@/components/storefabric/FabricOutFooter.vue';
import SearchSelectPopup from '@/components/storefabric/SearchSelectPopup.vue'; import SearchSelectPopup from '@/components/storefabric/SearchSelectPopup.vue';
import PlusBarcodePanel from '@/components/common/PlusBarcodePanel.vue';
export default { export default {
components: { components: {
FabricInfoPopup, FabricInfoPopup,
FineCodePopup, FineCodePopup,
OrderStatusBar, OrderStatusBar,
FabricOutDetailList,
FabricOutScanBar, FabricOutScanBar,
FabricOutScanDetail, FabricOutScanDetail,
FabricOutSummaryTable,
FabricOutFooter, FabricOutFooter,
SearchSelectPopup, SearchSelectPopup,
PlusBarcodePanel,
}, },
mixins: [formMixin], mixins: [formMixin],
data() {
return {
pageMode: 'edit',
headerExpanded: false,
};
},
onLoad(e) { onLoad(e) {
uni.setNavigationBarTitle({ title: '编辑坯布出仓单' }); uni.setNavigationBarTitle({ title: '编辑坯布出仓单' });
this.pageMode = 'edit'; this.pageMode = 'edit';
this.headerExpanded = false;
if (e.id) { if (e.id) {
this.loadOrder(Number(e.id), { rejectIfLocked: true }); this.loadOrder(Number(e.id), { rejectIfLocked: true });
} }
@@ -4,9 +4,9 @@
* 业务说明: * 业务说明:
* 1. 后端当前仅提供「坯布其他出货单」一种类型的接口,故出仓类型固定为 other, * 1. 后端当前仅提供「坯布其他出货单」一种类型的接口,故出仓类型固定为 other,
* 表头保留接收单位(business_unit) / 出货日期 / 备注 等字段。 * 表头保留接收单位(business_unit) / 出货日期 / 备注 等字段。
* 2. 用户先填写表头并「提交保存」(addGfmOtherDeliveryOrder),拿到出仓单 id 后即可扫码; * 2. 用户先填写表头并「提交保存」(addGfmOtherDeliveryOrder),拿到出仓单 id 后才显示扫码区和汇总表;
* 扫码新增/删除细码走 updateGfmOtherDeliveryOrder;勾选锁定维度时附带 *_lock 字段,操作后用返回的最新详情刷新。 * 扫码新增/删除细码走 updateGfmOtherDeliveryOrder;勾选锁定维度时附带 *_lock 字段,操作后用返回的最新详情刷新。
* 3. 后端没有「修改表头」接口,保存成功或编辑进入后表头变为只读,仅可扫码维护细码。 * 3. 后端没有「修改表头」接口,保存成功或编辑进入后表头变为只读,并默认收起,仅可扫码维护细码。
*/ */
import util from '@/common/util'; import util from '@/common/util';
import scanMixin from '@/common/scanMixin.js'; import scanMixin from '@/common/scanMixin.js';
@@ -42,6 +42,8 @@ export default {
orderId: 0, orderId: 0,
form: this.getEmptyForm(), form: this.getEmptyForm(),
headerSaved: false, headerSaved: false,
// 新增未保存时展开表头;保存后及编辑进入时收起
headerExpanded: true,
selectShow: false, selectShow: false,
selectList: [], selectList: [],
selectType: '', selectType: '',
@@ -62,6 +64,7 @@ export default {
auditStatus: 0, auditStatus: 0,
businessUnitOptions: [], businessUnitOptions: [],
dropdownLoading: false, dropdownLoading: false,
phoneScanPanelOpen: false,
}; };
}, },
computed: { computed: {
@@ -75,6 +78,14 @@ export default {
headerEditable() { headerEditable() {
return this.pageMode === 'add' && !this.headerSaved; return this.pageMode === 'add' && !this.headerSaved;
}, },
/** 已保存或编辑页才提供收起/展开 */
showHeaderToggle() {
return this.pageMode === 'edit' || this.headerSaved;
},
/** 未保存只填表头;保存后才出现扫码区与汇总表 */
showScanSection() {
return this.headerSaved;
},
dateLabel() { dateLabel() {
return '出货日期'; return '出货日期';
}, },
@@ -102,15 +113,28 @@ export default {
}, },
onHide() { onHide() {
this.isPageActive = false; this.isPageActive = false;
this.closePhoneScanPanel();
this.unregisterScanBroadcast(); this.unregisterScanBroadcast();
}, },
onUnload() { onUnload() {
this.isPageActive = false; this.isPageActive = false;
this.closePhoneScanPanel();
this.unregisterScanBroadcast(); this.unregisterScanBroadcast();
}, },
methods: { methods: {
handlePhoneScan() { handlePhoneScan() {
this.openPhoneScan(); if (!this.canScan) {
this.showError('请先提交保存后再扫码');
return;
}
this.phoneScanPanelOpen = !this.phoneScanPanelOpen;
},
closePhoneScanPanel() {
this.phoneScanPanelOpen = false;
},
onPlusBarcodeSuccess(scanResult) {
this.QRBarCode = String(scanResult || '').trim().replace(/[\r\n]/g, '');
return this.handleScan();
}, },
registerOrderScanBroadcast() { registerOrderScanBroadcast() {
this.registerScanBroadcast((scanResult) => { this.registerScanBroadcast((scanResult) => {
@@ -122,6 +146,7 @@ export default {
const nextCanScan = this.isEditable && canScanAtStatus(status); const nextCanScan = this.isEditable && canScanAtStatus(status);
if (this.canScan && !nextCanScan) { if (this.canScan && !nextCanScan) {
this.unregisterScanBroadcast(); this.unregisterScanBroadcast();
this.closePhoneScanPanel();
} }
this.canScan = nextCanScan; this.canScan = nextCanScan;
}, },
@@ -151,8 +176,13 @@ export default {
delivery_time: this.$u.timeFormat(new Date(), 'yyyy-mm-dd'), delivery_time: this.$u.timeFormat(new Date(), 'yyyy-mm-dd'),
remark: '', remark: '',
item_data: [], item_data: [],
summary_rows: [],
}; };
}, },
toggleHeader() {
if (!this.showHeaderToggle) return;
this.headerExpanded = !this.headerExpanded;
},
loadOrder(id, options = {}) { loadOrder(id, options = {}) {
const { rejectIfLocked = false } = options; const { rejectIfLocked = false } = options;
return this.$u.api.gfmOtherDeliveryOrder.detail({ id }) return this.$u.api.gfmOtherDeliveryOrder.detail({ id })
@@ -242,6 +272,7 @@ export default {
const order = normalizeOrder(detail); const order = normalizeOrder(detail);
this.applyOrder(order); this.applyOrder(order);
this.headerSaved = true; this.headerSaved = true;
this.headerExpanded = false;
this.syncCanScanFromStatus(order.audit_status); this.syncCanScanFromStatus(order.audit_status);
this.showSuccess('保存成功,可以扫码', '提交成功'); this.showSuccess('保存成功,可以扫码', '提交成功');
this.registerOrderScanBroadcast(); this.registerOrderScanBroadcast();
@@ -298,14 +329,14 @@ export default {
if (!this.canScan || !this.orderId) { if (!this.canScan || !this.orderId) {
this.showError('请先提交保存后再扫码'); this.showError('请先提交保存后再扫码');
this.QRBarCode = ''; this.QRBarCode = '';
return; return Promise.resolve();
} }
if (!code) { if (!code) {
this.QRBarCode = ''; this.QRBarCode = '';
return; return Promise.resolve();
} }
const scanType = this.BarCodeDelStatus ? 2 : 1; const scanType = this.BarCodeDelStatus ? 2 : 1;
this.doScanUpdate(code, scanType); return this.doScanUpdate(code, scanType);
}, },
BarCodeDelChange(e) { BarCodeDelChange(e) {
this.BarCodeDelStatus = (e.detail.value || []).length > 0; this.BarCodeDelStatus = (e.detail.value || []).length > 0;
@@ -325,11 +356,13 @@ export default {
uni.hideLoading(); uni.hideLoading();
const order = normalizeOrder(detail); const order = normalizeOrder(detail);
this.form.item_data = order.item_data; this.form.item_data = order.item_data;
this.form.summary_rows = order.summary_rows || [];
this.auditStatus = order.audit_status; this.auditStatus = order.audit_status;
this.applyScanDetail(scanCode, order, scanType); this.applyScanDetail(scanCode, order, scanType);
if (refreshFineCodes) { if (refreshFineCodes) {
const row = order.item_data.find((i) => (i.group_key || String(i.id)) === this.currentGroupKey); const rows = order.summary_rows || [];
this.currentFineCodes = row ? [...row.fine_codes] : []; const row = rows.find((i) => i.group_key === this.currentGroupKey);
this.currentFineCodes = row ? [...(row.fine_codes || [])] : [];
} }
this.BillDataMessage = scanType === 2 ? '删除成功' : '扫码出仓成功'; this.BillDataMessage = scanType === 2 ? '删除成功' : '扫码出仓成功';
this.QRBarCode = ''; this.QRBarCode = '';
@@ -351,6 +384,15 @@ export default {
this.currentFineCodes = [...(row.fine_codes || [])]; this.currentFineCodes = [...(row.fine_codes || [])];
this.fineCodeShow = true; this.fineCodeShow = true;
}, },
onSummaryCellClick(event) {
const row = event && event.lineData;
if (!row) return;
if (event.key === 'grey_fabric_code' || event.key === 'grey_fabric_name') {
this.openFabricInfo(row);
return;
}
this.openFineCode(row);
},
onDeleteFineCode(fineCode) { onDeleteFineCode(fineCode) {
if (this.isReadonly || !this.canScan) return; if (this.isReadonly || !this.canScan) return;
const scanCode = getFineCodeScanCode(fineCode); const scanCode = getFineCodeScanCode(fineCode);
@@ -6,6 +6,47 @@
.fabric-out-mt32 { .fabric-out-mt32 {
margin-top: 32rpx; margin-top: 32rpx;
} }
.fabric-out-headerBar {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 100rpx;
padding: 16rpx 26rpx;
background: #fff;
border-bottom: 1rpx solid #f5f5f5;
box-sizing: border-box;
}
.fabric-out-headerBarMain {
display: flex;
align-items: center;
min-width: 0;
flex: 1;
}
.fabric-out-headerBarTitle {
font-size: 40rpx;
font-weight: bold;
color: #333;
flex-shrink: 0;
}
.fabric-out-headerBarSub {
margin-left: 16rpx;
font-size: 36rpx;
color: #666;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.fabric-out-headerBarAction {
display: flex;
align-items: center;
flex-shrink: 0;
margin-left: 16rpx;
font-size: 36rpx;
color: #2979ff;
}
.fabric-out-headerBarIcon {
margin-left: 8rpx;
}
.fabric-out-page .flex-white-plr26, .fabric-out-page .flex-white-plr26,
.fabric-out-page .flex-white-plr26-column, .fabric-out-page .flex-white-plr26-column,
.fabric-out-page .flex-white-plr26 text, .fabric-out-page .flex-white-plr26 text,
+206 -76
View File
@@ -9,17 +9,47 @@
</template> </template>
</common-navbar> </common-navbar>
<PlusBarcodePanel
ref="plusBarcodePanel"
:visible.sync="phoneScanPanelOpen"
hint-text="先扫描布票,再填写信息后确认进仓"
:scan-time-space="1200"
@success="onPlusBarcodeSuccess"
/>
<view class="manual-in__scan"> <view class="manual-in__scan">
<input <input
class="manual-in__scan-input" class="manual-in__scan-input"
type="text" type="text"
confirm-type="done" confirm-type="done"
:confirm-hold="true"
:focus="scanFocus" :focus="scanFocus"
v-model="scanCode" v-model="scanCode"
placeholder="请点击扫描/输入布票编码" placeholder="请先扫描布票编码"
placeholder-class="manual-in__placeholder" placeholder-class="manual-in__placeholder"
@confirm="onScanConfirm" @confirm="onScanConfirm"
/> />
<view
v-if="scanCode"
class="manual-in__scan-icon"
@click.stop="clearScanCode"
>
<u-icon name="close-circle-fill" size="44" color="#bfbfbf" />
</view>
<view
v-if="phoneScanPanelOpen"
class="manual-in__scan-close"
@click.stop="handlePhoneScan"
>
关闭扫码
</view>
<view
v-else
class="manual-in__scan-icon"
@click.stop="handlePhoneScan"
>
<u-icon name="scan" size="44" color="#595959" />
</view>
</view> </view>
<view class="manual-in__panel"> <view class="manual-in__panel">
@@ -43,6 +73,22 @@
<text class="manual-in__label">坯布编号</text> <text class="manual-in__label">坯布编号</text>
<text class="manual-in__value">{{ detail.grey_fabric_code || '-' }}</text> <text class="manual-in__value">{{ detail.grey_fabric_code || '-' }}</text>
</view> </view>
<view class="manual-in__row">
<text class="manual-in__label">卷号</text>
<text class="manual-in__value">{{ detail.volume_number != null && detail.volume_number !== '' ? detail.volume_number : '-' }}</text>
</view>
</view>
<view class="manual-in__panel manual-in__panel--form">
<view class="manual-in__row manual-in__row--input" @click="openInspectorPicker">
<text class="manual-in__label">查布工</text>
<view class="manual-in__right">
<text :class="detail.inspector_name ? 'manual-in__field-text' : 'manual-in__placeholder'">
{{ detail.inspector_name || '请选择查布工' }}
</text>
<text class="manual-in__action" @click.stop="clearInspector">取消</text>
</view>
</view>
<view class="manual-in__row manual-in__row--input"> <view class="manual-in__row manual-in__row--input">
<text class="manual-in__label">重量</text> <text class="manual-in__label">重量</text>
<view class="manual-in__right"> <view class="manual-in__right">
@@ -66,15 +112,6 @@
<text class="manual-in__action" @click.stop="clearLevel">取消</text> <text class="manual-in__action" @click.stop="clearLevel">取消</text>
</view> </view>
</view> </view>
<view class="manual-in__row manual-in__row--input" @click="openInspectorPicker">
<text class="manual-in__label">查布工</text>
<view class="manual-in__right">
<text :class="detail.inspector_name ? 'manual-in__field-text' : 'manual-in__placeholder'">
{{ detail.inspector_name || '请选择查布工' }}
</text>
<text class="manual-in__action" @click.stop="clearInspector">取消</text>
</view>
</view>
<view class="manual-in__row manual-in__row--input"> <view class="manual-in__row manual-in__row--input">
<text class="manual-in__label">存放仓位</text> <text class="manual-in__label">存放仓位</text>
<view class="manual-in__right"> <view class="manual-in__right">
@@ -88,20 +125,17 @@
<text class="manual-in__action" @click="editWarehouseBin">修改</text> <text class="manual-in__action" @click="editWarehouseBin">修改</text>
</view> </view>
</view> </view>
<view class="manual-in__row" v-if="detail.volume_number != null && detail.volume_number !== ''">
<text class="manual-in__label">卷号</text>
<text class="manual-in__value">{{ detail.volume_number }}</text>
</view>
</view> </view>
<view class="manual-in__footer"> <view class="manual-in__footer">
<u-button <u-button
type="primary" type="primary"
shape="circle"
:loading="submitting" :loading="submitting"
:disabled="submitting || loadingDetail" :disabled="submitting || loadingDetail"
@click="submitInWarehouse" @click="submitInWarehouse"
>确定进仓</u-button> >
确认进仓
</u-button>
</view> </view>
<SearchSelectPopup <SearchSelectPopup
@@ -109,6 +143,8 @@
title="选择等级" title="选择等级"
placeholder="请输入等级名称" placeholder="请输入等级名称"
:list="levelOptions" :list="levelOptions"
multiple
:selected="detail.grey_fabric_level_id"
@confirm="onLevelConfirm" @confirm="onLevelConfirm"
/> />
<SearchSelectPopup <SearchSelectPopup
@@ -124,6 +160,7 @@
<script> <script>
import CommonNavbar from '@/components/common-navbar/index'; import CommonNavbar from '@/components/common-navbar/index';
import SearchSelectPopup from '@/components/storefabric/SearchSelectPopup.vue'; import SearchSelectPopup from '@/components/storefabric/SearchSelectPopup.vue';
import PlusBarcodePanel from '@/components/common/PlusBarcodePanel.vue';
import scanMixin from '@/common/scanMixin.js'; import scanMixin from '@/common/scanMixin.js';
import util from '@/common/util.js'; import util from '@/common/util.js';
import { formatWeightKg } from '@/common/storeFabricBusinessOut.js'; import { formatWeightKg } from '@/common/storeFabricBusinessOut.js';
@@ -177,7 +214,7 @@ function normalizeLevelIds(value) {
} }
export default { export default {
components: { CommonNavbar, SearchSelectPopup }, components: { CommonNavbar, SearchSelectPopup, PlusBarcodePanel },
mixins: [scanMixin], mixins: [scanMixin],
data() { data() {
return { return {
@@ -195,11 +232,19 @@ export default {
inspectorPickerShow: false, inspectorPickerShow: false,
inspectorOptions: [], inspectorOptions: [],
inspectorOptionsLoaded: false, inspectorOptionsLoaded: false,
phoneScanPanelOpen: false,
}; };
}, },
computed: { computed: {
levelDisplayName() { levelDisplayName() {
return this.detail.grey_fabric_level_name || ''; if (this.detail.grey_fabric_level_name) return this.detail.grey_fabric_level_name;
const ids = normalizeLevelIds(this.detail.grey_fabric_level_id);
if (!ids.length) return '';
const nameMap = {};
this.levelOptions.forEach((item) => {
nameMap[String(item.value)] = item.label;
});
return ids.map((id) => nameMap[String(id)]).filter(Boolean).join('、');
}, },
}, },
onLoad() { onLoad() {
@@ -208,12 +253,32 @@ export default {
this.loadInspectorOptions(); this.loadInspectorOptions();
}, },
onShow() { onShow() {
this.scanFocus = false; this.isPageActive = true;
this.$nextTick(() => { this.refocusScanInput(50);
this.scanFocus = true; },
}); onHide() {
this.isPageActive = false;
this.closePhoneScanPanel();
},
onUnload() {
this.isPageActive = false;
this.closePhoneScanPanel();
clearTimeout(this._scanFocusTimer);
}, },
methods: { methods: {
refocusScanInput(delay = 120) {
clearTimeout(this._scanFocusTimer);
this.scanFocus = false;
this._scanFocusTimer = setTimeout(() => {
this.scanFocus = true;
}, delay);
},
closePhoneScanPanel() {
this.phoneScanPanelOpen = false;
},
onPlusBarcodeSuccess(scanResult) {
return this.handleScanCode(scanResult);
},
navToSetting() { navToSetting() {
uni.navigateTo({ url: '/pages/sys/user/scan-settings' }); uni.navigateTo({ url: '/pages/sys/user/scan-settings' });
}, },
@@ -272,10 +337,15 @@ export default {
} }
this.levelPickerShow = true; this.levelPickerShow = true;
}, },
onLevelConfirm(item) { onLevelConfirm(items) {
if (!item) return; const list = Array.isArray(items) ? items : (items ? [items] : []);
this.detail.grey_fabric_level_id = [Number(item.value)]; this.detail.grey_fabric_level_id = list
this.detail.grey_fabric_level_name = item.label || ''; .map((item) => Number(item.value))
.filter((item) => Number.isFinite(item));
this.detail.grey_fabric_level_name = list
.map((item) => item.label)
.filter(Boolean)
.join('、');
}, },
async loadInspectorOptions() { async loadInspectorOptions() {
try { try {
@@ -316,6 +386,13 @@ export default {
if (!code) return; if (!code) return;
this.fetchScanDetail(code); this.fetchScanDetail(code);
}, },
clearScanCode() {
this.scanCode = '';
this.refocusScanInput();
},
handlePhoneScan() {
this.phoneScanPanelOpen = !this.phoneScanPanelOpen;
},
onScanConfirm() { onScanConfirm() {
const code = String(this.scanCode || '').trim(); const code = String(this.scanCode || '').trim();
if (!code) { if (!code) {
@@ -324,8 +401,22 @@ export default {
} }
this.fetchScanDetail(code); this.fetchScanDetail(code);
}, },
validateBeforeSubmit() {
const fabricPieceCode = String(this.detail.fabric_piece_code || this.scanCode || '').trim();
if (!fabricPieceCode) {
return '请先扫描或输入布票编码';
}
const inspectorName = String(this.detail.inspector_name || '').trim();
if (!inspectorName && (this.detail.inspector_id == null || this.detail.inspector_id === '')) {
return '请选择查布工';
}
if (toWeightInt(this.weightKg) == null) {
return '请输入有效重量';
}
return '';
},
async fetchScanDetail(code) { async fetchScanDetail(code) {
if (this.loadingDetail) return; if (this.loadingDetail || this.submitting) return;
this.loadingDetail = true; this.loadingDetail = true;
this.scanCode = code; this.scanCode = code;
try { try {
@@ -335,18 +426,29 @@ export default {
this.applyScanDetail(res, code); this.applyScanDetail(res, code);
} catch (error) { } catch (error) {
console.log('扫码获取细码失败', error); console.log('扫码获取细码失败', error);
const kept = this.keepFormFields();
this.detail = { this.detail = {
...emptyDetail(), ...emptyDetail(),
fabric_piece_code: code, fabric_piece_code: code,
...kept,
}; };
this.weightKg = ''; this.scanCode = '';
this.refocusScanInput(200);
} finally { } finally {
this.loadingDetail = false; this.loadingDetail = false;
} }
}, },
keepFormFields() {
return {
grey_fabric_level_id: normalizeLevelIds(this.detail.grey_fabric_level_id),
grey_fabric_level_name: this.detail.grey_fabric_level_name || '',
inspector_id: this.detail.inspector_id,
inspector_name: this.detail.inspector_name || '',
};
},
applyScanDetail(res, fallbackCode) { applyScanDetail(res, fallbackCode) {
const data = res || {}; const data = res || {};
const levelIds = normalizeLevelIds(data.grey_fabric_level_id); const kept = this.keepFormFields();
this.detail = { this.detail = {
...emptyDetail(), ...emptyDetail(),
fabric_piece_code: data.fabric_piece_code || fallbackCode || '', fabric_piece_code: data.fabric_piece_code || fallbackCode || '',
@@ -354,32 +456,21 @@ export default {
machine_number: data.machine_number || '', machine_number: data.machine_number || '',
grey_fabric_name: data.grey_fabric_name || '', grey_fabric_name: data.grey_fabric_name || '',
grey_fabric_code: data.grey_fabric_code || '', grey_fabric_code: data.grey_fabric_code || '',
inspection_weight: formatDisplayWeightKg(data.inspection_weight) ? data.inspection_weight : null, inspection_weight: toWeightInt(this.weightKg),
grey_fabric_level_id: levelIds, volume_number: data.volume_number != null && data.volume_number !== '' ? data.volume_number : null,
grey_fabric_level_name: data.grey_fabric_level_name || '', ...kept,
inspector_id: data.inspector_id != null ? data.inspector_id : null,
inspector_name: data.inspector_name || '',
}; };
this.weightKg = formatDisplayWeightKg(data.inspection_weight);
this.scanCode = this.detail.fabric_piece_code; this.scanCode = this.detail.fabric_piece_code;
util.playSpeak('扫码成功');
}, },
async submitInWarehouse() { async submitInWarehouse() {
const err = this.validateBeforeSubmit();
if (err) {
this.$u.toast(err);
return;
}
const fabricPieceCode = String(this.detail.fabric_piece_code || this.scanCode || '').trim(); const fabricPieceCode = String(this.detail.fabric_piece_code || this.scanCode || '').trim();
if (!fabricPieceCode) {
this.$u.toast('请先扫描或输入布票编码');
return;
}
const actualWeight = toWeightInt(this.weightKg); const actualWeight = toWeightInt(this.weightKg);
if (actualWeight == null) {
this.$u.toast('请输入有效重量');
return;
}
const levelIds = normalizeLevelIds(this.detail.grey_fabric_level_id); const levelIds = normalizeLevelIds(this.detail.grey_fabric_level_id);
if (!levelIds.length) {
this.$u.toast('请选择等级');
return;
}
if (this.submitting) return; if (this.submitting) return;
this.submitting = true; this.submitting = true;
try { try {
@@ -387,8 +478,10 @@ export default {
fabric_piece_code: fabricPieceCode, fabric_piece_code: fabricPieceCode,
actual_weight: actualWeight, actual_weight: actualWeight,
electronic_scale_weight: actualWeight, electronic_scale_weight: actualWeight,
grey_fabric_level_id: levelIds,
}; };
if (levelIds.length) {
payload.grey_fabric_level_id = levelIds;
}
const inspectorName = String(this.detail.inspector_name || '').trim(); const inspectorName = String(this.detail.inspector_name || '').trim();
if (inspectorName) { if (inspectorName) {
payload.inspector_name = inspectorName; payload.inspector_name = inspectorName;
@@ -418,22 +511,21 @@ export default {
this.resetForNextScan(); this.resetForNextScan();
} catch (error) { } catch (error) {
console.log('手动进仓失败', error); console.log('手动进仓失败', error);
this.scanCode = '';
this.refocusScanInput(200);
} finally { } finally {
this.submitting = false; this.submitting = false;
} }
}, },
resetForNextScan() { resetForNextScan() {
const kept = this.keepFormFields();
this.scanCode = ''; this.scanCode = '';
this.detail = emptyDetail(); this.detail = {
this.weightKg = ''; ...emptyDetail(),
this.warehouseBinId = null; ...kept,
this.warehouseBinName = ''; };
this.$nextTick(() => { // toast 会抢焦点,稍后再聚焦,方便连续扫码
this.scanFocus = false; this.refocusScanInput(600);
this.$nextTick(() => {
this.scanFocus = true;
});
});
}, },
}, },
}; };
@@ -445,7 +537,7 @@ export default {
.manual-in { .manual-in {
min-height: 100vh; min-height: 100vh;
background: #f5f6f8; background: #f5f6f8;
padding-bottom: 180rpx; padding-bottom: calc(160rpx + env(safe-area-inset-bottom));
box-sizing: border-box; box-sizing: border-box;
} }
@@ -461,14 +553,46 @@ export default {
margin: 16rpx 0; margin: 16rpx 0;
padding: 0 28rpx; padding: 0 28rpx;
background: #fff; background: #fff;
display: flex;
align-items: center;
gap: 12rpx;
} }
.manual-in__scan-input { .manual-in__scan-input {
flex: 1;
min-width: 0;
height: $pda-scan-input-height; height: $pda-scan-input-height;
font-size: $pda-font-body; font-size: $pda-font-body;
color: #202328; color: #202328;
} }
.manual-in__scan-icon {
display: flex;
align-items: center;
justify-content: center;
width: 72rpx;
height: 72rpx;
flex-shrink: 0;
border-radius: 8rpx;
border: 1rpx solid #d9d9d9;
background: #f7f7f7;
}
.manual-in__scan-close {
display: flex;
align-items: center;
justify-content: center;
height: 72rpx;
padding: 0 16rpx;
flex-shrink: 0;
border-radius: 8rpx;
border: 1rpx solid #2979ff;
background: #eaf2ff;
color: #2979ff;
font-size: $pda-font-action;
white-space: nowrap;
}
.manual-in__placeholder { .manual-in__placeholder {
color: #b0b4bb; color: #b0b4bb;
font-size: $pda-font-placeholder; font-size: $pda-font-placeholder;
@@ -478,6 +602,27 @@ export default {
background: #fff; background: #fff;
} }
.manual-in__panel--form {
margin-top: 16rpx;
}
.manual-in__footer {
position: fixed;
left: 0;
right: 0;
bottom: 0;
padding: 20rpx 28rpx calc(20rpx + env(safe-area-inset-bottom));
background: #fff;
box-shadow: 0 -4rpx 16rpx rgba(0, 0, 0, 0.06);
box-sizing: border-box;
z-index: 20;
::v-deep .u-btn {
height: $pda-button-height !important;
font-size: $pda-font-button !important;
}
}
.manual-in__row { .manual-in__row {
display: flex; display: flex;
align-items: center; align-items: center;
@@ -527,6 +672,7 @@ export default {
text-align: right; text-align: right;
font-size: $pda-font-body; font-size: $pda-font-body;
color: #202328; color: #202328;
word-break: break-all;
} }
.manual-in__unit { .manual-in__unit {
@@ -542,20 +688,4 @@ export default {
color: #2f78e6; color: #2f78e6;
flex-shrink: 0; flex-shrink: 0;
} }
.manual-in__footer {
position: fixed;
left: 0;
right: 0;
bottom: 0;
padding: 24rpx 40rpx calc(24rpx + env(safe-area-inset-bottom));
background: #fff;
box-shadow: 0 -4rpx 16rpx rgba(0, 0, 0, 0.04);
}
::v-deep .manual-in__footer .u-btn {
height: $pda-button-height !important;
line-height: $pda-button-height !important;
font-size: $pda-font-button !important;
}
</style> </style>
+64 -21
View File
@@ -4,6 +4,7 @@
<view class="haotoplogo"> <view class="haotoplogo">
<image src="/static/haotop/image/logo/Start.jpg" mode="aspectFit" class="logoimg"></image> <image src="/static/haotop/image/logo/Start.jpg" mode="aspectFit" class="logoimg"></image>
</view> </view>
<view class="app-name">{{ appName }}</view>
<!-- <div v-if="loginType === 'currentPhone'">--> <!-- <div v-if="loginType === 'currentPhone'">-->
<!-- <u-tabs :list="list" :is-scroll="false" :current="current" @change="onClickItem"></u-tabs> --> <!-- <u-tabs :list="list" :is-scroll="false" :current="current" @change="onClickItem"></u-tabs> -->
<!-- <view v-if="current === 0"> --> <!-- <view v-if="current === 0"> -->
@@ -103,8 +104,9 @@
<!-- </view>--> <!-- </view>-->
<!-- </view>--> <!-- </view>-->
<!-- </div>--> <!-- </div>-->
<u-picker class="login-env-picker" v-model="showApiUrlPicker" mode="selector" :range="apiUrlList" range-key="label" <u-select class="login-env-picker" v-model="showApiUrlPicker" :list="apiUrlList" :default-value="apiUrlDefaultIndex"
@confirm="onApiUrlConfirm" @cancel="showApiUrlPicker = false"></u-picker> title="选择服务器" :show-search="false" :item-height="88" :visible-item-count="5"
@confirm="onApiUrlConfirm" @cancel="showApiUrlPicker = false"></u-select>
<!-- 版本信息显示 --> <!-- 版本信息显示 -->
<view class="version-info"> <view class="version-info">
<text class="version-text">版本: {{ appVersion }}</text> <text class="version-text">版本: {{ appVersion }}</text>
@@ -116,13 +118,23 @@
/** /**
* Copyright (c) 2013-Now http://aidex.vip All rights reserved. * Copyright (c) 2013-Now http://aidex.vip All rights reserved.
*/ */
import config, { getTestApiUrl } from '@/common/config.js'; import config, { getDefaultApiUrl, resolveUpgradeDownloadUrl } from '@/common/config.js';
import base64 from '@/common/base64.js'; import base64 from '@/common/base64.js';
import util from '@/common/util.js'; import util from '@/common/util.js';
import md5 from '@/common/md5.js'; import md5 from '@/common/md5.js';
import manifest from '@/manifest.json'; import manifest from '@/manifest.json';
import { mapState } from 'vuex' import { mapState } from 'vuex'
import app_upgrade from '@/uni_modules/app-upgrade/js_sdk/index.js' import app_upgrade from '@/uni_modules/app-upgrade/js_sdk/index.js'
import { ensureScanConfigAfterLogin } from '@/common/scanAutoConfig.js'
function isDefaultPassword(data) {
if (!data || typeof data !== 'object') return false;
const value = data.is_default_password != null
? data.is_default_password
: (data.user && data.user.is_default_password);
return value === true || value === 1 || value === '1' || value === 'true';
}
export default { export default {
data() { data() {
return { return {
@@ -134,7 +146,7 @@ export default {
password: "" password: ""
}, },
showApiUrlPicker: false, showApiUrlPicker: false,
selectedApiUrl: getTestApiUrl(), selectedApiUrl: getDefaultApiUrl(),
customApiUrl: 'http://192.168.1.66:50002/hcscm_weave/pda/v1', customApiUrl: 'http://192.168.1.66:50002/hcscm_weave/pda/v1',
apiUrlList: config.devApiUrlOptions, apiUrlList: config.devApiUrlOptions,
phoneNo: '', phoneNo: '',
@@ -156,18 +168,27 @@ export default {
}; };
}, },
computed: { computed: {
appName() {
return manifest.name || '';
},
appVersion() { appVersion() {
return manifest.versionName; return manifest.versionName;
}, },
envName() { envName() {
return process.env.VUE_APP_ENV_NAME || ''; return process.env.VUE_APP_ENV_NAME || '';
},
apiUrlDefaultIndex() {
const list = this.apiUrlList || [];
let index = list.findIndex(item => item.value === this.selectedApiUrl);
if (index < 0) index = list.findIndex(item => item.label === '正式环境');
return [index >= 0 ? index : 0];
} }
}, },
onShow() { onShow() {
const testUrl = getTestApiUrl(); const defaultUrl = getDefaultApiUrl();
util.updateApiUrl(testUrl); util.updateApiUrl(defaultUrl);
this.selectedApiUrl = testUrl; this.selectedApiUrl = defaultUrl;
uni.getStorage({ uni.getStorage({
key: 'UserInfo', key: 'UserInfo',
@@ -208,9 +229,8 @@ export default {
}, },
onApiUrlConfirm(e) { onApiUrlConfirm(e) {
console.log('e', JSON.stringify(e)); const selectedValue = e && e[0] && e[0].value;
const selectedValue = this.apiUrlList[e[0]].value; if (selectedValue == null) return;
console.log('selectedValue', selectedValue)
this.selectedApiUrl = selectedValue; this.selectedApiUrl = selectedValue;
this.showApiUrlPicker = false; this.showApiUrlPicker = false;
@@ -315,7 +335,7 @@ export default {
this.$u.api.pdaLogin({ this.$u.api.pdaLogin({
'phone': this.login.username, 'phone': this.login.username,
'password': this.login.password, 'password': this.login.password,
}).then((res) => { }).then(async (res) => {
console.log('login res', res) console.log('login res', res)
var aLoginUserData = res; var aLoginUserData = res;
@@ -346,9 +366,17 @@ export default {
getApp().globalData.StoreNameID = aLoginUserData.default_physical_warehouse_id; getApp().globalData.StoreNameID = aLoginUserData.default_physical_warehouse_id;
getApp().globalData.StoreName = aLoginUserData.default_physical_warehouse_name; getApp().globalData.StoreName = aLoginUserData.default_physical_warehouse_name;
getApp().globalData.StoreTypeNo = ''; getApp().globalData.StoreTypeNo = '';
try {
await ensureScanConfigAfterLogin(this.$u.api);
} catch (scanError) {
console.log('自动匹配扫码设置失败', scanError);
}
const workbenchUrl = isDefaultPassword(aLoginUserData)
? '/pages/sys/workbench/index?defaultPassword=1'
: '/pages/sys/workbench/index';
setTimeout(() => { setTimeout(() => {
uni.reLaunch({ uni.reLaunch({
url: '/pages/sys/workbench/index' url: workbenchUrl
}); });
}, 500); }, 500);
@@ -421,10 +449,18 @@ export default {
return { status: 0 }; return { status: 0 };
} }
// 用户已取消过该版本:登录页自动检查不再弹框
const dismissedVersion = uni.getStorageSync('appUpdateDismissedVersion');
if (dismissedVersion && String(dismissedVersion) === String(res.latest_version)) {
console.log('用户已取消该版本更新,跳过自动弹框:', dismissedVersion);
return { status: 0 };
}
return { return {
changelog: res.message + ',最新版本:' + res.latest_version, changelog: res.message + ',最新版本:' + res.latest_version,
status: res.need_update ? 1 : 0, // 0 无新版本 | 1 有新版本 status: res.need_update ? 1 : 0, // 0 无新版本 | 1 有新版本
path: res.download_url // 新apk地址 path: resolveUpgradeDownloadUrl(res.download_url), // 新apk地址
latest_version: res.latest_version
}; };
} catch (error) { } catch (error) {
console.log('检查版本更新失败:', error); console.log('检查版本更新失败:', error);
@@ -484,7 +520,16 @@ export default {
height: 150rpx; height: 150rpx;
// max-width: 5%; // max-width: 5%;
// max-height: 5%; // max-height: 5%;
margin: 10rpx auto 10rpx auto; margin: 10rpx auto 0 auto;
}
.app-name {
margin: 8rpx 0 24rpx;
color: #242820;
font-size: 40rpx;
font-weight: 700;
line-height: 1.3;
text-align: center;
} }
.logoimg { .logoimg {
@@ -585,21 +630,19 @@ export default {
</style> </style>
<style lang="scss" scoped> <style lang="scss" scoped>
.login-env-picker { .login-env-picker {
::v-deep .u-picker-header, ::v-deep .u-select__header,
::v-deep .u-btn-picker { ::v-deep .u-select__header__btn {
height: 100rpx; height: 100rpx;
font-size: 36rpx; font-size: 36rpx;
} }
::v-deep .u-picker-body { ::v-deep .u-select__header__title {
height: 560rpx; font-size: 36rpx;
} }
::v-deep .u-column-item, ::v-deep .u-select__body__picker-view__item,
::v-deep .u-line-1 { ::v-deep .u-line-1 {
height: 88rpx;
font-size: 40rpx; font-size: 40rpx;
line-height: 88rpx;
} }
} }
</style> </style>
+33 -3
View File
@@ -41,7 +41,7 @@
<u-gap height="20" bg-color="#f5f5f5"></u-gap> <u-gap height="20" bg-color="#f5f5f5"></u-gap>
<u-cell-item icon="question-circle" :iconStyle="{ color: '#ff8d06' }" title="常见问题" @click="navTo('problem')"></u-cell-item> <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="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="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="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="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="account" :iconStyle="{ color: '#27c0dc' }" title="关于我们" @click="navTo('about')"></u-cell-item>
@@ -52,12 +52,17 @@
</u-cell-group> </u-cell-group>
</view> </view>
</view> </view>
<view class="app-meta">
<text class="app-name">{{ appName }}</text>
<text class="app-version">版本 {{ appVersion }}</text>
</view>
</view> </view>
</template> </template>
<script> <script>
import CommonNavbar from "@/components/common-navbar/index"; import CommonNavbar from "@/components/common-navbar/index";
import app_upgrade from '@/uni_modules/app-upgrade/js_sdk/index.js'; import app_upgrade from '@/uni_modules/app-upgrade/js_sdk/index.js';
import config from '@/common/config.js'; import config, { resolveUpgradeDownloadUrl } from '@/common/config.js';
import manifest from '@/manifest.json';
/** /**
* Copyright (c) 2013-Now http://aidex.vip All rights reserved. * Copyright (c) 2013-Now http://aidex.vip All rights reserved.
*/ */
@@ -76,6 +81,12 @@ export default {
}, },
computed: { computed: {
appName() {
return manifest.name || '';
},
appVersion() {
return manifest.versionName || '';
},
avatarUrl() { avatarUrl() {
// let url = this.vuex_user.avatarUrl || '/ctxPath/static/images/user1.jpg'; // let url = this.vuex_user.avatarUrl || '/ctxPath/static/images/user1.jpg';
// url = url.replace('/ctxPath/', this.vuex_config.baseUrl + '/'); // url = url.replace('/ctxPath/', this.vuex_config.baseUrl + '/');
@@ -122,7 +133,8 @@ export default {
return { return {
changelog: res.message + ',最新版本:' + res.latest_version, changelog: res.message + ',最新版本:' + res.latest_version,
status: res.need_update ? 1 : 0, status: res.need_update ? 1 : 0,
path: res.download_url path: resolveUpgradeDownloadUrl(res.download_url),
latest_version: res.latest_version
}; };
}, 1); }, 1);
// #endif // #endif
@@ -152,4 +164,22 @@ page {
height:50rpx; height:50rpx;
} }
} }
.app-meta {
padding: 48rpx 30rpx 40rpx;
text-align: center;
}
.app-name {
display: block;
color: #242820;
font-size: 36rpx;
font-weight: 700;
line-height: 1.4;
}
.app-version {
display: block;
margin-top: 8rpx;
color: #8a8f86;
font-size: 32rpx;
line-height: 1.3;
}
</style> </style>
+10 -11
View File
@@ -68,31 +68,30 @@ export default {
methods: { methods: {
submit() { submit() {
this.$refs.uForm.validate(valid => { this.$refs.uForm.validate(valid => {
if (valid) { if (!valid) {
this.$u.toast('您填写的信息有误,请根据提示修正。');
return;
}
this.$u.api.user.infoSavePwd({ this.$u.api.user.infoSavePwd({
oldPassword: this.model.oldPassword, oldPassword: this.model.oldPassword,
newPassword: this.model.newPassword newPassword: this.model.newPassword
}).then(res => { }).then(() => {
if(res.code == '200'){
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: res.msg, content: '密码修改成功',
showCancel: false, showCancel: false,
success: function () { success: () => {
uni.navigateBack(); uni.navigateBack();
} }
}); });
}else{ }).catch((err) => {
const message = (err && (err.message || err.msg)) || '修改密码失败';
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: res.msg, content: message,
showCancel: false showCancel: false
}); });
}
}); });
} else {
this.$u.toast('您填写的信息有误,请根据提示修正。');
}
}); });
}, },
cancel() { cancel() {
+11 -12
View File
@@ -33,7 +33,7 @@ export default {
model: { model: {
oldPassword: '', oldPassword: '',
newPassword: '', newPassword: '',
confirmNewPassword: '' confirmPassword: ''
}, },
rules: { rules: {
oldPassword: [ oldPassword: [
@@ -78,31 +78,30 @@ export default {
methods: { methods: {
submit() { submit() {
this.$refs.uForm.validate(valid => { this.$refs.uForm.validate(valid => {
if (valid) { if (!valid) {
this.$u.toast('您填写的信息有误,请根据提示修正。');
return;
}
this.$u.api.user.infoSavePwd({ this.$u.api.user.infoSavePwd({
oldPassword: this.model.oldPassword, oldPassword: this.model.oldPassword,
newPassword: this.model.newPassword newPassword: this.model.newPassword
}).then(res => { }).then(() => {
if(res.code == '200'){
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: res.msg, content: '密码修改成功',
showCancel: false, showCancel: false,
success: function () { success: () => {
uni.navigateBack(); uni.navigateBack();
} }
}); });
}else{ }).catch((err) => {
const message = (err && (err.message || err.msg)) || '修改密码失败';
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: res.msg, content: message,
showCancel: false showCancel: false
}); });
}
}); });
} else {
this.$u.toast('您填写的信息有误,请根据提示修正。');
}
}); });
}, },
cancel() { cancel() {
+10 -1
View File
@@ -42,6 +42,7 @@ import {
mapDictionaryToScannerConfig, mapDictionaryToScannerConfig,
PHONE_SCAN_BRAND, PHONE_SCAN_BRAND,
saveScanConfig, saveScanConfig,
autoConfigureScanSettings,
} from '@/common/scanConfig.js'; } from '@/common/scanConfig.js';
export default { export default {
@@ -100,6 +101,7 @@ export default {
this.ensurePhoneScanOption(); this.ensurePhoneScanOption();
this.ensureSeuicOption(); this.ensureSeuicOption();
this.ensureNlscanOption(); this.ensureNlscanOption();
this.ensureNlscanCompatOption();
this.initFormFromSaved(); this.initFormFromSaved();
}, },
useFallbackConfigList() { useFallbackConfigList() {
@@ -136,8 +138,15 @@ export default {
ensureNlscanOption() { ensureNlscanOption() {
this.ensureBuiltinScannerOption('nlscan'); this.ensureBuiltinScannerOption('nlscan');
}, },
ensureNlscanCompatOption() {
this.ensureBuiltinScannerOption('nlscan_compat');
},
initFormFromSaved() { initFormFromSaved() {
const savedConfig = getScanConfig(this.getScannerConfigs()); // N5S 曾被误识别为东集时,进入设置页会纠正并写回
const rematch = autoConfigureScanSettings({
remoteConfigs: this.remoteScannerConfigs || [],
});
const savedConfig = (rematch && rematch.config) || getScanConfig(this.getScannerConfigs());
if (savedConfig) { if (savedConfig) {
this.applyConfig(savedConfig); this.applyConfig(savedConfig);
return; return;
+18 -1
View File
@@ -76,9 +76,12 @@ export default {
}; };
}, },
onLoad() { onLoad(options) {
const sys = uni.getSystemInfoSync(); const sys = uni.getSystemInfoSync();
this.statusBarHeight = sys.statusBarHeight || 20; this.statusBarHeight = sys.statusBarHeight || 20;
if (options && String(options.defaultPassword) === '1') {
this.promptChangePassword();
}
// #ifdef APP-PLUS // #ifdef APP-PLUS
plus.runtime.getProperty(plus.runtime.appid, (inf) => { plus.runtime.getProperty(plus.runtime.appid, (inf) => {
if (inf && inf.version) { if (inf && inf.version) {
@@ -90,6 +93,20 @@ export default {
}, },
methods: { methods: {
promptChangePassword() {
setTimeout(() => {
uni.showModal({
title: '提示',
content: '当前使用的是默认密码,请修改密码',
confirmText: '去修改',
cancelText: '稍后',
success: (res) => {
if (!res.confirm) return;
uni.navigateTo({ url: '/pages/sys/user/pwd' });
},
});
}, 400);
},
handleScanCode(scanResult) { handleScanCode(scanResult) {
const cleanResult = scanResult.trim().replace(/[\r\n]/g, ''); const cleanResult = scanResult.trim().replace(/[\r\n]/g, '');
uni.navigateTo({ uni.navigateTo({
Binary file not shown.
Binary file not shown.
+6 -6
View File
@@ -1,7 +1,7 @@
/** /**
* Copyright (c) 2013-Now http://aidex.vip All rights reserved. * Copyright (c) 2013-Now http://aidex.vip All rights reserved.
*/ */
import config, { getTestApiUrl } from '@/common/config.js'; import config, { getDefaultApiUrl } from '@/common/config.js';
import util from '@/common/util.js'; import util from '@/common/util.js';
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
@@ -19,15 +19,15 @@ try{
} }
// 初始化API URL // 初始化API URL(默认正式环境)
function initApiUrl() { function initApiUrl() {
const testUrl = getTestApiUrl(); const defaultUrl = getDefaultApiUrl();
try { try {
uni.setStorageSync('ApiUrl', testUrl); uni.setStorageSync('ApiUrl', defaultUrl);
} catch (e) { } catch (e) {
console.log('写入测试环境地址失败', e); console.log('写入正式环境地址失败', e);
} }
return testUrl; return defaultUrl;
} }
// 需要永久存储,且下次APP启动需要取出的,在state中的变量名 // 需要永久存储,且下次APP启动需要取出的,在state中的变量名
+8 -3
View File
@@ -37,11 +37,12 @@ class AppDialog {
} }
// 显示 // 显示
show(apkUrl, changelog) { show(apkUrl, changelog, latestVersion = '') {
this.drawView(changelog) this.drawView(changelog)
this.maskEl.show() this.maskEl.show()
this.popupEl.show() this.popupEl.show()
this.apkUrl = apkUrl; this.apkUrl = apkUrl;
this.latestVersion = latestVersion || '';
} }
// 隐藏 // 隐藏
@@ -309,8 +310,12 @@ class AppDialog {
const buttonWidth = (this.viewWidth - this.viewPadding) / 2; const buttonWidth = (this.viewWidth - this.viewPadding) / 2;
if (e.clientY > maxTop - 40 && e.clientY < maxTop) { if (e.clientY > maxTop - 40 && e.clientY < maxTop) {
if (showCancel) { if (showCancel) {
// 取消 // 取消:记住已跳过的版本,登录页自动检查不再弹出
// if(e.clientX>this.viewPadding && e.clientX<maxLeft-buttonWidth-this.viewPadding){} if (e.clientX > this.viewPadding && e.clientX < this.viewPadding + buttonWidth) {
if (this.latestVersion) {
uni.setStorageSync('appUpdateDismissedVersion', String(this.latestVersion));
}
}
// 确定 // 确定
if (e.clientX > maxLeft - buttonWidth && e.clientX < maxLeft) { if (e.clientX > maxLeft - buttonWidth && e.clientX < maxLeft) {
upgrade.checkOs(this.apkUrl) upgrade.checkOs(this.apkUrl)
+2 -1
View File
@@ -40,7 +40,8 @@ class CheckUpate{
if(res.status===1){ if(res.status===1){
const path=res.path || ''; const path=res.path || '';
const changeLog=res.changelog || ''; const changeLog=res.changelog || '';
appDialog.show(path,changeLog); const latestVersion=res.latest_version || '';
appDialog.show(path,changeLog,latestVersion);
} }
}) })
this.storageTimeStamp() this.storageTimeStamp()
+1
View File
@@ -14,6 +14,7 @@ module.exports = {
'process.env': { 'process.env': {
...definitions[0]['process.env'], ...definitions[0]['process.env'],
VUE_APP_UPGRADE_NAME: JSON.stringify(process.env.VUE_APP_UPGRADE_NAME), VUE_APP_UPGRADE_NAME: JSON.stringify(process.env.VUE_APP_UPGRADE_NAME),
VUE_APP_UPGRADE_CDN_PREFIX: JSON.stringify(process.env.VUE_APP_UPGRADE_CDN_PREFIX),
VUE_APP_PRODUCTION_API_URL: JSON.stringify(process.env.VUE_APP_PRODUCTION_API_URL), VUE_APP_PRODUCTION_API_URL: JSON.stringify(process.env.VUE_APP_PRODUCTION_API_URL),
VUE_APP_DEV_API_URL: JSON.stringify(process.env.VUE_APP_DEV_API_URL), VUE_APP_DEV_API_URL: JSON.stringify(process.env.VUE_APP_DEV_API_URL),
VUE_APP_ENV_NAME: JSON.stringify(process.env.VUE_APP_ENV_NAME), VUE_APP_ENV_NAME: JSON.stringify(process.env.VUE_APP_ENV_NAME),