Commit 77896584 authored by lanbaoming's avatar lanbaoming

2024-04-08

parents
Pipeline #4 failed with stages
VUE_APP_BASE_URL=https://api.jd.jdshangmen.com/
\ No newline at end of file
VUE_APP_BASE_URL=https://api.jd.jdshangmen.com/
\ No newline at end of file
.DS_Store
node_modules/
unpackage/
dist/
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.project
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw*
/pnpm-lock.yaml
/package-lock.json
{
// launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
// launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数
"version" : "0.0",
"configurations" : [
{
"app-plus" : {
"launchtype" : "remote"
},
"default" : {
"launchtype" : "remote"
},
"type" : "uniCloud"
},
{
"playground" : "standard",
"type" : "uni-app:app-android"
},
{
"playground" : "custom",
"type" : "uni-app:app-ios"
}
]
}
shamefully-hoist=true
捷道-客户端-仓管PDA
本地运行:npm run dev:h5
测试环境:npm run build:h5:test
生产环境:npm run build
PDA 安卓打包签名证书说明
test.keystore
包名:com.jd.app.pda
别名:pda_prod
密码:123456
!!!! 打包前需检查:名称,图标,接口域名,包名,版本号
pda测试包名:com.jd.app.pda.test
pda生产包名:com.jd.app.pda
客户端测试包名:com.jiedaotest.app
客户端生产包名:com.jiedao.app
\ No newline at end of file
const plugins = []
if (process.env.UNI_OPT_TREESHAKINGNG) {
plugins.push(require('@dcloudio/vue-cli-plugin-uni-optimize/packages/babel-plugin-uni-api/index.js'))
}
if (
(
process.env.UNI_PLATFORM === 'app-plus' &&
process.env.UNI_USING_V8
) ||
(
process.env.UNI_PLATFORM === 'h5' &&
process.env.UNI_H5_BROWSER === 'builtin'
)
) {
const path = require('path')
const isWin = /^win/.test(process.platform)
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
const input = normalizePath(process.env.UNI_INPUT_DIR)
try {
plugins.push([
require('@dcloudio/vue-cli-plugin-hbuilderx/packages/babel-plugin-console'),
{
file (file) {
file = normalizePath(file)
if (file.indexOf(input) === 0) {
return path.relative(input, file)
}
return false
}
}
])
} catch (e) {}
}
process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui']
process.UNI_LIBRARIES.forEach(libraryName => {
plugins.push([
'import',
{
'libraryName': libraryName,
'customName': (name) => {
return `${libraryName}/lib/${name}/${name}`
}
}
])
})
module.exports = {
presets: [
[
'@vue/app',
{
modules: 'commonjs',
useBuiltIns: process.env.UNI_PLATFORM === 'h5' ? 'usage' : 'entry'
}
]
],
plugins
}
const fs = require('fs');
const root = "./src"
let allFiles = []
const savePath = "./src/i18n/languages/en_US.json"
const crypto = require('crypto');
const https = require('https');
const querystring = require('querystring');
// 你的百度翻译API的App ID和密钥
const appId = "20230911001813245"
const appKey = "lJlOnktUO0pn8G_MZ10O"
const translateText = (text, fromLang = 'zh', toLang = 'en') => {
return new Promise((resolve, reject) => {
// 百度翻译API的接口地址
const apiUrl = "https://fanyi-api.baidu.com/api/trans/vip/translate";
// 构建请求参数
const params = {
q: text,
from: fromLang,
to: toLang,
appid: appId,
salt: Math.random().toString().slice(2),
sign: ''
};
// 生成签名
const signStr = appId + text + params.salt + appKey;
params.sign = require('crypto').createHash('md5').update(signStr).digest('hex');
// 发送HTTP POST请求
const options = {
hostname: 'fanyi-api.baidu.com',
port: 443,
path: '/api/trans/vip/translate',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': querystring.stringify(params).length
}
};
const req = https.request(options, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
console.log('翻译结果:', data);
resolve(JSON.parse(data).trans_result[0].dst)
});
});
req.on('error', (err) => {
console.error(err);
});
req.write(querystring.stringify(params));
req.end();
})
};
function getFiles(dir){
let files = fs.readdirSync(dir)
files.forEach(file => {
let path = dir + '/' + file
if(fs.lstatSync(path).isDirectory()){
getFiles(path)
}else allFiles.push(path)
})
}
getFiles(root)
let messages = new Set()
allFiles.forEach(file => {
let data = fs.readFileSync(file, {encoding: 'utf-8'})
let matched = data.matchAll(/\$t\([\'\"]{1}([^\"\']+)[\'\"]{1}/g)
let i = 0
for(let item of matched){
i ++
messages.add(item[1])
}
})
let obj = require(savePath)
Array.from(messages).forEach(word => {
if(!obj[word])obj[word] = ""
})
let autoTransCnt = 0
async function translate(obj){
// 对未翻译内容调用百度翻译进行翻译操作,有变量的不做处理
for(let text in obj){
if(obj[text] || text.includes('{'))continue
const textEn = await translateText(text)
console.log(`${text} => ${textEn}\n`)
obj[text] = textEn
autoTransCnt ++
// 账号请求频率限制1ps
await new Promise(resolve => setTimeout(resolve, 1000))
}
}
translate(obj).then(res => {
fs.writeFileSync(savePath, JSON.stringify(obj, null, 4))
console.log(messages)
console.warn(`本次共提取 ${messages.size} 个待翻译内容,保存于${savePath}`)
console.log(`已调用百度api自动翻译 ${autoTransCnt} 个内容\n`)
console.log("done!")
})
{
"name": "jiedao-app-pda",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "npm run dev:h5",
"build": "npm run build:h5",
"build:app-plus": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build",
"build:app-plus-test": "cross-env NODE_ENV=development UNI_PLATFORM=app-plus vue-cli-service uni-build",
"build:custom": "cross-env NODE_ENV=production uniapp-cli custom",
"build:h5": "cross-env NODE_ENV=production UNI_PLATFORM=h5 vue-cli-service uni-build",
"build:h5:test": "cross-env NODE_ENV=development UNI_PLATFORM=h5 vue-cli-service uni-build",
"build:mp-360": "cross-env NODE_ENV=production UNI_PLATFORM=mp-360 vue-cli-service uni-build",
"build:mp-alipay": "cross-env NODE_ENV=production UNI_PLATFORM=mp-alipay vue-cli-service uni-build",
"build:mp-baidu": "cross-env NODE_ENV=production UNI_PLATFORM=mp-baidu vue-cli-service uni-build",
"build:mp-jd": "cross-env NODE_ENV=production UNI_PLATFORM=mp-jd vue-cli-service uni-build",
"build:mp-kuaishou": "cross-env NODE_ENV=production UNI_PLATFORM=mp-kuaishou vue-cli-service uni-build",
"build:mp-lark": "cross-env NODE_ENV=production UNI_PLATFORM=mp-lark vue-cli-service uni-build",
"build:mp-qq": "cross-env NODE_ENV=production UNI_PLATFORM=mp-qq vue-cli-service uni-build",
"build:mp-toutiao": "cross-env NODE_ENV=production UNI_PLATFORM=mp-toutiao vue-cli-service uni-build",
"build:mp-weixin": "cross-env NODE_ENV=production UNI_PLATFORM=mp-weixin vue-cli-service uni-build",
"build:mp-xhs": "cross-env NODE_ENV=production UNI_PLATFORM=mp-xhs vue-cli-service uni-build",
"build:quickapp-native": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-native vue-cli-service uni-build",
"build:quickapp-webview": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview vue-cli-service uni-build",
"build:quickapp-webview-huawei": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview-huawei vue-cli-service uni-build",
"build:quickapp-webview-union": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview-union vue-cli-service uni-build",
"dev:app-plus": "cross-env NODE_ENV=development UNI_PLATFORM=app-plus vue-cli-service uni-build --watch",
"dev:custom": "cross-env NODE_ENV=development uniapp-cli custom",
"dev:h5": "cross-env NODE_ENV=development UNI_PLATFORM=h5 vue-cli-service uni-serve",
"dev:mp-360": "cross-env NODE_ENV=development UNI_PLATFORM=mp-360 vue-cli-service uni-build --watch",
"dev:mp-alipay": "cross-env NODE_ENV=development UNI_PLATFORM=mp-alipay vue-cli-service uni-build --watch",
"dev:mp-baidu": "cross-env NODE_ENV=development UNI_PLATFORM=mp-baidu vue-cli-service uni-build --watch",
"dev:mp-jd": "cross-env NODE_ENV=development UNI_PLATFORM=mp-jd vue-cli-service uni-build --watch",
"dev:mp-kuaishou": "cross-env NODE_ENV=development UNI_PLATFORM=mp-kuaishou vue-cli-service uni-build --watch",
"dev:mp-lark": "cross-env NODE_ENV=development UNI_PLATFORM=mp-lark vue-cli-service uni-build --watch",
"dev:mp-qq": "cross-env NODE_ENV=development UNI_PLATFORM=mp-qq vue-cli-service uni-build --watch",
"dev:mp-toutiao": "cross-env NODE_ENV=development UNI_PLATFORM=mp-toutiao vue-cli-service uni-build --watch",
"dev:mp-weixin": "cross-env NODE_ENV=development UNI_PLATFORM=mp-weixin vue-cli-service uni-build --watch",
"dev:mp-xhs": "cross-env NODE_ENV=development UNI_PLATFORM=mp-xhs vue-cli-service uni-build --watch",
"dev:quickapp-native": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-native vue-cli-service uni-build --watch",
"dev:quickapp-webview": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview 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",
"info": "node node_modules/@dcloudio/vue-cli-plugin-uni/commands/info.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:h5": "cross-env UNI_PLATFORM=h5 jest -i",
"test:ios": "cross-env UNI_PLATFORM=app-plus UNI_OS_NAME=ios jest -i",
"test:mp-baidu": "cross-env UNI_PLATFORM=mp-baidu jest -i",
"test:mp-weixin": "cross-env UNI_PLATFORM=mp-weixin jest -i"
},
"dependencies": {
"@dcloudio/uni-app": "2.0.2-3090620231104001",
"@dcloudio/uni-app-plus": "2.0.2-3090620231104001",
"@dcloudio/uni-h5": "2.0.2-3090620231104001",
"@dcloudio/uni-helper-json": "*",
"@dcloudio/uni-i18n": "2.0.2-3090620231104001",
"@dcloudio/uni-mp-360": "2.0.2-3090620231104001",
"@dcloudio/uni-mp-alipay": "2.0.2-3090620231104001",
"@dcloudio/uni-mp-baidu": "2.0.2-3090620231104001",
"@dcloudio/uni-mp-jd": "2.0.2-3090620231104001",
"@dcloudio/uni-mp-kuaishou": "2.0.2-3090620231104001",
"@dcloudio/uni-mp-lark": "2.0.2-3090620231104001",
"@dcloudio/uni-mp-qq": "2.0.2-3090620231104001",
"@dcloudio/uni-mp-toutiao": "2.0.2-3090620231104001",
"@dcloudio/uni-mp-vue": "2.0.2-3090620231104001",
"@dcloudio/uni-mp-weixin": "2.0.2-3090620231104001",
"@dcloudio/uni-mp-xhs": "2.0.2-3090620231104001",
"@dcloudio/uni-quickapp-native": "2.0.2-3090620231104001",
"@dcloudio/uni-quickapp-webview": "2.0.2-3090620231104001",
"@dcloudio/uni-stacktracey": "2.0.2-3090620231104001",
"@dcloudio/uni-stat": "2.0.2-3090620231104001",
"@dcloudio/uni-ui": "^1.4.22",
"@vue/shared": "3.3.8",
"core-js": "^3.25.5",
"crypto-js": "^4.0.0",
"dayjs": "^1.11.5",
"decimal.js": "^10.4.3",
"flyio": "0.6.14",
"lodash": "^4.17.21",
"lrz": "^4.9.40",
"prettier": "^1.19.1",
"regenerator-runtime": "^0.12.1",
"uni-simple-router": "^1.5.2",
"vconsole": "^3.14.7",
"vue": "^2.6.12",
"vuex": "3.6.2"
},
"devDependencies": {
"@babel/runtime": "~7.12.0",
"@dcloudio/types": "^3.0.15",
"@dcloudio/uni-automator": "2.0.2-3090620231104001",
"@dcloudio/uni-cli-i18n": "2.0.2-3090620231104001",
"@dcloudio/uni-cli-shared": "2.0.2-3090620231104001",
"@dcloudio/uni-migration": "2.0.2-3090620231104001",
"@dcloudio/uni-template-compiler": "2.0.2-3090620231104001",
"@dcloudio/vue-cli-plugin-hbuilderx": "2.0.2-3090620231104001",
"@dcloudio/vue-cli-plugin-uni": "2.0.2-3090620231104001",
"@dcloudio/vue-cli-plugin-uni-optimize": "2.0.2-3090620231104001",
"@dcloudio/webpack-uni-mp-loader": "2.0.2-3090620231104001",
"@dcloudio/webpack-uni-pages-loader": "2.0.2-3090620231104001",
"@vue/cli": "^4.5.17",
"@vue/cli-plugin-babel": "~4.5.17",
"@vue/cli-service": "~4.5.17",
"babel-plugin-import": "1.13.8",
"cross-env": "7.0.3",
"html-webpack-plugin": "^5.6.0",
"jest": "25.5.4",
"mini-types": "*",
"miniprogram-api-typings": "^3.6.0",
"postcss-comment": "^2.0.0",
"sass": "1.32.13",
"sass-loader": "10.1.1",
"vue-template-compiler": "^2.7.13"
},
"browserslist": [
"Android >= 4.4",
"ios >= 9"
],
"uni-app": {
"scripts": {}
}
}
const path = require('path')
module.exports = {
parser: require('postcss-comment'),
plugins: [
require('postcss-import')({
resolve (id, basedir, importOptions) {
if (id.startsWith('~@/')) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3))
} else if (id.startsWith('@/')) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2))
} else if (id.startsWith('/') && !id.startsWith('//')) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1))
}
return id
}
}),
require('autoprefixer')({
remove: process.env.UNI_PLATFORM !== 'h5'
}),
require('@dcloudio/vue-cli-plugin-uni/packages/postcss')
]
}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>
<%= htmlWebpackPlugin.options.title %>
</title>
<script>
document.addEventListener('DOMContentLoaded', function() {
document.documentElement.style.fontSize = document.documentElement.clientWidth / 20 + 'px'
})
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<link rel="stylesheet" href="<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css" />
</head>
<body>
<noscript>
<strong>Please enable JavaScript to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
\ No newline at end of file
<script>
// const VConsole = require('./static/js/vconsole.min.js');
import store from 'store/store';
import * as types from 'store/mutations-types'
export default {
onLaunch() {
//#ifdef APP-PLUS
uni.setStorageSync('isShowVersion', 1)
plus.runtime.getProperty( plus.runtime.appid, function ( wgtinfo ) {
// 获取 app的version
let appversion = wgtinfo.version;
let versionCode = wgtinfo.versionCode
// 存缓存 版本号
try {
uni.setStorageSync('appversion', appversion);
uni.setStorageSync('versionCode', versionCode);
} catch (e) {}
console.log( "appversion:" + appversion );
} );
//#endif
},
onShow() {
// console.log('app show');
//检查登录
// if (!store.getters.userToken()) {
// store.dispatch(types.SHOW_ALERT, {
// msg: '用户已登出,请重新登陆',
// onHide: () => {
// uni.reLaunch({
// url: '/pages/login/login'
// });
// }
// })
// }
},
onHide() {},
mounted() {
// const vconsole = new VConsole();
}
};
</script>
<style lang="scss">
/* 引入color-ui样式库 */
@import 'colorui/main.css';
@import 'colorui/icon.css';
@import './style/style.scss';
/* 解决头条小程序组件内引入字体不生效的问题 */
/* #ifdef MP-TOUTIAO */
@font-face {
font-family: uniicons;
src: url('./static/uni.ttf');
}
/* #endif */
uni-checkbox .uni-checkbox-input.uni-checkbox-input-checked{
background-color:#007aff !important;
}
</style>
import http from '../util/http'
import upload from '../util/uniAppUpload.js'
import store from '../store/store'
import * as types from '../store/mutations-types'
import {
defaultPageSize
} from '../util/config'
/**
* 登录接口
* @param mobile 手机号码
* @param password 手机号码
* @returns {Promise}
*/
export const login = (username, password, sign='') => {
return http('/system/pda-login', {
username,
password,
sign
}, {
method: 'post',
loading: true
}, 'login').then((data) => {
store.commit(types.SET_USER_TOKEN, data.token)
// getUserInfo(data.token)
// return data
})
}
/**
* 注册并登录接口
* @param code 短信验证码
* @param mobile 手机号码
* @param password 密码
* @returns {Promise}
*/
export const signUp = (code, mobile, password) => {
return http('/app-api/member/reg', {
code,
mobile,
password
}, {
method: 'post',
loading: true
}).then((data) => {
store.commit(types.SET_USER_TOKEN, data.token)
// getUserInfo(data.token)
// return data
})
}
/**
* 发送手机验证码
* @param mobile 手机号码
* @param scene 发送场景(0注册1登录2修改密码3忘记密码),示例值(1)
* @returns {Promise}
*/
export const sendSmsCode = (mobile, scene) => {
return http('/app-api/member/send-sms-code', {
mobile,
scene
}, {
method: 'post',
loading: true
})
}
/**
* 获取用户资料
* @returns {Promise}
*/
export const getUserInfo = (userToken) => {
userToken = userToken || store.getters.userToken()
return http('/member/getMember', {
token: userToken
}, {
method: 'post'
}).then((data) => {
let userInfo = {
id: data.id, //id
username: data.username, //用户名
name: data.name_zh, //名称
number: data.number, //工号
mobile: data.phone, //手机
originId: data.originId,
destinationId: data.destinationId,
}
store.commit(types.SET_USER_INFO, userInfo)
})
}
/**
* 未入仓订单
*/
export const getWarehousingOrder = (page, keyword, originId = [], destinationId = []) => {
return http('/order/getWarehousingOrder', {
page: page,
keyword: keyword,
originId: originId,
destinationId: destinationId,
}, {
method: 'post',
})
}
/**
* 订单商品
*/
export const getOrderGoods = (id) => {
return http('/order/getOrderGoods', {
id: id,
}, {
method: 'post',
// loading: true
})
}
/**
* 订单入仓商品
*/
export const getOrderWarehouseGoods = (id) => {
return http('/order/getOrderWarehouseGoods', {
id: id,
}, {
method: 'post',
// loading: true
})
}
/**
* 查询品牌&备案
*/
export const getBrand = (name) => {
return http('/brand/getBrand', {
name: name
}, {
method: 'post',
loading: true
})
}
/**
* 查询商品表
*/
export const getGoods = (name, type) => {
return http('/goods/getGoods', {
name: name,
type: type
}, {
method: 'post',
loading: true
})
}
/**
* 商品入仓(添加or修改)
*/
export const editWarehouseGoods = (orderId, goodsId, warehouse, warehouseId = null,remarks = '',add_type) => {
return http('/warehousing/editWarehousing', {
orderId: orderId,
goodsId: goodsId,
warehouse: warehouse,
warehouseId: warehouseId,
remarks:remarks,
add_type:add_type?1:0
}, {
method: 'post',
loading: true
})
}
/**
* 新商品入仓
*/
export const addNewWarehouseGoods = (orderId, orderGoods, warehouse,remarks = '',add_type) => {
return http('/warehousing/addNewGoodsWarehousing', {
token: store.getters.userToken(),
orderId: orderId,
orderGoods: orderGoods,
warehouse: warehouse,
remarks:remarks,
add_type:add_type?1:0
}, {
method: 'post',
loading: true
})
}
/**
* 删除入仓商品
*/
export const delWarehouseGoods = (id) => {
return http('/warehousing/delWarehousing', {
id: id,
}, {
method: 'post',
loading: true
})
}
/**
* 完成入仓
*/
export const orderWarehousing = (orderId,is_handler,handler_type,handler_desc,money,image_url,label,locationId,wareId,areaId) => {
let formData={
token: store.getters.userToken(),
id: orderId,
money:money,
label:label,
locationId:locationId,
wareId:wareId,
areaId:areaId
};
if(is_handler){
formData.is_handler = 1;
formData.handler_type = handler_type;
formData.handler_desc = handler_desc;
formData.image_url = image_url;
}
return http('/order/orderWarehousing',formData, {
method: 'post',
loading: true,
// edit by knight 20210819 设置请求头
headers: {'Content-Type':'application/json'},
keepObject:true
})
}
/**
* 获取目的地
*/
export const getEndWarehouseFromStartId = (startId) => {
return http('/warehouse/getEndWarehouseFromStartId', {
startId: startId,
}, {
method: 'post',
})
}
// 获得仓库列表
export function getWarehouseList(params) {
return http('/ecw/warehouse/list', params, {
method: 'GET',
});
}
export function getCounty(params) {
return http('/ecw/region/getListTree', params, {
method: 'GET'
})
}
/*************************** 装柜 *********************************/
/**
* 包装类型
*/
export const getPackageTypeList = () => {
return http('/order/packageTypeList', {
}, {
method: 'post',
})
}
/**
* 转异-原因
*/
export const getHandlerType = () => {
return http('/warehousing/handler_type', {
}, {
method: 'post',
})
}
/**
* 上传图片
*/
export const updateImg = (file) => {
return upload('/upload/thumb', file , {
token: store.getters.userToken(),
}, {
method: 'post',
loading: true
}).then((data) => {
return data;
})
}
/**
* 文件删除
*/
export const deleteImg = (path) => {
return http('/upload/delete', {
path:path,
token: store.getters.userToken()
}, {
method: 'post',
loading: true,
errorHandle: false,
})
}
/**
* 获取审批人
*/
export const getApproval = () => {
return http('/member/approval', {
}, {
method: 'post',
})
}
/**
* 获取材质
*/
export const getMaterialLlist = () => {
return http('/Goods/getMaterialLlist', {
}, {
method: 'post',
})
}
/**
* 订单调仓接口
*/
export const transferWarehouses = (arrival_date,transfer_order) => {
return http('/order/transferWarehouses', {
token: store.getters.userToken(),
arrival_date: arrival_date,
transfer_order:transfer_order
}, {
method: 'post',
})
}
/**
* 仓位接口
*/
export const getLocationSelect = (orderId) => {
return http('/order/getLocationSelect', {
token: store.getters.userToken(),
orderId:orderId
}, {
method: 'post',
})
}
/**
* 订单仓位修改
*/
export const editAOrderLocation = (orderId,wareId,areaId,locationId) => {
return http('/Warehousing/editAOrderLocation', {
token: store.getters.userToken(),
orderId:orderId,
locationId:locationId,
wareId:wareId,
areaId:areaId,
}, {
method: 'post',
})
}
/**
* 入仓单的打印接口
*/
export const getInboundData = (orderId,goodsId) => {
return http('/Warehousing/getInboundData', {
token: store.getters.userToken(),
orderId:orderId,
goodsId:goodsId
}, {
method: 'post',
loading: true,
errorHandle: false,
})
}
/**
* 打印机配置接口
*/
export const getPrinterConf = (orderId) => {
return http('/Printer/getPrinterConf', {
// token: store.getters.userToken(),
// orderId:orderId
}, {
method: 'post'
})
}
/**
* 入仓时间
*/
export const getPrintSelectTime = (orderId,goodsId) => {
return http('/Warehousing/getPrintSelectTime', {
token: store.getters.userToken(),
orderId:orderId,
goodsId:goodsId
}, {
method: 'post',
loading: true,
errorHandle: false,
})
}
/**
* 发货人证件查询
*/
export const certificateSearch = (key) => {
return http('/ecw/order/certificateSearch', {
key
}, {
method: 'get',
loading: true,
errorHandle: false,
})
}
/**
* 获得出货分页
*/
export const shipmentBoxPage = (params) => {
return http(`/shipment/box/page`, params, {
method: 'GET',
});
}
\ No newline at end of file
import store from '../store/store'
import * as types from '../store/mutations-types.js'
let flag = true
export default (error, reject) => {
if (error.code != undefined && error.code != 0) {
switch (error.code + '') {
//9001 错误:用户token 过期
case '401':
store.commit(types.SET_USER_TOKEN, null)
console.log(flag, '-------flag-----------');
if (flag) {
uni.redirectTo({
url: '/pages/login/login'
})
// store.dispatch(types.SHOW_ALERT, {
// msg: '用户已登出,请重新登陆',
// onHide: () => {
// uni.redirectTo({
// url: '/pages/login/login'
// })
// flag = true
// }
// })
}
break;
// order/getWarehousingOrder {"code":301,"errorMsg":"该订单属于义乌仓货物,请核实订单信息。"}
case '301':
store.dispatch(types.SHOW_ALERT, {
msg: error.msg||'错误',
onHide: () => {
}
})
break
default:
store.dispatch(types.SHOW_TOAST, {
msg: error.msg
})
}
} else {
//默认弹窗展示出错信息
store.dispatch(types.SHOW_TOAST, {
msg: '网络异常'
})
}
reject()
}
export default {
locale: uni.getStorageSync('locale') ? uni.getStorageSync('locale') : 'zh-Hans',
setLang(msg) {
this.locale = msg
uni.setLocale(msg)
}
}
import http from '../util/http'
import store from '../store/store'
import * as types from '../store/mutations-types'
import upload from '../util/uniAppUpload.js'
// 上传
export const updateImg = (file) => {
return upload('app-api/file/upload', file , {
Authorization: 'Bearer ' + store.getters.userToken()
}, {
method: 'post',
loading: true
}).then((data) => {
return data;
})
}
// 字典数据查询
export const listSimpleDictDatas = (params) => {
return http('/system/dict-data/list-all-simple', params, {
method: 'GET',
})
}
// 获得所有产品属性
export const getProductAttrList = (params) => {
return http('/ecw/product-attr/list', params, {
method: 'GET',
})
}
// 获得所有产品属性
export const getUserProfile = () => {
return http('/system/user/profile/get', {}, {
method: 'GET',
}).then(data => {
store.commit(types.SET_USER_INFO, data)
})
}
// 获得所有产品属性
export const getUserPermission = () => {
return http('/system/get-permission-info', {}, {
method: 'GET',
})
}
export const getVesionData = (params) => {
return http('/system/version/latestVersion', params, {
method: 'GET',
})
}
/*
Animation 微动画
基于ColorUI组建库的动画模块 by 文晓港 2019年3月26日19:52:28
*/
/* css 滤镜 控制黑白底色gif的 */
.gif-black{
mix-blend-mode: screen;
}
.gif-white{
mix-blend-mode: multiply;
}
/* Animation css */
[class*=animation-] {
animation-duration: .5s;
animation-timing-function: ease-out;
animation-fill-mode: both
}
.animation-fade {
animation-name: fade;
animation-duration: .8s;
animation-timing-function: linear
}
.animation-scale-up {
animation-name: scale-up
}
.animation-scale-down {
animation-name: scale-down
}
.animation-slide-top {
animation-name: slide-top
}
.animation-slide-bottom {
animation-name: slide-bottom
}
.animation-slide-left {
animation-name: slide-left
}
.animation-slide-right {
animation-name: slide-right
}
.animation-shake {
animation-name: shake
}
.animation-reverse {
animation-direction: reverse
}
@keyframes fade {
0% {
opacity: 0
}
100% {
opacity: 1
}
}
@keyframes scale-up {
0% {
opacity: 0;
transform: scale(.2)
}
100% {
opacity: 1;
transform: scale(1)
}
}
@keyframes scale-down {
0% {
opacity: 0;
transform: scale(1.8)
}
100% {
opacity: 1;
transform: scale(1)
}
}
@keyframes slide-top {
0% {
opacity: 0;
transform: translateY(-100%)
}
100% {
opacity: 1;
transform: translateY(0)
}
}
@keyframes slide-bottom {
0% {
opacity: 0;
transform: translateY(100%)
}
100% {
opacity: 1;
transform: translateY(0)
}
}
@keyframes shake {
0%,
100% {
transform: translateX(0)
}
10% {
transform: translateX(-9px)
}
20% {
transform: translateX(8px)
}
30% {
transform: translateX(-7px)
}
40% {
transform: translateX(6px)
}
50% {
transform: translateX(-5px)
}
60% {
transform: translateX(4px)
}
70% {
transform: translateX(-3px)
}
80% {
transform: translateX(2px)
}
90% {
transform: translateX(-1px)
}
}
@keyframes slide-left {
0% {
opacity: 0;
transform: translateX(-100%)
}
100% {
opacity: 1;
transform: translateX(0)
}
}
@keyframes slide-right {
0% {
opacity: 0;
transform: translateX(100%)
}
100% {
opacity: 1;
transform: translateX(0)
}
}
\ No newline at end of file
<template>
<view>
<view class="cu-custom" :style="[{height:CustomBar + 'px'}]">
<view class="cu-bar fixed" :style="style" :class="[bgImage!=''?'none-bg text-white bg-img':'',bgColor]">
<view class="action" @tap="BackPage" v-if="isBack">
<text class="cuIcon-back"></text>
<slot name="backText"></slot>
</view>
<view class="content" :style="[{top:StatusBar + 'px'}]">
<slot name="content"></slot>
</view>
<slot name="right"></slot>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
StatusBar: this.StatusBar,
CustomBar: this.CustomBar
};
},
name: 'cu-custom',
computed: {
style() {
var StatusBar= this.StatusBar;
var CustomBar= this.CustomBar;
var bgImage = this.bgImage;
var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
if (this.bgImage) {
style = `${style}background-image:url(${bgImage});`;
}
return style
}
},
props: {
bgColor: {
type: String,
default: ''
},
isBack: {
type: [Boolean, String],
default: false
},
bgImage: {
type: String,
default: ''
},
},
methods: {
BackPage() {
uni.navigateBack({
delta: 1
});
}
}
}
</script>
<style>
</style>
This diff is collapsed.
This diff is collapsed.
<template>
<text>
<template v-for="(dict, index) in getDictDatas2(type, value)">
<!-- 默认样式 -->
<text v-if="dict.colorType === 'default' || dict.colorType === '' || dict.colorType === undefined" :key="dict.value" :index="index"
:class="dict.cssClass" :style="color">{{ $l(dict, 'label') }}</text>
</template>
</text>
</template>
<script>
import {getDictDatas2} from "@/util/dict";
export default {
name: "DictTag",
methods: {getDictDatas2},
props: {
type: String,
value: [Number, String, Boolean, Array],
color: {
type: String,
default: ''
}
},
data() {
return {
// 不要用$lang来判断语言,因为他不是响应式的,有时候会异常
// locale:this.$lang.locale
};
}
};
</script>
<style scoped>
.el-tag + .el-tag {
margin-left: 10px;
}
</style>
This diff is collapsed.
<template>
<view class="img-wrap">
<uni-grid :column="4" :highlight="true" :show-border="false">
<uni-grid-item v-for="(item, index) in list" :key="index" :index="index">
<view class="grid-item-box" style="height: 100%;position: relative;">
<image :src="iconpath" mode="widthFix"
style="position: absolute;top:4px;right:4px;width:24px;height:24px;z-index:9" @tap="delimage(index)"></image>
<image v-if="item.type === 'image'" :src="item.url" mode="scaleToFill" style="height: 100%"
@tap="previewImage(item.url)"/>
<video v-else-if="item.type === 'video'" :id="`video_${index}`" :src="item.url"
style="width: 100%;height: 100%" @fullscreenchange="fullscreenchange" @play="playVideo(index)"
@tap="playVideo(index)"></video>
</view>
</uni-grid-item>
<uni-grid-item>
<view class="grid-item-box" style="height: 100%">
<view class="grid-item-box-add" @tap="chooseVideoImage">
<uni-icons color="#eae8eb" size="30" type="plusempty"></uni-icons>
<!-- <text>添加视频或图片</text> -->
</view>
</view>
</uni-grid-item>
</uni-grid>
<view style="font-size: 12px;color: #999999">
请上传 大小不超过 <text style="color: #ff3333;">50MB</text><br>
格式为<text style="color: #ff3333;">png/jpg/jpeg/mp4/m4v</text>的文件
</view>
</view>
</template>
<script>
import iconpath from "@/static/images/close.png";
import {updateImg} from "@/api/system";
import {warehousePictureCreate} from "@/pages/loading/api";
export default {
props: {
value: {
type: Array,
default: () => {
return []
}
},
bizId: {
type: Number,
default: undefined
},
type: {
type: Number,
default: undefined
}
},
data() {
return {
iconpath,
list: []
}
},
mounted() {
this.list = this.value
},
methods: {
warehousePictureCreate(url){
if (this.bizId && this.type) {
return warehousePictureCreate({
bizId: this.bizId,
type: this.type,
url
})
}
},
delimage(index){
this.$emit('delete', this.list[index].url)
this.list.splice(index,1)
},
fullscreenchange(event) {
// if (uni.getSystemInfoSync().platform == "ios") { return }
if (!event.detail.fullScreen) {
// this.videoContext.pause()
}
},
playVideo(index) {
setTimeout(() => {
this.videoContext = uni.createVideoContext(`video_${index}`)
// this.videoContext.play()
// this.videoContext.requestFullScreen()
}, 500)
},
chooseVideoImage() {
uni.showActionSheet({
title: this.$t('选择上传类型'),
itemList: [this.$t('图片'), this.$t('视频')],
success: res => {
if (res.tapIndex == 0) {
this.chooseImages(true);
} else {
this.chooseVideo();
}
}
});
},
previewImage(url) {
//uniapp预览轮播图
uni.previewImage({
current: 0, //预览图片的下标
urls: [url] //预览图片的地址,必须要数组形式,如果不是数组形式就转换成数组形式就可以
})
},
chooseImages(flag) {
uni.chooseImage({
count: 9, //默认是9张
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], //从相册选择
success: res => {
// let imgFile = res.tempFilePaths;
res.tempFilePaths.forEach((item, index) => {
updateImg(item).then(data => {
this.warehousePictureCreate(data.data)
if (flag) {
this.list.push({ type: 'image', url: data.data })
} else {
// this.exceptionList.push({ url: data.data })
this.$set(this.exceptionList, this.exceptionList.length, { url: data.data })
}
})
})
}
})
},
//上传视频
chooseVideo(index) {
uni.chooseVideo({
maxDuration: 60, //拍摄视频最长拍摄时间,单位秒。最长支持 60 秒
count: 9,
// camera: this.cameraList[this.cameraIndex].value, //'front'、'back',默认'back'
// sourceType: sourceType[this.sourceTypeIndex],
success: res => {
let videoFile = res.tempFilePath;
// res.tempFilePaths.forEach((item, index) => {
updateImg(videoFile).then(data => {
this.list.push({ type: 'video', url: data.data })
})
// })
},
fail:(error)=>{
uni.hideLoading();
uni.showToast({
title: error,
icon: 'none'
})
}
})
},
}
}
</script>
<style lang="scss" scoped>
.img-wrap {
::v-deep .uni-grid-item {
background: #fbf8fb;
}
.grid-item-box-add {
height: 100%;
display: flex;
flex-flow: column;
font-size: 10px;
padding: 16px 0;
text-align: center;
justify-content: center;
}
}
</style>
<template>
<view class="lee-datetime-main">
<picker mode="multiSelector" :disabled="disabled" @change="bindChange" @columnchange="bindColumnchange"
:value="indexPic" :range="originData" range-key="text" :field="field">
<view class="lee-datetime-text">{{datetimeStr}}</view>
</picker>
</view>
</template>
<script>
export default {
name: "lee-datetime", // 时间选择器 年月日时分秒
props: {
// 传入时间值 , 注意时间格式必须为YYYY-MM-DD hh:mm-ss 或者 YYYY-MM-DD
// 传入时间值 , 注意时间格式必须为YYYY-MM-DD hh:mm-ss 或者 YYYY-MM-DD
// 传入时间值 , 注意时间格式必须为YYYY-MM-DD hh:mm-ss 或者 YYYY-MM-DD
value: {
type: String,
default: ""
},
// 是否禁用
disabled: {
type: Boolean,
default: false
},
placeholder: {
type: String,
default: "请选择日期"
},
field: {
type: String,
default: '',
}
},
watch: {
value(newVal, oldVal) {
this.setPropValue(newVal)
}
},
data() {
return {
originData: [
[],
[],
[],
[],
[],
[]
],
indexPic: [0, 0, 0, 0, 0, 0],
datetimeStr: "",
}
},
mounted() {
console.log("进入时间组件-mounted", this.value)
this.datetimeStr = this.value && this.value != "" ? this.value : this.placeholder
this.initData()
},
methods: {
bindChange(event) {
// 组件返回值
let returnV = {
text: "",
value: ""
}
let returnVIndex = event.target.value
let yyyy = this.originData[0][returnVIndex[0]]
let mmmm = this.originData[1][returnVIndex[1]]
let dddd = this.originData[2][returnVIndex[2]]
let hh = this.originData[3][returnVIndex[3]]
let mm = this.originData[4][returnVIndex[4]]
let ss = this.originData[5][returnVIndex[5]]
// 参数重组
returnV.text = yyyy.text + mmmm.text + dddd.text + " " + hh.text + mm.text + ss.text
returnV.value = yyyy.value + "-" + mmmm.value + "-" + dddd.value + " " + hh.value + ":" + mm.value + ":" +
ss.value
returnV.field = this.field
// 组件返回时间与参数值
this.$emit("change", returnV)
},
bindColumnchange(event) {
console.log('修改的列为', event.detail.column, ',值为', event.detail.value, this.indexPic, this.originData);
this.indexPic[event.detail.column] = event.detail.value // 记录变动列下标值
if (event.detail.column === 1) {
let dd = this.getDateNum(this.originData[0][this.indexPic[0]].value, this.originData[event.detail
.column][event.detail
.value
].value)
let ddArr = []
// 更新选中月天数日期
for (let i = 1; i <= dd; i++) {
ddArr.push({
value: i < 10 ? '0' + i : i,
text: i < 10 ? '0' + i + "" : i + ""
})
}
this.originData[event.detail.column + 1] = ddArr // 更新选中月的天数日期
// this.indexPic[event.detail.column + 1] = 0 // 更新选中月的天数日期下标
this.originData = [...this.originData]
}
},
// 更新prop传入值
setPropValue(value) {
let valueDate = new Date();
if (value && value != "") {
let str = value;
// let str = "2020-02-02 02:02:02"; // test
str = str.replace(/-/g, "/");
console.log(str)
valueDate = new Date(str);
}
// 获取传入值年月日时分秒后,为组件设置默认下标回显
let yy = valueDate.getFullYear()
let mm = valueDate.getMonth() + 1
let dd = valueDate.getDate()
let hh = valueDate.getHours()
let mi = valueDate.getMinutes()
let ss = valueDate.getSeconds()
// console.log("组件传入值", yy, mm,
// dd,
// hh,
// mi,
// ss)
this.originData.forEach((item, index) => {
switch (index) {
case 0:
for (let i = 0; i < item.length; i++) {
if (Number(item[i].value) === yy) {
this.indexPic[0] = i
break;
}
}
break;
case 1:
for (let i = 0; i < item.length; i++) {
if (Number(item[i].value) === mm) {
this.indexPic[1] = i
break;
}
}
break;
case 2:
for (let i = 0; i < item.length; i++) {
if (Number(item[i].value) === dd) {
this.indexPic[2] = i
break;
}
}
break;
case 3:
for (let i = 0; i < item.length; i++) {
if (Number(item[i].value) === hh) {
this.indexPic[3] = i
break;
}
}
break;
case 4:
for (let i = 0; i < item.length; i++) {
if (Number(item[i].value) === mi) {
this.indexPic[4] = i
break;
}
}
break;
case 5:
for (let i = 0; i < item.length; i++) {
if (Number(item[i].value) === ss) {
this.indexPic[5] = i
break;
}
}
break;
}
})
// 更新页面数组渲染
this.indexPic = [...this.indexPic]
this.datetimeStr = value && value != "" ? value : this.placeholder // 同步更新页面回显
},
// 数据初始化
initData() {
let year = [],
month = [],
date = [],
hours = [],
minutes = [],
seconds = [],
YY = 5, // 组件定义年限范围
MM = 12,
DD = this.getDateNum("", 1),
hh = 23,
mm = 60,
ss = 60
// 年数组
let nowYY = new Date().getFullYear()
for (let iyy = nowYY - YY; iyy <= nowYY + YY; iyy++) {
year.push({
value: iyy,
text: iyy + ""
})
}
for (let imm = 1; imm <= MM; imm++) {
month.push({
value: imm < 10 ? '0' + imm : imm,
text: imm < 10 ? '0' + imm + "" : imm + ""
})
}
for (let idd = 1; idd <= DD; idd++) {
date.push({
value: idd < 10 ? '0' + idd : idd,
text: idd < 10 ? '0' + idd + "" : idd + ""
})
}
for (let ih = 0; ih <= hh; ih++) {
hours.push({
value: ih < 10 ? '0' + ih : ih,
text: ih < 10 ? '0' + ih + "" : ih + ""
})
}
for (let im = 0; im < mm; im++) {
minutes.push({
value: im < 10 ? '0' + im : im,
text: im < 10 ? '0' + im + "" : im + ""
})
seconds.push({
value: im < 10 ? '0' + im : im,
text: im < 10 ? '0' + im + "" : im + ""
})
}
this.originData[0] = year
this.originData[1] = month
this.originData[2] = date
this.originData[3] = hours
this.originData[4] = minutes
this.originData[5] = seconds
this.originData = [...this.originData]
// console.log("查看源数组", this.originData)
this.setPropValue(this.value)
},
// 获取当前月天数
getDateNum(year, month) {
if (!year) {
year = new Date().getFullYear()
}
if (!month) {
month = new Date().getMonth() + 1
}
// console.log(year + "年-" + (month) + "月")
let d = new Date(year, month, 0);
let result = d.getDate();
return result
}
}
}
</script>
<style scoped>
.lee-datetime-main {
min-width: 200rpx;
min-height: 50rpx;
}
.lee-datetime-text {
color: #888A88;
padding: 10rpx;
}
</style>
<template>
<view class="uni-combox">
<view v-if="label" class="uni-combox__label" :style="labelStyle">
<text>{{ label }}</text>
</view>
<view class="uni-combox__input-box">
<input class="uni-combox__input" type="text" :placeholder="placeholder" v-model="inputVal" @input="onInput" @focus="onFocus" @blur="onBlur" />
<uni-icons class="uni-combox__input-arrow" type="arrowdown" size="14" @click="toggleSelector"></uni-icons>
<view class="uni-combox__selector" v-if="showSelector">
<scroll-view scroll-y="true" class="uni-combox__selector-scroll">
<view class="uni-combox__selector-empty" v-if="filterCandidatesLength === 0">
<text>{{ emptyTips }}</text>
</view>
<view class="uni-combox__selector-item" v-for="(item, index) in filterCandidates" :key="index" @click="onSelectorClick(index)">
<text>{{ item }}</text>
</view>
</scroll-view>
</view>
</view>
</view>
</template>
<script>
// import uniIcons from '../uni-icons/uni-icons.vue';
import { uniIcons } from '@dcloudio/uni-ui';
export default {
name: 'myCombox',
components: {
uniIcons
},
props: {
label: {
type: String,
default: ''
},
labelWidth: {
type: String,
default: 'auto'
},
placeholder: {
type: String,
default: ''
},
candidates: {
type: Array,
default() {
return [];
}
},
emptyTips: {
type: String,
default: '无匹配项'
},
value: {
type: String,
default: ''
},
allowCreate:{ //允许输入值来创建新的条目
type: Boolean,
default: true
}
},
data() {
return {
showSelector: false,
inputVal: '',
selectVal:''
};
},
computed: {
labelStyle() {
if (this.labelWidth === 'auto') {
return {};
}
return {
width: this.labelWidth
};
},
filterCandidates() {
return this.candidates.filter(item => {
return item.indexOf(this.inputVal) > -1;
});
},
filterCandidatesLength() {
return this.filterCandidates.length;
}
},
watch: {
value: {
handler(newVal) {
this.inputVal = newVal;
},
immediate: true
},
showSelector(newVal){
if(!this.allowCreate){
if(!!newVal){
// selector显示
this.selectVal = this.inputVal;
}else{
// selector隐藏时
if(this.selectVal != this.inputVal){
this.inputVal='';
}
}
}
}
},
methods: {
toggleSelector() {
this.showSelector = !this.showSelector;
},
onFocus() {
this.showSelector = true;
},
onBlur() {
setTimeout(() => {
this.showSelector = false;
}, 50);
},
onSelectorClick(index) {
this.inputVal = this.filterCandidates[index];
this.selectVal = this.inputVal;
this.showSelector = false;
this.$emit('input', this.inputVal);
//追加单独的点击事件返回,用于确认选择了哪个备选值
this.$emit('selected', this.inputVal);
},
onInput() {
setTimeout(() => {
this.$emit('input', this.inputVal);
});
}
}
};
</script>
<style scoped>
.uni-combox {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
height: 40px;
flex-direction: row;
align-items: center;
/* border-bottom: solid 1px #DDDDDD;
*/
}
.uni-combox__label {
font-size: 16px;
line-height: 22px;
padding-right: 10px;
color: #999999;
}
.uni-combox__input-box {
position: relative;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex: 1;
flex-direction: row;
align-items: center;
}
.uni-combox__input {
flex: 1;
font-size: 16px;
height: 22px;
line-height: 22px;
}
.uni-combox__input-arrow {
padding: 10px;
}
.uni-combox__selector {
box-sizing: border-box;
position: absolute;
top: 42px;
left: 0;
width: 100%;
background-color: #ffffff;
border-radius: 6px;
box-shadow: #dddddd 4px 4px 8px, #dddddd -4px -4px 8px;
z-index: 2;
}
.uni-combox__selector-scroll {
max-height: 200px;
box-sizing: border-box;
}
.uni-combox__selector::before {
content: '';
position: absolute;
width: 0;
height: 0;
border-bottom: solid 6px #ffffff;
border-right: solid 6px transparent;
border-left: solid 6px transparent;
left: 50%;
top: -6px;
margin-left: -6px;
}
.uni-combox__selector-empty,
.uni-combox__selector-item {
/* #ifdef APP-NVUE */
display: flex;
/* #endif */
line-height: 36px;
font-size: 14px;
text-align: center;
border-bottom: solid 1px #dddddd;
margin: 0px 10px;
}
.uni-combox__selector-empty:last-child,
.uni-combox__selector-item:last-child {
border-bottom: none;
}
</style>
let main, receiver, filter, _codeQueryTag = false, temp = [], init = false, start = false;
export default {
initScan() {
if(init) return
// #ifdef APP-PLUS
let _this = this;
main = plus.android.runtimeMainActivity(); //获取activity
var IntentFilter = plus.android.importClass('android.content.IntentFilter');
filter = new IntentFilter();
//android.intent.ACTION_DECODE_DATA
filter.addAction(uni._scanlistener_action || "android.intent.ACTION_DECODE_DATA"); // 换你的广播动作,你的pda设备里面看
receiver = plus.android.implements('io.dcloud.feature.internal.reflect.BroadcastReceiver', {
onReceive: function(context, intent) {
//barcode_string
plus.android.importClass(intent);
let code = intent.getStringExtra(uni._scanlistener_label || "barcode_string"); // 换你的广播标签,你的pda设备里面看
_this.queryCode(code);
}
});
// #endif
init = true
},
startScan() {
if(!start) {
start = true
// #ifdef APP-PLUS
main.registerReceiver(receiver, filter);
// #endif
}
},
stopScan() {
if(start) {
start = false
// #ifdef APP-PLUS
main.unregisterReceiver(receiver);
// #endif
}
},
install(fn) {
if(typeof fn == 'function' && !~temp.indexOf(fn)) temp.push(fn)
},
uninstall(fn) {
if(typeof fn == 'function') {
const index = temp.find(i=>i == fn)
if(~index) temp.splice(index, 1)
}
},
queryCode: function(code) {
//防重复
// if (_codeQueryTag) return false;
// _codeQueryTag = true;
// setTimeout(function() {
// _codeQueryTag = false;
// }, 150);
if(temp && temp.length) {
temp[temp.length - 1](code)
}
uni.vibrateShort()
uni.$emit("qs_scanlistener_handle", code);
}
}
<template>
<view class="wrapper" :class="{'dark-icon': darkIcon}">
<input type="password" style='width:0;height:0;min-height:0;position: absolute;'/>
<input type="text" autocomplete="off" style='width:0;height:0;min-height:0;position: absolute;'/>
<easyinput
v-bind="$attrs"
@iconClick="$emit('iconClick', $event)"
@input="$emit('input', $event)"
@confirm="$emit('confirm', $event)"
clearable
:disabled="mode == 'boardcast'"></easyinput>
<!-- #ifdef APP-PLUS -->
<view v-if="$platform === 'android'" class="icon" @click="changeMode">
<!-- <uni-icons :type="mode == 'boardcast' ? 'navigate' : 'font'" size="30"></uni-icons> -->
<!-- 需求方要求:广播就是广播模式,点击可以切换,广播模式显示广播图标,键盘模式显示键盘图标 -->
<image v-if="mode == 'keyboard'" src="../../static/images/keyboard.png"></image>
<image v-if="mode == 'boardcast'" src="../../static/images/broadcast.png"></image>
</view>
<!-- #endif -->
</view>
</template>
<script>
import scaninput from './scanInput.js'
if(uni.getSystemInfoSync().platform == 'android'){
scaninput.initScan()
scaninput.startScan()
}
export default {
name:"scan-listener",
props:{
darkIcon: Boolean // 是否是深色图标
},
created() {
console.log('创建扫码')
// #ifdef APP-PLUS
if(this.$platform === 'android'){
this.mode = uni.getStorageSync('scanMode') || 'boardcast' // 默认是键盘输入模式
scaninput.install(this.scanHandle)
}
// #endif
},
beforeDestroy() {
// #ifdef APP-PLUS
if(this.$platform === 'android'){
console.log("销毁扫码")
scaninput.uninstall(this.scanHandle)
}
// #endif
},
watch: {
mode(newValue, oldValue) {
uni.setStorageSync('scanMode', this.mode)
}
},
methods: {
scanHandle(code) {
// console.log('广播模式')
if(this.mode != 'boardcast'){
console.log('键盘输入模式,不做处理')
return false
}
this.inputVal = code
this.$emit('submit', code)
},
changeMode(){
this.mode = this.mode == 'boardcast' ? 'keyboard' : 'boardcast'
}
},
data() {
return {
mode: 'keyboard', // 默认键盘输入模式,可选boardcast广播模式
inputVal: '',
};
}
}
</script>
<script module="keyboard" lang="renderjs">
/* export default {
mounted () {
const onKey = (event) => {
const keys1 = ['type', 'timeStamp']
const keys2 = ['altKey', 'code', 'ctrlKey', 'isComposing', 'key', 'location', 'metaKey', 'repeat', 'shiftKey']
const keys3 = ['char', 'charCode', 'keyCode', 'keyIdentifier', 'keyLocation', 'which']
const data = {}
keys1.concat(keys2, keys3).forEach(key => data[key] = event[key])
this.$ownerInstance.callMethod('onEvent', data)
}
const names = ['keyup'] //'keydown',
names.forEach(name => {
document.addEventListener(name, onKey, false)
})
this.$on('hook:beforeDestroy', () => {
names.forEach(name => {
document.removeEventListener(name, onKey, false)
})
})
}
} */
</script>
<style lang="scss">
.wrapper{
display: flex;
align-items: center;
.icon{
margin-left: 10px;
display: flex;
align-items: center;
image{
width: 50rpx;
height: 50rpx;
}
}
}
.dark-icon{
.icon image{
filter: invert(100%);
}
}
</style>
\ No newline at end of file
<template>
<view class="uni-combox" :class="border ? '' : 'uni-combox__no-border'">
<view v-if="label" class="uni-combox__label" :style="labelStyle">
<text>{{label}}</text>
</view>
<view class="uni-combox__input-box">
<input class="uni-combox__input" type="text" :placeholder="placeholder"
placeholder-class="uni-combox__input-plac" v-model="inputVal" @input="onInput" @focus="onFocus"
@blur="onBlur" />
<uni-icons :type="showSelector? 'top' : 'bottom'" size="14" color="#999" @click="toggleSelector">
</uni-icons>
<view v-if="isShowDetermined" style="position: absolute;right: 22px;color: #ea7d60">{{ isChinese ? '待确定' : 'To be determined' }}</view>
</view>
<view class="uni-combox__selector" v-if="showSelector">
<view class="uni-popper__arrow"></view>
<scroll-view scroll-y="true" class="uni-combox__selector-scroll">
<view class="uni-combox__selector-empty" v-if="filterCandidatesLength === 0" @click="onSelectorClick(-1)">
<text>{{emptyTips}}</text>
</view>
<view class="uni-combox__selector-item" v-for="(item,index) in filterCandidatesShort" :key="index"
@click="onSelectorClick(index)" style="display: flex;justify-content: space-between">
<text>{{item}}</text>
<text v-if="productListToBeDeterminedComputed[index]" style="color: #ea7d60">({{ isChinese ? '待确定' : 'To be determined' }})</text>
</view>
</scroll-view>
</view>
</view>
</template>
<script>
/**
* Combox 组合输入框
* @description 组合输入框一般用于既可以输入也可以选择的场景
* @tutorial https://ext.dcloud.net.cn/plugin?id=1261
* @property {String} label 左侧文字
* @property {String} labelWidth 左侧内容宽度
* @property {String} placeholder 输入框占位符
* @property {Array} candidates 候选项列表
* @property {String} emptyTips 筛选结果为空时显示的文字
* @property {String} value 组合框的值
*/
export default {
name: 'selectCombox',
emits: ['input', 'update:modelValue'],
props: {
isChinese: {
type: Boolean,
default: true
},
border: {
type: Boolean,
default: true
},
label: {
type: String,
default: ''
},
labelWidth: {
type: String,
default: 'auto'
},
placeholder: {
type: String,
default: ''
},
candidates: {
type: Array,
default () {
return []
}
},
valuedates: {
type: Array,
default () {
return []
}
},
productListToBeDetermined: {
type: Array,
default () {
return []
}
},
isJSON: {
type: Boolean,
default: false
},
isCheckBox: {
type: Boolean,
default: false
},
emptyTips: {
type: String,
default: '无匹配项'
},
// #ifndef VUE3
value: {
type: [String, Number],
default: ''
},
// #endif
// #ifdef VUE3
modelValue: {
type: [String, Number],
default: ''
},
// #endif
},
data() {
return {
showSelector: false,
inputVal: '',
idVal: ''
}
},
computed: {
isShowDetermined() {
const index = this.candidates.findIndex((item) => {
return item === this.inputVal
})
return index !== -1 && this.productListToBeDeterminedComputed[index]
},
productListToBeDeterminedComputed() {
return this.productListToBeDetermined.filter((item, index) => {
return this.candidates[index].toString().toLowerCase().indexOf(this.inputVal.toLowerCase()) > -1
})
},
filterCandidatesShort() {
return this.filterCandidates.slice(0, 19)
},
labelStyle() {
if (this.labelWidth === 'auto') {
return ""
}
return `width: ${this.labelWidth}`
},
filterCandidates() {
return this.candidates.filter((item = '') => {
return item.toString().toLowerCase().indexOf(this.inputVal.toLowerCase()) > -1
})
},
filterValuedates() {
return this.valuedates.filter((item) => {
return item.titleZh.toString().toLowerCase().indexOf(this.inputVal.toLowerCase()) > -1
})
},
filterCandidatesLength() {
return this.filterCandidates.length
}
},
watch: {
// #ifndef VUE3
value: {
handler(newVal) {
this.inputVal = newVal
},
immediate: true
},
// #endif
// #ifdef VUE3
modelValue: {
handler(newVal) {
this.inputVal = newVal
},
immediate: true
},
// #endif
},
methods: {
toggleSelector() {
this.showSelector = !this.showSelector
},
onFocus() {
this.showSelector = true
},
onBlur() {
setTimeout(() => {
// this.showSelector && this.$emit('getValue', this.inputVal);
this.showSelector = false
}, 153)
},
onSelectorClick(index) {
if (this.isCheckBox) {
let flag = this.arrays.indexOf(index);
if (flag != -1) {
let x = (this.arrays || []).findIndex((item) => item === index)
this.arrays.splice(x, 1);
} else {
this.arrays.push(index);
}
this.inputVal = this.getInpuevals();
if (this.isJSON) {
this.$emit('getValue', this.arrays);
} else {
this.$emit('getValue', this.trimSpace(this.inputVal.split(" ")));
}
} else {
this.showSelector = false
if (this.isJSON) {
this.$emit('getValue', this.filterCandidates[index].index);
this.inputVal = this.filterCandidates[index][this.keyName];
} else {
this.$emit('getValue', this.filterCandidates[index], this.filterValuedates[index]?.id);
this.inputVal = this.filterCandidates[index]
this.idVal = this.filterValuedates[index]?.id
}
}
},
onInput() {
setTimeout(() => {
this.$emit('input', this.inputVal)
this.$emit('update:modelValue', this.inputVal)
})
}
}
}
</script>
<style lang="scss" >
.uni-combox {
font-size: 14px;
border: 1px solid #DCDFE6;
border-radius: 4px;
padding: 6px 10px;
position: relative;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
// height: 40px;
flex-direction: row;
align-items: center;
// border-bottom: solid 1px #DDDDDD;
}
.uni-combox__label {
font-size: 16px;
line-height: 22px;
padding-right: 10px;
color: #999999;
}
.uni-combox__input-box {
position: relative;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex: 1;
flex-direction: row;
align-items: center;
}
.uni-combox__input {
flex: 1;
font-size: 14px;
height: 22px;
line-height: 22px;
}
.uni-combox__input-plac {
font-size: 14px;
color: #999;
}
.uni-combox__selector {
/* #ifndef APP-NVUE */
box-sizing: border-box;
/* #endif */
position: absolute;
top: calc(100% + 12px);
left: 0;
width: 100%;
background-color: #FFFFFF;
border: 1px solid #EBEEF5;
border-radius: 6px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
z-index: 2;
padding: 4px 0;
}
.uni-combox__selector-scroll {
/* #ifndef APP-NVUE */
max-height: 200px;
box-sizing: border-box;
/* #endif */
}
.uni-combox__selector-empty,
.uni-combox__selector-item {
/* #ifndef APP-NVUE */
display: flex;
cursor: pointer;
/* #endif */
line-height: 36px;
font-size: 14px;
text-align: center;
// border-bottom: solid 1px #DDDDDD;
padding: 0px 10px;
}
.uni-combox__selector-item:hover {
background-color: #f9f9f9;
}
.uni-combox__selector-empty:last-child,
.uni-combox__selector-item:last-child {
/* #ifndef APP-NVUE */
border-bottom: none;
/* #endif */
}
// picker 弹出层通用的指示小三角
.uni-popper__arrow,
.uni-popper__arrow::after {
position: absolute;
display: block;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
border-width: 6px;
}
.uni-popper__arrow {
filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03));
top: -6px;
left: 10%;
margin-right: 3px;
border-top-width: 0;
border-bottom-color: #EBEEF5;
}
.uni-popper__arrow::after {
content: " ";
top: 1px;
margin-left: -6px;
border-top-width: 0;
border-bottom-color: #fff;
}
.uni-combox__no-border {
border: none;
}
</style>
<template>
<view class="cu-bar tabbar bg-white shadow foot">
<view class="action" @click="NavChange" data-tab="warehousing">
<view class="cuIcon-cu-image"><text class="cuIcon-scan" :class="getActiveClass('warehousing')"></text></view>
<view :class="getActiveClass('warehousing')">入仓</view>
</view>
<view class="action" @click="NavChange" data-tab="loading">
<view class="cuIcon-cu-image"><text class="cuIcon-deliver" :class="getActiveClass('loading')"></text></view>
<view :class="getActiveClass('loading')">装柜</view>
</view>
</view>
</template>
<script>
export default {
name: 'tab-bar',
props: ['currentPage'],
data() {
return {
url: {
warehousing: '/pages/warehousing/list',
loading: '/pages/loading/list'
}
};
},
computed: {
getActiveClass() {
return function(tab) {
return this.currentPage == tab ? 'text-blue' : 'text-gray';
};
}
},
methods: {
NavChange: function(e) {
const url = this.url[e.currentTarget.dataset.tab];
uni.navigateTo({
url: url
});
}
}
};
</script>
<style></style>
<template>
<view class="cu-modal" :style="{ display: show ? 'show' : '' }">
<view class="cu-dialog">
<view class="cu-bar bg-white justify-end">
<view class="content">{{ title }}</view>
<view class="action" @tap="hideToast"><text class="cuIcon-close text-red"></text></view>
</view>
<view class="padding-xl" v-html="content"></view>
</view>
</view>
</template>
<script>
export default {
name: 'toast',
props: ['show', 'title', 'content'],
data() {
return {};
},
onLoad() {},
methods: {
hideToast() {
this.$emit('update:show', false);
}
}
};
</script>
<style></style>
This diff is collapsed.
<template>
<!-- #ifdef APP-NVUE -->
<text :style="{ color: color, 'font-size': iconSize }" class="uni-icons" @click="_onClick">{{unicode}}</text>
<!-- #endif -->
<!-- #ifndef APP-NVUE -->
<text :style="{ color: color, 'font-size': iconSize }" class="uni-icons" :class="['uniui-'+type,customPrefix,customPrefix?type:'']" @click="_onClick"></text>
<!-- #endif -->
</template>
<script>
import icons from './icons.js';
const getVal = (val) => {
const reg = /^[0-9]*$/g
return (typeof val === 'number' || reg.test(val) )? val + 'px' : val;
}
// #ifdef APP-NVUE
var domModule = weex.requireModule('dom');
import iconUrl from './uniicons.ttf'
domModule.addRule('fontFace', {
'fontFamily': "uniicons",
'src': "url('"+iconUrl+"')"
});
// #endif
/**
* Icons 图标
* @description 用于展示 icons 图标
* @tutorial https://ext.dcloud.net.cn/plugin?id=28
* @property {Number} size 图标大小
* @property {String} type 图标图案,参考示例
* @property {String} color 图标颜色
* @property {String} customPrefix 自定义图标
* @event {Function} click 点击 Icon 触发事件
*/
export default {
name: 'UniIcons',
emits:['click'],
props: {
type: {
type: String,
default: ''
},
color: {
type: String,
default: '#333333'
},
size: {
type: [Number, String],
default: 16
},
customPrefix:{
type: String,
default: ''
}
},
data() {
return {
icons: icons.glyphs
}
},
computed:{
unicode(){
let code = this.icons.find(v=>v.font_class === this.type)
if(code){
return unescape(`%u${code.unicode}`)
}
return ''
},
iconSize(){
return getVal(this.size)
}
},
methods: {
_onClick() {
this.$emit('click')
}
}
}
</script>
<style lang="scss">
/* #ifndef APP-NVUE */
@import './uniicons.css';
@font-face {
font-family: uniicons;
src: url('./uniicons.ttf') format('truetype');
}
/* #endif */
.uni-icons {
font-family: uniicons;
text-decoration: none;
text-align: center;
}
</style>
This diff is collapsed.
<template>
<view>
<template v-if="text">
<text style="margin-right: 10px;color: #4085e3" @click="handleOpen">{{ num }}{{$t('')}}({{ $t('混箱') }})</text>
</template>
<template v-else>
<button class="mini-btn" type="primary" size="mini" @tap="handleOpen" style="margin-left: 10rpx">{{ title }}</button>
</template>
<view class="add-popup">
<uni-popup ref="popup1" background-color="#fff">
<view class="popup-content">
<view class="popup-title">{{ title }}</view>
<WarehouseRecordDetailItem
v-for="(item, index) in dataList"
v-model="dataList[index]"
:key="index"
:index="index"
:attr-list="attrList"
:readonly="readonly"
@handle-delete="handleDelete"
/>
<button v-show="!readonly" type="primary" size="mini" @click="handleAddItem">添加一条明细</button>
<button v-if="orderId" style="margin-left: 10rpx" type="primary" size="mini" @click="handleChooseOrderProduct">选择订单商品</button>
<view class="popup-foot-btn">
<button v-show="!readonly" class="mini-btn" type="primary" size="mini" @tap="handleSave">{{$t('确认')}}</button>
<button v-show="!readonly" class="mini-btn" type="default" size="mini" @tap="handleCancel">{{$t('取消')}}</button>
<button v-show="readonly" class="mini-btn" type="default" size="mini" @tap="handleCancel">{{$t('关闭')}}</button>
</view>
</view>
</uni-popup>
</view>
</view>
</template>
<script>
import WarehouseRecordDetailItem from "@/components/warehouse-record-detail/item.vue";
export default {
name: "WarehouseRecordDetail",
components: {WarehouseRecordDetailItem},
props: {
value: {
type: Array,
default: () => []
},
readonly: {
type: Boolean,
default: false
},
text: {
type: Boolean,
default: false
},
num:{
type:Number,
default:0
},
// 订单ID,有此参数则表示备货页面引用,需开启选择订单商品
orderId: Number,
warehouseInId:Number
},
data() {
return {
dataList: [],
// 特性列表
attrList: []
}
},
mounted() {
uni.addProductFromOrder = this.addItem
},
beforeDestroy() {
uni.addProductFromOrder = null
},
methods: {
init() {
if (!this.value || this.value.length === 0) {
this.dataList = [{
"boxGauge": "",
"brand": undefined,
"cartonsNum": undefined,
"createTime": "",
"expressNo": "",
"prodAttrIds": '',
"prodId": undefined,
"quantityAll": undefined,
"specificationType": undefined,
"unit": "",
"usageIds": "",
"volume": undefined,
"weight": undefined
}]
} else {
this.dataList = JSON.parse(JSON.stringify(this.value))
}
},
handleAddItem() {
this.dataList.push({
"boxGauge": "",
"brand": undefined,
"cartonsNum": undefined,
"createTime": "",
"expressNo": "",
"prodAttrIds": '',
"prodId": undefined,
"quantityAll": undefined,
"specificationType": undefined,
"unit": "",
"usageIds": "",
"volume": undefined,
"weight": undefined
})
},
handleDelete(index) {
this.dataList.splice(index, 1)
},
handleOpen() {
this.init()
this.$refs.popup1.open('center')
},
handleCancel() {
this.$refs.popup1.close()
// this.popupForm = {}
},
handleSave() {
for (let i = 0; i < this.dataList.length; i++) {
if (!this.dataList[i].prodId) {
return uni.showToast({
title: '明细' + (i + 1) + ': ' + '请选择品名',
icon: "error"
})
}
if (!this.dataList[i].brand) {
return uni.showToast({
title: '明细' + (i + 1) + ': ' + '请选择品牌',
icon: "error"
})
}
// if (!this.dataList[i].prodAttrIds) {
// return uni.showToast({
// title: '明细' + (i + 1) + ': ' + '请选择商品特性',
// icon: "error"
// })
// }
}
this.$emit('input', this.dataList)
this.$refs.popup1.close()
},
handleChooseOrderProduct(){
uni.navigateTo({
url: `/pages/stocking/chooseOrderProducts?orderId=${this.orderId}&warehouseInId=${this.warehouseInId}`
})
},
async addItem(item) {
console.log("addItem", {...item})
if(this.dataList?.length){
let lastItem = this.dataList[this.dataList.length - 1]
if(!lastItem.prodId && !lastItem.brand && !lastItem.material && !lastItem.quantityAll){
this.dataList.splice(0, 1)
}
}
await this.$nextTick()
this.dataList.push({
"boxGauge": "",
"brand": item.brand,
"cartonsNum": undefined,
"createTime": "",
"expressNo": "",
"prodAttrIds": item.prodAttrIds,
"prodId": item.prodId,
"quantityAll": item.quantityAll,
"specificationType": undefined,
"unit": "",
"usageIds": item.usageIds || "",
"volume": undefined,
"weight": undefined,
"material": item.material
})
}
},
computed: {
title() {
if (this.readonly) {
return '查看箱明细'
}
return !this.value || this.value.length === 0 ? '添加箱明细' : '编辑箱明细'
}
}
}
</script>
<style scoped lang="scss">
.add-popup {
::v-deep .uni-popup__wrapper {
background: none !important;
}
.popup-content {
width: 90vw;
border-radius: 8px;
background: #fff;
padding: 8px;
max-height: 80vh;
overflow: auto;
.popup-title {
line-height: 48px;
text-align: center;
font-size: 18px;
font-weight: bold;
}
.add-form {
::v-deep .uni-forms-item__label {
font-weight: bold;
}
}
.add-row-btn {
border: 0.5px solid #eee;
text-align: center;
line-height: 30px;
border-radius: 5px;
::v-deep .uni-icons {
vertical-align: bottom;
margin-right: 8px;
}
}
.add-popup-card {
margin: 16px 0 0 0 !important;
.card-row {
display: flex;
align-items: center;
margin-bottom: 12px;
> text {
padding: 0 6px;
}
}
.delete-btn {
width: 72px;
line-height: 30px;
border: 0.5px solid #007aff;
text-align: center;
border-radius: 15px;
color: #007aff;
margin-left: auto;
}
}
.popup-foot-btn {
padding: 8px;
margin-top: 8px;
text-align: center;
button {
border: 1px solid #007aff;
}
> button + button {
margin-left: 16px;
color: #007aff;
background: #fff;
}
}
}
}
</style>
This diff is collapsed.
import Vue from 'vue'
import VueI18n from './vue-i18n/vue-i18n.common'
// import {getLocale} from '@/util/db'
Vue.use(VueI18n)
const i18n = new VueI18n({
locale: uni.getStorageSync('locale')|| 'zh-Hans',
formatFallbackMessages: false,
fallbackLocale: 'zh-Hans',
messages: {
'en': require('./languages/en_US.json'),
'zh-Hans': require('./languages/zh_CN.json')
}
})
/*
用法
$l('title') => titleZh
$l(item, 'title') => item.titleZh
$l(null, 'title') => titleZh
$l() => Zh
*/
Vue.prototype.$l = i18n.l = (object, field = '') => {
let prefix = i18n.locale.split(/[-_]/g)[0] // 改成正则让他同时支持-和_,否则$l取值可能会异常
let append = prefix.charAt(0).toUpperCase() + prefix.toLowerCase().substr(1)
if(typeof object == 'string'){
return object + append
}
// 如果object是null或者字符串则返回字段名
if(!object) return field + append
return object[field + append] || object[field]
}
/* Vue.filter('$t', Vue.$i18n)
*/
// 重新console.warn来捕获未翻译的内容
/* console.wareOrig = console.warn
console.warn = (...data) => {
console.log('warn', typeof data)
console.wareOrig(data)
} */
export default i18n
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
The MIT License (MIT)
Copyright (c) 2016 kazuya kawaguchi
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This diff is collapsed.
This diff is collapsed.
declare type $npm$Vue$Dictionaly<T> = { [key: string]: T }
declare type Util = {
extend: (to: Object, from: ?Object) => Object,
hasOwn: (obj: Object, key: string) => boolean,
isPlainObject: (obj: any) => boolean,
isObject: (obj: mixed) => boolean,
}
declare type Config = {
optionMergeStrategies: $npm$Vue$Dictionaly<Function>,
silent: boolean,
productionTip: boolean,
performance: boolean,
devtools: boolean,
errorHandler: ?(err: Error, vm: Vue, info: string) => void,
ignoredElements: Array<string>,
keyCodes: $npm$Vue$Dictionaly<number>,
isReservedTag: (x?: string) => boolean,
parsePlatformTagName: (x: string) => string,
isUnknownElement: (x?: string) => boolean,
getTagNamespace: (x?: string) => string | void,
mustUseProp: (tag: string, type: ?string, name: string) => boolean,
}
declare interface Vue {
static config: Config,
static util: Util,
static version: string,
}
This diff is collapsed.
/* @flow */
import { warn } from '../util'
export default {
name: 'i18n',
functional: true,
props: {
tag: {
type: [String, Boolean, Object],
default: 'span'
},
path: {
type: String,
required: true
},
locale: {
type: String
},
places: {
type: [Array, Object]
}
},
render (h: Function, { data, parent, props, slots }: Object) {
const { $i18n } = parent
if (!$i18n) {
if (process.env.NODE_ENV !== 'production') {
warn('Cannot find VueI18n instance!')
}
return
}
const { path, locale, places } = props
const params = slots()
const children = $i18n.i(
path,
locale,
onlyHasDefaultPlace(params) || places
? useLegacyPlaces(params.default, places)
: params
)
const tag = (!!props.tag && props.tag !== true) || props.tag === false ? props.tag : 'span'
return tag ? h(tag, data, children) : children
}
}
function onlyHasDefaultPlace (params) {
let prop
for (prop in params) {
if (prop !== 'default') { return false }
}
return Boolean(prop)
}
function useLegacyPlaces (children, places) {
const params = places ? createParamsFromPlaces(places) : {}
if (!children) { return params }
// Filter empty text nodes
children = children.filter(child => {
return child.tag || child.text.trim() !== ''
})
const everyPlace = children.every(vnodeHasPlaceAttribute)
if (process.env.NODE_ENV !== 'production' && everyPlace) {
warn('`place` attribute is deprecated in next major version. Please switch to Vue slots.')
}
return children.reduce(
everyPlace ? assignChildPlace : assignChildIndex,
params
)
}
function createParamsFromPlaces (places) {
if (process.env.NODE_ENV !== 'production') {
warn('`places` prop is deprecated in next major version. Please switch to Vue slots.')
}
return Array.isArray(places)
? places.reduce(assignChildIndex, {})
: Object.assign({}, places)
}
function assignChildPlace (params, child) {
if (child.data && child.data.attrs && child.data.attrs.place) {
params[child.data.attrs.place] = child
}
return params
}
function assignChildIndex (params, child, index) {
params[index] = child
return params
}
function vnodeHasPlaceAttribute (vnode) {
return Boolean(vnode.data && vnode.data.attrs && vnode.data.attrs.place)
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment