初始提交

This commit is contained in:
2026-01-04 11:09:06 +08:00
commit 8fa31df250
1326 changed files with 213907 additions and 0 deletions

308
App.vue Normal file
View File

@@ -0,0 +1,308 @@
<script>
import chat from '@/libs/chat.js'
import {
getAppVersion
} from '@/api/common.js'
import {
getMessageDetail,
checkInfo,
} from '@/api/message.js'
import {
useLocale
} from '@/locale/useLocale';
import {
useChatStore
} from '@/store/modules/chat'
import {
useUserStore
} from '@/store/modules/user'
const chatStore = useChatStore()
export default {
data() {
return {
version: 0,
resVersion: 0,
modileSystem: 'android',
Apk: ''
}
},
onLaunch() {
/* 空路由拦截 */
uni.addInterceptor("reLaunch", {
invoke(e) {
if (e.url == "/") {
history.back();
return false;
}
},
});
// #ifndef MP || H5
/* 获取设备信息 */
uni.getSystemInfo({
success(res) {
uni.setStorageSync('systemInfo', res.ua)
}
})
const token = uni.getStorageSync("token");
if (!token) return
chat.initSocket()
const userStore = useUserStore()
userStore.getCurrentUser().then(res => {
const {
initLocale
} = useLocale();
initLocale()
})
this.handlePush()
// this.getAppVersion()
// 开启消息通知弹窗
this.setPermissions()
// #endif
},
methods: {
handlePush() {
// 获取unipushID
uni.getPushClientId({
success: (res) => {
uni.setStorageSync('push_clientid', res.cid)
},
fail(err) {}
})
// 处理推送消息
uni.onPushMessage(res => {
const data = res.data.payload.data
// 公告跟系统消息
if (data.messageType == 1 || data.messageType == 3) {
uni.navigateTo({
url: '/pages/message/messageDetail/index?id=' + data.id
});
return
}
// 流程消息(包括委托)
if (data.messageType == 2) {
return this.toFlow(data.id)
}
// 日程消息
if (data.messageType == 4) {
return this.toSchedule(data.id)
}
// 聊天
if (data.messageType == 100) {
return this.toIm(res.data.payload)
}
})
},
setPermissions() {
if (plus.os.name == 'Android') { // 判断是Android
var main = plus.android.runtimeMainActivity();
var pkName = main.getPackageName();
var uid = main.getApplicationInfo().plusGetAttribute("uid");
var NotificationManagerCompat = plus.android.importClass(
"android.support.v4.app.NotificationManagerCompat");
//android.support.v4升级为androidx
if (NotificationManagerCompat == null) {
NotificationManagerCompat = plus.android.importClass(
"androidx.core.app.NotificationManagerCompat");
}
var areNotificationsEnabled = NotificationManagerCompat.from(main).areNotificationsEnabled();
// 未开通‘允许通知’权限,则弹窗提醒开通,并点击确认后,跳转到系统设置页面进行设置
if (!areNotificationsEnabled) {
uni.showModal({
title: '通知权限开启提醒',
content: '您还没有开启通知权限,无法接受到消息通知,请前往设置!',
showCancel: false,
confirmText: '去设置',
success: function(res) {
if (res.confirm) {
var Intent = plus.android.importClass('android.content.Intent');
var Build = plus.android.importClass("android.os.Build");
//android 8.0引导
if (Build.VERSION.SDK_INT >= 26) {
var intent = new Intent('android.settings.APP_NOTIFICATION_SETTINGS');
intent.putExtra('android.provider.extra.APP_PACKAGE', pkName);
} else if (Build.VERSION.SDK_INT >= 21) { //android 5.0-7.0
var intent = new Intent('android.settings.APP_NOTIFICATION_SETTINGS');
intent.putExtra("app_package", pkName);
intent.putExtra("app_uid", uid);
} else { //(<21)其他--跳转到该应用管理的详情页
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
var uri = Uri.fromParts("package", mainActivity.getPackageName(),
null);
intent.setData(uri);
}
// 跳转到该应用的系统通知设置页
main.startActivity(intent);
}
}
});
}
} else if (plus.os.name == 'iOS') { // 判断是ISO
var isOn = undefined;
var types = 0;
var app = plus.ios.invoke('UIApplication', 'sharedApplication');
var settings = plus.ios.invoke(app, 'currentUserNotificationSettings');
if (settings) {
types = settings.plusGetAttribute('types');
plus.ios.deleteObject(settings);
} else {
types = plus.ios.invoke(app, 'enabledRemoteNotificationTypes');
}
plus.ios.deleteObject(app);
isOn = (0 != types);
if (isOn == false) {
uni.showModal({
title: '通知权限开启提醒',
content: '您还没有开启通知权限,无法接受到消息通知,请前往设置!',
showCancel: false,
confirmText: '去设置',
success: function(res) {
if (res.confirm) {
var app = plus.ios.invoke('UIApplication', 'sharedApplication');
var setting = plus.ios.invoke('NSURL', 'URLWithString:', 'app-settings:');
plus.ios.invoke(app, 'openURL:', setting);
plus.ios.deleteObject(setting);
plus.ios.deleteObject(app);
}
}
});
}
}
},
getAppVersion() {
getAppVersion().then(res => {
let data = res.data.sysVersion || ''
const matches = data.match(/(\d+\.\d+\.\d+)/);
if (matches && matches.length > 0) this.Apk =
`https://cdn.jnpfsoft.com/apk/Android-java-${matches[0]}.apk`
data.trim();
this.version = Number(data.replace(/[^0-9]/ig, ""))
this.$nextTick(() => {
this.onUpdate()
})
}).catch((err) => {})
},
onUpdate() {
plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
let resVersion = this.define.sysVersion;
resVersion.trim();
this.resVersion = Number(resVersion.replace(/[^0-9]/ig, ""))
if (this.version != this.resVersion) {
process.env.NODE_ENV === "production" ?
uni.setStorageSync('isUpdate', 1) : uni.removeStorageSync('isUpdate')
uni.showModal({ //提醒用户更新
title: "立即更新版本",
success: (res) => {
if (res.confirm) {
uni.removeStorageSync('isUpdate')
let system = plus.os.name;
if (system === 'Android') {
// let url = devLanguage ? javaApk : dotNetApk;
if (!this.Apk) return this.$u.toast('下载链接为空')
plus.runtime.openURL(this.Apk)
// uni.downloadFile({
// //下载地址
// url: url,
// success: data => {
// if (data.statusCode === 200) {
// plus.runtime.install(data
// .tempFilePath, {
// force: false
// },
// function() {
// plus.runtime
// .restart();
// });
// }
// }
// })
} else {
plus.runtime.launchApplication({
action: `itms-apps://itunes.apple.com/cn/app/id${'appleId自行配置'}`
}, function(e) {});
}
} else if (res.cancel) {
if (this.modileSystem == 'ios') {
plus.ios.import("UIApplication")
.sharedApplication()
.performSelector("exit")
} else if (this.modileSystem == 'android') {
plus.runtime.quit();
}
}
}
})
}
})
},
// 打开聊天页面
toIm(item) {
chatStore.reduceBadgeNum(0)
uni.navigateTo({
url: '/pages/message/im/index?name=' + item.realName + '/' + item.account + '&formUserId=' +
item.formUserId +
'&headIcon=' +
item
.headIcon
})
},
// 打开日程页面
toSchedule(id) {
getMessageDetail(id).then(res => {
chatStore.setMsgInfoNum()
let bodyText = res.data.bodyText ? JSON.parse(res.data.bodyText) : {};
if (bodyText.type == 3) return
let groupId = bodyText.groupId || ''
uni.navigateTo({
url: '/pages/workFlow/schedule/detail?groupId=' + groupId +
'&id=' + bodyText.id
});
})
},
// 打开流程页面
toFlow(id) {
getMessageDetail(id).then(res => {
chatStore.setMsgInfoNum()
let bodyText = res.data.bodyText ? JSON.parse(res.data.bodyText) : {};
if (res.data.flowType == 2) {
let url = '/pages/workFlow/entrustAgent/index'
url = bodyText.type == 1 ? url + '?index=1' : url + '?index=2'
uni.navigateTo({
url: url
});
return
}
let config = {
fullName: res.data.title,
id: bodyText.operatorId || res.data.id,
...bodyText
}
checkInfo(bodyText.operatorId || config.taskId, config.opType).then(res => {
config.opType = res.data.opType;
setTimeout(() => {
uni.navigateTo({
url: '/pages/workFlow/flowBefore/index?config=' +
this.jnpf.base64.encode(JSON.stringify(config))
});
}, 300)
})
})
}
}
}
</script>
<style lang="scss">
/*每个页面公共css */
@import "@/uni_modules/vk-uview-ui/index.scss";
@import "@/assets/iconfont/ym/iconfont.css";
@import "@/assets/iconfont/custom/iconfont.css";
@import "@/assets/scss/common.scss";
@import "@/assets/scss/components.scss";
</style>

33
README.md Normal file
View File

@@ -0,0 +1,33 @@
#jnpf-app-vue3
## 一 环境要求
### 1.1 开发环境
- 操作系统:`Windows 10/11``MacOS`
- `Node.js` v16.15.x(某些情况下可能需要安装 Python3)及以上版本;
- `HBuilder X` (最新版)
### 1.2 运行环境
`Nginx` 建议使用 `1.18.0` 及以上版本、兼容 `OpenResty``TongHttpServer` 6.0(国产信创)
## 二 关联项目
> 需要使用下表中的对应分支
| 项目 | 分支 | 说明 |
| ------------------------- | ------------- | ------------------------------------------|
| **后端**(任一后端服务) | | |
| jnpf-java-boot | v6.0.x-stable | Java 单体项目源码 |
| jnpf-java-cloud | v6.0.x-stable | Java 微服务项目源码 |
| jnpf-dotnet | v6.0.x-stable | .NET 单体项目源码 |
| jnpf-dotnet-cloud | v6.0.x-stable | .NET 微服务项目源码 |
## 三 使用说明
### 3.1 高德地图配置
打开 `/utils/define.ts` 配置文件,修改 `aMapWebKey`
打开 `manifest.json` 文件点击app模块配置修改高德地图相关配置信息。点击web配置修改高德地图相关配置信息。

102
api/apply/apply.js Normal file
View File

@@ -0,0 +1,102 @@
import request from '@/utils/request'
// 获取应用菜单
export function getMenuList(data) {
return request({
url: '/api/app/Menu',
method: 'get',
data,
options: {
load: false
}
})
}
// 获取常用 1-流程 2-应用
export function getUsualList() {
return request({
url: '/api/system/MenuData',
method: 'get',
options: {
load: false
}
})
}
//流程常用更多
export function getCommonFlowTree(id) {
return request({
url: `/api/workflow/template/CommonFlowTree`,
method: 'get'
})
}
// 获取常用流程
export function getFlowUsualList(data) {
return request({
url: '/api/workflow/template/Selector',
method: 'get',
data,
options: {
load: false
}
})
}
// 获取常用全部 1-流程 2-应用
export function getAppDataList(data) {
return request({
url: '/api/system/MenuData/getAppDataList',
data,
options: {
load: false
}
})
}
// 获取添加流程
export function setCommonFlow(id) {
return request({
url: `/api/workflow/template/SetCommonFlow/${id}`,
method: 'post'
})
}
export function addUsual(id) {
return request({
url: `/api/system/MenuData/${id}`,
method: 'post'
})
}
export function delUsual(id) {
return request({
url: `/api/system/MenuData/${id}`,
method: 'delete'
})
}
export function getFlowList(data) {
return request({
url: '/api/workflow/template/Selector',
data
})
}
export function getDataList(data) {
return request({
url: `/api/system/MenuData/getDataList`,
data
})
}
export function getChildList(id) {
return request({
url: `/api/app/Menu/getChildList/${id}`
})
}
export function getChildMenuList(data) {
return request({
url: '/api/app/Menu/getMenuList?keyword=' + data.keyword,
data
})
}
// 获取应用菜单
export function getMenuSys() {
return request({
url: '/api/app/Menu/sys',
method: 'get',
options: {
load: false
}
})
}

42
api/apply/order.js Normal file
View File

@@ -0,0 +1,42 @@
import request from '@/utils/request'
// 删除订单
export function Delete(id) {
return request({
url: `/api/extend/CrmOrder/${id}`,
method: 'DELETE'
})
}
// 获取订单列表
export function getOrderList(data, options) {
return request({
url: `/api/extend/CrmOrder`,
method: 'get',
data,
options
})
}
// 获取商品列表
export function getGoodsList(data) {
return request({
url: `/api/extend/CrmOrder/Goods`,
method: 'get',
data,
options: {
load: false
}
})
}
// 获取客户列表
export function getCustomerList(keyword) {
return request({
url: `/api/extend/CrmOrder/Customer`,
method: 'get',
data: {
keyword: keyword || ''
},
options: {
load: false
}
})
}

49
api/apply/reportLog.js Normal file
View File

@@ -0,0 +1,49 @@
import request from '@/utils/request'
//获取我发出的日志
export function getSendList(data, options) {
return request({
url: `/api/extend/WorkLog/Send`,
method: 'GET',
data,
options
})
}
//获取收到的日志
export function getReceiveList(data, options) {
return request({
url: `/api/extend/WorkLog/Receive`,
method: 'GET',
data,
options
})
}
//日志info
export function getLogInfo(id) {
return request({
url: `/api/extend/WorkLog/${id}`,
method: 'GET',
})
}
//日志保存
export function createLog(data) {
return request({
url: `/api/extend/WorkLog`,
method: 'POST',
data
})
}
//日志修改
export function updateLog(data) {
return request({
url: `/api/extend/WorkLog/${data.id}`,
method: 'PUT',
data
})
}
//日志删除
export function delLog(id) {
return request({
url: `/api/extend/WorkLog/${id}`,
method: 'DELETE'
})
}

88
api/apply/visualDev.js Normal file
View File

@@ -0,0 +1,88 @@
import request from '@/utils/request'
// 获取列表表单配置JSON
export function getConfigData(modelId, menuId) {
return request({
url: `/api/visualdev/OnlineDev/${modelId}/Config?menuId=${menuId}`,
method: 'GET'
})
}
// 通过菜单id获取列表表单配置JSON
export function getConfigDataByMenuId(data = {}) {
return request({
url: `/api/visualdev/OnlineDev/Config`,
method: 'GET',
data
}, );
}
// 获取数据列表
export function getModelList(modelId, data, options) {
return request({
url: `/api/visualdev/OnlineDev/${modelId}/List`,
method: 'POST',
data,
options: {
load: false
}
})
}
// 添加数据
export function createModel(modelId, data) {
return request({
url: `/api/visualdev/OnlineDev/${modelId}?menuId=${data.menuId}`,
method: 'POST',
data
})
}
// 修改数据
export function updateModel(modelId, data) {
return request({
url: `/api/visualdev/OnlineDev/${modelId}/${data.id}?menuId=${data.menuId}`,
method: 'PUT',
data
})
}
// 获取数据信息
export function getModelInfo(modelId, id, menuId) {
return request({
url: `/api/visualdev/OnlineDev/${modelId}/${id}?menuId=${menuId}`,
method: 'GET'
})
}
// 删除数据
export function deteleModel(data, id) {
return request({
url: `/api/visualdev/OnlineDev/batchDelete/${id}`,
method: 'POST',
data
})
}
// 表单外链
export function getConfig(id) {
return request({
url: `/api/visualdev/OnlineDev/${id}/Config`,
method: 'GET'
})
}
// 修改记录
export function getOnlineLog(modelId, id) {
return request({
url: `/api/visualdev/OnlineLog?modelId=${modelId}&dataId=${id}`,
method: 'GET'
})
}
//自定义按钮发起流程
export function launchFlow(data, id) {
return request({
url: `/api/visualdev/OnlineDev/${id}/actionLaunchFlow`,
method: 'POST',
data
})
}
// 获取关联表单数据详情
export function getDataChange(data, modelId) {
return request({
url: `/api/visualdev/OnlineDev/${modelId}/DataChange`,
method: 'post',
data
})
}

46
api/apply/webDesign.js Normal file
View File

@@ -0,0 +1,46 @@
import request from '@/utils/request'
// 获取列表表单配置JSON
export function getConfig(modelId, encryption) {
return request({
url: `/api/visualdev/ShortLink/${modelId}/Config?encryption=${encryption}`,
method: 'GET'
})
}
// 获取数据详情
export function getDataChange(modelId, id, encryption) {
return request({
url: `/api/visualdev/ShortLink/${modelId}/${id}/DataChange` + (encryption ? '?encryption=' +
encryption : ''),
method: 'GET'
})
}
export function createModel(modelId, data, encryption) {
return request({
url: `/api/visualdev/ShortLink/${modelId}?encryption=${encryption}`,
method: 'POST',
data
})
}
// 表单外链表单信息
export function getShortLink(id, encryption) {
return request({
url: `/api/visualdev/ShortLink/getConfig/${id}?encryption=${encryption}`,
method: 'GET'
})
}
//表单外链密码验证
export function checkPwd(data) {
return request({
url: `/api/visualdev/ShortLink/checkPwd`,
method: 'POST',
data
})
}
// 表单外链列表
export function listLink(id, data, encryption) {
return request({
url: `/api/visualdev/ShortLink/${id}/ListLink?encryption=${encryption}`,
method: 'POST',
data
})
}

651
api/common.js Normal file
View File

@@ -0,0 +1,651 @@
import request from '@/utils/request'
//app版本升级
export function versionUpgrade(appName) {
return request({
url: `/api/file/AppStartInfo/${appName}`,
})
}
export function getAppVersion() {
return request({
url: `/api/app/Version`
})
}
// 获取数据字典数据
export function getDictionaryDataAll() {
return request({
url: '/api/system/DictionaryData/All',
options: {
load: false
}
})
}
// 获取字典数据下拉框列表
export function getDictionaryDataSelector(dictionaryTypeId) {
return request({
url: `/api/system/DictionaryData/${dictionaryTypeId}/Data/Selector`,
options: {
load: false
}
})
}
// 获取关联表单数据详情
export function getRelationFormDetail(modelId, data) {
return request({
url: `/api/visualdev/OnlineDev/${modelId}/DataChange`,
method: 'post',
data
})
}
// 获取关联表单弹窗列表
export function getRelationSelect(id, data, options) {
return request({
url: `/api/visualdev/Base/${id}/FieldDataSelect`,
data,
options: {
load: false
}
})
}
// 获取弹窗选择远端接口数据
export function getPopSelect(id, data, options) {
return request({
url: `/api/system/DataInterface/${id}/Actions/List`,
method: 'POST',
data,
options: {
load: true
}
})
}
// 获取多条接口数据
export function getDataInterfaceDataInfoByIds(id, data) {
return request({
url: `/api/system/DataInterface/${id}/Actions/InfoByIds`,
method: 'POST',
data
})
}
// 获取组织/公司下拉框列表
export function getOrganizeSelector(data) {
if (!data) data = {
parentId: '0'
};
return request({
url: '/api/permission/Organize/Selector',
options: {
load: false
},
data
})
}
// 获取组织和岗位下拉框列表
export function getOrgAndPosSelector(data) {
if (!data) data = {
id: '0',
type: 'organize'
};
return request({
url: '/api/permission/Organize/AsyncPosList',
options: {
load: false
},
data
})
}
// 获取选中组织基本信息
export function getOrgSelectedList(data) {
return request({
url: `/api/permission/Organize/SelectedList`,
method: 'POST',
options: {
load: false
},
data
})
}
// 获取岗位下拉列表
export function getPositionSelector(data) {
return request({
url: '/api/permission/Position/Selector',
options: {
load: false
},
data
})
}
// 获取选中岗位信息
export function getPositionSelectedList(data) {
return request({
url: `/api/permission/Position/SelectedList`,
method: 'POST',
options: {
load: false
},
data
})
}
// 获取用户下拉框列表(公司+部门+用户)
export function getUserSelector() {
return request({
url: '/api/permission/Users/Selector',
options: {
load: false
}
})
}
// 通过部门id,岗位id,角色id,分组id,用户id获取用户列表(带分页)
export const getUsersByUserCondition = (data) => {
return request({
url: '/api/permission/Users/UserCondition',
method: 'post',
data
})
}
// 通过部门id获取部门树形
export const getOrgByOrganizeCondition = (data) => {
return request({
url: `/api/permission/Organize/OrganizeCondition`,
method: 'post',
data
})
}
// 通过部门id,岗位id获取岗位树形
export const getPositionByCondition = (data) => {
return request({
url: `/api/permission/Position/PositionCondition`,
method: 'post',
data
})
}
// 获取用户基本信息
export const getUserInfoList = ids => {
return request({
url: '/api/permission/Users/getUserList',
method: 'post',
data: {
ids
}
})
}
// 获取当前组织用户
export const getOrganization = (keyword) => {
return request({
url: '/api/permission/Users/getOrganization',
method: 'get',
data: {
keyword,
organizeId: '0'
}
})
}
//获取用户详情
export function getUesrDetail(id) {
return request({
url: '/api/app/User/' + id,
method: 'GET'
})
}
// 获取接口数据
export function getDataInterfaceRes(id, data) {
return request({
url: `/api/system/DataInterface/${id}/Actions/Preview`,
method: 'post',
options: {
load: false
},
data: data || {}
})
}
// 用户登录
export function login(data) {
return request({
url: '/api/oauth/Login',
method: 'post',
data,
header: {
'Content-Type': 'application/x-www-form-urlencoded',
}
})
}
// 账号注销
export function accountCancel(token) {
return request({
url: '/api/oauth/logoutCurrentUser',
method: 'post',
token,
header: {
'Content-Type': 'application/x-www-form-urlencoded',
}
})
}
//获取验证码
export function clickSms(account) {
return request({
url: 'https://app.jnpfsoft.com/api/Saas/Tenant/SmsCode/' + account,
method: 'GET',
header: {
'Content-Type': 'application/x-www-form-urlencoded',
}
})
}
//验证码登录
export function loginSms(data) {
return request({
url: 'https://app.jnpfsoft.com/api/Saas/Tenant/LoginSms',
method: 'POST',
data,
header: {
'Content-Type': 'application/x-www-form-urlencoded',
}
})
}
// 退出登录
export function logout() {
return request({
url: '/api/oauth/Logout',
method: 'POST'
})
}
// 获取当前用户信息
export function getCurrentUser() {
return request({
url: '/api/oauth/CurrentUser?type=app',
options: {
load: false
},
header: {
'App-Code': ''
}
})
}
// 获取当前用户个人资料
export function getUserSettingInfo() {
return request({
url: '/api/permission/Users/Current/BaseInfo',
method: 'GET',
options: {
load: false
}
})
}
// 更新当前用户个人资料
export function updateUserInfo(data) {
return request({
url: '/api/permission/Users/Current/BaseInfo',
method: 'PUT',
data: data,
options: {
load: false
}
})
}
// 修改密码信息发送
export function updatePasswordMessage() {
return request({
url: '/api/oauth/updatePasswordMessage',
method: 'POST',
data: {},
options: {
load: false
}
})
}
// 用户登录测试
export function login2(data) {
return request({
url: '/api/oauth',
method: 'GET',
data,
options: {
load: false
}
})
}
export function getBillNumber(enCode) {
return request({
url: `/api/system/BillRule/BillNumber/${enCode}`,
method: 'GET',
options: {
load: false
}
})
}
// 获取下载文件链接
export function getDownloadUrl(type, fileId) {
return request({
url: `/api/file/Download/${type}/${fileId}`,
method: 'GET'
})
}
// 修改当前用户密码
export function updatePassword(data) {
return request({
url: '/api/permission/Users/Current/Actions/ModifyPassword',
method: 'POST',
data
})
}
// 获取我的下属
export function getSubordinate(id) {
return request({
url: `/api/permission/Users/Current/Subordinate/${id ? id : '0'}`,
method: 'GET'
})
}
// 获取默认配置
export function getConfig(account) {
return request({
url: `/api/oauth/getConfig/${account}`,
method: 'get',
options: {
load: false
}
})
}
// 获取行政区划下拉框数据
export function getProvinceSelector(id) {
return request({
url: `/api/system/Area/${id}/Selector/0`,
method: 'GET'
})
}
// 获取行政区划下拉框数据
export function getProvinceSelectorInfoList(idsList) {
return request({
url: `/api/system/Area/GetAreaByIds`,
method: 'post',
data: {
idsList
}
})
}
// 设置主要组织、主要岗位
export function setMajor(data) {
return request({
url: `/api/permission/Users/Current/major`,
method: 'put',
data
})
}
// 获取当前用户所有组织
export function getUserOrganizes(data) {
return request({
url: `/api/permission/Users/Current/getUserOrganizes`,
method: 'GET',
data
})
}
// 获取当前用户所有岗位
export function getUserPositions(data) {
return request({
url: `/api/permission/Users/Current/getUserPositions`,
method: 'GET',
data
})
}
// 获取当前用户个人资料
export function UserSettingInfo() {
return request({
url: '/api/permission/Users/Current/BaseInfo',
method: 'GET'
})
}
// 更新当前用户个人资料
export function UpdateUser(data) {
return request({
url: '/api/permission/Users/Current/BaseInfo',
method: 'PUT',
data
})
}
// 更新当前用户头像
export function UpdateAvatar(name) {
return request({
url: `/api/permission/Users/Current/Avatar/${name}`,
method: 'PUT'
})
}
// 获取分组下拉框列表
export const getGroupSelector = () => {
return request({
url: '/api/permission/Group/Selector',
method: 'GET'
})
}
// 获取分组列表
export const getGroupCondition = (data) => {
return request({
url: '/api/permission/Group/GroupCondition',
method: 'POST',
data
})
}
// 获取角色下拉框列表
export const getRoleSelector = () => {
return request({
url: '/api/permission/Role/Selector',
method: 'GET',
data: {
type: 'user',
isSystem: 0
},
options: {
load: false
}
})
}
// 获取角色下拉框列表
export const getRoleCondition = (data) => {
return request({
url: '/api/permission/Role/RoleCondition',
method: 'POST',
data
})
}
// app第三方登录
export const getCallback = (data) => {
return request({
url: `/api/oauth/socials/app/callback/${data.source}?uuid=` + data.uuid,
method: 'GET'
})
}
// 第三方登录
export function otherlogin(data, ticket) {
return request({
url: `/api/oauth/socials/render/${data}` + '?ticket=' + ticket,
method: 'get'
})
}
// 获取登陆配置
export function getLoginConfig() {
return request({
url: '/api/oauth/getLoginConfig',
})
}
//获取登录票据
export function getTicket() {
return request({
url: `/api/oauth/getTicket`,
method: 'GET',
})
}
// 轮询获取登陆状态
export function getTicketStatus(ticket) {
return request({
url: `/api/oauth/getTicketStatus/${ticket}`,
method: 'GET',
options: {
load: false
}
})
}
// 获取第三方列表
export const getSocialsUserList = () => {
return request({
url: '/api/permission/socials/login',
method: 'GET'
})
}
// 第三方登录回调列表后点击登录
export function socialsLogin(data) {
return request({
url: `/api/oauth/Login/socials`,
data,
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
})
}
// 获取签名列表
export const getSignImgList = () => {
return request({
url: '/api/permission/Users/Current/SignImg',
method: 'GET',
options: {
load: false
}
})
}
// 新增签名
export const createSignImg = (data) => {
return request({
url: '/api/permission/Users/Current/SignImg',
method: 'post',
data,
options: {
load: false
}
})
}
// 设置默认签名
export const setDefSignImg = (id) => {
return request({
url: `/api/permission/Users/Current/${id}/SignImg`,
method: 'put',
options: {
load: false
}
})
}
// 删除签名
export const delSignImg = (id) => {
return request({
url: `/api/permission/Users/Current/${id}/SignImg`,
method: 'delete',
options: {
load: false
}
})
}
// 获取选中组织、岗位、角色、用户基本信息
export const getSelectedList = ids => {
return request({
url: '/api/permission/Users/getSelectedList',
method: 'post',
data: {
ids
}
})
}
// 通过组织、岗位、角色、用户ids获取选中用户基本信息
export const getSelectedUserList = data => {
return request({
url: '/api/permission/Users/getSelectedUserList',
method: 'post',
data
})
}
// 委托选择用户
export const getReceiveUserList = data => {
return request({
url: '/api/permission/Users/ReceiveUserList',
method: 'get',
data,
options: {
load: true
}
})
}
// 获取用户下拉框列表
export const getListByAuthorize = (organizeId, keyword) => {
return request({
url: `/api/permission/Users/GetListByAuthorize/${organizeId}`,
method: 'post',
data: {
keyword
}
})
}
// 查询附近数据
export function getAroundList(data) {
return request({
url: '/api/system/Location/around',
method: 'get',
data
})
}
//根据关键字查询附近数据
export function getTextList(data) {
return request({
url: '/api/system/Location/text',
method: 'get',
data
})
}
//逆地理编码
export function getAddress(data) {
return request({
url: '/api/system/Location/regeo',
method: 'get',
data
})
}
// 更改扫码凭证状态-已扫码
export function setCodeCertificateStatus(ticket, status) {
return request({
url: `/api/oauth/setCodeCertificateStatus/${ticket}/${status}`,
method: 'GET',
options: {
load: false
}
})
}
// 扫码确认登录
export function confirmLogin(ticket) {
return request({
url: `/api/oauth/confirmLogin/${ticket}`,
method: 'GET',
options: {
load: false
}
})
}
export function getLangJson(locale) {
const header = locale ? {
"Accept-Language": locale
} : {}
return request({
url: '/api/system/BaseLang/LangJson',
method: 'GET',
header
})
}
//获取用户列表
export function getUserList(data) {
return request({
url: '/api/permission/Users',
method: 'GET',
data,
options: {
load: false
}
})
}

40
api/commonWords.js Normal file
View File

@@ -0,0 +1,40 @@
import request from '@/utils/request'
//获取常用语
export function getSelector() {
return request({
url: `/api/system/CommonWords/Selector?type=App`,
method: 'get'
})
}
// 获取常用语列表
export function commonWords(data) {
return request({
url: `/api/system/CommonWords`,
method: 'get',
data
})
}
// 审批常用语新建
export function Create(data) {
return request({
url: '/api/system/CommonWords',
method: 'post',
data
})
}
// 审批常用语编辑
export function Update(data) {
return request({
url: `/api/system/CommonWords/${data.id}`,
method: 'put',
data
})
}
// 删除审批常用语详情
export function Delete(id) {
return request({
url: `/api/system/CommonWords/${id}`,
method: 'DELETE'
})
}

44
api/home.js Normal file
View File

@@ -0,0 +1,44 @@
import request from '@/utils/request'
// 获取通知公告
export function getNotice(data) {
return request({
url: '/api/visualdev/Dashboard/Notice',
method: 'post',
data,
options: {
load: false
}
})
}
// 获取未读邮件
export function getEmail() {
return request({
url: '/api/visualdev/Dashboard/Email',
method: 'get',
options: {
load: false
}
})
}
// 获取待办事项
export function getFlowTodo(type) {
return request({
url: `/api/workflow/monitor/FlowTodo?type=${type}`,
method: 'get',
options: {
load: false
}
})
}
// 获取我的待办事项
export function getMyFlowTodo() {
return request({
url: '/api/visualdev/Dashboard/MyFlowTodo',
method: 'get',
options: {
load: false
}
})
}

10
api/index/index.js Normal file
View File

@@ -0,0 +1,10 @@
import request from '@/utils/request'
export function getHomeData(id) {
return request({
url: `/api/system/HomeData/app`,
method: 'get',
options: {
load: true
}
})
}

73
api/message.js Normal file
View File

@@ -0,0 +1,73 @@
import request from '@/utils/request'
// 获取IM对话列表
export function getIMReply(data) {
return request({
url: '/api/message/imreply',
method: 'Get',
options: {
load: true
},
data
})
}
//获取消息列表
export function getMessageList(data) {
return request({
url: '/api/message',
data,
options: {
load: false
}
})
}
//获取消息列表
export function getUnReadMsgNum(data) {
return request({
url: '/api/message/getUnReadMsgNum',
data,
options: {
load: false
}
})
}
// 全部已读
export function MessageAllRead(data) {
return request({
url: '/api/message/Actions/ReadAll',
method: 'POST',
data
})
}
//消息详情
export function getMessageDetail(id) {
return request({
url: `/api/message/ReadInfo/${id}`,
method: 'get'
})
}
// 判断是否有查看消息详情权限(消息通知用)
export function checkInfo(taskOperatorId, opType) {
return request({
url: `/api/workflow/operator/${taskOperatorId}/Info?opType=${opType}`,
method: 'get'
})
}
// 删除会话列表
export function relocation(id) {
return request({
url: `/api/message/imreply/relocation/${id}`,
method: 'delete'
})
}
// 获取组织下拉框列表
export function getOrgAndPosSelector(data) {
return request({
url: '/api/permission/Organize/AsyncPosList',
method: 'get',
data,
options: {
load: false
}
})
}

73
api/portal/portal.js Normal file
View File

@@ -0,0 +1,73 @@
import request from '@/utils/request'
//门户列表
export function PortalList() {
return request({
url: `/api/visualdev/Portal/Selector/Menu`,
method: 'get',
options: {
load: false
}
})
}
//更新门户
export function SetPortal(id) {
return request({
url: `/api/visualdev/Portal/${id}/Actions/SetDefault?platform=App`,
method: 'put',
options: {
load: false
}
})
}
//门户列表切换后列表
export function auth(id) {
return request({
url: `/api/visualdev/Portal/${id}/auth?platform=App`,
method: 'get',
options: {
load: false
}
})
}
//获取门户地图数据
export function geojson(code) {
return request({
url: `/api/system/atlas/geojson?code=${code}&hasChildren=true`,
method: 'get',
options: {
load: false
}
})
}
//获取省市区树
export function getAtlas() {
return request({
url: `/api/system/atlas`,
method: 'get',
options: {
load: false
}
})
}
// 获取发送配置列表列表
export const getMsgTemplate = data => {
return request({
url: '/api/message/SendMessageConfig/getSendConfigList',
method: 'GET',
data,
options: {
load: false
}
})
}
// 预览
export const getPreviewPortal = id => {
return request({
url: '/api/visualdev/Portal/' + id,
method: 'GET',
options: {
load: false
}
})
}

11
api/signature.js Normal file
View File

@@ -0,0 +1,11 @@
import request from '@/utils/request'
// 通过id获取签章下拉框列表
export function getListByIds(data) {
return request({
url: '/api/system/Signature/ListByIds',
method: 'post',
data
})
}

14
api/system.js Normal file
View File

@@ -0,0 +1,14 @@
import request from '@/utils/request'
// 获取应用列表
export function getSystemList(data) {
return request({
url: '/api/system/System/userAuthList',
method: 'get',
data,
options: {
load: true
}
})
}

139
api/workFlow/document.js Normal file
View File

@@ -0,0 +1,139 @@
import request from '@/utils/request'
// 获取文档列表
export function getDocumentList(data) {
return request({
url: `/api/file/Document?keyword=${data.keyword}&parentId=${data.parentId}`,
method: 'get'
})
}
// 文件下载
export function packDownload(e) {
return request({
url: `/api/file/Document/PackDownload`,
method: 'POST',
data:JSON.parse(e)
})
}
// 文件重命名
export function resetFileName(data) {
return request({
url: `/api/file/Document/${data.id}`,
method: 'PUT',
data
})
}
// 文件重命名详情
export function fileDetail(id) {
return request({
url: `/api/file/Document/${id}`,
method: 'get'
})
}
// 新建文件夹
export function addFolder(data) {
return request({
url: `/api/file/Document`,
method: 'POST',
data
})
}
// 文件删除
export function batchDelete(e) {
return request({
url: `/api/file/Document/BatchDelete`,
method: 'POST',
data:JSON.parse(e)
})
}
// 文件回收站
export function trash(data) {
return request({
url: `/api/file/Document/Trash`,
method: 'GET',
data
})
}
// 文件回收站删除
export function trashDelete(data) {
return request({
url: `/api/file/Document/Trash`,
method: 'post',
data
})
}
// 文件还原
export function recovery(data) {
return request({
url: `/api/file/Document/Trash/Actions/Recovery`,
method: 'POST',
data
})
}
// 文件树列表
export function folderTree(data) {
return request({
url: `/api/file/Document/FolderTree`,
method: 'POST',
data
})
}
// 文件移动
export function folderMove(data) {
return request({
url: `/api/file/Document/Actions/MoveTo/${data.id}`,
method: 'PUT',
data
})
}
// 文件共享列表
export function shareFolderList(data) {
return request({
url: `/api/file/Document/Share`,
method: 'GET',
data
})
}
// 文件共享
export function shareFolder(data) {
return request({
url: `/api/file/Document/Actions/Share`,
method: 'POST',
data
})
}
// 共享给我
export function shareTome(data) {
return request({
url: `/api/file/Document/ShareTome`,
method: 'GET',
data
})
}
// 取消共享
export function cancelShare(data) {
return request({
url: `/api/file/Document/Actions/CancelShare`,
method: 'POST',
data
})
}
// 获取共享人员
export function shareUser(id) {
return request({
url: `/api/file/Document/ShareUser/${id}`,
method: 'GET'
})
}
// 更新共享人员
export function shareAdjustment(data) {
return request({
url: `/api/file/Document/Actions/ShareAdjustment/${data.ids}`,
method: 'POST',
data
})
}

84
api/workFlow/entrust.js Normal file
View File

@@ -0,0 +1,84 @@
import request from '@/utils/request'
// 获取流程委托列表
export function FlowDelegateList(data) {
return request({
url: `/api/workflow/delegate`,
method: 'get',
data
})
}
// 获取流程委托信息
export function FlowDelegateInfo(id) {
return request({
url: `/api/workflow/delegate/${id}`,
method: 'get'
})
}
// 删除流程委托
export function DeleteDelagate(id) {
return request({
url: `/api/workflow/delegate/${id}`,
method: 'DELETE'
})
}
// 新建流程委托
export function Create(data) {
return request({
url: `/api/workflow/delegate`,
method: 'post',
data
})
}
// 更新流程委托
export function Update(data) {
return request({
url: `/api/workflow/delegate/${data.id}`,
method: 'PUT',
data
})
}
// 获取流程的所有委托人
export function getDelegateUser(id) {
return request({
url: `/api/workflow/delegate/UserList?templateId=${id}`,
method: 'get'
})
}
// 获取一个委托终止
export function entrustStop(id) {
return request({
url: `/api/workflow/delegate/Stop/${id}`,
method: 'put',
data: {}
})
}
// 获取用户下拉框列表
export const getListByAuthorize = (organizeId, keyword) => {
return request({
url: `/api/permission/Users/GetListByAuthorize/${organizeId}`,
method: 'post',
data: {
keyword
}
})
}
// 获取用户下拉框列表
export function getPrincipalDetails(id) {
return request({
url: `/api/workflow/delegate/Info/${id}`,
method: 'get'
})
}
// 接受委托
export function entrustHandle(id, data) {
return request({
url: `/api/workflow/delegate/Notarize/${id}?type=${data.type}`,
method: 'post',
data: {}
})
}

232
api/workFlow/flowBefore.js Normal file
View File

@@ -0,0 +1,232 @@
import request from '@/utils/request'
import jnpf from '@/utils/jnpf'
// 获取待我审批信息
export function FlowTask(id, data) {
const userInfo = uni.getStorageSync('userInfo') || {}
const newId = jnpf.aesEncryption.encrypt(id + ',' + userInfo.userId + ',' + jnpf.idGenerator());
return request({
url: `/api/workflow/task/${newId}`,
method: 'get',
data,
options: {
load: true
}
})
}
// 流程记录
export function recordList(data) {
return request({
url: `/api/workflow/operator/RecordList`,
method: 'get',
data
})
}
// 获取流程任务
export function taskList(data) {
return request({
url: `/api/workflow/trigger/task/List`,
method: 'get',
data
})
}
//减签列表
export function AddSignUserIdList(data, id) {
return request({
url: `/api/workflow/operator/AddSignUserIdList/${id}`,
method: 'post',
data
})
}
//减签
export function ReduceApprover(data, id) {
return request({
url: `/api/workflow/operator/ReduceApprover/${id}`,
method: 'post',
data
})
}
// 流程签收
export function SignFor(data) {
return request({
url: `/api/workflow/operator/Sign`,
method: 'post',
data
})
}
// 退回
export function back(id) {
return request({
url: `/api/workflow/operator/SendBackNodeList/${id}`,
method: 'get'
})
}
// 确认退回
export function sendBack(data, id) {
return request({
url: `/api/workflow/operator/SendBack/${id}`,
method: 'post',
data
})
}
// 开始办理
export function Transact(data) {
return request({
url: `/api/workflow/operator/Transact`,
method: 'post',
data
})
}
// 待我审核审核
export function Audit(id, data) {
return request({
url: `/api/workflow/operator/Audit/${id}`,
method: 'post',
data,
options: {
load: true
}
})
}
// 待我审核退回
export function Reject(id, data) {
return request({
url: `/api/workflow/operator/Audit/${id}`,
method: 'post',
data
})
}
// 撤回审核
export function auditRecall(id, data) {
return request({
url: `/api/workflow/operator/Recall/${id}`,
method: 'post',
data
})
}
export function launchRecall(id, data) {
return request({
url: `/api/workflow/task/Recall/${id}`,
method: 'PUT',
data
})
}
//减签
export function addSignUserIdList(id, data) {
return request({
url: `/api/workflow/operator/AddSignUserIdList/${id}`,
method: 'POST',
data
})
}
// 驳回审核
export function cancel(id, data) {
return request({
url: `/api/workflow/Engine/FlowBefore/Cancel/${id}`,
method: 'post',
data
})
}
// 待我审核转审
export function Transfer(id, data) {
return request({
url: `/api/workflow/operator/Transfer/${id}`,
method: 'post',
data
})
}
// 审批汇总
export function getRecordList(id, data) {
return request({
url: `/api/workflow/Engine/FlowBefore/RecordList/${id}`,
method: 'get',
data
})
}
// 待我审核保存草稿
export function saveAudit(id, data) {
return request({
url: `/api/workflow/operator/SaveAudit/${id}`,
method: 'post',
data
})
}
export function saveAssist(id, data) {
return request({
url: `/api/workflow/operator/AssistSave/${id}`,
method: 'post',
data
})
}
// 判断是否有候选人
export function Candidates(id, data) {
return request({
url: `/api/workflow/operator/CandidateNode/${id}`,
method: 'post',
data
})
}
// 获取候选人列表(分页)
export function CandidateUser(id, data) {
return request({
url: `/api/workflow/operator/CandidateUser/${id}`,
method: 'post',
data
})
}
// 获取审批退回类型
export function RejectList(id) {
return request({
url: `/api/workflow/Engine/FlowBefore/RejectList/${id}`,
method: 'get'
})
}
//协办
export function Assist(id, data) {
return request({
url: `/api/workflow/operator/Assist/${id}`,
method: 'post',
data
})
}
// 加签
export function FreeApprover(id, data) {
return request({
url: `/api/workflow/operator/AddSign/${id}`,
method: 'post',
data
})
}
// 返回多个子流程信息
export function SubFlowInfo(id) {
return request({
url: `/api/workflow/Engine/FlowBefore/SubFlowInfo/${id}`,
method: 'get'
})
}
// 获取流程实例相关人员(分页)
export function getTaskUserList(taskId, data) {
return request({
url: `/api/workflow/task/TaskUserList/${taskId}`,
method: 'get',
data
})
}
// 外部节点重试
export function retryOutside(nodeId) {
return request({
url: `/api/workflow/task/Hooks/Retry/${nodeId}`,
method: 'get',
})
}

120
api/workFlow/flowEngine.js Normal file
View File

@@ -0,0 +1,120 @@
import request from '@/utils/request'
// 获取流程引擎列表
export function FlowEngineList(data) {
return request({
url: `/api/workflow/Engine/flowTemplate`,
method: 'get',
data
})
}
// 获取流程引擎信息
export function FlowEngineInfo(id) {
return request({
url: `/api/workflow/Engine/flowTemplate/${id}`,
method: 'get'
})
}
//获取流程引擎分页
export function getFlowSelector(data) {
return request({
url: `/api/workflow/template/Selector`,
method: 'get',
data,
options: {
load: true
}
})
}
//表单预览
export function flowForm(id) {
return request({
url: `/api/flowForm/Form/${id}`,
method: 'get'
})
}
// 列表ListAll
export function FlowEngineListAll() {
return request({
url: `/api/workflow/Engine/flowTemplate/ListAll`,
method: 'get',
options: {
load: false
}
})
}
// 流程引擎下拉框
export function FlowEngineSelector(type) {
return request({
url: `/api/workflow/Engine/flowTemplate/Selector`,
method: 'get',
data: {
type
}
})
}
// 获取流程评论列表
export function getCommentList(data) {
return request({
url: `/api/workflow/comment`,
method: 'get',
data
})
}
// 新建流程评论
export function createComment(data) {
return request({
url: `/api/workflow/comment`,
method: 'post',
data
})
}
// 删除流程评论
export function delComment(id) {
return request({
url: `/api/workflow/comment/${id}`,
method: 'delete'
})
}
// 委托可选全部流程
export function FlowEngineAll(data) {
return request({
url: `/api/workflow/Engine/flowTemplate/getflowAll`,
method: 'get',
data
})
}
// 获取引擎id
export function getFlowIdByCode() {
return request({
url: `/api/extend/CrmOrder`,
method: 'get'
})
}
// 获取待办未读
export function getFlowTodoCount(data) {
return request({
url: `/api/workflow/monitor/FlowTodoCount`,
method: 'post',
data
})
}
// 委托 通过list<flowId>获取流程引擎列表
export function getFlowEngineListByIds(data) {
return request({
url: `/api/workflow/template/GetFlowList`,
method: 'post',
data
})
}
// 获取流程版本Id和发起节点表单id(大流程id)
export function getFlowStartFormId(id) {
return request({
url: `/api/workflow/template/StartFormId/${id}`,
method: 'get',
})
}

View File

@@ -0,0 +1,16 @@
import request from '@/utils/request'
// 撤销
export function Revoke(id, data) {
return request({
url: `/api/workflow/task/Revoke/${id}`,
method: 'PUT',
data
})
}
// 发起催办
export function Press(id) {
return request({
url: `/api/workflow/task/Press/${id}`,
method: 'post'
})
}

65
api/workFlow/schedule.js Normal file
View File

@@ -0,0 +1,65 @@
import request from '@/utils/request'
// 获取日程安排列表
export function List(data) {
return request({
url: '/api/system/Schedule/AppList',
method: 'get',
data,
options: {
load: false
}
})
}
// 新建日程安排
export function ScheduleCreate(data) {
return request({
url: '/api/system/Schedule',
method: 'post',
data,
options: {
load: false
}
})
}
// 删除日程安排
export function ScheduleDelete(id, type) {
return request({
url: `/api/system/Schedule/${id}/${type}`,
method: 'DELETE',
options: {
load: false
}
})
}
// 获取日程安排信息
export function ScheduleInfo(id) {
return request({
url: `/api/system/Schedule/${id}`,
method: 'get',
options: {
load: false
}
})
}
// 更新日程安排
export function ScheduleUpdate(data, type) {
return request({
url: `/api/system/Schedule/${data.id}/${type}`,
method: 'PUT',
data,
options: {
load: false
}
})
}
//查看日程详情
export function ScheduleDetail(groupId, id) {
return request({
url: `/api/system/Schedule/detail?groupId=${groupId}&id=${id}`,
method: 'get',
options: {
load: false
}
})
}

49
api/workFlow/template.js Normal file
View File

@@ -0,0 +1,49 @@
import request from '@/utils/request'
// 获取发起
export function getFlowLaunchList(data) {
return request({
url: `/api/workflow/task`,
method: 'get',
data,
options: {
load: false
}
})
}
// 删除流程发起
export function delFlowLaunch(id) {
return request({
url: '/api/workflow/task/' + id,
method: 'delete',
});
}
// 获取待签
export function getOperatorList(data) {
return request({
url: `/api/workflow/operator/List/${data.category}`,
method: 'get',
data,
options: {
load: false
}
})
}
// 获取流程发起列表
// export function TreeList() {
// return request({
// url: `/api/workflow/template/TreeList`,
// method: 'get'
// })
// }
// 获取流程发起列表
// export function OperatorList() {
// return request({
// url: `api/workflow/operator/List/0`,
// method: 'get'
// })
// }

View File

@@ -0,0 +1,35 @@
import request from '@/utils/request'
// 新建表单
export function Create(data) {
return request({
url: `/api/workflow/task`,
method: 'post',
data,
options: {
load: true
}
})
}
// 修改表单
export function Update(data) {
return request({
url: `/api/workflow/task/${data.id}`,
method: 'put',
data
})
}
//通过表单id获取流程id
export function getFormById(id) {
return request({
url: `/api/flowForm/Form/getFormById/${id}`,
method: 'get'
})
}
//查看发起表单
export function getStartFormInfo(id) {
return request({
url: `/api/workflow/task/ViewStartForm/${id}`,
method: 'get'
})
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1265
assets/scss/common.scss Normal file

File diff suppressed because it is too large Load Diff

271
assets/scss/components.scss Normal file
View File

@@ -0,0 +1,271 @@
.jnpf-tree-select-popup {
height: 100%;
z-index: 9999 !important;
.jnpf-tree-select-body {
height: 100%;
display: flex;
flex-direction: column;
.jnpf-tree-select-title {
display: flex;
align-items: center;
height: 100rpx;
padding: 0 16rpx !important;
.backIcon {
font-size: 40rpx;
color: #000;
}
.title {
flex: 1;
text-align: center;
padding-right: 40rpx;
font-size: 32rpx;
}
}
.jnpf-tree-select-search {
padding: 10px 12px;
}
.jnpf-tree-selected {
width: 100%;
padding: 0 24rpx 0;
.jnpf-tree-selected-head {
width: 100%;
height: 60rpx;
display: flex;
justify-content: space-between;
.clear-btn {
color: #2979ff;
}
}
.jnpf-tree-selected-box {
width: 100%;
display: flex;
justify-content: center;
border-radius: 8rpx;
border: 1rpx dashed #c0c4cc;
margin-top: 10rpx;
.select-list {
height: 150rpx;
max-height: 150rpx;
justify-content: flex-start;
flex-wrap: wrap;
.u-selectTag {
margin-bottom: 10rpx;
margin-left: 10rpx;
}
}
.jnpf-tree-selected-list{
display: flex;
justify-content: flex-start;
flex-wrap: wrap;
padding-top: 10rpx;
.u-selectTag {
width: 310rpx;
border: 1px solid #2194fa;
background-color: #e8f4fe;
line-height: 40rpx;
margin: 10rpx;
padding-left: 10rpx;
display: flex;
align-items: center;
border-radius: 8rpx;
&.u-selectTag-flow{
.jnpf-tree-selected-content{
width: 100%;
margin-left: 0;
}
}
.jnpf-tree-selected-content {
width: 74%;
margin-left: 10rpx;
.name-box{
color: #353535;
display: flex;
.name {
flex: 1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.close {
width: 26px;
padding-right: 8rpx;
justify-content: flex-end;
color: #2194fa;
}
}
.organize {
color: #a0a1a1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis
}
}
}
}
.user-select-list{
max-height: 240rpx;
display: flex;
justify-content: flex-start;
flex-wrap: wrap;
padding-top: 10rpx;
}
}
}
.jnpf-tree-selected-line{
height: 20rpx;
background-color: #eaecf0;
margin-top: 8rpx;
}
.jnpf-tree-selected-tabs{
height: 70rpx;
padding: 0 20rpx;
border-bottom: 1rpx solid #e4e4e7;
display: flex;
align-items: center;
.tab-item{
line-height: 66rpx;
margin-right: 30rpx;
border-bottom: 4rpx solid transparent;
&.tab-item-active{
z-index: 1;
color: #2979ff;
border-bottom: 4rpx solid #2979ff;
}
}
}
.jnpf-tree-selected-breadcrumb{
height: 70rpx;
padding: 0 20rpx;
background-color: #eaecf0;
display: flex;
align-items: center;
.breadcrumb-item{
margin-right: 10rpx;
&.icon-ym{
font-size: 20rpx;
margin-right: 10rpx;
color: #a0a1a1;
}
&.breadcrumb-item-active{
color: #2979ff;
}
}
}
.jnpf-tree-select-tree {
flex: 1;
overflow: auto;
.ly-tree{
padding: 0 20rpx 20rpx;
}
.list-box{
height: 100%;
.list-item{
display: flex;
width: 100%;
padding: 0 10px;
box-sizing: border-box;
.radio-label{
display: flex;
width: 100%;
}
.list-item-content{
flex: 1;
}
}
}
.jnpf-selcet-list{
padding: 0 20rpx;
}
.jnpf-selcet-cell{
height: 70rpx;
border-bottom: 1rpx solid #e4e4e7;
display: flex;
align-items: center;
.jnpf-selcet-cell-action{
height: 70rpx;
display: flex;
align-items: center;
position: relative;
margin-right: 16rpx;
flex-shrink: 0;
.ly-radio,
.ly-checkbox{
padding-right: 0;
}
&::after {
position: absolute;
display: block;
content: '';
left: 0;
top: 0;
height: 100%;
width: 100%;
z-index: 1;
}
}
.jnpf-selcet-cell-avatar{
margin-right: 10rpx;
}
.jnpf-selcet-cell-icon{
margin-right: 10rpx;
}
.jnpf-selcet-cell-name{
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
}
}
.nodata {
height: 100%;
margin: auto;
align-items: center;
justify-content: center;
color: #909399;
}
.jnpf-date-range {
width: 100%;
display: flex;
.u-input__input {
text-align: center !important;
}
}
.jnpf-bottom-actions,
.jnpf-tree-select-actions {
background-color: #fff;
display: flex;
width: 100%;
height: 88rpx;
box-shadow: 0 -2rpx 8rpx #e1e5ec;
z-index: 999999;
flex-shrink: 0;
.buttom-btn {
width: 100%;
/* #ifndef MP */
height: 88rpx !important;
line-height: 88rpx !important;
border-radius: 0 !important;
&::after {
border: none !important;
}
/* #endif */
/* #ifdef MP */
.u-btn {
width: 100%;
height: 88rpx !important;
line-height: 88rpx !important;
border-radius: 0 !important;
&::after {
border: none !important;
}
}
/* #endif */
}
}

View File

@@ -0,0 +1,204 @@
<template>
<view class="card">
<view class="card-content">
<view class="card-tabs u-flex">
<view class="u-flex card-left">
<view class="card-title">{{title}}</view>
<u-tabs :list="tabList" :is-scroll="true" v-model="current" @change="tabChange"
inactive-color="#666" font-size="28"></u-tabs>
</view>
<view @click="openPage" class="morebtn">更多<u-icon name="arrow-right" class="u-p-r-10"
color="#666"></u-icon></view>
</view>
<view class="card-item">
<view class="item u-flex-col" v-for="(item,index) in cardData" :key="index" @click="clickItem(item)">
<view class="item-icon" :class="item.icon"
:style="{ background: item.iconBackground || '#008cff' }"></view>
<view class="item-title u-m-t-8">{{item.fullName}}</view>
</view>
<view v-if="showAdd" class="item u-flex-col u-col-center" @click="add">
<text class="u-font-40 item-icon more">+</text>
<text class="u-m-t-8 item-title">添加</text>
</view>
</view>
<JnpfEmpty v-if="!cardData.length && type != 'collect' "></JnpfEmpty>
</view>
</view>
</template>
<script>
export default {
props: {
title: {
type: String,
default: "我的收藏"
},
menuList: {
type: Array,
default: () => []
},
flowList: {
type: Array,
default: () => []
},
showAdd: {
type: Boolean,
default: false
},
type: {
type: String,
default: "collect"
},
flowEnabled: {
type: Boolean,
default: false
}
},
data() {
return {
tabList: [{
name: '应用功能',
type: 'menu'
}],
current: 0,
cardData: [],
userInfo: {}
}
},
computed: {
tabType() {
return this.tabList[this.current].type
}
},
watch: {
menuList: {
handler(val) {
if (this.current != 0) this.cardData = this.flowList
},
immediate: true
},
flowList: {
handler(val) {
if (this.current == 0) this.cardData = this.menuList
},
immediate: true
}
},
created() {
this.userInfo = uni.getStorageSync('userInfo') || {}
this.handleTabList()
},
methods: {
handleTabList() {
if (this.flowEnabled) {
this.tabList.push({
name: '发起审批',
type: 'flow'
})
}
},
tabChange(index) {
this.current = index;
if (this.tabType === 'menu') this.cardData = this.menuList
if (this.tabType === 'flow') this.cardData = this.flowList
},
clickItem(item) {
this.$emit('launch', {
...item,
tabType: this.tabType
})
},
openPage() {
let url;
if (this.type === 'collect') {
url = this.tabType === 'menu' ? '/pages/commonPage/morePage/index?type=2' :
'/pages/commonPage/morePage/index?type=1'
} else {
url = this.tabType === 'menu' ? '/pages/apply/menu/index' : '/pages/workFlow/workFlow/index'
}
this.$emit('openPage', url)
},
add() {
let url = this.tabType === 'menu' ? '/pages/apply/allAppApply/index' :
'/pages/workFlow/allAppWorkFlow/index'
this.$emit('addApp', url)
}
}
}
</script>
<style lang="scss">
.card {
margin-top: 20rpx;
&-title {
padding: 0 20rpx;
color: #303133;
font-size: 36rpx;
margin-bottom: 10rpx;
font-weight: 500;
}
&-content {
width: 100%;
height: 100%;
background-color: #fff;
.card-tabs {
width: 100%;
justify-content: space-between;
.card-left {}
.morebtn {
color: #666;
}
}
.card-item {
width: 100%;
display: flex;
flex-wrap: wrap;
flex-direction: row;
.item {
width: 25%;
padding: 10px;
justify-content: center;
align-items: center;
padding: 30rpx 0;
.item-icon {
width: 50px;
height: 50px;
text-align: center;
line-height: 50px;
color: #fff;
border-radius: 18px;
font-size: 24px;
background-color: #f0f2f6;
&:before {
margin-left: 4rpx;
}
}
.more {
background: #ececec;
color: #666;
font-size: 1.5625rem;
}
.item-title {
width: 92px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: center;
font-size: 24rpx;
}
}
}
}
}
</style>

View File

@@ -0,0 +1,168 @@
<template>
<view class="commonTabs-v">
<view class="icon-ym u-tabs-box" v-if="list.length" :class="{'boxShadow':isBoxShadow}">
<view class="apply-tabs">
<u-tabs :list="list" v-model="tabCurrent" @change="change" :is-scroll="isScroll" :name="prop"
:height="height">
</u-tabs>
</view>
<view class="more-icon" :class="icon" @click="iconClick "></view>
</view>
<u-popup v-model="showPopup" mode="bottom" closeable close-icon-color="#666666">
<view class="classifyTitle">
全部分类
</view>
<scroll-view scroll-y="true" :style="{'height':scrollHeight+'rpx'}">
<view class="classify-scroll-view u-flex">
<view v-for="(item,index) in list" :key="index" @click="classifyItem(index)"
class="classify-item u-font-28 u-line-1">
{{item.fullName}}
</view>
</view>
</scroll-view>
</u-popup>
</view>
</template>
<script>
export default {
props: {
list: {
type: Array,
default: () => []
},
current: {
type: Number,
default: 0
},
scrollHeight: {
type: String,
default: '360'
},
prop: {
type: String,
default: 'fullName'
},
icon: {
type: String,
default: 'icon-ym icon-ym-app-more'
},
height: {
type: String,
default: '84'
},
type: {
type: String,
default: 'flow'
},
isBoxShadow: {
type: Boolean,
default: false
},
isScroll: {
type: Boolean,
default: true
}
},
data() {
return {
tabCurrent: 0,
showPopup: false,
categoryList: []
}
},
watch: {
current: {
handler(val) {
this.tabCurrent = val
},
immediate: true
}
},
methods: {
classifyItem(index) {
this.change(index)
},
iconClick() {
if (this.type != 'flow') return this.$emit('iconClick');
this.showPopup = true
},
change(e) {
this.tabCurrent = e;
this.showPopup = false;
this.$emit('change', e);
}
}
}
</script>
<style lang="scss">
.commonTabs-v {
.boxShadow {
box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);
}
.u-tabs-box {
position: relative;
.apply-tabs {
width: 94%;
.u-tabs {
height: 2.75rem;
}
}
.more-icon {
position: absolute;
top: 0;
right: 0;
/* #ifdef MP */
height: 85rpx;
line-height: 85rpx;
/* #endif */
/* #ifndef MP */
height: 88rpx;
line-height: 88rpx;
/* #endif */
text-align: center;
padding: 0 16rpx;
background-color: #fff;
opacity: 0.9;
box-shadow: 0px 0px 30rpx 8rpx rgba(243, 243, 243, 0.8);
}
}
.classifyTitle {
font-family: PingFang SC;
height: 110rpx;
width: 100%;
line-height: 110rpx;
padding-left: 20rpx;
padding-right: 20rpx;
font-size: 32rpx;
color: #333333;
font-weight: 500;
}
.classify-scroll-view {
padding-bottom: 70rpx;
padding: 0 20rpx 64rpx;
justify-content: flex-start;
flex-wrap: wrap;
.classify-item {
width: 22%;
text-align: center;
margin: 10rpx;
background-color: #EEF0F4;
border-radius: 8rpx;
background: rgba(238, 240, 244, 0.39);
color: #666666;
line-height: 58rpx;
padding: 0 20rpx;
}
}
}
</style>

View File

@@ -0,0 +1,53 @@
<template>
<view class="u-flex-col buttom-btn-left-inner" @click.stop="handleClick"
:class="btnType === 'reject' ? 'reject' : ''">
<u-icon v-if="customIcon" :name="iconName" :size="size" :custom-prefix="btnIcon"></u-icon>
<u-icon v-else :name="iconName" :size="size"></u-icon>
<text>{{btnText}}</text>
</view>
</template>
<script>
export default {
props: {
btnLoading: {
type: Boolean,
default: false
},
customIcon: {
type: Boolean,
default: false
},
btnText: {
type: String,
default: ''
},
btnIcon: {
type: String,
default: 'icon-ym icon-ym-add-cancel'
},
btnType: {
type: String,
default: 'cancel'
},
iconName: {
type: String,
default: 'icon-ym'
},
size: {
type: [Number, String],
default: 24
}
},
methods: {
handleClick() {
if (this.btnType === 'cancel') return this.jnpf.goBack()
if (this.btnType === 'more') return this.$emit('handleBtn', this.btnLoading ? false : true)
if (this.btnType === 'save' || this.btnType === 'reject') return this.$emit('handleBtn')
}
}
}
</script>
<style>
</style>

View File

@@ -0,0 +1,59 @@
<template>
<u-alert-tips class="jnpf-alert" :type="type" :title="title" :show-icon="showIcon" :description="description"
:close-able="closable" :close-text="closeText" @close="show=false" :show="show" :title-style="titleStyle"
:desc-style="descStyle" />
</template>
<script>
export default {
name: 'jnpf-alert',
props: {
type: {
type: String,
default: 'success'
},
title: {
type: String,
default: '这是一个提示'
},
tagIcon: {
type: String,
default: 'icon-ym icon-ym-generator-alert'
},
showIcon: {
type: Boolean,
default: false
},
closable: {
type: Boolean,
default: false
},
description: {
type: String,
default: ''
},
closeText: {
type: String,
default: ''
}
},
data() {
return {
show: true,
titleStyle: {
'word-break': 'break-all',
'line-height': '34rpx'
},
descStyle: {
'word-break': 'break-all',
'line-height': '40rpx',
},
}
}
}
</script>
<style lang="scss">
.jnpf-alert {
width: 100%;
min-height: 72rpx;
}
</style>

View File

@@ -0,0 +1,242 @@
<template>
<u-popup class="jnpf-tree-select-popup" :maskCloseAble="maskCloseAble" mode="right" v-model="showPopup"
:safeAreaInsetBottom="safeAreaInsetBottom" @close="close" :z-index="uZIndex" width="100%">
<view class="jnpf-tree-select-body">
<view class="jnpf-tree-select-title">
<text class="icon-ym icon-ym-report-icon-preview-pagePre backIcon" @tap="close()"></text>
<view class="title">省市区</view>
</view>
<view class="jnpf-tree-selected">
<view class="jnpf-tree-selected-head">
<view>{{$t('component.jnpf.common.selected')}}({{selectList.length||0}})</view>
<view v-if="multiple" class="clear-btn" @click="setCheckAll">
{{$t('component.jnpf.common.clearAll')}}
</view>
</view>
<view class="jnpf-tree-selected-box">
<scroll-view scroll-y="true" class="select-list">
<u-tag closeable @close="delSelect(index)" v-for="(item,index) in selectList" :key="index"
:text="item" class="u-selectTag" />
</scroll-view>
</view>
</view>
<view class="jnpf-tree-selected-line"></view>
<view class="jnpf-tree-select-tree">
<scroll-view :scroll-y="true" style="height: 100%">
<ly-tree ref="tree" :node-key="realProps.value" :tree-data="options" :show-checkbox="false"
:defaultExpandAll='false' @node-click="handleNodeClick" :props="realProps"
:show-node-icon="true" :show-radio="false" :load="loadNode" lazy />
</scroll-view>
</view>
<!-- 底部按钮 -->
<view class="jnpf-tree-select-actions">
<u-button class="buttom-btn" @click="close()">{{$t('common.cancelText')}}</u-button>
<u-button class="buttom-btn" type="primary"
@click.stop="handleConfirm()">{{$t('common.okText')}}</u-button>
</view>
</view>
</u-popup>
</template>
<script>
const defaultProps = {
label: 'fullName',
value: 'id',
icon: 'icon',
children: 'children'
}
var _self;
import {
getProvinceSelector
} from '@/api/common.js'
export default {
name: "tree-select",
props: {
selectedData: {
type: Array,
default () {
return [];
}
},
ids: {
type: Array,
default () {
return [];
}
},
// 是否显示边框
border: {
type: Boolean,
default: true
},
// 通过双向绑定控制组件的弹出与收起
modelValue: {
type: Boolean,
default: false
},
// "取消"按钮的颜色
cancelColor: {
type: String,
default: '#606266'
},
// "确定"按钮的颜色
confirmColor: {
type: String,
default: '#2979ff'
},
// 弹出的z-index值
zIndex: {
type: [String, Number],
default: 99999
},
safeAreaInsetBottom: {
type: Boolean,
default: false
},
// 是否允许通过点击遮罩关闭Picker
maskCloseAble: {
type: Boolean,
default: true
},
props: {
type: Object,
default: () => ({
label: 'fullName',
value: 'id',
icon: 'icon',
children: 'children',
isLeaf: 'isLeaf'
})
},
multiple: {
type: Boolean,
default: false
},
// 顶部标题
title: {
type: String,
default: ''
},
// 取消按钮的文字
cancelText: {
type: String,
default: '取消'
},
// 确认按钮的文字
confirmText: {
type: String,
default: '确认'
},
level: {
type: Number,
default: 2
}
},
data() {
return {
moving: false,
selectList: [],
selectListId: [],
newListId: [],
options: [],
selectData: []
};
},
watch: {
// 在select弹起的时候重新初始化所有数据
modelValue: {
immediate: true,
handler(val) {
this.showPopup = val
if (val) setTimeout(() => this.init(), 10);
}
},
},
created() {
_self = this
this.init()
},
computed: {
uZIndex() {
// 如果用户有传递z-index值优先使用
return this.zIndex ? this.zIndex : this.$u.zIndex.popup;
},
realProps() {
return {
...defaultProps,
...this.props
}
}
},
methods: {
init() {
this.selectList = JSON.parse(JSON.stringify(this.selectedData))
this.selectListId = !!this.ids ? this.ids : []
},
loadNode(node, resolve) {
let id = node.key === null ? -1 : node.key
let level = node.level
getProvinceSelector(id).then(res => {
const list = res.data.list.map((value, i) => ({
id: value.id,
fullName: value.fullName,
isLeaf: level >= _self.level ? true : value.isLeaf
}));
resolve(list)
})
},
handleNodeClick(obj) {
if (!obj.isLeaf) return
let getNodePath = this.$refs.tree.getNodePath(obj)
let list = []
let listId = []
let selectList = []
for (let i = 0; i < getNodePath.length; i++) {
list.push(getNodePath[i].fullName)
listId.push(getNodePath[i].id)
let obj = {
fullName: getNodePath[i].fullName,
id: getNodePath[i].id
}
selectList.push(obj)
}
if (listId.length !== this.level + 1) return;
if (!this.multiple) {
this.selectList = [];
this.selectListId = [];
this.selectData = [];
}
var isExist = false;
for (var i = 0; i < this.selectList.length; i++) {
if (this.selectList[i] == list.join('/')) {
isExist = true;
break;
}
};
!isExist && this.selectListId.push(listId);
!isExist && this.selectList.push(list.join('/'));
!isExist && this.selectData.push(selectList);
},
delSelect(index) {
this.selectList.splice(index, 1);
if (!this.multiple) {
this.selectListId = [];
this.selectData = []
}
this.selectListId.splice(index, 1);
},
setCheckAll() {
this.selectList = [];
this.selectListId = [];
this.$refs.tree.setCheckAll(false);
},
handleConfirm() {
this.$emit('confirm', this.selectList, this.selectListId, this.selectData);
this.close();
},
close() {
this.$emit('close');
}
}
};
</script>

View File

@@ -0,0 +1,113 @@
<template>
<view class="jnpf-area-select">
<selectBox v-model="innerValue" :disabled='disabled' :placeholder="placeholder" @openSelect="openSelect"
:select-open="selectShow" >
</selectBox>
<Tree v-if="selectShow" v-model="selectShow" :multiple="multiple" :props="props" :selectedData="selectedData"
:level='level' :ids='modelValue' @confirm="handleConfirm" @close="handleClose()" />
</view>
</template>
<script>
import Tree from './Tree.vue';
import selectBox from '@/components/selectBox'
import {
getProvinceSelectorInfoList
} from '@/api/common.js'
export default {
name: 'jnpf-area-select',
components: {
Tree,
selectBox
},
props: {
modelValue: {
default: ''
},
placeholder: {
type: String,
default: '请选择'
},
props: {
type: Object,
default: () => ({
label: 'fullName',
value: 'id',
children: 'children',
isLeaf: 'isLeaf'
})
},
disabled: {
type: Boolean,
default: false
},
multiple: {
type: Boolean,
default: false
},
level: {
type: Number,
default: 2
}
},
watch: {
modelValue: {
handler(val) {
this.setDefault(val)
},
immediate: true
}
},
data() {
return {
selectShow: false,
innerValue: '',
selectedData: []
}
},
methods: {
setDefault(id) {
this.innerValue = ''
this.selectedData = []
if (!Array.isArray(id) || id.length === 0) return
if (!this.multiple) id = [id]
getProvinceSelectorInfoList(id).then(res => {
const list = res.data
let txt = ''
for (let i = 0; i < list.length; i++) {
txt += (i ? ',' : '') + list[i].join('/')
this.selectedData.push(list[i].join('/'))
}
this.innerValue = txt
})
},
openSelect() {
if (this.disabled) return
this.selectShow = true
},
handleClose() {
this.selectShow = false
},
handleConfirm(e, selectId, selectData) {
this.selectedData = e;
let label = '';
let value = [];
this.defaultValue = value
this.innerValue = e.join()
if (!this.multiple) {
this.$emit('update:modelValue', selectId[0])
this.$emit('change', selectId[0], selectData)
} else {
this.$emit('update:modelValue', selectId)
this.$emit('change', selectId, selectData)
}
},
}
}
</script>
<style lang="scss" scoped>
.jnpf-area-select {
width: 100%;
}
</style>

View File

@@ -0,0 +1,203 @@
<template>
<view class="search-popup-v">
<u-popup v-model="showPopup" width="100%" height="100vh" mode="right" :mask="false" @close="close">
<view class="search-popup-b">
<view class="search-popup-h">
<view class="search-popup-h-txt">
<u-icon name="close" @click="showPopup=false" class="search-popup-h-icon" />
</view>
<u-input type="text" v-model="value" placeholder="请输入" @input="onInput" :clearable="clearable" />
</view>
</view>
<view class="search-popup-item" v-if="showList.length>0">
<view v-for="(item, index) in showList" :key="index" @tap="selectThisItem(item)"
class="u-p-l-20 u-p-r-20">{{item[relationField]}}</view>
</view>
<JnpfEmpty v-if="showList.length<1"></JnpfEmpty>
</u-popup>
</view>
</template>
<script>
import {
getPopSelect
} from '@/api/common.js'
export default {
props: {
interfaceId: {
type: String,
default: ''
},
clearable: {
type: Boolean,
default: true
},
relationField: {
type: String,
default: 'fullName'
},
total: {
type: [String, Number],
default: 50
},
formData: {
type: Object
},
templateJson: {
type: Array,
default: () => []
},
rowIndex: {
default: null
},
},
data() {
return {
istQuery: {
keyword: '',
pageSize: 1000
},
showPopup: false,
value: '',
showList: [],
timer: ''
}
},
methods: {
init(val) {
this.showPopup = true
this.value = val
this.getDataInterfaceList()
},
getDataInterfaceList() {
this.showList = []
const paramList = this.getParamList()
let query = {
interfaceId: this.interfaceId,
relationField: this.relationField,
pageSize: 10000,
paramList
}
getPopSelect(this.interfaceId, query).then(res => {
let list = JSON.parse(JSON.stringify(res.data.list)) || []
if (list.length) list = this.unique(list, this.relationField)
this.showList = list.splice(0, this.total)
})
},
unique(arr, attrName) {
const res = new Map();
// 根据对象的某个属性值去重
return arr.filter(o => !res.has(o[attrName]) && res.set(o[attrName], 1));
},
getParamList() {
let templateJson = this.templateJson
for (let i = 0; i < templateJson.length; i++) {
if (templateJson[i].relationField && this.formData && templateJson[i].sourceType == 1) {
if (templateJson[i].relationField.includes('-')) {
let tableVModel = templateJson[i].relationField.split('-')[0]
let childVModel = templateJson[i].relationField.split('-')[1]
templateJson[i].defaultValue = this.formData[tableVModel] && this.formData[tableVModel][this
.rowIndex
] && this.formData[tableVModel][this.rowIndex][childVModel] || ''
} else {
templateJson[i].defaultValue = this.formData[templateJson[i].relationField] || ''
}
}
if (templateJson[i].relationField == '@keyword') templateJson[i].defaultValue = this.value
}
return templateJson
},
onInput(e) {
this.value = e
this.$emit('confirm', this.value);
this.timer && clearTimeout(this.timer);
this.timer = setTimeout(() => {
this.list = [];
this.getDataInterfaceList()
}, 300);
},
close() {
this.showPopup = false
},
selectThisItem(item) {
this.value = item[this.relationField];
this.$emit('confirm', this.value);
this.close()
}
}
}
</script>
<style lang="scss">
.search-popup-v {
.search-popup-b {
height: 158rpx;
.search-popup-h {
padding: 0 20rpx;
border-bottom: 1rpx solid #cbcbcb;
position: fixed;
width: 100%;
background-color: #fff;
z-index: 9;
text-align: center;
.search-popup-h-txt {
height: 86rpx;
width: 100%;
padding: 15rpx 0;
text-align: center;
line-height: 54rpx;
box-sizing: border-box;
font-size: 32rpx;
font-weight: 700;
letter-spacing: 2rpx;
.search-popup-h-icon {
float: right;
margin-top: 12rpx;
}
}
}
}
.search-popup-item {
width: 100%;
height: 100%;
z-index: 9997;
}
.search-notData {
width: 100%;
height: calc(100% - 160rpx);
background-color: #fff;
.notData-box {
width: 100%;
height: 100%;
justify-content: center;
align-items: center;
.notData-inner {
width: 280rpx;
height: 340rpx;
align-items: center;
.iconImg {
width: 100%;
height: 100%;
}
.notData-inner-text {
padding: 30rpx 0;
color: #909399;
}
}
}
}
}
</style>

View File

@@ -0,0 +1,139 @@
<template>
<view class="jnpf-auto-complete">
<selectBox v-model="innerValue" :disabled='disabled' :placeholder="placeholder" @openSelect="showSearch"
>
</selectBox>
<SearchForm ref="searchForm" :interfaceId="interfaceId" :relationField="relationField"
:templateJson="templateJson" @confirm="confirm" :total="total || 50" :formData="formData"
:clearable="clearable" :rowIndex="rowIndex" />
</view>
</template>
<script>
import SearchForm from './SearchForm';
import selectBox from '@/components/selectBox'
export default {
name: 'jnpf-auto-complete',
components: {
SearchForm,
selectBox
},
props: {
modelValue: {
default: ''
},
formData: {
type: Object
},
options: {
type: Array,
default: () => []
},
placeholder: {
type: String,
default: '请输入'
},
clearable: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
templateJson: {
type: Array,
default: () => []
},
interfaceId: {
type: String,
default: ''
},
relationField: {
type: String,
default: 'fullName'
},
total: {
type: Number,
default: 50
},
rowIndex: {
default: null
}
},
data() {
return {
innerValue: ''
}
},
watch: {
modelValue: {
handler(val) {
this.innerValue = val || ''
},
immediate: true
}
},
methods: {
showSearch() {
if (this.disabled) return
this.$nextTick(() => {
this.$refs.searchForm.init(this.innerValue)
})
},
confirm(e) {
this.innerValue = e
this.$emit('update:modelValue', e);
this.$emit('change', e);
}
}
}
</script>
<style lang="scss">
.jnpf-auto-complete {
width: 100%;
.str-auto-complete-container {
width: 549rpx;
height: 360px;
border-radius: 8rpx;
box-shadow: 0rpx 0rpx 12rpx #dfe3e9;
position: absolute;
z-index: 9997;
background: #fff;
top: 94rpx;
left: 0;
right: 0;
overflow-y: scroll;
.str-auto-complete-mask {
width: 100%;
height: calc(100% - 90rpx);
position: fixed;
left: 0;
top: 0;
bottom: 0;
right: 0;
z-index: 9999;
}
.str-auto-complete-item {
position: relative;
padding: 10rpx;
z-index: 9999
}
}
.auto-complete-b {
width: 549rpx;
height: 360px;
z-index: 999;
position: absolute;
background-color: #fff;
border: 1px solid red;
top: 94rpx;
left: 0;
right: 0;
}
}
</style>

View File

@@ -0,0 +1,116 @@
<template>
<tki-barcode class="jnpf-barcode" v-if="barcode&&showBarCode" ref="barcode" :format="format" :cid="cid"
:val="barcode" :opations="opations" loadMake :key="key" />
</template>
<script>
import tkiBarcode from "./tki-barcode/tki-barcode.vue"
let unique = 0
export default {
name: 'jnpf-barcode',
props: {
dataType: {
type: String,
default: 'static'
},
format: {
type: String,
default: 'code128'
},
lineColor: {
type: String,
default: '#000'
},
background: {
type: String,
default: '#fff'
},
relationField: {
type: String,
default: ''
},
formData: {
type: Object
},
width: {
type: Number,
default: 4
},
height: {
type: Number,
default: 40
},
staticText: {
type: String,
default: ''
}
},
components: {
tkiBarcode
},
data() {
return {
cid: '',
relationText: "",
showBarCode: false,
key: +new Date()
}
},
computed: {
barcode() {
return this.dataType === 'static' ? this.staticText : this.relationText?.toString()
},
opations() {
return {
format: this.format,
width: this.width,
height: this.height,
displayValue: false,
lineColor: this.lineColor,
background: this.background,
}
}
},
created() {
this.cid = this.uuid()
this.showBarCode = true
uni.$on('updateCode', () => {
this.showBarCode = false
this.$nextTick(() => {
this.showBarCode = true
})
})
},
watch: {
formData: {
handler: function(val) {
if (val && this.dataType === 'relation' && this.relationField) {
if (this.relationText != val[this.relationField]) {
this.relationText = val[this.relationField]
setTimeout(() => {
this.key = +new Date()
}, 50)
}
}
},
deep: true,
immediate: true
},
},
methods: {
uuid() {
const time = Date.now()
const random = Math.floor(Math.random() * 1000000000)
unique++
return 'barcode_' + random + unique + String(time)
}
},
}
</script>
<style lang="scss" scoped>
.jnpf-barcode {
width: 100%;
overflow: hidden;
margin-bottom: -20rpx;
}
</style>

View File

@@ -0,0 +1,212 @@
import barcodes from './barcodes/index.js'
let barcode = {};
(function() {
// 初始化
barcode = function(cont, ctxid, options, ctxsize, result) {
let ops = {},
newOptions, encodings, globaContext, ctx, globaCtxid, cbCanvasSize, cbResult;
globaCtxid = ctxid
cbCanvasSize = ctxsize
cbResult = result
newOptions = Object.assign(ops, options);
// 修成margin
fixMargin(newOptions)
// 处理options 数据
if (newOptions.text == '' || !cont) {
return false
}
// 获取ctx
globaContext = cont
ctx = uni.createCanvasContext(globaCtxid, globaContext)
// 获取编码数据
encodings = new barcodes[newOptions.format.toUpperCase()](newOptions.text, newOptions).encode()
let fixencodings = fixEncodings(encodings, newOptions)
// 返回canvas实际大小
cbCanvasSize({
width: fixencodings.width,
height: fixencodings.height
})
// 绘制canvas
setTimeout(() => {
drawCanvas.render(newOptions, fixencodings)
}, 50);
// 绘制canvas
let drawCanvas = {
render(options, encoding) {
this.prepare(options, encoding)
encoding.encodings.forEach((v, i) => {
this.barcode(options, v)
this.text(options, v)
this.move(v)
});
this.draw(options, encoding)
},
barcode(options, encoding) {
let binary = encoding.data;
let yFrom;
if (options.textPosition == "top") {
yFrom = options.marginTop + options.fontSize + options.textMargin;
} else {
yFrom = options.marginTop;
}
// 绘制条码
ctx.fillStyle = options.lineColor;
for (let b = 0; b < binary.length; b++) {
let x = b * options.width + encoding.barcodePadding;
let height = options.height
if (encoding.options) {
if (encoding.options.height != undefined) {
height = encoding.options.height
}
}
if (binary[b] === "1") {
ctx.fillRect(x, yFrom, options.width, height);
} else if (binary[b]) {
ctx.fillRect(x, yFrom, options.width, height * binary[b]);
}
}
},
text(options, encoding) {
if (options.displayValue) {
let x, y, align, size;
if (options.textPosition == "top") {
y = options.marginTop + options.fontSize;
} else {
y = options.height + options.textMargin + options.marginTop + options.fontSize;
}
if (encoding.options) {
if (encoding.options.textAlign != undefined) {
align = encoding.options.textAlign
}
if (encoding.options.fontSize != undefined) {
size = encoding.options.fontSize
}
} else {
align = options.textAlign
size = options.fontSize
}
ctx.setFontSize(size)
if (align == "left" || encoding.barcodePadding > 0) {
x = 0;
ctx.setTextAlign('left')
} else if (align == "right") {
x = encoding.width - 1;
ctx.setTextAlign('right')
} else {
x = encoding.width / 2;
ctx.setTextAlign('center');
}
ctx.fillStyle = options.fontColor;
if (encoding.text != undefined) {
ctx.fillText(encoding.text, x, y);
}
}
},
move(encoding) {
ctx.translate(encoding.width, 0);
},
prepare(options, encoding) {
// 绘制背景
if (options.background) {
ctx.fillStyle = options.background;
ctx.fillRect(0, 0, encoding.width, encoding.height);
}
ctx.translate(options.marginLeft, 0);
},
draw(options, encoding) {
ctx.draw(false, () => {
this.toImgs(options, encoding)
})
},
toImgs(options, encoding) {
setTimeout(() => {
try {
uni.canvasToTempFilePath({
width: encoding.width,
height: encoding.height,
destWidth: encoding.width,
destHeight: encoding.height,
canvasId: globaCtxid,
fileType: 'png',
success: function(res) {
cbResult(res.tempFilePath)
},
fail: function(res) {
cbResult(res)
},
complete: function() {
uni.hideLoading();
},
}, globaContext);
} catch (e) {
//TODO handle the exception
}
}, options.text.length + 100);
}
}
// 混入canvas数据
function fixEncodings(encoding, options) {
let encodingArr = [],
width = options.marginLeft + options.marginRight,
height;
if (!Array.isArray(encoding)) {
encodingArr[0] = JSON.parse(JSON.stringify(encoding))
} else {
encodingArr = [...encoding]
}
encodingArr.forEach((v, i) => {
// 获取文本宽度
let textWidth = ctx.measureText(encodingArr[i].text ? encodingArr[i].text : '').width;
// 获取条形码宽度
let barcodeWidth = encodingArr[i].data.length * options.width;
// 获取内边距
let barcodePadding = 0;
if (options.displayValue && barcodeWidth < textWidth) {
if (options.textAlign == "center") {
barcodePadding = Math.floor((textWidth - barcodeWidth) / 2);
} else if (options.textAlign == "left") {
barcodePadding = 0;
} else if (options.textAlign == "right") {
barcodePadding = Math.floor(textWidth - barcodeWidth);
}
}
// 混入encodingArr[i]
encodingArr[i].barcodePadding = barcodePadding
encodingArr[i].width = Math.ceil(Math.max(textWidth, barcodeWidth))
width += encodingArr[i].width
if (encodingArr[i].options) {
if (encodingArr[i].options.height != undefined) {
encodingArr[i].height = encodingArr[i].options.height + (options.displayValue &&
(encodingArr[i].text ? encodingArr[i].text : '').length > 0 ? options
.fontSize + options.textMargin : 0) + options.marginTop + options
.marginBottom;
} else {
encodingArr[i].height = height = options.height + (options.displayValue && (
encodingArr[i].text ? encodingArr[i].text : '').length > 0 ? options
.fontSize + options.textMargin : 0) + options.marginTop + options
.marginBottom;
}
} else {
encodingArr[i].height = height = options.height + (options.displayValue && (
encodingArr[i].text ? encodingArr[i].text : '').length > 0 ? options
.fontSize + options.textMargin : 0) + options.marginTop + options
.marginBottom;
}
});
return {
encodings: encodingArr,
width,
height
};
}
// 修正Margin
function fixMargin(options) {
options.marginTop = options.marginTop == undefined ? options.margin : options.marginTop;
options.marginBottom = options.marginBottom == undefined ? options.margin : options.marginBottom;
options.marginRight = options.marginRight == undefined ? options.margin : options.marginRight;
options.marginLeft = options.marginLeft == undefined ? options.margin : options.marginLeft;
}
};
})()
export default barcode

View File

@@ -0,0 +1,19 @@
"use strict";
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
var Barcode = function Barcode(data, options) {
_classCallCheck(this, Barcode);
this.data = data;
this.text = options.text || data;
this.options = options;
};
export default Barcode

View File

@@ -0,0 +1,208 @@
'use strict';
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
import _Barcode3 from '../Barcode.js'
import _constants from './constants'
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
}
// This is the master class,
// it does require the start code to be included in the string
var CODE128 = function(_Barcode) {
_inherits(CODE128, _Barcode);
function CODE128(data, options) {
_classCallCheck(this, CODE128);
// Get array of ascii codes from data
var _this = _possibleConstructorReturn(this, (CODE128.__proto__ || Object.getPrototypeOf(CODE128)).call(
this, data.substring(1), options));
_this.bytes = data.split('').map(function(char) {
return char.charCodeAt(0);
});
return _this;
}
_createClass(CODE128, [{
key: 'valid',
value: function valid() {
// ASCII value ranges 0-127, 200-211
return (/^[\x00-\x7F\xC8-\xD3]+$/.test(this.data));
}
// The public encoding function
}, {
key: 'encode',
value: function encode() {
var bytes = this.bytes;
// Remove the start code from the bytes and set its index
var startIndex = bytes.shift() - 105;
// Get start set by index
var startSet = _constants.SET_BY_CODE[startIndex];
if (startSet === undefined) {
throw new RangeError('The encoding does not start with a start character.');
}
if (this.shouldEncodeAsEan128() === true) {
bytes.unshift(_constants.FNC1);
}
// Start encode with the right type
var encodingResult = CODE128.next(bytes, 1, startSet);
return {
text: this.text === this.data ? this.text.replace(/[^\x20-\x7E]/g, '') : this.text,
data:
// Add the start bits
CODE128.getBar(startIndex) +
// Add the encoded bits
encodingResult.result +
// Add the checksum
CODE128.getBar((encodingResult.checksum + startIndex) % _constants.MODULO) +
// Add the end bits
CODE128.getBar(_constants.STOP)
};
}
// GS1-128/EAN-128
}, {
key: 'shouldEncodeAsEan128',
value: function shouldEncodeAsEan128() {
var isEAN128 = this.options.ean128 || false;
if (typeof isEAN128 === 'string') {
isEAN128 = isEAN128.toLowerCase() === 'true';
}
return isEAN128;
}
// Get a bar symbol by index
}], [{
key: 'getBar',
value: function getBar(index) {
return _constants.BARS[index] ? _constants.BARS[index].toString() : '';
}
// Correct an index by a set and shift it from the bytes array
}, {
key: 'correctIndex',
value: function correctIndex(bytes, set) {
if (set === _constants.SET_A) {
var charCode = bytes.shift();
return charCode < 32 ? charCode + 64 : charCode - 32;
} else if (set === _constants.SET_B) {
return bytes.shift() - 32;
} else {
return (bytes.shift() - 48) * 10 + bytes.shift() - 48;
}
}
}, {
key: 'next',
value: function next(bytes, pos, set) {
if (!bytes.length) {
return {
result: '',
checksum: 0
};
}
var nextCode = void 0,
index = void 0;
// Special characters
if (bytes[0] >= 200) {
index = bytes.shift() - 105;
var nextSet = _constants.SWAP[index];
// Swap to other set
if (nextSet !== undefined) {
nextCode = CODE128.next(bytes, pos + 1, nextSet);
}
// Continue on current set but encode a special character
else {
// Shift
if ((set === _constants.SET_A || set === _constants.SET_B) && index ===
_constants.SHIFT) {
// Convert the next character so that is encoded correctly
bytes[0] = set === _constants.SET_A ? bytes[0] > 95 ? bytes[0] - 96 : bytes[
0] : bytes[0] < 32 ? bytes[0] + 96 : bytes[0];
}
nextCode = CODE128.next(bytes, pos + 1, set);
}
}
// Continue encoding
else {
index = CODE128.correctIndex(bytes, set);
nextCode = CODE128.next(bytes, pos + 1, set);
}
// Get the correct binary encoding and calculate the weight
var enc = CODE128.getBar(index);
var weight = index * pos;
return {
result: enc + nextCode.result,
checksum: weight + nextCode.checksum
};
}
}]);
return CODE128;
}(_Barcode3);
export default CODE128;

View File

@@ -0,0 +1,80 @@
'use strict';
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
import _CODE3 from './CODE128'
import _constants from './constants'
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
}
var CODE128A = function(_CODE) {
_inherits(CODE128A, _CODE);
function CODE128A(string, options) {
_classCallCheck(this, CODE128A);
return _possibleConstructorReturn(this, (CODE128A.__proto__ || Object.getPrototypeOf(CODE128A)).call(this,
_constants.A_START_CHAR + string, options));
}
_createClass(CODE128A, [{
key: 'valid',
value: function valid() {
return new RegExp('^' + _constants.A_CHARS + '+$').test(this.data);
}
}]);
return CODE128A;
}(_CODE3);
export default CODE128A;

View File

@@ -0,0 +1,79 @@
'use strict';
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
import _CODE3 from './CODE128'
import _constants from './constants'
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
}
var CODE128B = function(_CODE) {
_inherits(CODE128B, _CODE);
function CODE128B(string, options) {
_classCallCheck(this, CODE128B);
return _possibleConstructorReturn(this, (CODE128B.__proto__ || Object.getPrototypeOf(CODE128B)).call(this,
_constants.B_START_CHAR + string, options));
}
_createClass(CODE128B, [{
key: 'valid',
value: function valid() {
return new RegExp('^' + _constants.B_CHARS + '+$').test(this.data);
}
}]);
return CODE128B;
}(_CODE3);
export default CODE128B;

View File

@@ -0,0 +1,79 @@
'use strict';
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
import _CODE3 from './CODE128'
import _constants from './constants'
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
}
var CODE128C = function(_CODE) {
_inherits(CODE128C, _CODE);
function CODE128C(string, options) {
_classCallCheck(this, CODE128C);
return _possibleConstructorReturn(this, (CODE128C.__proto__ || Object.getPrototypeOf(CODE128C)).call(this,
_constants.C_START_CHAR + string, options));
}
_createClass(CODE128C, [{
key: 'valid',
value: function valid() {
return new RegExp('^' + _constants.C_CHARS + '+$').test(this.data);
}
}]);
return CODE128C;
}(_CODE3);
export default CODE128C;

View File

@@ -0,0 +1,63 @@
'use strict';
import _CODE3 from './CODE128'
import _auto2 from './auto'
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
}
var CODE128AUTO = function(_CODE) {
_inherits(CODE128AUTO, _CODE);
function CODE128AUTO(data, options) {
_classCallCheck(this, CODE128AUTO);
// ASCII value ranges 0-127, 200-211
if (/^[\x00-\x7F\xC8-\xD3]+$/.test(data)) {
var _this = _possibleConstructorReturn(this, (CODE128AUTO.__proto__ || Object.getPrototypeOf(
CODE128AUTO)).call(this, (0, _auto2)(data), options));
} else {
var _this = _possibleConstructorReturn(this, (CODE128AUTO.__proto__ || Object.getPrototypeOf(
CODE128AUTO)).call(this, data, options));
}
return _possibleConstructorReturn(_this);
}
return CODE128AUTO;
}(_CODE3);
export default CODE128AUTO;

View File

@@ -0,0 +1,71 @@
'use strict';
import _constants from './constants'
// Match Set functions
var matchSetALength = function matchSetALength(string) {
return string.match(new RegExp('^' + _constants.A_CHARS + '*'))[0].length;
};
var matchSetBLength = function matchSetBLength(string) {
return string.match(new RegExp('^' + _constants.B_CHARS + '*'))[0].length;
};
var matchSetC = function matchSetC(string) {
return string.match(new RegExp('^' + _constants.C_CHARS + '*'))[0];
};
// CODE128A or CODE128B
function autoSelectFromAB(string, isA) {
var ranges = isA ? _constants.A_CHARS : _constants.B_CHARS;
var untilC = string.match(new RegExp('^(' + ranges + '+?)(([0-9]{2}){2,})([^0-9]|$)'));
if (untilC) {
return untilC[1] + String.fromCharCode(204) + autoSelectFromC(string.substring(untilC[1].length));
}
var chars = string.match(new RegExp('^' + ranges + '+'))[0];
if (chars.length === string.length) {
return string;
}
return chars + String.fromCharCode(isA ? 205 : 206) + autoSelectFromAB(string.substring(chars.length), !isA);
}
// CODE128C
function autoSelectFromC(string) {
var cMatch = matchSetC(string);
var length = cMatch.length;
if (length === string.length) {
return string;
}
string = string.substring(length);
// Select A/B depending on the longest match
var isA = matchSetALength(string) >= matchSetBLength(string);
return cMatch + String.fromCharCode(isA ? 206 : 205) + autoSelectFromAB(string, isA);
}
// Detect Code Set (A, B or C) and format the string
function auto(string) {
var newString = void 0;
var cLength = matchSetC(string).length;
// Select 128C if the string start with enough digits
if (cLength >= 2) {
newString = _constants.C_START_CHAR + autoSelectFromC(string);
} else {
// Select A/B depending on the longest match
var isA = matchSetALength(string) > matchSetBLength(string);
newString = (isA ? _constants.A_START_CHAR : _constants.B_START_CHAR) + autoSelectFromAB(string, isA);
}
return newString.replace(/[\xCD\xCE]([^])[\xCD\xCE]/, // Any sequence between 205 and 206 characters
function(match, char) {
return String.fromCharCode(203) + char;
});
};
export default auto

View File

@@ -0,0 +1,99 @@
"use strict";
var _SET_BY_CODE;
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
// constants for internal usage
var SET_A = 0;
var SET_B = 1;
var SET_C = 2;
// Special characters
var SHIFT = 98;
var START_A = 103;
var START_B = 104;
var START_C = 105;
var MODULO = 103;
var STOP = 106;
var FNC1 = 207;
// Get set by start code
var SET_BY_CODE = (_SET_BY_CODE = {}, _defineProperty(_SET_BY_CODE, START_A, SET_A),
_defineProperty(_SET_BY_CODE, START_B, SET_B), _defineProperty(_SET_BY_CODE, START_C, SET_C), _SET_BY_CODE);
// Get next set by code
var SWAP = {
101: SET_A,
100: SET_B,
99: SET_C
};
var A_START_CHAR = String.fromCharCode(208); // START_A + 105
var B_START_CHAR = String.fromCharCode(209); // START_B + 105
var C_START_CHAR = String.fromCharCode(210); // START_C + 105
// 128A (Code Set A)
// ASCII characters 00 to 95 (09, AZ and control codes), special characters, and FNC 14
var A_CHARS = "[\x00-\x5F\xC8-\xCF]";
// 128B (Code Set B)
// ASCII characters 32 to 127 (09, AZ, az), special characters, and FNC 14
var B_CHARS = "[\x20-\x7F\xC8-\xCF]";
// 128C (Code Set C)
// 0099 (encodes two digits with a single code point) and FNC1
var C_CHARS = "(\xCF*[0-9]{2}\xCF*)";
// CODE128 includes 107 symbols:
// 103 data symbols, 3 start symbols (A, B and C), and 1 stop symbol (the last one)
// Each symbol consist of three black bars (1) and three white spaces (0).
var BARS = [11011001100, 11001101100, 11001100110, 10010011000, 10010001100, 10001001100, 10011001000,
10011000100, 10001100100, 11001001000, 11001000100, 11000100100, 10110011100, 10011011100, 10011001110,
10111001100, 10011101100, 10011100110, 11001110010, 11001011100, 11001001110, 11011100100, 11001110100,
11101101110, 11101001100, 11100101100, 11100100110, 11101100100, 11100110100, 11100110010, 11011011000,
11011000110, 11000110110, 10100011000, 10001011000, 10001000110, 10110001000, 10001101000, 10001100010,
11010001000, 11000101000, 11000100010, 10110111000, 10110001110, 10001101110, 10111011000, 10111000110,
10001110110, 11101110110, 11010001110, 11000101110, 11011101000, 11011100010, 11011101110, 11101011000,
11101000110, 11100010110, 11101101000, 11101100010, 11100011010, 11101111010, 11001000010, 11110001010,
10100110000, 10100001100, 10010110000, 10010000110, 10000101100, 10000100110, 10110010000, 10110000100,
10011010000, 10011000010, 10000110100, 10000110010, 11000010010, 11001010000, 11110111010, 11000010100,
10001111010, 10100111100, 10010111100, 10010011110, 10111100100, 10011110100, 10011110010, 11110100100,
11110010100, 11110010010, 11011011110, 11011110110, 11110110110, 10101111000, 10100011110, 10001011110,
10111101000, 10111100010, 11110101000, 11110100010, 10111011110, 10111101110, 11101011110, 11110101110,
11010000100, 11010010000, 11010011100, 1100011101011
];
export default {
SET_A,
SET_B,
SET_C,
SHIFT,
START_A,
START_B,
START_C,
MODULO,
STOP,
FNC1,
SET_BY_CODE,
SWAP,
A_START_CHAR,
B_START_CHAR,
C_START_CHAR,
A_CHARS,
B_CHARS,
C_CHARS,
BARS
}

View File

@@ -0,0 +1,17 @@
'use strict';
import CODE128 from './CODE128_AUTO.js'
import CODE128A from './CODE128A.js'
import CODE128B from './CODE128B.js'
import CODE128C from './CODE128C.js'
export default {
CODE128,
CODE128A,
CODE128B,
CODE128C,
};

View File

@@ -0,0 +1,141 @@
"use strict";
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
import _Barcode3 from '../Barcode.js'
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
} // Encoding documentation:
// https://en.wikipedia.org/wiki/Code_39#Encoding
var CODE39 = function(_Barcode) {
_inherits(CODE39, _Barcode);
function CODE39(data, options) {
_classCallCheck(this, CODE39);
data = data.toUpperCase();
// Calculate mod43 checksum if enabled
if (options.mod43) {
data += getCharacter(mod43checksum(data));
}
return _possibleConstructorReturn(this, (CODE39.__proto__ || Object.getPrototypeOf(CODE39)).call(this, data,
options));
}
_createClass(CODE39, [{
key: "encode",
value: function encode() {
// First character is always a *
var result = getEncoding("*");
// Take every character and add the binary representation to the result
for (var i = 0; i < this.data.length; i++) {
result += getEncoding(this.data[i]) + "0";
}
// Last character is always a *
result += getEncoding("*");
return {
data: result,
text: this.text
};
}
}, {
key: "valid",
value: function valid() {
return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/) !== -1;
}
}]);
return CODE39;
}(_Barcode3);
// All characters. The position in the array is the (checksum) value
var characters = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "-", ".", " ", "$", "/", "+",
"%", "*"
];
// The decimal representation of the characters, is converted to the
// corresponding binary with the getEncoding function
var encodings = [20957, 29783, 23639, 30485, 20951, 29813, 23669, 20855, 29789, 23645, 29975, 23831, 30533, 22295,
30149, 24005, 21623, 29981, 23837, 22301, 30023, 23879, 30545, 22343, 30161, 24017, 21959, 30065, 23921, 22385,
29015, 18263, 29141, 17879, 29045, 18293, 17783, 29021, 18269, 17477, 17489, 17681, 20753, 35770
];
// Get the binary representation of a character by converting the encodings
// from decimal to binary
function getEncoding(character) {
return getBinary(characterValue(character));
}
function getBinary(characterValue) {
return encodings[characterValue].toString(2);
}
function getCharacter(characterValue) {
return characters[characterValue];
}
function characterValue(character) {
return characters.indexOf(character);
}
function mod43checksum(data) {
var checksum = 0;
for (var i = 0; i < data.length; i++) {
checksum += characterValue(data[i]);
}
checksum = checksum % 43;
return checksum;
}
export default CODE39;

View File

@@ -0,0 +1,151 @@
'use strict';
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
import _constants from './constants'
import _encoder2 from './encoder'
import _Barcode3 from '../Barcode.js'
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
}
// Base class for EAN8 & EAN13
var EAN = function(_Barcode) {
_inherits(EAN, _Barcode);
function EAN(data, options) {
_classCallCheck(this, EAN);
// Make sure the font is not bigger than the space between the guard bars
var _this = _possibleConstructorReturn(this, (EAN.__proto__ || Object.getPrototypeOf(EAN)).call(this, data,
options));
_this.fontSize = !options.flat && options.fontSize > options.width * 10 ? options.width * 10 : options
.fontSize;
// Make the guard bars go down half the way of the text
_this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin;
return _this;
}
_createClass(EAN, [{
key: 'encode',
value: function encode() {
return this.options.flat ? this.encodeFlat() : this.encodeGuarded();
}
}, {
key: 'leftText',
value: function leftText(from, to) {
return this.text.substr(from, to);
}
}, {
key: 'leftEncode',
value: function leftEncode(data, structure) {
return (0, _encoder2)(data, structure);
}
}, {
key: 'rightText',
value: function rightText(from, to) {
return this.text.substr(from, to);
}
}, {
key: 'rightEncode',
value: function rightEncode(data, structure) {
return (0, _encoder2)(data, structure);
}
}, {
key: 'encodeGuarded',
value: function encodeGuarded() {
var textOptions = {
fontSize: this.fontSize
};
var guardOptions = {
height: this.guardHeight
};
return [{
data: _constants.SIDE_BIN,
options: guardOptions
}, {
data: this.leftEncode(),
text: this.leftText(),
options: textOptions
}, {
data: _constants.MIDDLE_BIN,
options: guardOptions
}, {
data: this.rightEncode(),
text: this.rightText(),
options: textOptions
}, {
data: _constants.SIDE_BIN,
options: guardOptions
}];
}
}, {
key: 'encodeFlat',
value: function encodeFlat() {
var data = [_constants.SIDE_BIN, this.leftEncode(), _constants.MIDDLE_BIN, this
.rightEncode(), _constants.SIDE_BIN
];
return {
data: data.join(''),
text: this.text
};
}
}]);
return EAN;
}(_Barcode3);
export default EAN;

View File

@@ -0,0 +1,186 @@
'use strict';
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var _get = function get(object, property, receiver) {
if (object === null) object = Function.prototype;
var desc = Object.getOwnPropertyDescriptor(object, property);
if (desc === undefined) {
var parent = Object.getPrototypeOf(object);
if (parent === null) {
return undefined;
} else {
return get(parent, property, receiver);
}
} else if ("value" in desc) {
return desc.value;
} else {
var getter = desc.get;
if (getter === undefined) {
return undefined;
}
return getter.call(receiver);
}
};
import _constants from './constants'
import _EAN3 from './EAN'
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
} // Encoding documentation:
// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Binary_encoding_of_data_digits_into_EAN-13_barcode
// Calculate the checksum digit
// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Calculation_of_checksum_digit
var checksum = function checksum(number) {
var res = number.substr(0, 12).split('').map(function(n) {
return +n;
}).reduce(function(sum, a, idx) {
return idx % 2 ? sum + a * 3 : sum + a;
}, 0);
return (10 - res % 10) % 10;
};
var EAN13 = function(_EAN) {
_inherits(EAN13, _EAN);
function EAN13(data, options) {
_classCallCheck(this, EAN13);
// Add checksum if it does not exist
if (data.search(/^[0-9]{12}$/) !== -1) {
data += checksum(data);
}
// Adds a last character to the end of the barcode
var _this = _possibleConstructorReturn(this, (EAN13.__proto__ || Object.getPrototypeOf(EAN13)).call(this,
data, options));
_this.lastChar = options.lastChar;
return _this;
}
_createClass(EAN13, [{
key: 'valid',
value: function valid() {
return this.data.search(/^[0-9]{13}$/) !== -1 && +this.data[12] === checksum(this.data);
}
}, {
key: 'leftText',
value: function leftText() {
return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype),
'leftText', this).call(this, 1, 6);
}
}, {
key: 'leftEncode',
value: function leftEncode() {
var data = this.data.substr(1, 6);
var structure = _constants.EAN13_STRUCTURE[this.data[0]];
return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype),
'leftEncode', this).call(this, data, structure);
}
}, {
key: 'rightText',
value: function rightText() {
return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype),
'rightText', this).call(this, 7, 6);
}
}, {
key: 'rightEncode',
value: function rightEncode() {
var data = this.data.substr(7, 6);
return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype),
'rightEncode', this).call(this, data, 'RRRRRR');
}
// The "standard" way of printing EAN13 barcodes with guard bars
}, {
key: 'encodeGuarded',
value: function encodeGuarded() {
var data = _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype),
'encodeGuarded', this).call(this);
// Extend data with left digit & last character
if (this.options.displayValue) {
data.unshift({
data: '000000000000',
text: this.text.substr(0, 1),
options: {
textAlign: 'left',
fontSize: this.fontSize
}
});
if (this.options.lastChar) {
data.push({
data: '00'
});
data.push({
data: '00000',
text: this.options.lastChar,
options: {
fontSize: this.fontSize
}
});
}
}
return data;
}
}]);
return EAN13;
}(_EAN3);
export default EAN13;

View File

@@ -0,0 +1,93 @@
'use strict';
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
import _constants from './constants'
import _encoder2 from './encoder'
import _Barcode3 from '../Barcode.js'
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
} // Encoding documentation:
// https://en.wikipedia.org/wiki/EAN_2#Encoding
var EAN2 = function(_Barcode) {
_inherits(EAN2, _Barcode);
function EAN2(data, options) {
_classCallCheck(this, EAN2);
return _possibleConstructorReturn(this, (EAN2.__proto__ || Object.getPrototypeOf(EAN2)).call(this, data,
options));
}
_createClass(EAN2, [{
key: 'valid',
value: function valid() {
return this.data.search(/^[0-9]{2}$/) !== -1;
}
}, {
key: 'encode',
value: function encode() {
// Choose the structure based on the number mod 4
var structure = _constants.EAN2_STRUCTURE[parseInt(this.data) % 4];
return {
// Start bits + Encode the two digits with 01 in between
data: '1011' + (0, _encoder2)(this.data, structure, '01'),
text: this.text
};
}
}]);
return EAN2;
}(_Barcode3);
export default EAN2;

View File

@@ -0,0 +1,100 @@
'use strict';
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
import _constants from './constants'
import _encoder2 from './encoder'
import _Barcode3 from '../Barcode.js'
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
} // Encoding documentation:
// https://en.wikipedia.org/wiki/EAN_5#Encoding
var checksum = function checksum(data) {
var result = data.split('').map(function(n) {
return +n;
}).reduce(function(sum, a, idx) {
return idx % 2 ? sum + a * 9 : sum + a * 3;
}, 0);
return result % 10;
};
var EAN5 = function(_Barcode) {
_inherits(EAN5, _Barcode);
function EAN5(data, options) {
_classCallCheck(this, EAN5);
return _possibleConstructorReturn(this, (EAN5.__proto__ || Object.getPrototypeOf(EAN5)).call(this, data,
options));
}
_createClass(EAN5, [{
key: 'valid',
value: function valid() {
return this.data.search(/^[0-9]{5}$/) !== -1;
}
}, {
key: 'encode',
value: function encode() {
var structure = _constants.EAN5_STRUCTURE[checksum(this.data)];
return {
data: '1011' + (0, _encoder2)(this.data, structure, '01'),
text: this.text
};
}
}]);
return EAN5;
}(_Barcode3);
export default EAN5;

View File

@@ -0,0 +1,142 @@
'use strict';
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var _get = function get(object, property, receiver) {
if (object === null) object = Function.prototype;
var desc = Object.getOwnPropertyDescriptor(object, property);
if (desc === undefined) {
var parent = Object.getPrototypeOf(object);
if (parent === null) {
return undefined;
} else {
return get(parent, property, receiver);
}
} else if ("value" in desc) {
return desc.value;
} else {
var getter = desc.get;
if (getter === undefined) {
return undefined;
}
return getter.call(receiver);
}
};
import _EAN3 from './EAN'
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
} // Encoding documentation:
// http://www.barcodeisland.com/ean8.phtml
// Calculate the checksum digit
var checksum = function checksum(number) {
var res = number.substr(0, 7).split('').map(function(n) {
return +n;
}).reduce(function(sum, a, idx) {
return idx % 2 ? sum + a : sum + a * 3;
}, 0);
return (10 - res % 10) % 10;
};
var EAN8 = function(_EAN) {
_inherits(EAN8, _EAN);
function EAN8(data, options) {
_classCallCheck(this, EAN8);
// Add checksum if it does not exist
if (data.search(/^[0-9]{7}$/) !== -1) {
data += checksum(data);
}
return _possibleConstructorReturn(this, (EAN8.__proto__ || Object.getPrototypeOf(EAN8)).call(this, data,
options));
}
_createClass(EAN8, [{
key: 'valid',
value: function valid() {
return this.data.search(/^[0-9]{8}$/) !== -1 && +this.data[7] === checksum(this.data);
}
}, {
key: 'leftText',
value: function leftText() {
return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype),
'leftText', this).call(this, 0, 4);
}
}, {
key: 'leftEncode',
value: function leftEncode() {
var data = this.data.substr(0, 4);
return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype),
'leftEncode', this).call(this, data, 'LLLL');
}
}, {
key: 'rightText',
value: function rightText() {
return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype),
'rightText', this).call(this, 4, 4);
}
}, {
key: 'rightEncode',
value: function rightEncode() {
var data = this.data.substr(4, 4);
return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype),
'rightEncode', this).call(this, data, 'RRRR');
}
}]);
return EAN8;
}(_EAN3);
export default EAN8;

View File

@@ -0,0 +1,210 @@
"use strict";
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
import _encoder2 from './encoder'
import _Barcode3 from '../Barcode.js'
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
} // Encoding documentation:
// https://en.wikipedia.org/wiki/Universal_Product_Code#Encoding
var UPC = function(_Barcode) {
function UPC(data, options) {
_classCallCheck(this, UPC);
// Add checksum if it does not exist
if (data.search(/^[0-9]{11}$/) !== -1) {
data += checksum(data);
}
var _this = _possibleConstructorReturn(this, (UPC.__proto__ || Object.getPrototypeOf(UPC)).call(this, data,
options));
_this.displayValue = options.displayValue;
// Make sure the font is not bigger than the space between the guard bars
if (options.fontSize > options.width * 10) {
_this.fontSize = options.width * 10;
} else {
_this.fontSize = options.fontSize;
}
// Make the guard bars go down half the way of the text
_this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin;
return _this;
}
_createClass(UPC, [{
key: "valid",
value: function valid() {
return this.data.search(/^[0-9]{12}$/) !== -1 && this.data[11] == checksum(this.data);
}
}, {
key: "encode",
value: function encode() {
if (this.options.flat) {
return this.flatEncoding();
} else {
return this.guardedEncoding();
}
}
}, {
key: "flatEncoding",
value: function flatEncoding() {
var result = "";
result += "101";
result += (0, _encoder2)(this.data.substr(0, 6), "LLLLLL");
result += "01010";
result += (0, _encoder2)(this.data.substr(6, 6), "RRRRRR");
result += "101";
return {
data: result,
text: this.text
};
}
}, {
key: "guardedEncoding",
value: function guardedEncoding() {
var result = [];
// Add the first digit
if (this.displayValue) {
result.push({
data: "00000000",
text: this.text.substr(0, 1),
options: {
textAlign: "left",
fontSize: this.fontSize
}
});
}
// Add the guard bars
result.push({
data: "101" + (0, _encoder2)(this.data[0], "L"),
options: {
height: this.guardHeight
}
});
// Add the left side
result.push({
data: (0, _encoder2)(this.data.substr(1, 5), "LLLLL"),
text: this.text.substr(1, 5),
options: {
fontSize: this.fontSize
}
});
// Add the middle bits
result.push({
data: "01010",
options: {
height: this.guardHeight
}
});
// Add the right side
result.push({
data: (0, _encoder2)(this.data.substr(6, 5), "RRRRR"),
text: this.text.substr(6, 5),
options: {
fontSize: this.fontSize
}
});
// Add the end bits
result.push({
data: (0, _encoder2)(this.data[11], "R") + "101",
options: {
height: this.guardHeight
}
});
// Add the last digit
if (this.displayValue) {
result.push({
data: "00000000",
text: this.text.substr(11, 1),
options: {
textAlign: "right",
fontSize: this.fontSize
}
});
}
return result;
}
}]);
return UPC;
}(_Barcode3);
// Calulate the checksum digit
// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Calculation_of_checksum_digit
function checksum(number) {
var result = 0;
var i;
for (i = 1; i < 11; i += 2) {
result += parseInt(number[i]);
}
for (i = 0; i < 11; i += 2) {
result += parseInt(number[i]) * 3;
}
return (10 - result % 10) % 10;
}
export default {
UPC,
checksum
};

View File

@@ -0,0 +1,245 @@
'use strict';
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
import _encoder2 from './encoder'
import _Barcode3 from '../Barcode.js'
import _UPC from './UPC.js'
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
} // Encoding documentation:
// https://en.wikipedia.org/wiki/Universal_Product_Code#Encoding
//
// UPC-E documentation:
// https://en.wikipedia.org/wiki/Universal_Product_Code#UPC-E
var EXPANSIONS = ["XX00000XXX", "XX10000XXX", "XX20000XXX", "XXX00000XX", "XXXX00000X", "XXXXX00005", "XXXXX00006",
"XXXXX00007", "XXXXX00008", "XXXXX00009"
];
var PARITIES = [
["EEEOOO", "OOOEEE"],
["EEOEOO", "OOEOEE"],
["EEOOEO", "OOEEOE"],
["EEOOOE", "OOEEEO"],
["EOEEOO", "OEOOEE"],
["EOOEEO", "OEEOOE"],
["EOOOEE", "OEEEOO"],
["EOEOEO", "OEOEOE"],
["EOEOOE", "OEOEEO"],
["EOOEOE", "OEEOEO"]
];
var UPCE = function(_Barcode) {
_inherits(UPCE, _Barcode);
function UPCE(data, options) {
_classCallCheck(this, UPCE);
var _this = _possibleConstructorReturn(this, (UPCE.__proto__ || Object.getPrototypeOf(UPCE)).call(this,
data, options));
// Code may be 6 or 8 digits;
// A 7 digit code is ambiguous as to whether the extra digit
// is a UPC-A check or number system digit.
_this.isValid = false;
if (data.search(/^[0-9]{6}$/) !== -1) {
_this.middleDigits = data;
_this.upcA = expandToUPCA(data, "0");
_this.text = options.text || '' + _this.upcA[0] + data + _this.upcA[_this.upcA.length - 1];
_this.isValid = true;
} else if (data.search(/^[01][0-9]{7}$/) !== -1) {
_this.middleDigits = data.substring(1, data.length - 1);
_this.upcA = expandToUPCA(_this.middleDigits, data[0]);
if (_this.upcA[_this.upcA.length - 1] === data[data.length - 1]) {
_this.isValid = true;
} else {
// checksum mismatch
return _possibleConstructorReturn(_this);
}
} else {
return _possibleConstructorReturn(_this);
}
_this.displayValue = options.displayValue;
// Make sure the font is not bigger than the space between the guard bars
if (options.fontSize > options.width * 10) {
_this.fontSize = options.width * 10;
} else {
_this.fontSize = options.fontSize;
}
// Make the guard bars go down half the way of the text
_this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin;
return _this;
}
_createClass(UPCE, [{
key: 'valid',
value: function valid() {
return this.isValid;
}
}, {
key: 'encode',
value: function encode() {
if (this.options.flat) {
return this.flatEncoding();
} else {
return this.guardedEncoding();
}
}
}, {
key: 'flatEncoding',
value: function flatEncoding() {
var result = "";
result += "101";
result += this.encodeMiddleDigits();
result += "010101";
return {
data: result,
text: this.text
};
}
}, {
key: 'guardedEncoding',
value: function guardedEncoding() {
var result = [];
// Add the UPC-A number system digit beneath the quiet zone
if (this.displayValue) {
result.push({
data: "00000000",
text: this.text[0],
options: {
textAlign: "left",
fontSize: this.fontSize
}
});
}
// Add the guard bars
result.push({
data: "101",
options: {
height: this.guardHeight
}
});
// Add the 6 UPC-E digits
result.push({
data: this.encodeMiddleDigits(),
text: this.text.substring(1, 7),
options: {
fontSize: this.fontSize
}
});
// Add the end bits
result.push({
data: "010101",
options: {
height: this.guardHeight
}
});
// Add the UPC-A check digit beneath the quiet zone
if (this.displayValue) {
result.push({
data: "00000000",
text: this.text[7],
options: {
textAlign: "right",
fontSize: this.fontSize
}
});
}
return result;
}
}, {
key: 'encodeMiddleDigits',
value: function encodeMiddleDigits() {
var numberSystem = this.upcA[0];
var checkDigit = this.upcA[this.upcA.length - 1];
var parity = PARITIES[parseInt(checkDigit)][parseInt(numberSystem)];
return (0, _encoder2)(this.middleDigits, parity);
}
}]);
return UPCE;
}(_Barcode3);
function expandToUPCA(middleDigits, numberSystem) {
var lastUpcE = parseInt(middleDigits[middleDigits.length - 1]);
var expansion = EXPANSIONS[lastUpcE];
var result = "";
var digitIndex = 0;
for (var i = 0; i < expansion.length; i++) {
var c = expansion[i];
if (c === 'X') {
result += middleDigits[digitIndex++];
} else {
result += c;
}
}
result = '' + numberSystem + result;
return '' + result + (0, _UPC.checksum)(result);
}
export default UPCE;

View File

@@ -0,0 +1,48 @@
'use strict';
// Standard start end and middle bits
var SIDE_BIN = '101';
var MIDDLE_BIN = '01010';
var BINARIES = {
'L': [ // The L (left) type of encoding
'0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111',
'0001011'
],
'G': [ // The G type of encoding
'0100111', '0110011', '0011011', '0100001', '0011101', '0111001', '0000101', '0010001', '0001001',
'0010111'
],
'R': [ // The R (right) type of encoding
'1110010', '1100110', '1101100', '1000010', '1011100', '1001110', '1010000', '1000100', '1001000',
'1110100'
],
'O': [ // The O (odd) encoding for UPC-E
'0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111',
'0001011'
],
'E': [ // The E (even) encoding for UPC-E
'0100111', '0110011', '0011011', '0100001', '0011101', '0111001', '0000101', '0010001', '0001001',
'0010111'
]
};
// Define the EAN-2 structure
var EAN2_STRUCTURE = ['LL', 'LG', 'GL', 'GG'];
// Define the EAN-5 structure
var EAN5_STRUCTURE = ['GGLLL', 'GLGLL', 'GLLGL', 'GLLLG', 'LGGLL', 'LLGGL', 'LLLGG', 'LGLGL', 'LGLLG', 'LLGLG'];
// Define the EAN-13 structure
var EAN13_STRUCTURE = ['LLLLLL', 'LLGLGG', 'LLGGLG', 'LLGGGL', 'LGLLGG', 'LGGLLG', 'LGGGLL', 'LGLGLG', 'LGLGGL',
'LGGLGL'
];
export default {
SIDE_BIN,
MIDDLE_BIN,
BINARIES,
EAN2_STRUCTURE,
EAN5_STRUCTURE,
EAN13_STRUCTURE
}

View File

@@ -0,0 +1,23 @@
'use strict';
import _constants from './constants'
// Encode data string
var encode = function encode(data, structure, separator) {
var encoded = data.split('').map(function(val, idx) {
return _constants.BINARIES[structure[idx]];
}).map(function(val, idx) {
return val ? val[data[idx]] : '';
});
if (separator) {
var last = data.length - 1;
encoded = encoded.map(function(val, idx) {
return idx < last ? val + separator : val;
});
}
return encoded.join('');
};
export default encode

View File

@@ -0,0 +1,22 @@
'use strict';
import EAN13 from './EAN13'
import EAN8 from './EAN8.js'
import EAN5 from './EAN5.js'
import EAN2 from './EAN2.js'
import UPC from './UPC.js'
import UPCE from './UPCE.js'
export default {
EAN13,
EAN8,
EAN5,
EAN2,
UPC: UPC.UPC,
UPCE
}

View File

@@ -0,0 +1,100 @@
'use strict';
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
import _constants from './constants'
import _Barcode3 from '../Barcode'
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
}
var ITF = function(_Barcode) {
_inherits(ITF, _Barcode);
function ITF() {
_classCallCheck(this, ITF);
return _possibleConstructorReturn(this, (ITF.__proto__ || Object.getPrototypeOf(ITF)).apply(this,
arguments));
}
_createClass(ITF, [{
key: 'valid',
value: function valid() {
return this.data.search(/^([0-9]{2})+$/) !== -1;
}
}, {
key: 'encode',
value: function encode() {
var _this2 = this;
// Calculate all the digit pairs
var encoded = this.data.match(/.{2}/g).map(function(pair) {
return _this2.encodePair(pair);
}).join('');
return {
data: _constants.START_BIN + encoded + _constants.END_BIN,
text: this.text
};
}
// Calculate the data of a number pair
}, {
key: 'encodePair',
value: function encodePair(pair) {
var second = _constants.BINARIES[pair[1]];
return _constants.BINARIES[pair[0]].split('').map(function(first, idx) {
return (first === '1' ? '111' : '1') + (second[idx] === '1' ? '000' : '0');
}).join('');
}
}]);
return ITF;
}(_Barcode3);
export default ITF;

View File

@@ -0,0 +1,93 @@
'use strict';
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
import _ITF3 from './ITF'
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
}
// Calculate the checksum digit
var checksum = function checksum(data) {
var res = data.substr(0, 13).split('').map(function(num) {
return parseInt(num, 10);
}).reduce(function(sum, n, idx) {
return sum + n * (3 - idx % 2 * 2);
}, 0);
return Math.ceil(res / 10) * 10 - res;
};
var ITF14 = function(_ITF) {
_inherits(ITF14, _ITF);
function ITF14(data, options) {
_classCallCheck(this, ITF14);
// Add checksum if it does not exist
if (data.search(/^[0-9]{13}$/) !== -1) {
data += checksum(data);
}
return _possibleConstructorReturn(this, (ITF14.__proto__ || Object.getPrototypeOf(ITF14)).call(this, data,
options));
}
_createClass(ITF14, [{
key: 'valid',
value: function valid() {
return this.data.search(/^[0-9]{14}$/) !== -1 && +this.data[13] === checksum(this.data);
}
}]);
return ITF14;
}(_ITF3);
export default ITF14;

View File

@@ -0,0 +1,11 @@
'use strict';
var START_BIN = '1010';
var END_BIN = '11101';
var BINARIES = ['00110', '10001', '01001', '11000', '00101', '10100', '01100', '00011', '10010', '01010'];
export default {
START_BIN,
END_BIN,
BINARIES
}

View File

@@ -0,0 +1,9 @@
'use strict';
import ITF from './ITF'
import ITF14 from './ITF14'
export default {
ITF,
ITF14
}

View File

@@ -0,0 +1,111 @@
"use strict";
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
import _Barcode3 from '../Barcode.js'
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
} // Encoding documentation
// https://en.wikipedia.org/wiki/MSI_Barcode#Character_set_and_binary_lookup
var MSI = function(_Barcode) {
_inherits(MSI, _Barcode);
function MSI(data, options) {
_classCallCheck(this, MSI);
return _possibleConstructorReturn(this, (MSI.__proto__ || Object.getPrototypeOf(MSI)).call(this, data,
options));
}
_createClass(MSI, [{
key: "encode",
value: function encode() {
// Start bits
var ret = "110";
for (var i = 0; i < this.data.length; i++) {
// Convert the character to binary (always 4 binary digits)
var digit = parseInt(this.data[i]);
var bin = digit.toString(2);
bin = addZeroes(bin, 4 - bin.length);
// Add 100 for every zero and 110 for every 1
for (var b = 0; b < bin.length; b++) {
ret += bin[b] == "0" ? "100" : "110";
}
}
// End bits
ret += "1001";
return {
data: ret,
text: this.text
};
}
}, {
key: "valid",
value: function valid() {
return this.data.search(/^[0-9]+$/) !== -1;
}
}]);
return MSI;
}(_Barcode3);
function addZeroes(number, n) {
for (var i = 0; i < n; i++) {
number = "0" + number;
}
return number;
}
export default MSI;

View File

@@ -0,0 +1,49 @@
'use strict';
import _MSI3 from './MSI.js'
import _checksums from './checksums.js'
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
}
var MSI10 = function(_MSI) {
_inherits(MSI10, _MSI);
function MSI10(data, options) {
_classCallCheck(this, MSI10);
return _possibleConstructorReturn(this, (MSI10.__proto__ || Object.getPrototypeOf(MSI10)).call(this, data +
(0, _checksums.mod10)(data), options));
}
return MSI10;
}(_MSI3);
export default MSI10;

View File

@@ -0,0 +1,51 @@
'use strict';
import _MSI3 from './MSI.js'
import _checksums from './checksums.js'
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
}
var MSI1010 = function(_MSI) {
_inherits(MSI1010, _MSI);
function MSI1010(data, options) {
_classCallCheck(this, MSI1010);
data += (0, _checksums.mod10)(data);
data += (0, _checksums.mod10)(data);
return _possibleConstructorReturn(this, (MSI1010.__proto__ || Object.getPrototypeOf(MSI1010)).call(this,
data, options));
}
return MSI1010;
}(_MSI3);
export default MSI1010;

View File

@@ -0,0 +1,50 @@
'use strict';
import _MSI3 from './MSI.js'
import _checksums from './checksums.js'
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
}
var MSI11 = function(_MSI) {
_inherits(MSI11, _MSI);
function MSI11(data, options) {
_classCallCheck(this, MSI11);
return _possibleConstructorReturn(this, (MSI11.__proto__ || Object.getPrototypeOf(MSI11)).call(this, data +
(0, _checksums.mod11)(data), options));
}
return MSI11;
}(_MSI3);
export default MSI11;

View File

@@ -0,0 +1,51 @@
'use strict';
import _MSI3 from './MSI.js'
import _checksums from './checksums.js'
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
}
var MSI1110 = function(_MSI) {
_inherits(MSI1110, _MSI);
function MSI1110(data, options) {
_classCallCheck(this, MSI1110);
data += (0, _checksums.mod11)(data);
data += (0, _checksums.mod10)(data);
return _possibleConstructorReturn(this, (MSI1110.__proto__ || Object.getPrototypeOf(MSI1110)).call(this,
data, options));
}
return MSI1110;
}(_MSI3);
export default MSI1110;

View File

@@ -0,0 +1,29 @@
"use strict";
function mod10(number) {
var sum = 0;
for (var i = 0; i < number.length; i++) {
var n = parseInt(number[i]);
if ((i + number.length) % 2 === 0) {
sum += n;
} else {
sum += n * 2 % 10 + Math.floor(n * 2 / 10);
}
}
return (10 - sum % 10) % 10;
}
function mod11(number) {
var sum = 0;
var weights = [2, 3, 4, 5, 6, 7];
for (var i = 0; i < number.length; i++) {
var n = parseInt(number[number.length - 1 - i]);
sum += weights[i % weights.length] * n;
}
return (11 - sum % 11) % 11;
}
export default {
mod10,
mod11
}

View File

@@ -0,0 +1,19 @@
'use strict';
import MSI from './MSI.js'
import MSI10 from './MSI10.js'
import MSI11 from './MSI11.js'
import MSI1010 from './MSI1010.js'
import MSI1110 from './MSI1110.js'
export default {
MSI,
MSI10,
MSI11,
MSI1010,
MSI1110
}

View File

@@ -0,0 +1,129 @@
"use strict";
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
import _Barcode3 from '../Barcode.js'
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
} // Encoding specification:
// http://www.barcodeisland.com/codabar.phtml
var codabar = function(_Barcode) {
_inherits(codabar, _Barcode);
function codabar(data, options) {
_classCallCheck(this, codabar);
if (data.search(/^[0-9\-\$\:\.\+\/]+$/) === 0) {
data = "A" + data + "A";
}
var _this = _possibleConstructorReturn(this, (codabar.__proto__ || Object.getPrototypeOf(codabar)).call(
this, data.toUpperCase(), options));
_this.text = _this.options.text || _this.text.replace(/[A-D]/g, '');
return _this;
}
_createClass(codabar, [{
key: "valid",
value: function valid() {
return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/) !== -1;
}
}, {
key: "encode",
value: function encode() {
var result = [];
var encodings = this.getEncodings();
for (var i = 0; i < this.data.length; i++) {
result.push(encodings[this.data.charAt(i)]);
// for all characters except the last, append a narrow-space ("0")
if (i !== this.data.length - 1) {
result.push("0");
}
}
return {
text: this.text,
data: result.join('')
};
}
}, {
key: "getEncodings",
value: function getEncodings() {
return {
"0": "101010011",
"1": "101011001",
"2": "101001011",
"3": "110010101",
"4": "101101001",
"5": "110101001",
"6": "100101011",
"7": "100101101",
"8": "100110101",
"9": "110100101",
"-": "101001101",
"$": "101100101",
":": "1101011011",
"/": "1101101011",
".": "1101101101",
"+": "101100110011",
"A": "1011001001",
"B": "1001001011",
"C": "1010010011",
"D": "1010011001"
};
}
}]);
return codabar;
}(_Barcode3);
export default codabar;

View File

@@ -0,0 +1,37 @@
'use strict';
import _CODE from './CODE39/'
import _CODE2 from './CODE128/'
import _EAN_UPC from './EAN_UPC/'
import _ITF from './ITF/'
import _MSI from './MSI/'
import _pharmacode from './pharmacode/'
import _codabar from './codabar'
export default {
CODE128: _CODE2.CODE128,
CODE128A: _CODE2.CODE128A,
CODE128B: _CODE2.CODE128B,
CODE128C: _CODE2.CODE128C,
EAN13: _EAN_UPC.EAN13,
EAN8: _EAN_UPC.EAN8,
EAN5: _EAN_UPC.EAN5,
EAN2: _EAN_UPC.EAN2,
UPC: _EAN_UPC.UPCE,
UPCE: _EAN_UPC.UPCE,
ITF14: _ITF.ITF14,
ITF: _ITF.ITF,
MSI: _MSI.MSI,
MSI10: _MSI.MSI10,
MSI11: _MSI.MSI11,
MSI1010: _MSI.MSI1010,
MSI1110: _MSI.MSI1110,
PHARMACODE: _pharmacode,
CODABAR: _codabar,
CODE39: _CODE,
}

View File

@@ -0,0 +1,103 @@
"use strict";
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
import _Barcode3 from '../Barcode.js'
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ =
superClass;
} // Encoding documentation
// http://www.gomaro.ch/ftproot/Laetus_PHARMA-CODE.pdf
var pharmacode = function(_Barcode) {
_inherits(pharmacode, _Barcode);
function pharmacode(data, options) {
_classCallCheck(this, pharmacode);
var _this = _possibleConstructorReturn(this, (pharmacode.__proto__ || Object.getPrototypeOf(pharmacode))
.call(this, data, options));
_this.number = parseInt(data, 10);
return _this;
}
_createClass(pharmacode, [{
key: "encode",
value: function encode() {
var z = this.number;
var result = "";
// http://i.imgur.com/RMm4UDJ.png
// (source: http://www.gomaro.ch/ftproot/Laetus_PHARMA-CODE.pdf, page: 34)
while (!isNaN(z) && z != 0) {
if (z % 2 === 0) {
// Even
result = "11100" + result;
z = (z - 2) / 2;
} else {
// Odd
result = "100" + result;
z = (z - 1) / 2;
}
}
// Remove the two last zeroes
result = result.slice(0, -2);
return {
data: result,
text: this.text
};
}
}, {
key: "valid",
value: function valid() {
return this.number >= 3 && this.number <= 131070;
}
}]);
return pharmacode;
}(_Barcode3);
export default pharmacode;

View File

@@ -0,0 +1,203 @@
<template xlang="wxml" minapp="mpvue">
<view class="tki-barcode">
<!-- #ifndef MP-ALIPAY -->
<canvas class="tki-barcode-canvas" :canvas-id="cid"
:style="{width:canvasWidth+'px',height:canvasHeight+'px'}" />
<!-- #endif -->
<!-- #ifdef MP-ALIPAY -->
<canvas :id="cid" :width="canvasWidth" :height="canvasHeight" class="tki-barcode-canvas" />
<!-- #endif -->
<image v-show="show" :src="result" :style="{width:canvasWidth+'px',height:canvasHeight+'px'}" />
</view>
</template>
<script>
// const barcode = require('./barcode.js');
import barCode from "./barcode.js"
const opations = {
// format: "CODE128",//选择要使用的条形码类型 微信支持的条码类型有 code128\code39\ena13\ean8\upc\itf14\
width: 4, //设置条之间的宽度
height: 120, //高度
displayValue: true, //是否在条形码下方显示文字
// text: "1234567890",//覆盖显示的文本
textAlign: "center", //设置文本的水平对齐方式
textPosition: "bottom", //设置文本的垂直位置
textMargin: 0, //设置条形码和文本之间的间距
fontSize: 24, //设置文本的大小
fontColor: "#000000", //设置文本的颜色
lineColor: "#000000", //设置条形码的颜色
background: "#FFFFFF", //设置条形码的背景色
margin: 0, //设置条形码周围的空白边距
marginTop: undefined, //设置条形码周围的上边距
marginBottom: undefined, //设置条形码周围的下边距
marginLeft: undefined, //设置条形码周围的左边距
marginRight: undefined, //设置条形码周围的右边距
}
export default {
name: "tkiBarcode",
props: {
show: {
type: Boolean,
default: true
},
cid: {
type: String,
default: 'tki-barcode-canvas'
},
unit: {
type: String,
default: 'upx'
},
val: {
type: String,
default: ''
},
format: {
type: String,
default: 'CODE128'
},
opations: {
type: Object,
default: function() {
return {}
}
},
onval: {
type: Boolean,
default: false
},
loadMake: {
type: Boolean,
default: true
},
},
data() {
return {
result: '',
canvasWidth: 0,
canvasHeight: 0,
defaultOpations: Object.assign({}, opations)
}
},
onUnload: function() {},
methods: {
_makeCode() {
let that = this
// 合并参数
Object.assign(this.defaultOpations, this.opations)
if (that.unit == "upx") {
if (that.defaultOpations.width) {
that.defaultOpations.width = uni.upx2px(that.defaultOpations.width)
}
if (that.defaultOpations.height) {
that.defaultOpations.height = uni.upx2px(that.defaultOpations.height)
}
if (that.defaultOpations.fontSize) {
that.defaultOpations.fontSize = uni.upx2px(that.defaultOpations.fontSize)
}
}
if (that._empty(that.defaultOpations.text)) {
that.defaultOpations.text = that.val
}
if (that._empty(that.defaultOpations.format)) {
that.defaultOpations.format = that.format
}
new barCode(that, that.cid, that.defaultOpations,
function(res) { // 生成条形码款高回调
that.canvasWidth = res.width
that.canvasHeight = res.height
},
function(res) { // 生成条形码的回调
// 返回值
that._result(res)
// 重置默认参数
that.defaultOpations = opations
},
);
},
_clearCode() {
this._result('')
},
_saveCode() {
let that = this;
if (this.result != "") {
uni.saveImageToPhotosAlbum({
filePath: that.result,
success: function() {
uni.showToast({
title: '条形码保存成功',
icon: 'success',
duration: 2000
});
}
});
}
},
_result(res) {
this.result = res;
this.$emit('result', res)
},
_empty(v) {
let tp = typeof v,
rt = false;
if (tp == "number" && String(v) == "") {
rt = true
} else if (tp == "undefined") {
rt = true
} else if (tp == "object") {
if (JSON.stringify(v) == "{}" || JSON.stringify(v) == "[]" || v == null) rt = true
} else if (tp == "string") {
if (v == "" || v == "undefined" || v == "null" || v == "{}" || v == "[]") rt = true
} else if (tp == "function") {
rt = false
}
return rt
}
},
watch: {
val(n, o) {
if (this.onval) {
if (n != o && !this._empty(n)) {
setTimeout(() => {
this._makeCode()
}, 0);
}
}
},
opations: {
handler(n, o) {
if (this.onval) {
if (!this._empty(n)) {
setTimeout(() => {
this._makeCode()
}, 0);
}
}
},
deep: true
}
},
mounted: function() {
if (this.loadMake) {
if (!this._empty(this.val)) {
setTimeout(() => {
this._makeCode()
}, 0);
}
}
},
}
</script>
<style>
.tki-barcode {
text-align: right;
position: relative;
}
.tki-barcode-canvas {
position: fixed !important;
top: -99999upx;
left: -99999upx;
z-index: -99999;
}
</style>

View File

@@ -0,0 +1,60 @@
<template>
<view :class="'jnpf-button jnpf-button-'+align">
<u-button :custom-style="customStyle" :type="realType" :disabled="disabled"
@click="onClick">{{buttonText}}</u-button>
</view>
</template>
<script>
export default {
name: 'jnpf-button',
props: {
align: {
default: 'left'
},
buttonText: {
default: ''
},
disabled: {
type: Boolean,
default: false
},
type: {
default: ''
}
},
computed: {
realType() {
return !this.type ? 'default' : this.type === 'danger' ? 'error' : this.type
}
},
data() {
return {
customStyle: {
display: 'inline-block'
}
}
},
methods: {
onClick(event) {
this.$emit('click', event)
}
}
}
</script>
<style lang="scss" scoped>
.jnpf-button {
width: 100%;
&.jnpf-button-left {
text-align: left;
}
&.jnpf-button-center {
text-align: center;
}
&.jnpf-button-right {
text-align: right;
}
}
</style>

View File

@@ -0,0 +1,303 @@
<template>
<view class="jnpf-calculation jnpf-calculation-right">
<view class="u-flex ">
<u-input input-align='right' v-model="innerValue" disabled placeholder='' />
<span class="unit" v-if="type === 2">{{ unitObj[dateCalConfig?.dateUnit] }}</span>
</view>
<view class="tips" v-if="isAmountChinese">{{rmbText}}</view>
</view>
</template>
<script>
import {
dayjs
} from '@/uni_modules/iRainna-dayjs/js_sdk/dayjs.min.js'
/**
* 中缀转后缀(逆波兰 Reverse Polish Notation
* @param {Array} exps - 中缀表达式数组
*/
const toRPN = exps => {
const s1 = [] // 符号栈
const s2 = [] // 输出栈
const getTopVal = (stack) => stack.length > 0 ? stack[stack.length - 1] : null
const levelCompare = (c1, c2) => {
const getIndex = c => ['+-', '×÷', '()'].findIndex(t => t.includes(c))
return getIndex(c1) - getIndex(c2)
}
exps.forEach(t => {
if (typeof t === 'string' && Number.isNaN(Number(t))) { // 是符号
if (t === '(') {
s1.push(t)
} else if (t === ')') {
let popVal
do {
popVal = s1.pop()
popVal !== '(' && s2.push(popVal)
} while (s1.length && popVal !== '(')
} else {
let topVal = getTopVal(s1)
if (!topVal) { // s1 为空 直接push
s1.push(t)
} else {
while (topVal && topVal !== '(' && levelCompare(topVal, t) >= 0) { // 优先级 >= t 弹出到s2
s2.push(s1.pop())
topVal = getTopVal(s1)
}
s1.push(t)
}
}
return
}
s2.push(t) // 数字直接入栈
})
while (s1.length) {
s2.push(s1.pop())
}
return s2
}
const calcRPN = rpnExps => {
rpnExps = rpnExps.concat()
const calc = (x, y, type) => {
let a1 = Number(x),
a2 = Number(y)
switch (type) {
case '+':
return a1 + a2;
case '-':
return a1 - a2;
case '×':
return a1 * a2;
case '÷':
return a1 / a2;
}
}
for (let i = 2; i < rpnExps.length; i++) {
if ('+-×÷'.includes(rpnExps[i])) {
let val = calc(rpnExps[i - 2], rpnExps[i - 1], rpnExps[i])
rpnExps.splice(i - 2, 3, val)
i = i - 2
}
}
return rpnExps[0]
}
const mergeNumberOfExps = expressions => {
const res = []
const isNumChar = n => /^[\d|\.]$/.test(n)
for (let i = 0; i < expressions.length; i++) {
if (i > 0 && isNumChar(expressions[i - 1]) && isNumChar(expressions[i])) {
res[res.length - 1] += expressions[i]
continue
}
res.push(expressions[i])
}
return res
}
export default {
name: 'jnpf-calculation',
props: {
modelValue: {
type: [String, Number],
default: ''
},
thousands: {
type: Boolean,
default: false
},
precision: {
default: 0
},
isAmountChinese: {
type: Boolean,
default: false
},
expression: {
type: Array,
default: []
},
config: {
type: Object,
default: {}
},
formData: {
type: Object,
default: {}
},
rowIndex: {
type: [String, Number],
default: ''
},
roundType: {
type: [String, Number],
default: 1
},
dateCalConfig: Object,
type: {
default: 1,
type: Number,
},
},
data() {
return {
innerValue: '',
RPN_EXP: toRPN(mergeNumberOfExps(this.expression)),
rmbText: '',
subValue: 0,
unitObj: {
d: '天',
h: '时',
M: '月',
m: '分',
s: '秒',
Y: '年',
},
startTime: new Date(),
endTime: new Date(),
}
},
watch: {
formData: {
handler(val, oldVal) {
setTimeout(() => {
this.execRPN()
}, 0)
},
deep: true,
immediate: true
},
modelValue: {
handler(val, oldVal) {
this.innerValue = val
},
deep: true,
immediate: true
},
},
methods: {
getRoundValue(val) {
const precision = this.precision || 0;
let truncatedNumber
if (this.roundType == 2) {
if (precision === 0) Math.trunc(val);
const factor = Math.pow(10, precision);
truncatedNumber = Math.trunc(val * factor) / factor;
return truncatedNumber
}
if (this.roundType == 3) return Math.ceil(val)
if (this.roundType == 4) return Math.floor(val);
return val.toFixed(precision)
},
/**
* 计算表达式
*/
execRPN() {
if (this.type === 2) {
if (this.dateCalConfig?.startTimeType == 1) this.startTime = this.dateCalConfig.startTimeValue;
if (this.dateCalConfig?.startTimeType == 2) this.startTime = this.getFormVal(this.dateCalConfig
.startRelationField);
let endTime = new Date();
if (this.dateCalConfig?.endTimeType == 1) this.endTime = this.dateCalConfig.endTimeValue;
if (this.dateCalConfig?.endTimeType == 2) this.endTime = this.getFormVal(this.dateCalConfig
.endRelationField);
this.innerValue = this.calDateDiff(this.startTime, this.endTime, this.dateCalConfig?.dateUnit);
this.$emit('update:modelValue', this.innerValue)
} else {
const temp = this.RPN_EXP.map(t => typeof t === 'object' ? this.getFormVal(t.__vModel__) : t)
this.setValue(temp)
this.subValue = JSON.parse(JSON.stringify(this.innerValue))
if (isNaN(this.innerValue)) this.innerValue = 0
this.rmbText = this.jnpf.getAmountChinese(Number(this.subValue) || 0)
this.$emit('update:modelValue', this.subValue)
if (this.thousands) this.innerValue = this.numFormat(this.innerValue)
}
},
calDateDiff(startDate, endDate, unit) {
if (!startDate || !endDate) return '';
const start = dayjs(startDate);
let end = dayjs(endDate);
if (end.hour() === 0 && end.minute() === 0 && end.second() === 0 && this.dateCalConfig?.dateFormat ===
2) {
end = end.endOf('d');
}
const diff = end.diff(start, unit == 'Y' ? 'y' : unit, true);
const data = !!diff || diff === 0 ? this.getRoundValue(diff) : '';
return data;
},
setValue(temp) {
let result = calcRPN(temp);
if (isNaN(result) || !isFinite(result)) {
this.innerValue = 0;
} else {
let num = Number(result);
if (this.roundType == 2) {
this.innerValue = num;
} else {
this.innerValue = Number(num.toFixed(this.precision ||
0));
}
}
this.innerValue = this.getRoundValue(parseFloat(this.innerValue));
},
/**
* 千分符
*/
numFormat(num) {
num = num.toString().split("."); // 分隔小数点
let arr = num[0].split("").reverse(); // 转换成字符数组并且倒序排列
let res = [];
for (let i = 0, len = arr.length; i < len; i++) {
if (i % 3 === 0 && i !== 0) res.push(","); // 添加分隔符
res.push(arr[i]);
}
res.reverse(); // 再次倒序成为正确的顺序
if (num[1]) { // 如果有小数的话添加小数部分
res = res.join("").concat("." + num[1]);
} else {
res = res.join("");
}
return res
},
/**
* 获取指定组件的值
*/
getFormVal(vModel) {
try {
if (vModel.indexOf('.') > -1) {
let [tableVModel, cmpVModel] = vModel.split('.');
if (typeof this.rowIndex === 'number') {
if (!Array.isArray(this.formData[tableVModel]) || this.formData[tableVModel].length < this
.rowIndex + 1) return 0;
return this.formData[tableVModel][this.rowIndex][cmpVModel] || 0;
} else {
if (!this.formData[tableVModel].length) return 0;
return this.formData[tableVModel].reduce((sum, c) => (c[cmpVModel] ? Number(c[cmpVModel]) :
0) + sum, 0);
}
}
return this.formData[vModel] || 0
} catch (error) {
console.warn('计算公式出错, 可能包含无效的组件值', error)
return 0
}
},
}
}
</script>
<style lang="scss" scoped>
.jnpf-calculation {
width: 100%;
&.jnpf-calculation-right {
text-align: right;
}
.tips {
color: #999999;
line-height: 40rpx;
}
.unit {
padding-left: 10rpx;
}
}
</style>

View File

@@ -0,0 +1,277 @@
<template>
<u-popup class="jnpf-tree-select-popup" width="100%" v-model="showPopup" length="auto" mode="right" :popup="false"
:safeAreaInsetBottom="safeAreaInsetBottom" :maskCloseAble="maskCloseAble" :z-index="uZIndex" @close="close">
<view class="jnpf-tree-select-body">
<view class="jnpf-tree-select-title">
<text class="icon-ym icon-ym-report-icon-preview-pagePre backIcon" @tap="close"></text>
<view class="title">级联选择</view>
</view>
<view class="jnpf-tree-select-search" v-if="filterable">
<u-search :placeholder="$t('app.apply.pleaseKeyword')" v-model="filterText" height="72"
:show-action="false" bg-color="#f0f2f6" shape="square">
</u-search>
</view>
<view class="jnpf-tree-selected">
<view class="jnpf-tree-selected-head">
<view>{{$t('component.jnpf.common.selected')}}</view>
<view v-if="multiple" class="clear-btn" @click="setCheckAll">
{{$t('component.jnpf.common.clearAll')}}
</view>
</view>
<view class="jnpf-tree-selected-box">
<scroll-view scroll-y="true" class="select-list">
<u-tag closeable @close="delSelect(index)" v-for="(list,index) in selectListText" :key="index"
:text="list" class="u-selectTag" />
</scroll-view>
</view>
</view>
<view class="jnpf-tree-select-tree">
<scroll-view :scroll-y="true" style="height: 100%">
<ly-tree ref="tree" :tree-data="options" check-on-click-node default-expand-all
:node-key="realProps.value" highlight-current :props="realProps" @node-click="handleNodeClick"
:filter-node-method="filterNode" />
</scroll-view>
</view>
<!-- 底部按钮 -->
<view class="jnpf-tree-select-actions">
<u-button class="buttom-btn" @click="close()">{{$t('common.cancelText')}}</u-button>
<u-button class="buttom-btn" type="primary"
@click.stop="handleConfirm">{{$t('common.okText')}}</u-button>
</view>
</view>
</u-popup>
</template>
<script>
/**
* tree-select 树形选择器
* @property {Boolean} v-model 布尔值变量,用于控制选择器的弹出与收起
* @property {Boolean} safe-area-inset-bottom 是否开启底部安全区适配(默认false)
* @property {String} cancel-color 取消按钮的颜色(默认#606266
* @property {String} confirm-color 确认按钮的颜色(默认#2979ff)
* @property {String} confirm-text 确认按钮的文字
* @property {String} cancel-text 取消按钮的文字
* @property {Boolean} mask-close-able 是否允许通过点击遮罩关闭Picker(默认true)
* @property {String Number} z-index 弹出时的z-index值(默认10075)
* @event {Function} confirm 点击确定按钮,返回当前选择的值
*/
const defaultProps = {
label: 'fullName',
value: 'id',
icon: 'icon',
children: 'children'
}
import {
getProvinceSelector
} from '@/api/common.js'
let _self;
export default {
name: "tree-select",
props: {
selectList: {
type: Array,
default () {
return [];
}
},
selectedId: {
type: Array,
default () {
return [];
}
},
selectData: {
type: Array,
default () {
return [];
}
},
options: {
type: Array,
default: () => []
},
// 是否显示边框
border: {
type: Boolean,
default: true
},
filterable: {
type: Boolean,
default: false
},
showAllLevels: {
type: Boolean,
default: true
},
clearable: {
type: Boolean,
default: false
},
// 通过双向绑定控制组件的弹出与收起
modelValue: {
type: Boolean,
default: false
},
// "取消"按钮的颜色
cancelColor: {
type: String,
default: '#606266'
},
// "确定"按钮的颜色
confirmColor: {
type: String,
default: '#2979ff'
},
// 弹出的z-index值
zIndex: {
type: [String, Number],
default: 0
},
safeAreaInsetBottom: {
type: Boolean,
default: false
},
// 是否允许通过点击遮罩关闭Picker
maskCloseAble: {
type: Boolean,
default: true
},
props: {
type: Object,
default: () => ({
label: 'fullName',
value: 'id',
icon: 'icon',
children: 'children',
isLeaf: 'isLeaf'
})
},
multiple: {
type: Boolean,
default: false
},
// 顶部标题
title: {
type: String,
default: ''
},
// 取消按钮的文字
cancelText: {
type: String,
default: '取消'
},
// 确认按钮的文字
confirmText: {
type: String,
default: '确认'
},
level: {
type: Number,
default: 0
}
},
data() {
return {
moving: false,
selectListText: [],
selectListId: [],
selectListData: [],
newListId: [],
filterText: '',
showPopup: false
};
},
watch: {
// 在select弹起的时候重新初始化所有数据
modelValue: {
immediate: true,
handler(val) {
this.showPopup = val
if (val) setTimeout(() => this.init(), 10);
}
},
filterText(val) {
this.$refs.tree.filter(val);
}
},
created() {
_self = this
this.init()
},
computed: {
uZIndex() {
// 如果用户有传递z-index值优先使用
return this.zIndex ? this.zIndex : this.$u.zIndex.popup;
},
realProps() {
return {
...defaultProps,
...this.props
}
}
},
methods: {
init() {
this.selectListText = this.$u.deepClone(this.selectList)
this.selectListId = this.$u.deepClone(this.selectedId)
this.selectListData = this.$u.deepClone(this.selectData)
},
filterNode(value, options) {
if (!value) return true;
return options[this.props.label].indexOf(value) !== -1;
},
handleNodeClick(obj) {
if (!obj.parentId && !obj.isLeaf) return
let allPath = this.$refs.tree.getNodePath(obj)
let list = []
let listId = []
let currentNode = obj.data
if (!this.multiple) {
this.selectListText = [];
this.selectListId = [];
this.selectListData = [];
}
let txt = ''
let ids = ''
for (let i = 0; i < allPath.length; i++) {
listId.push(allPath[i][this.props.value])
ids += (i ? ',' : '') + allPath[i][this.props.value]
txt += (i ? '/' : '') + allPath[i][this.props.label]
}
if (this.showAllLevels) {
this.selectListText.push(txt)
} else {
this.selectListText.push(currentNode[this.props.label])
}
this.selectListText = [...new Set(this.selectListText)]
var isExist = false;
for (var i = 0; i < this.selectListId.length; i++) {
if (this.selectListId[i].join(',') === ids) {
isExist = true;
break;
}
};
!isExist && this.selectListId.push(listId);
this.selectListData = allPath
},
delSelect(index) {
this.selectListText.splice(index, 1);
this.selectListId.splice(index, 1);
this.selectListData.splice(index, 1);
},
setCheckAll() {
this.selectListText = [];
this.selectListId = [];
this.selectListData = [];
this.$refs.tree.setCheckAll(false);
},
handleConfirm() {
this.$emit('confirm', this.selectListText, this.selectListId, this.selectListData);
this.close();
},
close() {
this.$emit('close', false);
}
}
};
</script>

View File

@@ -0,0 +1,151 @@
<template>
<view class="jnpf-cascader">
<selectBox v-model="innerValue" :disabled='disabled' :placeholder="placeholder" @openSelect="openSelect"
:select-open="selectShow" >
</selectBox>
<Tree v-if="selectShow" v-model="selectShow" :multiple="multiple" :props="props" :selectList="selectList"
:options="options" :selectedId="!multiple ? [modelValue] : modelValue" :filterable='filterable'
:selectData="selectData" :clearable="clearable" :showAllLevels="showAllLevels" @close="handleClose"
@confirm="handleConfirm" />
</view>
</template>
<script>
import selectBox from '@/components/selectBox'
import Tree from './Tree';
export default {
name: 'jnpf-cascader',
components: {
Tree,
selectBox
},
props: {
modelValue: {
default: ''
},
placeholder: {
type: String,
default: '请选择'
},
options: {
type: Array,
default: () => []
},
props: {
type: Object,
default: () => ({
label: 'fullName',
value: 'id',
children: 'children'
})
},
disabled: {
type: Boolean,
default: false
},
multiple: {
type: Boolean,
default: false
},
showAllLevels: {
type: Boolean,
default: true
},
filterable: {
type: Boolean,
default: false
},
clearable: {
type: Boolean,
default: false
},
},
watch: {
modelValue: {
handler(val) {
this.setDefault(this.modelValue)
},
immediate: true
},
options: {
handler(val) {
this.setDefault(this.modelValue)
},
deep: true
}
},
data() {
return {
selectShow: false,
innerValue: '',
selectList: [],
selectData: [],
allList: []
}
},
methods: {
async setDefault(value) {
this.innerValue = ''
this.selectData = []
this.selectList = []
if (!value || !value?.length) return
this.allList = await this.treeToArray(value)
if (!this.multiple) value = [value]
let txt = []
for (let i = 0; i < value.length; i++) {
let val = uni.$u.deepClone(value[i])
for (let j = 0; j < val.length; j++) {
inner: for (let k = 0; k < this.allList.length; k++) {
if (val[j] === this.allList[k][this.props.value]) {
val[j] = this.allList[k][this.props.label];
this.selectData.push(this.allList[k])
break;
}
}
}
txt.push(val)
}
this.selectList = txt.map(o => this.showAllLevels ? o.join('/') : o[o.length - 1])
this.innerValue = this.selectList.join()
},
async treeToArray() {
let options = uni.$u.deepClone(this.options)
let list = []
const loop = (options) => {
for (let i = 0; i < options.length; i++) {
const item = options[i]
list.push(item)
if (item[this.props.children] && Array.isArray(item[this.props.children])) {
loop(item[this.props.children])
}
}
}
loop(options)
return list
},
openSelect() {
if (this.disabled) return
this.selectShow = true
},
handleConfirm(e, selectId, selectData) {
this.selectList = e;
this.innerValue = e.join()
if (!this.multiple) {
this.$emit('update:modelValue', selectId[0])
this.$emit('change', selectId[0], selectData[0])
} else {
this.$emit('update:modelValue', selectId)
this.$emit('change', selectId, selectData)
}
},
handleClose() {
this.selectShow = false
}
}
}
</script>
<style lang="scss" scoped>
.jnpf-cascader {
width: 100%;
}
</style>

View File

@@ -0,0 +1,97 @@
<template>
<u-checkbox-group class="jnpf-checkbox" :disabled='disabled' :wrap="direction == 'horizontal' ? false : true"
@change="onChange">
<u-checkbox v-model="item.checked" v-for="(item, index) in optionList" :key="index" :name="item[props.value]"
:class="{'jnpf-checkbox-disabled':disabled}">
{{item[props.label]}}
</u-checkbox>
</u-checkbox-group>
</template>
<script>
export default {
name: 'jnpf-checkbox',
inheritAttrs: false,
props: {
modelValue: {
type: Array,
default: () => []
},
direction: {
type: String,
default: "horizontal"
},
options: {
type: Array,
default: () => []
},
props: {
type: Object,
default: () => ({
label: 'fullName',
value: 'id'
})
},
disabled: {
type: Boolean,
default: false
}
},
data() {
return {
optionList: []
}
},
watch: {
modelValue: {
handler(val) {
if (!val || !val?.length) return this.setColumnData()
this.setDefault()
},
immediate: true,
},
options: {
handler(val) {
this.setColumnData()
},
immediate: true,
}
},
methods: {
setDefault() {
if (!this.modelValue || !this.modelValue?.length) return
outer: for (let i = 0; i < this.modelValue.length; i++) {
inner: for (let j = 0; j < this.optionList.length; j++) {
if (this.modelValue[i] === this.optionList[j][this.props.value]) {
this.optionList[j].checked = true
break inner
}
}
}
},
setColumnData() {
this.optionList = this.options.map(o => ({
...o,
checked: false
}))
this.setDefault()
},
onChange(value) {
const selectData = this.optionList.filter(o => o.checked) || []
this.$emit('update:modelValue', value)
this.$emit('change', value, selectData)
},
}
}
</script>
<style lang="scss" scoped>
:deep(.u-checkbox__icon-wrap--square) {
border-color: #D9D9D9 !important;
}
.jnpf-checkbox-disabled {
:deep(.u-checkbox__icon-wrap--disabled) {
background-color: #E6E6E6 !important;
border-color: #D9D9D9 !important;
}
}
</style>

View File

@@ -0,0 +1,129 @@
<template>
<view class="jnpf-color-picker">
<view class="color-box" :class="{'color-disabled':disabled}" @click="open">
<view class="colorVal" :style="{backgroundColor:bgColor}">
<uni-icons type="bottom" size="10" color='#c7c7c7'></uni-icons>
</view>
</view>
<t-color-picker ref="colorPicker" :color="innerValue" @confirm="confirm" :colorFormat='colorFormat' />
</view>
</template>
<script>
import tColorPicker from './t-color-picker.vue'
import conversion from '@/libs/color-typeConversion.js'
export default {
name: 'jnpf-color-picker',
components: {
tColorPicker
},
props: {
modelValue: {
default: ''
},
colorFormat: {
type: String,
default: 'hex'
},
disabled: {
type: Boolean,
default: false
},
},
data() {
return {
bgColor: "#fff",
hsvObj: {},
hsvList: ['h', 's', 'v'],
innerValue: ''
};
},
watch: {
modelValue: {
handler(val) {
this.innerValue = val
this.setDafault()
},
immediate: true
}
},
methods: {
open(item) {
if (this.disabled) return
this.$refs.colorPicker.open();
},
confirm(e) {
this.bgColor = e.colorVal
this.$emit('update:modelValue', this.bgColor)
this.$emit('change', this.bgColor)
},
setDafault() {
if (!this.innerValue) return this.bgColor = '#fff'
this.$nextTick(() => {
if (this.colorFormat === 'hsv') {
let color = ""
var result = this.innerValue.match(/\(([^)]*)\)/)
result[1].split(',').forEach((o, i) => {
this.$set(this[this.colorFormat + 'Obj'], this[this.colorFormat + 'List'][i],
o)
})
color = conversion.hsv2rgb(this[this.colorFormat + 'Obj'].h, this[this.colorFormat + 'Obj']
.s,
this[this.colorFormat + 'Obj'].v)
this.bgColor = `rgb(${color.r},${color.g},${color.b})`
} else {
this.bgColor = this.innerValue
}
})
}
}
};
</script>
<style lang="scss">
.jnpf-color-picker {
flex: 1;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-end;
.color-box {
width: 70rpx;
height: 70rpx;
border: 1px solid #e6e6e6;
background-color: #fff;
border-radius: 10rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
&.color-disabled {
background-color: #E6E6E6 !important;
border-color: #D9D9D9 !important;
}
.colorVal {
width: 48rpx;
height: 48rpx;
border: 1px solid #999;
border-radius: 6rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #fff;
.colorVal-inner {
width: 100%;
height: 100%;
color: #c7c7c7;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
}
}
}
</style>

View File

@@ -0,0 +1,633 @@
<template>
<view v-show="show" class="t-wrapper" @touchmove.stop.prevent="moveHandle">
<view class="t-mask" :class="{active:active}" @click.stop="close"></view>
<view class="t-box" :class="{active:active}">
<view class="t-header">
<view class="t-header-button" @click="close">取消</view>
<view class="t-header-button" @click="confirm">确认</view>
</view>
<view class="t-color__box"
:style="{ background: 'rgb(' + bgcolor.r + ',' + bgcolor.g + ',' + bgcolor.b + ')'}">
<view class="t-background boxs" @touchstart="touchstart($event, 0)" @touchmove="touchmove($event, 0)"
@touchend="touchend($event, 0)">
<view class="t-color-mask"></view>
<view class="t-pointer" :style="{ top: site[0].top - 8 + 'px', left: site[0].left - 8 + 'px' }">
</view>
</view>
</view>
<view class="t-control__box">
<view class="t-control__color" v-if="colorFormat == 'rgba'">
<view class="t-control__color-content"
:style="{ background: 'rgba(' + rgba.r + ',' + rgba.g + ',' + rgba.b + ',' + rgba.a + ')' }">
</view>
</view>
<view class="t-control-box__item">
<view class="t-controller boxs" @touchstart="touchstart($event, 1)"
@touchmove="touchmove($event, 1)" @touchend="touchend($event, 1)">
<view class="t-hue">
<view class="t-circle" :style="{ left: site[1].left - 12 + 'px' }"></view>
</view>
</view>
<view class="t-controller boxs" @touchstart="touchstart($event, 2)"
@touchmove="touchmove($event, 2)" @touchend="touchend($event, 2)" v-if="colorFormat == 'rgba'">
<view class="t-transparency">
<view class="t-circle" :style="{ left: site[2].left - 12 + 'px' }"></view>
</view>
</view>
</view>
</view>
<view class="t-result__box">
<view class="t-result__item">
<view class="t-result__box-input">{{colorVal}}</view>
</view>
<!-- <template v-else>
<view class="t-result__item">
<view class="t-result__box-input">{{rgba.r}}</view>
<view class="t-result__box-text">R</view>
</view>
<view class="t-result__item">
<view class="t-result__box-input">{{rgba.g}}</view>
<view class="t-result__box-text">G</view>
</view>
<view class="t-result__item">
<view class="t-result__box-input">{{rgba.b}}</view>
<view class="t-result__box-text">B</view>
</view>
<view class="t-result__item" v-if="colorFormat === 'rgba'">
<view class="t-result__box-input">{{rgba.a}}</view>
<view class="t-result__box-text">A</view>
</view>
</template> -->
</view>
<view class="t-alternative" v-if="isCommonColor">
<view class="t-alternative__item" v-for="(item,index) in conversion.colorList" :key="index">
<view class="t-alternative__item-content"
:style="{ background: 'rgba(' + item.r + ',' + item.g + ',' + item.b + ',' + item.a + ')' }"
@click="selectColor(item)">
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import conversion from '@/libs/color-typeConversion.js'
export default {
props: {
color: {
default: ''
},
colorFormat: {
default: 'hex'
},
isCommonColor: {
type: Boolean,
default: false
}
},
data() {
return {
show: false,
active: false,
// rgba 颜色
rgba: {
r: 0,
g: 0,
b: 0,
a: 1
},
// hsb 颜色
hsb: {
h: 0,
s: 0,
b: 0
},
site: [{
top: 0,
left: 0
}, {
left: 0
}, {
left: 0
}],
index: 0,
bgcolor: {
r: 255,
g: 0,
b: 0,
a: 1
},
hex: '#000000',
hsvList: ['h', 's', 'v'],
hsvObj: {},
hslList: ['h', 's', 'l'],
hslObj: {},
colorVal: '#000000',
hsv: '',
rgbObj: {},
rgbList: ['r', 'g', 'b'],
rgbaList: ['r', 'g', 'b', 'a'],
rgbaObj: {},
hsl: '',
conversion: conversion
};
},
created() {
},
methods: {
open() {
this.show = true;
this.$nextTick(() => {
this.init();
setTimeout(() => {
this.active = true;
setTimeout(() => {
this.getSelectorQuery();
}, 350)
}, 50)
})
},
init() {
if (!this.color) return
if (this.colorFormat == 'rgb' || this.colorFormat == 'rgba' || this.colorFormat == 'hsv' || this
.colorFormat == 'hsl') {
//将字符串括号中的值取出
var result = this.color.match(/\(([^)]*)\)/)
result[1].split(',').forEach((o, i) => {
this.$set(this[this.colorFormat + 'Obj'], this[this.colorFormat + 'List'][i], o)
})
if (this.colorFormat == 'rgb' || this.colorFormat == 'rgba') {
this.rgba = this[this.colorFormat + 'Obj']
this.hsb = conversion.rgbToHex(this.rgba);
this.setValue(this.rgba)
}
if (this.colorFormat == 'hsv') {
this.rgba = conversion.hsv2rgb(this[this.colorFormat + 'Obj'].h, this[this.colorFormat + 'Obj'].s,
this[
this.colorFormat + 'Obj'].v)
this.hsb = conversion.rgbToHex(this.rgba);
this.setValue(this.rgba)
}
if (this.colorFormat == 'hsl') {
this.rgba = conversion.hsl2rgb(parseInt(this.hslObj.h), parseInt(this.hslObj.s), parseInt(this
.hslObj
.l))
this.hsb = conversion.rgbToHex(this.rgba);
this.setValue(this.rgba)
}
} else {
this.rgba = conversion.hex2rgba(this.color)
this.hsb = conversion.rgbToHex(this.rgba);
this.setValue(this.rgba)
}
},
moveHandle() {},
close() {
this.active = false;
this.$nextTick(() => {
setTimeout(() => {
this.show = false;
}, 500)
})
},
confirm() {
this.$emit('confirm', {
rgba: this.rgba,
hex: this.hex,
colorVal: this.colorVal,
hsv: this.hsv,
hsl: this.hsl
})
this.close();
},
// 常用颜色选择
selectColor(item) {
this.setColorBySelect(item)
},
touchstart(e, index) {
const {
clientX,
clientY
} = e.touches[0];
this.pageX = clientX;
this.pageY = clientY;
this.setPosition(clientX, clientY, index);
},
touchmove(e, index) {
const {
clientX,
clientY
} = e.touches[0];
this.moveX = clientX;
this.moveY = clientY;
this.setPosition(clientX, clientY, index);
},
touchend(e, index) {},
/**
* 设置位置
*/
setPosition(x, y, index) {
this.index = index;
const {
top,
left,
width,
height
} = this.position[index];
// 设置最大最小值
this.site[index].left = Math.max(0, Math.min(parseInt(x - left), width));
if (index === 0) {
this.site[index].top = Math.max(0, Math.min(parseInt(y - top), height));
// 设置颜色
this.hsb.s = parseInt((100 * this.site[index].left) / width);
this.hsb.b = parseInt(100 - (100 * this.site[index].top) / height);
this.setColor();
this.setValue(this.rgba);
} else {
this.setControl(index, this.site[index].left);
}
},
/**
* 设置 rgb 颜色
*/
setColor() {
const rgb = conversion.HSBToRGB(this.hsb);
this.rgba.r = rgb.r;
this.rgba.g = rgb.g;
this.rgba.b = rgb.b;
},
/**
* 设置二进制颜色
* @param {Object} rgb
*/
setValue(rgb) {
let hsv = conversion.rgb2hsv(rgb.r, rgb.g, rgb.b)
let hsl = conversion.rgb2hsl(rgb.r, rgb.g, rgb.b)
this.hsv = 'hsv(' + hsv.h + ',' + hsv.s + ',' + hsv.v + ')'
this.hex = '#' + conversion.rgbToHex(rgb);
this.hsl = 'hsl(' + hsl.h + ',' + hsl.s + ',' + hsl.l + ')'
if (this.colorFormat == 'hsv') {
for (let key in hsv) {
if (key != 'h') {
hsv[key] += '%'
}
}
this.colorVal = 'hsv(' + hsv.h + ',' + hsv.s + ',' + hsv.v + ')'
} else if (this.colorFormat == 'hsl') {
this.colorVal = 'hsl(' + hsl.h + ',' + hsl.s + ',' + hsl.l + ')'
} else if (this.colorFormat == 'rgba') {
this.colorVal = this.colorFormat + '(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ',' + rgb.a + ')'
} else if (this.colorFormat == 'rgb') {
this.colorVal = this.colorFormat + '(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ')'
} else {
this.colorVal = '#' + conversion.rgbToHex(rgb);
}
},
setControl(index, x) {
const {
top,
left,
width,
height
} = this.position[index];
if (index === 1) {
this.hsb.h = parseInt((360 * x) / width);
this.bgcolor = conversion.HSBToRGB({
h: this.hsb.h,
s: 100,
b: 100
});
this.setColor()
} else {
this.rgba.a = (x / width).toFixed(1);
}
this.setValue(this.rgba);
},
setColorBySelect(getrgb) {
const {
r,
g,
b,
a
} = getrgb;
let rgb = {}
rgb = {
r: r ? parseInt(r) : 0,
g: g ? parseInt(g) : 0,
b: b ? parseInt(b) : 0,
a: a ? a : 0,
};
this.rgba = rgb;
this.hsb = conversion.rgbToHsb(rgb);
this.changeViewByHsb();
},
changeViewByHsb() {
const [a, b, c] = this.position;
this.site[0].left = parseInt(this.hsb.s * a.width / 100);
this.site[0].top = parseInt((100 - this.hsb.b) * a.height / 100);
this.setColor(this.hsb.h);
this.setValue(this.rgba);
this.bgcolor = conversion.HSBToRGB({
h: this.hsb.h,
s: 100,
b: 100
});
this.site[1].left = this.hsb.h / 360 * b.width;
if (this.colorFormat == 'rgba') {
this.site[2].left = this.rgba.a * c.width;
}
},
getSelectorQuery() {
const views = uni.createSelectorQuery().in(this);
views.selectAll('.boxs').boundingClientRect(data => {
if (!data || data.length === 0) {
this.getSelectorQuery()
return
}
this.position = data;
// this.site[0].top = data[0].height;
// this.site[0].left = 0;
// this.site[1].left = data[1].width;
// this.site[2].left = data[2].width;
this.setColorBySelect(this.rgba);
})
.exec();
}
}
};
</script>
<style>
.t-wrapper {
position: fixed;
top: 0;
bottom: 0;
left: 0;
width: 100%;
box-sizing: border-box;
z-index: 9999;
}
.t-box {
width: 100%;
position: absolute;
bottom: 0;
padding: 30rpx 0;
padding-top: 0;
background: #fff;
transition: all 0.3s;
transform: translateY(100%);
}
.t-box.active {
transform: translateY(0%);
}
.t-header {
display: flex;
justify-content: space-between;
width: 100%;
height: 100rpx;
border-bottom: 1px #eee solid;
box-shadow: 1px 0 2px rgba(0, 0, 0, 0.1);
background: #fff;
}
.t-header-button {
display: flex;
align-items: center;
width: 150rpx;
height: 100rpx;
font-size: 30rpx;
color: #666;
padding-left: 20rpx;
}
.t-header-button:last-child {
justify-content: flex-end;
padding-right: 20rpx;
}
.t-mask {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.6);
z-index: -1;
transition: all 0.3s;
opacity: 0;
}
.t-mask.active {
opacity: 1;
}
.t-color__box {
position: relative;
height: 400rpx;
background: rgb(255, 0, 0);
overflow: hidden;
box-sizing: border-box;
margin: 0 20rpx;
margin-top: 20rpx;
box-sizing: border-box;
}
.t-background {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(to right, #fff, rgba(255, 255, 255, 0));
}
.t-color-mask {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 400rpx;
background: linear-gradient(to top, #000, rgba(0, 0, 0, 0));
}
.t-pointer {
position: absolute;
bottom: -8px;
left: -8px;
z-index: 2;
width: 15px;
height: 15px;
border: 1px #fff solid;
border-radius: 50%;
}
.t-show-color {
width: 100rpx;
height: 50rpx;
}
.t-control__box {
margin-top: 50rpx;
width: 100%;
display: flex;
padding-left: 20rpx;
box-sizing: border-box;
}
.t-control__color {
flex-shrink: 0;
width: 100rpx;
height: 100rpx;
border-radius: 50%;
background-color: #fff;
background-image: linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee),
linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee);
background-size: 36rpx 36rpx;
background-position: 0 0, 18rpx 18rpx;
border: 1px #eee solid;
overflow: hidden;
}
.t-control__color-content {
width: 100%;
height: 100%;
}
.t-control-box__item {
display: flex;
flex-direction: column;
justify-content: space-between;
width: 100%;
padding: 0 30rpx;
}
.t-controller {
position: relative;
width: 100%;
height: 16px;
background-color: #fff;
background-image: linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee),
linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee);
background-size: 32rpx 32rpx;
background-position: 0 0, 16rpx 16rpx;
}
.t-hue {
width: 100%;
height: 100%;
background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
}
.t-transparency {
width: 100%;
height: 100%;
background: linear-gradient(to right, rgba(0, 0, 0, 0) 0%, rgb(0, 0, 0));
}
.t-circle {
position: absolute;
/* right: -10px; */
top: -2px;
width: 20px;
height: 20px;
box-sizing: border-box;
border-radius: 50%;
background: #fff;
box-shadow: 0 0 2px 1px rgba(0, 0, 0, 0.1);
}
.t-result__box {
margin-top: 20rpx;
padding: 10rpx;
width: 100%;
display: flex;
box-sizing: border-box;
}
.t-result__item {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 10rpx;
width: 100%;
box-sizing: border-box;
}
.t-result__box-input {
padding: 10rpx 0;
width: 100%;
font-size: 28rpx;
box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.1);
color: #999;
text-align: center;
background: #fff;
}
.t-result__box-text {
margin-top: 10rpx;
font-size: 28rpx;
line-height: 2;
}
.t-select {
flex-shrink: 0;
width: 150rpx;
padding: 0 30rpx;
}
.t-select .t-result__box-input {
border-radius: 10rpx;
border: none;
color: #999;
box-shadow: 1px 1px 2px 1px rgba(0, 0, 0, 0.1);
background: #fff;
}
.t-select .t-result__box-input:active {
box-shadow: 0px 0px 1px 0px rgba(0, 0, 0, 0.1);
}
.t-alternative {
display: flex;
flex-wrap: wrap;
/* justify-content: space-between; */
width: 100%;
padding-right: 10rpx;
box-sizing: border-box;
}
.t-alternative__item {
margin-left: 12rpx;
margin-top: 10rpx;
width: 50rpx;
height: 50rpx;
border-radius: 10rpx;
background-color: #fff;
background-image: linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee),
linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee);
background-size: 36rpx 36rpx;
background-position: 0 0, 18rpx 18rpx;
border: 1px #eee solid;
overflow: hidden;
}
.t-alternative__item-content {
width: 50rpx;
height: 50rpx;
background: rgba(255, 0, 0, 0.5);
}
.t-alternative__item:active {
transition: all 0.3s;
transform: scale(1.1);
}
</style>

View File

@@ -0,0 +1,221 @@
<template>
<view class="jnpf-calculation jnpf-calculation-right">
<u-input input-align='right' :modelValue="jnpf.toDate(innerValue, format)" disabled placeholder='' />
</view>
</template>
<script>
import {
dayjs
} from '@/uni_modules/iRainna-dayjs/js_sdk/dayjs.min.js'
const calcRPN = rpnExps => {
rpnExps = rpnExps.concat()
const calc = (x, y, type) => {
let a1 = Number(x),
a2 = Number(y)
switch (type) {
case '+':
return a1 + a2;
case '-':
return a1 - a2;
case '×':
return a1 * a2;
case '÷':
return a1 / a2;
}
}
for (let i = 2; i < rpnExps.length; i++) {
if ('+-×÷'.includes(rpnExps[i])) {
let val = calc(rpnExps[i - 2], rpnExps[i - 1], rpnExps[i])
rpnExps.splice(i - 2, 3, val)
i = i - 2
}
}
return rpnExps[0]
}
const mergeNumberOfExps = expressions => {
const res = []
const isNumChar = n => /^[\d|\.]$/.test(n)
for (let i = 0; i < expressions.length; i++) {
if (i > 0 && isNumChar(expressions[i - 1]) && isNumChar(expressions[i])) {
res[res.length - 1] += expressions[i]
continue
}
res.push(expressions[i])
}
return res
}
export default {
name: 'jnpf-date-calculation',
props: {
modelValue: {
type: [String, Number],
default: ''
},
expression: {
type: Array,
default: []
},
formData: {
type: Object,
default: {}
},
rowIndex: {
type: [String, Number],
default: ''
},
startRelationField: String,
startTimeValue: [String, Number],
startTimeType: {
default: 1,
type: Number,
},
format: {
default: 'yyyy-MM-dd',
type: String,
},
},
data() {
return {
innerValue: '',
startTime: new Date(),
}
},
computed: {
getExp() {
return mergeNumberOfExps(this.expression)
},
},
watch: {
formData: {
handler(val, oldVal) {
setTimeout(() => {
this.execRPN()
}, 0)
},
deep: true,
immediate: true
},
modelValue: {
handler(val, oldVal) {
this.innerValue = val
},
deep: true,
immediate: true
},
},
methods: {
/**
* 计算表达式
*/
execRPN() {
const temp = this.getExp.map(t => typeof t === 'object' ? this.getFormVal(t.__vModel__) : t)
if (this.startTimeType == 1) this.startTime = this.startTimeValue;
if (this.startTimeType == 2) this.startTime = this.getFormVal(this.startRelationField);
this.innerValue = this.calcDate(this.startTime, this.getDateInfo(temp));
this.$emit('update:modelValue', this.innerValue)
},
getDateInfo(exp) {
let days = 0;
let months = 0;
let years = 0;
let hours = 0;
let minutes = 0;
let seconds = 0;
for (let i = 0; i < exp.length; i += 3) {
const sign = exp[i];
const value = Number.parseInt(exp[i + 1], 10);
const unit = exp[i + 2];
const factor = sign === '+' ? 1 : -1;
switch (unit) {
case 'd': {
days += factor * value;
break;
}
case 'h': {
hours += factor * value;
break;
}
case 'M': {
months += factor * value;
break;
}
case 'm': {
minutes += factor * value;
break;
}
case 's': {
seconds += factor * value;
break;
}
case 'Y': {
years += factor * value;
break;
}
}
}
return {
days,
hours,
minutes,
months,
seconds,
years
};
},
calcDate(date, change) {
if (!date) return '';
const newDate = new Date(date);
newDate.setFullYear(newDate.getFullYear() + change.years);
newDate.setMonth(newDate.getMonth() + change.months);
newDate.setDate(newDate.getDate() + change.days);
newDate.setHours(newDate.getHours() + change.hours);
newDate.setMinutes(newDate.getMinutes() + change.minutes);
newDate.setSeconds(newDate.getSeconds() + change.seconds);
return dayjs(newDate).startOf(this.jnpf.getDateTimeUnit(this.format)).valueOf();
},
/**
* 获取指定组件的值
*/
getFormVal(vModel) {
try {
if (vModel.indexOf('.') > -1) {
let [tableVModel, cmpVModel] = vModel.split('.');
if (typeof this.rowIndex === 'number') {
if (!Array.isArray(this.formData[tableVModel]) || this.formData[tableVModel].length < this
.rowIndex + 1) return 0;
return this.formData[tableVModel][this.rowIndex][cmpVModel] || 0;
} else {
if (!this.formData[tableVModel].length) return 0;
return this.formData[tableVModel].reduce((sum, c) => (c[cmpVModel] ? Number(c[cmpVModel]) :
0) + sum, 0);
}
}
return this.formData[vModel] || 0
} catch (error) {
console.warn('计算公式出错, 可能包含无效的组件值', error)
return 0
}
},
}
}
</script>
<style lang="scss" scoped>
.jnpf-calculation {
width: 100%;
&.jnpf-calculation-right {
text-align: right;
}
.tips {
color: #999999;
line-height: 40rpx;
}
.unit {
padding-left: 10rpx;
}
}
</style>

View File

@@ -0,0 +1,633 @@
<template>
<view>
<u-popup :maskCloseAble="maskCloseAble" mode="bottom" :popup="false" v-model="showPopup" length="auto"
:safeAreaInsetBottom="safeAreaInsetBottom" @close="close" :z-index="uZIndex">
<view class="u-datetime-picker">
<view class="u-picker-header">
<view class="u-btn-picker u-btn-picker--tips" :style="{ color: cancelColor }"
hover-class="u-opacity" :hover-stay-time="150" @tap="close()">{{cancelText}}</view>
<view class="u-picker__title">{{ title }}</view>
<view class="u-btn-picker u-btn-picker--primary"
:style="{ color: moving ? cancelColor : confirmColor }" hover-class="u-opacity"
:hover-stay-time="150" @tap.stop="getResult('confirm')">
{{confirmText}}
</view>
</view>
<view class="u-picker-body">
<picker-view :value="valueArr" @change="change" class="u-picker-view" @pickstart="pickstart"
@pickend="pickend" v-if="valueArr.length">
<picker-view-column v-if="!reset && params.year">
<view class="u-column-item" v-for="(item, index) in years" :key="index">
{{ item }}
<text class="u-text" v-if="showTimeTag"></text>
</view>
</picker-view-column>
<picker-view-column v-if="!reset && params.month">
<view class="u-column-item" v-for="(item, index) in months" :key="index">
{{ formatNumber(item) }}
<text class="u-text" v-if="showTimeTag"></text>
</view>
</picker-view-column>
<picker-view-column v-if="!reset && params.day">
<view class="u-column-item" v-for="(item, index) in days" :key="index">
{{ formatNumber(item) }}
<text class="u-text" v-if="showTimeTag"></text>
</view>
</picker-view-column>
<picker-view-column v-if="!reset && params.hour">
<view class="u-column-item" v-for="(item, index) in hours" :key="index">
{{ formatNumber(item) }}
<text class="u-text" v-if="showTimeTag"></text>
</view>
</picker-view-column>
<picker-view-column v-if="!reset && params.minute">
<view class="u-column-item" v-for="(item, index) in minutes" :key="index">
{{ formatNumber(item) }}
<text class="u-text" v-if="showTimeTag"></text>
</view>
</picker-view-column>
<picker-view-column v-if="!reset && params.second">
<view class="u-column-item" v-for="(item, index) in seconds" :key="index">
{{ formatNumber(item) }}
<text class="u-text" v-if="showTimeTag"></text>
</view>
</picker-view-column>
</picker-view>
</view>
</view>
</u-popup>
</view>
</template>
<script>
export default {
name: 'u-picker',
props: {
params: {
type: Object,
default () {
return {
year: true,
month: true,
day: true,
hour: false,
minute: false,
second: false,
timestamp: true,
};
}
},
// 当mode=selector或者mode=multiSelector时提供的数组
range: {
type: Array,
default () {
return [];
}
},
// 当mode=selector或者mode=multiSelector时提供的默认选中的下标
defaultSelector: {
type: Array,
default () {
return [0];
}
},
// 当 range 是一个 ArrayObject 时,通过 range-key 来指定 Object 中 key 的值作为选择器显示内容
rangeKey: {
type: String,
default: ''
},
// 模式选择region-地区类型time-时间类型selector-单列模式multiSelector-多列模式
mode: {
type: String,
default: 'time'
},
// 年份开始时间
startDate: {
type: String,
default: '1899-01-01 00:00:00'
},
// 年份结束时间
endDate: {
type: String,
default: '2250-12-31 23:59:59'
},
// "取消"按钮的颜色
cancelColor: {
type: String,
default: '#606266'
},
// "确定"按钮的颜色
confirmColor: {
type: String,
default: '#2979ff'
},
// 默认显示的时间
defaultTime: {
type: String,
default: ''
},
// 时间模式时,是否显示后面的年月日中文提示
showTimeTag: {
type: Boolean,
default: true
},
safeAreaInsetBottom: {
type: Boolean,
default: false
},
// 是否允许通过点击遮罩关闭Picker
maskCloseAble: {
type: Boolean,
default: false
},
// 通过双向绑定控制组件的弹出与收起
modelValue: {
type: Boolean,
default: false
},
// 弹出的z-index值
zIndex: {
type: [String, Number],
default: 0
},
// 顶部标题
title: {
type: String,
default: ''
},
// 取消按钮的文字
cancelText: {
type: String,
default: '取消'
},
// 确认按钮的文字
confirmText: {
type: String,
default: '确认'
},
format: {
type: String,
default: 'yyyy-MM-dd HH:mm:ss'
}
},
data() {
return {
years: [],
months: [],
days: [],
hours: [],
minutes: [],
seconds: [],
year: 0,
month: 0,
day: 0,
hour: 0,
minute: 0,
second: 0,
reset: false,
valueArr: [],
moving: false, // 列是否还在滑动中,微信小程序如果在滑动中就点确定,结果可能不准确
showPopup: false
};
},
mounted() {
this.init();
},
computed: {
propsChange() {
// 引用这几个变量,是为了监听其变化
return `${this.mode}-${this.defaultTime}-${this.startYear}-${this.endYear}-${this.defaultRegion}-${this.areaCode}`;
},
yearAndMonth() {
return `${this.year}-${this.month}`;
},
uZIndex() {
// 如果用户有传递z-index值优先使用
return this.zIndex ? this.zIndex : this.$u.zIndex.popup;
}
},
watch: {
propsChange() {
this.reset = true;
setTimeout(() => this.init(), 10);
},
// watch监听月份的变化实时变更日的天数因为不同月份天数不一样
// 一个月可能有3031天甚至闰年2月的29天平年2月28天
yearAndMonth(val) {
if (this.params.year) this.setDays();
},
// 微信和QQ小程序由于一些奇怪的原因(故同时对所有平台均初始化一遍),需要重新初始化才能显示正确的值
modelValue: {
handler(val) {
if (val) {
this.showPopup = val
this.reset = true;
setTimeout(() => this.init(), 10);
}
},
immediate: true
}
},
methods: {
// 标识滑动开始,只有微信小程序才有这样的事件
pickstart() {
// #ifdef MP-WEIXIN
this.moving = true;
// #endif
},
// 标识滑动结束
pickend() {
// #ifdef MP-WEIXIN
this.moving = false;
// #endif
},
getIndex: function(arr, val) {
let index = arr.indexOf(val);
// 如果index为-1(即找不到index值)~(-1)=-(-1)-1=0导致条件不成立
return ~index ? index : 0;
},
//日期时间处理
initTimeValue() {
// 格式化时间在IE浏览器(uni不存在此情况),无法识别日期间的"-"间隔符号
let fdate = this.defaultTime.replace(/\-/g, '/');
fdate = fdate && fdate.indexOf('/') == -1 ? `1899/01/01 ${fdate}` : fdate;
let time = null;
if (fdate) time = new Date(fdate);
else time = new Date();
// 获取年日月时分秒
this.year = time.getFullYear();
this.month = Number(time.getMonth()) + 1;
this.day = time.getDate();
this.hour = time.getHours();
this.minute = time.getMinutes();
this.second = time.getSeconds();
},
init() {
this.valueArr = [];
this.reset = false;
this.initTimeValue();
if (this.params.year) {
this.valueArr.push(0);
this.setYears();
}
if (this.params.month) {
this.valueArr.push(0);
this.setMonths();
}
if (this.params.day) {
this.valueArr.push(0);
this.setDays();
}
if (this.params.hour) {
this.valueArr.push(0);
this.setHours();
}
if (this.params.minute) {
this.valueArr.push(0);
this.setMinutes();
}
if (this.params.second) {
this.valueArr.push(0);
this.setSeconds();
}
},
// 设置picker的某一列值
setYears() {
// 获取年份集合
this.generateArray('year');
if (this.years[0] > this.year) this.year = this.years[0]
if (this.years[this.years.length - 1] < this.year) this.year = this.years[this.years.length - 1]
// 设置this.valueArr某一项的值是为了让picker预选中某一个值
this.valueArr.splice(this.valueArr.length - 1, 1, this.getIndex(this.years, this.year));
},
setMonths() {
this.generateArray('month');
if (this.months[0] > this.month) this.month = this.months[0]
if (this.months[this.months.length - 1] < this.month) this.month = this.months[this.months.length - 1]
this.valueArr.splice(this.valueArr.length - 1, 1, this.getIndex(this.months, this.month));
},
setDays() {
let totalDays = new Date(this.year, this.month, 0).getDate();
this.generateArray('day');
let index = 0;
// 这里不能使用类似setMonths()中的this.valueArr.splice(this.valueArr.length - 1, xxx)做法
// 因为this.month和this.year变化时会触发watch中的this.setDays()导致this.valueArr.length计算有误
if (this.params.year && this.params.month) index = 2;
else if (this.params.month) index = 1;
else if (this.params.year) index = 1;
else index = 0;
// 当月份变化时,会导致日期的天数也会变化,如果原来选的天数大于变化后的天数,则重置为变化后的最大值
// 比如原来选中3月31日调整为2月后日期变为最大29这时如果day值继续为31显然不合理于是将其置为29(picker-column从1开始)
// if (this.day > this.days.length) this.day = this.days.length;
if (this.days[0] > this.day) this.day = this.days[0]
if (this.days[this.days.length - 1] < this.day) this.day = this.days[this.days.length - 1]
this.valueArr.splice(index, 1, this.getIndex(this.days, this.day));
},
setHours() {
this.generateArray('hour');
if (this.hours[0] > this.hour) this.hour = this.hours[0]
if (this.hours[this.hours.length - 1] < this.hour) this.hour = this.hours[this.hours.length - 1]
this.valueArr.splice(this.valueArr.length - 1, 1, this.getIndex(this.hours, this.hour));
},
setMinutes() {
this.generateArray('minute');
if (this.minutes[0] > this.minute) this.minute = this.minutes[0]
if (this.minutes[this.minutes.length - 1] < this.minute) this.minute = this.minutes[this.minutes.length -
1]
this.valueArr.splice(this.valueArr.length - 1, 1, this.getIndex(this.minutes, this.minute));
},
setSeconds() {
this.generateArray('second');
if (this.seconds[0] > this.second) this.second = this.seconds[0]
if (this.seconds[this.seconds.length - 1] < this.second) this.second = this.seconds[this.seconds.length -
1]
this.valueArr.splice(this.valueArr.length - 1, 1, this.getIndex(this.seconds, this.second));
},
generateArray(type) {
let startArr = this.startDate.split(" "); //开始日期时间
let endArr = this.endDate.split(" "); //结束日期时间
if (!this.month) this.month = this.months[this.months.length - 1]
let totalDays = new Date(this.year, this.month, 0).getDate(); //当月天数
//开始年月日时分秒
let startDateArr = startArr[0] ? startArr[0].split("-") : []; //开始日期
let startTimeArr = startArr[1] ? startArr[1].split(":") : []; //开始时间
let startYear = Number(startDateArr[0]) || 1; //开始年
let startMonth = Number(startDateArr[1]) || 1; //开始月
let startDay = Number(startDateArr[2]) || 1; //开始天数
let startHour = Number(startTimeArr[0]) || 0 //开始小时
let startMinute = Number(startTimeArr[1]) || 0 //开始分钟
let startSecond = Number(startTimeArr[2]) || 0 //开始秒
//结束年月日时分秒
let endDateArr = endArr[0] ? endArr[0].split("-") : [] //结束日期
let endTimeArr = endArr[1] ? endArr[1].split(":") : []; //结束时间
let endYear = Number(endDateArr[0]) || 12; //结束年
let endMonth = Number(endDateArr[1]) || 12; //结束月
let endDay = Number(endDateArr[2]) || totalDays; //结束天数
let endHour = Number(endTimeArr[0]) || 0 //结束小时
let endMinute = Number(endTimeArr[1]) || 0 //结束分钟
let endSecond = Number(endTimeArr[2]) || 0 //结束秒
// 转为数值格式否则用户给end-year等传递字符串值时下面的end+1会导致字符串拼接而不是相加
if (type == 'year') {
startYear = Number(startYear);
endYear = Number(endYear);
endYear = endYear > startYear ? endYear : startYear;
// 生成数组,获取其中的索引,并剪出来
this.years = [...Array(endYear + 1).keys()].slice(startYear);
this.generateArray('month')
} else if (type == 'month') {
let months = []
if (startYear == Number(this.year)) {
if (endYear == Number(this.year)) { // 起始年份,末尾年份一样时
months = [...Array(endMonth + 1).keys()].slice(startMonth);
} else {
months = [...Array(12 + 1).keys()].slice(startMonth);
}
} else if (endYear == Number(this.year)) {
months = [...Array(endMonth + 1).keys()].slice(1);
} else {
months = [...Array(12 + 1).keys()].slice(1);
}
this.months = months
this.generateArray('day')
} else if (type === 'day') {
let days = []
if (startYear == Number(this.year) && startMonth == Number(this.month)) {
if (endYear == Number(this.year) && endMonth == Number(this
.month)) {
days = [...Array(endDay + 1).keys()].slice(startDay);
} else {
days = [...Array(totalDays + 1).keys()].slice(startDay);
}
} else if (endYear == Number(this.year) && endMonth == Number(this.month)) {
days = [...Array(endDay + 1).keys()].slice(1);
} else {
days = [...Array(totalDays + 1).keys()].slice(1);
}
this.days = days
this.generateArray('hour')
} else if (type === 'hour') {
let hours = []
if (startYear == Number(this.year) && startMonth == Number(this.month) && startDay == Number(
this.day)) {
if (endYear == Number(this.year) && endMonth == Number(this.month) && endDay == Number(this
.day)) {
hours = [...Array(endHour + 1).keys()].slice(startHour);
} else {
hours = [...Array(23 + 1).keys()].slice(startHour);
}
} else if (endYear == Number(this.year) && endMonth == Number(this.month) && endDay == Number(
this.day)) {
hours = [...Array(endHour + 1).keys()].slice(0);
} else {
hours = [...Array(23 + 1).keys()].slice(0);
}
this.hours = hours
this.generateArray('minute')
} else if (type === 'minute') {
let minutes = []
if (startYear == Number(this.year) && startMonth == Number(this.month) && startDay == Number(
this.day) && startHour == Number(this.hour)) {
if (endYear == Number(this.year) && endMonth == Number(this.month) && endDay == Number(this.day) &&
endHour == Number(this.hour)) {
minutes = [...Array(endMinute + 1).keys()].slice(startMinute);
} else {
minutes = [...Array(59 + 1).keys()].slice(startMinute);
}
} else if (endYear == Number(this.year) && endMonth == Number(this.month) && endDay == Number(
this.day) && endHour == Number(this.hour)) {
minutes = [...Array(endMinute + 1).keys()].slice(0);
} else {
minutes = [...Array(59 + 1).keys()].slice(0);
}
this.minutes = minutes
this.generateArray('seconds')
} else {
let seconds = []
if (startYear == Number(this.year) && startMonth == Number(this.month) && startDay == Number(
this.day) && startHour == Number(this.hour) && startMinute ==
Number(this.minute)) {
if (endYear == Number(this.year) && endMonth == Number(this.month) && endDay == Number(this
.day) && endHour == Number(this.hour) && endMinute ==
Number(this.minute)) {
seconds = [...Array(endSecond + 1).keys()].slice(startSecond);
} else {
seconds = [...Array(59 + 1).keys()].slice(startSecond);
}
} else if (endYear == Number(this.year) && endMonth == Number(this.month) && endDay == Number(this
.day) && endHour == Number(this.hour) && endMinute == Number(
this.minute)) {
seconds = [...Array(endSecond + 1).keys()].slice(0);
} else {
seconds = [...Array(59 + 1).keys()].slice(0);
}
this.seconds = seconds
}
},
close() {
this.$emit('close')
},
// 用户更改picker的列选项
change(e) {
this.valueArr = e.detail.value;
let i = 0;
// 这里使用i++是因为this.valueArr数组的长度是不确定长度的它根据this.params的值来配置长度
// 进入if规则i会加1保证了能获取准确的值
if (this.params.year) {
this.year = this.years[this.valueArr[i++]];
this.generateArray('year')
}
if (this.params.month) {
this.month = this.months[this.valueArr[i++]];
this.generateArray('month')
}
if (this.params.day) {
const index = this.valueArr[i++]
this.day = this.days[index] ? this.days[index] : this.days[0];
this.generateArray('day')
}
if (this.params.hour) {
this.hour = this.hours[this.valueArr[i++]];
this.generateArray('hour')
}
if (this.params.minute) {
this.minute = this.minutes[this.valueArr[i++]];
this.generateArray('minute')
}
if (this.params.second) {
this.second = this.seconds[this.valueArr[i++]];
this.generateArray('second')
}
},
// 用户点击确定按钮
getResult() {
// #ifdef MP-WEIXIN
if (this.moving) return;
// #endif
let result = {};
// 只返回用户在this.params中配置了为true的字段
if (this.params.year) result.year = this.formatNumber(this.year || 0);
if (this.params.month) result.month = this.formatNumber(this.month || 0);
if (this.params.day) result.day = this.formatNumber(this.day || 0);
if (this.params.hour) result.hour = this.formatNumber(this.hour || 0);
if (this.params.minute) result.minute = this.formatNumber(this.minute || 0);
if (this.params.second) result.second = this.formatNumber(this.second || 0);
if (this.params.timestamp) result.timestamp = this.getTimestamp();
this.$emit('confirm', result);
this.close();
},
// 小于10前面补0用于月份日期时分秒等
formatNumber(num) {
return +num < 10 ? '0' + num : String(num);
},
// 获取时间戳
getTimestamp() {
let format = this.jnpf.handelFormat(this.format)
let timeType = format === 'yyyy' ? '/01/01 00:00:00' : format === 'yyyy-MM' ? '/01 00:00:00' :
format === 'yyyy-MM-dd' ?
' 00:00:00' : ''
// yyyy-mm-dd为安卓写法不支持iOS需要使用"/"分隔,才能二者兼容
let time = "";
if (this.params.year && !this.params.month && !this.params.day && !this.params.hour && !this.params
.minute && !this.params.second) {
time = this.year + timeType
} else if (this.params.year && this.params.month && !this.params.day && !this.params.hour && !this.params
.minute && !this.params.second) {
time = this.year + '/' + this.month + timeType
} else if (this.params.year && this.params.month && this.params.day && !this.params.hour && !this.params
.minute && !this.params.second) {
time = this.year + '/' + this.month + '/' + this.day + timeType
} else if (this.params.year && this.params.month && this.params.day && this.params.hour && !this.params
.minute && !this.params.second) {
time = this.year + '/' + this.month + '/' + this.day + " " + this.hour + timeType
} else if (this.params.year && this.params.month && this.params.day && this.params.hour && this.params
.minute && !this.params.second) {
time = this.year + '/' + this.month + '/' + this.day + " " + this.hour + ":" + this.minute + timeType
} else {
time = this.year + '/' + this.month + '/' + this.day + " " + this.hour + ":" + this.minute + ":" + this
.second + timeType
}
return new Date(time).getTime();
}
}
};
</script>
<style lang="scss" scoped>
.u-datetime-picker {
position: relative;
z-index: 999;
}
.u-picker-view {
height: 100%;
box-sizing: border-box;
}
.u-picker-header {
width: 100%;
height: 90rpx;
padding: 0 40rpx;
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
font-size: 30rpx;
background: #fff;
position: relative;
}
.u-picker-header::after {
content: '';
position: absolute;
border-bottom: 1rpx solid #eaeef1;
-webkit-transform: scaleY(0.5);
transform: scaleY(0.5);
bottom: 0;
right: 0;
left: 0;
}
.u-picker__title {
color: $u-content-color;
}
.u-picker-body {
width: 100%;
height: 500rpx;
overflow: hidden;
background-color: #fff;
}
.u-column-item {
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
color: $u-main-color;
padding: 0 8rpx;
}
.u-text {
font-size: 24rpx;
padding-left: 8rpx;
}
.u-btn-picker {
padding: 16rpx;
box-sizing: border-box;
text-align: center;
text-decoration: none;
}
.u-opacity {
opacity: 0.5;
}
.u-btn-picker--primary {
color: $u-type-primary;
}
.u-btn-picker--tips {
color: $u-tips-color;
}
</style>

View File

@@ -0,0 +1,210 @@
<template>
<view class="jnpf-date-time">
<selectBox v-model="innerValue" :disabled='disabled' :placeholder="placeholder" @openSelect="openSelect"
:select-open="selectShow" >
</selectBox>
<Select v-if="selectShow" v-model="selectShow" mode="time" :defaultTime="defaultTime" :params="params"
:startDate="startDate" :endDate="endDate" :format='format' @close="handleClose" @confirm="handleConfirm" />
</view>
</template>
<script>
import Select from './Select.vue';
import selectBox from '@/components/selectBox'
export default {
name: 'jnpf-dateTime',
components: {
Select,
selectBox
},
props: {
scene: {
type: String,
default: 'form'
},
inputType: {
type: String,
default: 'select'
},
modelValue: {
type: [String, Number],
default: ''
},
placeholder: {
type: String,
default: '请选择'
},
disabled: {
type: Boolean,
default: false
},
type: {
type: String,
default: 'date'
},
startTime: {
type: [String, Number],
default: 0
},
selectType: {
type: String,
default: ''
},
endTime: {
type: [String, Number],
default: 0
},
format: {
type: String,
default: 'yyyy-MM-dd HH:mm:ss'
}
},
data() {
return {
startDate: '',
endDate: '',
params: {
year: true,
month: true,
day: true,
hour: true,
minute: true,
second: true,
timestamp: true
},
defaultTime: '',
selectShow: false,
innerValue: '',
startTimestamp: -25140,
endTimestamp: 7289625599000,
formatObj: {
'yyyy': 'yyyy',
'yyyy-MM': 'yyyy-mm',
'yyyy-MM-dd': 'yyyy-mm-dd',
'yyyy-MM-dd HH:mm': 'yyyy-mm-dd hh:MM',
'yyyy-MM-dd HH:mm:ss': 'yyyy-mm-dd hh:MM:ss',
'HH:mm:ss': 'hh:MM:ss',
"HH:mm": "hh:MM",
'YYYY': 'yyyy',
'YYYY-MM': 'yyyy-mm',
'YYYY-MM-DD': 'yyyy-mm-dd',
'YYYY-MM-DD HH:mm': 'yyyy-mm-dd hh:MM',
'YYYY-MM-DD HH:mm:ss': 'yyyy-mm-dd hh:MM:ss',
}
}
},
watch: {
modelValue: {
handler(val) {
this.setDefault()
},
immediate: true,
deep: true
},
startTime(val) {
this.setMode()
},
endTime(val) {
this.setMode()
}
},
created() {
this.setMode()
},
methods: {
setMode() {
let str = this.formatObj[this.format] || 'yyyy-mm-dd hh:MM:ss'
let formatArr = str.trim().split(" ")
let startYear = '970'
if (this.type === 'time') {
let t = formatArr[0].split(":") || []
this.params = {
...this.params,
year: false,
month: false,
day: false,
hour: t.includes('hh'),
minute: t.includes('MM'),
second: t.includes('ss'),
}
this.startDate = this.startTime ? this.getYearDate() + ' ' + this.startTime : this.getYearDate() +
' ' + "00:00:00"
this.endDate = this.endTime ? this.getYearDate() + ' ' + this.endTime : this.getYearDate() + ' ' +
"23:59:59"
} else {
let y = formatArr[0] ? formatArr[0].split("-") : []
let t = formatArr[1] ? formatArr[1].split(":") : []
this.params = {
...this.params,
year: y.includes('yyyy'),
month: y.includes('mm'),
day: y.includes('dd'),
hour: t.includes('hh'),
minute: t.includes('MM'),
second: t.includes('ss'),
}
// #ifdef APP
const sys = uni.getSystemInfoSync()
let platform = sys.platform
startYear = platform === 'ios' ? '1899' : '970'
// #endif
this.startDate = this.startTime ? this.$u.timeFormat(this.startTime, str) : startYear + '-1-1 00:00:00'
this.endDate = this.endTime ? this.$u.timeFormat(this.endTime, str) : '2500-12-31 23:59:59'
}
},
getYearDate() {
let date = new Date();
let year = date.getFullYear()
let month = date.getMonth() + 1
let day = date.getDate()
return year + '-' + month + '-' + day
},
setDefault() {
if (!this.modelValue) return this.innerValue = ''
if (this.type === 'time') {
let valueArr = this.modelValue.split(':')
let formatArr = this.formatObj[this.format].split(':')
this.innerValue = this.modelValue
if (valueArr.length != formatArr.length) this.innerValue = valueArr[0] + ':' + valueArr[1]
this.defaultTime = this.getYearDate() + ' ' + this.modelValue
} else {
const format = 'yyyy-mm-dd hh:MM:ss'
this.innerValue = this.$u.timeFormat(Number(this.modelValue), this.formatObj[this.format])
this.defaultTime = this.$u.timeFormat(Number(this.modelValue), format)
}
},
openSelect() {
uni.hideKeyboard()
if (this.disabled) return
if (new Date(this.startDate).getTime() > new Date(this.endDate).getTime()) return this
.$u.toast('开始时间不能大于结束时间')
this.selectShow = true
},
handleConfirm(e) {
let newFormat = this.format
let timeType = newFormat === 'yyyy' ? '/01/01 00:00:00' : newFormat === 'yyyy-MM' ? '/01 00:00:00' :
newFormat === 'yyyy-MM-dd' ?
' 00:00:00' : ''
this.innerValue = ''
if (this.params.year) this.innerValue += e.year
if (this.params.month) this.innerValue += '-' + e.month
if (this.params.day) this.innerValue += '-' + e.day
if (this.params.hour) this.innerValue += (this.type === 'time' ? '' : ' ') + e.hour
if (this.params.minute) this.innerValue += ':' + e.minute
if (this.params.second) this.innerValue += ':' + e.second
const value = this.type === 'time' ? this.innerValue : e.timestamp
if (this.modelValue === value) return
this.$emit('update:modelValue', value)
this.$emit('change', value, this.selectType)
},
handleClose() {
this.selectShow = false
}
}
}
</script>
<style lang="scss" scoped>
.jnpf-date-time {
width: 100%;
}
</style>

View File

@@ -0,0 +1,141 @@
<template>
<view class="jnpf-date-range">
<JnpfDatePicker v-if="type=='date'" v-model="startValue" placeholder="开始日期" :disabled="disabled"
inputType="text" scene="searchList" :format="format" @change="change" :defaultTime="startDefaultTime"
selectType='start' :key="key" ref="dateTime" />
<JnpfTimePicker v-else v-model="startValue" placeholder="开始时间" :disabled="disabled" inputType="text"
scene="searchList" :format="format" @change="change" :defaultTime="startDefaultTime" selectType='start'
:key="key" ref="dateTime" />
<view class="u-p-l-10 u-p-r-10"></view>
<JnpfDatePicker v-if="type=='date'" v-model="endValue" placeholder="结束日期" :disabled="disabled" inputType="text"
scene="searchList" :format="format" @change="change" :defaultTime="endDefaultTime" selectType='end'
:key="key+1" ref="dateTime" />
<JnpfTimePicker v-else v-model="endValue" placeholder="结束时间" :disabled="disabled" inputType="text"
scene="searchList" :format="format" @change="change" :defaultTime="endDefaultTime" selectType='end'
:key="key+1" ref="dateTime" />
</view>
</template>
<script>
const DEFAULT_FORMAT = 'yyyy-mm-dd hh:MM:ss';
export default {
name: 'jnpf-date-range',
props: {
modelValue: {
type: [Array, String],
default: () => []
},
placeholder: {
type: String,
default: '请选择日期范围'
},
disabled: {
type: Boolean,
default: false
},
format: {
type: String,
default: 'yyyy-MM-dd HH:mm:ss'
},
type: {
type: String,
default: 'date'
}
},
data() {
return {
startDefaultTime: '',
endDefaultTime: '',
startValue: '',
endValue: '',
datetimerange: [],
datetimerangeObj: {},
key: +new Date()
}
},
watch: {
modelValue: {
handler(val) {
if (Array.isArray(val) && val.length) {
// 当 modelValue 是有效数组时,更新本地状态
this.startValue = val[0];
this.endValue = val[1];
this.$set(this.datetimerangeObj, 'start', val[0]);
this.$set(this.datetimerangeObj, 'end', val[1]);
} else {
// 清空本地状态
this.startValue = '';
this.endValue = '';
this.datetimerangeObj = {};
this.datetimerange = [];
// 仅当 val 不是空数组时,才触发更新
if (!Array.isArray(val) || val.length !== 0) {
this.$emit('update:modelValue', []);
}
}
},
immediate: true,
deep: true
}
},
methods: {
change(e, type) {
this.datetimerange = [];
this.$set(this.datetimerangeObj, type, e || '');
// 始终使用开始时间作为参考时间
const startValue = this.datetimerangeObj.start;
this.setDefaultTime(startValue);
this.handleValue();
},
setDefaultTime(value) {
this.$refs.dateTime.defaultTime = this.type === 'time' ? value : this.$u.timeFormat(value, DEFAULT_FORMAT);
},
handleValue() {
const {
start,
end
} = this.datetimerangeObj;
this.datetimerange = [start, end];
if (this.shouldValidate()) {
if (start > end) {
this.handleInvalidRange();
return;
}
}
this.emitUpdate();
},
shouldValidate() {
return this.datetimerangeObj.start && this.datetimerangeObj.end;
},
handleInvalidRange() {
this.$u.toast('开始时间不能大于结束时间');
this.clearValues();
},
clearValues() {
setTimeout(() => {
this.startValue = "";
this.endValue = "";
this.datetimerangeObj = {};
this.datetimerange = [];
this.emitUpdate();
this.refreshComponent();
}, 500);
},
emitUpdate() {
this.$emit('update:modelValue', this.datetimerange);
},
refreshComponent() {
this.key = +new Date();
}
}
}
</script>

View File

@@ -0,0 +1,13 @@
<template>
<u-divider half-width="200" height="80">{{content}}</u-divider>
</template>
<script>
export default {
name: 'jnpf-divider',
props: {
content: {
default: ''
}
},
}
</script>

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -0,0 +1,274 @@
<template>
<view class="jnpf-editor">
<template v-if="!detailed">
<view class='toolbar'>
<view :class="{'ql-active':formats.bold}" class="iconfont icon-zitijiacu" data-name="bold"
@tap="format">
</view>
<view :class="{'ql-active':formats.italic}" class="iconfont icon-zitixieti" data-name="italic"
@tap="format"></view>
<view :class="{'ql-active':formats.underline}" class="iconfont icon-zitixiahuaxian"
data-name="underline" @tap="format"></view>
<view :class="{'ql-active':formats.strike}" class="iconfont icon-zitishanchuxian" data-name="strike"
@tap="format"></view>
<view :class="{'ql-active':formats.align==='left'}" class="iconfont icon-zuoduiqi" data-name="align"
data-value="left" @tap="format"></view>
<view :class="{'ql-active':formats.align==='center'}" class="iconfont icon-juzhongduiqi"
data-name="align" data-value="center" @tap="format"></view>
<view :class="{'ql-active':formats.align==='right'}" class="iconfont icon-youduiqi" data-name="align"
data-value="right" @tap="format"></view>
<view :class="{'ql-active':formats.align==='justify'}" class="iconfont icon-zuoyouduiqi"
data-name="align" data-value="justify" @tap="format"></view>
<view :class="{'ql-active':formats.lineHeight}" class="iconfont icon-line-height" data-name="lineHeight"
data-value="2" @tap="format"></view>
<view :class="{'ql-active':formats.letterSpacing}" class="iconfont icon-Character-Spacing"
data-name="letterSpacing" data-value="2em" @tap="format"></view>
<view :class="{'ql-active':formats.marginTop}" class="iconfont icon-722bianjiqi_duanqianju"
data-name="marginTop" data-value="20px" @tap="format"></view>
<view :class="{'ql-active':formats.marginBottom}" class="iconfont icon-723bianjiqi_duanhouju"
data-name="marginBottom" data-value="20px" @tap="format"></view>
<view class="iconfont icon-clearedformat" @tap="removeFormat"></view>
<view :class="{'ql-active':formats.fontFamily}" class="iconfont icon-font" data-name="fontFamily"
data-value="Pacifico" @tap="format"></view>
<view :class="{'ql-active':formats.fontSize === '24px'}" class="iconfont icon-fontsize"
data-name="fontSize" data-value="24px" @tap="format"></view>
<view :class="{'ql-active':formats.color === '#0000ff'}" class="iconfont icon-text_color"
data-name="color" data-value="#0000ff" @tap="format"></view>
<view :class="{'ql-active':formats.backgroundColor === '#00ff00'}" class="iconfont icon-fontbgcolor"
data-name="backgroundColor" data-value="#00ff00" @tap="format"></view>
<view class="iconfont icon-date" @tap="insertDate"></view>
<view class="iconfont icon--checklist" data-name="list" data-value="check" @tap="format"></view>
<view :class="{'ql-active':formats.list === 'ordered'}" class="iconfont icon-youxupailie"
data-name="list" data-value="ordered" @tap="format"></view>
<view :class="{'ql-active':formats.list === 'bullet'}" class="iconfont icon-wuxupailie" data-name="list"
data-value="bullet" @tap="format"></view>
<view class="iconfont icon-undo" @tap="undo"></view>
<view class="iconfont icon-redo" @tap="redo"></view>
<view class="iconfont icon-outdent" data-name="indent" data-value="-1" @tap="format"></view>
<view class="iconfont icon-indent" data-name="indent" data-value="+1" @tap="format"></view>
<view class="iconfont icon-fengexian" @tap="insertDivider"></view>
<view class="iconfont icon-charutupian" @tap="insertImage"></view>
<view :class="{'ql-active':formats.header === 1}" class="iconfont icon-format-header-1"
data-name="header" :data-value="1" @tap="format"></view>
<view :class="{'ql-active':formats.script === 'sub'}" class="iconfont icon-zitixiabiao"
data-name="script" data-value="sub" @tap="format"></view>
<view :class="{'ql-active':formats.script === 'super'}" class="iconfont icon-zitishangbiao"
data-name="script" data-value="super" @tap="format"></view>
<view class="iconfont icon-shanchu" @tap="clear"></view>
<view :class="{'ql-active':formats.direction === 'rtl'}" class="iconfont icon-direction-rtl"
data-name="direction" data-value="rtl" @tap="format"></view>
</view>
<view class="editor-wrapper">
<editor :id="id" class="ql-container" :class="{'ql-disabled':disabled}" :placeholder="placeholder"
showImgSize showImgToolbar showImgResize @statuschange="onStatusChange" :read-only="disabled"
@ready="onEditorReady" @input="getValue">
</editor>
</view>
</template>
<view v-else class="editor-box">
<mp-html :content="modelValue" />
</view>
</view>
</template>
<script>
export default {
name: 'jnpf-editor',
props: {
modelValue: {
type: String,
default: ''
},
placeholder: {
type: String,
default: '请输入'
},
disabled: {
type: Boolean,
default: false
},
detailed: {
type: Boolean,
default: false
},
},
data() {
return {
innerValue: '',
readOnly: false,
formats: {},
editorChange: false,
id: 'jnpf-editor-' + this.jnpf.idGenerator(),
}
},
watch: {
modelValue(val) {
if (this.editorChange && val) return
this.editorChange = false
this.editorCtx && this.editorCtx.setContents({
html: val
})
}
},
onLoad() {
uni.loadFontFace({
family: 'Pacifico',
source: 'url("/Pacifico-Regular.ttf")'
})
},
methods: {
readOnlyChange() {
this.readOnly = !this.readOnly
},
onEditorReady() {
// #ifdef APP-PLUS || H5 ||MP-WEIXIN
uni.createSelectorQuery().in(this).select('#' + this.id).context((res) => {
this.editorCtx = res.context
this.editorCtx.setContents({
html: this.modelValue
})
}).exec()
// #endif
},
undo() {
this.editorCtx.undo()
},
redo() {
this.editorCtx.redo()
},
format(e) {
let {
name,
value
} = e.target.dataset
if (!name) return
this.editorCtx.format(name, value)
},
onStatusChange(e) {
const formats = e.detail
this.formats = formats
},
insertDivider() {
this.editorCtx.insertDivider()
},
clear() {
this.editorCtx.clear()
},
removeFormat() {
this.editorCtx.removeFormat()
},
insertDate() {
const date = new Date()
const formatDate = `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`
this.editorCtx.insertText({
text: formatDate
})
},
insertImage() {
uni.chooseImage({
count: 1,
success: (res) => {
this.getImageBase64(res)
}
})
},
getImageBase64(res) {
const image = res.tempFilePaths[0]
// #ifdef MP-WEIXIN
uni.getFileSystemManager().readFile({
filePath: image,
encoding: "base64",
success: (e) => {
this.insertImageVal('data:image/jpeg;base64,' + e.data)
},
});
// #endif
// #ifdef APP-PLUS
let path = plus.io.convertLocalFileSystemURL(image);
let fileReader = new plus.io.FileReader();
fileReader.readAsDataURL(path);
fileReader.onloadend = (e) => {
this.insertImageVal(e.target.result);
}
// #endif
// #ifdef H5
uni.request({
url: image, //临时路径
responseType: 'arraybuffer', //设置返回的数据格式为arraybuffer
success: res => {
const base64 = wx.arrayBufferToBase64(res.data)
this.insertImageVal('data:image/jpeg;base64,' + base64);
},
})
// #endif
},
insertImageVal(image) {
this.editorCtx.insertImage({
src: image,
alt: '图像',
success: function() {}
})
},
getValue(e) {
this.editorChange = true
const that = this
this.editorCtx.getContents({
success: function(res) {
let val = res.text === '\n' ? '' : res.html
that.$emit('update:modelValue', val)
}
});
}
}
}
</script>
<style lang="scss" scoped>
@import "./editor-icon.css";
:deep(.ql-editor) {
word-break: break-all;
}
.jnpf-editor {
background-color: #fff;
.iconfont {
display: inline-block;
width: 80rpx;
height: 80rpx;
cursor: pointer;
font-size: 20px;
line-height: 80rpx;
text-align: center;
}
.toolbar {
height: 240rpx;
background: #f5f5f5;
overflow-y: auto;
box-sizing: border-box;
border-bottom: 0;
font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
}
.ql-container {
box-sizing: border-box;
padding: 20rpx;
width: 100%;
height: 400rpx;
margin-top: 20rpx;
font-size: 30rpx;
line-height: 1.5;
&.ql-disabled {
color: #9B9B9B !important;
}
}
.ql-active {
color: #06c;
}
}
</style>

View File

@@ -0,0 +1,63 @@
<template>
<view class="jnpf-empty" :style="{'z-index':zIndex}">
<view class="u-flex-col jnpf-empty-inner">
<image :src="getImageUrl" class="jnpf-empty-inner-img"></image>
<text class="jnpf-empty-inner-text">{{description||$t('common.noData')}}</text>
</view>
</view>
</template>
<script>
import resources from '@/libs/resources'
export default {
name: 'jnpf-empty',
props: {
zIndex: {
type: [String, Number],
default: 999
},
image: {
type: String,
default: ''
},
description: {
type: String,
default: ''
},
},
data() {
return {
icon: resources.message.nodata,
}
},
computed: {
getImageUrl() {
return this.image || this.icon
}
}
}
</script>
<style lang="scss">
.jnpf-empty {
display: flex;
justify-content: center;
align-items: center;
.jnpf-empty-inner {
width: 154px;
height: 170px;
align-items: center;
.jnpf-empty-inner-text {
padding: 30rpx 0;
color: #909399;
}
.jnpf-empty-inner-img {
width: 100%;
height: 100%;
}
}
}
</style>

View File

@@ -0,0 +1,160 @@
<template>
<u-popup class="jnpf-tree-select-popup" mode="right" v-model="showPopup" @close="close" :z-index="uZIndex"
width="100%">
<view class="jnpf-tree-select-body">
<view class="jnpf-tree-select-title">
<text class="icon-ym icon-ym-report-icon-preview-pagePre backIcon" @tap="close()"></text>
<view class="title">分组选择</view>
</view>
<view class="jnpf-tree-select-search">
<u-search :placeholder="$t('app.apply.pleaseKeyword')" v-model="keyword" height="72"
:show-action="false" @change="handleSearch" bg-color="#f0f2f6" shape="square">
</u-search>
</view>
<view class="jnpf-tree-selected">
<view class="jnpf-tree-selected-head">
<view>{{$t('component.jnpf.common.selected')}}({{selectedList.length||0}})</view>
<view v-if="multiple" class="clear-btn" @click="removeAll">
{{$t('component.jnpf.common.clearAll')}}
</view>
</view>
<view class="jnpf-tree-selected-box">
<scroll-view scroll-y="true" class="select-list">
<u-tag closeable @close="handleRemove(index)" v-for="(item,index) in selectedList" :key="index"
:text="item.fullName" class="u-selectTag" />
</scroll-view>
</view>
</view>
<view class="jnpf-tree-selected-line"></view>
<view class="jnpf-tree-selected-tabs">
<view class="tab-item tab-item-active">用户组</view>
</view>
<view class="jnpf-tree-select-tree">
<scroll-view :scroll-y="true" style="height: 100%">
<view class="jnpf-selcet-list" v-if="options.length">
<view class="jnpf-selcet-cell" v-for="item in options" :key="item.id"
@click.stop="handleNodeClick(item)">
<view class="jnpf-selcet-cell-action">
<lyCheckbox :type="multiple ? 'checkbox' : 'radio'"
:checked="selectedIds.includes(item.id)" />
</view>
<view class="jnpf-selcet-cell-name">
{{item.fullName}}
</view>
</view>
</view>
<Empty class="h-full" v-else />
</scroll-view>
</view>
<!-- 底部按钮 -->
<view class="jnpf-tree-select-actions">
<u-button class="buttom-btn" @click="close()">{{$t('common.cancelText')}}</u-button>
<u-button class="buttom-btn" type="primary"
@click.stop="handleConfirm()">{{$t('common.okText')}}</u-button>
</view>
</view>
</u-popup>
</template>
<script>
import lyCheckbox from '@/components/ly-tree/components/ly-checkbox.vue';
import Empty from '../Empty/index.vue'
export default {
components: {
lyCheckbox,
Empty
},
props: {
getOptions: {
type: Function,
},
selectedData: {
type: Array,
default: () => []
},
// 通过双向绑定控制组件的弹出与收起
modelValue: {
type: Boolean,
default: false
},
// 弹出的z-index值
zIndex: {
type: [String, Number],
default: 99999
},
multiple: {
type: Boolean,
default: false
}
},
data() {
return {
moving: false,
selectedList: [],
selectedIds: [],
keyword: '',
showPopup: false,
options: [],
cacheData: [],
};
},
watch: {
modelValue: {
handler(val) {
this.showPopup = val
if (val) setTimeout(() => this.init(), 10);
},
immediate: true
},
selectedList: {
handler(val) {
this.selectedIds = val.map((o) => o.id);
},
deep: true
},
},
computed: {
uZIndex() {
// 如果用户有传递z-index值优先使用
return this.zIndex ? this.zIndex : this.$u.zIndex.popup;
},
},
methods: {
init() {
this.keyword = ''
this.selectedList = JSON.parse(JSON.stringify(this.selectedData))
if (this.getOptions) {
this.getOptions().then(res => {
this.options = res || []
this.cacheData = res || []
})
} else {
this.options = []
this.cacheData = []
}
},
handleNodeClick(data) {
const index = this.selectedList.findIndex((o) => o.id === data.id);
if (index !== -1) return this.selectedList.splice(index, 1);
this.multiple ? this.selectedList.push(data) : (this.selectedList = [data]);
},
handleRemove(index) {
this.selectedList.splice(index, 1);
},
removeAll() {
this.selectedList = [];
},
handleConfirm() {
this.$emit('confirm', this.selectedList, this.selectedIds);
this.close();
},
close() {
this.$emit('close');
},
handleSearch(val) {
this.options = this.cacheData.filter((o) => o.fullName.includes(val));
},
}
};
</script>

View File

@@ -0,0 +1,136 @@
<template>
<view class="jnpf-group-select w-full">
<selectBox v-model="innerValue" :placeholder="placeholder" @openSelect="openSelect" :select-open="selectShow"
:disabled="disabled">
</selectBox>
<SelectPopup v-model="selectShow" :getOptions="getOptions" :multiple="multiple" :selectedData="selectedData"
@close="handleClose" @confirm="handleConfirm" />
</view>
</template>
<script>
import SelectPopup from './SelectPopup';
import selectBox from '@/components/selectBox'
import {
useBaseStore
} from '@/store/modules/base'
import {
getGroupCondition
} from '@/api/common'
const baseStore = useBaseStore()
export default {
name: 'jnpf-group-select',
components: {
SelectPopup,
selectBox
},
props: {
modelValue: {
default: ''
},
placeholder: {
type: String,
default: '请选择'
},
disabled: {
type: Boolean,
default: false
},
multiple: {
type: Boolean,
default: false
},
selectType: {
type: String,
default: 'all'
},
ableIds: {
type: Array,
default: () => []
},
},
data() {
return {
selectShow: false,
innerValue: '',
selectedData: [],
allList: [],
}
},
watch: {
modelValue: {
handler() {
this.setDefault()
},
immediate: true
},
allList: {
handler() {
this.setDefault()
},
deep: true,
},
},
created() {
this.initData()
},
methods: {
async initData() {
this.allList = await baseStore.getGroupList()
},
setDefault() {
if (!this.modelValue || !this.modelValue.length) return this.setNullValue();
let selectedData = [];
let val = this.multiple ? this.modelValue : [this.modelValue];
for (let i = 0; i < val.length; i++) {
inner: for (let j = 0; j < this.allList.length; j++) {
if (this.allList[j].id === val[i]) {
selectedData.push(this.allList[j])
break inner
}
}
}
this.selectedData = selectedData
this.innerValue = this.selectedData.map(o => o.fullName).join();
},
getOptions() {
return new Promise((resolve, reject) => {
if (this.selectType === 'custom') {
const query = {
ids: this.ableIds
}
getGroupCondition(query).then(res => {
resolve(res.data || [])
}).catch(error => {
reject(error)
})
} else {
baseStore.getGroupList().then(res => {
resolve(res || [])
})
}
})
},
setNullValue() {
this.innerValue = '';
this.selectedData = [];
},
openSelect() {
if (this.disabled) return
this.selectShow = true
},
handleConfirm(selectedData, selectedIds) {
if (!this.multiple) {
this.$emit('update:modelValue', selectedIds[0])
this.$emit('change', selectedIds[0], selectedData[0])
} else {
this.$emit('update:modelValue', selectedIds)
this.$emit('change', selectedIds, selectedData)
}
},
handleClose() {
this.selectShow = false
}
}
}
</script>

View File

@@ -0,0 +1,40 @@
<template>
<view class="jnpf-group-title" :style="{'text-align':contentPosition}" @click="handleClick()">{{content}}
<u-icon :name="helpMessage? 'question-circle-fill':''" class="u-m-l-10" color="#a0acb7"></u-icon>
</view>
</template>
<script>
export default {
name: 'jnpf-group-title',
props: {
content: {
type: String,
default: ''
},
helpMessage: {
type: String,
default: ''
},
contentPosition: {
type: String,
default: 'left'
},
},
methods: {
handleClick() {
if (!this.helpMessage) return
this.$emit('groupIcon')
}
}
}
</script>
<style lang="scss" scoped>
.jnpf-group-title {
width: 100%;
color: #333333;
font-size: 32rpx;
line-height: 70rpx;
margin: 0;
padding: 0 20rpx;
}
</style>

View File

@@ -0,0 +1,234 @@
<template>
<view class="jnpf-input">
<template v-if="!detailed">
<view class="input-content" :class="{'input-border':addonBefore||addonAfter}">
<view class="input-left u-line-1" v-if="addonBefore">{{addonBefore}}</view>
<view class="input-center">
<u-input input-align='right' :border="false" v-model="innerValue"
:type="showPassword?'password':'text'" :maxlength="maxlength||maxlength===0?maxlength:9999"
:placeholder="placeholder" :disabled="disabled" :clearable='disabled ? false : clearable'
@input="onInput" @blur="onBlur" :class="{'input-disabled':disabled}" />
</view>
<!-- #ifndef H5 -->
<text class=" icon-ym icon-ym-scanCode1" v-if="useScan" @click="scanCode" />
<!-- #endif -->
<view class="input-right u-line-1" v-if="addonAfter">{{addonAfter}}</view>
<view class="input-count" v-if="showCount&&!addonBefore&&!addonAfter">
<text>{{ innerValue?String(innerValue).length:0 }}</text><text
v-if="maxlength">/{{ maxlength }}</text>
</view>
</view>
</template>
<view class="detail-text" :class="{ ellipsis: showOverflow ,['detail-text-'+align]:true,disabled:disabled }"
v-else>
<text class="detail-text-addon" v-if="addonBefore">{{ addonBefore }}</text>
{{ maskedValue }}
<text class="detail-text-addon" v-if="addonAfter">{{ addonAfter }}</text>
</view>
</view>
</template>
<script>
import {
useTextMask
} from './useTextMask';
export default {
name: 'jnpf-input',
props: {
modelValue: {
type: [String, Number],
default: ''
},
placeholder: {
type: String,
default: '请输入'
},
maxlength: {
type: Number,
default: null
},
showPassword: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
clearable: {
type: Boolean,
default: false
},
detailed: {
type: Boolean,
default: false
},
showOverflow: {
type: Boolean,
default: false
},
addonBefore: {
type: String,
default: ''
},
addonAfter: {
type: String,
default: ''
},
align: {
type: String,
default: 'right'
},
useScan: {
type: Boolean,
default: false
},
useMask: {
type: Boolean,
default: false
},
maskConfig: {
type: Object,
default: () => {}
},
showCount: {
type: Boolean,
default: false
},
},
data() {
return {
innerValue: '',
maskedValue: '',
}
},
watch: {
modelValue: {
handler(val) {
this.innerValue = val
if (!this.useMask) return (this.maskedValue = val);
const {
getMaskedText
} = useTextMask(this.maskConfig);
this.maskedValue = getMaskedText(val);
},
immediate: true,
}
},
methods: {
onInput(val) {
this.$nextTick(() => {
this.$emit('update:modelValue', val)
this.$emit('change', val)
})
},
onBlur(val) {
this.$emit('blur', val)
},
isJSON(str) {
try {
var obj = JSON.parse(str);
if (typeof obj == 'object' && obj) {
return true;
} else {
return false;
}
} catch (e) {
return false;
}
},
scanCode() {
uni.scanCode({
success: res => {
if (!res.result || typeof res.result !== 'string') return
this.onInput(res.result)
}
});
}
}
}
</script>
<style lang="scss">
.jnpf-input {
width: 100%;
.input-content {
display: flex;
border-radius: 10rpx;
height: 74rpx;
&.input-border {
border: 1rpx solid rgb(220, 223, 230)
}
.input-center {
flex: 1;
// padding: 0 8rpx;
.input-disabled {
:deep(.uni-input-placeholder) {
color: #9B9B9B !important;
}
:deep(.uni-input-input) {
color: #9B9B9B !important;
}
}
}
.input-left,
.input-right {
flex-shrink: 0;
width: 128rpx;
background-color: #f5f7fa;
color: #909399;
padding: 0 10rpx;
text-align: center;
}
.input-left {
border-right: 1rpx solid #dcdfe6;
border-radius: 10rpx 0 0 10rpx;
}
.input-right {
border-left: 1rpx solid #dcdfe6;
border-radius: 0px 10px 10px 0px;
}
.icon-ym-scanCode1 {
margin-right: 8rpx;
color: #909399;
}
.input-count {
color: #909399;
font-size: 24rpx;
}
}
.detail-text {
word-break: break-all;
text-align: right;
.detail-text-addon {
color: #909399;
}
&.disabled {
background-color: #ebedf0;
}
&.ellipsis {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
&.detail-text-left {
text-align: left;
}
}
}
</style>

View File

@@ -0,0 +1,170 @@
/**
* maskType
* 1 - 全掩盖
* 2 - 姓名-显示前1个字后1个字
* 3 - 手机号-显示前3位后4位
* 4 - 邮箱-显示前3个字@和之后的字
* 5 - 身份证-显示前6位后3位虚拟为4位
* 6 - IP地址-显示第1段IP
* 7 - 车牌号-显示前1个字后2位
* 8 - 银行卡号-显示前6位后4位
* 0 - 自定义规则
*/
export const defaultMaskOptions = {
filler: '*', // 填充符号
maskType: 1, // 掩码规则
prefixType: 1, // 开头显示
prefixLimit: 0, // 开头字数
prefixSpecifyChar: '', // 开头字符
suffixType: 1, // 结尾显示
suffixLimit: 0, // 结尾字数
suffixSpecifyChar: '', // 结尾字符
ignoreChar: '', // 显示字符
useUnrealMask: false, // 虚拟掩码
unrealMaskLength: 1, // 虚拟掩码长度
};
export function useTextMask(options = {}) {
const config = {
...defaultMaskOptions,
...options
};
// 全掩盖
function maskAll(str) {
return config.filler.repeat(str.length);
}
//姓名 显示前1个字后1个字
function maskName(str) {
if (str.length <= 1) return str;
const prefix = str[0];
if (str.length === 2) return prefix + config.filler;
const suffix = str.slice(-1);
const maskedChars = config.filler.repeat(str.length - 2);
return prefix + maskedChars + suffix;
}
// 手机号 - 显示前3位后4位
function maskPhoneNumber(str) {
if (str.length <= 7) return str;
const prefix = str.slice(0, 3);
const suffix = str.slice(-4);
const maskedChars = config.filler.repeat(str.length - 7);
return prefix + maskedChars + suffix;
}
// 邮箱 - 显示前3个字@和之后的字
function maskEmailAddress(str) {
const atIndex = str.indexOf('@');
if (str.length <= 3 || (atIndex > -1 && atIndex < 3)) return str;
let suffixLength = 0;
let maskedCharsLength = str.length - 3;
if (atIndex > 0) {
suffixLength = atIndex;
maskedCharsLength = atIndex - 3;
}
const prefix = str.slice(0, 3);
const suffix = suffixLength ? str.slice(suffixLength) : '';
const maskedChars = config.filler.repeat(maskedCharsLength);
return prefix + maskedChars + suffix;
}
// 身份证 - 显示前6位后3位虚拟为4位
function maskIdNumber(str) {
if (str.length <= 9) return str;
const prefix = str.slice(0, 6);
const suffix = str.slice(-3);
const maskedChars = config.filler.repeat(4);
return prefix + maskedChars + suffix;
}
// IP地址-显示第1段IP
function maskIPAddress(str) {
const segments = str.split('.');
if (segments.length < 1) return str;
const maskedChars = ('.' + config.filler.repeat(3)).repeat(3);
return segments[0] + maskedChars;
}
// 车牌号-显示前1个字后2位
function maskLicensePlate(str) {
if (str.length <= 3) return str;
const prefix = str[0];
const suffix = str.slice(-2);
const maskedChars = config.filler.repeat(str.length - 3);
return prefix + maskedChars + suffix;
}
// 银行卡号-显示前6位后4位
function maskBankCard(str) {
if (str.length <= 10) return str;
const prefix = str.slice(0, 6);
const suffix = str.slice(-4);
const maskedChars = config.filler.repeat(str.length - 10);
return prefix + maskedChars + suffix;
}
// 自定义掩码规则
function maskCustom(str) {
let prefixLength = 0,
suffixLength = 0;
if (config.prefixType === 2) prefixLength = config.prefixLimit || 0;
if ((config.prefixType === 3 || config.prefixType === 4) && config.prefixSpecifyChar) {
let specifyCharIndex = str.indexOf(config.prefixSpecifyChar);
if (specifyCharIndex > -1) prefixLength = config.prefixType === 3 ? specifyCharIndex :
specifyCharIndex + config.prefixSpecifyChar.length;
}
if (config.suffixType === 2) suffixLength = config.suffixLimit || 0;
if ((config.suffixType === 3 || config.suffixType === 4) && config.suffixSpecifyChar) {
let specifyCharIndex = str.indexOf(config.suffixSpecifyChar);
if (specifyCharIndex > -1) suffixLength = config.suffixType === 3 ?
str.length - specifyCharIndex - config.suffixSpecifyChar.length :
str.length - specifyCharIndex;
}
if (prefixLength + suffixLength >= str.length) return str;
const prefix = prefixLength ? str.slice(0, prefixLength) : '';
const suffix = suffixLength ? str.slice(-suffixLength) : '';
let middleChar = '';
if (!config.ignoreChar) {
const maskedLength = config.useUnrealMask ? config.unrealMaskLength || 1 : str.length - prefixLength -
suffixLength;
middleChar = config.filler.repeat(maskedLength);
} else {
const ignoreCharList = config.ignoreChar.split(',');
const middleStr = str.slice(prefixLength, str.length - suffixLength);
const reg = new RegExp('(' + ignoreCharList.map(o => o.replace(/\*/g, '\\*')).join('|') + ')', 'g');
let list = middleStr.split(reg);
list = list.map(o => {
if (o && !ignoreCharList.includes(o)) {
const maskedLength = config.useUnrealMask ? config.unrealMaskLength || 1 : o.length;
o = config.filler.repeat(maskedLength);
}
return o;
});
middleChar = list.join('');
}
return prefix + middleChar + suffix;
}
// 获取掩码后文本
function getMaskedText(str) {
if (!str) return '';
if (config.maskType === 1) return maskAll(str);
if (config.maskType === 2) return maskName(str);
if (config.maskType === 3) return maskPhoneNumber(str);
if (config.maskType === 4) return maskEmailAddress(str);
if (config.maskType === 5) return maskIdNumber(str);
if (config.maskType === 6) return maskIPAddress(str);
if (config.maskType === 7) return maskLicensePlate(str);
if (config.maskType === 8) return maskBankCard(str);
if (config.maskType === 0) return maskCustom(str);
return str;
}
return {
maskAll,
maskName,
maskPhoneNumber,
maskEmailAddress,
maskIdNumber,
maskIPAddress,
maskLicensePlate,
maskBankCard,
maskCustom,
getMaskedText
};
}

View File

@@ -0,0 +1,260 @@
<template>
<view class="jnpf-input-number">
<!-- 数字输入 -->
<view v-if="!detailed">
<u-number-box v-if="controls" v-model="innerValue" :step="step" :min="min" :max="max" :key="key"
:disabled="disabled" :positive-integer="false" :input-height="60" @blur="onNumberBlur"
@change="onChange" />
<view v-else class="input-content" :class="{'input-border':addonBefore||addonAfter}">
<view class="input-left u-line-1" v-if="addonBefore">{{addonBefore}}</view>
<view class="input-center">
<u-input v-model="innerValue" :placeholder="placeholder" :class="{'input-disabled':disabled}"
:input-align='addonBefore || addonAfter? "center":"right"' :disabled="disabled"
:clearable="false" @focus="onFocus" @blur="onBlur" @input="onInputChange">
</u-input>
</view>
<view class="input-right u-line-1" v-if="addonAfter">{{addonAfter}}</view>
</view>
</view>
<!-- 详情 -->
<view v-else>
<view class="detail-content u-flex">
<view class="detail-left u-line-1" v-if="addonBefore&&!controls">{{addonBefore}}</view>
<view class="detail-center">{{thousands?jnpf.thousandsFormat(innerValue) :innerValue}}</view>
<view class="detail-right u-line-1" v-if="addonAfter&&!controls">{{addonAfter}}</view>
</view>
</view>
<!-- 大写金额 -->
<view class="amount-chinese-name" v-if="isAmountChinese&&getChineseName">{{getChineseName}}</view>
</view>
</template>
<script>
/**
* inputNumber 数字输入框
* @modelValue v-model
* @min {Number} 最小值
* @max {Number} 最大值
* @step {Number} 每次点击改变的间隔大小
* @placeholder {String} 占位符
* @addonBefore {String} 前缀
* @addonAfter {String} 后缀
* @thousands {Boolean} 金额千位符
* @isAmountChinese {Boolean} 金额大写
* @detailed {Boolean} 详情
*/
export default {
name: 'jnpf-input-number',
props: {
modelValue: {
type: [Number, String],
default: ''
},
min: {
type: Number,
default: -999999999999999
},
max: {
type: Number,
default: 999999999999999
},
step: {
type: Number,
default: 1
},
disabled: {
type: Boolean,
default: false
},
addonBefore: {
default: ''
},
addonAfter: {
default: ''
},
precision: {
type: Number
},
controls: {
type: Boolean,
default: false
},
thousands: {
type: Boolean,
default: false
},
isAmountChinese: {
type: Boolean,
default: false
},
detailed: {
type: Boolean,
default: false
},
type: {
default: ''
},
placeholder: {
default: '请输入'
},
},
data() {
return {
innerValue: null,
key: +new Date()
}
},
watch: {
modelValue: {
handler(val) {
if (val == null || val == undefined) return;
this.setValue(val)
},
immediate: true
},
getChineseName(val) {
uni.$emit('initCollapse')
}
},
computed: {
getChineseName() {
if (!this.isAmountChinese || (!this.getNumberValue && this.getNumberValue !== 0)) return ""
return this.jnpf.getAmountChinese(this.getNumberValue)
},
getNumberValue() {
return this.handleConvertNum(this.innerValue)
},
},
methods: {
setValue(val) {
this.innerValue = (!val && val !== 0) || isNaN(val) ? null : Number(val);
if (!this.innerValue && this.innerValue !== 0) return
if (this.innerValue < this.min) this.innerValue = this.min
if (this.innerValue > this.max) this.innerValue = this.max
if (!isNaN(this.precision)) {
const value = Number(this.getNumberValue).toFixed(this.precision)
this.innerValue = this.controls ? Number(value) : value
}
if (this.thousands) this.innerValue = this.jnpf.thousandsFormat(this.innerValue)
},
onChange() {
this.setValue(this.innerValue)
this.$nextTick(() => {
this.emitValueChanges(this.innerValue)
})
},
emitValueChanges(value) {
// 统一事件触发逻辑
this.$emit('update:modelValue', value)
this.$emit('change', value)
},
onInputChange() {
this.$nextTick(() => {
if (this.innerValue == null || this.innerValue == undefined) return;
if (this.innerValue < this.min || this.innerValue > this.max) return;
this.emitValueChanges(this.innerValue)
})
},
onNumberBlur() {
this.key = +new Date()
this.setValue(this.innerValue)
this.$emit('blur', this.innerValue)
},
onBlur(val) {
this.setValue(this.getNumberValue)
this.$nextTick(() => {
if (this.getNumberValue > this.min && this.getNumberValue < this.max) return;
this.$emit('blur', this.getNumberValue)
this.emitValueChanges(this.getNumberValue)
})
},
onFocus() {
if (!this.innerValue) return
if (this.innerValue.toString().indexOf('e+') > -1) return
this.innerValue = !isNaN(this.precision) ? Number(this.getNumberValue).toFixed(this.precision) : this
.getNumberValue
},
handleConvertNum(val) {
if (!val && val !== 0) return null
let num = this.$u.deepClone(val.toString().split("."))
const arr2 = num.length > 1 ? num[1].split("").filter(o => (!isNaN(o))).join('') : []
let arr = num[0].split("").filter(o => (!isNaN(o))).join('');
let res = num[1] ? arr + '.' + arr2 : Number(arr)
return val.toString().indexOf('-') != -1 ? Number('-' + res) : res
}
}
}
</script>
<style lang="scss" scoped>
.jnpf-input-number {
width: 100%;
display: flex;
flex-direction: column;
align-items: flex-end;
:deep(.u-number-input) {
width: 150rpx !important;
}
.input-content {
display: flex;
border-radius: 10rpx;
height: 74rpx;
&.input-border {
border: 1rpx solid rgb(220, 223, 230)
}
.input-disabled {
:deep(.uni-input-placeholder) {
color: #9B9B9B !important;
}
:deep(.uni-input-input) {
color: #9B9B9B !important;
}
}
.input-left,
.input-right {
flex-shrink: 0;
width: 128rpx;
background-color: #f5f7fa;
color: #909399;
padding: 0 10rpx;
text-align: center;
}
.input-left {
border-right: 1rpx solid #dcdfe6;
border-radius: 10rpx 0 0 10rpx;
}
.input-right {
border-left: 1rpx solid #dcdfe6;
border-radius: 0px 10px 10px 0px;
}
}
.detail-content {
.detail-left {
max-width: 128rpx;
padding-right: 16rpx;
color: #909399;
}
.detail-right {
max-width: 128rpx;
padding-left: 16rpx;
color: #909399;
}
}
.amount-chinese-name {
color: #999999;
line-height: 40rpx;
padding: 10rpx 10rpx 0 0;
}
}
</style>

View File

@@ -0,0 +1,62 @@
<template>
<view class="jnpf-link" :style="textStyle" @click="handleClick()">
<text>{{content}}</text>
</view>
</template>
<script>
export default {
name: 'jnpf-link',
props: {
content: {
type: String,
default: '文本链接'
},
href: {
type: String,
default: ''
},
target: {
type: String,
default: ''
},
textStyle: {
type: Object,
default: {}
}
},
methods: {
handleClick(event) {
if (!this.href) return this.$u.toast("未配置跳转链接")
if (this.target === '_self') {
uni.navigateTo({
url: '/pages/apply/externalLink/index?url=' + this.href,
fail: (err) => {
this.$u.toast("暂无此页面")
}
})
} else {
// #ifdef APP
plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
plus.runtime.openURL(this.href)
})
// #endif
// #ifndef APP
uni.navigateTo({
url: '/pages/apply/externalLink/index?url=' + this.href,
fail: (err) => {
this.$u.toast("暂无此页面")
}
})
// #endif
}
}
}
}
</script>
<style lang="scss" scoped>
.jnpf-link {
width: 100%;
color: #1890ff;
text-align: right;
}
</style>

View File

@@ -0,0 +1,274 @@
<template>
<view class="jnpf-location">
<u-button class="jnpf-location-btn" :class="{'jnpf-location-disabled':disabled}" @click="handleLocation"
v-if="!detailed" size="mini">
<u-icon class="jnpf-location-icon" name="map" />
{{ innerValue.fullAddress ||errTitle ? $t('app.apply.location.relocation') :$t('app.apply.location.location') }}
</u-button>
<view class="location-card" v-if="innerValue.fullAddress">
<view class="location-card-info" @click="getLocation">
<image class="location-card-static-map" :src="staticMapUrl" v-if="enableLocationScope" />
<view class="location-card-address" :class="{'disabled':disabled}">{{ innerValue.fullAddress }}</view>
<u-icon name="close-circle-fill" v-if="!detailed && !disabled && clearable" @click="handleClear" />
</view>
</view>
<view v-if="errTitle" class="errTitle">{{errTitle}}</view>
</view>
</template>
<script>
import {
getAddress
} from '@/api/common.js'
const defaultValue = {
lat: '',
lng: '',
name: '',
fullAddress: '',
};
export default {
name: 'jnpf-location',
props: {
modelValue: {
type: String,
default: ''
},
autoLocation: {
type: Boolean,
default: false
},
enableLocationScope: {
type: Boolean,
default: false
},
adjustmentScope: {
type: Number,
default: 500
},
enableDesktopLocation: {
type: Boolean,
default: false
},
locationScope: {
type: Array,
default: []
},
disabled: {
type: Boolean,
default: false
},
detailed: {
type: Boolean,
default: false
},
clearable: {
type: Boolean,
default: false
},
buttonText: {
type: String,
default: '添加定位'
}
},
data() {
return {
innerValue: '',
errTitle: '',
emitKey: ''
}
},
watch: {
modelValue: {
handler(val) {
this.innerValue = val ? JSON.parse(val) : defaultValue
},
immediate: true,
},
},
computed: {
staticMapUrl() {
if (!this.enableLocationScope) return ' ';
const location = this.innerValue.lng + ',' + this.innerValue.lat;
const url =
`${this.define.baseURL}/api/system/Location/staticmap?location=${location}&zoom=19&size=80*80&key=${this.define.aMapWebKey}`;
return url;
}
},
created() {
this.errTitle = ''
this.handleAutoLocation()
this.handleListen()
},
methods: {
handleListen() {
this.emitKey = 'location' + this.jnpf.idGenerator()
uni.$on(this.emitKey, data => {
this.handleConfirm(data)
})
},
handleLocation(val) {
if (this.disabled || this.detailed) return
const data = {
adjustmentScope: this.adjustmentScope,
enableLocationScope: this.enableLocationScope,
enableDesktopLocation: this.enableDesktopLocation,
locationScope: this.locationScope,
emitKey: this.emitKey
}
uni.navigateTo({
url: '/pages/apply/location/index?data=' + JSON.stringify(data)
})
},
handleAutoLocation() {
if (!this.autoLocation || this.innerValue.fullAddress || this.detailed) return;
uni.getLocation({
type: 'gcj02',
isHighAccuracy: true,
success: (e) => {
const getAddressFun = () => {
const query = {
location: e.longitude + ',' + e.latitude,
key: this.define.aMapWebKey
}
getAddress(query).then(res => {
const data = res.data.regeocode.addressComponent;
this.innerValue = {
pName: data.province,
cName: data.city,
adName: data.district,
address: data.streetNumber.street + data.streetNumber
.number,
name: res.data.regeocode.formatted_address,
lng: e.longitude,
lat: e.latitude,
fullAddress: res.data.regeocode.formatted_address,
};
this.$emit('update:modelValue', JSON.stringify(this.innerValue));
this.$emit('change', JSON.stringify(this.innerValue));
}).catch(() => {
this.handelError()
})
}
if (this.enableDesktopLocation && this.locationScope.length) {
let list = [];
for (let i = 0; i < this.locationScope.length; i++) {
const o = this.locationScope[i];
const discount = this.jnpf.getDistance(o.lat, o.lng, e.latitude, e
.longitude) || 0;
list.push(discount > o.radius);
}
if (list.every(o => o === true)) return;
getAddressFun()
} else {
getAddressFun()
}
},
fail: (err) => {
this.handelError()
}
});
},
handleConfirm(item) {
this.innerValue = item ? JSON.parse(item) : defaultValue
this.errTitle = ''
this.onchange()
},
handelError() {
this.errTitle = '定位失败,请检查网络畅通、定位开启后重试'
},
handleClear() {
this.innerValue = defaultValue;
this.$emit('update:modelValue', '');
this.$emit('change', '');
},
onchange() {
let innerValue = this.$u.deepClone(this.innerValue)
this.$emit('update:modelValue', JSON.stringify(innerValue))
this.$emit('change', JSON.stringify(innerValue))
},
openMap() {
uni.openLocation({
latitude: Number(this.innerValue.lat),
longitude: Number(this.innerValue.lng),
name: this.innerValue.name,
address: this.innerValue.address,
success: () => {},
fail: function(error) {
console.log(error)
}
});
},
getLocation() {
if (this.detailed) return this.openMap()
if (this.enableLocationScope) this.handleLocation()
}
}
}
</script>
<style lang="scss">
.jnpf-location {
width: 100%;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
.jnpf-location-btn {
margin: unset;
&.jnpf-location-disabled {
background-color: #E6E6E6 !important;
border-color: #D9D9D9 !important;
color: #9B9B9B !important;
}
.jnpf-location-icon {
font-size: 28rpx;
padding-right: 2px;
}
}
.location-card {
display: flex;
align-items: center;
margin-top: 16rpx;
background: #f2f2f6;
padding: 16rpx;
border-radius: 16rpx;
justify-content: space-between;
.location-card-info {
flex: 1;
display: flex;
align-items: center;
.location-card-static-map {
width: 96rpx;
height: 96rpx;
margin-right: 8rpx;
flex-shrink: 0;
}
.location-card-address {
line-height: 1.5;
padding: 0 8rpx;
word-break: normal;
white-space: normal;
&.disabled {
color: #9B9B9B !important;
}
}
}
.location-card-actions {
color: rgb(135, 143, 149);
cursor: pointer;
flex-shrink: 0;
}
}
.errTitle {
color: $u-type-error
}
}
</style>

View File

@@ -0,0 +1,76 @@
<template>
<view class="jnpf-num-range">
<u-input input-align='right' v-model="min" :placeholder="$t('component.jnpf.numberRange.min')" type="number" @blur="onblur($event,'min')" />
<text class="separator">-</text>
<u-input input-align='right' v-model="max" :placeholder="$t('component.jnpf.numberRange.max')" type="number" @blur="onblur($event,'max')" />
</view>
</template>
<script>
export default {
name: 'jnpf-number-range',
props: {
modelValue: {
type: Array,
default: () => []
},
disabled: {
type: Boolean,
default: false
},
precision: {
type: Number,
default: undefined
},
},
data() {
return {
min: '',
max: ''
}
},
watch: {
modelValue: {
handler(val) {
if (Array.isArray(val) && val.length === 2) {
this.min = val[0]
this.max = val[1]
} else {
this.min = ''
this.max = ''
}
},
immediate: true,
},
min(val) {
this.onChange()
},
max(val) {
this.onChange()
}
},
methods: {
onblur(e, type) {
this[type] = !isNaN(this.precision) && (e == '0' || e) ? Number(e).toFixed(this.precision) : e
},
onChange() {
if ((!this.min && this.min !== 0) && (!this.max && this.max !== 0)) return this.$emit('update:modelValue',
[])
this.$emit('update:modelValue', [this.min, this.max])
}
}
}
</script>
<style lang="scss" scoped>
.jnpf-num-range {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
.separator {
margin: 0 20rpx;
flex-shrink: 0;
}
}
</style>

View File

@@ -0,0 +1,54 @@
<template>
<u-input input-align='right' :modelValue="modelValue" placeholder="系统自动生成" disabled />
</template>
<script>
export default {
name: 'jnpf-open-data',
props: {
modelValue: {
type: String,
default: ''
},
/**
* currUser - 当前用户
* currTime - 当前时间
* currOrganize - 所属组织
* currPosition - 所属岗位
*/
type: {
type: String,
default: ''
},
},
data() {
return {
innerValue: '',
userInfo: ''
}
},
created() {
this.userInfo = uni.getStorageSync('userInfo') || {}
this.setDefault()
},
methods: {
setDefault() {
if (this.type === 'currUser') {
this.innerValue = this.userInfo.userName + '/' + this.userInfo.userAccount
if (!this.userInfo.userName && !this.userInfo.userAccount) this.innerValue = ""
}
if (this.type === 'currTime') {
this.innerValue = this.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM:ss')
}
if (this.type === 'currOrganize' && this.userInfo.organizeList?.length) {
const list = this.userInfo.organizeList.map((o) => o.treeName);
this.innerValue = list.join(',');
}
if (this.type === 'currPosition' && this.userInfo.positionList?.length) {
const list = this.userInfo.positionList.map((o) => o.treeName);
this.innerValue = list.join(',');
}
}
}
}
</script>

View File

@@ -0,0 +1,297 @@
<template>
<u-popup class="jnpf-tree-select-popup" mode="right" v-model="showPopup" width="100%" @close="close">
<view class="jnpf-tree-select-body">
<view class="jnpf-tree-select-title">
<text class="icon-ym icon-ym-report-icon-preview-pagePre backIcon" @tap="close()"></text>
<view class="title">组织选择</view>
</view>
<view class="jnpf-tree-select-search">
<u-search :placeholder="$t('app.apply.pleaseKeyword')" v-model="keyword" height="72"
:show-action="false" @change="handleSearch" bg-color="#f0f2f6" shape="square">
</u-search>
</view>
<view class="jnpf-tree-selected">
<view class="jnpf-tree-selected-head">
<view>{{$t('component.jnpf.common.selected')}}({{selectedList.length||0}})</view>
<view v-if="multiple" class="clear-btn" @click="setCheckAll">
{{$t('component.jnpf.common.clearAll')}}
</view>
</view>
<view class="jnpf-tree-selected-box">
<scroll-view scroll-y="true" class="select-list">
<u-tag closeable @close="delSelect(index)" v-for="(item,index) in selectedList" :key="index"
:text="item.orgNameTree" class="u-selectTag" />
</scroll-view>
</view>
</view>
<view class="jnpf-tree-selected-line"></view>
<view class="jnpf-tree-selected-tabs">
<view class="tab-item" :class="{'tab-item-active':activeKey==='1'}" @click="toggloActive('1')">组织构架
</view>
<view class="tab-item" :class="{'tab-item-active':activeKey==='2'}" @click="toggloActive('2')"
v-if="selectType === 'all'">
当前组织
</view>
</view>
<view class="jnpf-tree-select-tree">
<scroll-view :scroll-y="true" style="height: 100%" v-if="activeKey==='1' && !hasPage">
<ly-tree v-if="selectType !== 'all'" :tree-data="options" :node-key="realProps.value"
default-expand-all :props="realProps" :filter-node-method="filterNode"
child-visible-for-filter-node show-node-icon @node-click="handleTreeNodeClick"
:show-checkbox="multiple" :show-radio="!multiple" :expandOnClickNode="false"
:checkOnClickNode="true" :expandOnCheckNode="false" checkStrictly ref="tree">
</ly-tree>
<ly-tree ref="tree" v-if="selectType === 'all'" :props="realProps" :node-key="realProps.value"
:load="loadNode" lazy :tree-data="lazyOptions" show-node-icon :defaultExpandAll='false'
@node-click="handleTreeNodeClick" :show-checkbox="multiple" :show-radio="!multiple"
:expandOnClickNode="false" :checkOnClickNode="true" :expandOnCheckNode="false" checkStrictly />
</scroll-view>
<scroll-view :scroll-y="true" style="height: 100%" :refresher-enabled="false" :refresher-threshold="100"
:scroll-with-animation='true' :refresher-triggered="triggered" @scrolltolower="handleScrollToLower"
v-if="activeKey==='2'|| (activeKey==='1' && hasPage)">
<view class="jnpf-selcet-list" v-if="list.length">
<view class="jnpf-selcet-cell" v-for="item in list" :key="item.id"
@click.stop="handleNodeClick(item)">
<view class="jnpf-selcet-cell-action">
<lyCheckbox :type="multiple ? 'checkbox' : 'radio'"
:checked="selectedIds.includes(item.id)" />
</view>
<view class="jnpf-selcet-cell-name">
{{item.orgNameTree}}
</view>
</view>
</view>
<Empty class="h-full" v-else />
</scroll-view>
</view>
<!-- 底部按钮 -->
<view class="jnpf-tree-select-actions">
<u-button class="buttom-btn" @click="close()">{{$t('common.cancelText')}}</u-button>
<u-button class="buttom-btn" type="primary"
@click.stop="handleConfirm()">{{$t('common.okText')}}</u-button>
</view>
</view>
</u-popup>
</template>
<script>
import {
getOrgByOrganizeCondition,
getOrganizeSelector
} from '@/api/common'
import lyCheckbox from '@/components/ly-tree/components/ly-checkbox.vue';
import Empty from '../Empty/index.vue'
const defaultProps = {
label: 'fullName',
value: 'id',
icon: 'icon',
children: 'children'
}
export default {
props: {
selectedData: {
type: Array,
default: () => []
},
ableIds: {
type: Array,
default: () => []
},
selectType: {
type: String,
default: 'all'
},
// 通过双向绑定控制组件的弹出与收起
modelValue: {
type: Boolean,
default: false
},
// 弹出的z-index值
zIndex: {
type: [String, Number],
default: 0
},
props: {
type: Object,
default: () => ({
label: 'fullName',
value: 'id',
icon: 'icon',
children: 'children',
isLeaf: 'isLeaf'
})
},
multiple: {
type: Boolean,
default: false
}
},
components: {
lyCheckbox,
Empty
},
data() {
return {
moving: false,
selectedList: [],
selectedIds: [],
keyword: '',
showPopup: false,
options: [],
lazyOptions: [],
activeKey: '1',
hasPage: false,
pagination: {
hasPage: 1,
currentPage: 1,
pageSize: 20
},
triggered: false,
finish: false,
list: []
};
},
watch: {
// 在select弹起的时候重新初始化所有数据
modelValue: {
handler(val) {
this.showPopup = val
if (!val) this.activeKey = ''
if (val) setTimeout(() => this.init(), 10);
},
immediate: true
},
selectedList: {
handler(val) {
this.selectedIds = val.map((o) => o.id);
this.$refs.tree && this.$refs.tree.setCheckedKeys(this.selectedIds)
},
deep: true
},
},
computed: {
uZIndex() {
// 如果用户有传递z-index值优先使用
return this.zIndex ? this.zIndex : this.$u.zIndex.popup;
},
realProps() {
return {
...defaultProps,
...this.props
}
},
getCurrOrgList() {
const userInfo = uni.getStorageSync('userInfo') || {}
const list = (userInfo.organizeList || []).map((o) => ({
...o,
orgNameTree: o.treeName
}))
return list
}
},
methods: {
init() {
this.keyword = ""
this.hasPage = 0
this.activeKey = '1'
this.finish = false
this.pagination.currentPage = 1
this.$nextTick(() => {
this.triggered = true
})
this.selectedList = JSON.parse(JSON.stringify(this.selectedData))
if (this.selectType !== 'all') this.getConditionOptions()
},
getConditionOptions() {
if (!this.ableIds.length) return
const query = {
ids: this.ableIds
}
getOrgByOrganizeCondition(query).then(res => {
this.options = res.data.list || []
this.$refs.tree && this.$refs.tree.setCheckedKeys(this.selectedIds)
})
},
filterNode(value, data) {
if (!value) return true;
return data[this.realProps.label].indexOf(value) !== -1;
},
loadNode(node, resolve) {
const id = node.key || '0'
const data = {
keyword: '',
parentId: id
}
getOrganizeSelector(data).then(res => {
resolve(res.data?.list)
this.$refs.tree && this.$refs.tree.setCheckedKeys(this.selectedIds)
})
},
handleScrollToLower() {
if (this.finish || this.activeKey === '2') return
this.getTreeData()
},
getTreeData() {
let data = {
keyword: this.keyword,
parentId: '0',
...this.pagination
}
getOrganizeSelector(data).then(res => {
const list = res.data.list || []
if (list.length < this.pagination.pageSize) this.finish = true;
this.list = this.list.concat(list);
this.pagination.currentPage++
})
},
onTreeCheck(item) {
this.handleTreeNodeClick(item);
},
handleTreeNodeClick(item) {
const data = item.data
this.handleNodeClick(data)
},
handleNodeClick(data) {
const index = this.selectedList.findIndex((o) => o.id === data.id);
if (index !== -1) return this.selectedList.splice(index, 1);
this.multiple ? this.selectedList.push(data) : (this.selectedList = [data]);
},
delSelect(index) {
this.selectedList.splice(index, 1);
},
setCheckAll() {
this.selectedIds = []
this.selectedList = []
},
handleConfirm() {
this.$emit('confirm', this.selectedList, this.selectedIds);
this.close();
},
close() {
this.$emit('close', false);
},
toggloActive(key) {
if (this.activeKey === key) return
this.keyword = ''
this.$nextTick(() => {
this.activeKey = key
if (this.activeKey === '2') this.list = this.getCurrOrgList
})
},
handleSearch(val) {
this.keyword = val
if (this.selectType !== 'all') return this.$refs.tree && this.$refs.tree.filter(val)
this.hasPage = !!val
this.list = []
if (this.activeKey != '1') this.activeKey = '1'
this.$nextTick(() => {
if (this.keyword) {
this.pagination.currentPage = 1
this.finish = false
this.$u.debounce(this.getTreeData, 300)
}
})
},
}
};
</script>

Some files were not shown because too many files have changed in this diff Show More