微信小程序运行成功;
H5运行成功
This commit is contained in:
ldeyun 2024-09-30 01:26:58 +08:00
commit d572f28fad
1071 changed files with 138711 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules/
unpackage/

31
.hbuilderx/launch.json Normal file
View File

@ -0,0 +1,31 @@
{
// launch.json configurations app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
// launchtypelocalremote, localremote
"version" : "0.0",
"configurations" : [
{
"app-plus" :
{
"launchtype" : "remote"
},
"default" :
{
"launchtype" : "local"
},
"h5" :
{
"launchtype" : "remote"
},
"mp-weixin" :
{
"launchtype" : "local"
},
"provider" : "aliyun",
"type" : "uniCloud"
},
{
"playground" : "standard",
"type" : "uni-app:app-android"
}
]
}

56
App.vue Normal file
View File

@ -0,0 +1,56 @@
<script>
import initApp from '@/common/appInit.js';
import openApp from '@/common/openApp.js';
// #ifdef H5
openApp() //h5app
// #endif
import checkIsAgree from '@/pagesPackage/uni-agree/utils/uni-agree.js';
import uniIdPageInit from '@/uni_modules/uni-id-pages/init.js';
export default {
globalData: {
searchText: '',
appVersion: {},
config: {},
$i18n: {},
$t: {}
},
onLaunch: function() {
console.log('App Launch')
this.globalData.$i18n = this.$i18n
this.globalData.$t = str => this.$t(str)
initApp();
uniIdPageInit()
// #ifdef APP-PLUS
//checkIsAgree(); APPvue
// #endif
// #ifdef H5
// checkIsAgree(); //
// #endif
// #ifdef APP-PLUS
//idfastorage
/*var idfa = '';
var manager = plus.ios.invoke('ASIdentifierManager', 'sharedManager');
if(plus.ios.invoke(manager, 'isAdvertisingTrackingEnabled')){
var identifier = plus.ios.invoke(manager, 'advertisingIdentifier');
idfa = plus.ios.invoke(identifier, 'UUIDString');
plus.ios.deleteObject(identifier);
}
plus.ios.deleteObject(manager);
console.log('idfa = '+idfa);*/
// #endif
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
}
}
</script>
<style>
/*每个页面公共css */
</style>

201
LICENSE Normal file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

3
README.md Normal file
View File

@ -0,0 +1,3 @@
<h2>
文档已移至 <a href="https://uniapp.dcloud.io/uniCloud/uni-starter.html" target="_blank">uni-starter文档</a>
</h2>

3
androidPrivacy.json Normal file
View File

@ -0,0 +1,3 @@
{
"prompt" : "template"
}

268
changelog.md Normal file
View File

@ -0,0 +1,268 @@
## 2.1.82023-12-15
更新 升级依赖的uni-icons版本为2.0.8
## 2.1.72023-12-15
修复 因网络错误引起的 manifest.json 文件错误引起的 web 端字体大小等样式问题
## 2.1.62023-12-14
- 更新 依赖的uni-id-pages的版本为1.1.17
## 2.1.52023-10-20
- 更新 依赖的uni-id-pages的版本为1.1.16
## 2.1.42023-07-11
- 纠正`opendb-news-articles.schema.json`错误的权限表达式`doc.uid`为`doc.user_id`
## 2.1.32023-05-10
- 更新 依赖的uni-id-pages的版本为1.1.13 修复 启用摇树优化后切换登陆方式报错的问题
## 2.1.22023-02-10
- 新增 微信小程序端 首页需强制登录时,隐藏返回首页按钮
## 2.1.12023-02-02
- 重要 分包加载uni-id-pages 优化后 运行时主包大小为637KB 分包为78KB发布后主包大小为585KB 分包为75KB
- 新增 微信小程序端 支持选择使用微信资料的“头像”和“昵称” 设置用户资料 [详情参考](https://wdoc-76491.picgzc.qpic.cn/MTY4ODg1MDUyNzQyMDUxNw_21263_rTNhg68FTngQGdvQ_1647431233?w=1280&h=695.7176470588236)
## 2.1.02023-01-17
- 重要 新增uni-admin需要的相关依赖和初始化数据方便uni-admin关联uni-starter后可直接运行
- 升级依赖的 [uni-id-pages](https://ext.dcloud.net.cn/plugin?name=uni-id-pages) 修复如下问题:
1. 优化 压缩依赖的文件资源大小
2. 更新依赖的 验证码插件`uni-captcha`版本的版本为 0.6.4 修复 部分情况下APP端无法获取验证码的问题 [详情参考](https://ext.dcloud.net.cn/plugin?id=4048)
3. 修复 客户端token过期后点击退出登录按钮报错的问题
4. uni-id-co 修复 updateUser 接口`手机号`和`邮箱`参数值为空字符串时,修改无效的问题
## 2.0.62022-10-19
- 更新 文件路径:`/uni_modules/uni-id-pages/init.js`内uni-push客户端推送标识获取失败的提示
## 2.0.52022-10-19
- 更新依赖的`uni-id-pages`的版本为1.0.26
## 2.0.42022-09-21
- 新增 使用uni-id-pages的账号信息的状态管理功能
## 2.0.32022-09-20
- 更新 依赖的`uni-ui`组件为最新版本(注意:该版本的`uni-form`相关组件将自定义节点设置成[虚拟节点](https://uniapp.dcloud.net.cn/tutorial/vue-api.html#%E5%85%B6%E4%BB%96%E9%85%8D%E7%BD%AE))
- 更新 依赖的`uni_module`-> `uni-id-pages`为 v1.0.19版 修复 小程序端使用将自定义节点设置成虚拟节点的uni-ui组件导致的样式错乱问题
## 2.0.22022-09-19
- 更新表结构解决部分clientDB操作没有权限的问题
## 2.0.12022-09-16
- 更改默认值
## 2.0.02022-09-16
- 【重要】 v2版正式发布 应用`uni-id-pages`、`uniIdRouter`;(注意:此版本更新内容较多,升级请注意备份)
- 考虑到部分旧项目不想升级,保留`uni-starter v1`版源码,托管在仓库的[v1分支](https://gitcode.net/dcloud/uni-starter/-/blob/v1/README.md)继续使用v1版遇到问题可以提交[Issue](https://gitcode.net/dcloud/uni-starter/-/issues/new?issue%5Bassignee_id%5D=&issue%5Bmilestone_id%5D=)有bug仍然会修复但v1版本不再新增功能。
## 1.2.72022-08-10
- 修复微信小程序绑定手机号失败的问题
## 1.2.62022-06-29
- 支持 ios 安全区
## 1.2.52022-05-29
升级预置的`uni_modules`->`uni-captcha`版本为0.6.0。[详情](https://ext.dcloud.net.cn/plugin?name=uni-captcha)
## 1.2.42022-05-20
- 修改`uni-starter.config.js`->`debug`的默认值为`false`
## 1.2.32022-05-20
- 默认关闭`manifest.json`中的扩展配置
- `uni-starter.config.js` 新增debug,用于配置是否开启调试模式
## 1.2.22022-05-19
- 优化登陆体验账号密码登陆错误超过2次再显示图形验证码进行人机校验。
## 1.2.12022-05-18
- 修复在某些情况下,微信小程序端验证码显示错误的问题
## 1.2.02022-05-16
- 短信验证码登陆、绑定手机号码新增防刷逻辑。当短信验证码输入错误2次以上弹出图形验证码进行人机校验。
- uni-id-cf新增防刷机制。更改loginLog为uniIdLog 记录各类uni-id操作并新增action字段记录操作的行为名称
- 注册账号新增需要输入图形验证码
## 1.1.342022-05-12
修复绑定手机号码未验证空验证码的问题。注意请确保项目依赖的uni-id版本为3.3.18+
## 1.1.332022-02-24
修复微信小程序端,个人资料-绑定手机号码一键获取微信资料中手机号码绑定授权点击“拒绝”时toastencryptedData 不可为空的问题
## 1.1.322022-02-24
- 删除多余文件:`uniCloud/database/opendb-news-articles-detail.schema.json`
- 修复当用户选择验证码登陆方式,在输入验证码页面,点击微信登陆时报“你未同意隐私政策协议”的问题
## 1.1.312022-02-16
修复微信小程序端,修改绑定的手机号码时表单验证不正常的问题
## 1.1.302022-01-26
- 新增逻辑:调用uni-id-cf的logout接口后刷新设备信息中token的有效期
- 修复某些情况下前端执行logout没调用uniID.logout的问题
- 修复某些情况下报push_clientid未定义的问题
## 1.1.292022-01-25
- 保存`uni_id_token`到`storage`改用异步方法,方便通过拦截器执行`token`更新后的操作
- 新增通过拦截器监听`uni_id_token`更新调用云函数刷新刷新设备信息token有效期的API `renewDeviceTokenExpired`
- 删除留言板示例
- 修复图片验证码样式问题
## 1.1.282022-01-12
删除list页第37行多了个``引起的报错
## 1.1.272022-01-11
更新uni-id-cf为:1.0.10版,修复 限制只有 admin 用户可管理用户标签(不支持非 admin 用户操作managerMultiTag 接口)
## 1.1.262021-12-29
- 性能优化list页面使用`getTemp`[详情](https://uniapp.dcloud.io/uniCloud/unicloud-db?id=collection)
- 拉齐uni-starter和uni-admin的schema新增uni-id-tag.schema.json更新opendb-verify-codes.schema.json
- 修复首次登陆,用户id没存储到storage的问题
- 新增:执行退出登陆后,通过云函数调用`uniID.logout`
## 1.1.252021-12-09
修复H5端在about页面返回触发`uniShare.hide()`引发报错
## 1.1.242021-11-29
- 新增注销用户账号的功能
- 修复在某些情况下签到不连续7天也获得60积分的问题
## 1.1.232021-11-20
- 使用`uni.getUniverifyManager`优化一键登陆中点击第三方登陆的逻辑未勾选隐私政策时toast提醒并阻止了一键登陆界面的close
- 新增支持看激励视频广告签到
## 1.1.222021-11-10
删除`common/openApp.js`中可选链操作符解决vue3版本在hbuilderX内置浏览器不兼容的问题
## 1.1.212021-11-10
新增app端列表页面使用原生list下拉刷新
## 1.1.202021-11-08
修复vue3版某些情况下i18n报错的问题
## 1.1.192021-11-08
配置文件`uni-starter.config.js`默认关闭i18n多语言国际化
## 1.1.182021-10-14
使用2.0版`uni-share`。当显示分享窗口时,监听返回操作(如:物理返回,全面屏手机侧滑)关闭分享窗口,而不是关闭当前页面。
## 1.1.172021-10-12
- 更新文档
- 修复list页面where条件中缺少&符,导致的错误
## 1.1.162021-10-05
在控制台提示开启多语言国际化将获取i18n中配置的tabbar的值覆盖pages.json中配置的tabbar的值
## 1.1.152021-10-02
新增支持配置是否开启i18n多语言国际化。
配置文件:`uni-starter.config.js`
`
"i18n":{
"enable":true //默认启用国际化。如果你不想使用国际化相关功能请改为false
}
`
## 1.1.142021-09-30
1. 通过微信小程序登录自动保存`sessionKey`到`uni-id-users`表
2. 我的-设置-个人资料 点击绑定手机号码,完善账号信息支持以下三种策略:
- APP端如果支持使用"通过运营商一键获取手机号码"
- 微信小程序端,支持"一键获取微信绑定的手机号"
- 其他端,通过手机验证码
## 1.1.132021-09-29
修复search页面因多语言国际化导致的白屏问题
## 1.1.122021-09-28
1. 改造微信登录逻辑,直接使用`uni.login`参数`"onlyAuthorize":true`实现
2. 修复一键登录弹出层已勾选“同意隐私政策协议”点击自定义登录按钮报“你未同意隐私政策协议”的bug
## 1.1.112021-09-24
优化邀请下载app页`pages/ucenter/invite`)下载按钮闪烁的问题
## 1.1.102021-09-23
修复获取验证码按钮的文字,在中文模式下显示为英文的问题
## 1.1.92021-09-16
修复由多语言切换功能引起的隐私政策协议标题链接被重写的问题
## 1.1.82021-09-15
更新数据表guestbook的schema中更新权限的配置
## 1.1.72021-09-14
更新数据表opendb-news-articles的schema中的权限配置
## 1.1.62021-09-13
纠正错误schema权限表达式`doc.uid`为`doc.user_id`
## 1.1.52021-09-01
为了更直观理解路由拦截。移除路由拦截器中默认过滤登录相关页面拦截的逻辑。确保所有白名单页面均在配置文件router.visitor中体现
## 1.1.42021-08-31
修改错误的文章表`SChema`的读权限表达式
## 1.1.32021-08-31
修复在微信小程序端默认语言为英文的问题
## 1.1.22021-08-30
修复在微信小程序下切换语言报`locale`不存在的问题
## 1.1.12021-08-30
- 解决3.2.6以下版本hbuilderx编译的项目报`uni.setLocale`不存在的问题
## 1.1.02021-08-27
- APP端支持vue3 hbuilderx 3.2.5+
- 支持国际化 中英文切换
- 新增留言板示例
- 修复签到的时区问题
## 1.0.482021-08-10
- 修复登录成功后响应体包含`userInfo.password`的问题
- 修改了`uni-id-users`表的schema中字段username的编辑权限防止用户通过clientDB绕过用户名不能重复的规则更新用户名的问题
## 1.0.472021-08-09
- 更新文档快速体验部署流程
- 修复一键登录优先时报变量找不到的问题
## 1.0.462021-08-05
清理多余文件
## 1.0.452021-08-05
默认首页为nvue页面+fast
## 1.0.442021-08-05
解决首页为非nvue页面时白屏的问题。
- 注意:本次在`common/appInit.js`中修改了路由拦截的逻辑是个兼容方案当首页为非nvue页面路由拦截器逻辑会在加载首页时执行。接下来新版本的hx编译的uni-app项目无论首页是否为nvue都不走拦截器保持各端逻辑一致。
## 1.0.432021-08-02
1. 微信小程序端,新增:微信登录成功后,弹出是否"获取微信头像和昵称,完善个人资料"的弹框
2. APP端新增逻辑微信登录成功后自动获取用户的微信昵称和头像完善用户个人资料
- 提示因为微信的头像一旦更换微信返回的头像url会失效。所以以上两示例功能将url客户端下载到临时目录/服务端转为Buffer再上传到uniCloud云存储中再使用。
## 1.0.422021-07-29
新增绑定手机号码页面前端校验
## 1.0.412021-07-27
1. 支持vue3.0
2. 去掉App.vue全局样式避免与非flex布局的页面样式冲突
## 1.0.402021-07-22
1. 调整使用正则表达式配置强制登录功能的写法,解决在小程序端的兼容问题。
2. 新增签到功能培养用户习惯提升用户粘性。支持每日签到奖励、周期性连续7日签到奖励翻倍。
## 1.0.392021-07-19
1. 强制登录配置,新增白名单模式
2. 强制登录配置,支持正则表达式
## 1.0.382021-07-17
删除多余文件
## 1.0.372021-07-14
去掉配置文件:`uni-starter.config.js``h5` —> `url`结尾的`/`
## 1.0.362021-07-14
剪切板中的邀请码,添加标识性前缀 `uniInvitationCode:`
## 1.0.352021-07-12
1. H5端默认不开启隐私权限协议签署页面。因为网页端没有什么隐私权限能被获取目前全球仅欧盟有要求如有需要请手动开启
2. 在列表页演示如何在onShow生命周期获取设备位置并在设备或者应用没有权限时自动引导。设置完毕自动重新获取。[更多点此查看插件介绍](https://ext.dcloud.net.cn/plugin?name=json-gps)
## 1.0.342021-07-08
修复,打开登录页时携带参数,导致的快捷登录方式重复的问题
## 1.0.332021-07-06
修复,点击短信验证码登录打开的页面不正确的问题
## 1.0.322021-07-06
修复,仅配置一种快捷登录时的错误
## 1.0.312021-07-02
优化项目文档
## 1.0.302021-07-01
1. 简化宫格页面写法,方便理解如何控制不同状态角色的用户是否可见哪些元素。
2. uni-id-cf发送短信验证码api默认注释掉虚拟发送短信验证码的代码块。
3. uni-id-cf统一action名称为驼峰法
## 1.0.292021-06-29
1. 修复在安卓10以下设备,操作登录获取不到oaid会直接导致登录失败的bug
2. 修复uniCloud版本为阿里云版时删除头像设置失败腾讯云版删除头像后二次上传失败的问题
## 1.0.282021-06-28
修复云函数uni-id-cf的resetPwdBySmsCode接口未注册过的用户也能调用的问题
## 1.0.272021-06-25
修改文档新增h5版演示示例
## 1.0.262021-06-24
升级用户头像上传的裁切功能app端为原生裁剪其他端保持原来方式。数据表字段改用avatar_file存储file对象方便做图片的回显
## 1.0.252021-06-23
预置uniCloud admin依赖的uniCloud文件方便uniCloud admin与uni-starter配套使用时免做文件迁移
## 1.0.242021-06-23
删除callFunction拦截器中多余的代码
## 1.0.232021-06-22
更正调试遗留的uni-config-center/uni-id/config.json的tokenExpiresIn=1配置问题改为默认值7200
## 1.0.222021-06-22
1. 新增一键登录授权界面的其他快捷登录按钮
2. 优化uni-quick-login组件代码
3. 调整隐私政策协议框勾选逻辑:在登录页面已勾选,同步勾选。如果没勾选需要手动勾选(为符合应用市场上架要求)
4. 调整登录页隐私政策协议框位置。
5. 增强路由拦截新增判断token是否过期。
## 1.0.212021-06-21
优化uni_modules模式使用uni-id-cf方便uni-starter与uniCloud-admin的uni-id-cf同步更新。
## 1.0.202021-06-18
1.H5端新增强制要求用户同意隐私协议 2.兼容ios端自动设置打开下载页用户的剪切板为邀请者的inviteCode 3.成功注册用户且请求体含邀请码inviteCode自动关联裂变关系
## 1.0.192021-06-17
1.新增获取邀请码接口getUserInviteCode 2.在邀请用户下载应用页面自动设置被邀请用户的剪切板为邀请者的code(仅支持安卓端) 3.在注册或登录并注册请求时自动添加剪切板中的请求参数 4.统一接口名称为驼峰法
## 1.0.182021-06-15
修复APP端有安装微信客户端但未显示微信登录快捷键的问题
## 1.0.172021-06-09
修复非APP端deviceInfo为空引起的登录失败问题
## 1.0.162021-06-08
新增,操作注册/登录操作自动获取客户端设备push_clientid、imei、oaid、idfa新增/更新到数据表uni-id-device新增操作注册/登录操作自动获取客户端设备push_clientid、imei、oaid、idfa新增/更新到数据表uni-id-device
## 1.0.152021-06-07
为迎合苹果App Store的规则登录与分享功能项显示之前自动检测是否安装了对应客户端。比如设备未安装微信则不显示微信快捷登录和微信分享选项。为迎合苹果App Store的规则登录与分享功能项显示之前自动检测是否安装了对应客户端。比如设备未安装微信则不显示微信快捷登录和微信分享选项。
## 1.0.142021-06-07
修改错误的表名称uni-verify为opendb-verify-codes
## 1.0.132021-06-04
新增一键登录界面的第三方快捷登录按钮
## 1.0.122021-05-28
修复拦截器在ios app端会报错Unhandled promise...的问题
## 1.0.102021-05-27
新增callfunction的拦截器废除this.request的写法。为callFunction添加请求失败是否断网判断并提示、恢复网络自动重新执行、自动处理响应体token过期自动跳转到登录页面、token自动续期
## 1.0.92021-05-23
修复变量被重复定义的问题
## 1.0.82021-05-22
宫格页(/pages/grid/grid),新增根据当前用户是否登录、是否为管理员的角色来决定是否显示的示范
## 1.0.72021-05-22
删除多余数据
## 1.0.62021-05-22
修复当username用户名&密码为第一优先级的登录方式时。无法切换到smsCode(短信验证码)登录方式
## 1.0.52021-05-20
改用uni_modules方式处理图片选择api时无权限引导用户快捷打开系统设置
## 1.0.42021-05-19
为方便部署添加空的manifest.json uni-config-center下的uni-id配置
## 1.0.32021-05-18
重大调整原云函数名称user-center改名叫uni-id-cf
修复绑定手机号码场景。因手机未插SIM导致的一键登录失败后未直接跳到获取短信验证码方式绑定
## 1.0.22021-05-17
添加 uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json 文件
## 1.0.12021-05-17
manifest.json 在小程序平台增加了一个配置项 betterScopedSlots启用新的作用域插槽编译用于支持作用域插槽内使用复杂表达式。
## 1.0.02021-05-17
第一版

164
common/appInit.js Normal file
View File

@ -0,0 +1,164 @@
import uniStarterConfig from '@/uni-starter.config.js';
//应用初始化页
// #ifdef APP-PLUS
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
import callCheckVersion from '@/uni_modules/uni-upgrade-center-app/utils/call-check-version';
// 实现,路由拦截。当应用无访问摄像头/相册权限,引导跳到设置界面 https://ext.dcloud.net.cn/plugin?id=5095
import interceptorChooseImage from '@/uni_modules/json-interceptor-chooseImage/js_sdk/main.js';
interceptorChooseImage()
// #endif
const db = uniCloud.database()
export default async function() {
const debug = uniStarterConfig.debug;
// uniStarterConfig挂载到getApp().globalData.config
setTimeout(() => {
getApp({
allowDefault: true
}).globalData.config = uniStarterConfig;
}, 1)
// 初始化appVersion仅app生效
initAppVersion();
//clientDB的错误提示
function onDBError({
code, // 错误码详见https://uniapp.dcloud.net.cn/uniCloud/clientdb?id=returnvalue
message
}) {
console.log('onDBError', {
code,
message
});
// 处理错误
console.error(code, message);
}
// 绑定clientDB错误事件
db.on('error', onDBError)
//拦截云对象请求
uniCloud.interceptObject({
async invoke({
objectName, // 云对象名称
methodName, // 云对象的方法名称
params // 参数列表
}) {
// console.log('interceptObject',{
// objectName, // 云对象名称
// methodName, // 云对象的方法名称
// params // 参数列表
// });
if(objectName == "uni-id-co" && (methodName.includes('loginBy') || ['login','registerUser'].includes(methodName) )){
console.log('执行登录相关云对象');
params[0].inviteCode = await new Promise((callBack) => {
uni.getClipboardData({
success: function(res) {
console.log('剪切板内容:'+res.data);
if (res.data.slice(0, 18) == 'uniInvitationCode:') {
let uniInvitationCode = res.data.slice(18, 38)
console.log('当前用户是其他用户推荐下载的,推荐者的code是' + uniInvitationCode);
// uni.showModal({
// content: '当前用户是其他用户推荐下载的,推荐者的code是'+uniInvitationCode,
// showCancel: false
// });
callBack(uniInvitationCode)
//当前用户是其他用户推荐下载的。这里登记他的推荐者id 为当前用户的myInviteCode。判断如果是注册
} else {
callBack()
}
},
fail() {
console.log('error--');
callBack()
},
complete() {
// #ifdef MP-WEIXIN
uni.hideToast()
// #endif
}
});
})
// console.log(params);
}
// console.log(params);
},
success(e) {
console.log(e);
},
complete() {
},
fail(e){
console.error(e);
// if (debug) {
// uni.showModal({
// content: JSON.stringify(e),
// showCancel: false
// });
// }else{
// uni.showToast({
// title: '系统错误请稍后再试',
// icon:'error'
// });
// }
}
})
// #ifdef APP-PLUS
// 监听并提示设备网络状态变化
uni.onNetworkStatusChange(res => {
console.log(res.isConnected);
console.log(res.networkType);
if (res.networkType != 'none') {
uni.showToast({
title: '当前网络类型:' + res.networkType,
icon: 'none',
duration: 3000
})
} else {
uni.showToast({
title: '网络类型:' + res.networkType,
icon: 'none',
duration: 3000
})
}
});
// #endif
}
/**
* // 初始化appVersion
*/
function initAppVersion() {
// #ifdef APP-PLUS
let appid = plus.runtime.appid;
plus.runtime.getProperty(appid, (wgtInfo) => {
let appVersion = plus.runtime;
let currentVersion = appVersion.versionCode > wgtInfo.versionCode ? appVersion : wgtInfo;
getApp({
allowDefault: true
}).appVersion = {
...currentVersion,
appid,
hasNew: false
}
// 检查更新小红点
callCheckVersion().then(res => {
// console.log('检查是否有可以更新的版本', res);
if (res.result.code > 0) {
// 有新版本
getApp({
allowDefault: true
}).appVersion.hasNew = true;
console.log(checkUpdate());
}
})
});
// 检查更新
// #endif
}

36
common/openApp.js Normal file
View File

@ -0,0 +1,36 @@
/*
创建在h5端全局悬浮引导用户下载app的功能
如不需要本功能直接移除配置文件uni-starter.config.js下的h5/openApp即可
*/
import CONFIG from '../uni-starter.config.js';
const CONFIG_OPEN = CONFIG.h5.openApp || {};
// 仅H5端添加"打开APP"
export default function() {
// #ifdef H5
if (!CONFIG_OPEN.openUrl) return;
let openLogo = CONFIG_OPEN.logo ?
`<img src="${CONFIG_OPEN.logo}" style="width: 2rem;height: 2rem;border-radius: 3px;">` : '';
let openApp = document.createElement("div");
openApp.id = 'openApp';
openApp.style =
'position: fixed;background:#FFFFFF;box-shadow: #eeeeee 1px 1px 9px; ;top: 0;left: 0;right: 0;z-index: 999;width: 100%;height: 45px;display: flex;flex-direction: row;justify-content: space-between;align-items: center;box-sizing: border-box;padding: 0 0.5rem;'
openApp.innerHTML = `
<div style="display: flex;flex-direction: row;justify-content: flex-start;align-items: center;">
${openLogo}
<div style="padding-left: 0.3rem;font-size: 12px;">${CONFIG_OPEN.appname || ''}</div>
</div>
<div class="openBtn" style="padding: 5px;font-size:12px;border-radius: 2px;border: 1px solid #007AFF;color: #007AFF;">下载app</div>
`;
document.body.insertBefore(openApp, document.body.firstChild);
document.body.style = 'height:calc(100% - 45px); margin-top:45px;';
openApp.addEventListener('click', e => {
var target = e.target || e.srcElement;
if (target.className.indexOf('openBtn') >= 0) {
window.location.href = CONFIG_OPEN.openUrl;
}
})
//#endif
}

View File

@ -0,0 +1,95 @@
<template>
<refresh @refresh="refresh" @pullingdown="onpullingdown" :display="showRefresh ? 'show' : 'hide'">
<view class="refreshBox">
<!-- 可以自己添加图片路径或base64实现图片 <image class="refreshImg" :src="config[state].img" mode="widthFix" resize="cover"></image> -->
<text class="refreshText">{{config[state].text}}</text>
</view>
</refresh>
</template>
<script>
export default {
data() {
return {
showRefresh:false,
state:0
}
},
methods:{
onpullingdown({pullingDistance,viewHeight}) {
if(pullingDistance < viewHeight){
this.state = 0
}else{
this.state = 1
}
},
refresh(){
// console.log('refresh');
this.showRefresh = true
this.state = 2
this.$emit('refresh')
}
},
watch: {
loading(loading, oldValue) {
if(!loading){
this.showRefresh = false
this.state = 3
}
}
},
props: {
loading: {
type:Boolean,
default(){
return false
}
},
config: {
type: Array,
default(){
return [
{
text:"继续下拉执行刷新",
img:""//base64
},
{
text:"释放立即刷新",
img:""//base64
},
{
text:"正在疯狂的加载中",
img:""//base64
},
{
text:"加载成功",
img:""//base64
}
]
}
},
},
}
</script>
<style lang="scss" scoped>
.refreshBox{
width: 750rpx;
height: 50px;
justify-content: center;
align-items: center;
flex-direction: row;
/* #ifndef APP-PLUS */
margin-top: -50px;
/* #endif */
}
.refreshImg{
width: 55rpx;
height: 55rpx;
z-index: 111;
}
.refreshText{
font-size: 26rpx;
color: #999999;
padding-left: 6rpx;
}
</style>

View File

@ -0,0 +1,6 @@
{
"noData": "No Data",
"noNetwork": "Network error",
"toSet": "Go to settings",
"error": "error"
}

View File

@ -0,0 +1,6 @@
import en from './en.json'
import zhHans from './zh-Hans.json'
export default {
en,
'zh-Hans': zhHans
}

View File

@ -0,0 +1,6 @@
{
"noData": "暂无数据",
"noNetwork": "网络异常",
"toSet": "前往设置",
"error": "错误"
}

View File

@ -0,0 +1,3 @@
新增uni-load-state组件这是一个封装数据请求状态的组件。根据uniCloud-db组件提供的参数直接响应对应的效果。
包括加载中、当前页面为空、没有更多数据、上拉加载更多;
加载错误判断如果是断网就引导打开系统网络设置页面。恢复联网后自动触发networkResume方法。

View File

@ -0,0 +1,171 @@
<template>
<view @appear="appear">
<view v-if="state.error">
<view class="box" v-if="networkType == 'none'">
<image class="icon-image" src="@/static/uni-load-state/disconnection.png" mode="widthFix"></image>
<text class="tip-text">{{noNetwork}}</text>
<view class="btn btn-default" @click="openSettings">
<text class="btn-text">{{toSet}}</text>
</view>
</view>
<text class="error" v-else>{{error}}{{JSON.stringify(state.error)}}</text>
</view>
<template v-else>
<!-- #ifdef APP-NVUE -->
<text class="state-text">{{state.loading?'加载中...':(state.hasMore?'上拉加载更多':'没有更多数据了')}}</text>
<!-- #endif -->
<!-- #ifndef APP-NVUE -->
<uni-load-more class="uni-load-more" :status="state.loading?'loading':(state.hasMore?'hasMore':'noMore')"></uni-load-more>
<!-- #endif -->
</template>
</view>
</template>
<script>
import {
initVueI18n
} from '@dcloudio/uni-i18n'
import messages from './i18n/index.js'
const {
t
} = initVueI18n(messages)
export default {
name: "uni-load-state",
computed: {
noData() {
return t('noData')
},
noNetwork() {
return t('noNetwork')
},
toSet() {
return t('toSet')
},
error() {
return t('error')
}
},
data() {
return {
"networkType": ""
};
},
props: {
state: {
type: Object,
default () {
return {
"loading": true,
"hasMore": false,
"pagination": {
"pages": 0
},
"data": [],
"error": {}
}
}
}
},
mounted() {
uni.onNetworkStatusChange(({
networkType
}) => {
if (this.networkType == 'none' && networkType != 'none') { //
this.$emit('networkResume')
}
this.networkType = networkType;
});
uni.getNetworkType({
success: ({
networkType
}) => {
this.networkType = networkType;
}
});
},
methods: {
appear() {
if (!this.state.loading && this.state.hasMore) {
this.$emit('loadMore')
}
},
openSettings() {
if (uni.getSystemInfoSync().platform == "ios") {
var UIApplication = plus.ios.import("UIApplication");
var application2 = UIApplication.sharedApplication();
var NSURL2 = plus.ios.import("NSURL");
var setting2 = NSURL2.URLWithString("App-prefs:root=General");
application2.openURL(setting2);
plus.ios.deleteObject(setting2);
plus.ios.deleteObject(NSURL2);
plus.ios.deleteObject(application2);
} else {
var Intent = plus.android.importClass("android.content.Intent");
var Settings = plus.android.importClass("android.provider.Settings");
var mainActivity = plus.android.runtimeMainActivity();
var intent = new Intent(Settings.ACTION_SETTINGS);
mainActivity.startActivity(intent);
}
}
}
}
</script>
<style scoped>
.box {
flex: 1;
width: 700rpx;
flex-direction: column;
align-items: center;
justify-content: center;
}
.uni-load-more{
align-items: center;
justify-content: center;
}
.state-text {
text-align: center;
font-size: 26rpx;
width: 690rpx;
padding: 10rpx;
color: #999999;
}
.icon-image {
width: 300rpx;
}
.tip-text {
color: #999999;
font-size: 32rpx;
margin-bottom: 30rpx;
}
.btn {
padding: 5px 10px;
width: 128px;
flex-direction: row;
align-items: center;
justify-content: center;
text-align: center;
}
.btn-text {
color: #999999;
font-size: 15px;
}
.btn-default {
border-color: #999999;
border-style: solid;
border-width: 1px;
border-radius: 3px;
}
.error {
width: 690rpx;
color: #DD524D;
}
</style>

20
index.html Normal file
View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<title></title>
<!--preload-links-->
<!--app-context-->
</head>
<body>
<div id="app"><!--app-html--></div>
<script type="module" src="/main.js"></script>
</body>
</html>

View File

@ -0,0 +1,104 @@
/*
字典模块
作者:AC
时间:2019/12/24 14:00
说明:所有其中的数据都不会显示在Storage中 一定程度上防止了泄漏
主要方法说明:
AddKeyValue:添加键值对
DeleteValueByKey:根据键删除值
GetValueByKey:根据键获取值
ClearDictionary:清空字典内容
GetDictionary:获取字典
GetValueByKeyAndFun:根据键获取值 并且运行一个指定的函数(要求此函数必须返回这个键对应的值)
主要参数说明:
dictionary:字典
httpDictionary: 字典操作
code:状态值
key:字典的键
value:字典的值
fun:外部函数(要求此函数必须返回这个键对应的值)
操作日志:
1.初步搭建 2019/12/14 14:00 AC
*/
/*
以下发出的功能均经过项目中的实际使用
在uni-app 中的微信小程序项目下 可以使用 避免使用Storage的一系列坑
不过此数据字典 会在每次用户关闭小程序或者关闭页面的时候清空.
仅仅可以用在小程序的优化访问中 一些静态数据的存储以及修改 以及一些临时数据的存储
需要在初始化的时候进行创建 详见APP.VUE 示例
*/
var message=require("script/Message.js");
//初始化请求字典集合
var dictionary={};
//执行结果值
var value="";
var httpDictionary={
//添加/修改字典值-如果有这个key 则会覆盖其中原先的值
AddKeyValue:function(key,value){
dictionary[key]=value;
},
//删除key的值
DeleteValueByKey:function(key){
return DeleteValue(key);
},
//根据key获取值
GetValueByKey:function(key){
return GetValues(key);
},
//清空字典的所有值 恢复成默认值
ClearDictionary:function(){
dictionary={};
},
//获取整个字典
GetDictionary:function(){
return dictionary;
},
//获取字典的值 并且执行fun函数 如果fun是一个函数 结果fun必须返回一个字符串
GetValueByKeyAndFun:function(key,fun){
return typeof fun == "function"? fun(this.GetValueByKey(key)):this.GetValueByKey(key);
}
}
//获取value值
function GetValues(key){
try{
//键为空 增加提示信息
if(key==""){
return message.SetMessage("A002","在执行获取字典内容的时候,键为空","",1);
}
console.log("值:"+dictionary[key]);
return (typeof dictionary[key] == "undefined"?"":dictionary[key]);
}catch(e){
return message.SetMessage("A001","在执行获取"+key+"的值的时候发生异常","",0);
}
}
//尝试清除字典中的值
function DeleteValue(key){
try{
//键为空 增加提示信息
if(key==""){
return message.SetMessage("A002","在执行清除字典内容的时候,键为空",false,1);
}
dictionary[key]="";
return true;
}catch(e){
return message.SetMessage("A001","在执行清除"+key+"的值的时候发生异常",false,0);
}
}
//设置字典中的值
function SetValue(key,value){
try{
if(key==""){
return message.SetMessage("A002","在执行添加字典内容的时候,键为空",false,1);
}
dictionary[key]=value;
return true;
}catch(e){
return message.SetMessage("A001","在执行添加"+key+"的值的时候发生异常",false,0);
}
}
module.exports=httpDictionary;

View File

@ -0,0 +1,59 @@
/*
消息模块
作者:AC
时间:2019/12/26
说明:目前只是简单的消息模块 后期会增加日志等功能
参数说明:
exec:
type:0 必定运行异常 1 系统警告 2 系统提示 3 正常请求 4可能会出现异常
code:
"A001":执行异常
"A002":传入参数为空
"A200":提示信息
"A400":无权操作
message:消息内容 可以是提示,异常,警告等消息头 只需对应的type即可
switchType:消息类型字典 常量
Message:
函数说明:
SetMessage:设置消息
result:需要返回的值(其他操作携带过来的 此处可以对其进行再次处理)
code:同exce.code
message:同exce.message
type:同exce.type
操作日志:
1.初步搭建:2019/12/26 15:00 AC 搭建完成 通过测试
2.增加type 3 4
*/
//消息模块 此处为简单版本 保存运行时的日志信息
//完善版本正在项目中使用并且测试,可自己完善其中的部分,如果您有更好的建议
//希望您能够 添加我的qq 2960861359 或者微信 K11150922
var exce={
message:"",
code:"",
type:2,
typeInfo:"提示"
};
var switchType={
"0":"异常",
"1":"警告",
"2":"提示",
"3":"请求",
"4":"可能出现异常"//当message为空 则表示可能出现异常
}
var Message={
//设置错误信息
SetMessage:function(code,message,result,type){
exce.message=message;
exce.code=code;
exce.type=type;
exce.typeInfo=switchType[type]==""?"未注册的状态":switchType[type];
return result;
},
GetMessage:function(){
return exce;
}
}
//消息模块
module.exports=Message;

View File

@ -0,0 +1,159 @@
var WIFI_SERVICE = 'wifi';
var ACTIVITY_SERVICE = 'activity';
/**
* 获取wifi的mac地址
*/
function getMac(){
try{
var os = plus.os.name;
if('Android' == os){
var main = plus.android.runtimeMainActivity();
var wifiService = main.getSystemService(WIFI_SERVICE);
var wifiInfo = plus.android.invoke(wifiService, 'getConnectionInfo');
var mac = plus.android.invoke(wifiInfo, 'getMacAddress');
return mac;
}else{
//unsupport, nothing to do.
}
}catch(e){
console.error('error @getMac!!');
}
}
/**
* 获取手机可用内存大小
* 单位为字节
*/
function getAvailMemory(){
try{
var os = plus.os.name;
if('Android' == os){
var ActivityManager = plus.android.importClass('android.app.ActivityManager');
var mi = new ActivityManager.MemoryInfo();
var activityService = plus.android.runtimeMainActivity().getSystemService(ACTIVITY_SERVICE);
activityService.getMemoryInfo(mi);
var memoryInfo = mi.plusGetAttribute('availMem');
return memoryInfo;
}else{
//unsupport, nothing to do.
}
}catch(e){
console.error('error @getAvailMemory!!');
}
}
/**
* 获取手机总内存大小
* 单位为KB
*/
function getTotalMemory(){
try{
var os = plus.os.name;
if('Android' == os){
var memInfo = '/proc/meminfo';
var temp = '',
ramSize = '',
arrays, initMemory;
var fileReader = plus.android.importClass("java.io.FileReader");
var bufferedReader = plus.android.importClass("java.io.BufferedReader");
var FileReader = new fileReader(memInfo);
var BufferedReader = new bufferedReader(FileReader, 8192);
while ((temp = BufferedReader.readLine()) != null) {
if (-1 != temp.indexOf('MemTotal:')) {
var value = temp.replace(/[^0-9]/ig, "");
ramSize = parseInt(value);
}
}
return ramSize;
}else{
//unsupport, nothing to do.
}
}catch(e){
console.error('error @getAvailMemory!!');
}
}
/**
* 获取内部存储空间大小
* 单位为字节
*/
function getInternalStorage(){
try{
var os = plus.os.name;
if('Android' == os){
var environment = plus.android.importClass('android.os.Environment');
var statFs = plus.android.importClass('android.os.StatFs');
var files = plus.android.importClass('java.io.File');
var Files = environment.getDataDirectory();
var StatFs = new statFs(Files.getPath());
var blockSize = parseFloat(StatFs.getBlockSize());
var blockCount = parseFloat(StatFs.getBlockCount());
var internalMemSize = blockSize*blockCount;
return internalMemSize;
}else{
//unsupport, nothing to do.
}
}catch(e){
console.error('error @getCpuInfo!!');
}
}
/**
* 获取CPU信息
*/
function getCpuInfo(){
try{
var os = plus.os.name;
if('Android' == os){
var cpuInfo = '/proc/cpuinfo';
var temp = '',
cpuHardware;
var fileReader = plus.android.importClass('java.io.FileReader');
var bufferedReader = plus.android.importClass('java.io.BufferedReader');
var FileReader = new fileReader(cpuInfo);
var BufferedReader = new bufferedReader(FileReader, 8192);
while ((temp = BufferedReader.readLine()) != null) {
if (-1 != temp.indexOf('Hardware')) {
cpuHardware = temp.substr(parseInt(temp.indexOf(":")) + 1);
}
}
return cpuHardware;
}else{
//unsupport, nothing to do.
}
}catch(e){
console.error('error @getCpuInfo!!');
}
}
/**
* 获取CPU核数
*/
function getCpuCount(){
try{
var os = plus.os.name;
if('Android' == os){
var Runtime = plus.android.importClass("java.lang.Runtime");
var cpuCount = Runtime.getRuntime().availableProcessors();
return cpuCount;
}else{
//unsupport, nothing to do.
}
}catch(e){
console.error('error @getCpuInfo!!');
}
}
module.exports = {
mac: getMac,
availMem: getAvailMemory,
totalMem: getTotalMemory,
interStorage: getInternalStorage,
cpuInfo: getCpuInfo,
cpuCount: getCpuCount,
getCpuInfo
}

113
js_sdk/util/dictTools.js Normal file
View File

@ -0,0 +1,113 @@
const db = uniCloud.database();
import {
getJsonTree,
groupBy
} from "@/js_sdk/util/jsonData";
//一次性把字典数据查询并存储
export function saveDictItemStore() {
db.collection('ngTools_DictItem').field(
"dictID,itemValue as value , itemText as text ,itemColor,description,sortOrder"
).orderBy('dictID,sortOrder')
.get().then((res) => {
console.log(res)
if (res.result.data) {
const selectData = groupBy(res.result.data, 'dictID');
// #ifdef APP-PLUS
uni.setStorageSync("dictItem", selectData);
// #endif
// #ifdef H5
localStorage.setItem("dictItem", JSON.stringify(selectData));
// #endif
// #ifdef MP-WEIXIN
wx.setStorageSync("dictItem", selectData);
// #endif
console.log(res.result.data)
console.log(selectData)
}
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
console.log(3333)
}).finally(() => {
console.log(4444)
uni.hideLoading()
})
}
//一次性把字典数据查询并存储
export function saveDepartStore() {
db.collection('ngTools_depart').field(
"_id,parent_id,depart_name,level,sort,manager_uid,status"
).orderBy('parent_id')
.get().then((res) => {
if (res.result.data) {
const departData = getJsonTree(res.result.data);
console.log(departData)
// #ifdef APP-PLUS
uni.setStorageSync("departData", departData);
// #endif
// #ifdef H5
localStorage.setItem("departData", JSON.stringify(departData));
// #endif
// #ifdef MP-WEIXIN
wx.setStorageSync("departData", departData);
// #endif
console.log(res.result.data)
console.log(departData)
}
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
console.log(3333)
}).finally(() => {
console.log(4444)
uni.hideLoading()
})
}
export function getDictItemStore(dictID) {
let data = [];
// #ifdef MP-WEIXIN
data = (wx.getStorageSync("dictItem"));
// #endif
// #ifdef APP-PLUS
data = uni.getStorageSync("dictItem");
// #endif
// #ifdef H5
data = JSON.parse(localStorage.getItem("dictItem"));
// #endif
return data[dictID];
// console.log(this.selectData);
// console.log(data);
// if (this.selectData.length > 0) {
// }
}
export function getDepartStore() {
let data = [];
// #ifdef MP-WEIXIN
data = (wx.getStorageSync("departData"));
// #endif
// #ifdef APP-PLUS
data = uni.getStorageSync("departData");
// #endif
// #ifdef H5
data = JSON.parse(localStorage.getItem("departData"));
// #endif
return data;
}

48
js_sdk/util/jsonData.js Normal file
View File

@ -0,0 +1,48 @@
export function groupBy(array, key) {
return array.reduce((result, currentItem) => {
// 使用 key 的值作为分组的键
const groupKey = currentItem[key];
// 如果 result 中不存在这个键,则创建一个数组
if (!result[groupKey]) {
result[groupKey] = [];
}
// 将当前项推入对应的分组数组中
result[groupKey].push(currentItem);
return result;
}, {});
}
export function getJsonTree(items) {
const rootItems = [];
const lookup = {};
for (const item of items) {
const itemId = item._id;
const parentId = item.parent_id;
if (!lookup[itemId]) lookup[itemId] = {
['children']: []
};
lookup[itemId] = {
...item,
children: lookup[itemId]['children']
};
const parent = parentId ? lookup[parentId] : null;
if (parent) {
if (!parent.children) parent.children = [];
parent.children.push(lookup[itemId]);
} else {
rootItems.push(lookup[itemId]);
}
}
return rootItems;
}

View File

@ -0,0 +1,129 @@
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const validator = {
"dictName": {
"rules": [
{
"format": "string",
'require':true,
}
],
"title": "字典名称",
"label": "字典名称"
},
"dictCode": {
"rules": [
{
"format": "string",
'require':true,
}
],
"title": "字典编码",
"label": "字典编码"
},
"description": {
"rules": [
{
"format": "string"
}
],
"title": "描述",
"label": "描述"
},
"delFlag": {
"rules": [
{
"format": "int"
}
],
"title": "删除状态",
"label": "删除状态"
},
"createBy": {
"rules": [
{
"format": "string"
}
],
"title": "创建人",
"label": "创建人"
},
"updateBy": {
"rules": [
{
"format": "string"
}
],
"title": "更新人",
"label": "更新人"
},
"updateTime": {
"rules": [
{
"format": "datetime"
}
],
"title": "更新时间",
"label": "更新时间"
}
// ,
// "createTime": {
// "rules": [
// {
// "format": "datetime"
// }
// ],
// "title": "创建时间",
// "label": "创建时间"
// }
}
const enumConverter = {}
function filterToWhere(filter, command) {
let where = {}
for (let field in filter) {
let { type, value } = filter[field]
switch (type) {
case "search":
if (typeof value === 'string' && value.length) {
where[field] = new RegExp(value)
}
break;
case "select":
if (value.length) {
let selectValue = []
for (let s of value) {
selectValue.push(command.eq(s))
}
where[field] = command.or(selectValue)
}
break;
case "range":
if (value.length) {
let gt = value[0]
let lt = value[1]
where[field] = command.and([command.gte(gt), command.lte(lt)])
}
break;
case "date":
if (value.length) {
let [s, e] = value
let startDate = new Date(s)
let endDate = new Date(e)
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
case "timestamp":
if (value.length) {
let [startDate, endDate] = value
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
}
}
return where
}
export { validator, enumConverter, filterToWhere }

View File

@ -0,0 +1,153 @@
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const validator = {
"dictID": {
"rules": [
{
"format": "string"
}
],
"title": "字典ID",
"label": "字典ID"
},
"itemValue": {
"rules": [
{
"format": "string"
}
],
"title": "字典项值",
"label": "字典项值"
},
"itemText": {
"rules": [
{
"format": "string"
}
],
"title": "字典项文本",
"label": "字典项文本"
},
"itemColor": {
"rules": [
{
"format": "string"
}
],
"title": "字典项颜色",
"label": "字典项颜色"
},
"description": {
"rules": [
{
"format": "string"
}
],
"title": "描述",
"label": "描述"
},
"sortOrder": {
"rules": [
{
"format": "string"
}
],
"title": "排序",
"label": "排序"
},
"status": {
"rules": [
{
"format": "int"
}
],
"title": "状态",
"label": "状态"
},
"createBy": {
"rules": [
{
"format": "string"
}
],
"title": "创建人",
"label": "创建人"
},
"updateBy": {
"rules": [
{
"format": "string"
}
],
"title": "更新人",
"label": "更新人"
},
"createTime": {
"rules": [
{
"format": "datetime"
}
],
"title": "创建时间",
"label": "创建时间"
},
"updateTime": {
"rules": [
{
"format": "datetime"
}
],
"title": "更新时间",
"label": "更新时间"
}
}
const enumConverter = {}
function filterToWhere(filter, command) {
let where = {}
for (let field in filter) {
let { type, value } = filter[field]
switch (type) {
case "search":
if (typeof value === 'string' && value.length) {
where[field] = new RegExp(value)
}
break;
case "select":
if (value.length) {
let selectValue = []
for (let s of value) {
selectValue.push(command.eq(s))
}
where[field] = command.or(selectValue)
}
break;
case "range":
if (value.length) {
let gt = value[0]
let lt = value[1]
where[field] = command.and([command.gte(gt), command.lte(lt)])
}
break;
case "date":
if (value.length) {
let [s, e] = value
let startDate = new Date(s)
let endDate = new Date(e)
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
case "timestamp":
if (value.length) {
let [startDate, endDate] = value
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
}
}
return where
}
export { validator, enumConverter, filterToWhere }

View File

@ -0,0 +1,108 @@
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const validator = {
"dMeterType": {
"rules": [
{
"format": "string"
}
],
"title": "流量计类别",
"label": "流量计类别"
},
"departID": {
"rules": [
{
"format": "string"
}
],
"title": "部门编号",
"label": "部门编号"
},
"createBy": {
"rules": [
{
"format": "string"
}
],
"title": "创建人",
"label": "创建人"
},
"updateBy": {
"rules": [
{
"format": "string"
}
],
"title": "更新人",
"label": "更新人"
},
"createTime": {
"rules": [
{
"format": "datetime"
}
],
"title": "创建时间",
"label": "创建时间"
},
"updateTime": {
"rules": [
{
"format": "datetime"
}
],
"title": "更新时间",
"label": "更新时间"
}
}
const enumConverter = {}
function filterToWhere(filter, command) {
let where = {}
for (let field in filter) {
let { type, value } = filter[field]
switch (type) {
case "search":
if (typeof value === 'string' && value.length) {
where[field] = new RegExp(value)
}
break;
case "select":
if (value.length) {
let selectValue = []
for (let s of value) {
selectValue.push(command.eq(s))
}
where[field] = command.or(selectValue)
}
break;
case "range":
if (value.length) {
let gt = value[0]
let lt = value[1]
where[field] = command.and([command.gte(gt), command.lte(lt)])
}
break;
case "date":
if (value.length) {
let [s, e] = value
let startDate = new Date(s)
let endDate = new Date(e)
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
case "timestamp":
if (value.length) {
let [startDate, endDate] = value
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
}
}
return where
}
export { validator, enumConverter, filterToWhere }

View File

@ -0,0 +1,457 @@
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const validator = {
"createBy": {
"rules": [{
"format": "string"
}],
"title": "创建人",
"label": "创建人"
},
"updateBy": {
"rules": [{
"format": "string"
}],
"title": "更新人",
"label": "更新人"
},
"meterID": {
"rules": [{
"format": "string"
}],
"title": "计量点编号",
"label": "计量点编号"
},
"dFlowCalbz": {
"rules": [{
"format": "string"
}],
"title": "流量计算标准",
"label": "流量计算标准"
},
"dZcalbz": {
"rules": [{
"format": "string"
}],
"title": "压缩因子计算标准",
"label": "压缩因子计算标准"
},
"dCbtj": {
"rules": [{
"format": "string"
}],
"title": "计量参比条件压力",
"label": "计量参比条件压力"
},
"dPb_M": {
"rules": [{
"format": "string"
}],
"title": "计量参比条件压力",
"label": "计量参比条件压力"
},
"dTb_M": {
"rules": [{
"format": "string"
}],
"title": "计量参比条件温度",
"label": "计量参比条件温度"
},
"dPb_E": {
"rules": [{
"format": "string"
}],
"title": "燃烧参比条件压力",
"label": "燃烧参比条件压力"
},
"dTb_E": {
"rules": [{
"format": "string"
}],
"title": "燃烧参比条件温度",
"label": "燃烧参比条件温度"
},
"dPatm": {
"rules": [{
"format": "string",
"required": true,
"errorMessage": '大气压未输入'
}],
"title": "当地大气压",
"label": "当地大气压"
},
"dPatmUnit": {
"rules": [{
"format": "string"
}],
"title": "当地大气压单位",
"label": "当地大气压单位"
},
"dNG_Compents": {
"rules": [{
"format": "string"
}],
"title": "天然气组分",
"label": "天然气组分"
},
"dMeterType": {
"rules": [{
"format": "string"
}],
"title": "流量计类别",
"label": "流量计类别"
},
"dCoreType": {
"rules": [{
"format": "string"
}],
"title": "节流装置类型",
"label": "节流装置类型"
},
"dPtmode": {
"rules": [{
"format": "string"
}],
"title": "取压方式",
"label": "取压方式"
},
"dPipeType": {
"rules": [{
"format": "string"
}],
"title": "管道类型",
"label": "管道类型"
},
"dPipeD": {
"rules": [{
"format": "string",
"required": true,
"errorMessage": '管径未输入'
}],
"title": "管道内径",
"label": "管道内径"
},
"dLenUnit": {
"rules": [{
"format": "string"
}],
"title": "长度单位",
"label": "长度单位"
},
"dPipeDtemp": {
"rules": [{
"format": "string"
}],
"title": "管道内径参考温度",
"label": "管道内径参考温度"
},
"dPileDtempU": {
"rules": [{
"format": "string"
}],
"title": "温度单位",
"label": "温度单位"
},
"dPipeMaterial": {
"rules": [{
"format": "string"
}],
"title": "管道材料",
"label": "管道材料"
},
"dOrificeD": {
"rules": [{
"format": "string",
"required": true,
"errorMessage": '孔径未输入'
}],
"title": "孔板孔径",
"label": "孔板孔径"
},
"dOrificeUnit": {
"rules": [{
"format": "string"
}],
"title": "长度单位",
"label": "长度单位"
},
"dOrificeDtemp": {
"rules": [{
"format": "string"
}],
"title": "孔板内径参考温度",
"label": "孔板内径参考温度"
},
"dOrificeDtempUnit": {
"rules": [{
"format": "string"
}],
"title": "温度单位",
"label": "温度单位"
},
"dOrificeMaterial": {
"rules": [{
"format": "string"
}],
"title": "孔板材料",
"label": "孔板材料"
},
"dOrificeSharpness": {
"rules": [{
"format": "string"
}],
"title": "锐利度系数计算方法",
"label": "锐利度系数计算方法"
},
"dOrificeRk": {
"rules": [{
"format": "string"
}],
"title": "孔板入口圆弧半径",
"label": "孔板入口圆弧半径"
},
"dOrificeRkLenU": {
"rules": [{
"format": "string"
}],
"title": "长度单位",
"label": "长度单位"
},
"dPf": {
"rules": [{
"format": "string",
"required": true,
"errorMessage": '工况压力未输入'
}],
"title": "输入压力",
"label": "输入压力"
},
"dPfUnit": {
"rules": [{
"format": "string"
}],
"title": "压力单位",
"label": "压力单位"
},
"dPfType": {
"rules": [{
"format": "string"
}],
"title": "压力类型",
"label": "压力类型"
},
"dTf": {
"rules": [{
"format": "string",
"required": true,
"errorMessage": '工况温度未输入'
}],
"title": "输入温度",
"label": "输入温度"
},
"dTfUnit": {
"rules": [{
"format": "string"
}],
"title": "温度单位",
"label": "温度单位"
},
"dDp": {
"rules": [{
"format": "string",
"required": true,
"errorMessage": '差压未输入'
}],
"title": "输入差压",
"label": "输入差压"
},
"dDpUnit": {
"rules": [{
"format": "string"
}],
"title": "压力单位",
"label": "压力单位"
},
"dVFlowUnit": {
"rules": [{
"format": "string"
}],
"title": "体积流量单位",
"label": "体积流量单位"
},
"dMFlowUnit": {
"rules": [{
"format": "string"
}],
"title": "质量流量单位",
"label": "质量流量单位"
},
"dEFlowUnit": {
"rules": [{
"format": "string"
}],
"title": "能量流量单位",
"label": "能量流量单位"
},
"dCdCalMethod": {
"rules": [{
"format": "string"
}],
"title": "流出系数计算方法",
"label": "流出系数计算方法"
},
"dMeterFactor": {
"rules": [{
"format": "string",
"required": true,
"errorMessage": '仪表系数未输入'
}],
"title": "仪表系数",
"label": "仪表系数"
},
"dPulseNum": {
"rules": [{
"format": "string",
"required": true,
"errorMessage": '脉冲数未输入'
}],
"title": "脉冲数",
"label": "脉冲数"
},
"dVFlowMax": {
"rules": [{
"format": "string"
}],
"title": "最大体积流量",
"label": "最大体积流量"
},
"dVFlowMin": {
"rules": [{
"format": "string"
}],
"title": "最小体积流量",
"label": "最小体积流量"
},
"dVFlowCon": {
"rules": [{
"format": "string"
}],
"title": "常用流量",
"label": "常用流量"
},
"dPfRangeMin": {
"rules": [{
"format": "string"
}],
"title": "压力量程",
"label": "压力量程"
},
"dPfRangeMax": {
"rules": [{
"format": "string"
}],
"title": "压力量程",
"label": "压力量程"
},
"dDpRangeMin": {
"rules": [{
"format": "string"
}],
"title": "差压量程",
"label": "差压量程"
},
"dDpRangeMax": {
"rules": [{
"format": "string"
}],
"title": "差压量程",
"label": "差压量程"
},
"dTfRangeMin": {
"rules": [{
"format": "string"
}],
"title": "温度计量程",
"label": "温度计量程"
},
"dTfRangeMax": {
"rules": [{
"format": "string"
}],
"title": "温度计量程",
"label": "温度计量程"
},
"updateTime": {
"rules": [{
"format": "datetime"
}],
"title": "更新时间",
"label": "更新时间"
},
"createTime": {
"rules": [{
"format": "datetime"
}],
"title": "创建时间",
"label": "创建时间"
}
}
const enumConverter = {}
function filterToWhere(filter, command) {
let where = {}
for (let field in filter) {
let {
type,
value
} = filter[field]
switch (type) {
case "search":
if (typeof value === 'string' && value.length) {
where[field] = new RegExp(value)
}
break;
case "select":
if (value.length) {
let selectValue = []
for (let s of value) {
selectValue.push(command.eq(s))
}
where[field] = command.or(selectValue)
}
break;
case "range":
if (value.length) {
let gt = value[0]
let lt = value[1]
where[field] = command.and([command.gte(gt), command.lte(lt)])
}
break;
case "date":
if (value.length) {
let [s, e] = value
let startDate = new Date(s)
let endDate = new Date(e)
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
case "timestamp":
if (value.length) {
let [startDate, endDate] = value
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
}
}
return where
}
export {
validator,
enumConverter,
filterToWhere
}

View File

@ -0,0 +1,295 @@
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const validator = {
"samplingDate": {
"rules": [{
"format": "date"
}],
"title": "取样日期",
"defaultValue": {
"$env": "now"
},
"label": "取样日期"
},
"assayDate": {
"rules": [{
"format": "date"
}],
"title": "分析日期",
"defaultValue": {
"$env": "now"
},
"label": "分析日期"
},
"samplingLocation": {
"rules": [{
"format": "array"
},
{
"arrayType": "string"
}
],
"title": "取样地点",
"label": "取样地点"
},
"sampleNumber": {
"rules": [{
"format": "string"
}],
"title": "样品编号",
"label": "样品编号"
},
"NG_C1": {
"rules": [{
"format": "float"
}],
"title": "甲烷C1",
"defaultValue": 0,
"label": "甲烷C1"
},
"NG_N2": {
"rules": [{
"format": "float"
}],
"title": "氮气N2",
"defaultValue": 0,
"label": "氮气N2"
},
"NG_CO2": {
"rules": [{
"format": "float"
}],
"title": "二氧化碳CO2",
"defaultValue": 0,
"label": "二氧化碳CO2"
},
"NG_C2": {
"rules": [{
"format": "float"
}],
"title": "乙烷C2",
"defaultValue": 0,
"label": "乙烷C2"
},
"NG_C3": {
"rules": [{
"format": "float"
}],
"title": "丙烷C3",
"defaultValue": 0,
"label": "丙烷C3"
},
"NG_H2O": {
"rules": [{
"format": "float"
}],
"title": "水H2O",
"defaultValue": 0,
"label": "水H2O"
},
"NG_H2S": {
"rules": [{
"format": "float"
}],
"title": "硫化氢H2S",
"defaultValue": 0,
"label": "硫化氢H2S"
},
"NG_H2": {
"rules": [{
"format": "float"
}],
"title": "氢气H2",
"defaultValue": 0,
"label": "氢气H2"
},
"NG_CO": {
"rules": [{
"format": "float"
}],
"title": "一氧化碳CO",
"defaultValue": 0,
"label": "一氧化碳CO"
},
"NG_O2": {
"rules": [{
"format": "float"
}],
"title": "氧气O2",
"defaultValue": 0,
"label": "氧气O2"
},
"NG_iC4": {
"rules": [{
"format": "float"
}],
"title": "异丁烷iC4",
"defaultValue": 0,
"label": "异丁烷iC4"
},
"NG_nC4": {
"rules": [{
"format": "float"
}],
"title": "正丁烷nC4",
"defaultValue": 0,
"label": "正丁烷nC4"
},
"NG_iC5": {
"rules": [{
"format": "float"
}],
"title": "异戊烷iC5",
"defaultValue": 0,
"label": "异戊烷iC5"
},
"NG_nC5": {
"rules": [{
"format": "float"
}],
"title": "正戊烷nC5",
"defaultValue": 0,
"label": "正戊烷nC5"
},
"NG_C6": {
"rules": [{
"format": "float"
}],
"title": "己烷C6",
"defaultValue": 0,
"label": "己烷C6"
},
"NG_C7": {
"rules": [{
"format": "float"
}],
"title": "庚烷C7",
"defaultValue": 0,
"label": "庚烷C7"
},
"NG_C8": {
"rules": [{
"format": "float"
}],
"title": "辛烷C8",
"defaultValue": 0,
"label": "辛烷C8"
},
"NG_C9": {
"rules": [{
"format": "float"
}],
"title": "壬烷C9",
"defaultValue": 0,
"label": "壬烷C9"
},
"NG_C10": {
"rules": [{
"format": "float"
}],
"title": "癸烷C10",
"defaultValue": 0,
"label": "癸烷C10"
},
"NG_He": {
"rules": [{
"format": "float"
}],
"title": "氦气He",
"defaultValue": 0,
"label": "氦气He"
},
"NG_Ar": {
"rules": [{
"format": "float"
}],
"title": "氩气Ar",
"defaultValue": 0,
"label": "氩气Ar"
},
// "NG_SUM": {
// "rules": [{
// "format": "float",
// "required": true,
// "errorMessage": '组分输入不全'
// },
// {
// validateFunction: function(rule, value, data, callback) {
// console.log(value)
// console.log(data)
// if (Math.abs(parseFloat(value) - 100) > 0.0001) {
// callback('组分之和不等于100%')
// }
// return true
// }
// }
// ],
// "title": "合计",
// "defaultValue": 0,
// "label": "合计"
// },
"createTime": {
"rules": [{
"format": "datetime"
}],
"title": "创建时间",
"label": "创建时间"
}
}
const enumConverter = {}
function filterToWhere(filter, command) {
let where = {}
for (let field in filter) {
let {
type,
value
} = filter[field]
switch (type) {
case "search":
if (typeof value === 'string' && value.length) {
where[field] = new RegExp(value)
}
break;
case "select":
if (value.length) {
let selectValue = []
for (let s of value) {
selectValue.push(command.eq(s))
}
where[field] = command.or(selectValue)
}
break;
case "range":
if (value.length) {
let gt = value[0]
let lt = value[1]
where[field] = command.and([command.gte(gt), command.lte(lt)])
}
break;
case "date":
if (value.length) {
let [s, e] = value
let startDate = new Date(s)
let endDate = new Date(e)
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
case "timestamp":
if (value.length) {
let [startDate, endDate] = value
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
}
}
return where
}
export {
validator,
enumConverter,
filterToWhere
}

View File

@ -0,0 +1,558 @@
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const validator = {
"adMixture": {
"rules": [
{
"format": "string"
}
],
"title": "摩尔组成",
"label": "摩尔组成"
},
"adMixtureV": {
"rules": [
{
"format": "string"
}
],
"title": "体积组成",
"label": "体积组成"
},
"adMixtureD": {
"rules": [
{
"format": "string"
}
],
"title": "质量组成",
"label": "质量组成"
},
"dCbtj": {
"rules": [
{
"format": "string"
}
],
"title": "参比条件",
"label": "参比条件"
},
"dPb": {
"rules": [
{
"format": "string"
}
],
"title": "参比压力",
"label": "参比压力"
},
"dTb": {
"rules": [
{
"format": "string"
}
],
"title": "参比温度",
"label": "参比温度"
},
"dPf": {
"rules": [
{
"format": "string"
}
],
"title": "绝对压力",
"label": "绝对压力"
},
"dTf": {
"rules": [
{
"format": "string"
}
],
"title": "工况温度",
"label": "工况温度"
},
"dMrx": {
"rules": [
{
"format": "string"
}
],
"title": "分子量",
"label": "分子量"
},
"dZb": {
"rules": [
{
"format": "string"
}
],
"title": "标况压缩因子",
"label": "标况压缩因子"
},
"dZf": {
"rules": [
{
"format": "string"
}
],
"title": "工况压缩因子",
"label": "工况压缩因子"
},
"dFpv": {
"rules": [
{
"format": "string"
}
],
"title": "超压缩系数",
"label": "超压缩系数"
},
"dDb": {
"rules": [
{
"format": "string"
}
],
"title": "标况摩尔密度",
"label": "标况摩尔密度"
},
"dDf": {
"rules": [
{
"format": "string"
}
],
"title": "工况摩尔密度",
"label": "工况摩尔密度"
},
"dRhob": {
"rules": [
{
"format": "string"
}
],
"title": "标况质量密度",
"label": "标况质量密度"
},
"dRhof": {
"rules": [
{
"format": "string"
}
],
"title": "工况质量密度",
"label": "工况质量密度"
},
"dRD_Ideal": {
"rules": [
{
"format": "string"
}
],
"title": "理想气体的相对密度",
"label": "理想气体的相对密度"
},
"dRD_Real": {
"rules": [
{
"format": "string"
}
],
"title": "真实气体的相对密度",
"label": "真实气体的相对密度"
},
"dHo": {
"rules": [
{
"format": "string"
}
],
"title": "理想气体的比焓",
"label": "理想气体的比焓"
},
"dH": {
"rules": [
{
"format": "string"
}
],
"title": "真实气体的焓",
"label": "真实气体的焓"
},
"dS": {
"rules": [
{
"format": "string"
}
],
"title": "真实气体的熵",
"label": "真实气体的熵"
},
"dCpi": {
"rules": [
{
"format": "string"
}
],
"title": "理想气体定压热容",
"label": "理想气体定压热容"
},
"dCp": {
"rules": [
{
"format": "string"
}
],
"title": "定压热容",
"label": "定压热容"
},
"dCv": {
"rules": [
{
"format": "string"
}
],
"title": "定容积热容",
"label": "定容积热容"
},
"dk": {
"rules": [
{
"format": "string"
}
],
"title": "比热比",
"label": "比热比"
},
"dKappa": {
"rules": [
{
"format": "string"
}
],
"title": "等熵指数",
"label": "等熵指数"
},
"dSOS": {
"rules": [
{
"format": "string"
}
],
"title": "声速",
"label": "声速"
},
"dCstar": {
"rules": [
{
"format": "string"
}
],
"title": "临界流函数",
"label": "临界流函数"
},
"dHhvMol": {
"rules": [
{
"format": "string"
}
],
"title": "摩尔高位发热量",
"label": "摩尔高位发热量"
},
"dLhvMol": {
"rules": [
{
"format": "string"
}
],
"title": "摩尔低位发热量",
"label": "摩尔低位发热量"
},
"dHhvv": {
"rules": [
{
"format": "string"
}
],
"title": "体积高位发热量",
"label": "体积高位发热量"
},
"dLhvv": {
"rules": [
{
"format": "string"
}
],
"title": "体积低位发热量",
"label": "体积低位发热量"
},
"dHhvm": {
"rules": [
{
"format": "string"
}
],
"title": "质量高位发热量",
"label": "质量高位发热量"
},
"dLhvm": {
"rules": [
{
"format": "string"
}
],
"title": "质量地位发热量",
"label": "质量地位发热量"
},
"dZb11062": {
"rules": [
{
"format": "string"
}
],
"title": "标况压缩因子",
"label": "标况压缩因子"
},
"dRhob11062": {
"rules": [
{
"format": "string"
}
],
"title": "标况质量密度",
"label": "标况质量密度"
},
"dRhof11062": {
"rules": [
{
"format": "string"
}
],
"title": "工况质量密度",
"label": "工况质量密度"
},
"dRD_Ideal11062": {
"rules": [
{
"format": "string"
}
],
"title": "理想气体的相对密度",
"label": "理想气体的相对密度"
},
"dRD_Real11062": {
"rules": [
{
"format": "string"
}
],
"title": "真实气体的相对密度",
"label": "真实气体的相对密度"
},
"dWobbeIndex": {
"rules": [
{
"format": "string"
}
],
"title": "真实气体的沃泊指数",
"label": "真实气体的沃泊指数"
},
"Pc": {
"rules": [
{
"format": "string"
}
],
"title": "临界压力",
"label": "临界压力"
},
"TC": {
"rules": [
{
"format": "string"
}
],
"title": "临界温度",
"label": "临界温度"
},
"Bzsx": {
"rules": [
{
"format": "string"
}
],
"title": "爆炸上限",
"label": "爆炸上限"
},
"Bzxx": {
"rules": [
{
"format": "string"
}
],
"title": "爆炸下限",
"label": "爆炸下限"
},
"TotalC": {
"rules": [
{
"format": "string"
}
],
"title": "总炭含量",
"label": "总炭含量"
},
"C2": {
"rules": [
{
"format": "string"
}
],
"title": "C2组分含量",
"label": "C2组分含量"
},
"C2j": {
"rules": [
{
"format": "string"
}
],
"title": "C2以上组分含量",
"label": "C2以上组分含量"
},
"C3j": {
"rules": [
{
"format": "string"
}
],
"title": "C3以上组分含量",
"label": "C3以上组分含量"
},
"C4j": {
"rules": [
{
"format": "string"
}
],
"title": "C4以上组分含量",
"label": "C4以上组分含量"
},
"C5j": {
"rules": [
{
"format": "string"
}
],
"title": "C5以上组分含量",
"label": "C5以上组分含量"
},
"C6j": {
"rules": [
{
"format": "string"
}
],
"title": "C6以上组分含量",
"label": "C6以上组分含量"
},
"C3C4": {
"rules": [
{
"format": "string"
}
],
"title": "C3C4组分含量",
"label": "C3C4组分含量"
},
"createBy": {
"rules": [
{
"format": "string"
}
],
"title": "创建人",
"label": "创建人"
},
"updateBy": {
"rules": [
{
"format": "string"
}
],
"title": "更新人",
"label": "更新人"
},
"createTime": {
"rules": [
{
"format": "datetime"
}
],
"title": "创建时间",
"label": "创建时间"
},
"updateTime": {
"rules": [
{
"format": "datetime"
}
],
"title": "更新时间",
"label": "更新时间"
}
}
const enumConverter = {}
function filterToWhere(filter, command) {
let where = {}
for (let field in filter) {
let { type, value } = filter[field]
switch (type) {
case "search":
if (typeof value === 'string' && value.length) {
where[field] = new RegExp(value)
}
break;
case "select":
if (value.length) {
let selectValue = []
for (let s of value) {
selectValue.push(command.eq(s))
}
where[field] = command.or(selectValue)
}
break;
case "range":
if (value.length) {
let gt = value[0]
let lt = value[1]
where[field] = command.and([command.gte(gt), command.lte(lt)])
}
break;
case "date":
if (value.length) {
let [s, e] = value
let startDate = new Date(s)
let endDate = new Date(e)
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
case "timestamp":
if (value.length) {
let [startDate, endDate] = value
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
}
}
return where
}
export { validator, enumConverter, filterToWhere }

View File

@ -0,0 +1,72 @@
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const validator = {
"samplingLocation": {
"rules": [
{
"format": "string"
}
],
"title": "取样地点",
"label": "取样地点"
},
"departName": {
"rules": [
{
"format": "string"
}
],
"title": "单位名称",
"label": "单位名称"
}
}
const enumConverter = {}
function filterToWhere(filter, command) {
let where = {}
for (let field in filter) {
let { type, value } = filter[field]
switch (type) {
case "search":
if (typeof value === 'string' && value.length) {
where[field] = new RegExp(value)
}
break;
case "select":
if (value.length) {
let selectValue = []
for (let s of value) {
selectValue.push(command.eq(s))
}
where[field] = command.or(selectValue)
}
break;
case "range":
if (value.length) {
let gt = value[0]
let lt = value[1]
where[field] = command.and([command.gte(gt), command.lte(lt)])
}
break;
case "date":
if (value.length) {
let [s, e] = value
let startDate = new Date(s)
let endDate = new Date(e)
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
case "timestamp":
if (value.length) {
let [startDate, endDate] = value
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
}
}
return where
}
export { validator, enumConverter, filterToWhere }

View File

@ -0,0 +1,102 @@
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const validator = {
"parent_id": {
"rules": [
{
"format": "string"
}
]
},
"depart_name": {
"rules": [
{
"format": "string",
"required": true,
"errorMessage": '单位名称未输入'
}
],
"title": "部门名称",
"label": "部门名称"
},
"level": {
"rules": [
{
"format": "int"
}
]
},
"sort": {
"rules": [
{
"format": "int"
}
],
"title": "显示顺序",
"label": "显示顺序"
},
"manager_uid": {
"rules": [
{
"format": "string"
}
]
},
"status": {
"rules": [
{
"format": "int"
}
]
}
}
const enumConverter = {}
function filterToWhere(filter, command) {
let where = {}
for (let field in filter) {
let { type, value } = filter[field]
switch (type) {
case "search":
if (typeof value === 'string' && value.length) {
where[field] = new RegExp(value)
}
break;
case "select":
if (value.length) {
let selectValue = []
for (let s of value) {
selectValue.push(command.eq(s))
}
where[field] = command.or(selectValue)
}
break;
case "range":
if (value.length) {
let gt = value[0]
let lt = value[1]
where[field] = command.and([command.gte(gt), command.lte(lt)])
}
break;
case "date":
if (value.length) {
let [s, e] = value
let startDate = new Date(s)
let endDate = new Date(e)
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
case "timestamp":
if (value.length) {
let [startDate, endDate] = value
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
}
}
return where
}
export { validator, enumConverter, filterToWhere }

View File

@ -0,0 +1,131 @@
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const validator = {
"parent_id": {
"rules": [
{
"format": "string"
}
]
},
"name": {
"rules": [
{
"required": true
},
{
"format": "string"
}
],
"title": "类别名称",
"label": "类别名称"
},
"icon": {
"rules": [
{
"format": "string"
},
{
"pattern": "^(http://|https://|/|./|@/)\\S"
}
],
"title": "图标地址",
"label": "图标地址"
},
"sort": {
"rules": [
{
"format": "int"
}
],
"title": "排序",
"label": "排序"
},
"description": {
"rules": [
{
"format": "string"
}
],
"title": "类别描述",
"label": "类别描述"
},
"is_hot_show": {
"rules": [
{
"format": "bool"
}
],
"title": "加入热门显示",
"label": "加入热门显示"
},
"is_index_show": {
"rules": [
{
"format": "bool"
}
],
"title": "首页显示",
"label": "首页显示"
},
"create_date": {
"rules": [
{
"format": "timestamp"
}
],
"defaultValue": {
"$env": "now"
}
}
}
const enumConverter = {}
function filterToWhere(filter, command) {
let where = {}
for (let field in filter) {
let { type, value } = filter[field]
switch (type) {
case "search":
if (typeof value === 'string' && value.length) {
where[field] = new RegExp(value)
}
break;
case "select":
if (value.length) {
let selectValue = []
for (let s of value) {
selectValue.push(command.eq(s))
}
where[field] = command.or(selectValue)
}
break;
case "range":
if (value.length) {
let gt = value[0]
let lt = value[1]
where[field] = command.and([command.gte(gt), command.lte(lt)])
}
break;
case "date":
if (value.length) {
let [s, e] = value
let startDate = new Date(s)
let endDate = new Date(e)
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
case "timestamp":
if (value.length) {
let [startDate, endDate] = value
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
}
}
return where
}
export { validator, enumConverter, filterToWhere }

View File

@ -0,0 +1,257 @@
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const validator = {
"category_id": {
"rules": [
{
"format": "string"
}
]
},
"goods_sn": {
"rules": [
{
"required": true
},
{
"format": "string"
}
],
"title": "货号",
"label": "货号"
},
"name": {
"rules": [
{
"required": true
},
{
"format": "string"
}
],
"title": "名称",
"label": "名称"
},
"keywords": {
"rules": [
{
"format": "string"
}
],
"title": "关键字",
"label": "关键字"
},
"goods_desc": {
"rules": [
{
"format": "string"
}
],
"title": "详细描述",
"label": "详细描述"
},
"goods_thumb": {
"rules": [
{
"format": "string"
},
{
"pattern": "^(http://|https://|/|./|@/)\\S"
}
],
"title": "缩略图地址",
"label": "缩略图地址"
},
"goods_banner_imgs": {
"rules": [
{
"format": "array"
}
]
},
"remain_count": {
"rules": [
{
"required": true
},
{
"format": "int"
}
],
"title": "库存数量",
"label": "库存数量"
},
"month_sell_count": {
"rules": [
{
"required": true
},
{
"format": "int"
}
]
},
"total_sell_count": {
"rules": [
{
"required": true
},
{
"format": "int"
}
]
},
"comment_count": {
"rules": [
{
"required": true
},
{
"format": "int"
}
]
},
"is_real": {
"rules": [
{
"required": true
},
{
"format": "bool"
}
],
"title": "是否为实物",
"label": "是否为实物"
},
"is_on_sale": {
"rules": [
{
"required": true
},
{
"format": "bool"
}
],
"title": "是否上架",
"label": "是否上架"
},
"is_alone_sale": {
"rules": [
{
"required": true
},
{
"format": "bool"
}
]
},
"is_best": {
"rules": [
{
"required": true
},
{
"format": "bool"
}
]
},
"is_new": {
"rules": [
{
"required": true
},
{
"format": "bool"
}
],
"title": "是否新品",
"label": "是否新品"
},
"is_hot": {
"rules": [
{
"required": true
},
{
"format": "bool"
}
]
},
"add_date": {
"rules": [
{
"format": "timestamp"
}
],
"defaultValue": {
"$env": "now"
}
},
"last_modify_date": {
"rules": [
{
"format": "timestamp"
}
],
"defaultValue": {
"$env": "now"
}
},
"seller_note": {
"rules": [
{
"format": "string"
}
]
}
}
const enumConverter = {}
function filterToWhere(filter, command) {
let where = {}
for (let field in filter) {
let { type, value } = filter[field]
switch (type) {
case "search":
if (typeof value === 'string' && value.length) {
where[field] = new RegExp(value)
}
break;
case "select":
if (value.length) {
let selectValue = []
for (let s of value) {
selectValue.push(command.eq(s))
}
where[field] = command.or(selectValue)
}
break;
case "range":
if (value.length) {
let gt = value[0]
let lt = value[1]
where[field] = command.and([command.gte(gt), command.lte(lt)])
}
break;
case "date":
if (value.length) {
let [s, e] = value
let startDate = new Date(s)
let endDate = new Date(e)
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
case "timestamp":
if (value.length) {
let [startDate, endDate] = value
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
}
}
return where
}
export { validator, enumConverter, filterToWhere }

View File

@ -0,0 +1,129 @@
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const validator = {
"infoName": {
"rules": [
{
"required": true
},
{
"format": "string"
}
],
"title": "资料名称",
"label": "资料名称"
},
"infomation": {
"rules": [
{
"format": "string"
}
],
"title": "资料内容",
"label": "资料内容"
},
"infoSouce": {
"rules": [
{
"format": "string"
}
],
"title": "资料来源",
"label": "资料来源"
},
"infoType": {
"rules": [
{
"format": "string"
}
],
"title": "资料类型",
"label": "资料类型"
},
"createTime": {
"rules": [
{
"format": "datetime"
}
],
"title": "创建时间",
"label": "创建时间"
},
"createBy": {
"rules": [
{
"format": "string"
}
],
"title": "创建人",
"label": "创建人"
},
"updateTime": {
"rules": [
{
"format": "datetime"
}
],
"title": "更新时间",
"label": "更新时间"
},
"updateBy": {
"rules": [
{
"format": "string"
}
],
"title": "更新人",
"label": "更新人"
}
}
const enumConverter = {}
function filterToWhere(filter, command) {
let where = {}
for (let field in filter) {
let { type, value } = filter[field]
switch (type) {
case "search":
if (typeof value === 'string' && value.length) {
where[field] = new RegExp(value)
}
break;
case "select":
if (value.length) {
let selectValue = []
for (let s of value) {
selectValue.push(command.eq(s))
}
where[field] = command.or(selectValue)
}
break;
case "range":
if (value.length) {
let gt = value[0]
let lt = value[1]
where[field] = command.and([command.gte(gt), command.lte(lt)])
}
break;
case "date":
if (value.length) {
let [s, e] = value
let startDate = new Date(s)
let endDate = new Date(e)
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
case "timestamp":
if (value.length) {
let [startDate, endDate] = value
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
}
}
return where
}
export { validator, enumConverter, filterToWhere }

View File

@ -0,0 +1,130 @@
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const validator = {
"bannerfile": {
"rules": [
{
"required": true
},
{
"format": "file"
}
],
"title": "图片文件",
"label": "图片文件"
},
"open_url": {
"rules": [
{
"format": "string"
},
{
"format": "url"
},
{
"pattern": "^(http://|https://|/|./|@/)\\S"
}
],
"title": "点击目标地址",
"label": "点击目标地址"
},
"title": {
"rules": [
{
"format": "string"
},
{
"maxLength": 20
}
],
"title": "标题",
"label": "标题"
},
"sort": {
"rules": [
{
"format": "int"
}
],
"title": "排序",
"label": "排序"
},
"category_id": {
"rules": [
{
"format": "string"
}
],
"title": "分类id",
"label": "分类id"
},
"status": {
"rules": [
{
"format": "bool"
}
],
"title": "生效状态",
"defaultValue": true,
"label": "生效状态"
},
"description": {
"rules": [
{
"format": "string"
}
],
"title": "备注",
"label": "备注"
}
}
const enumConverter = {}
function filterToWhere(filter, command) {
let where = {}
for (let field in filter) {
let { type, value } = filter[field]
switch (type) {
case "search":
if (typeof value === 'string' && value.length) {
where[field] = new RegExp(value)
}
break;
case "select":
if (value.length) {
let selectValue = []
for (let s of value) {
selectValue.push(command.eq(s))
}
where[field] = command.or(selectValue)
}
break;
case "range":
if (value.length) {
let gt = value[0]
let lt = value[1]
where[field] = command.and([command.gte(gt), command.lte(lt)])
}
break;
case "date":
if (value.length) {
let [s, e] = value
let startDate = new Date(s)
let endDate = new Date(e)
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
case "timestamp":
if (value.length) {
let [startDate, endDate] = value
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
}
}
return where
}
export { validator, enumConverter, filterToWhere }

View File

@ -0,0 +1,354 @@
// 表单校验规则由 schema2code 生成,不建议直接修改校验规则,而建议通过 schema2code 生成, 详情: https://uniapp.dcloud.net.cn/uniCloud/schema
const validator = {
"username": {
"rules": [
{
"format": "string"
}
],
"title": "用户名",
"label": "用户名"
},
"password_secret_version": {
"rules": [
{
"format": "int"
}
],
"title": "passwordSecret",
"label": "passwordSecret"
},
"nickname": {
"rules": [
{
"format": "string"
}
],
"title": "昵称",
"label": "昵称"
},
"gender": {
"rules": [
{
"format": "int"
},
{
"range": [
{
"text": "未知",
"value": 0
},
{
"text": "男",
"value": 1
},
{
"text": "女",
"value": 2
}
]
}
],
"title": "性别",
"defaultValue": 0,
"label": "性别"
},
"status": {
"rules": [
{
"format": "int"
},
{
"range": [
{
"text": "正常",
"value": 0
},
{
"text": "禁用",
"value": 1
},
{
"text": "审核中",
"value": 2
},
{
"text": "审核拒绝",
"value": 3
}
]
}
],
"title": "用户状态",
"defaultValue": 0,
"label": "用户状态"
},
"mobile": {
"rules": [
{
"format": "string"
},
{
"pattern": "^\\+?[0-9-]{3,20}$"
}
],
"title": "手机号码",
"label": "手机号码"
},
"mobile_confirmed": {
"rules": [
{
"format": "int"
},
{
"range": [
{
"text": "未验证",
"value": 0
},
{
"text": "已验证",
"value": 1
}
]
}
],
"title": "手机号验证状态",
"defaultValue": 0,
"label": "手机号验证状态"
},
"email": {
"rules": [
{
"format": "string"
},
{
"format": "email"
}
],
"title": "邮箱",
"label": "邮箱"
},
"email_confirmed": {
"rules": [
{
"format": "int"
},
{
"range": [
{
"text": "未验证",
"value": 0
},
{
"text": "已验证",
"value": 1
}
]
}
],
"title": "邮箱验证状态",
"defaultValue": 0,
"label": "邮箱验证状态"
},
"avatar": {
"rules": [
{
"format": "string"
}
],
"title": "头像地址",
"label": "头像地址"
},
"avatar_file": {
"rules": [
{
"format": "file"
}
],
"title": "头像文件",
"label": "头像文件"
},
"d_ids": {
"rules": [
{
"format": "array"
}
],
"title": "部门",
"label": "部门"
},
"e_ids": {
"rules": [
{
"format": "array"
}
],
"title": "企业",
"label": "企业"
},
"wx_unionid": {
"rules": [
{
"format": "string"
}
]
},
"ali_openid": {
"rules": [
{
"format": "string"
}
]
},
"apple_openid": {
"rules": [
{
"format": "string"
}
]
},
"dcloud_appid": {
"rules": [
{
"format": "array"
}
]
},
"comment": {
"rules": [
{
"format": "string"
}
],
"title": "备注",
"label": "备注"
},
"score": {
"rules": [
{
"format": "int"
}
]
},
"last_login_date": {
"rules": [
{
"format": "timestamp"
}
]
},
"last_login_ip": {
"rules": [
{
"format": "string"
}
]
},
"token": {
"rules": [
{
"format": "array"
}
]
},
"inviter_uid": {
"rules": [
{
"format": "array"
}
]
},
"invite_time": {
"rules": [
{
"format": "timestamp"
}
]
},
"my_invite_code": {
"rules": [
{
"format": "string"
}
]
},
"identities": {
"rules": [
{
"format": "array"
}
]
}
}
const enumConverter = {
"gender_valuetotext": {
"0": "未知",
"1": "男",
"2": "女"
},
"status_valuetotext": {
"0": "正常",
"1": "禁用",
"2": "审核中",
"3": "审核拒绝"
},
"mobile_confirmed_valuetotext": {
"0": "未验证",
"1": "已验证"
},
"email_confirmed_valuetotext": {
"0": "未验证",
"1": "已验证"
}
}
function filterToWhere(filter, command) {
let where = {}
for (let field in filter) {
let { type, value } = filter[field]
switch (type) {
case "search":
if (typeof value === 'string' && value.length) {
where[field] = new RegExp(value)
}
break;
case "select":
if (value.length) {
let selectValue = []
for (let s of value) {
selectValue.push(command.eq(s))
}
where[field] = command.or(selectValue)
}
break;
case "range":
if (value.length) {
let gt = value[0]
let lt = value[1]
where[field] = command.and([command.gte(gt), command.lte(lt)])
}
break;
case "date":
if (value.length) {
let [s, e] = value
let startDate = new Date(s)
let endDate = new Date(e)
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
case "timestamp":
if (value.length) {
let [startDate, endDate] = value
where[field] = command.and([command.gte(startDate), command.lte(endDate)])
}
break;
}
}
return where
}
export { validator, enumConverter, filterToWhere }

191
lang/en.js Normal file
View File

@ -0,0 +1,191 @@
export default {
tabbar:'List,Grid,contacts,Mine',
agreementsTitle:'User service agreement,Privacy policy',
common: {
wechatFriends: "friends",
wechatBbs: "bbs",
weibo: "weibo",
more: "more",
agree:"agree",
copy: "copy",
wechatApplet: "applet",
cancelShare: "cancel sharing",
updateSucceeded: "update succeeded",
phonePlaceholder: "Please enter your mobile phone number",
verifyCodePlaceholder: "Please enter the verification code",
newPasswordPlaceholder: "Please enter a new password",
confirmNewPasswordPlaceholder: "Please confirm the new password",
confirmPassword: "Please confirm the password",
verifyCodeSend: "Verification code has been sent to via SMS",
passwordDigits: "The password is 6 - 20 digits",
getVerifyCode: "Get Code",
noAgree: "You have not agreed to the privacy policy agreement",
gotIt: "got it",
login: "sign in",
error: "error",
complete: "complete",
submit: "Submit",
formatErr: "Incorrect mobile phone number format",
sixDigitCode: "Please enter a 6-digit verification code",
resetNavTitle:"Reset password"
},
list: {
inputPlaceholder: "Please enter the search content",
},
search: {
cancelText: "cancel",
searchHistory: "search history",
searchDiscovery: "search discovery",
deleteAll: "delete all",
delete: "delete",
deleteTip: "Are you sure to clear the search history ?",
complete: "complete",
searchHiddenTip: "Current search found hidden",
},
grid: {
grid: "Grid Assembly",
visibleToAll: "Visible to all",
invisibleToTourists: "Invisible to tourists",
adminVisible: "Admin visible",
clickTip: "Click the",
clickTipGrid: "grid",
},
mine: {
showText: "Text",
signIn: "Check In Reward",
signInByAd:"Check In Reward By AD",
toEvaluate: "To Evaluate",
readArticles: "Read Articles",
myScore: "My Score",
invite: "Invite Friends",
feedback: "Problems And Feedback",
settings: "Settings",
about: "About",
checkUpdate: "Check for Updates",
clicked: "You Clicked",
checkScore: "Please check your points after logging in",
currentScore: "The current score is ",
noScore: "There are currently no points",
notLogged: "not logged in",
},
userinfo: {
navigationBarTitle:"My Profile",
ProfilePhoto: "Profile Photo",
nickname: "Nickname",
notSet: "not set",
phoneNumber: "Phone Number",
notSpecified: "Not Specified",
setNickname: "Set Nickname ",
setNicknamePlaceholder: "Please enter a nickname to set",
bindPhoneNumber: "One click binding of local number",
bindOtherLogin: "Other number binding",
noChange: "No change",
uploading: "uploading",
requestFail: "Request for service failed",
setting: "setting",
deleteSucceeded: "Delete succeeded",
setSucceeded: "Set successfully",
},
smsCode: {
resendVerifyCode: "resend",
phoneErrTip: "Mobile phone number format error",
sendSuccessTip: "SMS verification code sent successfully",
},
loadMore: {
noData: "No Data",
noNetwork: "Network error",
toSet: "Go to settings",
error: "error",
},
uniFeedback: {
navigationBarTitle: "Problems and feedback",
msgTitle: "Message content",
imgTitle: "Picture list",
contacts: "contacts",
phone: "contact number",
submit: "submit",
},
settings: {
navigationBarTitle:"Settings",
userInfo: "Personal Data",
changePassword: "change password",
clearTmp: "clean cache",
pushServer: "push function",
fingerPrint: "fingerprint unlock",
facial: "face unlock",
deactivate: "Deactivate",
logOut: "Logout",
login: "Login",
changeLanguage: "Language",
please: "please",
successText: "success",
failTip: "Authentication failed. Please try again",
authFailed: "authentication failed",
deviceNoOpen: "The device is not turned on",
fail: "fail",
tips: "tips",
exitLogin: "Do you want to log out",
cancelText: "cancel",
confirmText: "confirm",
clearing: "clearing",
clearedSuccessed: "Cleared successfully",
},
deactivate: {
cancelText: "cancel",
nextStep: "next step",
navigationBarTitle:"Logout prompt"
},
about: {
sacnQR: "Scan the QR Code and your friends can also download it",
client: "applCantion",
and: "And",
about: "About",
},
invite: {
download: "Download",
},
login: {
phoneLogin: "After logging in, you can show yourself",
phoneLoginTip: "Unregistered mobile phone numbers will be automatically registered after verification",
getVerifyCode: "Get Code",
},
uniQuickLogin: {
accountLogin: "Account",
SMSLogin: "SMS",
wechatLogin: "wechat",
appleLogin: "Apple",
oneClickLogin: "One click login",
QQLogin: "QQ",
xiaomiLogin: "Xiaomi",
getProviderFail: "Failed to get service provider",
loginErr: "Login service initialization error",
chooseOtherLogin: "Click the third-party login",
},
pwdLogin: {
pwdLogin: "User name password login",
placeholder: "Please enter mobile number / user name",
passwordPlaceholder: "Please input a password",
verifyCodePlaceholder: "Please enter the verification code",
login: "sign in",
forgetPassword: "Forget password",
register: "Registered account",
},
register: {
navigationBarTitle:"register",
usernamePlaceholder: "Please enter user name",
nicknamePlaceholder: "Please enter user nickname",
passwordDigitsPlaceholder: "Please enter a 6-20 digit password",
passwordAgain: "Enter the password again",
registerAndLogin: "Register and log in",
},
listDetail: {
follow: "Click follow",
newsErr: "Error, news ID is empty",
},
newsLog:{
navigationBarTitle:"Reading Log"
},
bindMobile:{
navigationBarTitle:"Bind Mobile"
}
}

96
lang/i18n.js Normal file
View File

@ -0,0 +1,96 @@
import langEn from './en'
import zhHans from './zh-Hans'
import uniStarterConfig from '../uni-starter.config.js'
const {i18n:{enable:i18nEnable} }= uniStarterConfig
const messages = {
'en': langEn,
'zh-Hans': zhHans
}
let currentLang
if(i18nEnable){
currentLang = uni.getStorageSync('CURRENT_LANG')
}else{
currentLang = "zh-Hans"
}
// console.log(uni.getStorageSync('CURRENT_LANG'),currentLang);
if (!currentLang) {
if (uni.getLocale) {
console.log('获取应用语言:', uni.getLocale());
let language = 'en'
if (uni.getLocale() != 'en') {
language = 'zh-Hans'
}
uni.setStorageSync('CURRENT_LANG', language)
currentLang = language
} else {
uni.getSystemInfo({
success: function(res) {
console.log('获取设备信息:', res);
let language = 'zh-Hans'
if (res.language == 'en') {
language = 'en'
}
uni.setStorageSync('CURRENT_LANG', language)
currentLang = language
},
fail: (err) => {
console.error(err)
}
})
}
}
let i18nConfig = {
locale: currentLang, // set locale
messages // set locale messages
}
// #ifdef VUE2
import Vue from 'vue'
import VueI18n from 'vue-i18n'
Vue.use(VueI18n)
const i18n = new VueI18n(i18nConfig)
// #endif
// #ifdef VUE3
import {
createI18n
} from 'vue-i18n'
const i18n = createI18n(i18nConfig)
// #endif
export default i18n
if(i18nEnable){
console.log(`
你已开启多语言国际化将自动根据语言获取lang/en.jslang/en.js文件中配置的tabbar的值
覆盖你在pages.json中的tabbar的值
如果你不需要多语言国际化请打开配置文件uni-starter.config.js找到 -> i18n -> enable把值设置为false
`);
let initLanguageAfter = () => {
function $i18n(e){
// #ifdef VUE3
return i18n.global.messages[i18n.global.locale][e]
// #endif
return i18n.messages[i18n.locale][e]
}
setTimeout(function(){
//底部tabbar更新
$i18n('tabbar').split(',').forEach((text, index) => {
// console.log(text);
uni.setTabBarItem({
index,
text,
complete: e => {
// console.log("e: " + JSON.stringify(e));
}
})
})
},1)
}
initLanguageAfter()
uni.$on('changeLanguage', e => {
console.log('changeLanguage', e);
initLanguageAfter(e)
})
}

268
lang/zh-Hans.js Normal file
View File

@ -0,0 +1,268 @@
export default {
tabbar: '列表,宫格,通讯录,我的',
agreementsTitle: '用户服务协议,隐私政策',
common: {
wechatFriends: "微信好友",
wechatBbs: "微信朋友圈",
weibo: "微博",
more: "更多",
agree: "同意",
copy: "复制",
wechatApplet: "微信小程序",
cancelShare: "取消分享",
updateSucceeded: "更新成功",
phonePlaceholder: "请输入手机号",
verifyCodePlaceholder: "请输入验证码",
newPasswordPlaceholder: "请输入新密码",
confirmNewPasswordPlaceholder: "请确认新密码",
confirmPassword: "请确认密码",
verifyCodeSend: "验证码已通过短信发送至",
passwordDigits: "密码为6 - 20位",
getVerifyCode: "获取验证码",
noAgree: "你未同意隐私政策协议",
gotIt: "知道了",
login: "登录",
error: "错误",
complete: "完成",
submit: "提交",
formatErr: "手机号码格式不正确",
sixDigitCode: "请输入6位验证码",
resetNavTitle: "重置密码"
},
list: {
inputPlaceholder: "请输入搜索内容",
},
search: {
cancelText: '取消',
searchHistory: "搜索历史",
searchDiscovery: "搜索发现",
deleteAll: "全部删除",
delete: "删除",
deleteTip: "确认清空搜索历史吗?",
complete: "完成",
searchHiddenTip: "当前搜索发现已隐藏",
},
grid: {
grid: "宫格组件",
visibleToAll: "所有人可见",
invisibleToTourists: "游客不可见",
adminVisible: "管理员可见",
clickTip: "点击第",
clickTipGrid: "个宫格",
},
llJs: {
grid: "流量计算",
cysllJs: {
title: "差压式流量计",
url: "/pagesPackage/ngtools_Flow/cysllJs",
icon:'kb.png'
},
sdsllJs: {
title: "速度式流量计",
url: "/pagesPackage/ngtools_Flow/sdsllJs",
icon:'sd.png'
},
ljlllJs: {
title: "临界流流量计",
url: "/pagesPackage/ngtools_Flow/ljlllJs",
icon:'pz.png'
}
},
wxcsJs: {
grid: "参数计算",
ysyzJs: {
title: "压缩因子",
url: "/pagesPackage/ngtools_Par/zJs",
icon:'z.png'
},
rzJs: {
title: "密度热值",
url: "/pagesPackage/ngtools_Par/mdRzJs",
icon:'md.png'
},
qtJs: {
title: "其他参数",
url: "/pagesPackage/ngtools_Par/qtJs",
icon:'qt.png'
}
},
CNGJs: {
grid: "CNG、LNG计算",
LNGQhJs: {
title: "LNG气化量",
url: "/pagesPackage/ngtools_CNG/LNGQhJs",
icon:'qh.png'
},
srjJs: {
title: "管束车容积",
url: "/pagesPackage/ngtools_CNG/srjJs",
icon:'v.png'
},
zxcJs: {
title: "CNG装卸量",
url: "/pagesPackage/ngtools_CNG/zxcJs",
icon:'zx.png'
},
},
QtJs: {
grid: "其他计算",
ZBGJs: {
title: "压缩因子表格",
url: "/pagesPackage/ngtools_Par/ZBgJs",
icon:'zt'
},
srjBGJs: {
title: "水容积表格",
url: "/pagesPackage/ngtools_CNG/srjBgJs",
icon:'vt'
}
// ,
// SqgyJs: {
// title: "输气工艺",
// url: "/pagesPackage/ngtools_Flow/SqgyJs",
// icon:''
// }
},
mine: {
showText: "文字",
dict:"数据字典",
depart:"组织机构",
myPay:"打赏/购买",
signIn: "普通签到",
signInByAd: "看广告签到",
toEvaluate: "去评分",
readArticles: "阅读过的文章",
myScore: "我的积分",
invite: "分销推荐",
feedback: "问题与反馈",
settings: "设置",
checkUpdate: "检查更新",
about: "关于",
clicked: "你点击了",
checkScore: "请登录后查看积分",
currentScore: "当前积分为",
noScore: "当前无积分",
notLogged: "未登录",
},
userinfo: {
navigationBarTitle: "个人资料",
ProfilePhoto: "头像",
nickname: "昵称",
notSet: "未设置",
phoneNumber: "手机号",
notSpecified: "未绑定",
setNickname: "设置昵称",
setNicknamePlaceholder: "请输入要设置的昵称",
bindPhoneNumber: "本机号码一键绑定",
bindOtherLogin: "其他号码绑定",
noChange: "没有变化",
uploading: "正在上传",
requestFail: "请求服务失败",
setting: "设置中",
deleteSucceeded: "删除成功",
setSucceeded: "设置成功",
},
smsCode: {
resendVerifyCode: "重新发送",
phoneErrTip: "手机号格式错误",
sendSuccessTip: "短信验证码发送成功",
},
loadMore: {
noData: "暂无数据",
noNetwork: "网络异常",
toSet: "前往设置",
error: "错误",
},
uniFeedback: {
navigationBarTitle: "问题与反馈",
msgTitle: "留言内容",
imgTitle: "图片列表",
contacts: "联系人",
phone: "联系电话",
submit: "提交",
},
settings: {
navigationBarTitle: "设置",
userInfo: "账号资料",
changePassword: "修改密码",
clearTmp: "清理缓存",
pushServer: "推送功能",
fingerPrint: "指纹解锁",
facial: "人脸解锁",
deactivate: "注销账号",
logOut: "退出登录",
login: "登录",
failTip: "认证失败请重试",
authFailed: "认证失败",
changeLanguage: "切换语言",
please: "请用",
successText: "成功",
deviceNoOpen: "设备未开启",
fail: "失败",
tips: "提示",
exitLogin: "是否退出登录?",
clearing: "清除中",
clearedSuccessed: "清除成功",
confirmText: "确定",
cancelText: '取消',
},
deactivate: {
cancelText: '取消',
nextStep: "下一步",
navigationBarTitle: "注销提示"
},
about: {
sacnQR: "扫描二维码,您的朋友也可以下载",
client: "客户端",
and: "和",
about: "关于",
},
invite: {
download: "下载",
},
login: {
phoneLogin: "登录后即可展示自己",
phoneLoginTip: "未注册的手机号验证通过后将自动注册",
getVerifyCode: "获取验证码",
},
uniQuickLogin: {
accountLogin: "账号登录",
SMSLogin: "短信验证码",
wechatLogin: "微信登录",
appleLogin: "苹果登录",
oneClickLogin: "一键登录",
QQLogin: "QQ登录",
xiaomiLogin: "小米登录",
getProviderFail: "获取服务供应商失败",
loginErr: "登录服务初始化错误",
chooseOtherLogin: "点击了第三方登录",
},
pwdLogin: {
pwdLogin: "用户名密码登录",
placeholder: "请输入手机号/用户名",
passwordPlaceholder: "请输入密码",
verifyCodePlaceholder: "请输入验证码",
login: "登录",
forgetPassword: "忘记密码",
register: "注册账号",
},
register: {
navigationBarTitle: "注册",
usernamePlaceholder: "请输入用户名",
nicknamePlaceholder: "请输入用户昵称",
registerAndLogin: "注册并登录",
passwordDigitsPlaceholder: "请输入6-20位密码",
passwordAgain: "再次输入密码",
},
listDetail: {
follow: "点击关注",
newsErr: "出错了新闻ID为空",
},
newsLog: {
navigationBarTitle: "阅读记录"
},
bindMobile: {
navigationBarTitle: "绑定手机号码"
}
}

32
main.js Normal file
View File

@ -0,0 +1,32 @@
import App from './App'
import i18n from './lang/i18n'
Vue.prototype.staticDir = 'https://ngtools.cn:3000/pic/static/';
Vue.prototype.getStaticFilePath = function(url) {
return Vue.prototype.staticDir + url;
}
// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
i18n,
...App
})
app.$mount()
// #endif
// #ifdef VUE3
import {
createSSRApp
} from 'vue'
export function createApp() {
const app = createSSRApp(App)
app.use(i18n)
return {
app
}
}
// #endif

180
manifest.json Normal file
View File

@ -0,0 +1,180 @@
{
"name" : "NGTools",
"appid" : "__UNI__ED84AD5",
"description" : "天然气计算工具",
"versionName" : "1.0.0",
"versionCode" : "100",
"transformPx" : false,
"app-plus" : {
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"delay" : 0
},
"modules" : {
"OAuth" : {},
"Push" : {},
"Payment" : {}
},
"distribute" : {
"android" : {
"permissions" : [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
"ios" : {
"dSYMs" : false
},
"sdkConfigs" : {
"push" : {
"unipush" : {
"version" : "2",
"offline" : false
}
},
"oauth" : {
"weixin" : {
"appid" : "wx9f9b7d747d261686",
"UniversalLinks" : ""
}
},
"ad" : {
"hw" : {},
"360" : {}
},
"payment" : {
"alipay" : {
"__platform__" : [ "android" ]
},
"weixin" : {
"__platform__" : [ "android" ],
"appid" : "wx9f9b7d747d261686",
"UniversalLinks" : ""
}
}
},
"icons" : {
"android" : {
"hdpi" : "unpackage/res/icons/72x72.png",
"xhdpi" : "unpackage/res/icons/96x96.png",
"xxhdpi" : "unpackage/res/icons/144x144.png",
"xxxhdpi" : "unpackage/res/icons/192x192.png"
},
"ios" : {
"appstore" : "unpackage/res/icons/1024x1024.png",
"ipad" : {
"app" : "unpackage/res/icons/76x76.png",
"app@2x" : "unpackage/res/icons/152x152.png",
"notification" : "unpackage/res/icons/20x20.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"proapp@2x" : "unpackage/res/icons/167x167.png",
"settings" : "unpackage/res/icons/29x29.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"spotlight" : "unpackage/res/icons/40x40.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png"
},
"iphone" : {
"app@2x" : "unpackage/res/icons/120x120.png",
"app@3x" : "unpackage/res/icons/180x180.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"notification@3x" : "unpackage/res/icons/60x60.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"settings@3x" : "unpackage/res/icons/87x87.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png",
"spotlight@3x" : "unpackage/res/icons/120x120.png"
}
}
}
},
"uniStatistics" : {
"enable" : true
},
"optimization" : {
"subPackages" : true
}
},
"quickapp" : {},
"mp-weixin" : {
"appid" : "wx9f9b7d747d261686",
"lazyCodeLoading" : "requiredComponents",
"setting" : {
"urlCheck" : false,
"minified" : true
},
"usingComponents" : true,
"optimization" : {
"subPackages" : true
},
"permission" : {},
"unipush" : {
"enable" : true
},
"secureNetwork" : {
"enable" : true
},
"uniStatistics" : {
"enable" : true
}
},
"mp-alipay" : {
"usingComponents" : true
},
"mp-baidu" : {
"usingComponents" : true
},
"mp-toutiao" : {
"usingComponents" : true
},
"uniStatistics" : {
"enable" : false,
"version" : "2"
},
"vueVersion" : "2",
"locale" : "zh-Hans",
"h5" : {
"devServer" : {
"port" : 80,
"disableHostCheck" : true,
"proxy" : {
"/api" : {
"target" : "https://ngtools.cn:8443",
"changeOrigin" : true,
"secure" : true,
"pathRewrite" : {
"^/api" : ""
}
}
}
},
"router" : {
"base" : "ngtools"
},
"uniStatistics" : {
"enable" : true
}
}
}
//
//host
//
//
// https

90
package.json Normal file
View File

@ -0,0 +1,90 @@
{
"id": "NGTools",
"displayName": "NGTools",
"version": "2.1.8",
"description": "天然气计算工具",
"keywords": [
"login",
"登录",
"搜索",
"uni-id实例",
"留言板"
],
"type": "module",
"repository": "https://gitcode.net/dcloud/uni-starter",
"engines": {
"HBuilderX": "^3.2.6"
},
"dcloudext": {
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": "",
"type": "unicloud-template-project"
},
"uni_modules": {
"dependencies": [
"uni-id-pages"
],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"App": {
"app-vue": "y",
"app-nvue": "u"
},
"H5-mobile": {
"Safari": "u",
"Android Browser": "u",
"微信浏览器(Android)": "u",
"QQ浏览器(Android)": "u"
},
"H5-pc": {
"Chrome": "y",
"IE": "n",
"Edge": "u",
"Firefox": "u",
"Safari": "u"
},
"小程序": {
"微信": "y",
"阿里": "u",
"百度": "u",
"字节跳动": "u",
"QQ": "u",
"京东": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
},
"Vue": {
"vue2": "y",
"vue3": "y"
}
}
}
},
"dependencies": {
"browserslist": "^4.23.0",
"caniuse-lite": "^1.0.30001627",
"qrcodejs2": "^0.0.2"
}
}

666
pages.json Normal file
View File

@ -0,0 +1,666 @@
{
"pages": [{
"path": "pages/grid/grid",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "pages/list/list",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "pages/list/detail",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "pages/ucenter",
"style": {
"navigationStyle": "custom"
}
}
// #ifdef APP-PLUS
, {
"path": "uni_modules/uni-upgrade-center-app/pages/upgrade-popup",
"style": {
"disableScroll": true,
"app-plus": {
"backgroundColorTop": "transparent",
"background": "transparent",
"titleNView": false,
"scrollIndicator": false,
"popGesture": "none",
"animationType": "fade-in",
"animationDuration": 200
}
}
}
// #endif
],
"subPackages": [{
"root": "pagesPackage/components",
"pages": [{
"path": "popup",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false,
"navigationStyle": "custom",
"app-plus": {
"animationType": "fade-in", // fade-in
"background": "transparent", //
"backgroundColor": "transparent", //
"webviewBGTransparent": true,
"mask": "none",
"popGesture": "none", // IOS
"bounce": "none" //
}
}
}]
},
{
"root": "pagesPackage/opendb-banner",
"pages": [{
"path": "add",
"style": {
"navigationBarTitleText": "新增"
}
},
{
"path": "edit",
"style": {
"navigationBarTitleText": "编辑"
}
},
{
"path": "list",
"style": {
"navigationBarTitleText": "列表"
}
},
{
"path": "detail",
"style": {
"navigationBarTitleText": "详情"
}
}
]
},
{
"root": "pagesPackage/uni-agree",
"pages": [{
"path": "uni-agree",
"style": {
"navigationStyle": "custom",
"app-plus": {
"popGesture": "none"
}
}
}]
},
{
"root": "pagesPackage/ucenter",
"pages": [{
"path": "invite/invite",
"style": {
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "settings/settings",
"style": {
"navigationBarTitleText": "设置"
}
},
{
"path": "read-news-log/read-news-log",
"style": {
"navigationBarTitleText": "阅读记录",
"enablePullDownRefresh": true
}
},
{
"path": "pay/index",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "about/about",
"style": {
"navigationBarTitleText": "关于",
"app-plus": {
"titleNView": {
"buttons": [{
"type": "share"
}]
}
}
}
}
]
},
{
"root": "uni_modules/uni-feedback",
"pages": [{
"path": "pages/opendb-feedback/opendb-feedback",
"style": {
"navigationBarTitleText": "意见反馈",
"enablePullDownRefresh": false
}
}]
}, {
"root": "uni_modules/uni-id-pages/pages",
"pages": [{
"path": "userinfo/userinfo",
"style": {
"navigationBarTitleText": "个人资料"
}
},
{
"path": "userinfo/realname-verify/realname-verify",
"style": {
"enablePullDownRefresh": false,
"navigationBarTitleText": "实名认证"
}
},
{
"path": "login/login-withoutpwd"
},
{
"path": "login/login-withpwd"
},
{
"path": "userinfo/deactivate/deactivate",
"style": {
"navigationBarTitleText": "注销账号"
}
},
{
"path": "userinfo/bind-mobile/bind-mobile",
"style": {
"navigationBarTitleText": "绑定手机号码"
}
},
{
"path": "login/login-smscode",
"style": {
"navigationBarTitleText": "手机验证码登录"
}
},
{
"path": "register/register",
"style": {
"navigationBarTitleText": "注册"
}
},
{
"path": "retrieve/retrieve",
"style": {
"navigationBarTitleText": "重置密码"
}
}, {
"path": "common/webview/webview",
"style": {
"enablePullDownRefresh": false,
"navigationBarTitleText": ""
}
}, {
"path": "userinfo/change_pwd/change_pwd",
"style": {
"enablePullDownRefresh": false,
"navigationBarTitleText": "修改密码"
}
}, {
"path": "register/register-by-email",
"style": {
"navigationBarTitleText": "邮箱验证码注册"
}
}, {
"path": "retrieve/retrieve-by-email",
"style": {
"navigationBarTitleText": "通过邮箱重置密码"
}
},
{
"path": "userinfo/set-pwd/set-pwd",
"style": {
"enablePullDownRefresh": false,
"navigationBarTitleText": "设置密码"
}
}
// #ifdef H5
,
{
"path": "userinfo/cropImage/cropImage"
},
{
"path": "register/register-admin",
"style": {
"enablePullDownRefresh": false,
"navigationBarTitleText": "注册管理员账号"
}
}
// #endif
]
}, {
"root": "pagesPackage/ngtools_Flow",
"pages": [{
"path": "cysllJs",
"style": {
"navigationBarTitleText": "差压式流量计算",
"navigationStyle": "custom"
}
}, {
"path": "sdsllJs",
"style": {
"navigationBarTitleText": "速度式流量计算",
"navigationStyle": "custom"
}
},
{
"path": "ljlllJs",
"style": {
"navigationBarTitleText": "临界流流量计算",
"navigationStyle": "custom"
}
},
{
"path": "SqgyJs",
"style": {
"navigationBarTitleText": "输气工艺",
"navigationStyle": "custom"
}
}
]
}, {
"root": "pagesPackage/ngtools_Par",
"pages": [{
"path": "zJs",
"style": {
"navigationBarTitleText": "压缩因子计算GB/T 17747",
"navigationStyle": "custom"
}
},
{
"path": "mdRzJs",
"style": {
"navigationBarTitleText": "密度热值计算GB/T 11062",
"navigationStyle": "custom"
}
},
{
"path": "qtJs",
"style": {
"navigationBarTitleText": "其他物性参数计算",
"navigationStyle": "custom"
}
},
{
"path": "ZBgJs",
"style": {
"navigationBarTitleText": "压缩因子表格",
"navigationStyle": "custom"
}
}
]
}, {
"root": "pagesPackage/ngtools_CNG",
"pages": [{
"path": "LNGQhJs",
"style": {
"navigationBarTitleText": "LNG气化计算",
"navigationStyle": "custom"
}
},
{
"path": "srjJs",
"style": {
"navigationBarTitleText": "罐车水容积计算",
"navigationStyle": "custom"
}
},
{
"path": "zxcJs",
"style": {
"navigationBarTitleText": "装卸量计算",
"navigationStyle": "custom"
}
},
{
"path": "srjBgJs",
"style": {
"navigationBarTitleText": "水容积表格",
"navigationStyle": "custom"
}
}
]
}, {
"root": "pagesPackage/ngTools_depart",
"pages": [{
"path": "add",
"style": {
"navigationStyle": "custom"
}
}, {
"path": "edit",
"style": {
"navigationStyle": "custom"
}
}, {
"path": "list",
"style": {
"navigationStyle": "custom"
}
}, {
"path": "detail",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "departList/departList",
"style": {
"navigationBarTitleText": ""
}
}
]
},
{
"root": "pagesPackage/ngTools_Dict",
"pages": [{
"path": "add",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "edit",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "list",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "detail",
"style": {
"navigationStyle": "custom"
}
}
]
},
{
"root": "pagesPackage/ngTools_DictItem",
"pages": [{
"path": "add",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "edit",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "list",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "detail",
"style": {
"navigationStyle": "custom"
}
}
]
},
{
"root": "pagesPackage/ngtools_information",
"pages": [{
"path": "add",
"style": {
"navigationBarTitleText": "新增"
}
},
{
"path": "edit",
"style": {
"navigationBarTitleText": "编辑"
}
},
{
"path": "list",
"style": {
"navigationBarTitleText": "列表"
}
},
{
"path": "detail",
"style": {
"navigationBarTitleText": "详情"
}
}
]
},
{
"root": "pagesPackage/ngtools_categories",
"pages": [{
"path": "add",
"style": {
"navigationBarTitleText": "新增"
}
},
{
"path": "edit",
"style": {
"navigationBarTitleText": "编辑"
}
},
{
"path": "list",
"style": {
"navigationBarTitleText": "列表"
}
},
{
"path": "detail",
"style": {
"navigationBarTitleText": "详情"
}
}
]
},
{
"root": "pagesPackage/ngTools_SamplingLocation",
"pages": [{
"path": "add",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "edit",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "list",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "detail",
"style": {
"navigationStyle": "custom"
}
}
]
},
{
"root": "pagesPackage/ngTools_MeterList",
"pages": [{
"path": "add",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "edit",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "list",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "detail",
"style": {
"navigationStyle": "custom"
}
}
]
},
{
"root": "pagesPackage/ngtools-goods",
"pages": [{
"path": "add",
"style": {
"navigationBarTitleText": "新增"
}
},
{
"path": "edit",
"style": {
"navigationBarTitleText": "编辑"
}
},
{
"path": "list",
"style": {
"navigationBarTitleText": "列表"
}
},
{
"path": "detail",
"style": {
"navigationBarTitleText": "详情"
}
}
]
},
{
"root": "uni_modules/uni-pay",
"pages": [{
"path": "pages/success/success",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "pages/ad-interactive-webview/ad-interactive-webview",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "pages/pay-desk/pay-desk",
"style": {
"navigationStyle": "custom"
}
}
]
}
],
"globalStyle": {
// #ifdef H5
"h5": {
"titleNView": false
},
// #endif
"navigationBarTextStyle": "black",
// "navigationBarTitleText": "uni-starter",
"navigationBarBackgroundColor": "#FFFFFF",
"backgroundColor": "#F8F8F8",
"enablePullDownRefresh": false,
// "maxWidth":375,
"rpxCalcMaxDeviceWidth": 375,
"rpxCalcBaseDeviceWidth": 375
// "rpxCalcIncludeWidth":0
},
"condition": {
"list": [{
"path": "pages/list/detail"
},
// {
// "path": "pages/list/list"
// },
{
"path": "pages/ucenter/settings/settings"
}
],
"current": 1
},
"tabBar": {
"color": "#7A7E83",
"selectedColor": "#007AFF",
"borderStyle": "black",
"backgroundColor": "#FFFFFF",
"list": [{
"pagePath": "pages/grid/grid",
"iconPath": "static/tabbar/list.png",
"selectedIconPath": "static/tabbar/list_active.png",
"text": "首页"
}
// , {
// "pagePath": "pages/list/list",
// "iconPath": "static/tabbar/grid.png",
// "selectedIconPath": "static/tabbar/grid_active.png",
// "text": "常用资料"
// }
, {
"pagePath": "pages/ucenter",
"iconPath": "static/tabbar/me.png",
"selectedIconPath": "static/tabbar/me_active.png",
"text": "我的"
}]
},
"uniIdRouter": {
"loginPage": "uni_modules/uni-id-pages/pages/login/login-withoutpwd",
"needLogin": [
"/uni_modules/uni-id-pages/pages/userinfo/userinfo"
],
"resToLogin": true
}
}

404
pages/grid/grid.vue Normal file
View File

@ -0,0 +1,404 @@
<template>
<view class="warp">
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar title="天然气计算工具集" />
<view class="content">
<ad-rewarded-video adpid="1507000689" :loadnext="true" v-slot:default="{loading, error}" @load="onadload"
@close="onadclose" @error="onaderror">
<button :disabled="loading" :loading="loading">显示广告</button>
<view v-if="error">{{error}}</view>
</ad-rewarded-video>
</view>
<!-- 流量计算 -->
<view class="section-box">
<text class="decoration"></text>
<text class="section-text">{{$t('llJs.grid')}}</text>
</view>
<view class="Grid">
<view class="Grid-Item" v-for="(item,index) in llJsgridList" :key="index">
<navigator :url="item.url">
<view class="GSimg">
<image class="Image" :src="getStaticFilePath('mianicon/'+item.icon)" mode="aspectFit"></image>
</view>
<view class="GStitle">{{ item.type }}</view>
</navigator>
</view>
</view>
<!-- 参数计算 -->
<view class="section-box">
<text class="decoration"></text>
<text class="section-text">{{$t('wxcsJs.grid')}}</text>
</view>
<view class="Grid">
<view class="Grid-Item" v-for="(item,index) in wxcsJsgridList" :key="index">
<navigator :url="item.url">
<view class="GSimg">
<image class="Image" :src="getStaticFilePath('/logomain.png')" mode="aspectFit"></image>
</view>
<view class="GStitle">{{ item.type }}</view>
</navigator>
</view>
</view>
<!-- CNG计算 -->
<view class="section-box">
<text class="decoration"></text>
<text class="section-text">{{$t('CNGJs.grid')}}</text>
</view>
<view class="Grid">
<view class="Grid-Item" v-for="(item,index) in CNGJsgridList" :key="index">
<navigator :url="item.url">
<view class="GSimg">
<image class="Image" :src="getStaticFilePath('/logomain.png')" mode="aspectFill"></image>
</view>
<view class="GStitle">{{ item.type }}</view>
</navigator>
</view>
</view>
<!-- <!-- CNG计算 -->
<view class="section-box">
<text class="decoration"></text>
<text class="section-text">{{$t('QtJs.grid')}}</text>
</view>
<view class="Grid">
<view class="Grid-Item" v-for="(item,index) in QtJsgridList" :key="index">
<navigator :url="item.url">
<view class="GSimg">
<image class="Image" :src="getStaticFilePath('/logomain.png')" mode="aspectFill"></image>
</view>
<view class="GStitle">{{ item.type }}</view>
</navigator>
</view>
</view>
</view>
</template>
<script>
// import {
// getJsonTree,
// groupBy
// } from "@/js_sdk/util/jsonData";
import deviceinfo from '@/js_sdk/dc-deviceinfo/deviceinfo.js'
import {
saveDepartStore,
saveDictItemStore
} from '@/js_sdk/util/dictTools';
// #ifdef APP-PLUS
import statusBar from "@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar";
// #endif
const db = uniCloud.database();
export default {
// #ifdef APP-PLUS
components: {
statusBar
},
// #endif
data() {
return {
llJsgridList: [],
wxcsJsgridList: [],
CNGJsgridList: [],
QtJsgridList: [],
current: 0,
hasLogin: false,
CPUNo: [],
msgList: []
}
},
onShow() {
this.hasLogin = uniCloud.getCurrentUserInfo().tokenExpired > Date.now()
},
mounted() {
//#ifdef APP
plus.device.getInfo({
success: function(e) {
console.log('getDeviceInfo success: ' + JSON.stringify(e));
},
fail: function(e) {
console.log('getDeviceInfo failed: ' + JSON.stringify(e));
}
});
// this.CPUNo=JSON.stringify(plus.device.getInfo())
//#endif
let that = this;
uni.getSystemInfo({
success: function(res) {
// console.log(res)
}
});
},
onLoad() {
this.getGrid();
saveDictItemStore();
saveDepartStore();
},
methods: {
getGrid() {
let gridList = []
gridList.push({
"type": this.$t('llJs.cysllJs.title'),
"url": this.$t('llJs.cysllJs.url'),
"icon": this.$t('llJs.cysllJs.icon')
})
gridList.push({
"type": this.$t('llJs.sdsllJs.title'),
"url": this.$t('llJs.sdsllJs.url'),
"icon": this.$t('llJs.sdsllJs.icon')
})
gridList.push({
"type": this.$t('llJs.ljlllJs.title'),
"url": this.$t('llJs.ljlllJs.url'),
"icon": this.$t('llJs.ljlllJs.icon')
})
this.llJsgridList = gridList
gridList = []
gridList.push({
"type": this.$t('wxcsJs.ysyzJs.title'),
"url": this.$t('wxcsJs.ysyzJs.url')
})
gridList.push({
"type": this.$t('wxcsJs.rzJs.title'),
"url": this.$t('wxcsJs.rzJs.url')
})
gridList.push({
"type": this.$t('wxcsJs.qtJs.title'),
"url": this.$t('wxcsJs.qtJs.url')
})
this.wxcsJsgridList = gridList
gridList = []
gridList.push({
"type": this.$t('CNGJs.srjJs.title'),
"url": this.$t('CNGJs.srjJs.url')
})
gridList.push({
"type": this.$t('CNGJs.zxcJs.title'),
"url": this.$t('CNGJs.zxcJs.url')
})
gridList.push({
"type": this.$t('CNGJs.LNGQhJs.title'),
"url": this.$t('CNGJs.LNGQhJs.url')
})
this.CNGJsgridList = gridList
gridList = []
gridList.push({
"type": this.$t('QtJs.ZBGJs.title'),
"url": this.$t('QtJs.ZBGJs.url')
})
gridList.push({
"type": this.$t('QtJs.srjBGJs.title'),
"url": this.$t('QtJs.srjBGJs.url')
})
// gridList.push({
// "type": this.$t('QtJs.SqgyJs.title'),
// "url": this.$t('QtJs.SqgyJs.url')
// })
this.QtJsgridList = gridList
},
/**
* banner加载后触发的回调
*/
onqueryload(data) {
// console.log(JSON.stringify(data))
},
changeSwiper(e) {
this.current = e.detail.current
},
/**
* 点击banner的处理
*/
clickBannerItem(item) {
// -url
if (item.open_url) {
uni.navigateTo({
url: '/uni_modules/uni-id-pages/pages/common/webview/webview?url=' + item.open_url +
'&title=' + item.title,
success: res => {},
fail: () => {},
complete: () => {}
});
}
//
}
}
}
</script>
<style lang="scss">
/* #ifndef APP-NVUE */
page {
display: flex;
flex-direction: column;
box-sizing: border-box;
background-color: #fff;
min-height: 100%;
height: auto;
}
view {
font-size: 14px;
line-height: inherit;
}
/* #endif */
.section-box {
display: flex;
flex-direction: row;
align-items: center;
padding: 20rpx;
}
.decoration {
width: 4px;
height: 12px;
border-radius: 10px;
background-color: #2979ff;
margin-left: 30rpx;
}
.section-text {
color: blue;
margin-left: 10rpx;
font-size: 16px;
}
/* #ifdef APP-NVUE */
.warp {
background-color: #fff;
}
/* #endif */
.big-number {
font-size: 50rpx;
font-weight: 700;
font-stretch: condensed;
font-style: oblique;
}
.text {
text-align: center;
font-size: 26rpx;
margin-top: 10rpx;
}
.Grid {
width: 90vw;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: flex-start;
align-content: space-between;
padding: 20rpx 40rpx;
column-gap: calc(25% / 3);
row-gap: 10rpx;
box-sizing: content-box;
.Grid-Item {
width: 25%;
height: 150rpx;
text-align: center;
border: 0rpx solid #ccc;
box-sizing: content-box;
background: #ffffff;
background-image: "@/static/uni-center/headers.png";
.GSimg {
width: 100%;
height: 10rpx;
margin-top: 20rpx;
text-align: center;
.Image {
width: 80rpx;
height: 80rpx;
}
}
.GStitle {
width: 100%;
height: 34rpx;
line-height: 34rpx;
color: orangered;
font-size: 24rpx;
margin-top: 80rpx;
}
}
}
.banner-image {
width: 750rpx;
height: 400rpx;
}
.swiper-box {
height: 400rpx;
}
.search-icons {
padding: 16rpx;
}
.search-container-bar {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
justify-content: center;
align-items: center;
position: fixed;
left: 0;
right: 0;
z-index: 10;
background-color: #fff;
}
/* #ifndef APP-NVUE || VUE3*/
::v-deep
/* #endif */
.uni-searchbar__box {
border-width: 0;
}
/* #ifndef APP-NVUE || VUE3 */
::v-deep
/* #endif */
.uni-input-placeholder {
font-size: 28rpx;
}
</style>

373
pages/list/detail.vue Normal file
View File

@ -0,0 +1,373 @@
<template>
<!--
本页面模板教程https://ext.dcloud.net.cn/plugin?id=2717
uni-list 文档https://ext.dcloud.net.cn/plugin?id=24
uniCloud 文档https://uniapp.dcloud.io/uniCloud/README
unicloud-db 组件文档https://uniapp.dcloud.net.cn/uniCloud/unicloud-db-component
DB Schema 规范https://uniapp.dcloud.net.cn/uniCloud/schema
-->
<view class="article">
<!-- #ifdef APP-PLUS -->
<uni-nav-bar :statusBar="true" :border="false"></uni-nav-bar>
<!-- #endif -->
<view class="article-title">{{ title }}</view>
<unicloud-db v-slot:default="{data, loading, error, options}" :options="formData" collection="opendb-news-articles,uni-id-users"
:field="field" :getone="true" :where="where" :manual="true" ref="detail"
foreignKey="opendb-news-articles.user_id" @load="loadData">
<template v-if="!loading && data">
<uni-list :border="false">
<uni-list-item thumbSize="lg" :thumb="data.image">
<!-- 通过body插槽定义作者信息内容 -->
<template v-slot:body>
<view class="header-content">
<view class="uni-title">{{data.user_id && data.user_id[0] && data.user_id[0].nickname || '未知'}}</view>
</view>
</template>
<template v-slot:footer>
<view class="footer">
<view class="uni-note">更新于
<uni-dateformat :date="data.last_modify_date" format="yyyy-MM-dd hh:mm"
:threshold="[60000, 2592000000]" />
</view>
</view>
</template>
</uni-list-item>
</uni-list>
<view class="banner">
<!-- 文章开头缩略图 -->
<image class="banner-img" :src="data.avatar" mode="widthFix"></image>
<!-- 文章摘要 -->
<view class="banner-title">
<text class="uni-ellipsis">{{data.excerpt}}</text>
</view>
</view>
<view class="article-content">
<rich-text :nodes="data.content"></rich-text>
</view>
</template>
</unicloud-db>
</view>
</template>
<script>
// #ifdef APP
import UniShare from '@/uni_modules/uni-share/js_sdk/uni-share.js';
import uniNavBar from '@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.vue';
const uniShare = new UniShare()
// #endif
const db = uniCloud.database();
const readNewsLog = db.collection('read-news-log')
export default {
// #ifdef APP
components:{
"uni-nav-bar":uniNavBar
},
onBackPress({from}) {
if(from == 'backbutton'){
if(uniShare.isShow){
this.$nextTick(function(){
console.log(uniShare);
uniShare.hide()
})
}
return uniShare.isShow;
}
},
// #endif
data() {
return {
// _id
id: "",
title: 'title',
//
// ,
field: 'user_id.nickname,user_id._id,avatar,excerpt,last_modify_date,comment_count,like_count,title,content',
formData: {
noData: '<p style="text-align:center;color:#666">详情加载中...</p>'
}
}
},
computed: {
uniStarterConfig() {
return getApp().globalData.config
},
where(){
//where , https://uniapp.dcloud.net.cn/uniCloud/unicloud-db?id=jsquery
return `_id =="${this.id}"`
}
},
onLoad(event) {
//id id
if (event.id) {
this.id = event.id
}
//
if (event.title) {
this.title = event.title
uni.setNavigationBarTitle({
title: event.title
})
}
},
onReady() {
// where clinetDB loadData onLoad
if (this.id) { // ID
this.$refs.detail.loadData()
} else {
uni.showToast({
icon: 'none',
title: this.$t('listDetail.newsErr')
})
}
},
onNavigationBarButtonTap(event) {
if (event.type == 'share') {
this.shareClick();
}
},
methods: {
$log(...args){
console.log('args',...args,this.id)
},
setReadNewsLog(){
let item = {
"article_id":this.id,
"last_time":Date.now()
},
readNewsLog = uni.getStorageSync('readNewsLog')||[],
index = -1;
readNewsLog.forEach(({article_id},i)=>{
if(article_id == item.article_id){
index = i
}
})
if(index === -1){
readNewsLog.push(item)
}else{
readNewsLog.splice(index,1,item)
}
uni.setStorageSync('readNewsLog',readNewsLog)
console.log(readNewsLog);
},
setFavorite() {
if ( uniCloud.getCurrentUserInfo().tokenExpired < Date.now() ){
return console.log('未登录用户');
}
let article_id = this.id,
last_time = Date.now();
console.log({article_id,last_time});
readNewsLog.where(`"article_id" == "${article_id}" && "user_id"==$env.uid`)
.update({last_time})
.then(({result:{updated}}) => {
console.log('updated',updated);
if (!updated) {
readNewsLog.add({article_id}).then(e=>{
console.log(e);
}).catch(err => {
console.log(err);
})
}
}).catch(err => {
console.log(err);
})
},
loadData(data) {
//
if (this.title == '' && data[0].title) {
this.title = data[0].title
uni.setNavigationBarTitle({
title: data[0].title
});
}
this.setReadNewsLog();
},
/**
* followClick
* 点击关注
*/
followClick() {
uni.showToast({
title:this.$t('listDetail.follow'),
icon: 'none'
});
},
/**
* 分享该文章
*/
// #ifdef APP
shareClick() {
let {
_id,
title,
excerpt,
avatar
} = this.$refs.detail.dataList
console.log( JSON.stringify({
_id,
title,
excerpt,
avatar
}) );
uniShare.show({
content: { //typeherftitlesummaryimageUrl
type: 0,
href: this.uniStarterConfig.h5.url + `/#/pages/list/detail?id=${_id}&title=${title}`,
title: this.title,
summary: excerpt,
imageUrl: avatar + '?x-oss-process=image/resize,m_fill,h_100,w_100' //ios
},
menus: [{
"img": "/static/app-plus/sharemenu/wechatfriend.png",
"text": this.$t('common.wechatFriends'),
"share": {
"provider": "weixin",
"scene": "WXSceneSession"
}
},
{
"img": "/static/app-plus/sharemenu/wechatmoments.png",
"text": this.$t('common.wechatBbs'),
"share": {
"provider": "weixin",
"scene": "WXSceneTimeline"
}
},
{
"img": "/static/app-plus/sharemenu/mp_weixin.png",
"text": this.$t('common.wechatApplet'),
"share": {
provider: "weixin",
scene: "WXSceneSession",
type: 5,
miniProgram: {
id: this.uniStarterConfig.mp.weixin.id,
path: `/pages/list/detail?id=${_id}&title=${title}`,
webUrl: this.uniStarterConfig.h5.url +
`/#/pages/list/detail?id=${_id}&title=${title}`,
type: 0
},
}
},
{
"img": "/static/app-plus/sharemenu/weibo.png",
"text": this.$t('common.weibo'),
"share": {
"provider": "sinaweibo"
}
},
{
"img": "/static/app-plus/sharemenu/qq.png",
"text": "QQ",
"share": {
"provider": "qq"
}
},
{
"img": "/static/app-plus/sharemenu/copyurl.png",
"text": this.$t('common.copy'),
"share": "copyurl"
},
{
"img": "/static/app-plus/sharemenu/more.png",
"text": this.$t('common.more'),
"share": "shareSystem"
}
],
cancelText: this.$t('common.cancelShare'),
}, e => { //callback
console.log(e);
})
}
// #endif
}
}
</script>
<style scoped>
.header-content {
flex: 1;
display: flex;
flex-direction: column;
font-size: 14px;
}
/* 标题 */
.uni-title {
display: flex;
margin-bottom: 5px;
font-size: 14px;
font-weight: bold;
color: #3b4144;
}
/* 描述 额外文本 */
.uni-note {
color: #999;
font-size: 12px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
align-items: center;
}
.footer {
display: flex;
align-items: center;
}
.footer-button {
display: flex;
align-items: center;
font-size: 12px;
height: 30px;
color: #fff;
background-color: #ff5a5f;
}
.banner {
position: relative;
margin: 0 15px;
height: 180px;
overflow: hidden;
}
.banner-img {
position: absolute;
width: 100%;
}
.banner-title {
display: flex;
align-items: center;
position: absolute;
padding: 0 15px;
width: 100%;
bottom: 0;
height: 30px;
font-size: 14px;
color: #fff;
background: rgba(0, 0, 0, 0.4);
overflow: hidden;
box-sizing: border-box;
}
.uni-ellipsis {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.article-title {
padding: 20px 15px;
padding-bottom: 0;
}
.article-content {
padding: 15px;
font-size: 15px;
overflow: hidden;
}
</style>

206
pages/list/list.nvue Normal file
View File

@ -0,0 +1,206 @@
<template>
<view class="pages">
<!-- #ifndef H5 -->
<statusBar></statusBar>
<!-- #endif -->
<info-list></info-list>
</view>
</template>
<script>
let cdbRef;
import infoList from '@/pagesPackage/ngtools_information/list.vue'
import statusBar from "@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-status-bar";
import Gps from '@/uni_modules/json-gps/js_sdk/gps.js';
const gps = new Gps(),
db = uniCloud.database();
export default {
components: {
statusBar,
infoList
},
computed: {
inputPlaceholder(e) {
if (uni.getStorageSync('CURRENT_LANG') == "en") {
return 'Please enter the search content'
} else {
return '请输入搜索内容'
}
},
colList() {
return [
db.collection('opendb-news-articles').where(this.where).field(
'avatar,title,last_modify_date,user_id').getTemp(),
db.collection('uni-id-users').field('_id,nickname').getTemp()
]
}
},
data() {
return {
where: '"article_status" == 1',
keyword: "",
showRefresh: false,
listHight: 0
}
},
watch: {
keyword(keyword, oldValue) {
let where = '"article_status" == 1 '
if (keyword) {
this.where = where + `&& /${keyword}/.test(title)`;
} else {
this.where = where;
}
}
},
async onReady() {
// #ifdef APP-NVUE
/* 可用窗口高度 - 搜索框高 - 状态栏高 */
this.listHight = uni.getSystemInfoSync().windowHeight - uni.getSystemInfoSync().statusBarHeight - 50 +
'px';
// #endif
// #ifndef APP-NVUE
this.listHight = 'auto'
// #endif
cdbRef = this.$refs.udb
},
async onShow() {
this.keyword = getApp().globalData.searchText
getApp().globalData.searchText = ''
//这里仅演示如何在onShow生命周期获取设备位置并在设备或者应用没有权限时自动引导。设置完毕自动重新获取。
//你可以基于他做自己的业务,比如:根据距离由近到远排序列表数据等
// uni.showLoading({
// title:"获取定位中"
// });
//默认h5端不获取定位
// #ifndef H5
let location = await gps.getLocation({
geocode: true
})
// console.log(location);
// #endif
// if(location){
// uni.showToast({
// title: JSON.stringify(location),
// icon: 'none'
// });
// }
// uni.hideLoading()
},
methods: {
searchClick(e) { //点击搜索框
uni.hideKeyboard();
uni.navigateTo({
url: '/pages/list/search/search',
animationType: 'fade-in'
});
},
retry() {
this.refresh()
},
refresh() {
cdbRef.loadData({
clear: true
}, () => {
uni.stopPullDownRefresh()
// #ifdef APP-NVUE
this.showRefresh = false
// #endif
console.log('end');
})
console.log('refresh');
},
loadMore() {
cdbRef.loadMore()
},
onqueryerror(e) {
console.error(e);
},
onpullingdown(e) {
console.log(e);
this.showRefresh = true
if (e.pullingDistance > 100) {
this.refresh()
}
}
},
// #ifndef APP-NVUE
onPullDownRefresh() {
this.refresh()
},
onReachBottom() {
this.loadMore()
}
// #endif
}
</script>
<style scoped>
/* #ifndef APP-NVUE */
view {
display: flex;
box-sizing: border-box;
flex-direction: column;
}
/* #endif */
.pages {
background-color: #FFFFFF;
}
.avatar {
width: 200rpx;
height: 200rpx;
margin-right: 10rpx;
}
.main {
justify-content: space-between;
flex: 1;
}
.title {
font-size: 16px;
}
.info {
flex-direction: row;
justify-content: space-between;
}
.author,
.last_modify_date {
font-size: 14px;
color: #999999;
}
.uni-search-box {
background-color: #FFFFFF;
position: sticky;
height: 50px;
top: 0;
left: 0;
/* #ifndef APP-PLUS */
z-index: 9;
/* #endif */
/* #ifdef MP-WEIXIN */
width: 580rpx;
/* #endif */
}
.cover-search-bar {
height: 50px;
position: relative;
top: -50px;
margin-bottom: -50px;
/* #ifndef APP-NVUE */
z-index: 999;
/* #endif */
}
</style>

503
pages/ucenter.vue Normal file
View File

@ -0,0 +1,503 @@
<template>
<view class="center">
<uni-sign-in ref="signIn"></uni-sign-in>
<view class="userInfo" @click.capture="toUserInfo">
<cloud-image width="150rpx" height="150rpx" v-if="hasLogin&&userInfo.avatar_file&&userInfo.avatar_file.url"
:src="userInfo.avatar_file.url"></cloud-image>
<view v-else class="defaultAvatarUrl">
<uni-icons color="#ffffff" size="50" type="person-filled" />
</view>
<view class="logo-title">
<text class="uer-name" v-if="hasLogin">{{userInfo.nickname||userInfo.username||userInfo.mobile}}</text>
<text class="uer-name" v-else>{{$t('mine.notLogged')}}</text>
</view>
</view>
<!-- <uni-grid class="grid" :column="4" :showBorder="false" :square="true">
<uni-grid-item class="item" v-for="(item,index) in gridList" @click.native="tapGrid(index)" :key="index">
<uni-icons class="icon" color="#007AFF" :type="item.icon" size="26"></uni-icons>
<text class="text">{{item.text}}</text>
</uni-grid-item>
</uni-grid> -->
<uni-list class="center-list" v-for="(sublist , index) in ucenterList" :key="index">
<uni-list-item v-for="(item,i) in sublist" :title="item.title" link :rightText="item.rightText" :key="i"
:clickable="true" :to="item.to" @click="ucenterListClick(item)" :show-extra-icon="true"
:extraIcon="{type:item.icon,color:'#999'}">
<template v-slot:footer>
<view v-if="item.showBadge" class="item-footer">
<text class="item-footer-text">{{item.rightText}}</text>
<view class="item-footer-badge"></view>
</view>
</template>
</uni-list-item>
</uni-list>
</view>
</template>
<script>
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
import callCheckVersion from '@/uni_modules/uni-upgrade-center-app/utils/call-check-version';
// #ifdef APP
import UniShare from '@/uni_modules/uni-share/js_sdk/uni-share.js';
const uniShare = new UniShare()
// #endif
const db = uniCloud.database();
import {
store,
mutations
} from '@/uni_modules/uni-id-pages/common/store.js'
export default {
// #ifdef APP
onBackPress({
from
}) {
if (from == 'backbutton') {
this.$nextTick(function() {
uniShare.hide()
})
return uniShare.isShow;
}
},
// #endif
data() {
return {
gridList: [{
"text": this.$t('mine.dict'),
"icon": "chat"
},
{
"text": this.$t('mine.showText'),
"icon": "cloud-upload"
},
{
"text": this.$t('mine.showText'),
"icon": "contact"
},
{
"text": this.$t('mine.showText'),
"icon": "download"
}
],
ucenterList: [
[
{
"title": this.$t('mine.dict'),
"event": 'dictSetting',
"icon": "compose"
},
{
"title": this.$t('mine.depart'),
"event": 'departSetting',
"icon": "compose"
},
// {
// "title": this.$t('mine.myPay'),
// "event": 'myPaySetting',
// "icon": "compose"
// },
// // #ifdef APP-PLUS
// {
// "title": this.$t('mine.toEvaluate'),
// "event": 'gotoMarket',
// "icon": "star"
// },
// //#endif
// {
// "title":this.$t('mine.readArticles'),
// "to": '/pages/ucenter/read-news-log/read-news-log',
// "icon": "flag"
// },
// {
// "title": this.$t('mine.myScore'),
// "to": '',
// "event": 'getScore',
// "icon": "paperplane"
// }
// // #ifdef APP-PLUS
// , {
// "title": this.$t('mine.invite'),
// "event": 'share',
// "icon": "redo"
// }
// // #endif
],
[{
"title": this.$t('mine.feedback'),
"to": '/uni_modules/uni-feedback/pages/opendb-feedback/opendb-feedback',
"icon": "help"
}, {
"title": this.$t('mine.settings'),
"to": '/pages/ucenter/settings/settings',
"icon": "gear"
}],
// #ifdef APP-PLUS
[{
"title": this.$t('mine.about'),
"to": '/pages/ucenter/about/about',
"icon": "info"
}]
// #endif
],
listStyles: {
"height": "150rpx", //
"width": "150rpx", //
"border": { // Boolean
"color": "#eee", //
"width": "1px", //
"style": "solid", //
"radius": "100%" //
}
}
}
},
onLoad() {
//#ifdef APP-PLUS
this.ucenterList[this.ucenterList.length - 2].unshift({
title: this.$t('mine.checkUpdate'), // this.this.$t('mine.checkUpdate')""
rightText: this.appVersion.version + '-' + this.appVersion.versionCode,
event: 'checkVersion',
icon: 'loop',
showBadge: this.appVersion.hasNew
})
//#endif
},
onShow() {},
computed: {
userInfo() {
return store.userInfo
},
hasLogin() {
return store.hasLogin
},
// #ifdef APP-PLUS
appVersion() {
return getApp().appVersion
},
// #endif
appConfig() {
return getApp().globalData.config
}
},
methods: {
toSettings() {
uni.navigateTo({
url: "/pages/ucenter/settings/settings"
})
},
signIn() { //
this.$refs.signIn.open()
},
dictSetting() { //
uni.navigateTo({
url: "/pagesPackage/ngTools_Dict/list"
})
},
departSetting() { //
uni.navigateTo({
url: "/pagesPackage/ngTools_depart/list"
})
},
myPaySetting() { //
uni.navigateTo({
url: "/pagesPackage/ucenter/pay/index"
})
},
/**
* 个人中心项目列表点击事件
*/
ucenterListClick(item) {
if (!item.to && item.event) {
this[item.event]();
}
},
async checkVersion() {
let res = await callCheckVersion()
console.log(res);
if (res.result.code > 0) {
checkUpdate()
} else {
uni.showToast({
title: res.result.message,
icon: 'none'
});
}
},
toUserInfo() {
uni.navigateTo({
url: '/uni_modules/uni-id-pages/pages/userinfo/userinfo'
})
},
tapGrid(index) {
uni.showToast({
// title: '' + (index + 1) + '',
title: this.$t('mine.clicked') + " " + (index + 1),
icon: 'none'
});
},
/**
* 去应用市场评分
*/
gotoMarket() {
// #ifdef APP-PLUS
if (uni.getSystemInfoSync().platform == "ios") {
// appstoreid
let appstoreid = this.appConfig.marketId.ios; // 'id1417078253';
console.log({
appstoreid
});
plus.runtime.openURL("itms-apps://" + 'itunes.apple.com/cn/app/wechat/' + appstoreid + '?mt=8',
err => {
console.log('plus.runtime.openURL err:' + JSON.stringify(err));
});
}
if (uni.getSystemInfoSync().platform == "android") {
var Uri = plus.android.importClass("android.net.Uri");
var uri = Uri.parse("market://details?id=" + this.appConfig.marketId.android);
var Intent = plus.android.importClass('android.content.Intent');
var intent = new Intent(Intent.ACTION_VIEW, uri);
var main = plus.android.runtimeMainActivity();
main.startActivity(intent);
}
// #endif
},
/**
* 获取积分信息
*/
getScore() {
if (!this.userInfo) return uni.showToast({
title: this.$t('mine.checkScore'),
icon: 'none'
});
uni.showLoading({
mask: true
})
db.collection("uni-id-scores")
.where('"user_id" == $env.uid')
.field('score,balance')
.orderBy("create_date", "desc")
.limit(1)
.get()
.then((res) => {
console.log(res);
const data = res.result.data[0];
let msg = '';
msg = data ? (this.$t('mine.currentScore') + data.balance) : this.$t('mine.noScore');
uni.showToast({
title: msg,
icon: 'none'
});
}).finally(() => {
uni.hideLoading()
})
},
async share() {
let {
result
} = await db.collection('uni-id-users').where("'_id' == $cloudEnv_uid").field('my_invite_code').get()
let myInviteCode = result.data[0].my_invite_code
if (!myInviteCode) {
return uni.showToast({
title: '请检查uni-config-center中uni-id配置是否已启用 autoSetInviteCode',
icon: 'none'
});
}
console.log({
myInviteCode
});
let {
appName,
logo,
company,
slogan
} = this.appConfig.about
// #ifdef APP-PLUS
uniShare.show({
content: { //typeherftitlesummaryimageUrl
type: 0,
href: this.appConfig.h5.url +
`/#/pages/ucenter/invite/invite?code=uniInvitationCode:${myInviteCode}`,
title: appName,
summary: slogan,
imageUrl: logo +
'?x-oss-process=image/resize,m_fill,h_100,w_100' //ios
},
menus: [{
"img": "/static/app-plus/sharemenu/wechatfriend.png",
"text": this.$t('common.wechatFriends'),
"share": {
"provider": "weixin",
"scene": "WXSceneSession"
}
},
{
"img": "/static/app-plus/sharemenu/wechatmoments.png",
"text": this.$t('common.wechatBbs'),
"share": {
"provider": "weixin",
"scene": "WXSceneTimeline"
}
},
{
"img": "/static/app-plus/sharemenu/weibo.png",
"text": this.$t('common.weibo'),
"share": {
"provider": "sinaweibo"
}
},
{
"img": "/static/app-plus/sharemenu/qq.png",
"text": "QQ",
"share": {
"provider": "qq"
}
},
{
"img": "/static/app-plus/sharemenu/copyurl.png",
"text": this.$t('common.copy'),
"share": "copyurl"
},
{
"img": "/static/app-plus/sharemenu/more.png",
"text": this.$t('common.more'),
"share": "shareSystem"
}
],
cancelText: this.$t('common.cancelShare'),
}, e => { //callback
console.log(e);
})
// #endif
}
}
}
</script>
<style lang="scss" scoped>
/* #ifndef APP-NVUE */
view {
display: flex;
box-sizing: border-box;
flex-direction: column;
}
page {
background-color: #f8f8f8;
}
/* #endif*/
.center {
flex: 1;
flex-direction: column;
background-color: #f8f8f8;
}
.userInfo {
// padding: 20rpx;
padding-top: 60px;
background-image: url(http://h5.ngtools.cn/pic/static/uni-center/headers.png);
flex-direction: column;
align-items: center;
}
.defaultAvatarUrl {
width: 150rpx;
height: 150rpx;
background-color: #007aff;
border-radius: 100%;
justify-content: center;
align-items: center;
}
.logo-title {
flex: 1;
align-items: center;
justify-content: space-between;
flex-direction: row;
}
.uer-name {
height: 100rpx;
line-height: 100rpx;
font-size: 38rpx;
color: #FFFFFF;
}
.center-list {
margin-bottom: 30rpx;
background-color: #f9f9f9;
}
.center-list-cell {
width: 750rpx;
background-color: #007AFF;
height: 40rpx;
}
.grid {
background-color: #FFFFFF;
margin-bottom: 6px;
}
.uni-grid .text {
font-size: 16px;
height: 25px;
line-height: 25px;
color: #817f82;
}
.uni-grid .item ::v-deep .uni-grid-item__box {
justify-content: center;
align-items: center;
}
/*修改边线粗细示例*/
/* #ifndef APP-NVUE */
.center-list ::v-deep .uni-list--border:after {
-webkit-transform: scaleY(0.2);
transform: scaleY(0.2);
margin-left: 80rpx;
}
.center-list ::v-deep .uni-list--border-top,
.center-list ::v-deep .uni-list--border-bottom {
display: none;
}
/* #endif */
.item-footer {
flex-direction: row;
align-items: center;
}
.item-footer-text {
color: #999;
font-size: 24rpx;
padding-right: 10rpx;
}
.item-footer-badge {
width: 20rpx;
height: 20rpx;
/* #ifndef APP-NVUE */
border-radius: 50%;
/* #endif */
/* #ifdef APP-NVUE */
border-radius: 10rpx;
/* #endif */
background-color: #DD524D;
}
</style>

View File

@ -0,0 +1,104 @@
<template>
<view class="informantion_mask" @tap="closeWindow">
<view class="informantion_content" @tap.stop.prevent>
<view class="mask-header">
<image :src="getStaticFilePath('/logomain.png')" mode="aspectFit" @click="closeWindow"></image>
</view>
<view class="informantion-title">
<p class="informantion-title-p">开启消息通知</p>
<span class="informantion-title-span">不要错过你的特别关心的重要通知每天都要有干货推荐</span>
</view>
<view class="informantion-btn">
<button type="primary">去开启</button>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
props: {
message: {
type: Object,
default:{}
},
},
methods: {
//mask
closeWindow() {
uni.navigateBack({
delta: 1
})
}
}
}
</script>
<style lang="scss">
page {
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.4);
}
.informantion_mask {
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.informantion_content {
width: 600rpx;
height: 820rpx;
overflow: hidden;
border-radius: 10rpx;
background-color: white;
display: flex;
flex-direction: column;
justify-content: space-between;
padding-bottom: 20rpx;
}
.mask-header {
height: 400rpx;
position: relative;
background-image: url('http://h5.ngtools.cn/pic/static/logomain.png');
background-repeat: no-repeat;
background-size: cover;
image {
width: 40rpx;
height: 40rpx;
position: absolute;
top: 20rpx;
right: 20rpx;
}
}
.informantion-title {
text-align: center;
padding: 0 40rpx;
p {
font-size: 35rpx;
font-weight: bold;
line-height: 80rpx;
}
span {
color: #6C6C6C;
}
}
.informantion-btn {
height: 93rpx;
width: 80%;
margin: 0 auto;
}
</style>

View File

@ -0,0 +1,183 @@
<template>
<view class="uni-container">
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="新增 数据字典" @clickLeft="back" />
<uni-card><uni-forms ref="form" :model="formData" validate-trigger="submit" err-show-type="toast">
<uni-forms-item name="dictName" label="字典名称">
<uni-easyinput placeholder="字典名称" v-model="formData.dictName" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="dictCode" label="字典编码">
<uni-easyinput placeholder="字典编码" v-model="formData.dictCode" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="description" label="描述">
<uni-easyinput placeholder="描述" v-model="formData.description" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="delFlag" label="删除状态">
<uni-easyinput placeholder="删除状态" type="number" v-model="formData.delFlag"></uni-easyinput>
</uni-forms-item>
<!-- <uni-forms-item name="createBy" label="创建人">
<uni-easyinput placeholder="创建人" v-model="formData.createBy" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="updateBy" label="更新人">
<uni-easyinput placeholder="更新人" v-model="formData.updateBy" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="updateTime" label="更新时间">
<uni-datetime-picker v-model="formData.updateTime"></uni-datetime-picker>
</uni-forms-item>
<uni-forms-item name="createTime" label="创建时间">
<uni-datetime-picker v-model="formData.createTime"></uni-datetime-picker>
</uni-forms-item> -->
<view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button>
</view>
</uni-forms></uni-card>
</view>
</template>
<script>
import {
validator
} from '../../js_sdk/validator/ngTools_Dict.js';
import {
store,
mutations
} from '@/uni_modules/uni-id-pages/common/store.js'
const db = uniCloud.database();
const dbCollectionName = 'ngTools_Dict';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.indexOf(key) > -1) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"dictName": "",
"dictCode": "",
"description": "",
"delFlag": 0,
"createBy": "",
"updateBy": "",
"updateTime": "",
"createTime": ""
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
computed: {
userInfo() {
return store.userInfo
},
hasLogin() {
return store.hasLogin
},
// #ifdef APP-PLUS
appVersion() {
return getApp().appVersion
},
// #endif
appConfig() {
return getApp().globalData.config
}
},
methods: {
back() {
uni.navigateBack({
delta: 1
})
},
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
console.log(res)
return this.submitForm(res)
}).catch(() => {}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
console.log(JSON.stringify(value));
value.createBy=store.userInfo.nickname;
value.createTime=new Date().toLocaleDateString()+" "+ new Date().toLocaleTimeString();
// 使 clientDB
return db.collection(dbCollectionName).add(value).then((res) => {
uni.showToast({
icon: 'none',
title: '新增成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
}
}
}
</script>
<style>
.uni-container {
padding: 0px;
}
.uni-input-border,
.uni-textarea-border {
width: 100%;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
box-sizing: border-box;
}
.uni-input-border {
padding: 0 10px;
height: 35px;
}
.uni-textarea-border {
padding: 10px;
height: 80px;
}
.uni-button-group {
margin-top: 50px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.uni-button {
width: 184px;
}
</style>

View File

@ -0,0 +1,162 @@
<template>
<view class="container">
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="数据字典 详情" @clickLeft="back" />
<uni-card>
<view class="btns">
<button type="primary" size="mini" @click="handleUpdate">修改</button>
<button type="warn" size="mini" class="btn-delete" @click="handleDelete">删除</button>
</view>
<unicloud-db ref="udb" v-slot:default="{data, loading, error, options}" :options="options"
:collection="collectionList"
field="dictName,dictCode,description,delFlag,createBy,updateBy,updateTime,createTime" :where="queryWhere"
:getone="true" :manual="true">
<view v-if="error">{{error.message}}</view>
<view v-else-if="loading">
<uni-load-more :contentText="loadMore" status="loading"></uni-load-more>
</view>
<view v-else-if="data">
<uni-row>
<uni-col :span="6">
<uni-title title="字典名称"></uni-title>
</uni-col>
<uni-col :push='2' :span="14">
<uni-title :title="data.dictName"></uni-title>
</uni-col>
</uni-row>
<uni-row>
<uni-col :span="6">
<uni-title title="字典编码"></uni-title>
</uni-col>
<uni-col :push='2' :span="14">
<uni-title :title="data.dictCode"></uni-title>
</uni-col>
</uni-row>
<uni-row>
<uni-col :span="6">
<uni-title title="描述"></uni-title>
</uni-col>
<uni-col :push='2' :span="14">
<uni-title :title="data.description"></uni-title>
</uni-col>
</uni-row>
<!-- <uni-row>
<uni-col :span="6">
<uni-title title="删除状态"></uni-title>
</uni-col>
<uni-col :push='2' :span="14">
<uni-title :title="data.delFlag"></uni-title>
</uni-col>
</uni-row>
<uni-row>
<uni-col :span="6">
<uni-title title="创建人"></uni-title>
</uni-col>
<uni-col :push='2' :span="14">
<uni-title :title="data.createBy"></uni-title>
</uni-col>
</uni-row> -->
<view>
<uni-title color="blue" :title="data.dictName + ' 字典项'" align="center"></uni-title>
<dict-item :dictID="data.dictCode"></dict-item>
</view>
</view>
</unicloud-db>
</uni-card>
</view>
</template>
<script>
import dictItem from '../ngTools_DictItem/list.vue';
// schema2codeenum
import {
enumConverter
} from '../../js_sdk/validator/ngTools_Dict.js'
const db = uniCloud.database()
export default {
components: {
dictItem
},
data() {
return {
queryWhere: '',
collectionList: "ngTools_Dict",
loadMore: {
contentdown: '',
contentrefresh: '',
contentnomore: ''
},
options: {
// scheme enum valuetext
...enumConverter
}
}
},
onLoad(e) {
this._id = e.id
console.log(this._id)
},
onReady() {
if (this._id) {
this.queryWhere = '_id=="' + this._id + '"'
}
},
methods: {
back() {
uni.navigateBack({
delta: 1
})
},
handleUpdate() {
//
uni.navigateTo({
url: './edit?id=' + this._id,
events: {
// ,
refreshData: () => {
this.$refs.udb.loadData({
clear: true
})
}
}
})
},
handleDelete() {
this.$refs.udb.remove(this._id, {
success: (res) => {
// list
uni.navigateTo({
url: './list'
})
}
})
}
}
}
</script>
<style>
.container {
padding: 0px;
}
.btns {
margin-top: 10px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
}
.btns button {
flex: 1;
}
.btn-delete {
margin-left: 40px;
}
</style>

View File

@ -0,0 +1,198 @@
<template>
<view class="uni-container">
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="编辑 数据字典" @clickLeft="back" />
<uni-card> <uni-forms ref="form" :model="formData" validate-trigger="submit" err-show-type="toast">
<uni-forms-item name="dictName" label="字典名称">
<uni-easyinput placeholder="字典名称" v-model="formData.dictName" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="dictCode" label="字典编码">
<uni-easyinput placeholder="字典编码" v-model="formData.dictCode" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="description" label="描述">
<uni-easyinput placeholder="描述" v-model="formData.description" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="delFlag" label="删除状态">
<uni-easyinput placeholder="删除状态" type="number" v-model="formData.delFlag"></uni-easyinput>
</uni-forms-item>
<!-- <uni-forms-item name="createBy" label="创建人">
<uni-easyinput placeholder="创建人" v-model="formData.createBy" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="updateBy" label="更新人">
<uni-easyinput placeholder="更新人" v-model="formData.updateBy" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="updateTime" label="更新时间">
<uni-datetime-picker v-model="formData.updateTime"></uni-datetime-picker>
</uni-forms-item>
<uni-forms-item name="createTime" label="创建时间">
<uni-datetime-picker v-model="formData.createTime"></uni-datetime-picker>
</uni-forms-item> -->
<view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button>
</view>
</uni-forms>
</uni-card>
</view>
</template>
<script>
import {
validator
} from '../../js_sdk/validator/ngTools_Dict.js';
const db = uniCloud.database();
const dbCollectionName = 'ngTools_Dict';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.indexOf(key) > -1) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"dictName": "",
"dictCode": "",
"description": "",
"delFlag": null,
"createBy": "",
"updateBy": "",
"updateTime": null,
"createTime": null
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onLoad(e) {
if (e.id) {
const id = e.id
this.formDataId = id
this.getDetail(id)
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
back() {
uni.navigateBack({
delta: 1
})
},
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
console.log(value, this.formDataId)
value.updateBy = store.userInfo.nickname;
value.updateTime = new Date().toLocaleDateString() + " " + new Date().toLocaleTimeString();
// 使 clientDB
return db.collection(dbCollectionName).doc(this.formDataId).update(value).then((res) => {
uni.showToast({
icon: 'none',
title: '修改成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
},
/**
* 获取表单数据
* @param {Object} id
*/
getDetail(id) {
uni.showLoading({
mask: true
})
db.collection(dbCollectionName).doc(id).field(
"dictName,dictCode,description,delFlag,createBy,updateBy,updateTime,createTime").get().then((
res) => {
const data = res.result.data[0]
if (data) {
console.log(data)
this.formData = data
}
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
}).finally(() => {
uni.hideLoading()
})
}
}
}
</script>
<style>
.uni-container {
padding: 0px;
}
.uni-input-border,
.uni-textarea-border {
width: 100%;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
box-sizing: border-box;
}
.uni-input-border {
padding: 0 10px;
height: 35px;
}
.uni-textarea-border {
padding: 10px;
height: 80px;
}
.uni-button-group {
margin-top: 50px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.uni-button {
width: 184px;
}
</style>

View File

@ -0,0 +1,151 @@
<template>
<view class="container">
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="数据字典 列表" @clickLeft="back" />
<view>
<uni-title title="字典列表" align="center"></uni-title>
<uni-card>
<unicloud-db ref="udb" v-slot:default="{data, pagination, loading, hasMore, error}"
:collection="collectionList"
field="dictName,dictCode,description,delFlag,createBy,updateBy,updateTime,createTime">
<view v-if="error">{{error.message}}</view>
<view v-else-if="data">
<!-- <scroll-view :scroll-y="true" style="height: 30vh;"> -->
<zb-table :show-header="true" :columns="column" :stripe="true" :fit="false"
:isShowLoadMore="true" :border="true" @detail="buttonDetail" :data="data"></zb-table>
<!-- </scroll-view> -->
<view class="uni-pagination-box"><uni-pagination show-icon :page-size="pagination.size"
:total="pagination.count" @change="onpagination" /></view>
</view>
<uni-load-more :status="loading?'loading':(hasMore ? 'more' : 'noMore')"></uni-load-more>
</unicloud-db>
</uni-card>
<uni-fab ref="fab" horizontal="right" vertical="bottom" :pop-menu="false" @fabClick="fabClick" />
</view>
</view>
</template>
<script>
const db = uniCloud.database()
export default {
components: {
},
data() {
return {
collectionList: "ngTools_Dict",
loadMore: {
contentdown: '',
contentrefresh: '',
contentnomore: ''
},
tableData: [],
//
pageSize: 2,
//
pageCurrent: 1,
//
total: 0,
loading: false,
column: [{
type: 'selection',
fixed: true,
width: 40,
},
{
name: 'key',
label: '序号',
fixed: false,
width: 60,
emptyString: '--'
},
{
name: 'dictName',
label: '字典名称',
fixed: false,
width: 100,
emptyString: '--'
},
{
name: 'operation',
type: 'operation',
label: '操作',
renders: [{
name: '详情',
func: 'detail' // func @edit
}]
},
]
}
},
onPullDownRefresh() {
this.$refs.udb.loadData({
clear: true
}, () => {
uni.stopPullDownRefresh()
})
},
onReachBottom() {
this.$refs.udb.loadMore()
},
methods: {
onpagination(e) {
console.log(e)
this.pageCurrent = e.current
},
buttonDetail(e) {
uni.navigateTo({
url: './detail?id=' + e._id
})
},
dele(e) {
this.$refs.udb.remove(e._id, {
success: (res) => {
// // list
// uni.navigateTo({
// url: './list'
// })
}
})
},
back() {
uni.navigateBack({
delta: 1
})
},
handleItemClick(id) {
uni.navigateTo({
url: './detail?id=' + id
})
},
fabClick() {
//
uni.navigateTo({
url: './add',
events: {
// ,
refreshData: () => {
this.$refs.udb.loadData({
clear: true
})
}
}
})
}
}
}
</script>
<style>
.uni-button {
/* width: 60px; */
}
</style>

View File

@ -0,0 +1,182 @@
<template>
<view class="uni-container">
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="字典子项 添加" @clickLeft="back" />
<uni-card>
<uni-forms ref="form" :model="formData" validate-trigger="submit" err-show-type="toast">
<uni-forms-item name="dictID" label="字典ID">
<uni-easyinput placeholder="字典ID" v-model="formData.dictID" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="itemText" label="字典项文本">
<uni-easyinput placeholder="字典项文本" v-model="formData.itemText" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="itemValue" label="字典项值">
<uni-easyinput type="textarea" maxlength="-1" placeholder="字典项值" v-model="formData.itemValue"
trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="itemColor" label="字典项颜色">
<uni-easyinput placeholder="字典项颜色" v-model="formData.itemColor" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="description" label="描述">
<uni-easyinput placeholder="描述" v-model="formData.description" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="sortOrder" label="排序">
<uni-easyinput placeholder="排序" v-model="formData.sortOrder" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="status" label="状态">
<uni-easyinput placeholder="状态" type="number" v-model="formData.status"></uni-easyinput>
</uni-forms-item>
<!-- <uni-forms-item name="createBy" label="创建人">
<uni-easyinput placeholder="创建人" v-model="formData.createBy" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="updateBy" label="更新人">
<uni-easyinput placeholder="更新人" v-model="formData.updateBy" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="createTime" label="创建时间">
<uni-datetime-picker v-model="formData.createTime"></uni-datetime-picker>
</uni-forms-item>
<uni-forms-item name="updateTime" label="更新时间">
<uni-datetime-picker v-model="formData.updateTime"></uni-datetime-picker>
</uni-forms-item> -->
<view class="uni-button-group">
<button type="primary" size="mini" class="uni-button" @click="submit">提交</button>
</view>
</uni-forms>
</uni-card>
</view>
</template>
<script>
import {
validator
} from '../../js_sdk/validator/ngTools_DictItem.js';
const db = uniCloud.database();
const dbCollectionName = 'ngTools_DictItem';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.indexOf(key) > -1) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"dictID": "",
"itemValue": "",
"itemText": "",
"itemColor": "",
"description": "",
"sortOrder": "",
"status": null,
"createBy": "",
"updateBy": "",
"createTime": null,
"updateTime": null
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
},
dictID:""
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
onLoad(e) {
console.log(e)
this.formData.dictID=e.dictID
},
methods: {
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {}).finally(() => {
uni.hideLoading()
})
},
back() {
uni.navigateBack({
delta: 1
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使 clientDB
return db.collection(dbCollectionName).add(value).then((res) => {
uni.showToast({
icon: 'none',
title: '新增成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
}
}
}
</script>
<style>
.uni-container {
padding: 0px;
}
.uni-input-border,
.uni-textarea-border {
width: 100%;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
box-sizing: border-box;
}
.uni-input-border {
padding: 0 10px;
height: 35px;
}
.uni-textarea-border {
padding: 10px;
height: 80px;
}
.uni-button-group {
margin-top: 50px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.uni-button {
width: 184px;
}
</style>

View File

@ -0,0 +1,159 @@
<template>
<view class="container">
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="字典子项 详情" @clickLeft="back" />
<uni-card>
<unicloud-db ref="udb" v-slot:default="{data, loading, error, options}" :options="options"
:collection="collectionList"
field="dictID,itemValue,itemText,itemColor,description,sortOrder,status,createBy,updateBy,createTime,updateTime"
:where="queryWhere" :getone="true" :manual="true">
<view v-if="error">{{error.message}}</view>
<view v-else-if="loading">
<uni-load-more :contentText="loadMore" status="loading"></uni-load-more>
</view>
<view v-else-if="data">
<uni-row>
<uni-col :span="6">
<uni-title title="字典ID"></uni-title>
</uni-col>
<uni-col :push='2' :span="14">
<uni-title :title="data.dictID"></uni-title>
</uni-col>
</uni-row>
<uni-row>
<uni-col :span="6">
<uni-title title="字典项文本"></uni-title>
</uni-col>
<uni-col :push='2' :span="14">
<uni-title :title="data.itemText"></uni-title>
</uni-col>
</uni-row>
<uni-row>
<uni-col :span="6">
<uni-title title="字典项值"></uni-title>
</uni-col>
<uni-col :push='2' :span="14">
<uni-title :title="data.itemValue"></uni-title>
</uni-col>
</uni-row>
<uni-row>
<uni-col :span="6">
<uni-title title="状态"></uni-title>
</uni-col>
<uni-col :push='2' :span="14">
<uni-title :title="data.status"></uni-title>
</uni-col>
</uni-row>
<uni-row>
<uni-col :span="6">
<uni-title title="排序"></uni-title>
</uni-col>
<uni-col :push='2' :span="14">
<uni-title :title="data.sortOrder"></uni-title>
</uni-col>
</uni-row>
<uni-row>
<uni-col :span="6">
<uni-title title="创建人"></uni-title>
</uni-col>
<uni-col :push='2' :span="14">
<uni-title :title="data.createBy"></uni-title>
</uni-col>
</uni-row>
</view>
</unicloud-db>
<view class="btns">
<button type="primary" size="mini" @click="handleUpdate">修改</button>
<button type="warn" size="mini" class="btn-delete" @click="handleDelete">删除</button>
</view>
</uni-card>
</view>
</template>
<script>
// schema2codeenum
import {
enumConverter
} from '../../js_sdk/validator/ngTools_DictItem.js'
const db = uniCloud.database()
export default {
data() {
return {
queryWhere: '',
collectionList: "ngTools_DictItem",
loadMore: {
contentdown: '',
contentrefresh: '',
contentnomore: ''
},
options: {
// scheme enum valuetext
...enumConverter
}
}
},
onLoad(e) {
this._id = e.id
},
onReady() {
if (this._id) {
this.queryWhere = '_id=="' + this._id + '"'
}
},
methods: {
handleUpdate() {
//
uni.navigateTo({
url: './edit?id=' + this._id,
events: {
// ,
refreshData: () => {
this.$refs.udb.loadData({
clear: true
})
}
}
})
},back() {
uni.navigateBack({
delta: 1
})
},
handleDelete() {
this.$refs.udb.remove(this._id, {
success: (res) => {
// list
uni.navigateTo({
url: './list'
})
}
})
}
}
}
</script>
<style>
.container {
padding: 0px;
}
.btns {
margin-top: 10px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
}
.btns button {
flex: 1;
}
.btn-delete {
margin-left: 40px;
}
</style>

View File

@ -0,0 +1,208 @@
<template>
<view class="uni-container">
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="字典子项 编辑" @clickLeft="back" />
<uni-card> <uni-forms ref="form" :model="formData" validate-trigger="submit" err-show-type="toast">
<uni-forms-item name="dictID" label="字典ID">
<uni-easyinput placeholder="字典ID" v-model="formData.dictID" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="itemText" label="子项文本">
<uni-easyinput placeholder="子项文本" v-model="formData.itemText" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="itemValue" label="字典项值">
<uni-easyinput placeholder="字典项值" type="textarea" maxlength="-1" v-model="formData.itemValue"
trim="both"></uni-easyinput>
</uni-forms-item>
<!-- <uni-forms-item name="itemColor" label="子项颜色">
<uni-easyinput placeholder="字典项颜色" v-model="formData.itemColor" trim="both"></uni-easyinput>
</uni-forms-item> -->
<uni-forms-item name="description" label="描述">
<uni-easyinput placeholder="描述" v-model="formData.description" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="sortOrder" label="排序">
<uni-easyinput placeholder="排序" v-model="formData.sortOrder" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="status" label="状态">
<uni-easyinput placeholder="状态" type="number" v-model="formData.status"></uni-easyinput>
</uni-forms-item>
<!-- <uni-forms-item name="createBy" label="创建人">
<uni-easyinput placeholder="创建人" v-model="formData.createBy" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="updateBy" label="更新人">
<uni-easyinput placeholder="更新人" v-model="formData.updateBy" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="createTime" label="创建时间">
<uni-datetime-picker v-model="formData.createTime"></uni-datetime-picker>
</uni-forms-item>
<uni-forms-item name="updateTime" label="更新时间">
<uni-datetime-picker v-model="formData.updateTime"></uni-datetime-picker>
</uni-forms-item> -->
<view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button>
</view>
</uni-forms>
</uni-card>
</view>
</template>
<script>
import {
validator
} from '../../js_sdk/validator/ngTools_DictItem.js';
const db = uniCloud.database();
const dbCollectionName = 'ngTools_DictItem';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.indexOf(key) > -1) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"dictID": "",
"itemValue": "",
"itemText": "",
"itemColor": "",
"description": "",
"sortOrder": "",
"status": null,
"createBy": "",
"updateBy": "",
"createTime": null,
"updateTime": null
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onLoad(e) {
if (e.id) {
const id = e.id
this.formDataId = id
this.getDetail(id)
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使 clientDB
return db.collection(dbCollectionName).doc(this.formDataId).update(value).then((res) => {
uni.showToast({
icon: 'none',
title: '修改成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
},
back() {
uni.navigateBack({
delta: 1
})
},
/**
* 获取表单数据
* @param {Object} id
*/
getDetail(id) {
uni.showLoading({
mask: true
})
db.collection(dbCollectionName).doc(id).field(
"dictID,itemValue,itemText,itemColor,description,sortOrder,status,createBy,updateBy,createTime,updateTime"
).get().then((res) => {
const data = res.result.data[0]
if (data) {
this.formData = data
}
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
}).finally(() => {
uni.hideLoading()
})
}
}
}
</script>
<style>
.uni-container {
padding: 0px;
}
.uni-input-border,
.uni-textarea-border {
width: 100%;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
box-sizing: border-box;
}
.uni-input-border {
padding: 0 10px;
height: 35px;
}
.uni-textarea-border {
padding: 10px;
height: 80px;
}
.uni-button-group {
margin-top: 50px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.uni-button {
width: 184px;
}
</style>

View File

@ -0,0 +1,165 @@
<template>
<view class="container">
<!-- <uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="字典子项 列表" @clickLeft="back" /> -->
<unicloud-db ref="udb" v-slot:default="{data, pagination, loading, hasMore, error}"
:collection="collectionList"
field="dictID,itemValue,itemText,itemColor,description,sortOrder,status,createBy,updateBy,createTime,updateTime"
:where="wherecondition">
<view v-if="error">{{error.message}}</view>
<view v-else-if="data">
<zb-table :show-header="true" :columns="column" :stripe="true" :fit="false" :border="true"
@itemEdit="buttonEdit" :data="data"></zb-table>
<view class="uni-pagination-box"><uni-pagination show-icon :page-size="pagination.size"
:total="pagination.count" @change="onpagination" /></view>
</view>
<uni-load-more :status="loading?'loading':(hasMore ? 'more' : 'noMore')"></uni-load-more>
</unicloud-db>
<uni-fab ref="fab" horizontal="right" vertical="bottom" :pop-menu="false" @fabClick="fabClick" />
</view>
</template>
<script>
const db = uniCloud.database()
export default {
props: {
dictID: {
type: String,
default: "cyzf"
},
},
watch: {
dictID: {
immediate: true,
deep: true,
handler(val) {
this.wherecondition = "'dictID'=='" + val + "'";
}
},
},
data() {
return {
collectionList: "ngTools_DictItem",
wherecondition: "",
loadMore: {
contentdown: '',
contentrefresh: '',
contentnomore: ''
},
column: [
// {
// type: 'selection',
// fixed: true,
// width: 40
// },
{
name: 'key',
label: '序号',
fixed: false,
width: 40,
emptyString: '--'
},
{
name: 'itemText',
label: '字典文本',
width: 80,
align: 'center',
}, {
name: 'itemValue',
label: '字典项值',
fixed: false,
// width: 100,
emptyString: '--'
},
{
name: 'operation',
type: 'operation',
label: '操作',
width: 80,
renders: [{
name: '编辑',
func: 'itemEdit' // func @edit
},
// {
// name: '',
// type: 'warn',
// func: "dele"
// },
]
},
]
}
},
onPullDownRefresh() {
this.$refs.udb.loadData({
clear: true
}, () => {
uni.stopPullDownRefresh()
})
},
onReachBottom() {
this.$refs.udb.loadMore()
},
methods: {
onpagination(e) {
console.log(e)
this.pageCurrent = e.current
},
buttonEdit(e) {
uni.navigateTo({
url: '/pages/ngTools_DictItem/edit?id=' + e._id
})
},
dele() {
},
back() {
uni.navigateBack({
delta: 1
})
},
fabClick() {
//
uni.navigateTo({
url: '/pages/ngTools_DictItem/add?dictID=' + this.dictID,
events: {
// ,
refreshData: () => {
this.$refs.udb.loadData({
clear: true
})
}
}
})
}
}
}
</script>
<style lang="scss">
.uTd {
// background-color: #f1dada;
width: 180rpx;
padding: 10rpx 0rpx 0rpx;
// letter-spacing: 1rpx;
// line-height: 40rpx;
overflow: hidden;
-webkit-line-clamp: 1;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
// display: inline-block;
white-space: pre-wrap;
word-wrap: break-word;
height: auto;
}
</style>

View File

@ -0,0 +1,145 @@
<template>
<view class="uni-container">
<uni-forms ref="form" :model="formData" validate-trigger="submit" err-show-type="toast">
<uni-forms-item name="dMeterType" label="流量计类别">
<uni-easyinput placeholder="流量计类别" v-model="formData.dMeterType" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="departID" label="部门编号">
<uni-easyinput placeholder="部门编号" v-model="formData.departID" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="createBy" label="创建人">
<uni-easyinput placeholder="创建人" v-model="formData.createBy" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="updateBy" label="更新人">
<uni-easyinput placeholder="更新人" v-model="formData.updateBy" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="createTime" label="创建时间">
<uni-datetime-picker v-model="formData.createTime"></uni-datetime-picker>
</uni-forms-item>
<uni-forms-item name="updateTime" label="更新时间">
<uni-datetime-picker v-model="formData.updateTime"></uni-datetime-picker>
</uni-forms-item>
<view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button>
</view>
</uni-forms>
</view>
</template>
<script>
import { validator } from '../../js_sdk/validator/ngTools_MeterList.js';
const db = uniCloud.database();
const dbCollectionName = 'ngTools_MeterList';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.indexOf(key) > -1) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"dMeterType": "",
"departID": "",
"createBy": "",
"updateBy": "",
"createTime": null,
"updateTime": null
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {
}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使 clientDB
return db.collection(dbCollectionName).add(value).then((res) => {
uni.showToast({
icon: 'none',
title: '新增成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
}
}
}
</script>
<style>
.uni-container {
padding: 15px;
}
.uni-input-border,
.uni-textarea-border {
width: 100%;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
box-sizing: border-box;
}
.uni-input-border {
padding: 0 10px;
height: 35px;
}
.uni-textarea-border {
padding: 10px;
height: 80px;
}
.uni-button-group {
margin-top: 50px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.uni-button {
width: 184px;
}
</style>

View File

@ -0,0 +1,120 @@
<template>
<view class="container">
<unicloud-db ref="udb" v-slot:default="{data, loading, error, options}" :options="options" :collection="collectionList" field="dMeterType,departID,createBy,updateBy,createTime,updateTime" :where="queryWhere" :getone="true" :manual="true">
<view v-if="error">{{error.message}}</view>
<view v-else-if="loading">
<uni-load-more :contentText="loadMore" status="loading"></uni-load-more>
</view>
<view v-else-if="data">
<view>
<text>流量计类别</text>
<text>{{data.dMeterType}}</text>
</view>
<view>
<text>部门编号</text>
<text>{{data.departID}}</text>
</view>
<view>
<text>创建人</text>
<text>{{data.createBy}}</text>
</view>
<view>
<text>更新人</text>
<text>{{data.updateBy}}</text>
</view>
<view>
<text>创建时间</text>
<text>{{data.createTime}}</text>
</view>
<view>
<text>更新时间</text>
<text>{{data.updateTime}}</text>
</view>
</view>
</unicloud-db>
<view class="btns">
<button type="primary" @click="handleUpdate">修改</button>
<button type="warn" class="btn-delete" @click="handleDelete">删除</button>
</view>
</view>
</template>
<script>
// schema2codeenum
import { enumConverter } from '../../js_sdk/validator/ngTools_MeterList.js'
const db = uniCloud.database()
export default {
data() {
return {
queryWhere: '',
collectionList: "ngTools_MeterList",
loadMore: {
contentdown: '',
contentrefresh: '',
contentnomore: ''
},
options: {
// scheme enum valuetext
...enumConverter
}
}
},
onLoad(e) {
this._id = e.id
},
onReady() {
if (this._id) {
this.queryWhere = '_id=="' + this._id + '"'
}
},
methods: {
handleUpdate() {
//
uni.navigateTo({
url: './edit?id=' + this._id,
events: {
// ,
refreshData: () => {
this.$refs.udb.loadData({
clear: true
})
}
}
})
},
handleDelete() {
this.$refs.udb.remove(this._id, {
success: (res) => {
// list
uni.navigateTo({
url: './list'
})
}
})
}
}
}
</script>
<style>
.container {
padding: 10px;
}
.btns {
margin-top: 10px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
}
.btns button {
flex: 1;
}
.btn-delete {
margin-left: 10px;
}
</style>

View File

@ -0,0 +1,176 @@
<template>
<view class="uni-container">
<uni-forms ref="form" :model="formData" validate-trigger="submit" err-show-type="toast">
<uni-forms-item name="dMeterType" label="流量计类别">
<uni-easyinput placeholder="流量计类别" v-model="formData.dMeterType" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="departID" label="部门编号">
<uni-easyinput placeholder="部门编号" v-model="formData.departID" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="createBy" label="创建人">
<uni-easyinput placeholder="创建人" v-model="formData.createBy" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="updateBy" label="更新人">
<uni-easyinput placeholder="更新人" v-model="formData.updateBy" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="createTime" label="创建时间">
<uni-datetime-picker v-model="formData.createTime"></uni-datetime-picker>
</uni-forms-item>
<uni-forms-item name="updateTime" label="更新时间">
<uni-datetime-picker v-model="formData.updateTime"></uni-datetime-picker>
</uni-forms-item>
<view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button>
</view>
</uni-forms>
</view>
</template>
<script>
import { validator } from '../../js_sdk/validator/ngTools_MeterList.js';
const db = uniCloud.database();
const dbCollectionName = 'ngTools_MeterList';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.indexOf(key) > -1) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"dMeterType": "",
"departID": "",
"createBy": "",
"updateBy": "",
"createTime": null,
"updateTime": null
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onLoad(e) {
if (e.id) {
const id = e.id
this.formDataId = id
this.getDetail(id)
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {
}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使 clientDB
return db.collection(dbCollectionName).doc(this.formDataId).update(value).then((res) => {
uni.showToast({
icon: 'none',
title: '修改成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
},
/**
* 获取表单数据
* @param {Object} id
*/
getDetail(id) {
uni.showLoading({
mask: true
})
db.collection(dbCollectionName).doc(id).field("dMeterType,departID,createBy,updateBy,createTime,updateTime").get().then((res) => {
const data = res.result.data[0]
if (data) {
this.formData = data
}
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
}).finally(() => {
uni.hideLoading()
})
}
}
}
</script>
<style>
.uni-container {
padding: 15px;
}
.uni-input-border,
.uni-textarea-border {
width: 100%;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
box-sizing: border-box;
}
.uni-input-border {
padding: 0 10px;
height: 35px;
}
.uni-textarea-border {
padding: 10px;
height: 80px;
}
.uni-button-group {
margin-top: 50px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.uni-button {
width: 184px;
}
</style>

View File

@ -0,0 +1,72 @@
<template>
<view class="container">
<unicloud-db ref="udb" v-slot:default="{data, pagination, loading, hasMore, error}" :collection="collectionList" field="dMeterType,departID,createBy,updateBy,createTime,updateTime">
<view v-if="error">{{error.message}}</view>
<view v-else-if="data">
<uni-list>
<uni-list-item v-for="(item, index) in data" :key="index" showArrow :clickable="true" @click="handleItemClick(item._id)">
<template v-slot:body>
<text>
<!-- 此处默认显示为_id请根据需要自行修改为其他字段 -->
<!-- 如果使用了联表查询请参考生成的 admin 项目中 list.vue 页面 -->
{{item._id}}
</text>
</template>
</uni-list-item>
</uni-list>
</view>
<uni-load-more :status="loading?'loading':(hasMore ? 'more' : 'noMore')"></uni-load-more>
</unicloud-db>
<uni-fab ref="fab" horizontal="right" vertical="bottom" :pop-menu="false" @fabClick="fabClick" />
</view>
</template>
<script>
const db = uniCloud.database()
export default {
data() {
return {
collectionList: "ngTools_MeterList",
loadMore: {
contentdown: '',
contentrefresh: '',
contentnomore: ''
}
}
},
onPullDownRefresh() {
this.$refs.udb.loadData({
clear: true
}, () => {
uni.stopPullDownRefresh()
})
},
onReachBottom() {
this.$refs.udb.loadMore()
},
methods: {
handleItemClick(id) {
uni.navigateTo({
url: './detail?id=' + id
})
},
fabClick() {
//
uni.navigateTo({
url: './add',
events: {
// ,
refreshData: () => {
this.$refs.udb.loadData({
clear: true
})
}
}
})
}
}
}
</script>
<style>
</style>

View File

@ -0,0 +1,129 @@
<template>
<view class="uni-container">
<uni-forms ref="form" :model="formData" validate-trigger="submit" err-show-type="toast">
<uni-forms-item name="samplingLocation" label="取样地点">
<uni-easyinput placeholder="取样地点" v-model="formData.samplingLocation" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="departName" label="单位名称">
<uni-easyinput placeholder="单位名称" v-model="formData.departName" trim="both"></uni-easyinput>
</uni-forms-item>
<view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button>
</view>
</uni-forms>
</view>
</template>
<script>
import { validator } from '../../js_sdk/validator/ngTools_SamplingLocation.js';
const db = uniCloud.database();
const dbCollectionName = 'ngTools_SamplingLocation';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.indexOf(key) > -1) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"samplingLocation": "",
"departName": ""
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {
}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使 clientDB
return db.collection(dbCollectionName).add(value).then((res) => {
uni.showToast({
icon: 'none',
title: '新增成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
}
}
}
</script>
<style>
.uni-container {
padding: 15px;
}
.uni-input-border,
.uni-textarea-border {
width: 100%;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
box-sizing: border-box;
}
.uni-input-border {
padding: 0 10px;
height: 35px;
}
.uni-textarea-border {
padding: 10px;
height: 80px;
}
.uni-button-group {
margin-top: 50px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.uni-button {
width: 184px;
}
</style>

View File

@ -0,0 +1,104 @@
<template>
<view class="container">
<unicloud-db ref="udb" v-slot:default="{data, loading, error, options}" :options="options" :collection="collectionList" field="samplingLocation,departName" :where="queryWhere" :getone="true" :manual="true">
<view v-if="error">{{error.message}}</view>
<view v-else-if="loading">
<uni-load-more :contentText="loadMore" status="loading"></uni-load-more>
</view>
<view v-else-if="data">
<view>
<text>取样地点</text>
<text>{{data.samplingLocation}}</text>
</view>
<view>
<text>单位名称</text>
<text>{{data.departName}}</text>
</view>
</view>
</unicloud-db>
<view class="btns">
<button type="primary" @click="handleUpdate">修改</button>
<button type="warn" class="btn-delete" @click="handleDelete">删除</button>
</view>
</view>
</template>
<script>
// schema2codeenum
import { enumConverter } from '../../js_sdk/validator/ngTools_SamplingLocation.js'
const db = uniCloud.database()
export default {
data() {
return {
queryWhere: '',
collectionList: "ngTools_SamplingLocation",
loadMore: {
contentdown: '',
contentrefresh: '',
contentnomore: ''
},
options: {
// scheme enum valuetext
...enumConverter
}
}
},
onLoad(e) {
this._id = e.id
},
onReady() {
if (this._id) {
this.queryWhere = '_id=="' + this._id + '"'
}
},
methods: {
handleUpdate() {
//
uni.navigateTo({
url: './edit?id=' + this._id,
events: {
// ,
refreshData: () => {
this.$refs.udb.loadData({
clear: true
})
}
}
})
},
handleDelete() {
this.$refs.udb.remove(this._id, {
success: (res) => {
// list
uni.navigateTo({
url: './list'
})
}
})
}
}
}
</script>
<style>
.container {
padding: 10px;
}
.btns {
margin-top: 10px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
}
.btns button {
flex: 1;
}
.btn-delete {
margin-left: 10px;
}
</style>

View File

@ -0,0 +1,160 @@
<template>
<view class="uni-container">
<uni-forms ref="form" :model="formData" validate-trigger="submit" err-show-type="toast">
<uni-forms-item name="samplingLocation" label="取样地点">
<uni-easyinput placeholder="取样地点" v-model="formData.samplingLocation" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="departName" label="单位名称">
<uni-easyinput placeholder="单位名称" v-model="formData.departName" trim="both"></uni-easyinput>
</uni-forms-item>
<view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button>
</view>
</uni-forms>
</view>
</template>
<script>
import { validator } from '../../js_sdk/validator/ngTools_SamplingLocation.js';
const db = uniCloud.database();
const dbCollectionName = 'ngTools_SamplingLocation';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.indexOf(key) > -1) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"samplingLocation": "",
"departName": ""
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onLoad(e) {
if (e.id) {
const id = e.id
this.formDataId = id
this.getDetail(id)
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {
}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使 clientDB
return db.collection(dbCollectionName).doc(this.formDataId).update(value).then((res) => {
uni.showToast({
icon: 'none',
title: '修改成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
},
/**
* 获取表单数据
* @param {Object} id
*/
getDetail(id) {
uni.showLoading({
mask: true
})
db.collection(dbCollectionName).doc(id).field("samplingLocation,departName").get().then((res) => {
const data = res.result.data[0]
if (data) {
this.formData = data
}
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
}).finally(() => {
uni.hideLoading()
})
}
}
}
</script>
<style>
.uni-container {
padding: 15px;
}
.uni-input-border,
.uni-textarea-border {
width: 100%;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
box-sizing: border-box;
}
.uni-input-border {
padding: 0 10px;
height: 35px;
}
.uni-textarea-border {
padding: 10px;
height: 80px;
}
.uni-button-group {
margin-top: 50px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.uni-button {
width: 184px;
}
</style>

View File

@ -0,0 +1,72 @@
<template>
<view class="container">
<unicloud-db ref="udb" v-slot:default="{data, pagination, loading, hasMore, error}" :collection="collectionList" field="samplingLocation,departName">
<view v-if="error">{{error.message}}</view>
<view v-else-if="data">
<uni-list>
<uni-list-item v-for="(item, index) in data" :key="index" showArrow :clickable="true" @click="handleItemClick(item._id)">
<template v-slot:body>
<text>
<!-- 此处默认显示为_id请根据需要自行修改为其他字段 -->
<!-- 如果使用了联表查询请参考生成的 admin 项目中 list.vue 页面 -->
{{item._id}}
</text>
</template>
</uni-list-item>
</uni-list>
</view>
<uni-load-more :status="loading?'loading':(hasMore ? 'more' : 'noMore')"></uni-load-more>
</unicloud-db>
<uni-fab ref="fab" horizontal="right" vertical="bottom" :pop-menu="false" @fabClick="fabClick" />
</view>
</template>
<script>
const db = uniCloud.database()
export default {
data() {
return {
collectionList: "ngTools_SamplingLocation",
loadMore: {
contentdown: '',
contentrefresh: '',
contentnomore: ''
}
}
},
onPullDownRefresh() {
this.$refs.udb.loadData({
clear: true
}, () => {
uni.stopPullDownRefresh()
})
},
onReachBottom() {
this.$refs.udb.loadMore()
},
methods: {
handleItemClick(id) {
uni.navigateTo({
url: './detail?id=' + id
})
},
fabClick() {
//
uni.navigateTo({
url: './add',
events: {
// ,
refreshData: () => {
this.$refs.udb.loadData({
clear: true
})
}
}
})
}
}
}
</script>
<style>
</style>

View File

@ -0,0 +1,198 @@
<template>
<view class="uni-container">
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="添加部门" @clickLeft="back" />
<uni-card>
<uni-forms ref="form" :model="formData" validate-trigger="submit" err-show-type="toast">
<!-- <uni-forms-item name="parent_id" label="父级部门ID">
<uni-easyinput placeholder="父级部门ID" v-model="formData.parent_id"></uni-easyinput>
</uni-forms-item> -->
<uni-forms-item name="父级部门" label="父级部门">
<depart-select @change="onselectionchange"></depart-select>
</uni-forms-item>
<uni-forms-item name="depart_name" label="部门名称">
<uni-easyinput placeholder="部门名称" v-model="formData.depart_name" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="level" label="部门层级">
<uni-easyinput placeholder="部门层级,为提升检索效率而作的冗余设计" type="number"
v-model="formData.level"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="sort" label="显示顺序">
<uni-easyinput placeholder="部门在当前层级下的顺序,由小到大" type="number" v-model="formData.sort"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="manager_uid" label="部门主管用户">
<uni-easyinput placeholder="部门主管的userid 参考`uni-id-users` 表"
v-model="formData.manager_uid"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="status" label="部门状态">
<radio-group>
<radio :checked="true" @click="formData.status=0">正常</radio>
<radio :checked="false" @click="formData.status=1">禁用</radio>
</radio-group>
</uni-forms-item>
</uni-forms>
</uni-card>
<view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button>
</view>
</view>
</template>
<script>
import {
validator
} from '../../js_sdk/validator/ngTools_depart.js';
import {
getJsonTree,
groupBy
} from "@/js_sdk/util/jsonData";
import {
getDictItemStore,
getDepartStore,
saveDepartStore
} from '@/js_sdk/util/dictTools.js';
import departSelect from './depart_select.vue';
const db = uniCloud.database();
const dbCollectionName = 'ngTools_depart';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.indexOf(key) > -1) {
result[key] = validator[key]
}
}
return result
}
export default {
components: {
departSelect
},
data() {
let formData = {
"parent_id": "",
"depart_name": "",
"level": null,
"sort": null,
"manager_uid": "",
"status": null
}
return {
formData,
parentID: "",
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onLoad(e) {
console.log(e)
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
onselectionchange(selectDepartID) {
// console.log(selectDepartID)
this.parentID = selectDepartID;
// console.log(this.formData)
},
back() {
uni.navigateBack({
delta: 1
})
},
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
res.parent_id = this.parentID;
return this.submitForm(res)
})
.catch(() => {
})
.finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使 clientDB
return db.collection(dbCollectionName).add(value).then((res) => {
uni.showToast({
icon: 'none',
title: '新增成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => {
console.log("s")
saveDepartStore();
console.log("e")
uni.navigateBack()
}, 500)
}).catch((err) => {
uni.showModal({
content: err.message + '请求服务失败',
showCancel: false
})
})
}
}
}
</script>
<style>
.uni-container {
padding: 0px;
}
.uni-input-border,
.uni-textarea-border {
width: 100%;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
box-sizing: border-box;
}
.uni-input-border {
padding: 0 10px;
height: 35px;
}
.uni-textarea-border {
padding: 10px;
height: 80px;
}
.uni-button-group {
margin-top: 50px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.uni-button {
width: 184px;
}
</style>

View File

@ -0,0 +1,246 @@
<template>
<view>
<view style="padding:10px;color: #333;font-weight: 500;">
<view style="padding: 10px 0"><text>1设置单选和父级不可选</text></view>
<button style="width: 100%;background-color: #f9ae3d;color:#fff" size="mini" @click="itemclick(false, false)">设置</button>
<view style="padding: 10px 0"><text>2设置多选和父级不可选</text></view>
<button style="width: 100%;background-color: #f9ae3d;color:#fff" size="mini" @click="itemclick(true, false)">设置</button>
<view style="padding: 10px 0"><text>3设置单选和父级可选</text></view>
<button style="width: 100%;background-color: #f9ae3d;color:#fff" size="mini" @click="itemclick(false, true)">设置</button>
<view style="padding: 10px 0"><text>4设置多选和父级可选</text></view>
<button style="width: 100%;background-color: #f9ae3d;color:#fff" size="mini" @click="itemclick(true, true)" >设置</button>
<view style="padding: 10px 0"><text>4设置多选和父级可选和父级关联子级选择</text></view>
<button style="width: 100%;background-color: #f9ae3d;color:#fff" size="mini" @click="itemclick(true, true, true)" >设置</button>
<view style="padding: 10px 0"><text>5设置默认回显(默认选中: '上海-2', '黄埔区-35')</text></view>
<button style="width: 100%;background-color: #f9ae3d;color:#fff" size="mini" @click="echoDefault()" >设置</button>
<!-- 异步加载demo -->
<view style="padding: 10px 0"><text>6异步加载渲染demo</text></view>
<button style="width: 100%;background-color: #f9ae3d;color:#fff" size="mini" @click="openTree()" >设置</button>
</view>
<!-- 异步加载demo -->
<next-tree :selectParent="false" :checkStrictly="true" funcMode="checkbox" ref="nextTreeAsyncRef" :treeData="asyncTreeData" :loadData="loadData" />
<next-tree :expandedKeys="['3','3-1']" :changeVerify="changeVerify" :title="getTitle" ref="nextTreeRef" :checkStrictly="checkStrictly" :selectParent="selectParent" :funcMode="funcMode" :treeData="treeData" @cancel="oncancel" @confirm="onconfirm">
<!-- label插槽示意代码 -->
<!-- <template v-slot:label="{data}">
<view class="line-block">
<image class="img" v-if="data.iconSrc" :src="data.iconSrc"></image>
<text space="nbsp" v-if="data.prev">{{data.prev}}&nbsp;</text><text>{{data.label}}</text><text space="nbsp" v-if="data.post">&nbsp;{{data.post}}</text>
</view>
</template> -->
<!-- <template #topBar>
<view style="color: #666;padding:5px;"><text style="font-size: 12px;">历史记录</text></view>
<view style="display: flex;justify-content: space-between;padding-bottom: 10px;border-bottom: 1rpx solid #f0f0f0;">
<button @click="checkedFunc('1-3-3-4')" :style="'background-color:'+ (activeId === '1-3-3-4' ? '#f9ae3d' : '#ccc') + ';color:#fff;margin: 5px'" size="mini">北京区-4</button>
<button @click="checkedFunc('3-1-2')" :style="'background-color:'+ (activeId === '3-1-2' ? '#f9ae3d' : '#ccc') + ';color:#fff;margin: 5px'" size="mini">海珠区-2</button>
<button @click="checkedFunc('3-1-6')" :style="'background-color:'+ (activeId === '3-1-6' ? '#f9ae3d' : '#ccc') + ';color:#fff;margin: 5px'" size="mini">海珠区-5</button>
</view>
</template> -->
</next-tree>
</view>
</template>
<script>
let self = null;
export default {
data () {
return {
funcMode: 'radio',
selectParent: false,
checkStrictly: false,
activeId: '',
localData:{
'a1': [{id: 'a1-1', label: 'a1-1'}, {id: 'a1-2', label: 'a1-2',children: [] },{id: 'a1-3', label: 'a1-3'}],
'b1': [{id: 'b1-1', label: 'b1-1',children: []}, {id: 'b1-2', label: 'b1-2'},{id: 'b1-3', label: 'b1-3'}],
'c1': [{id: 'c1-1', label: 'c1-1'}, {id: 'c1-2', label: 'c1-2'},{id: 'c1-3', label: 'c1-3',children: []}],
'a1-2': [{id: 'a1-2-1', label: 'a1-2-1'}, {id: 'a1-2-2', label: 'a1-2-2'}],
'b1-1': [{id: 'b1-1-1', label: 'b1-1-1'}, {id: 'b1-1-2', label: 'b1-1-2'}],
'c1-3': [{id: 'c1-3-1', label: 'c1-3-1'}, {id: 'c1-3-2', label: 'c1-3-2'}]
},
asyncTreeData: [{id: 'a1', label: 'a1', children: []},{id: 'b1', label: 'b1', children: []},{id: 'c1', label: 'c1', children: []}],
treeData: [
{id: '1', label: '北京', checked: false},
{id: '2', label: '上海', checked: false, children: [
{id: '2-1', label: '上海-1', checked: false},
{id: '2-2', label: '上海-2', checked: false},
{id: '2-3', label: '上海-3', checked: false},
] },
{id: '3', label: '广州', children: [
{id: '3-1', label: '海珠区', checked: false, children: [
{id: '3-1-1', label: '海珠区-1', checked: false, disabled: true},
{id: '3-1-2', label: '海珠区-2', checked: false},
{id: '3-1-4', label: '海珠区-3', checked: false},
{id: '3-1-5', label: '海珠区-4', checked: false},
{id: '3-1-6', label: '海珠区-5', checked: false},
{id: '3-1-7', label: '海珠区-6', checked: false},
{id: '3-1-8', label: '海珠区-7', checked: false},
{id: '3-1-9', label: '海珠区-8', checked: false},
{id: '3-1-10', label: '海珠区-9', checked: false},
{id: '3-1-11', label: '海珠区-10', checked: false},
]},
{id: '3-2', label: '番禺区', checked: false, children: [
{id: '3-2-1', label: '番禺区-1', checked: false},
{id: '3-2-2', label: '番禺区-2', checked: false},
{id: '3-2-4', label: '番禺区-3', checked: false},
{id: '3-2-5', label: '番禺区-4', checked: false},
{id: '3-2-6', label: '番禺区-5', checked: false},
{id: '3-2-7', label: '番禺区-6', checked: false},
{id: '3-2-8', label: '番禺区-7', checked: false},
{id: '3-2-9', label: '番禺区-8', checked: false},
{id: '3-2-10', label: '番禺区-9', checked: false},
{id: '3-2-11', label: '番禺区-10', checked: false},
]},
{id: '3-3', label: '黄埔区', checked: false, children: [
{id: '3-3-1', label: '黄埔区-1', checked: false},
{id: '3-3-2', label: '黄埔区-2', checked: false},
{id: '3-3-3', label: '黄埔区-3', checked: false},
{id: '3-3-4', label: '黄埔区-4', checked: false},
{id: '3-3-5', label: '黄埔区-5', checked: false},
{id: '3-3-6', label: '黄埔区-6', checked: false},
{id: '3-3-7', label: '黄埔区-7', checked: false},
{id: '3-3-8', label: '黄埔区-8', checked: false},
{id: '3-3-9', label: '黄埔区-9', checked: false},
{id: '3-3-10', label: '黄埔区-10', checked: false},
{id: '3-3-12', label: '黄埔区-11', checked: false},
{id: '3-3-13', label: '黄埔区-12', checked: false},
{id: '3-3-13', label: '黄埔区-13', checked: false},
{id: '3-3-14', label: '黄埔区-14', checked: false},
{id: '3-3-15', label: '黄埔区-15', checked: false},
{id: '3-3-16', label: '黄埔区-16', checked: false},
{id: '3-3-17', label: '黄埔区-17', checked: false},
{id: '3-3-18', label: '黄埔区-18', checked: false},
{id: '3-3-19', label: '黄埔区-19', checked: false},
{id: '3-3-20', label: '黄埔区-20', checked: false},
{id: '3-3-21', label: '黄埔区-21', checked: false},
{id: '3-3-22', label: '黄埔区-22', checked: false},
{id: '3-3-23', label: '黄埔区-23', checked: false},
{id: '3-3-24', label: '黄埔区-24', checked: false},
{id: '3-3-25', label: '黄埔区-25', checked: false},
{id: '3-3-26', label: '黄埔区-26', checked: false},
{id: '3-3-27', label: '黄埔区-27', checked: false},
{id: '3-3-28', label: '黄埔区-28', checked: false},
{id: '3-3-29', label: '黄埔区-29', checked: false},
{id: '3-3-30', label: '黄埔区-30', checked: false},
{id: '3-3-31', label: '黄埔区-31', checked: false},
{id: '3-3-32', label: '黄埔区-32', checked: false},
{id: '3-3-33', label: '黄埔区-33', checked: false},
{id: '3-3-34', label: '黄埔区-34', checked: false},
{id: '3-3-35', label: '黄埔区-35', checked: false},
{id: '3-3-36', label: '黄埔区-36', checked: false},
]},
],
}]
}
},
methods: {
openTree() {
this.$refs.nextTreeAsyncRef.showTree = true
},
changeVerify(current, chooseList) {
//
// return
console.log('当前变化的数据', current)
console.log('已选择的数据', chooseList)
if(chooseList && chooseList.length > 4) {
return '最多可以选择4个节点'
}
},
checkedFunc(id) {
if(this.activeId === id) {
this.activeId = '';
this.$refs.nextTreeRef.checkedFunc(id, false)
} else {
this.activeId = id;
this.$refs.nextTreeRef.checkedFunc(id)
}
},
loadData(data) {
const type = data.$type; //
const source = data.source //
//
if (type === 'nodeLoad') {
const nodeItem = source;
//
// {[this.childrenKey]: []}
// if(nodeItem && this.localData[nodeItem.id]) {
// return this.localData[nodeItem.id]
// } else {
// return []
// }
//
// {[this.childrenKey]: []}
return new Promise((resolve, reject) => {
setTimeout(() => {
if(nodeItem && self.localData[nodeItem.id]) {
return resolve(self.localData[nodeItem.id])
} else {
return resolve([])
}
}, 1000)
})
} else if(type === 'remoteSearch') {
// ...doing
}
},
getTitle(checked) {
return `已选:${checked.length}`
},
echoDefault() {
const selectIds = ['2-1','3-3-35']
this.checkedTreeData(this.treeData, selectIds)
console.log('treeData的数据', this.treeData)
this.funcMode = 'checkbox'
this.$refs.nextTreeRef.showTree = true
},
itemclick(_multiple, _selectParent, _checkStrictly = false) {
this.funcMode = _multiple ? 'checkbox' : 'radio'
this.selectParent = _selectParent
this.checkStrictly = _checkStrictly
this.$refs.nextTreeRef.showTree = true
},
checkedTreeData(treeData, selectIds) {
// vue2treeDatacheckedcheckedtrueui
// 使this.$setcheckedthis.treeDatachecked
(treeData || []).map(item => {
if (selectIds.indexOf(item.id) !== -1) {
item.checked = true
} else {
item.checked = false
}
if (item.children && item.children.length) {
this.checkedTreeData(item.children, selectIds)
}
})
},
onconfirm(list) {
console.log('选中项的数量列表list', list)
},
oncancel() {
// treeData
this.checkedTreeData(this.treeData, [])
}
},
created() {
self = this
}
}
</script>
<style lang="scss">
.line-block {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
.img {
width: 40rpx;
height: 40rpx;
border-radius: 10rpx;
margin: 0 20rpx;
}
}
</style>

View File

@ -0,0 +1,42 @@
<template>
<view class="tree">
<!-- <uni-collapse v-for="(node, index) in treeData" :key="index">
<uni-collapse-item class="uni-collapse-item" :title="node.depart_name">
<view v-if="node.children && node.children.length > 0" >
<tree-node :treeData="node.children"></tree-node>
</view>
</uni-collapse-item>
</uni-collapse> -->
</view>
</template>
<script>
export default {
name: 'TreeNode',
props: {
treeData: Array
}
}
</script>
<style>
.tree-node {
margin-left: 20px;
}
.node-content {
/* 样式根据需要自定义 */
}
.node-children {
margin-left: 15px;
}
.uni-collapse-item {
margin-left: 15px; /* 层级缩进的距离 */
}
.uni-collapse-item:first-child {
margin-left: 0; /* 第一项无缩进 */
}
</style>

View File

@ -0,0 +1,161 @@
.next-tree-mask {
position: fixed;
top: 0rpx;
right: 0rpx;
bottom: 0rpx;
left: 0rpx;
z-index: 9998;
background-color: rgba(0, 0, 0, 0.6);
opacity: 0;
transition: all 0.3s ease;
visibility: hidden;
}
.next-tree-mask.show {
visibility: visible;
opacity: 1;
}
.next-tree-cnt {
position: fixed;
top: 0rpx;
right: 0rpx;
bottom: 0rpx;
left: 0rpx;
z-index: 9999;
top: 160rpx;
transition: all 0.3s ease;
transform: translateY(100%);
}
.next-tree-cnt.show {
transform: translateY(0);
}
.next-tree-bar {
background-color: #fff;
height: 72rpx;
padding-left: 20rpx;
padding-right: 20rpx;
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
border-bottom-width: 1rpx !important;
border-bottom-style: solid;
border-bottom-color: #f5f5f5;
font-size: 32rpx;
color: #757575;
line-height: 1;
}
.next-tree-bar-confirm {
color: #f9ae3d;
}
.next-tree-view {
position: absolute;
top: 0rpx;
right: 0rpx;
bottom: 0rpx;
left: 0rpx;
top: 72rpx;
background-color: #fff;
padding-top: 20rpx;
padding-right: 20rpx;
padding-bottom: 20rpx;
padding-left: 20rpx;
}
.next-tree-view-sc {
height: 100%;
overflow: hidden;
}
.next-tree-item {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 26rpx;
color: #757575;
line-height: 1;
height: 0;
opacity: 0;
transition: 0.2s;
position: relative;
overflow: hidden;
}
.next-tree-item.show {
height: 80rpx;
opacity: 1;
}
.next-tree-item.showchild:before {
transform: rotate(90deg);
}
.next-tree-item.border {
border-bottom: 1rpx solid rgba(204,204,204,0.2);
}
.next-tree-item.last:before {
opacity: 0;
}
.next-tree-icon {
width: 26rpx;
height: 26rpx;
margin-right: 8rpx;
}
.next-tree-label {
flex: 1;
display: flex;
align-items: center;
height: 100%;
line-height: 1.2;
}
.next-tree-check {
width: 40px;
height: 40px;
display: flex;
justify-content: center;
align-items: center;
}
.next-tree-check-yes,
.next-tree-check-no {
width: 20px;
height: 20px;
border-top-left-radius: 20%;
border-top-right-radius: 20%;
border-bottom-right-radius: 20%;
border-bottom-left-radius: 20%;
border-top-width: 1rpx;
border-left-width: 1rpx;
border-bottom-width: 1rpx;
border-right-width: 1rpx;
border-style: solid;
border-color: #f9ae3d;
display: flex;
justify-content: center;
align-items: center;
box-sizing: border-box;
}
.next-tree-check-yes-b {
border-top-left-radius: 20%;
border-top-right-radius: 20%;
border-bottom-right-radius: 20%;
border-bottom-left-radius: 20%;
background-color: #f9ae3d;
color: #fff;
}
.next-tree-check-yes-b .icon-text {
font-size: 14px;
font-weight: normal;
font-family: uicon-iconfont;
display: flex;
flex-direction: row;
align-items: center;
}
.next-tree-check .radio {
border-top-left-radius: 50%;
border-top-right-radius: 50%;
border-bottom-right-radius: 50%;
border-bottom-left-radius: 50%;
}
.next-tree-check .radio .next-tree-check-yes-b {
border-top-left-radius: 50%;
border-top-right-radius: 50%;
border-bottom-right-radius: 50%;
border-bottom-left-radius: 50%;
}
.hover-c {
opacity: 0.6;
}

View File

@ -0,0 +1,136 @@
<template>
<view>
<uni-easyinput @focus="open" v-model="selectText" placeholder="选择父级部门"></uni-easyinput>
<next-tree ref="nextTreeRef" funcMode="radio" uiMode="popup" :selectParent="true" labelKey="depart_name"
valueKey="_id" :multiple="false" :treeData="departTreeData" @confirm="onnodeclick" @change="onchange">
</next-tree>
</view>
</template>
<script>
import {
getJsonTree,
groupBy
} from "@/js_sdk/util/jsonData";
import {
saveDepartStore,
saveDictItemStore,
getDictItemStore,
getDepartStore
} from '@/js_sdk/util/dictTools.js';
export default {
data() {
return {
departTreeData: [],
selectText: "",
departID: "",
selectIDs:[]
}
},
props: {
selectID: {
type: String,
default: ""
},
},
watch: {
selectID: {
immediate: true,
deep: true,
handler(val) {
console.log(val)
this.departTreeData = getDepartStore()
this.selectIDs=[];
this.selectIDs.push(val)
this.echoDefault(this.selectIDs)
}
}
},
mounted() {
this.departTreeData = getDepartStore()
},
onShow() {
},
methods: {
open() {
this.departTreeData = getDepartStore();
setTimeout(() => {
this.$refs.nextTreeRef.showTree = true;
}, 500)
},
echoDefault(selectIds) {
this.checkedTreeData(this.departTreeData, selectIds)
console.log('treeData的数据', this.departTreeData)
console.log('treeData的选中的', selectIds)
this.funcMode = 'checkbox'
// this.$refs.nextTreeRef.showTree = true
},
checkedTreeData(treeData, selectIds) {
// vue2treeDatacheckedcheckedtrueui
// 使this.$setcheckedthis.treeDatachecked
(treeData || []).map(item => {
if (selectIds.indexOf(item._id) !== -1) {
console.log('v选中的', item)
this.selectText=item.depart_name
this.$emit("change", selectIds[0], this.selectText)
item.checked = true
} else {
item.checked = false
}
if (item.children && item.children.length) {
this.checkedTreeData(item.children, selectIds)
}
})
},
onchange(e) {
console.log("xzzzz---" + JSON.stringify(e))
let temp = this.getTreeName(e);
this.selectText = temp.strName;
let arrID = [];
let departParentID = "";
try {
arrID = temp.strID.split('/')
if (arrID.length > 1) {
departParentID = arrID[arrID.length - 1]
} else {
departParentID = arrID[0]
}
} catch (e) {
//TODO handle the exception
}
console.log(departParentID, this.selectText)
this.$emit("change", departParentID, this.selectText)
},
onnodeclick(e) {
// this.selectText = JSON.stringify(this.getTreeName(e));
// this.$emit("change",e[0]._id,this.selectText)
},
getTreeName(tree) {
// console.log("e", tree)
let treeParents = tree[0].parents
var strName = "";
var strID = "";
if (treeParents.length > 0) {
for (let i = 0; i < treeParents.length; i++) {
strName = strName + treeParents[i].depart_name + "/";
strID = strID + treeParents[i]._id + "/";
}
}
strName = strName + tree[0].depart_name;
strID = strID + tree[0]._id;
return {
"strName": strName,
"strID": strID
}
}
}
}
</script>

View File

@ -0,0 +1,130 @@
<template>
<view class="container">
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="部门详情" @clickLeft="back" />
<unicloud-db ref="udb" v-slot:default="{data, loading, error, options}" :options="options" :collection="collectionList" field="parent_id,depart_name,level,sort,manager_uid,status" :where="queryWhere" :getone="true" :manual="true">
<view v-if="error">{{error.message}}</view>
<view v-else-if="loading">
<uni-load-more :contentText="loadMore" status="loading"></uni-load-more>
</view>
<view v-else-if="data">
<uni-forms ref="form" >
<!-- <uni-forms-item name="parent_id" label="父级部门ID">
<uni-easyinput placeholder="父级部门ID" v-model="formData.parent_id"></uni-easyinput>
</uni-forms-item> -->
<!-- <uni-forms-item name="父级部门" label="父级部门">
<depart-select @change="onselectionchange"></depart-select>
</uni-forms-item> -->
<uni-forms-item name="depart_name" label="部门名称">
<uni-easyinput placeholder="部门名称" v-model="data.depart_name" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="level" label="部门层级">
<uni-easyinput placeholder="部门层级,为提升检索效率而作的冗余设计" type="number" v-model="data.level"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="sort" label="显示顺序">
<uni-easyinput placeholder="部门在当前层级下的顺序,由小到大" type="number" v-model="data.sort"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="manager_uid" label="部门主管用户">
<uni-easyinput placeholder="部门主管的userid 参考`uni-id-users` 表"
v-model="data.manager_uid"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="status" label="部门状态">
<radio-group>
<radio :checked="true" @click="data.status=0">正常</radio>
<radio :checked="false" @click="data.status=1">禁用</radio>
</radio-group>
</uni-forms-item>
</uni-forms>
</view>
</unicloud-db>
<view class="btns">
<button type="primary" @click="handleUpdate">修改</button>
<button type="warn" class="btn-delete" @click="handleDelete">删除</button>
</view>
</view>
</template>
<script>
// schema2codeenum
import { enumConverter } from '../../js_sdk/validator/ngTools_depart.js'
const db = uniCloud.database()
export default {
data() {
return {
queryWhere: '',
collectionList: "ngTools_depart",
loadMore: {
contentdown: '',
contentrefresh: '',
contentnomore: ''
},
options: {
// scheme enum valuetext
...enumConverter
}
}
},
onLoad(e) {
this._id = e.id
},
onReady() {
if (this._id) {
this.queryWhere = '_id=="' + this._id + '"'
}
},
methods: {back() {
uni.navigateBack({
delta: 1
})
},
handleUpdate() {
//
uni.navigateTo({
url: './edit?id=' + this._id,
events: {
// ,
refreshData: () => {
this.$refs.udb.loadData({
clear: true
})
}
}
})
},
handleDelete() {
this.$refs.udb.remove(this._id, {
success: (res) => {
// list
uni.navigateTo({
url: './list'
})
}
})
}
}
}
</script>
<style>
.container {
padding: 0px;
}
.btns {
margin-top: 10px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
}
.btns button {
flex: 1;
}
.btn-delete {
margin-left: 10px;
}
</style>

View File

@ -0,0 +1,209 @@
<template>
<view class="uni-container">
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="编辑部门信息" @clickLeft="back" />
<uni-card>
<uni-forms ref="form" :model="formData" validate-trigger="submit" err-show-type="toast">
<uni-forms-item name="父级部门" label="父级部门">
<depart-select :selectID="formData.parent_id" @change="onselectionchange"></depart-select>
</uni-forms-item>
<uni-forms-item name="depart_name" label="部门名称">
<uni-easyinput placeholder="部门名称" v-model="formData.depart_name" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="level" label="部门层级">
<uni-easyinput placeholder="部门层级,为提升检索效率而作的冗余设计" type="number"
v-model="formData.level"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="sort" label="显示顺序">
<uni-easyinput placeholder="部门在当前层级下的顺序,由小到大" type="number" v-model="formData.sort"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="manager_uid" label="部门主管">
<user-select v-model="formData.manager_uid"></user-select>
<uni-easyinput placeholder="部门主管的userid 参考`uni-id-users` 表"
v-model="formData.manager_uid"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="status" label="部门状态">
<uni-easyinput placeholder="部门状态0-正常、1-禁用" type="number" v-model="formData.status"></uni-easyinput>
</uni-forms-item>
</uni-forms>
</uni-card><view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button>
</view>
</view>
</template>
<script>
import userSelect from './user_select.vue';
import {
validator
} from '../../js_sdk/validator/ngTools_depart.js';
import departSelect from './depart_select.vue';
const db = uniCloud.database();
const dbCollectionName = 'ngTools_depart';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.indexOf(key) > -1) {
result[key] = validator[key]
}
}
return result
}
export default {
components: {
departSelect,
userSelect
},
data() {
let formData = {
"parent_id": "",
"depart_name": "",
"level": null,
"sort": null,
"manager_uid": "",
"status": null
}
return {
parentID: "",
selectDepartID:[],
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onLoad(e) {
console.log(e.pNode)
if (e.pNode) {
var pNode=JSON.parse(e.pNode)
const id = pNode._id
this.selectDepartID.push(pNode.parent_id)
console.log(this.selectDepartID)
this.formDataId = id
this.getDetail(id)
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
onselectionchange(e) {
// console.log(selectDepartID)
this.parentID = e;
// console.log(this.formData)
},
back() {
uni.navigateBack({
delta: 1
})
},
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
res.parent_id = this.parentID;
return this.submitForm(res)
}).catch(() => {}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使 clientDB
return db.collection(dbCollectionName).doc(this.formDataId).update(value).then((res) => {
uni.showToast({
icon: 'none',
title: '修改成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
},
/**
* 获取表单数据
* @param {Object} id
*/
getDetail(id) {
uni.showLoading({
mask: true
})
db.collection(dbCollectionName).doc(id).field("parent_id,depart_name,level,sort,manager_uid,status").get()
.then((res) => {
const data = res.result.data[0]
if (data) {
this.formData = data
}
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
}).finally(() => {
uni.hideLoading()
})
}
}
}
</script>
<style>
.uni-container {
padding: 0px;
}
.uni-input-border,
.uni-textarea-border {
width: 100%;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
box-sizing: border-box;
}
.uni-input-border {
padding: 0 10px;
height: 35px;
}
.uni-textarea-border {
padding: 10px;
height: 80px;
}
.uni-button-group {
margin-top: 50px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.uni-button {
width: 184px;
}
</style>

View File

@ -0,0 +1,119 @@
<template>
<view class="container">
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="组织机构" @clickLeft="back" />
<uni-card style="height: 90vh;">
<view>
<m-tree ref="departTree" :edit="true" :divider="true" :data="departTreeData"
:defaultProps="defaultProps" @edit-item="editItem" @add-item="addItem"></m-tree>
</view>
<tree-node :treeData="departTreeData"></tree-node>
</uni-card>
<uni-fab ref="fab" horizontal="right" vertical="bottom" :pop-menu="false" @fabClick="fabClick" />
</view>
</template>
<script>
import treeNode from './departList/departTree.vue';
import {
getDictItemStore,
getDepartStore,
saveDepartStore
} from '@/js_sdk/util/dictTools.js';
const db = uniCloud.database()
export default {
components: {
treeNode
},
mounted() {
console.log(111)
this.departTreeData = getDepartStore();
console.log(222)
},
data() {
return {
/*
tree 数据
*/
defaultProps: {
id: '_id', // idkey
children: 'children', // key
label: 'depart_name' // key
},
departTreeData: [],
loadMore: {
contentdown: '',
contentrefresh: '',
contentnomore: ''
}
}
},
onPullDownRefresh() {
this.departTreeData = getDepartStore()
},
onReachBottom() {
},
methods: {
editItem(e) {
console.log(e)
uni.navigateTo({
url: './edit?pNode=' + JSON.stringify(e.pNodeData)
})
},
addItem(e) {
console.log(e)
uni.navigateTo({
url: './add?pNode=' + e.pNodeData
})
},
showTree() {
this.$refs.nextTreeRef.showTree = true
},
onconfirm(list) {
console.log('选中项的数量列表list', list)
},
change(e) {
console.log('选中项的数量列表list', e)
},
handleItemClick(id) {
uni.navigateTo({
url: './detail?id=' + id
})
},
back() {
uni.navigateBack({
delta: 1
})
},
fabClick() {
//
uni.navigateTo({
url: './add',
events: {
// ,
refreshData: () => {
this.departTreeData = getDepartStore()
}
}
})
}
}
}
</script>
<style>
.tree-node {
margin-left: 20px;
}
.node-content {
/* 样式根据需要自定义 */
}
.node-children {
margin-left: 15px;
}
</style>

View File

@ -0,0 +1,102 @@
<template>
<view>
<!-- <uni-data-picker placeholder="请选择单位" popup-title="请选择单位" collection="ngTools_depart"
field="_id as value, depart_name as text" orderby="value asc" :step-searh="true" self-field="_id"
parent-field="parent_id" @change="onchange" @nodeclick="onnodeclick">
</uni-data-picker> -->
<!-- <uni-easyinput @focus="open" v-model="selectText" placeholder="选择用户"></uni-easyinput> -->
<uni-data-picker placeholder="请选择用户" popup-title="请选择用户" :localdata="userData" v-model="userID"
@change="onchange" :map="{text : 'username', value:'_id'}">
</uni-data-picker>
<!-- <next-tree ref="nextTreeRef" funcMode="radio" uiMode="popup" :selectParent="true" labelKey="username"
valueKey="_id" :multiple="false" :treeData="userData" @confirm="onnodeclick" @change="onchange">
</next-tree> -->
</view>
</template>
<script>
const db = uniCloud.database()
import {
getJsonTree,
groupBy
} from "@/js_sdk/util/jsonData";
import {
saveDepartStore,
saveDictItemStore,
getDictItemStore,
getDepartStore
} from '@/js_sdk/util/dictTools.js';
export default {
data() {
return {
collectionList: "uni-id-users",
userData: [],
selectText: "",
userID: "",
}
},
props: {
value: {
type: String,
default: ""
},
},
watch: {
value: {
immediate: true,
deep: true,
handler(val) {
console.log(val)
this.userID = val
}
}
},
mounted() {
this.userData = this.getUser()
},
onShow() {
},
methods: {
open() {
// this.departTreeData = getDepartStore();
setTimeout(() => {
this.$refs.nextTreeRef.showTree = true;
}, 500)
},
onchange(e) {
console.log(e)
this.$emit('input', e.detail.value[0].value)
},
getUser() {
db.collection('uni-id-users').field(
"_id,username,mobile,status"
).orderBy('username')
.get().then((res) => {
console.log(res.result.data)
if (res.result.data) {
this.userData = res.result.data;
}
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
}).finally(() => {
uni.hideLoading()
})
}
}
}
</script>

View File

@ -0,0 +1,201 @@
<template>
<view class="uni-container">
<uni-forms ref="form" :model="formData" validate-trigger="submit" err-show-type="toast">
<uni-forms-item name="category_id" label="">
<uni-easyinput placeholder="分类 id参考`opendb-mall-categories`表" v-model="formData.category_id"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="goods_sn" label="货号" required>
<uni-easyinput placeholder="商品的唯一货号" v-model="formData.goods_sn" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="name" label="名称" required>
<uni-easyinput placeholder="商品名称" v-model="formData.name" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="keywords" label="关键字">
<uni-easyinput placeholder="商品关键字,为搜索引擎收录使用" v-model="formData.keywords" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="goods_desc" label="详细描述">
<uni-easyinput placeholder="商品详细描述" v-model="formData.goods_desc" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="goods_thumb" label="缩略图地址">
<uni-easyinput placeholder="商品缩略图,用于在列表或搜索结果中预览显示" v-model="formData.goods_thumb" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="goods_banner_imgs" label="">
<uni-data-checkbox :multiple="true" v-model="formData.goods_banner_imgs"></uni-data-checkbox>
</uni-forms-item>
<uni-forms-item name="remain_count" label="库存数量" required>
<uni-easyinput placeholder="库存数量" type="number" v-model="formData.remain_count"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="month_sell_count" label="" required>
<uni-easyinput placeholder="月销量" type="number" v-model="formData.month_sell_count"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="total_sell_count" label="" required>
<uni-easyinput placeholder="总销量" type="number" v-model="formData.total_sell_count"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="comment_count" label="" required>
<uni-easyinput placeholder="累计评论数" type="number" v-model="formData.comment_count"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="is_real" label="是否为实物" required>
<switch @change="binddata('is_real', $event.detail.value)" :checked="formData.is_real"></switch>
</uni-forms-item>
<uni-forms-item name="is_on_sale" label="是否上架" required>
<switch @change="binddata('is_on_sale', $event.detail.value)" :checked="formData.is_on_sale"></switch>
</uni-forms-item>
<uni-forms-item name="is_alone_sale" label="" required>
<switch @change="binddata('is_alone_sale', $event.detail.value)" :checked="formData.is_alone_sale"></switch>
</uni-forms-item>
<uni-forms-item name="is_best" label="" required>
<switch @change="binddata('is_best', $event.detail.value)" :checked="formData.is_best"></switch>
</uni-forms-item>
<uni-forms-item name="is_new" label="是否新品" required>
<switch @change="binddata('is_new', $event.detail.value)" :checked="formData.is_new"></switch>
</uni-forms-item>
<uni-forms-item name="is_hot" label="" required>
<switch @change="binddata('is_hot', $event.detail.value)" :checked="formData.is_hot"></switch>
</uni-forms-item>
<uni-forms-item name="add_date" label="">
<uni-datetime-picker return-type="timestamp" v-model="formData.add_date"></uni-datetime-picker>
</uni-forms-item>
<uni-forms-item name="last_modify_date" label="">
<uni-datetime-picker return-type="timestamp" v-model="formData.last_modify_date"></uni-datetime-picker>
</uni-forms-item>
<uni-forms-item name="seller_note" label="">
<uni-easyinput placeholder="商家备注,仅商家可见" v-model="formData.seller_note" trim="both"></uni-easyinput>
</uni-forms-item>
<view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button>
</view>
</uni-forms>
</view>
</template>
<script>
import { validator } from '../../js_sdk/validator/ngtools-goods.js';
const db = uniCloud.database();
const dbCollectionName = 'ngtools-goods';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.indexOf(key) > -1) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"category_id": "",
"goods_sn": "",
"name": "",
"keywords": "",
"goods_desc": "",
"goods_thumb": "",
"goods_banner_imgs": [],
"remain_count": null,
"month_sell_count": null,
"total_sell_count": null,
"comment_count": null,
"is_real": null,
"is_on_sale": null,
"is_alone_sale": null,
"is_best": null,
"is_new": null,
"is_hot": null,
"add_date": null,
"last_modify_date": null,
"seller_note": ""
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {
}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使 clientDB
return db.collection(dbCollectionName).add(value).then((res) => {
uni.showToast({
icon: 'none',
title: '新增成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
}
}
}
</script>
<style>
.uni-container {
padding: 15px;
}
.uni-input-border,
.uni-textarea-border {
width: 100%;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
box-sizing: border-box;
}
.uni-input-border {
padding: 0 10px;
height: 35px;
}
.uni-textarea-border {
padding: 10px;
height: 80px;
}
.uni-button-group {
margin-top: 50px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.uni-button {
width: 184px;
}
</style>

View File

@ -0,0 +1,176 @@
<template>
<view class="container">
<unicloud-db ref="udb" v-slot:default="{data, loading, error, options}" :options="options" :collection="collectionList" field="category_id,goods_sn,name,keywords,goods_desc,goods_thumb,goods_banner_imgs,remain_count,month_sell_count,total_sell_count,comment_count,is_real,is_on_sale,is_alone_sale,is_best,is_new,is_hot,add_date,last_modify_date,seller_note" :where="queryWhere" :getone="true" :manual="true">
<view v-if="error">{{error.message}}</view>
<view v-else-if="loading">
<uni-load-more :contentText="loadMore" status="loading"></uni-load-more>
</view>
<view v-else-if="data">
<view>
<text>category_id</text>
<text>{{data.category_id}}</text>
</view>
<view>
<text>货号</text>
<text>{{data.goods_sn}}</text>
</view>
<view>
<text>名称</text>
<text>{{data.name}}</text>
</view>
<view>
<text>关键字</text>
<text>{{data.keywords}}</text>
</view>
<view>
<text>详细描述</text>
<text>{{data.goods_desc}}</text>
</view>
<view>
<text>缩略图地址</text>
<text>{{data.goods_thumb}}</text>
</view>
<view>
<text>goods_banner_imgs</text>
<text>{{data.goods_banner_imgs}}</text>
</view>
<view>
<text>库存数量</text>
<text>{{data.remain_count}}</text>
</view>
<view>
<text>month_sell_count</text>
<text>{{data.month_sell_count}}</text>
</view>
<view>
<text>total_sell_count</text>
<text>{{data.total_sell_count}}</text>
</view>
<view>
<text>comment_count</text>
<text>{{data.comment_count}}</text>
</view>
<view>
<text>是否为实物</text>
<text>{{data.is_real == true ? '✅' : '❌'}}</text>
</view>
<view>
<text>是否上架</text>
<text>{{data.is_on_sale == true ? '✅' : '❌'}}</text>
</view>
<view>
<text>is_alone_sale</text>
<text>{{data.is_alone_sale == true ? '✅' : '❌'}}</text>
</view>
<view>
<text>is_best</text>
<text>{{data.is_best == true ? '✅' : '❌'}}</text>
</view>
<view>
<text>是否新品</text>
<text>{{data.is_new == true ? '✅' : '❌'}}</text>
</view>
<view>
<text>is_hot</text>
<text>{{data.is_hot == true ? '✅' : '❌'}}</text>
</view>
<view>
<text>add_date</text>
<uni-dateformat :threshold="[0, 0]" :date="data.add_date"></uni-dateformat>
</view>
<view>
<text>last_modify_date</text>
<uni-dateformat :threshold="[0, 0]" :date="data.last_modify_date"></uni-dateformat>
</view>
<view>
<text>seller_note</text>
<text>{{data.seller_note}}</text>
</view>
</view>
</unicloud-db>
<view class="btns">
<button type="primary" @click="handleUpdate">修改</button>
<button type="warn" class="btn-delete" @click="handleDelete">删除</button>
</view>
</view>
</template>
<script>
// schema2codeenum
import { enumConverter } from '../../js_sdk/validator/ngtools-goods.js'
const db = uniCloud.database()
export default {
data() {
return {
queryWhere: '',
collectionList: "ngtools-goods",
loadMore: {
contentdown: '',
contentrefresh: '',
contentnomore: ''
},
options: {
// scheme enum valuetext
...enumConverter
}
}
},
onLoad(e) {
this._id = e.id
},
onReady() {
if (this._id) {
this.queryWhere = '_id=="' + this._id + '"'
}
},
methods: {
handleUpdate() {
//
uni.navigateTo({
url: './edit?id=' + this._id,
events: {
// ,
refreshData: () => {
this.$refs.udb.loadData({
clear: true
})
}
}
})
},
handleDelete() {
this.$refs.udb.remove(this._id, {
success: (res) => {
// list
uni.navigateTo({
url: './list'
})
}
})
}
}
}
</script>
<style>
.container {
padding: 10px;
}
.btns {
margin-top: 10px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
}
.btns button {
flex: 1;
}
.btn-delete {
margin-left: 10px;
}
</style>

View File

@ -0,0 +1,232 @@
<template>
<view class="uni-container">
<uni-forms ref="form" :model="formData" validate-trigger="submit" err-show-type="toast">
<uni-forms-item name="category_id" label="">
<uni-easyinput placeholder="分类 id参考`opendb-mall-categories`表" v-model="formData.category_id"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="goods_sn" label="货号" required>
<uni-easyinput placeholder="商品的唯一货号" v-model="formData.goods_sn" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="name" label="名称" required>
<uni-easyinput placeholder="商品名称" v-model="formData.name" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="keywords" label="关键字">
<uni-easyinput placeholder="商品关键字,为搜索引擎收录使用" v-model="formData.keywords" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="goods_desc" label="详细描述">
<uni-easyinput placeholder="商品详细描述" v-model="formData.goods_desc" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="goods_thumb" label="缩略图地址">
<uni-easyinput placeholder="商品缩略图,用于在列表或搜索结果中预览显示" v-model="formData.goods_thumb" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="goods_banner_imgs" label="">
<uni-data-checkbox :multiple="true" v-model="formData.goods_banner_imgs"></uni-data-checkbox>
</uni-forms-item>
<uni-forms-item name="remain_count" label="库存数量" required>
<uni-easyinput placeholder="库存数量" type="number" v-model="formData.remain_count"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="month_sell_count" label="" required>
<uni-easyinput placeholder="月销量" type="number" v-model="formData.month_sell_count"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="total_sell_count" label="" required>
<uni-easyinput placeholder="总销量" type="number" v-model="formData.total_sell_count"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="comment_count" label="" required>
<uni-easyinput placeholder="累计评论数" type="number" v-model="formData.comment_count"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="is_real" label="是否为实物" required>
<switch @change="binddata('is_real', $event.detail.value)" :checked="formData.is_real"></switch>
</uni-forms-item>
<uni-forms-item name="is_on_sale" label="是否上架" required>
<switch @change="binddata('is_on_sale', $event.detail.value)" :checked="formData.is_on_sale"></switch>
</uni-forms-item>
<uni-forms-item name="is_alone_sale" label="" required>
<switch @change="binddata('is_alone_sale', $event.detail.value)" :checked="formData.is_alone_sale"></switch>
</uni-forms-item>
<uni-forms-item name="is_best" label="" required>
<switch @change="binddata('is_best', $event.detail.value)" :checked="formData.is_best"></switch>
</uni-forms-item>
<uni-forms-item name="is_new" label="是否新品" required>
<switch @change="binddata('is_new', $event.detail.value)" :checked="formData.is_new"></switch>
</uni-forms-item>
<uni-forms-item name="is_hot" label="" required>
<switch @change="binddata('is_hot', $event.detail.value)" :checked="formData.is_hot"></switch>
</uni-forms-item>
<uni-forms-item name="add_date" label="">
<uni-datetime-picker return-type="timestamp" v-model="formData.add_date"></uni-datetime-picker>
</uni-forms-item>
<uni-forms-item name="last_modify_date" label="">
<uni-datetime-picker return-type="timestamp" v-model="formData.last_modify_date"></uni-datetime-picker>
</uni-forms-item>
<uni-forms-item name="seller_note" label="">
<uni-easyinput placeholder="商家备注,仅商家可见" v-model="formData.seller_note" trim="both"></uni-easyinput>
</uni-forms-item>
<view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button>
</view>
</uni-forms>
</view>
</template>
<script>
import { validator } from '../../js_sdk/validator/ngtools-goods.js';
const db = uniCloud.database();
const dbCollectionName = 'ngtools-goods';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.indexOf(key) > -1) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"category_id": "",
"goods_sn": "",
"name": "",
"keywords": "",
"goods_desc": "",
"goods_thumb": "",
"goods_banner_imgs": [],
"remain_count": null,
"month_sell_count": null,
"total_sell_count": null,
"comment_count": null,
"is_real": null,
"is_on_sale": null,
"is_alone_sale": null,
"is_best": null,
"is_new": null,
"is_hot": null,
"add_date": null,
"last_modify_date": null,
"seller_note": ""
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onLoad(e) {
if (e.id) {
const id = e.id
this.formDataId = id
this.getDetail(id)
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {
}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使 clientDB
return db.collection(dbCollectionName).doc(this.formDataId).update(value).then((res) => {
uni.showToast({
icon: 'none',
title: '修改成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
},
/**
* 获取表单数据
* @param {Object} id
*/
getDetail(id) {
uni.showLoading({
mask: true
})
db.collection(dbCollectionName).doc(id).field("category_id,goods_sn,name,keywords,goods_desc,goods_thumb,goods_banner_imgs,remain_count,month_sell_count,total_sell_count,comment_count,is_real,is_on_sale,is_alone_sale,is_best,is_new,is_hot,add_date,last_modify_date,seller_note").get().then((res) => {
const data = res.result.data[0]
if (data) {
this.formData = data
}
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
}).finally(() => {
uni.hideLoading()
})
}
}
}
</script>
<style>
.uni-container {
padding: 15px;
}
.uni-input-border,
.uni-textarea-border {
width: 100%;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
box-sizing: border-box;
}
.uni-input-border {
padding: 0 10px;
height: 35px;
}
.uni-textarea-border {
padding: 10px;
height: 80px;
}
.uni-button-group {
margin-top: 50px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.uni-button {
width: 184px;
}
</style>

View File

@ -0,0 +1,72 @@
<template>
<view class="container">
<unicloud-db ref="udb" v-slot:default="{data, pagination, loading, hasMore, error}" :collection="collectionList" field="category_id,goods_sn,name,keywords,goods_desc,goods_thumb,goods_banner_imgs,remain_count,month_sell_count,total_sell_count,comment_count,is_real,is_on_sale,is_alone_sale,is_best,is_new,is_hot,add_date,last_modify_date,seller_note">
<view v-if="error">{{error.message}}</view>
<view v-else-if="data">
<uni-list>
<uni-list-item v-for="(item, index) in data" :key="index" showArrow :clickable="true" @click="handleItemClick(item._id)">
<template v-slot:body>
<text>
<!-- 此处默认显示为_id请根据需要自行修改为其他字段 -->
<!-- 如果使用了联表查询请参考生成的 admin 项目中 list.vue 页面 -->
{{item._id}}
</text>
</template>
</uni-list-item>
</uni-list>
</view>
<uni-load-more :status="loading?'loading':(hasMore ? 'more' : 'noMore')"></uni-load-more>
</unicloud-db>
<uni-fab ref="fab" horizontal="right" vertical="bottom" :pop-menu="false" @fabClick="fabClick" />
</view>
</template>
<script>
const db = uniCloud.database()
export default {
data() {
return {
collectionList: "ngtools-goods",
loadMore: {
contentdown: '',
contentrefresh: '',
contentnomore: ''
}
}
},
onPullDownRefresh() {
this.$refs.udb.loadData({
clear: true
}, () => {
uni.stopPullDownRefresh()
})
},
onReachBottom() {
this.$refs.udb.loadMore()
},
methods: {
handleItemClick(id) {
uni.navigateTo({
url: './detail?id=' + id
})
},
fabClick() {
//
uni.navigateTo({
url: './add',
events: {
// ,
refreshData: () => {
this.$refs.udb.loadData({
clear: true
})
}
}
})
}
}
}
</script>
<style>
</style>

View File

@ -0,0 +1,325 @@
<template>
<view>
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="LNG气化计算" @clickLeft="back" />
<uni-card>
<!-- <view class="uni-button-group">
<uni-row width="100%">
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="cal">计算</button>
</uni-col>
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="save">打印结果</button>
</uni-col>
</uni-row>
</view> -->
<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="button"
activeColor="#4cd964"></uni-segmented-control>
</uni-card>
<view class="content">
<view v-show="current === 0">
<yjly-ngtools-meterPar :meter-type="8" v-model="meterPar" @calEnable="meterEnable">
</yjly-ngtools-meterPar>
</view>
<view v-show="current === 1">
<yjly-ngtools-NGComponents @calEnable="NGEnable" v-model="strNG">
</yjly-ngtools-NGComponents>
</view>
<view v-show="current === 2">
<yjly-ngtools-ParResult :formData="meterResult" :meter-type="8">
</yjly-ngtools-ParResult>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
items: ['工艺参数', '组分参数', '计算结果'],
current: 0,
strNG: "",
meterPar: [],
meterResult: {
"adMixture": "",
"adMixtureV": "",
"adMixtureD": "",
"dCbtj": "",
"dPb": "",
"dTb": "",
"dPf": "",
"dTf": "",
"dMrx": "",
"dZb": "",
"dZf": "",
"dFpv": "",
"dDb": "",
"dDf": "",
"dRhob": "",
"dRhof": "",
"dRD_Ideal": "",
"dRD_Real": "",
"dHo": "",
"dH": "",
"dS": "",
"dCpi": "",
"dCp": "",
"dCv": "",
"dk": "",
"dKappa": "",
"dSOS": "",
"dCstar": "",
"dHhvMol": "",
"dLhvMol": "",
"dHhvv": "",
"dLhvv": "",
"dHhvm": "",
"dLhvm": "",
"dZb11062": "",
"dRhob11062": "",
"dRhof11062": "",
"dRD_Ideal11062": "",
"dRD_Real11062": "",
"dWobbeIndex": "",
"Pc": "",
"TC": "",
"Bzsx": "",
"Bzxx": "",
"TotalC": "",
"C2": "",
"C2j": "",
"C3j": "",
"C4j": "",
"C5j": "",
"C6j": "",
"C3C4": "",
"dVLNG": ""
},
NGFlag: false,
meterFlag: false
};
},
watch: {
strNG: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
meterPar: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
},
methods: {
NGEnable(e) {
console.log(e)
this.NGFlag = e
},
meterEnable(e) {
console.log(e)
this.meterFlag = e
},
zeroPar() {
this.meterResult.adMixture = "0";
this.meterResult.adMixtureV = "0";
this.meterResult.adMixtureD = "0";
this.meterResult.dCbtj = "0";
this.meterResult.dPb = "0";
this.meterResult.dTb = "0";
this.meterResult.dPf = "0";
this.meterResult.dTf = "0";
this.meterResult.dMrx = "0";
this.meterResult.dZb = "0";
this.meterResult.dZf = "0";
this.meterResult.dFpv = "0";
this.meterResult.dDb = "0";
this.meterResult.dDf = "0";
this.meterResult.dRhob = "0";
this.meterResult.dRhof = "0";
this.meterResult.dRD_Ideal = "0";
this.meterResult.dRD_Real = "0";
this.meterResult.dHo = "0";
this.meterResult.dH = "0";
this.meterResult.dS = "0";
this.meterResult.dCpi = "0";
this.meterResult.dCp = "0";
this.meterResult.dCv = "0";
this.meterResult.dk = "0";
this.meterResult.dKappa = "0";
this.meterResult.dSOS = "0";
this.meterResult.dCstar = "0";
this.meterResult.dHhvMol = "0";
this.meterResult.dLhvMol = "0";
this.meterResult.dHhvv = "0";
this.meterResult.dLhvv = "0";
this.meterResult.dHhvm = "0";
this.meterResult.dLhvm = "0";
this.meterResult.dZb11062 = "0";
this.meterResult.dRhob11062 = "0";
this.meterResult.dRhof11062 = "0";
this.meterResult.dRD_Ideal11062 = "0";
this.meterResult.dRD_Real11062 = "0";
this.meterResult.dWobbeIndex = "0";
this.meterResult.Pc = "0";
this.meterResult.TC = "0";
this.meterResult.Bzsx = "0";
this.meterResult.Bzxx = "0";
this.meterResult.TotalC = "0";
this.meterResult.C2 = "0";
this.meterResult.C2j = "0";
this.meterResult.C3j = "0";
this.meterResult.C4j = "0";
this.meterResult.C5j = "0";
this.meterResult.C6j = "0";
this.meterResult.C3C4 = "0"
this.meterResult.dVLNG = "0"
},
onClickItem(e) {
if (this.current != e.currentIndex) {
this.current = e.currentIndex;
this.$nextTick(() => {
if (this.current == 2) {
this.cal();
}
}, 500)
}
},
back() {
uni.navigateBack({
delta: 1
})
},
cal() {
if (!this.NGFlag) {
// uni.navigateTo({
// url: '/pages/grid/popup?title=""&text=""'
// })
uni.showModal({
title: '提示',
content: '组分摩尔百分数合计不为100%,请检查并重新输入',
icon: 'none',
showCancel: false
})
this.current = 1;
return
}
if (!this.meterFlag) {
uni.showModal({
title: '提示',
content: '工艺参数输入不完整,请检查并重新输入',
icon: 'none',
showCancel: false
})
this.current = 0;
return
}
var NG_par = ""
NG_par = "0"; //
NG_par = NG_par + "," + this.meterPar.dCoreType; //
NG_par = NG_par + "," + this.meterPar.dFlowCalbz; //
NG_par = NG_par + "," + this.meterPar.dZcalbz; //
NG_par = NG_par + "," + this.meterPar.dCbtj; //'
NG_par = NG_par + "," + this.meterPar.dPb_M; //
NG_par = NG_par + "," + this.meterPar.dTb_M; //
NG_par = NG_par + "," + this.meterPar.dPb_E; //
NG_par = NG_par + "," + this.meterPar.dTb_E; //
NG_par = NG_par + "," + this.meterPar.dPatm; //
NG_par = NG_par + "," + this.meterPar.dPatmUnit; //
NG_par = NG_par + "," + this.strNG; //
NG_par = NG_par + "," + this.meterPar.dPtmode; //
NG_par = NG_par + "," + this.meterPar.dPipeType; //
NG_par = NG_par + "," + this.meterPar.dPipeD; //
NG_par = NG_par + "," + this.meterPar.dLenUnit; //
NG_par = NG_par + "," + this.meterPar.dPipeDtemp; //
NG_par = NG_par + "," + this.meterPar.dPileDtempU; //
NG_par = NG_par + "," + this.meterPar.dPipeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeD; //
NG_par = NG_par + "," + this.meterPar.dOrificeUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtemp; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtempUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeSharpness; //
NG_par = NG_par + "," + this.meterPar.dOrificeRk; //
NG_par = NG_par + "," + this.meterPar.dOrificeRkLenU; //
NG_par = NG_par + "," + this.meterPar.dPf; //
NG_par = NG_par + "," + this.meterPar.dPfUnit; //
NG_par = NG_par + "," + this.meterPar.dPfType; //
NG_par = NG_par + "," + this.meterPar.dTf; //
NG_par = NG_par + "," + this.meterPar.dTfUnit; //
NG_par = NG_par + "," + this.meterPar.dDp; //
NG_par = NG_par + "," + this.meterPar.dDpUnit; //
NG_par = NG_par + "," + this.meterPar.dVFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dMFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dEFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dMLNG; //LNG
console.log(NG_par);
var that = this;
var url = "";
// #ifdef MP-WEIXIN
url = "https://ngtools.cn:8443";
// #endif
// #ifdef H5
url = "/api"
// #endif
console.log(url)
uni.request({
url: url + '/LNGQhjs',
type: 'GET',
datatype: 'json',
sslVerify: false,
data: {
"par": NG_par
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
timeout: 1000, //10
success: function(res) {
console.log(res.data)
var data = JSON.stringify(res.data.message).toString().replace('[', '').replace(']',
'').split(',');
that.meterResult.dVLNG = data[63].substring(0, data[63].indexOf(".") + 5);
that.current = 2;
},
fail(e) {
console.log(e)
}
})
},
save() {
}
},
}
</script>
<style>
.uni-button-group {
margin-top: 0px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.mini-btn {
width: 100px;
margin-right: 10px;
}
</style>

View File

@ -0,0 +1,365 @@
<template>
<view>
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="水容积表格" @clickLeft="back" />
<uni-card>
<!-- <view class="uni-button-group">
<uni-row width="100%">
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="cal">计算</button>
</uni-col>
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="save">打印结果</button>
</uni-col>
</uni-row>
</view> -->
<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="button"
activeColor="#4cd964"></uni-segmented-control>
</uni-card>
<view class="content">
<view v-show="current === 0">
<yjly-ngtools-meterPar :meter-type="9" v-model="meterPar" @calEnable="meterEnable">
</yjly-ngtools-meterPar>
</view>
<view v-show="current === 1">
<yjly-ngtools-NGComponents @calEnable="NGEnable" v-model="strNG">
</yjly-ngtools-NGComponents>
</view>
<view v-show="current === 2">
<uni-card>
<view id="tableResult" class="table" v-html="strResult">
</view>
</uni-card>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
items: ['工艺参数', '组分参数', '计算结果'],
current: 0,
strNG: "",
meterPar: [],
strResult: null,
meterResult: {
"adMixture": "",
"adMixtureV": "",
"adMixtureD": "",
"dCbtj": "",
"dPb": "",
"dTb": "",
"dPf": "",
"dTf": "",
"dMrx": "",
"dZb": "",
"dZf": "",
"dFpv": "",
"dDb": "",
"dDf": "",
"dRhob": "",
"dRhof": "",
"dRD_Ideal": "",
"dRD_Real": "",
"dHo": "",
"dH": "",
"dS": "",
"dCpi": "",
"dCp": "",
"dCv": "",
"dk": "",
"dKappa": "",
"dSOS": "",
"dCstar": "",
"dHhvMol": "",
"dLhvMol": "",
"dHhvv": "",
"dLhvv": "",
"dHhvm": "",
"dLhvm": "",
"dZb11062": "",
"dRhob11062": "",
"dRhof11062": "",
"dRD_Ideal11062": "",
"dRD_Real11062": "",
"dWobbeIndex": "",
"Pc": "",
"TC": "",
"Bzsx": "",
"Bzxx": "",
"TotalC": "",
"C2": "",
"C2j": "",
"C3j": "",
"C4j": "",
"C5j": "",
"C6j": "",
"C3C4": "",
"dVCNG": "",
"dMCNG": ""
},
NGFlag: false,
meterFlag: false
};
},
watch: {
strNG: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
meterPar: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
},
methods: {
NGEnable(e) {
console.log(e)
this.NGFlag = e
},
meterEnable(e) {
console.log(e)
this.meterFlag = e
},
zeroPar() {
this.meterResult.adMixture = "0";
this.meterResult.adMixtureV = "0";
this.meterResult.adMixtureD = "0";
this.meterResult.dCbtj = "0";
this.meterResult.dPb = "0";
this.meterResult.dTb = "0";
this.meterResult.dPf = "0";
this.meterResult.dTf = "0";
this.meterResult.dMrx = "0";
this.meterResult.dZb = "0";
this.meterResult.dZf = "0";
this.meterResult.dFpv = "0";
this.meterResult.dDb = "0";
this.meterResult.dDf = "0";
this.meterResult.dRhob = "0";
this.meterResult.dRhof = "0";
this.meterResult.dRD_Ideal = "0";
this.meterResult.dRD_Real = "0";
this.meterResult.dHo = "0";
this.meterResult.dH = "0";
this.meterResult.dS = "0";
this.meterResult.dCpi = "0";
this.meterResult.dCp = "0";
this.meterResult.dCv = "0";
this.meterResult.dk = "0";
this.meterResult.dKappa = "0";
this.meterResult.dSOS = "0";
this.meterResult.dCstar = "0";
this.meterResult.dHhvMol = "0";
this.meterResult.dLhvMol = "0";
this.meterResult.dHhvv = "0";
this.meterResult.dLhvv = "0";
this.meterResult.dHhvm = "0";
this.meterResult.dLhvm = "0";
this.meterResult.dZb11062 = "0";
this.meterResult.dRhob11062 = "0";
this.meterResult.dRhof11062 = "0";
this.meterResult.dRD_Ideal11062 = "0";
this.meterResult.dRD_Real11062 = "0";
this.meterResult.dWobbeIndex = "0";
this.meterResult.Pc = "0";
this.meterResult.TC = "0";
this.meterResult.Bzsx = "0";
this.meterResult.Bzxx = "0";
this.meterResult.TotalC = "0";
this.meterResult.C2 = "0";
this.meterResult.C2j = "0";
this.meterResult.C3j = "0";
this.meterResult.C4j = "0";
this.meterResult.C5j = "0";
this.meterResult.C6j = "0";
this.meterResult.C3C4 = "0"
},
onClickItem(e) {
if (this.current != e.currentIndex) {
this.current = e.currentIndex;
this.$nextTick(() => {
if (this.current == 2) {
this.cal();
}
}, 500)
}
},
back() {
uni.navigateBack({
delta: 1
})
},
cal() {
if (!this.NGFlag) {
uni.showToast({
title: "组分参数输入不完整,请检查并重新输入"
})
this.current = 1;
return
}
if (!this.meterFlag) {
uni.showToast({
title: "工艺参数输入不完整,请检查并重新输入"
})
this.current = 0;
return
}
var NG_par = ""
NG_par = "0"; //
NG_par = NG_par + "," + this.meterPar.dCoreType; //
NG_par = NG_par + "," + this.meterPar.dFlowCalbz; //
NG_par = NG_par + "," + this.meterPar.dZcalbz; //
NG_par = NG_par + "," + this.meterPar.dCbtj; //'
NG_par = NG_par + "," + this.meterPar.dPb_M; //
NG_par = NG_par + "," + this.meterPar.dTb_M; //
NG_par = NG_par + "," + this.meterPar.dPb_E; //
NG_par = NG_par + "," + this.meterPar.dTb_E; //
NG_par = NG_par + "," + this.meterPar.dPatm; //
NG_par = NG_par + "," + this.meterPar.dPatmUnit; //
NG_par = NG_par + "," + this.strNG; //
NG_par = NG_par + "," + this.meterPar.dPtmode; //
NG_par = NG_par + "," + this.meterPar.dPipeType; //
NG_par = NG_par + "," + this.meterPar.dPipeD; //
NG_par = NG_par + "," + this.meterPar.dLenUnit; //
NG_par = NG_par + "," + this.meterPar.dPipeDtemp; //
NG_par = NG_par + "," + this.meterPar.dPileDtempU; //
NG_par = NG_par + "," + this.meterPar.dPipeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeD; //
NG_par = NG_par + "," + this.meterPar.dOrificeUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtemp; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtempUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeSharpness; //
NG_par = NG_par + "," + this.meterPar.dOrificeRk; //
NG_par = NG_par + "," + this.meterPar.dOrificeRkLenU; //
NG_par = NG_par + "," + this.meterPar.dPf; //
NG_par = NG_par + "," + this.meterPar.dPfUnit; //
NG_par = NG_par + "," + this.meterPar.dPfType; //
NG_par = NG_par + "," + this.meterPar.dTf; //
NG_par = NG_par + "," + this.meterPar.dTfUnit; //
NG_par = NG_par + "," + this.meterPar.dDp; //
NG_par = NG_par + "," + this.meterPar.dDpUnit; //
NG_par = NG_par + "," + this.meterPar.dVFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dMFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dEFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dVGsc; //
NG_par = NG_par + "," + this.meterPar.dPStep; //
NG_par = NG_par + "," + this.meterPar.dTStep; //
NG_par = NG_par + "," + this.meterPar.dPEnd; //
NG_par = NG_par + "," + this.meterPar.dTEnd; //
console.log(NG_par);
var that = this;
var url = "";
// #ifdef MP-WEIXIN
url = "https://ngtools.cn:8443";
// #endif
// #ifdef H5
url = "/api"
// #endif
console.log(url)
uni.request({
url: url + '/GSCVTCal',
type: 'GET',
sslVerify: false,
datatype: 'json',
data: {
"par": NG_par
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
timeout: 1000, //10
success: function(res) {
that.strResult = that.arrayToTable(res.data.result);
console.log(that.strResult)
that.current = 2;
},
})
},
save() {
const printWindow = window.open('', '_blank');
const printContent = document.getElementById('tableResult').outerHTML;
const styles = `<style>
body { margin: 0; padding: 0; }
table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid #ccc; padding: 8px; text-align: left; }
</style>`;
printWindow.document.write('<html><head><title>打印表格</title>');
printWindow.document.write(styles); //
printWindow.document.write('</head><body>');
printWindow.document.write(printContent); //
printWindow.document.write('</body></html>');
printWindow.document.close(); //
printWindow.focus(); // print
printWindow.print(); //
printWindow.close(); //
},
arrayToTable(array) {
let table = '<table border="1px solid #ccc">\n';
//
table += '<tr>\n';
for (let i = 0; i < array[0].length; i++) {
table += `<th>${array[0][i]}</th>\n`;
}
table += '</tr>\n';
//
for (let i = 1; i < array.length; i++) {
table += '<tr>\n';
for (let j = 0; j < array[i].length; j++) {
table += `<td style="width:100px">${array[i][j]}</td>\n`;
}
table += '</tr>\n';
}
table += '</table>';
return table;
}
},
}
</script>
<style>
.uni-button-group {
margin-top: 0px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.mini-btn {
width: 100px;
margin-right: 10px;
margin-bottom: 10px;
}
.table {
height: 70VH;
/* 设置固定高度 */
overflow-y: auto;
/* 开启垂直滚动条 */
overflow-x: auto;
/* 隐藏水平滚动条 */
border-width: 1px;
}
</style>

View File

@ -0,0 +1,313 @@
<template>
<view>
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="管束车水容积" @clickLeft="back" />
<uni-card>
<!-- <view class="uni-button-group">
<uni-row width="100%">
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="cal">计算</button>
</uni-col>
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="save">打印结果</button>
</uni-col>
</uni-row>
</view> -->
<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="button"
activeColor="#4cd964"></uni-segmented-control>
</uni-card>
<view class="content">
<view v-show="current === 0">
<yjly-ngtools-meterPar :meter-type="6" v-model="meterPar" @calEnable="meterEnable">
</yjly-ngtools-meterPar>
</view>
<view v-show="current === 1">
<yjly-ngtools-NGComponents @calEnable="NGEnable" v-model="strNG">
</yjly-ngtools-NGComponents>
</view>
<view v-show="current === 2">
<yjly-ngtools-ParResult :formData="meterResult" :meter-type="6">
</yjly-ngtools-ParResult>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
items: ['工艺参数', '组分参数', '计算结果'],
current: 0,
strNG: "",
meterPar: [],
meterResult: {
"adMixture": "",
"adMixtureV": "",
"adMixtureD": "",
"dCbtj": "",
"dPb": "",
"dTb": "",
"dPf": "",
"dTf": "",
"dMrx": "",
"dZb": "",
"dZf": "",
"dFpv": "",
"dDb": "",
"dDf": "",
"dRhob": "",
"dRhof": "",
"dRD_Ideal": "",
"dRD_Real": "",
"dHo": "",
"dH": "",
"dS": "",
"dCpi": "",
"dCp": "",
"dCv": "",
"dk": "",
"dKappa": "",
"dSOS": "",
"dCstar": "",
"dHhvMol": "",
"dLhvMol": "",
"dHhvv": "",
"dLhvv": "",
"dHhvm": "",
"dLhvm": "",
"dZb11062": "",
"dRhob11062": "",
"dRhof11062": "",
"dRD_Ideal11062": "",
"dRD_Real11062": "",
"dWobbeIndex": "",
"Pc": "",
"TC": "",
"Bzsx": "",
"Bzxx": "",
"TotalC": "",
"C2": "",
"C2j": "",
"C3j": "",
"C4j": "",
"C5j": "",
"C6j": "",
"C3C4": "",
"dVCNG": "",
"dMCNG": ""
},
NGFlag: false,
meterFlag: false
};
},
watch: {
strNG: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
meterPar: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
},
methods: {
NGEnable(e) {
console.log(e)
this.NGFlag = e
},
meterEnable(e) {
console.log(e)
this.meterFlag = e
},
zeroPar() {
this.meterResult.adMixture = "0";
this.meterResult.adMixtureV = "0";
this.meterResult.adMixtureD = "0";
this.meterResult.dCbtj = "0";
this.meterResult.dPb = "0";
this.meterResult.dTb = "0";
this.meterResult.dPf = "0";
this.meterResult.dTf = "0";
this.meterResult.dMrx = "0";
this.meterResult.dZb = "0";
this.meterResult.dZf = "0";
this.meterResult.dFpv = "0";
this.meterResult.dDb = "0";
this.meterResult.dDf = "0";
this.meterResult.dRhob = "0";
this.meterResult.dRhof = "0";
this.meterResult.dRD_Ideal = "0";
this.meterResult.dRD_Real = "0";
this.meterResult.dHo = "0";
this.meterResult.dH = "0";
this.meterResult.dS = "0";
this.meterResult.dCpi = "0";
this.meterResult.dCp = "0";
this.meterResult.dCv = "0";
this.meterResult.dk = "0";
this.meterResult.dKappa = "0";
this.meterResult.dSOS = "0";
this.meterResult.dCstar = "0";
this.meterResult.dHhvMol = "0";
this.meterResult.dLhvMol = "0";
this.meterResult.dHhvv = "0";
this.meterResult.dLhvv = "0";
this.meterResult.dHhvm = "0";
this.meterResult.dLhvm = "0";
this.meterResult.dZb11062 = "0";
this.meterResult.dRhob11062 = "0";
this.meterResult.dRhof11062 = "0";
this.meterResult.dRD_Ideal11062 = "0";
this.meterResult.dRD_Real11062 = "0";
this.meterResult.dWobbeIndex = "0";
this.meterResult.Pc = "0";
this.meterResult.TC = "0";
this.meterResult.Bzsx = "0";
this.meterResult.Bzxx = "0";
this.meterResult.TotalC = "0";
this.meterResult.C2 = "0";
this.meterResult.C2j = "0";
this.meterResult.C3j = "0";
this.meterResult.C4j = "0";
this.meterResult.C5j = "0";
this.meterResult.C6j = "0";
this.meterResult.C3C4 = "0"
},
onClickItem(e) {
if (this.current != e.currentIndex) {
this.current = e.currentIndex;
this.$nextTick(() => {
if (this.current == 2) {
this.cal();
}
}, 500)
}
},
back() {
uni.navigateBack({
delta: 1
})
},
cal() {
if (!this.NGFlag) {
uni.showToast({
title: "组分参数输入不完整,请检查并重新输入"
})
this.current = 1;
return
}
if (!this.meterFlag) {
uni.showToast({
title: "工艺参数输入不完整,请检查并重新输入"
})
this.current = 0;
return
}
var NG_par = ""
NG_par = "0"; //
NG_par = NG_par + "," + this.meterPar.dCoreType; //
NG_par = NG_par + "," + this.meterPar.dFlowCalbz; //
NG_par = NG_par + "," + this.meterPar.dZcalbz; //
NG_par = NG_par + "," + this.meterPar.dCbtj; //'
NG_par = NG_par + "," + this.meterPar.dPb_M; //
NG_par = NG_par + "," + this.meterPar.dTb_M; //
NG_par = NG_par + "," + this.meterPar.dPb_E; //
NG_par = NG_par + "," + this.meterPar.dTb_E; //
NG_par = NG_par + "," + this.meterPar.dPatm; //
NG_par = NG_par + "," + this.meterPar.dPatmUnit; //
NG_par = NG_par + "," + this.strNG; //
NG_par = NG_par + "," + this.meterPar.dPtmode; //
NG_par = NG_par + "," + this.meterPar.dPipeType; //
NG_par = NG_par + "," + this.meterPar.dPipeD; //
NG_par = NG_par + "," + this.meterPar.dLenUnit; //
NG_par = NG_par + "," + this.meterPar.dPipeDtemp; //
NG_par = NG_par + "," + this.meterPar.dPileDtempU; //
NG_par = NG_par + "," + this.meterPar.dPipeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeD; //
NG_par = NG_par + "," + this.meterPar.dOrificeUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtemp; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtempUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeSharpness; //
NG_par = NG_par + "," + this.meterPar.dOrificeRk; //
NG_par = NG_par + "," + this.meterPar.dOrificeRkLenU; //
NG_par = NG_par + "," + this.meterPar.dPf; //
NG_par = NG_par + "," + this.meterPar.dPfUnit; //
NG_par = NG_par + "," + this.meterPar.dPfType; //
NG_par = NG_par + "," + this.meterPar.dTf; //
NG_par = NG_par + "," + this.meterPar.dTfUnit; //
NG_par = NG_par + "," + this.meterPar.dDp; //
NG_par = NG_par + "," + this.meterPar.dDpUnit; //
NG_par = NG_par + "," + this.meterPar.dVFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dMFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dEFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dVGsc; //
console.log(NG_par);
var that = this;
var url = "";
// #ifdef MP-WEIXIN
url = "https://ngtools.cn:8443";
// #endif
// #ifdef H5
url = "/api"
// #endif
console.log(url)
uni.request({
url: url + '/GSCVCal',
type: 'GET',
sslVerify: false,
datatype: 'json',
data: {
"par": NG_par
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
timeout: 1000, //10
success: function(res) {
console.log(res.data)
var data = JSON.stringify(res.data.message).toString().replace('[', '').replace(']',
'').split(
',');
that.meterResult.dVCNG = data[63].substring(0, data[63].indexOf(".") + 6);
that.meterResult.dMCNG = data[64].substring(0, data[64].indexOf(".") + 6);
that.current = 2;
},
})
},
save() {
}
},
}
</script>
<style>
.uni-button-group {
margin-top: 0px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.mini-btn {
width: 100px;
margin-right: 10px;
margin-bottom: 10px;
}
</style>

View File

@ -0,0 +1,343 @@
<template>
<view>
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="CNG装卸量计算" @clickLeft="back" />
<uni-card>
<!-- <view class="uni-button-group">
<uni-row width="100%">
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="cal">计算</button>
</uni-col>
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="save">打印结果</button>
</uni-col>
</uni-row>
</view> -->
<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="button"
activeColor="#4cd964"></uni-segmented-control>
</uni-card>
<view class="content">
<view v-show="current === 0">
<yjly-ngtools-meterPar :meter-type="7" v-model="meterPar" @calEnable="meterEnable">
</yjly-ngtools-meterPar>
</view>
<view v-show="current === 1">
<yjly-ngtools-NGComponents @calEnable="NGEnable" v-model="strNG">
</yjly-ngtools-NGComponents>
</view>
<view v-show="current === 2">
<view style="text-align: center;padding-top: 10rpx;color: blue;">
{{strZxFlag}}
</view>
<yjly-ngtools-ParResult :formData="meterResult" :meter-type="7">
</yjly-ngtools-ParResult>
</view>
</view>
</view>
</template>
<script>
import {
importToJson,
exportToExcel
} from "@/uni_modules/sv-excel-json-each/js_sdk/parseExcel.js";
export default {
data() {
return {
items: ['工艺参数', '组分参数', '计算结果'],
current: 0,
strNG: "",
strZxFlag: "",
meterPar: [],
meterResult: {
"adMixture": "",
"adMixtureV": "",
"adMixtureD": "",
"dCbtj": "",
"dPb": "",
"dTb": "",
"dPf": "",
"dTf": "",
"dMrx": "",
"dZb": "",
"dZf": "",
"dFpv": "",
"dDb": "",
"dDf": "",
"dRhob": "",
"dRhof": "",
"dRD_Ideal": "",
"dRD_Real": "",
"dHo": "",
"dH": "",
"dS": "",
"dCpi": "",
"dCp": "",
"dCv": "",
"dk": "",
"dKappa": "",
"dSOS": "",
"dCstar": "",
"dHhvMol": "",
"dLhvMol": "",
"dHhvv": "",
"dLhvv": "",
"dHhvm": "",
"dLhvm": "",
"dZb11062": "",
"dRhob11062": "",
"dRhof11062": "",
"dRD_Ideal11062": "",
"dRD_Real11062": "",
"dWobbeIndex": "",
"Pc": "",
"TC": "",
"Bzsx": "",
"Bzxx": "",
"TotalC": "",
"C2": "",
"C2j": "",
"C3j": "",
"C4j": "",
"C5j": "",
"C6j": "",
"C3C4": "",
"dVCNG": "",
"dMCNG": ""
},
NGFlag: false,
meterFlag: false
};
},
watch: {
strNG: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
meterPar: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
},
methods: {
NGEnable(e) {
console.log(e)
this.NGFlag = e
},
meterEnable(e) {
console.log(e)
this.meterFlag = e
},
zeroPar() {
this.meterResult.adMixture = "0";
this.meterResult.adMixtureV = "0";
this.meterResult.adMixtureD = "0";
this.meterResult.dCbtj = "0";
this.meterResult.dPb = "0";
this.meterResult.dTb = "0";
this.meterResult.dPf = "0";
this.meterResult.dTf = "0";
this.meterResult.dMrx = "0";
this.meterResult.dZb = "0";
this.meterResult.dZf = "0";
this.meterResult.dFpv = "0";
this.meterResult.dDb = "0";
this.meterResult.dDf = "0";
this.meterResult.dRhob = "0";
this.meterResult.dRhof = "0";
this.meterResult.dRD_Ideal = "0";
this.meterResult.dRD_Real = "0";
this.meterResult.dHo = "0";
this.meterResult.dH = "0";
this.meterResult.dS = "0";
this.meterResult.dCpi = "0";
this.meterResult.dCp = "0";
this.meterResult.dCv = "0";
this.meterResult.dk = "0";
this.meterResult.dKappa = "0";
this.meterResult.dSOS = "0";
this.meterResult.dCstar = "0";
this.meterResult.dHhvMol = "0";
this.meterResult.dLhvMol = "0";
this.meterResult.dHhvv = "0";
this.meterResult.dLhvv = "0";
this.meterResult.dHhvm = "0";
this.meterResult.dLhvm = "0";
this.meterResult.dZb11062 = "0";
this.meterResult.dRhob11062 = "0";
this.meterResult.dRhof11062 = "0";
this.meterResult.dRD_Ideal11062 = "0";
this.meterResult.dRD_Real11062 = "0";
this.meterResult.dWobbeIndex = "0";
this.meterResult.Pc = "0";
this.meterResult.TC = "0";
this.meterResult.Bzsx = "0";
this.meterResult.Bzxx = "0";
this.meterResult.TotalC = "0";
this.meterResult.C2 = "0";
this.meterResult.C2j = "0";
this.meterResult.C3j = "0";
this.meterResult.C4j = "0";
this.meterResult.C5j = "0";
this.meterResult.C6j = "0";
this.meterResult.C3C4 = "0"
},
onClickItem(e) {
if (this.current != e.currentIndex) {
this.current = e.currentIndex;
this.$nextTick(() => {
if (this.current == 2) {
this.cal();
}
}, 500)
}
},
back() {
uni.navigateBack({
delta: 1
})
},
cal() {
if (!this.NGFlag) {
// uni.navigateTo({
// url: '/pages/grid/popup?title=""&text=""'
// })
uni.showModal({
title: '提示',
content: '组分摩尔百分数合计不为100%,请检查并重新输入',
icon: 'none',
showCancel: false
})
this.current = 1;
return
}
if (!this.meterFlag) {
uni.showModal({
title: '提示',
content: '工艺参数输入不完整,请检查并重新输入',
icon: 'none',
showCancel: false
})
this.current = 0;
return
}
var NG_par = ""
NG_par = "0"; //
NG_par = NG_par + "," + this.meterPar.dCoreType; //
NG_par = NG_par + "," + this.meterPar.dFlowCalbz; //
NG_par = NG_par + "," + this.meterPar.dZcalbz; //
NG_par = NG_par + "," + this.meterPar.dCbtj; //'
NG_par = NG_par + "," + this.meterPar.dPb_M; //
NG_par = NG_par + "," + this.meterPar.dTb_M; //
NG_par = NG_par + "," + this.meterPar.dPb_E; //
NG_par = NG_par + "," + this.meterPar.dTb_E; //
NG_par = NG_par + "," + this.meterPar.dPatm; //
NG_par = NG_par + "," + this.meterPar.dPatmUnit; //
NG_par = NG_par + "," + this.strNG; //
NG_par = NG_par + "," + this.meterPar.dPtmode; //
NG_par = NG_par + "," + this.meterPar.dPipeType; //
NG_par = NG_par + "," + this.meterPar.dPipeD; //
NG_par = NG_par + "," + this.meterPar.dLenUnit; //
NG_par = NG_par + "," + this.meterPar.dPipeDtemp; //
NG_par = NG_par + "," + this.meterPar.dPileDtempU; //
NG_par = NG_par + "," + this.meterPar.dPipeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeD; //
NG_par = NG_par + "," + this.meterPar.dOrificeUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtemp; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtempUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeSharpness; //
NG_par = NG_par + "," + this.meterPar.dOrificeRk; //
NG_par = NG_par + "," + this.meterPar.dOrificeRkLenU; //
NG_par = NG_par + "," + this.meterPar.dPf; //
NG_par = NG_par + "," + this.meterPar.dPfUnit; //
NG_par = NG_par + "," + this.meterPar.dPfType; //
NG_par = NG_par + "," + this.meterPar.dTf; //
NG_par = NG_par + "," + this.meterPar.dTfUnit; //
NG_par = NG_par + "," + this.meterPar.dDp; //
NG_par = NG_par + "," + this.meterPar.dDpUnit; //
NG_par = NG_par + "," + this.meterPar.dVFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dMFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dEFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dVGsc; //
NG_par = NG_par + "," + this.meterPar.dPfEnd; //
NG_par = NG_par + "," + this.meterPar.dTfEnd; //
console.log(NG_par);
var that = this;
var url = "";
// #ifdef MP-WEIXIN
url="https://ngtools.cn:8443";
// #endif
// #ifdef H5
url = "/api"
// #endif
console.log(url)
uni.request({
url: url + '/ZXCCal',
type: 'GET',
sslVerify: false,
datatype: 'json',
data: {
"par": NG_par
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
timeout: 1000, //10
success: function(res) {
console.log(res.data)
var data = JSON.stringify(res.data.message).toString().replace('[', '').replace(']',
'').split(
',');
that.meterResult.dVCNG = data[63].substring(0, data[63].indexOf(".") + 6);
that.meterResult.dMCNG = data[64].substring(0, data[64].indexOf(".") + 6);
if (that.meterResult.dVCNG > 0) {
that.strZxFlag = "装车"
} else {
that.strZxFlag = "卸车"
}
that.current = 2;
},
})
},
save() {
console.log(this.meterPar, this.meterResult)
exportToExcel(this.meterResult)
}
},
}
</script>
<style>
.uni-button-group {
margin-top: 0px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.mini-btn {
width: 100px;
margin-right: 10px;
margin-bottom: 10px;
}
</style>

View File

@ -0,0 +1,523 @@
<template>
<view>
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="输气工艺计算" @clickLeft="back" />
<uni-card>
<!-- <view class="uni-button-group">
<uni-row width="100%">
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="cal">计算</button>
</uni-col>
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="save">打印结果</button>
</uni-col>
</uni-row>
</view> -->
<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="button"
activeColor="#4cd964"></uni-segmented-control>
</uni-card>
<view class="content">
<view v-show="current === 0">
<uni-card>
<uni-forms ref="form" label-position="top" :model="formData" validate-trigger="submit"
err-show-type="toast">
<scroll-view scroll-y="true" :style="{height:scrollerHeight+'px'}">
<view class="uni-container">
<view class="formItem">
<uni-forms-item name="jsCs" label-width='150' label="输气工艺参数">
<yjly-dictItemSelect sql-condition="sqgyjscs"
v-model="formData.djsCs"></yjly-dictItemSelect>
</uni-forms-item>
</view>
<view class="formItem">
<uni-forms-item :required="true" name="jsgs" label-width='150' label="水力计算公式">
<yjly-dictItemSelect sql-condition="sqgysljsgs"
v-model="formData.djsGs"></yjly-dictItemSelect>
</uni-forms-item>
</view>
<!-- <view class="formItem">
<uni-forms-item name="dSqgLx" label-width='150' label="输气管道类型">
<yjly-dictItemSelect sql-condition="sqgygdlx"
v-model="formData.dSqgLx"></yjly-dictItemSelect>
</uni-forms-item>
</view> -->
<view class="formItem" v-if="formData.djsCs !='0'">
<uni-forms-item name="dflowSq" label-width='150' label="输气流量(m³/d)">
<uni-easyinput placeholder="输气流量" v-model="formData.dflowSq"
trim="both"></uni-easyinput>
</uni-forms-item>
</view>
<view class="formItem" v-if="formData.djsCs !='1'">
<uni-forms-item name="dPipleDw" label-width='150' label="管道外径(mm)">
<uni-easyinput placeholder="管道外径" v-model="formData.dPipleDw"
trim="both"></uni-easyinput>
</uni-forms-item>
</view>
<view class="formItem">
<uni-forms-item name="dPipleBh" label-width='150' label="管道壁厚(mm)">
<uni-easyinput placeholder="管道壁厚" v-model="formData.dPipleBh"
trim="both"></uni-easyinput>
</uni-forms-item>
</view>
<view class="formItem" v-if="formData.djsCs !='2'">
<uni-forms-item name="dPipleL" label-width='150' label="管道长度(km)">
<uni-easyinput placeholder="管道壁厚" v-model="formData.dPipleL"
trim="both"></uni-easyinput>
</uni-forms-item>
</view>
<view class="formItem" v-if="formData.djsCs !='3'">
<uni-forms-item name="dStartP" label-width='150' label="起点压力(MPa)">
<uni-easyinput placeholder="起点压力" v-model="formData.dStartP"
trim="both"></uni-easyinput>
</uni-forms-item>
</view>
<view class="formItem" v-if="formData.djsCs !='4'">
<uni-forms-item name="dEndP" label-width='150' label="终点压力(MPa)">
<uni-easyinput placeholder="终点压力" v-model="formData.dEndP"
trim="both"></uni-easyinput>
</uni-forms-item>
</view>
<view class="formItem">
<uni-forms-item name="strResult" label-width='150' label="计算结果">
<uni-easyinput placeholder="计算结果" v-model="strResult"
trim="both"></uni-easyinput>
</uni-forms-item>
</view>
</view>
</scroll-view>
</uni-forms>
</uni-card>
</view>
<view v-show="current === 1">
<yjly-ngtools-NGComponents @calEnable="NGEnable" v-model="strNG"></yjly-ngtools-NGComponents>
</view>
</view>
</view>
</template>
<script>
export default {
components: {
},
data() {
let formData = {
"dFlowCalbz": "0",
"dZcalbz": "0",
"dCbtj": "0",
"dPb_M": "101325",
"dTb_M": "293.15",
"dPb_E": "101325",
"dTb_E": "293.15",
"dPatm": "0.101325",
"dPatmUnit": "2",
"dMeterType": "0",
"dCoreType": "0",
"dPtmode": "0",
"dPipeType": "0",
"dPipeD": "0",
"dLenUnit": "3",
"dPipeDtemp": "20",
"dPileDtempU": "0",
"dPipeMaterial": "11.16",
"dOrificeD": "0",
"dOrificeUnit": "3",
"dOrificeDtemp": "20",
"dOrificeDtempUnit": "0",
"dOrificeMaterial": "16.6",
"dOrificeSharpness": "0",
"dOrificeRk": "0",
"dOrificeRkLenU": "3",
"dPf": "0",
"dPfUnit": "2",
"dPfType": "0",
"dTf": "0",
"dTfUnit": "0",
"dDp": "0",
"dDpUnit": "1",
"dVFlowUnit": "0",
"dMFlowUnit": "2",
"dEFlowUnit": "1",
"dVGsc": "",
"dPfEnd": "",
"dTfEnd": "",
"dMLNG": "",
"dPStep": "",
"dTStep": "",
"dPEnd": "",
"dTEnd": "",
"djsCs": "",
"djsGs": "",
"dSqgLx": "0",
"dPipleDw": "325",
"dPipleBh": "8",
"dPipleL": "20",
"dStartP": "2.5",
"dEndP": "1.8",
"dflowSq": "30000",
}
return {
items: ['工艺参数', '组分参数'],
current: 0,
strNG: "",
meterPar: [],
meterResult: {
"dCd": "",
"dCdCalMethod": "",
"dMeterFactor": "",
"dPulseNum": "",
"dVFlowMax": "",
"dVFlowMin": "",
"dVFlowCon": "",
"dPfRangeMin": "",
"dPfRangeMax": "",
"dDpRangeMin": "",
"dDpRangeMax": "",
"dTfRangeMin": "",
"dTfRangeMax": "",
"dE": "",
"dFG": "",
"dFT": "",
"dDViscosity": "",
"dDExpCoefficient": "",
"dRnPipe": "",
"dBk": "",
"dRoughNessPipe": "",
"dCdCorrect": "",
"dCdNozell": "",
"dVFlowb": "",
"dVFlowf": "",
"dMFlowb": "",
"dEFlowb": "",
"dVelocityFlow": "",
"dPressLost": "",
"dBeta": "",
"dKappa": "",
},
NGFlag: false,
meterFlag: false,
formData,
formOptions: {},
scrollerHeight: 0,
strResult: ""
};
},
watch: {
strNG: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
meterPar: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
},
onReady() {
this.formData.dMeterType = "0";
this.formData.dPatm = "0.0981"
this.formData.dPipeD = "259.38"
this.formData.dOrificeD = "150.25"
this.formData.dPf = "1.48"
this.formData.dTf = "15"
this.formData.dDp = " 12.5"
this.formData.dMeterFactor = "20000"
this.formData.dPulseNum = "300"
this.formData.dCd = "0.95"
this.formData.dVGsc = "25"
this.formData.dPfEnd = "20"
this.formData.dTfEnd = "35"
this.formData.dMLNG = "10"
this.formData.dPStep = "0.5"
this.formData.dTStep = "1"
this.formData.dPEnd = "5.48"
this.formData.dTEnd = "30"
this.formData.dPipleDw = "325"
this.formData.dPipleBh = "8"
this.formData.dPipleL = "20"
this.formData.dStartP = "2.5"
this.formData.dEndP = "1.8"
this.formData.dflowSq = "30000"
},
mounted() {
let that = this;
uni.getSystemInfo({
success: function(res) {
if (that.meterType == 3) {
that.scrollerHeight = (res.windowHeight - 560)
} else {
that.scrollerHeight = (res.windowHeight - 200)
}
}
});
},
methods: {
NGEnable(e) {
// console.log(e)
this.NGFlag = e
},
meterEnable(e) {
// console.log(e)
this.meterFlag = e
},
zeroPar() {
this.meterResult.dCd = "0";
this.meterResult.dCdCalMethod = "0";
this.meterResult.dMeterFactor = "0";
this.meterResult.dPulseNum = "0";
this.meterResult.dVFlowMax = "0";
this.meterResult.dVFlowMin = "0";
this.meterResult.dVFlowCon = "0";
this.meterResult.dPfRangeMin = "0";
this.meterResult.dPfRangeMax = "0";
this.meterResult.dDpRangeMin = "0";
this.meterResult.dDpRangeMax = "0";
this.meterResult.dTfRangeMin = "0";
this.meterResult.dTfRangeMax = "0";
this.meterResult.dE = "0";
this.meterResult.dFG = "0";
this.meterResult.dFT = "0";
this.meterResult.dDViscosity = "0";
this.meterResult.dDExpCoefficient = "0";
this.meterResult.dRnPipe = "0";
this.meterResult.dBk = "0";
this.meterResult.dRoughNessPipe = "0";
this.meterResult.dCdCorrect = "0";
this.meterResult.dCdNozell = "0";
this.meterResult.dVFlowb = "0";
this.meterResult.dVFlowf = "0";
this.meterResult.dMFlowb = "0";
this.meterResult.dEFlowb = "0";
this.meterResult.dVelocityFlow = "0";
this.meterResult.dPressLost = "0";
this.meterResult.dBeta = "0";
this.meterResult.dKappa = "0";
},
onClickItem(e) {
if (this.current != e.currentIndex) {
this.current = e.currentIndex;
this.$nextTick(() => {
if (this.current == 2) {
this.cal();
}
}, 500)
}
},
back() {
uni.navigateBack({
delta: 1
})
},
cal() {
if (this.formData.djsCs == "" || this.formData.djsGs == "" || this.formData
.dPipleDw == "" || this.formData.dPipleBh == "" || this.formData.dPipleL == "" || this.formData
.dStartP == "" || this.formData.dEndP == "" || this.formData.dflowSq == "") {
uni.showModal({
title: '提示',
content: '工艺参数输入不全,请检查并重新输入',
icon: 'none',
showCancel: false
})
this.current = 0;
return
}
if (!this.NGFlag) {
uni.showModal({
title: '提示',
content: '组分摩尔百分数合计不为100%,请检查并重新输入',
icon: 'none',
showCancel: false
})
this.current = 1;
return
}
var NG_par = ""
NG_par = "0"; //
NG_par = NG_par + "," + this.formData.dCoreType; //
NG_par = NG_par + "," + this.formData.dFlowCalbz; //
NG_par = NG_par + "," + this.formData.dZcalbz; //
NG_par = NG_par + "," + this.formData.dCbtj; //'
NG_par = NG_par + "," + this.formData.dPb_M; //
NG_par = NG_par + "," + this.formData.dTb_M; //
NG_par = NG_par + "," + this.formData.dPb_E; //
NG_par = NG_par + "," + this.formData.dTb_E; //
NG_par = NG_par + "," + this.formData.dPatm; //
NG_par = NG_par + "," + this.formData.dPatmUnit; //
NG_par = NG_par + "," + this.strNG; //
NG_par = NG_par + "," + this.formData.dPtmode; //
NG_par = NG_par + "," + this.formData.dPipeType; //
NG_par = NG_par + "," + this.formData.dPipeD; //
NG_par = NG_par + "," + this.formData.dLenUnit; //
NG_par = NG_par + "," + this.formData.dPipeDtemp; //
NG_par = NG_par + "," + this.formData.dPileDtempU; //
NG_par = NG_par + "," + this.formData.dPipeMaterial; //
NG_par = NG_par + "," + this.formData.dOrificeD; //
NG_par = NG_par + "," + this.formData.dOrificeUnit; //
NG_par = NG_par + "," + this.formData.dOrificeDtemp; //
NG_par = NG_par + "," + this.formData.dOrificeDtempUnit; //
NG_par = NG_par + "," + this.formData.dOrificeMaterial; //
NG_par = NG_par + "," + this.formData.dOrificeSharpness; //
NG_par = NG_par + "," + this.formData.dOrificeRk; //
NG_par = NG_par + "," + this.formData.dOrificeRkLenU; //
NG_par = NG_par + "," + this.formData.dPf; //
NG_par = NG_par + "," + this.formData.dPfUnit; //
NG_par = NG_par + "," + this.formData.dPfType; //
NG_par = NG_par + "," + this.formData.dTf; //
NG_par = NG_par + "," + this.formData.dTfUnit; //
NG_par = NG_par + "," + this.formData.dDp; //
NG_par = NG_par + "," + this.formData.dDpUnit; //
NG_par = NG_par + "," + this.formData.dVFlowUnit; //
NG_par = NG_par + "," + this.formData.dMFlowUnit; //
NG_par = NG_par + "," + this.formData.dEFlowUnit; //
NG_par = NG_par + "," + this.formData.djsCs;
NG_par = NG_par + "," + this.formData.djsGs;
NG_par = NG_par + "," + this.formData.dSqgLx;
NG_par = NG_par + "," + this.formData.dPipleDw;
NG_par = NG_par + "," + this.formData.dPipleBh;
NG_par = NG_par + "," + this.formData.dPipleL;
NG_par = NG_par + "," + this.formData.dStartP;
NG_par = NG_par + "," + this.formData.dEndP;
NG_par = NG_par + "," + this.formData.dflowSq;
console.log(NG_par);
var that = this;
var url = "";
// #ifdef MP-WEIXIN
url="https://ngtools.cn:8443";
// #endif
// #ifdef H5
url = "/api"
// #endif
console.log(url)
uni.request({
url: url + "/SQGYjs",
type: 'GET',
datatype: 'json',
data: {
"par": NG_par
},
sslVerify: false,
header: {
'content-type': 'application/x-www-form-urlencoded',
},
timeout: 1000, //10
success: function(res) {
console.log(res.data)
that.strResult = res.data.result;
that.current = 0;
},
fail: function(res) {
console.log(res)
}
})
},
save() {
console.log(this.meterPar, this.meterResult)
}
},
}
</script>
<style>
.uni-button-group {
margin-top: 0px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.mini-btn {
width: 100px;
margin-right: 10px;
}
.uni-container {
padding: 0px;
display: flex;
flex-wrap: wrap;
}
@media screen and (min-width: 1024px) {
.formItem {
width: 18%;
padding-right: 10px;
}
}
@media screen and (max-width: 1024px) {
.formItem {
width: 18%;
padding-right: 10px;
}
}
@media screen and (max-width: 768px) {
.formItem {
width: 22%;
padding-right: 10px;
}
}
@media screen and (max-width: 640px) {
.formItem {
width: 30%;
padding-right: 10px;
}
}
@media screen and (max-width: 480px) {
.formItem {
width: 45%;
padding-right: 10px;
}
}
@media screen and (max-width: 320px) {
.formItem {
width: 90%;
padding-right: 10px;
}
}
</style>

View File

@ -0,0 +1,299 @@
<template>
<view>
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="差压式流量计算" @clickLeft="back" />
<uni-card>
<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="button"
activeColor="#4cd964"></uni-segmented-control>
</uni-card>
<view class="content">
<view v-show="current === 0">
<yjly-ngtools-meterPar :meter-type="0" v-model="meterPar"
@calEnable="meterEnable"></yjly-ngtools-meterPar>
</view>
<view v-show="current === 1">
<yjly-ngtools-NGComponents @calEnable="NGEnable" v-model="strNG"></yjly-ngtools-NGComponents>
</view>
<view v-show="current === 2">
<yjly-ngtools-meterResult :formData="meterResult"></yjly-ngtools-meterResult>
</view>
</view>
</template>
<script>
export default {
data() {
return {
items: ['仪表参数', '组分参数', '计算结果'],
current: 0,
strNG: "",
meterPar: [],
</view>meterResult: {
"dCd": "",
"dCdCalMethod": "",
"dMeterFactor": "",
"dPulseNum": "",
"dVFlowMax": "",
"dVFlowMin": "",
"dVFlowCon": "",
"dPfRangeMin": "",
"dPfRangeMax": "",
"dDpRangeMin": "",
"dDpRangeMax": "",
"dTfRangeMin": "",
"dTfRangeMax": "",
"dE": "",
"dFG": "",
"dFT": "",
"dDViscosity": "",
"dDExpCoefficient": "",
"dRnPipe": "",
"dBk": "",
"dRoughNessPipe": "",
"dCdCorrect": "",
"dCdNozell": "",
"dVFlowb": "",
"dVFlowf": "",
"dMFlowb": "",
"dEFlowb": "",
"dVelocityFlow": "",
"dPressLost": "",
"dBeta": "",
"dKappa": "",
},
NGFlag: false,
meterFlag: false,
};
},
watch: {
strNG: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
meterPar: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
},
methods: {
NGEnable(e) {
// console.log(e)
this.NGFlag = e
},
meterEnable(e) {
// console.log(e)
this.meterFlag = e
},
zeroPar() {
this.meterResult.dCd = "0";
this.meterResult.dCdCalMethod = "0";
this.meterResult.dMeterFactor = "0";
this.meterResult.dPulseNum = "0";
this.meterResult.dVFlowMax = "0";
this.meterResult.dVFlowMin = "0";
this.meterResult.dVFlowCon = "0";
this.meterResult.dPfRangeMin = "0";
this.meterResult.dPfRangeMax = "0";
this.meterResult.dDpRangeMin = "0";
this.meterResult.dDpRangeMax = "0";
this.meterResult.dTfRangeMin = "0";
this.meterResult.dTfRangeMax = "0";
this.meterResult.dE = "0";
this.meterResult.dFG = "0";
this.meterResult.dFT = "0";
this.meterResult.dDViscosity = "0";
this.meterResult.dDExpCoefficient = "0";
this.meterResult.dRnPipe = "0";
this.meterResult.dBk = "0";
this.meterResult.dRoughNessPipe = "0";
this.meterResult.dCdCorrect = "0";
this.meterResult.dCdNozell = "0";
this.meterResult.dVFlowb = "0";
this.meterResult.dVFlowf = "0";
this.meterResult.dMFlowb = "0";
this.meterResult.dEFlowb = "0";
this.meterResult.dVelocityFlow = "0";
this.meterResult.dPressLost = "0";
this.meterResult.dBeta = "0";
this.meterResult.dKappa = "0";
this.meterResult.dZb = "0";
this.meterResult.dZf = "0";
this.meterResult.dFpv = "0";
},
onClickItem(e) {
this.ssss="";
if (this.current != e.currentIndex) {
this.current = e.currentIndex;
this.$nextTick(()=>{
if (this.current==2) {
this.cal();
}
},500)
}
},
back() {
uni.navigateBack({
delta: 1
})
},
cal() {
if (!this.NGFlag) {
// uni.navigateTo({
// url: '/pages/grid/popup?title=""&text=""'
// })
uni.showModal({
title: '提示',
content: '组分摩尔百分数合计不为100%,请检查并重新输入',
icon: 'none',
showCancel: false
})
this.current = 1;
return
}
if (!this.meterFlag) {
uni.showModal({
title: '提示',
content: '工艺参数输入不完整,请检查并重新输入',
icon: 'none',
showCancel: false
})
this.current = 0;
return
}
var NG_par = ""
NG_par = this.meterPar.dMeterType; //
NG_par = NG_par + "," + this.meterPar.dCoreType; //
NG_par = NG_par + "," + this.meterPar.dFlowCalbz; //
NG_par = NG_par + "," + this.meterPar.dZcalbz; //
NG_par = NG_par + "," + this.meterPar.dCbtj; //'
NG_par = NG_par + "," + this.meterPar.dPb_M; //
NG_par = NG_par + "," + this.meterPar.dTb_M; //
NG_par = NG_par + "," + this.meterPar.dPb_E; //
NG_par = NG_par + "," + this.meterPar.dTb_E; //
NG_par = NG_par + "," + this.meterPar.dPatm; //
NG_par = NG_par + "," + this.meterPar.dPatmUnit; //
NG_par = NG_par + "," + this.strNG; //
NG_par = NG_par + "," + this.meterPar.dPtmode; //
NG_par = NG_par + "," + this.meterPar.dPipeType; //
NG_par = NG_par + "," + this.meterPar.dPipeD; //
NG_par = NG_par + "," + this.meterPar.dLenUnit; //
NG_par = NG_par + "," + this.meterPar.dPipeDtemp; //
NG_par = NG_par + "," + this.meterPar.dPileDtempU; //
NG_par = NG_par + "," + this.meterPar.dPipeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeD; //
NG_par = NG_par + "," + this.meterPar.dOrificeUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtemp; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtempUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeSharpness; //
NG_par = NG_par + "," + this.meterPar.dOrificeRk; //
NG_par = NG_par + "," + this.meterPar.dOrificeRkLenU; //
NG_par = NG_par + "," + this.meterPar.dPf; //
NG_par = NG_par + "," + this.meterPar.dPfUnit; //
NG_par = NG_par + "," + this.meterPar.dPfType; //
NG_par = NG_par + "," + this.meterPar.dTf; //
NG_par = NG_par + "," + this.meterPar.dTfUnit; //
NG_par = NG_par + "," + this.meterPar.dDp; //
NG_par = NG_par + "," + this.meterPar.dDpUnit; //
NG_par = NG_par + "," + this.meterPar.dVFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dMFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dEFlowUnit; //
console.log(NG_par);
var that = this;
var url="";
// #ifdef MP-WEIXIN
url="https://ngtools.cn:8443";
// #endif
// #ifdef H5
url = "/api"
// #endif
console.log(url)
uni.request({
url: url + "/KBFlowcal",
type: 'GET',
datatype: 'json',
data: {
"par": NG_par
},
sslVerify: false,
header: {
'content-type': 'application/x-www-form-urlencoded',
},
timeout: 1000, //10
success: function(res) {
console.log(res)
var data = JSON.stringify(res.data.message).toString().replace('[', '').replace(']','').split(',');
that.meterResult.dCd = data[45].substring(0, data[45].indexOf(".") + 6);
that.meterResult.dE = data[46].substring(0, data[46].indexOf(".") + 6);
that.meterResult.dFG = data[47].substring(0, data[47].indexOf(".") + 6);
that.meterResult.dFT = data[48].substring(0, data[48].indexOf(".") + 6);
that.meterResult.dDViscosity = data[49].substring(0, data[49].indexOf(".") + 6);
that.meterResult.dDExpCoefficient = data[50].substring(0, data[50].indexOf(".") + 6);
that.meterResult.dRnPipe = data[51].substring(0, data[51].indexOf(".") + 2);
that.meterResult.dBk = data[52].substring(0, data[52].indexOf(".") + 5);
that.meterResult.dRoughNessPipe = data[53].substring(0, data[53].indexOf(".") + 5);
that.meterResult.dVFlowb = data[56].substring(0, data[56].indexOf(".") + 5);
that.meterResult.dVFlowf = data[57].substring(0, data[57].indexOf(".") + 5);
that.meterResult.dMFlowb = data[58].substring(0, data[58].indexOf(".") + 5);
that.meterResult.dEFlowb = data[59].substring(0, data[59].indexOf(".") + 5);
that.meterResult.dVelocityFlow = data[60].substring(0, data[60].indexOf(".") + 5);
that.meterResult.dPressLost = data[61].substring(0, data[61].indexOf(".") + 5);
that.meterResult.dBeta = data[62].substring(0, data[62].indexOf(".") + 5);
that.meterResult.dZb = data[64].substring(0, data[64].indexOf(".") + 6);
that.meterResult.dZf = data[65].substring(0, data[65].indexOf(".") + 6);
that.meterResult.dFpv = data[66].substring(0, data[66].indexOf(".") + 6);
that.meterResult.dKappa = data[80].substring(0, data[80].indexOf(".") + 6);
that.current = 2;
console.log(that.meterResult)
},
fail: function(res) {
console.log(res)
}
})
},
save() {
}
},
}
</script>
<style>
.uni-button-group {
margin-top: 0px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.mini-btn {
width: 100px;
margin-right: 10px;
margin-bottom: 10px;
}
</style>

View File

@ -0,0 +1,295 @@
<template>
<view>
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="临界流流量计算" @clickLeft="back" />
<uni-card>
<!-- <view class="uni-button-group">
<uni-row width="100%">
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="cal">计算</button>
</uni-col>
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="save">打印结果</button>
</uni-col>
</uni-row>
</view> -->
<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="button"
activeColor="#4cd964"></uni-segmented-control>
</uni-card>
<view class="content">
<view v-show="current === 0">
<yjly-ngtools-meterPar :meter-type="2" v-model="meterPar"
@calEnable="meterEnable"></yjly-ngtools-meterPar>
</view>
<view v-show="current === 1">
<yjly-ngtools-NGComponents @calEnable="NGEnable" v-model="strNG"></yjly-ngtools-NGComponents>
</view>
<view v-show="current === 2">
<yjly-ngtools-meterResult :meter-type="2" :formData="meterResult"></yjly-ngtools-meterResult>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
items: ['仪表参数', '组分参数', '计算结果'],
current: 0,
strNG: "",
meterPar: [],
meterResult: {
"dCd": "",
"dCdCalMethod": "",
"dMeterFactor": "",
"dPulseNum": "",
"dVFlowMax": "",
"dVFlowMin": "",
"dVFlowCon": "",
"dPfRangeMin": "",
"dPfRangeMax": "",
"dDpRangeMin": "",
"dDpRangeMax": "",
"dTfRangeMin": "",
"dTfRangeMax": "",
"dE": "",
"dFG": "",
"dFT": "",
"dDViscosity": "",
"dDExpCoefficient": "",
"dRnPipe": "",
"dBk": "",
"dRoughNessPipe": "",
"dCdCorrect": "",
"dCdNozell": "",
"dVFlowb": "",
"dVFlowf": "",
"dMFlowb": "",
"dEFlowb": "",
"dVelocityFlow": "",
"dPressLost": "",
"dBeta": "",
"dKappa": "",
"updateTime": null,
"createTime": null
},
NGFlag: false,
meterFlag: false
};
},
watch: {
strNG: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
meterPar: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
},
methods: {
NGEnable(e) {
console.log(e)
this.NGFlag = e
},
meterEnable(e) {
console.log(e)
this.meterFlag = e
},
zeroPar() {
this.meterResult.dCd = "0";
this.meterResult.dCdCalMethod = "0";
this.meterResult.dMeterFactor = "0";
this.meterResult.dPulseNum = "0";
this.meterResult.dVFlowMax = "0";
this.meterResult.dVFlowMin = "0";
this.meterResult.dVFlowCon = "0";
this.meterResult.dPfRangeMin = "0";
this.meterResult.dPfRangeMax = "0";
this.meterResult.dDpRangeMin = "0";
this.meterResult.dDpRangeMax = "0";
this.meterResult.dTfRangeMin = "0";
this.meterResult.dTfRangeMax = "0";
this.meterResult.dE = "0";
this.meterResult.dFG = "0";
this.meterResult.dFT = "0";
this.meterResult.dDViscosity = "0";
this.meterResult.dDExpCoefficient = "0";
this.meterResult.dRnPipe = "0";
this.meterResult.dBk = "0";
this.meterResult.dRoughNessPipe = "0";
this.meterResult.dCdCorrect = "0";
this.meterResult.dCdNozell = "0";
this.meterResult.dVFlowb = "0";
this.meterResult.dVFlowf = "0";
this.meterResult.dMFlowb = "0";
this.meterResult.dEFlowb = "0";
this.meterResult.dVelocityFlow = "0";
this.meterResult.dPressLost = "0";
this.meterResult.dBeta = "0";
this.meterResult.dKappa = "0";
this.meterResult.dCstar = "0";
},
onClickItem(e) {
if (this.current != e.currentIndex) {
this.current = e.currentIndex;
this.$nextTick(() => {
if (this.current == 2) {
this.cal();
}
}, 500)
}
},
back() {
uni.navigateBack({
delta: 1
})
},
cal() {
if (!this.NGFlag) {
// uni.navigateTo({
// url: '/pages/grid/popup?title=""&text=""'
// })
uni.showModal({
title: '提示',
content: '组分摩尔百分数合计不为100%,请检查并重新输入',
icon: 'none',
showCancel: false
})
this.current = 1;
return
}
if (!this.meterFlag) {
uni.showModal({
title: '提示',
content: '工艺参数输入不完整,请检查并重新输入',
icon: 'none',
showCancel: false
})
this.current = 0;
return
}
var NG_par = ""
NG_par = this.meterPar.dMeterType; //
NG_par = NG_par + "," + this.meterPar.dCoreType; //
NG_par = NG_par + "," + this.meterPar.dFlowCalbz; //
NG_par = NG_par + "," + this.meterPar.dZcalbz; //
NG_par = NG_par + "," + this.meterPar.dCbtj; //'
NG_par = NG_par + "," + this.meterPar.dPb_M; //
NG_par = NG_par + "," + this.meterPar.dTb_M; //
NG_par = NG_par + "," + this.meterPar.dPb_E; //
NG_par = NG_par + "," + this.meterPar.dTb_E; //
NG_par = NG_par + "," + this.meterPar.dPatm; //
NG_par = NG_par + "," + this.meterPar.dPatmUnit; //
NG_par = NG_par + "," + this.strNG; //
NG_par = NG_par + "," + this.meterPar.dPtmode; //
NG_par = NG_par + "," + this.meterPar.dPipeType; //
NG_par = NG_par + "," + this.meterPar.dPipeD; //
NG_par = NG_par + "," + this.meterPar.dLenUnit; //
NG_par = NG_par + "," + this.meterPar.dPipeDtemp; //
NG_par = NG_par + "," + this.meterPar.dPileDtempU; //
NG_par = NG_par + "," + this.meterPar.dPipeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeD; //
NG_par = NG_par + "," + this.meterPar.dOrificeUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtemp; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtempUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeSharpness; //
NG_par = NG_par + "," + this.meterPar.dOrificeRk; //
NG_par = NG_par + "," + this.meterPar.dOrificeRkLenU; //
NG_par = NG_par + "," + this.meterPar.dPf; //
NG_par = NG_par + "," + this.meterPar.dPfUnit; //
NG_par = NG_par + "," + this.meterPar.dPfType; //
NG_par = NG_par + "," + this.meterPar.dTf; //
NG_par = NG_par + "," + this.meterPar.dTfUnit; //
// NG_par = NG_par + "," + this.meterPar.dPulseNum; //
NG_par = NG_par + "," + this.meterPar.dDp; //
NG_par = NG_par + "," + this.meterPar.dDpUnit; //
NG_par = NG_par + "," + this.meterPar.dVFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dMFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dEFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dCd; //
console.log(NG_par);
var that = this;
var url = "";
// #ifdef MP-WEIXIN
url="https://ngtools.cn:8443";
// #endif
// #ifdef H5
url = "/api"
// #endif
console.log(url)
uni.request({
url: url + '/PZFlowcal',
type: 'GET',
datatype: 'json',
sslVerify: false,
data: {
"par": NG_par
},
timeout: 10000, //10
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function(res) {
console.log(res)
var data = JSON.stringify(res.data.message).toString().replace('[', '').replace(']',
'').split(
',');
that.meterResult.dVFlowb = data[56].substring(0, data[56].indexOf(".") + 5);
that.meterResult.dVFlowf = data[57].substring(0, data[57].indexOf(".") + 5);
that.meterResult.dMFlowb = data[58].substring(0, data[58].indexOf(".") + 5);
that.meterResult.dEFlowb = data[59].substring(0, data[59].indexOf(".") + 5);
that.meterResult.dZb = data[64].substring(0, data[64].indexOf(".") + 6);
that.meterResult.dZf = data[65].substring(0, data[65].indexOf(".") + 6);
that.meterResult.dKappa = data[80].substring(0, data[80].indexOf(".") + 6);
that.meterResult.dCstar = data[82].substring(0, data[82].indexOf(".") + 6);
that.current = 2;
console.log(that.meterResult)
},
fail: function(err) {
console.log(err)
}
})
},
save() {
}
},
}
</script>
<style>
.uni-button-group {
margin-top: 0px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.mini-btn {
width: 100px;
margin-right: 10px;
margin-bottom: 10px;
}
</style>

View File

@ -0,0 +1,293 @@
<template>
<view>
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="速度式流量计算" @clickLeft="back" />
<uni-card>
<!-- <view class="uni-button-group">
<uni-row width="100%">
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="cal">计算</button>
</uni-col>
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="save">打印结果</button>
</uni-col>
</uni-row>
</view> -->
<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="button"
activeColor="#4cd964"></uni-segmented-control>
</uni-card>
<view class="content">
<view v-show="current === 0">
<yjly-ngtools-meterPar :meter-type="1" v-model="meterPar"
@calEnable="meterEnable"></yjly-ngtools-meterPar>
</view>
<view v-show="current === 1">
<yjly-ngtools-NGComponents @calEnable="NGEnable" v-model="strNG"></yjly-ngtools-NGComponents>
</view>
<view v-show="current === 2">
<yjly-ngtools-meterResult :meter-type="1" :formData="meterResult"></yjly-ngtools-meterResult>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
items: ['仪表参数', '组分参数', '计算结果'],
current: 0,
strNG: "",
meterPar: [],
meterResult: {
"dCd": "",
"dCdCalMethod": "",
"dMeterFactor": "",
"dPulseNum": "",
"dVFlowMax": "",
"dVFlowMin": "",
"dVFlowCon": "",
"dPfRangeMin": "",
"dPfRangeMax": "",
"dDpRangeMin": "",
"dDpRangeMax": "",
"dTfRangeMin": "",
"dTfRangeMax": "",
"dE": "",
"dFG": "",
"dFT": "",
"dDViscosity": "",
"dDExpCoefficient": "",
"dRnPipe": "",
"dBk": "",
"dRoughNessPipe": "",
"dCdCorrect": "",
"dCdNozell": "",
"dVFlowb": "",
"dVFlowf": "",
"dMFlowb": "",
"dEFlowb": "",
"dVelocityFlow": "",
"dPressLost": "",
"dBeta": "",
"dKappa": "",
"updateTime": null,
"createTime": null
},
NGFlag: false,
meterFlag: false
};
},
watch: {
strNG: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
meterPar: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
},
methods: {
NGEnable(e) {
console.log(e)
this.NGFlag = e
},
meterEnable(e) {
console.log(e)
this.meterFlag = e
},
zeroPar() {
this.meterResult.dCd = "0";
this.meterResult.dCdCalMethod = "0";
this.meterResult.dMeterFactor = "0";
this.meterResult.dPulseNum = "0";
this.meterResult.dVFlowMax = "0";
this.meterResult.dVFlowMin = "0";
this.meterResult.dVFlowCon = "0";
this.meterResult.dPfRangeMin = "0";
this.meterResult.dPfRangeMax = "0";
this.meterResult.dDpRangeMin = "0";
this.meterResult.dDpRangeMax = "0";
this.meterResult.dTfRangeMin = "0";
this.meterResult.dTfRangeMax = "0";
this.meterResult.dE = "0";
this.meterResult.dFG = "0";
this.meterResult.dFT = "0";
this.meterResult.dDViscosity = "0";
this.meterResult.dDExpCoefficient = "0";
this.meterResult.dRnPipe = "0";
this.meterResult.dBk = "0";
this.meterResult.dRoughNessPipe = "0";
this.meterResult.dCdCorrect = "0";
this.meterResult.dCdNozell = "0";
this.meterResult.dVFlowb = "0";
this.meterResult.dVFlowf = "0";
this.meterResult.dMFlowb = "0";
this.meterResult.dEFlowb = "0";
this.meterResult.dVelocityFlow = "0";
this.meterResult.dPressLost = "0";
this.meterResult.dBeta = "0";
this.meterResult.dKappa = "0";
},
onClickItem(e) {
if (this.current != e.currentIndex) {
this.current = e.currentIndex;
this.$nextTick(() => {
if (this.current == 2) {
this.cal();
}
}, 500)
}
},
back() {
uni.navigateBack({
delta: 1
})
},
cal() {
if (!this.NGFlag) {
// uni.navigateTo({
// url: '/pages/grid/popup?title=""&text=""'
// })
uni.showModal({
title: '提示',
content: '组分摩尔百分数合计不为100%,请检查并重新输入',
icon: 'none',
showCancel: false
})
this.current = 1;
return
}
if (!this.meterFlag) {
uni.showModal({
title: '提示',
content: '工艺参数输入不完整,请检查并重新输入',
icon: 'none',
showCancel: false
})
this.current = 0;
return
}
var NG_par = ""
NG_par = this.meterPar.dMeterType; //
NG_par = NG_par + "," + this.meterPar.dCoreType; //
NG_par = NG_par + "," + this.meterPar.dFlowCalbz; //
NG_par = NG_par + "," + this.meterPar.dZcalbz; //
NG_par = NG_par + "," + this.meterPar.dCbtj; //'
NG_par = NG_par + "," + this.meterPar.dPb_M; //
NG_par = NG_par + "," + this.meterPar.dTb_M; //
NG_par = NG_par + "," + this.meterPar.dPb_E; //
NG_par = NG_par + "," + this.meterPar.dTb_E; //
NG_par = NG_par + "," + this.meterPar.dPatm; //
NG_par = NG_par + "," + this.meterPar.dPatmUnit; //
NG_par = NG_par + "," + this.strNG; //
NG_par = NG_par + "," + this.meterPar.dPtmode; //
NG_par = NG_par + "," + this.meterPar.dPipeType; //
NG_par = NG_par + "," + this.meterPar.dPipeD; //
NG_par = NG_par + "," + this.meterPar.dLenUnit; //
NG_par = NG_par + "," + this.meterPar.dPipeDtemp; //
NG_par = NG_par + "," + this.meterPar.dPileDtempU; //
NG_par = NG_par + "," + this.meterPar.dPipeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeD; //
NG_par = NG_par + "," + this.meterPar.dOrificeUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtemp; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtempUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeSharpness; //
NG_par = NG_par + "," + this.meterPar.dOrificeRk; //
NG_par = NG_par + "," + this.meterPar.dOrificeRkLenU; //
NG_par = NG_par + "," + this.meterPar.dPf; //
NG_par = NG_par + "," + this.meterPar.dPfUnit; //
NG_par = NG_par + "," + this.meterPar.dPfType; //
NG_par = NG_par + "," + this.meterPar.dTf; //
NG_par = NG_par + "," + this.meterPar.dTfUnit; //
NG_par = NG_par + "," + this.meterPar.dPulseNum; //
// NG_par = NG_par + "," + this.meterPar.dDp; //
NG_par = NG_par + "," + this.meterPar.dDpUnit; //
NG_par = NG_par + "," + this.meterPar.dVFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dMFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dEFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dMeterFactor; //
console.log(NG_par);
var that = this;
var url = "";
// #ifdef MP-WEIXIN
url="https://ngtools.cn:8443";
// #endif
// #ifdef H5
url = "/api"
// #endif
console.log(url)
uni.request({
url: url + '/SDFlowcal',
type: 'GET',
datatype: 'json',
sslVerify: false,
data: {
"par": NG_par
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
timeout: 1000, //10
success: function(res) {
var data = JSON.stringify(res.data.message).toString().replace('[', '').replace(']',
'').split(
',');
console.log(JSON.stringify(res.data));
that.meterResult.dVFlowb = data[56].substring(0, data[56].indexOf(".") + 5);
that.meterResult.dVFlowf = data[57].substring(0, data[57].indexOf(".") + 5);
that.meterResult.dMFlowb = data[58].substring(0, data[58].indexOf(".") + 5);
that.meterResult.dEFlowb = data[59].substring(0, data[59].indexOf(".") + 5);
// that.meterResult.dVelocityFlow = data[60].substring(0, data[60].indexOf(".") + 5);
// that.meterResult.dBeta = data[62].substring(0, data[62].indexOf(".") + 5);
that.meterResult.dZb = data[64].substring(0, data[64].indexOf(".") + 6);
that.meterResult.dZf = data[65].substring(0, data[65].indexOf(".") + 6);
// that.meterResult.dKappa = data[80].substring(0, data[80].indexOf(".") + 6);
that.current = 2;
console.log(that.meterResult)
},
fail: function(err) {
console.log(err)
}
})
},
save() {
}
},
}
</script>
<style>
.uni-button-group {
margin-top: 0px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.mini-btn {
width: 100px;
margin-right: 10px;
margin-bottom: 10px;
}
</style>

View File

@ -0,0 +1,367 @@
<template>
<view>
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="压缩因子表格" @clickLeft="back" />
<uni-card>
<!-- <view class="uni-button-group">
<uni-row width="100%">
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="cal">计算</button>
</uni-col>
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="save">打印结果</button>
</uni-col>
</uni-row>
</view> -->
<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="button"
activeColor="#4cd964"></uni-segmented-control>
</uni-card>
<view class="content">
<view v-show="current === 0">
<yjly-ngtools-meterPar :meter-type="10" v-model="meterPar" @calEnable="meterEnable">
</yjly-ngtools-meterPar>
</view>
<view v-show="current === 1">
<yjly-ngtools-NGComponents @calEnable="NGEnable" v-model="strNG">
</yjly-ngtools-NGComponents>
</view>
<view v-show="current === 2">
<!-- <yjly-ngtools-ParResult :formData="meterResult" :meter-type="10">
</yjly-ngtools-ParResult> -->
<uni-card>
<view class="table" v-html="strResult">
</view>
</uni-card>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
items: ['工艺参数', '组分参数', '计算结果'],
current: 0,
strNG: "",
meterPar: [],
meterResult: {
"adMixture": "",
"adMixtureV": "",
"adMixtureD": "",
"dCbtj": "",
"dPb": "",
"dTb": "",
"dPf": "",
"dTf": "",
"dMrx": "",
"dZb": "",
"dZf": "",
"dFpv": "",
"dDb": "",
"dDf": "",
"dRhob": "",
"dRhof": "",
"dRD_Ideal": "",
"dRD_Real": "",
"dHo": "",
"dH": "",
"dS": "",
"dCpi": "",
"dCp": "",
"dCv": "",
"dk": "",
"dKappa": "",
"dSOS": "",
"dCstar": "",
"dHhvMol": "",
"dLhvMol": "",
"dHhvv": "",
"dLhvv": "",
"dHhvm": "",
"dLhvm": "",
"dZb11062": "",
"dRhob11062": "",
"dRhof11062": "",
"dRD_Ideal11062": "",
"dRD_Real11062": "",
"dWobbeIndex": "",
"Pc": "",
"TC": "",
"Bzsx": "",
"Bzxx": "",
"TotalC": "",
"C2": "",
"C2j": "",
"C3j": "",
"C4j": "",
"C5j": "",
"C6j": "",
"C3C4": ""
},
NGFlag: false,
meterFlag: false,
strResult: null
};
},
watch: {
strNG: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
meterPar: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
},
methods: {
NGEnable(e) {
console.log(e)
this.NGFlag = e
},
meterEnable(e) {
console.log(e)
this.meterFlag = e
},
zeroPar() {
this.meterResult.adMixture = "0";
this.meterResult.adMixtureV = "0";
this.meterResult.adMixtureD = "0";
this.meterResult.dCbtj = "0";
this.meterResult.dPb = "0";
this.meterResult.dTb = "0";
this.meterResult.dPf = "0";
this.meterResult.dTf = "0";
this.meterResult.dMrx = "0";
this.meterResult.dZb = "0";
this.meterResult.dZf = "0";
this.meterResult.dFpv = "0";
this.meterResult.dDb = "0";
this.meterResult.dDf = "0";
this.meterResult.dRhob = "0";
this.meterResult.dRhof = "0";
this.meterResult.dRD_Ideal = "0";
this.meterResult.dRD_Real = "0";
this.meterResult.dHo = "0";
this.meterResult.dH = "0";
this.meterResult.dS = "0";
this.meterResult.dCpi = "0";
this.meterResult.dCp = "0";
this.meterResult.dCv = "0";
this.meterResult.dk = "0";
this.meterResult.dKappa = "0";
this.meterResult.dSOS = "0";
this.meterResult.dCstar = "0";
this.meterResult.dHhvMol = "0";
this.meterResult.dLhvMol = "0";
this.meterResult.dHhvv = "0";
this.meterResult.dLhvv = "0";
this.meterResult.dHhvm = "0";
this.meterResult.dLhvm = "0";
this.meterResult.dZb11062 = "0";
this.meterResult.dRhob11062 = "0";
this.meterResult.dRhof11062 = "0";
this.meterResult.dRD_Ideal11062 = "0";
this.meterResult.dRD_Real11062 = "0";
this.meterResult.dWobbeIndex = "0";
this.meterResult.Pc = "0";
this.meterResult.TC = "0";
this.meterResult.Bzsx = "0";
this.meterResult.Bzxx = "0";
this.meterResult.TotalC = "0";
this.meterResult.C2 = "0";
this.meterResult.C2j = "0";
this.meterResult.C3j = "0";
this.meterResult.C4j = "0";
this.meterResult.C5j = "0";
this.meterResult.C6j = "0";
this.meterResult.C3C4 = "0"
},
onClickItem(e) {
if (this.current != e.currentIndex) {
this.current = e.currentIndex;
this.$nextTick(() => {
if (this.current == 2) {
this.cal();
}
}, 500)
}
},
back() {
uni.navigateBack({
delta: 1
})
},
cal() {
if (!this.NGFlag) {
// uni.navigateTo({
// url: '/pages/grid/popup?title=""&text=""'
// })
uni.showModal({
title: '提示',
content: '组分摩尔百分数合计不为100%,请检查并重新输入',
icon: 'none',
showCancel: false
})
this.current = 1;
return
}
if (!this.meterFlag) {
uni.showModal({
title: '提示',
content: '工艺参数输入不完整,请检查并重新输入',
icon: 'none',
showCancel: false
})
this.current = 0;
return
}
var NG_par = ""
NG_par = "0"; //
NG_par = NG_par + "," + this.meterPar.dCoreType; //
NG_par = NG_par + "," + this.meterPar.dFlowCalbz; //
NG_par = NG_par + "," + this.meterPar.dZcalbz; //
NG_par = NG_par + "," + this.meterPar.dCbtj; //'
NG_par = NG_par + "," + this.meterPar.dPb_M; //
NG_par = NG_par + "," + this.meterPar.dTb_M; //
NG_par = NG_par + "," + this.meterPar.dPb_E; //
NG_par = NG_par + "," + this.meterPar.dTb_E; //
NG_par = NG_par + "," + this.meterPar.dPatm; //
NG_par = NG_par + "," + this.meterPar.dPatmUnit; //
NG_par = NG_par + "," + this.strNG; //
NG_par = NG_par + "," + this.meterPar.dPtmode; //
NG_par = NG_par + "," + this.meterPar.dPipeType; //
NG_par = NG_par + "," + this.meterPar.dPipeD; //
NG_par = NG_par + "," + this.meterPar.dLenUnit; //
NG_par = NG_par + "," + this.meterPar.dPipeDtemp; //
NG_par = NG_par + "," + this.meterPar.dPileDtempU; //
NG_par = NG_par + "," + this.meterPar.dPipeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeD; //
NG_par = NG_par + "," + this.meterPar.dOrificeUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtemp; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtempUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeSharpness; //
NG_par = NG_par + "," + this.meterPar.dOrificeRk; //
NG_par = NG_par + "," + this.meterPar.dOrificeRkLenU; //
NG_par = NG_par + "," + this.meterPar.dPf; //
NG_par = NG_par + "," + this.meterPar.dPfUnit; //
NG_par = NG_par + "," + this.meterPar.dPfType; //
NG_par = NG_par + "," + this.meterPar.dTf; //
NG_par = NG_par + "," + this.meterPar.dTfUnit; //
NG_par = NG_par + "," + this.meterPar.dDp; //
NG_par = NG_par + "," + this.meterPar.dDpUnit; //
NG_par = NG_par + "," + this.meterPar.dVFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dMFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dEFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dPStep; //
NG_par = NG_par + "," + this.meterPar.dTStep; //
NG_par = NG_par + "," + this.meterPar.dPEnd; //
NG_par = NG_par + "," + this.meterPar.dTEnd; //
console.log(NG_par);
var that = this;
var url = "";
// #ifdef MP-WEIXIN
url = "https://ngtools.cn:8443";
// #endif
// #ifdef H5
url = "/api"
// #endif
console.log(url)
uni.request({
url: url + '/ZTCal',
type: 'GET',
sslVerify: false,
datatype: 'json',
data: {
"par": NG_par
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
timeout: 1000, //10
success: function(res) {
that.strResult = that.arrayToTable(res.data.result);
console.log(that.strResult)
that.current = 2;
},
})
},
save() {
},
arrayToTable(array) {
let table = '<table border="1px solid #ccc">\n';
//
table += '<tr>\n';
for (let i = 0; i < array[0].length; i++) {
table += `<th>${array[0][i]}</th>\n`;
}
table += '</tr>\n';
//
for (let i = 1; i < array.length; i++) {
table += '<tr>\n';
for (let j = 0; j < array[i].length; j++) {
table += `<td style="width:100px">${array[i][j]}</td>\n`;
}
table += '</tr>\n';
}
table += '</table>';
return table;
}
},
}
</script>
<style>
.uni-button-group {
margin-top: 0px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.mini-btn {
width: 100px;
margin-right: 10px;
margin-bottom: 10px;
}
.table {
height: 70VH;
/* 设置固定高度 */
overflow-y: auto;
/* 开启垂直滚动条 */
overflow-x: auto;
/* 隐藏水平滚动条 */
scroll-snap-type: x;
border-width: 1px;
}
</style>

View File

@ -0,0 +1,342 @@
<template>
<view>
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="密度热值计算 (GB/T11062)" @clickLeft="back" />
<uni-card>
<!-- <view class="uni-button-group">
<uni-row width="100%">
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="cal">计算</button>
</uni-col>
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="save">打印结果</button>
</uni-col>
</uni-row>
</view> -->
<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="button"
activeColor="#4cd964"></uni-segmented-control>
</uni-card>
<view class="content">
<view v-show="current === 0">
<yjly-ngtools-meterPar :meter-type="4" v-model="meterPar" @calEnable="meterEnable">
</yjly-ngtools-meterPar>
</view>
<view v-show="current === 1">
<yjly-ngtools-NGComponents @calEnable="NGEnable" v-model="strNG">
</yjly-ngtools-NGComponents>
</view>
<view v-show="current === 2">
<yjly-ngtools-ParResult :formData="meterResult" :meter-type="4">
</yjly-ngtools-ParResult>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
items: ['工艺参数', '组分参数', '计算结果'],
current: 0,
strNG: "",
meterPar: [],
meterResult: {
"adMixture": "",
"adMixtureV": "",
"adMixtureD": "",
"dCbtj": "",
"dPb": "",
"dTb": "",
"dPf": "",
"dTf": "",
"dMrx": "",
"dZb": "",
"dZf": "",
"dFpv": "",
"dDb": "",
"dDf": "",
"dRhob": "",
"dRhof": "",
"dRD_Ideal": "",
"dRD_Real": "",
"dHo": "",
"dH": "",
"dS": "",
"dCpi": "",
"dCp": "",
"dCv": "",
"dk": "",
"dKappa": "",
"dSOS": "",
"dCstar": "",
"dHhvMol": "",
"dLhvMol": "",
"dHhvv": "",
"dLhvv": "",
"dHhvm": "",
"dLhvm": "",
"dZb11062": "",
"dRhob11062": "",
"dRhof11062": "",
"dRD_Ideal11062": "",
"dRD_Real11062": "",
"dWobbeIndex": "",
"Pc": "",
"TC": "",
"Bzsx": "",
"Bzxx": "",
"TotalC": "",
"C2": "",
"C2j": "",
"C3j": "",
"C4j": "",
"C5j": "",
"C6j": "",
"C3C4": ""
},
NGFlag: false,
meterFlag: false
};
},
watch: {
strNG: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
meterPar: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
},
methods: {
NGEnable(e) {
console.log(e)
this.NGFlag = e
},
meterEnable(e) {
console.log(e)
this.meterFlag = e
},
zeroPar() {
this.meterResult.adMixture = "0";
this.meterResult.adMixtureV = "0";
this.meterResult.adMixtureD = "0";
this.meterResult.dCbtj = "0";
this.meterResult.dPb = "0";
this.meterResult.dTb = "0";
this.meterResult.dPf = "0";
this.meterResult.dTf = "0";
this.meterResult.dMrx = "0";
this.meterResult.dZb = "0";
this.meterResult.dZf = "0";
this.meterResult.dFpv = "0";
this.meterResult.dDb = "0";
this.meterResult.dDf = "0";
this.meterResult.dRhob = "0";
this.meterResult.dRhof = "0";
this.meterResult.dRD_Ideal = "0";
this.meterResult.dRD_Real = "0";
this.meterResult.dHo = "0";
this.meterResult.dH = "0";
this.meterResult.dS = "0";
this.meterResult.dCpi = "0";
this.meterResult.dCp = "0";
this.meterResult.dCv = "0";
this.meterResult.dk = "0";
this.meterResult.dKappa = "0";
this.meterResult.dSOS = "0";
this.meterResult.dCstar = "0";
this.meterResult.dHhvMol = "0";
this.meterResult.dLhvMol = "0";
this.meterResult.dHhvv = "0";
this.meterResult.dLhvv = "0";
this.meterResult.dHhvm = "0";
this.meterResult.dLhvm = "0";
this.meterResult.dZb11062 = "0";
this.meterResult.dRhob11062 = "0";
this.meterResult.dRhof11062 = "0";
this.meterResult.dRD_Ideal11062 = "0";
this.meterResult.dRD_Real11062 = "0";
this.meterResult.dWobbeIndex = "0";
this.meterResult.Pc = "0";
this.meterResult.TC = "0";
this.meterResult.Bzsx = "0";
this.meterResult.Bzxx = "0";
this.meterResult.TotalC = "0";
this.meterResult.C2 = "0";
this.meterResult.C2j = "0";
this.meterResult.C3j = "0";
this.meterResult.C4j = "0";
this.meterResult.C5j = "0";
this.meterResult.C6j = "0";
this.meterResult.C3C4 = "0"
},
onClickItem(e) {
if (this.current != e.currentIndex) {
this.current = e.currentIndex;
this.$nextTick(() => {
if (this.current == 2) {
this.cal();
}
}, 500)
}
},
back() {
uni.navigateBack({
delta: 1
})
},
cal() {
if (!this.NGFlag) {
// uni.navigateTo({
// url: '/pages/grid/popup?title=""&text=""'
// })
uni.showModal({
title: '提示',
content: '组分摩尔百分数合计不为100%,请检查并重新输入',
icon: 'none',
showCancel: false
})
this.current = 1;
return
}
if (!this.meterFlag) {
uni.showModal({
title: '提示',
content: '工艺参数输入不完整,请检查并重新输入',
icon: 'none',
showCancel: false
})
this.current = 0;
return
}
var NG_par = ""
NG_par = "0"; //
NG_par = NG_par + "," + this.meterPar.dCoreType; //
NG_par = NG_par + "," + this.meterPar.dFlowCalbz; //
NG_par = NG_par + "," + this.meterPar.dZcalbz; //
NG_par = NG_par + "," + this.meterPar.dCbtj; //'
NG_par = NG_par + "," + this.meterPar.dPb_M; //
NG_par = NG_par + "," + this.meterPar.dTb_M; //
NG_par = NG_par + "," + this.meterPar.dPb_E; //
NG_par = NG_par + "," + this.meterPar.dTb_E; //
NG_par = NG_par + "," + this.meterPar.dPatm; //
NG_par = NG_par + "," + this.meterPar.dPatmUnit; //
NG_par = NG_par + "," + this.strNG; //
NG_par = NG_par + "," + this.meterPar.dPtmode; //
NG_par = NG_par + "," + this.meterPar.dPipeType; //
NG_par = NG_par + "," + this.meterPar.dPipeD; //
NG_par = NG_par + "," + this.meterPar.dLenUnit; //
NG_par = NG_par + "," + this.meterPar.dPipeDtemp; //
NG_par = NG_par + "," + this.meterPar.dPileDtempU; //
NG_par = NG_par + "," + this.meterPar.dPipeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeD; //
NG_par = NG_par + "," + this.meterPar.dOrificeUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtemp; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtempUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeSharpness; //
NG_par = NG_par + "," + this.meterPar.dOrificeRk; //
NG_par = NG_par + "," + this.meterPar.dOrificeRkLenU; //
NG_par = NG_par + "," + this.meterPar.dPf; //
NG_par = NG_par + "," + this.meterPar.dPfUnit; //
NG_par = NG_par + "," + this.meterPar.dPfType; //
NG_par = NG_par + "," + this.meterPar.dTf; //
NG_par = NG_par + "," + this.meterPar.dTfUnit; //
NG_par = NG_par + "," + this.meterPar.dDp; //
NG_par = NG_par + "," + this.meterPar.dDpUnit; //
NG_par = NG_par + "," + this.meterPar.dVFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dMFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dEFlowUnit; //
console.log(NG_par);
var that = this;
var url = "";
// #ifdef MP-WEIXIN
url="https://ngtools.cn:8443";
// #endif
// #ifdef H5
url = "/api"
// #endif
console.log(url)
uni.request({
url: url + '/ParCal',
type: 'GET',
sslVerify: false,
datatype: 'json',
data: {
"par": NG_par
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
timeout: 1000, //10
success: function(res) {
console.log(res.data)
var data = JSON.stringify(res.data.message).toString().replace('[', '').replace(']',
'').split(
',');
console.log(data)
that.meterResult.dMrx = data[63].substring(0, data[63].indexOf(".") + 6);
that.meterResult.dDb = data[67].substring(0, data[67].indexOf(".") + 6);
that.meterResult.dDf = data[68].substring(0, data[68].indexOf(".") + 6);
that.meterResult.dRhob = data[69].substring(0, data[69].indexOf(".") + 6);
that.meterResult.dRhof = data[70].substring(0, data[70].indexOf(".") + 6);
that.meterResult.dRD_Ideal = data[71].substring(0, data[71].indexOf(".") + 6);
that.meterResult.dRD_Real = data[72].substring(0, data[72].indexOf(".") + 6);
that.meterResult.dHhvMol = data[83].substring(0, data[83].indexOf(".") + 6);
that.meterResult.dLhvMol = data[84].substring(0, data[84].indexOf(".") + 6);
that.meterResult.dHhvv = data[85].substring(0, data[85].indexOf(".") + 6);
that.meterResult.dLhvv = data[86].substring(0, data[86].indexOf(".") + 6);
that.meterResult.dHhvm = data[87].substring(0, data[87].indexOf(".") + 6);
that.meterResult.dLhvm = data[88].substring(0, data[88].indexOf(".") + 6);
that.meterResult.dRhob11062 = data[90].substring(0, data[90].indexOf(".") + 6);
that.meterResult.dRhof11062 = data[91].substring(0, data[91].indexOf(".") + 6);
that.meterResult.dRD_Ideal11062 = data[92].substring(0, data[92].indexOf(".") + 6);
that.meterResult.dRD_Real11062 = data[93].substring(0, data[93].indexOf(".") + 6);
that.meterResult.dWobbeIndex = data[94].substring(0, data[94].indexOf(".") + 6);
that.current = 2;
},
})
},
save() {
}
},
}
</script>
<style>
.uni-button-group {
margin-top: 0px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.mini-btn {
width: 100px;
margin-right: 10px;
margin-bottom: 10px;
}
</style>

View File

@ -0,0 +1,335 @@
<template>
<view>
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="其他物性参数计算 " @clickLeft="back" />
<uni-card>
<!-- <view class="uni-button-group">
<uni-row width="100%">
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="cal">计算</button>
</uni-col>
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="save">打印结果</button>
</uni-col>
</uni-row>
</view> -->
<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="button"
activeColor="#4cd964"></uni-segmented-control>
</uni-card>
<view class="content">
<view v-show="current === 0">
<yjly-ngtools-meterPar :meter-type="5" v-model="meterPar" @calEnable="meterEnable">
</yjly-ngtools-meterPar>
</view>
<view v-show="current === 1">
<yjly-ngtools-NGComponents @calEnable="NGEnable" v-model="strNG">
</yjly-ngtools-NGComponents>
</view>
<view v-show="current === 2">
<yjly-ngtools-ParResult :formData="meterResult" :meter-type="5">
</yjly-ngtools-ParResult>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
items: ['工艺参数', '组分参数', '计算结果'],
current: 0,
strNG: "",
meterPar: [],
meterResult: {
"adMixture": "",
"adMixtureV": "",
"adMixtureD": "",
"dCbtj": "",
"dPb": "",
"dTb": "",
"dPf": "",
"dTf": "",
"dMrx": "",
"dZb": "",
"dZf": "",
"dFpv": "",
"dDb": "",
"dDf": "",
"dRhob": "",
"dRhof": "",
"dRD_Ideal": "",
"dRD_Real": "",
"dHo": "",
"dH": "",
"dS": "",
"dCpi": "",
"dCp": "",
"dCv": "",
"dk": "",
"dKappa": "",
"dSOS": "",
"dCstar": "",
"dHhvMol": "",
"dLhvMol": "",
"dHhvv": "",
"dLhvv": "",
"dHhvm": "",
"dLhvm": "",
"dZb11062": "",
"dRhob11062": "",
"dRhof11062": "",
"dRD_Ideal11062": "",
"dRD_Real11062": "",
"dWobbeIndex": "",
"Pc": "",
"TC": "",
"Bzsx": "",
"Bzxx": "",
"TotalC": "",
"C2": "",
"C2j": "",
"C3j": "",
"C4j": "",
"C5j": "",
"C6j": "",
"C3C4": ""
},
NGFlag: false,
meterFlag: false
};
},
watch: {
strNG: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
meterPar: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
},
methods: {
NGEnable(e) {
console.log(e)
this.NGFlag = e
},
meterEnable(e) {
console.log(e)
this.meterFlag = e
},
zeroPar() {
this.meterResult.adMixture = "0";
this.meterResult.adMixtureV = "0";
this.meterResult.adMixtureD = "0";
this.meterResult.dCbtj = "0";
this.meterResult.dPb = "0";
this.meterResult.dTb = "0";
this.meterResult.dPf = "0";
this.meterResult.dTf = "0";
this.meterResult.dMrx = "0";
this.meterResult.dZb = "0";
this.meterResult.dZf = "0";
this.meterResult.dFpv = "0";
this.meterResult.dDb = "0";
this.meterResult.dDf = "0";
this.meterResult.dRhob = "0";
this.meterResult.dRhof = "0";
this.meterResult.dRD_Ideal = "0";
this.meterResult.dRD_Real = "0";
this.meterResult.dHo = "0";
this.meterResult.dH = "0";
this.meterResult.dS = "0";
this.meterResult.dCpi = "0";
this.meterResult.dCp = "0";
this.meterResult.dCv = "0";
this.meterResult.dk = "0";
this.meterResult.dKappa = "0";
this.meterResult.dSOS = "0";
this.meterResult.dCstar = "0";
this.meterResult.dHhvMol = "0";
this.meterResult.dLhvMol = "0";
this.meterResult.dHhvv = "0";
this.meterResult.dLhvv = "0";
this.meterResult.dHhvm = "0";
this.meterResult.dLhvm = "0";
this.meterResult.dZb11062 = "0";
this.meterResult.dRhob11062 = "0";
this.meterResult.dRhof11062 = "0";
this.meterResult.dRD_Ideal11062 = "0";
this.meterResult.dRD_Real11062 = "0";
this.meterResult.dWobbeIndex = "0";
this.meterResult.Pc = "0";
this.meterResult.TC = "0";
this.meterResult.Bzsx = "0";
this.meterResult.Bzxx = "0";
this.meterResult.TotalC = "0";
this.meterResult.C2 = "0";
this.meterResult.C2j = "0";
this.meterResult.C3j = "0";
this.meterResult.C4j = "0";
this.meterResult.C5j = "0";
this.meterResult.C6j = "0";
this.meterResult.C3C4 = "0"
},
onClickItem(e) {
if (this.current != e.currentIndex) {
this.current = e.currentIndex;
this.$nextTick(() => {
if (this.current == 2) {
this.cal();
}
}, 500)
}
},
back() {
uni.navigateBack({
delta: 1
})
},
cal() {
if (!this.NGFlag) {
// uni.navigateTo({
// url: '/pages/grid/popup?title=""&text=""'
// })
uni.showModal({
title: '提示',
content: '组分摩尔百分数合计不为100%,请检查并重新输入',
icon: 'none',
showCancel: false
})
this.current = 1;
return
}
if (!this.meterFlag) {
uni.showModal({
title: '提示',
content: '工艺参数输入不完整,请检查并重新输入',
icon: 'none',
showCancel: false
})
this.current = 0;
return
}
var NG_par = ""
NG_par = "0"; //
NG_par = NG_par + "," + this.meterPar.dCoreType; //
NG_par = NG_par + "," + this.meterPar.dFlowCalbz; //
NG_par = NG_par + "," + this.meterPar.dZcalbz; //
NG_par = NG_par + "," + this.meterPar.dCbtj; //'
NG_par = NG_par + "," + this.meterPar.dPb_M; //
NG_par = NG_par + "," + this.meterPar.dTb_M; //
NG_par = NG_par + "," + this.meterPar.dPb_E; //
NG_par = NG_par + "," + this.meterPar.dTb_E; //
NG_par = NG_par + "," + this.meterPar.dPatm; //
NG_par = NG_par + "," + this.meterPar.dPatmUnit; //
NG_par = NG_par + "," + this.strNG; //
NG_par = NG_par + "," + this.meterPar.dPtmode; //
NG_par = NG_par + "," + this.meterPar.dPipeType; //
NG_par = NG_par + "," + this.meterPar.dPipeD; //
NG_par = NG_par + "," + this.meterPar.dLenUnit; //
NG_par = NG_par + "," + this.meterPar.dPipeDtemp; //
NG_par = NG_par + "," + this.meterPar.dPileDtempU; //
NG_par = NG_par + "," + this.meterPar.dPipeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeD; //
NG_par = NG_par + "," + this.meterPar.dOrificeUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtemp; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtempUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeSharpness; //
NG_par = NG_par + "," + this.meterPar.dOrificeRk; //
NG_par = NG_par + "," + this.meterPar.dOrificeRkLenU; //
NG_par = NG_par + "," + this.meterPar.dPf; //
NG_par = NG_par + "," + this.meterPar.dPfUnit; //
NG_par = NG_par + "," + this.meterPar.dPfType; //
NG_par = NG_par + "," + this.meterPar.dTf; //
NG_par = NG_par + "," + this.meterPar.dTfUnit; //
NG_par = NG_par + "," + this.meterPar.dDp; //
NG_par = NG_par + "," + this.meterPar.dDpUnit; //
NG_par = NG_par + "," + this.meterPar.dVFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dMFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dEFlowUnit; //
console.log(NG_par);
var that = this;
var url = "";
// #ifdef MP-WEIXIN
url = "https://ngtools.cn:8443";
// #endif
// #ifdef H5
url = "/api"
// #endif
console.log(url)
uni.request({
url: url + '/ParCal',
type: 'GET',
sslVerify: false,
datatype: 'json',
data: {
"par": NG_par
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
timeout: 1000, //10
success: function(res) {
console.log(res.data)
var data = JSON.stringify(res.data.message).toString().replace('[', '').replace(']',
'').split(
',');
console.log(data)
that.meterResult.Pc = data[95].substring(0, data[95].indexOf(".") + 6);
that.meterResult.TC = data[96].substring(0, data[96].indexOf(".") + 6);
that.meterResult.Bzsx = data[97].substring(0, data[97].indexOf(".") + 6);
that.meterResult.Bzxx = data[98].substring(0, data[98].indexOf(".") + 6);
that.meterResult.TotalC = data[99].substring(0, data[99].indexOf(".") + 4);
that.meterResult.C2 = data[100].substring(0, data[100].indexOf(".") + 4);
that.meterResult.C2j = data[101].substring(0, data[101].indexOf(".") + 4);
that.meterResult.C3j = data[102].substring(0, data[102].indexOf(".") + 4);
that.meterResult.C4j = data[103].substring(0, data[103].indexOf(".") + 4);
that.meterResult.C5j = data[104].substring(0, data[104].indexOf(".") + 4);
that.meterResult.C6j = data[105].substring(0, data[105].indexOf(".") + 4);
that.meterResult.C3C4 = data[106].substring(0, data[106].indexOf(".") + 4);
that.current = 2;
},
})
},
save() {
}
},
}
</script>
<style>
.uni-button-group {
margin-top: 0px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.mini-btn {
width: 100px;
margin-right: 10px;
margin-bottom: 10px;
}
</style>

View File

@ -0,0 +1,335 @@
<template>
<view>
<uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar left-icon="left" left-text="返回"
title="压缩因子(GB/T17747 AGA10)" @clickLeft="back" />
<uni-card>
<!-- <view class="uni-button-group">
<uni-row width="100%">
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="cal">计算</button>
</uni-col>
<uni-col :span="12"><button class="mini-btn" type="primary" size="mini" @click="save">打印结果</button>
</uni-col>
</uni-row>
</view> -->
<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="button"
activeColor="#4cd964"></uni-segmented-control>
</uni-card>
<view class="content">
<view v-show="current === 0">
<yjly-ngtools-meterPar :meter-type="4" v-model="meterPar" @calEnable="meterEnable">
</yjly-ngtools-meterPar>
</view>
<view v-show="current === 1">
<yjly-ngtools-NGComponents @calEnable="NGEnable" v-model="strNG">
</yjly-ngtools-NGComponents>
</view>
<view v-show="current === 2">
<yjly-ngtools-ParResult :formData="meterResult" :meter-type="3">
</yjly-ngtools-ParResult>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
items: ['工艺参数', '组分参数', '计算结果'],
current: 0,
strNG: "",
meterPar: [],
meterResult: {
"adMixture": "",
"adMixtureV": "",
"adMixtureD": "",
"dCbtj": "",
"dPb": "",
"dTb": "",
"dPf": "",
"dTf": "",
"dMrx": "",
"dZb": "",
"dZf": "",
"dFpv": "",
"dDb": "",
"dDf": "",
"dRhob": "",
"dRhof": "",
"dRD_Ideal": "",
"dRD_Real": "",
"dHo": "",
"dH": "",
"dS": "",
"dCpi": "",
"dCp": "",
"dCv": "",
"dk": "",
"dKappa": "",
"dSOS": "",
"dCstar": "",
"dHhvMol": "",
"dLhvMol": "",
"dHhvv": "",
"dLhvv": "",
"dHhvm": "",
"dLhvm": "",
"dZb11062": "",
"dRhob11062": "",
"dRhof11062": "",
"dRD_Ideal11062": "",
"dRD_Real11062": "",
"dWobbeIndex": "",
"Pc": "",
"TC": "",
"Bzsx": "",
"Bzxx": "",
"TotalC": "",
"C2": "",
"C2j": "",
"C3j": "",
"C4j": "",
"C5j": "",
"C6j": "",
"C3C4": ""
},
NGFlag: false,
meterFlag: false
};
},
watch: {
strNG: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
meterPar: {
immediate: true,
deep: true,
handler(val) {
this.zeroPar();
}
},
},
methods: {
NGEnable(e) {
console.log(e)
this.NGFlag = e
},
meterEnable(e) {
console.log(e)
this.meterFlag = e
},
zeroPar() {
this.meterResult.adMixture = "0";
this.meterResult.adMixtureV = "0";
this.meterResult.adMixtureD = "0";
this.meterResult.dCbtj = "0";
this.meterResult.dPb = "0";
this.meterResult.dTb = "0";
this.meterResult.dPf = "0";
this.meterResult.dTf = "0";
this.meterResult.dMrx = "0";
this.meterResult.dZb = "0";
this.meterResult.dZf = "0";
this.meterResult.dFpv = "0";
this.meterResult.dDb = "0";
this.meterResult.dDf = "0";
this.meterResult.dRhob = "0";
this.meterResult.dRhof = "0";
this.meterResult.dRD_Ideal = "0";
this.meterResult.dRD_Real = "0";
this.meterResult.dHo = "0";
this.meterResult.dH = "0";
this.meterResult.dS = "0";
this.meterResult.dCpi = "0";
this.meterResult.dCp = "0";
this.meterResult.dCv = "0";
this.meterResult.dk = "0";
this.meterResult.dKappa = "0";
this.meterResult.dSOS = "0";
this.meterResult.dCstar = "0";
this.meterResult.dHhvMol = "0";
this.meterResult.dLhvMol = "0";
this.meterResult.dHhvv = "0";
this.meterResult.dLhvv = "0";
this.meterResult.dHhvm = "0";
this.meterResult.dLhvm = "0";
this.meterResult.dZb11062 = "0";
this.meterResult.dRhob11062 = "0";
this.meterResult.dRhof11062 = "0";
this.meterResult.dRD_Ideal11062 = "0";
this.meterResult.dRD_Real11062 = "0";
this.meterResult.dWobbeIndex = "0";
this.meterResult.Pc = "0";
this.meterResult.TC = "0";
this.meterResult.Bzsx = "0";
this.meterResult.Bzxx = "0";
this.meterResult.TotalC = "0";
this.meterResult.C2 = "0";
this.meterResult.C2j = "0";
this.meterResult.C3j = "0";
this.meterResult.C4j = "0";
this.meterResult.C5j = "0";
this.meterResult.C6j = "0";
this.meterResult.C3C4 = "0"
},
onClickItem(e) {
if (this.current != e.currentIndex) {
this.current = e.currentIndex;
this.$nextTick(() => {
if (this.current == 2) {
this.cal();
}
}, 500)
}
},
back() {
uni.navigateBack({
delta: 1
})
},
cal() {
if (!this.NGFlag) {
// uni.navigateTo({
// url: '/pages/grid/popup?title=""&text=""'
// })
uni.showModal({
title: '提示',
content: '组分摩尔百分数合计不为100%,请检查并重新输入',
icon: 'none',
showCancel: false
})
this.current = 1;
return
}
if (!this.meterFlag) {
uni.showModal({
title: '提示',
content: '工艺参数输入不完整,请检查并重新输入',
icon: 'none',
showCancel: false
})
this.current = 0;
return
}
var NG_par = ""
NG_par = "0"; //
NG_par = NG_par + "," + this.meterPar.dCoreType; //
NG_par = NG_par + "," + this.meterPar.dFlowCalbz; //
NG_par = NG_par + "," + this.meterPar.dZcalbz; //
NG_par = NG_par + "," + this.meterPar.dCbtj; //'
NG_par = NG_par + "," + this.meterPar.dPb_M; //
NG_par = NG_par + "," + this.meterPar.dTb_M; //
NG_par = NG_par + "," + this.meterPar.dPb_E; //
NG_par = NG_par + "," + this.meterPar.dTb_E; //
NG_par = NG_par + "," + this.meterPar.dPatm; //
NG_par = NG_par + "," + this.meterPar.dPatmUnit; //
NG_par = NG_par + "," + this.strNG; //
NG_par = NG_par + "," + this.meterPar.dPtmode; //
NG_par = NG_par + "," + this.meterPar.dPipeType; //
NG_par = NG_par + "," + this.meterPar.dPipeD; //
NG_par = NG_par + "," + this.meterPar.dLenUnit; //
NG_par = NG_par + "," + this.meterPar.dPipeDtemp; //
NG_par = NG_par + "," + this.meterPar.dPileDtempU; //
NG_par = NG_par + "," + this.meterPar.dPipeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeD; //
NG_par = NG_par + "," + this.meterPar.dOrificeUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtemp; //
NG_par = NG_par + "," + this.meterPar.dOrificeDtempUnit; //
NG_par = NG_par + "," + this.meterPar.dOrificeMaterial; //
NG_par = NG_par + "," + this.meterPar.dOrificeSharpness; //
NG_par = NG_par + "," + this.meterPar.dOrificeRk; //
NG_par = NG_par + "," + this.meterPar.dOrificeRkLenU; //
NG_par = NG_par + "," + this.meterPar.dPf; //
NG_par = NG_par + "," + this.meterPar.dPfUnit; //
NG_par = NG_par + "," + this.meterPar.dPfType; //
NG_par = NG_par + "," + this.meterPar.dTf; //
NG_par = NG_par + "," + this.meterPar.dTfUnit; //
NG_par = NG_par + "," + this.meterPar.dDp; //
NG_par = NG_par + "," + this.meterPar.dDpUnit; //
NG_par = NG_par + "," + this.meterPar.dVFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dMFlowUnit; //
NG_par = NG_par + "," + this.meterPar.dEFlowUnit; //
console.log(NG_par);
var that = this;
var url = "";
// #ifdef MP-WEIXIN
url = "https://ngtools.cn:8443";
// #endif
// #ifdef H5
url = "/api"
// #endif
console.log(url)
uni.request({
url: url + '/ParCal',
type: 'GET',
sslVerify: false,
datatype: 'json',
data: {
"par": NG_par
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
timeout: 1000, //10
success: function(res) {
console.log(res.data)
var data = JSON.stringify(res.data.message).toString().replace('[', '').replace(']',
'').split(
',');
that.meterResult.dMrx = data[63].substring(0, data[63].indexOf(".") + 6);
that.meterResult.dZb = data[64].substring(0, data[64].indexOf(".") + 6);
that.meterResult.dZf = data[65].substring(0, data[65].indexOf(".") + 6);
that.meterResult.dFpv = data[66].substring(0, data[66].indexOf(".") + 6);
that.meterResult.dHo = data[73].substring(0, data[73].indexOf(".") + 6);
that.meterResult.dH = data[74].substring(0, data[74].indexOf(".") + 6);
that.meterResult.dS = data[75].substring(0, data[75].indexOf(".") + 6);
that.meterResult.dCpi = data[76].substring(0, data[76].indexOf(".") + 6);
that.meterResult.dCp = data[77].substring(0, data[77].indexOf(".") + 6);
that.meterResult.dCv = data[78].substring(0, data[78].indexOf(".") + 6);
that.meterResult.dk = data[79].substring(0, data[79].indexOf(".") + 6);
that.meterResult.dKappa = data[80].substring(0, data[80].indexOf(".") + 6);
that.meterResult.dSOS = data[81].substring(0, data[81].indexOf(".") + 6);
that.meterResult.dCstar = data[82].substring(0, data[82].indexOf(".") + 6);
that.meterResult.dZb11062 = data[89].substring(0, data[89].indexOf(".") + 6);
that.current = 2;
},
})
},
save() {
}
},
}
</script>
<style>
.uni-button-group {
margin-top: 0px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.mini-btn {
width: 100px;
margin-right: 10px;
margin-bottom: 10px;
}
</style>

View File

@ -0,0 +1,153 @@
<template>
<view class="uni-container">
<uni-forms ref="form" :model="formData" validate-trigger="submit" err-show-type="toast">
<uni-forms-item name="parent_id" label="">
<uni-easyinput placeholder="父ID用于多级分类" v-model="formData.parent_id"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="name" label="类别名称" required>
<uni-easyinput placeholder="类别名称" v-model="formData.name" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="icon" label="图标地址">
<uni-easyinput placeholder="类别图标/图片地址" v-model="formData.icon" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="sort" label="排序">
<uni-easyinput placeholder="类别排序,越大越靠后" type="number" v-model="formData.sort"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="description" label="类别描述">
<uni-easyinput placeholder="类别描述" v-model="formData.description" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="is_hot_show" label="加入热门显示">
<switch @change="binddata('is_hot_show', $event.detail.value)" :checked="formData.is_hot_show"></switch>
</uni-forms-item>
<uni-forms-item name="is_index_show" label="首页显示">
<switch @change="binddata('is_index_show', $event.detail.value)" :checked="formData.is_index_show"></switch>
</uni-forms-item>
<uni-forms-item name="create_date" label="">
<uni-datetime-picker return-type="timestamp" v-model="formData.create_date"></uni-datetime-picker>
</uni-forms-item>
<view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button>
</view>
</uni-forms>
</view>
</template>
<script>
import { validator } from '../../js_sdk/validator/ngtools-categories.js';
const db = uniCloud.database();
const dbCollectionName = 'ngtools-categories';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.indexOf(key) > -1) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"parent_id": "",
"name": "",
"icon": "",
"sort": null,
"description": "",
"is_hot_show": null,
"is_index_show": null,
"create_date": null
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {
}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使 clientDB
return db.collection(dbCollectionName).add(value).then((res) => {
uni.showToast({
icon: 'none',
title: '新增成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
}
}
}
</script>
<style>
.uni-container {
padding: 15px;
}
.uni-input-border,
.uni-textarea-border {
width: 100%;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
box-sizing: border-box;
}
.uni-input-border {
padding: 0 10px;
height: 35px;
}
.uni-textarea-border {
padding: 10px;
height: 80px;
}
.uni-button-group {
margin-top: 50px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.uni-button {
width: 184px;
}
</style>

View File

@ -0,0 +1,128 @@
<template>
<view class="container">
<unicloud-db ref="udb" v-slot:default="{data, loading, error, options}" :options="options" :collection="collectionList" field="parent_id,name,icon,sort,description,is_hot_show,is_index_show,create_date" :where="queryWhere" :getone="true" :manual="true">
<view v-if="error">{{error.message}}</view>
<view v-else-if="loading">
<uni-load-more :contentText="loadMore" status="loading"></uni-load-more>
</view>
<view v-else-if="data">
<view>
<text>parent_id</text>
<text>{{data.parent_id}}</text>
</view>
<view>
<text>类别名称</text>
<text>{{data.name}}</text>
</view>
<view>
<text>图标地址</text>
<text>{{data.icon}}</text>
</view>
<view>
<text>排序</text>
<text>{{data.sort}}</text>
</view>
<view>
<text>类别描述</text>
<text>{{data.description}}</text>
</view>
<view>
<text>加入热门显示</text>
<text>{{data.is_hot_show == true ? '✅' : '❌'}}</text>
</view>
<view>
<text>首页显示</text>
<text>{{data.is_index_show == true ? '✅' : '❌'}}</text>
</view>
<view>
<text>create_date</text>
<uni-dateformat :threshold="[0, 0]" :date="data.create_date"></uni-dateformat>
</view>
</view>
</unicloud-db>
<view class="btns">
<button type="primary" @click="handleUpdate">修改</button>
<button type="warn" class="btn-delete" @click="handleDelete">删除</button>
</view>
</view>
</template>
<script>
// schema2codeenum
import { enumConverter } from '../../js_sdk/validator/ngtools-categories.js'
const db = uniCloud.database()
export default {
data() {
return {
queryWhere: '',
collectionList: "ngtools-categories",
loadMore: {
contentdown: '',
contentrefresh: '',
contentnomore: ''
},
options: {
// scheme enum valuetext
...enumConverter
}
}
},
onLoad(e) {
this._id = e.id
},
onReady() {
if (this._id) {
this.queryWhere = '_id=="' + this._id + '"'
}
},
methods: {
handleUpdate() {
//
uni.navigateTo({
url: './edit?id=' + this._id,
events: {
// ,
refreshData: () => {
this.$refs.udb.loadData({
clear: true
})
}
}
})
},
handleDelete() {
this.$refs.udb.remove(this._id, {
success: (res) => {
// list
uni.navigateTo({
url: './list'
})
}
})
}
}
}
</script>
<style>
.container {
padding: 10px;
}
.btns {
margin-top: 10px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
}
.btns button {
flex: 1;
}
.btn-delete {
margin-left: 10px;
}
</style>

View File

@ -0,0 +1,184 @@
<template>
<view class="uni-container">
<uni-forms ref="form" :model="formData" validate-trigger="submit" err-show-type="toast">
<uni-forms-item name="parent_id" label="">
<uni-easyinput placeholder="父ID用于多级分类" v-model="formData.parent_id"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="name" label="类别名称" required>
<uni-easyinput placeholder="类别名称" v-model="formData.name" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="icon" label="图标地址">
<uni-easyinput placeholder="类别图标/图片地址" v-model="formData.icon" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="sort" label="排序">
<uni-easyinput placeholder="类别排序,越大越靠后" type="number" v-model="formData.sort"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="description" label="类别描述">
<uni-easyinput placeholder="类别描述" v-model="formData.description" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="is_hot_show" label="加入热门显示">
<switch @change="binddata('is_hot_show', $event.detail.value)" :checked="formData.is_hot_show"></switch>
</uni-forms-item>
<uni-forms-item name="is_index_show" label="首页显示">
<switch @change="binddata('is_index_show', $event.detail.value)" :checked="formData.is_index_show"></switch>
</uni-forms-item>
<uni-forms-item name="create_date" label="">
<uni-datetime-picker return-type="timestamp" v-model="formData.create_date"></uni-datetime-picker>
</uni-forms-item>
<view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button>
</view>
</uni-forms>
</view>
</template>
<script>
import { validator } from '../../js_sdk/validator/ngtools-categories.js';
const db = uniCloud.database();
const dbCollectionName = 'ngtools-categories';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.indexOf(key) > -1) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"parent_id": "",
"name": "",
"icon": "",
"sort": null,
"description": "",
"is_hot_show": null,
"is_index_show": null,
"create_date": null
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onLoad(e) {
if (e.id) {
const id = e.id
this.formDataId = id
this.getDetail(id)
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {
}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使 clientDB
return db.collection(dbCollectionName).doc(this.formDataId).update(value).then((res) => {
uni.showToast({
icon: 'none',
title: '修改成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
},
/**
* 获取表单数据
* @param {Object} id
*/
getDetail(id) {
uni.showLoading({
mask: true
})
db.collection(dbCollectionName).doc(id).field("parent_id,name,icon,sort,description,is_hot_show,is_index_show,create_date").get().then((res) => {
const data = res.result.data[0]
if (data) {
this.formData = data
}
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
}).finally(() => {
uni.hideLoading()
})
}
}
}
</script>
<style>
.uni-container {
padding: 15px;
}
.uni-input-border,
.uni-textarea-border {
width: 100%;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
box-sizing: border-box;
}
.uni-input-border {
padding: 0 10px;
height: 35px;
}
.uni-textarea-border {
padding: 10px;
height: 80px;
}
.uni-button-group {
margin-top: 50px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.uni-button {
width: 184px;
}
</style>

View File

@ -0,0 +1,72 @@
<template>
<view class="container">
<unicloud-db ref="udb" v-slot:default="{data, pagination, loading, hasMore, error}" :collection="collectionList" field="parent_id,name,icon,sort,description,is_hot_show,is_index_show,create_date">
<view v-if="error">{{error.message}}</view>
<view v-else-if="data">
<uni-list>
<uni-list-item v-for="(item, index) in data" :key="index" showArrow :clickable="true" @click="handleItemClick(item._id)">
<template v-slot:body>
<text>
<!-- 此处默认显示为_id请根据需要自行修改为其他字段 -->
<!-- 如果使用了联表查询请参考生成的 admin 项目中 list.vue 页面 -->
{{item._id}}
</text>
</template>
</uni-list-item>
</uni-list>
</view>
<uni-load-more :status="loading?'loading':(hasMore ? 'more' : 'noMore')"></uni-load-more>
</unicloud-db>
<uni-fab ref="fab" horizontal="right" vertical="bottom" :pop-menu="false" @fabClick="fabClick" />
</view>
</template>
<script>
const db = uniCloud.database()
export default {
data() {
return {
collectionList: "ngtools-categories",
loadMore: {
contentdown: '',
contentrefresh: '',
contentnomore: ''
}
}
},
onPullDownRefresh() {
this.$refs.udb.loadData({
clear: true
}, () => {
uni.stopPullDownRefresh()
})
},
onReachBottom() {
this.$refs.udb.loadMore()
},
methods: {
handleItemClick(id) {
uni.navigateTo({
url: './detail?id=' + id
})
},
fabClick() {
//
uni.navigateTo({
url: './add',
events: {
// ,
refreshData: () => {
this.$refs.udb.loadData({
clear: true
})
}
}
})
}
}
}
</script>
<style>
</style>

View File

@ -0,0 +1,153 @@
<template>
<view class="uni-container">
<uni-forms ref="form" :model="formData" validate-trigger="submit" err-show-type="toast">
<uni-forms-item name="infoName" label="资料名称" required>
<uni-easyinput placeholder="资料名称" v-model="formData.infoName"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="infomation" label="资料内容">
<uni-easyinput placeholder="资料内容" v-model="formData.infomation" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="infoSouce" label="资料来源">
<uni-easyinput placeholder="资料来源" v-model="formData.infoSouce" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="infoType" label="资料类型">
<uni-easyinput placeholder="资料类型" v-model="formData.infoType" trim="both"></uni-easyinput>
</uni-forms-item>
<!-- <uni-forms-item name="createBy" label="创建人">
<uni-easyinput placeholder="创建人" v-model="formData.createBy" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="updateBy" label="更新人">
<uni-easyinput placeholder="更新人" v-model="formData.updateBy" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="createTime" label="创建时间">
<uni-datetime-picker v-model="formData.createTime"></uni-datetime-picker>
</uni-forms-item>
<uni-forms-item name="updateTime" label="更新时间">
<uni-datetime-picker v-model="formData.updateTime"></uni-datetime-picker>
</uni-forms-item> -->
<view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button>
</view>
</uni-forms>
</view>
</template>
<script>
import { validator } from '../../js_sdk/validator/ngtools_information.js';
const db = uniCloud.database();
const dbCollectionName = 'ngtools_information';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.indexOf(key) > -1) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"infoName": "",
"infomation": "",
"infoSouce": "",
"infoType": "",
"createTime": null,
"createBy": "",
"updateTime": null,
"updateBy": ""
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {
}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使 clientDB
return db.collection(dbCollectionName).add(value).then((res) => {
uni.showToast({
icon: 'none',
title: '新增成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
}
}
}
</script>
<style>
.uni-container {
padding: 15px;
}
.uni-input-border,
.uni-textarea-border {
width: 100%;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
box-sizing: border-box;
}
.uni-input-border {
padding: 0 10px;
height: 35px;
}
.uni-textarea-border {
padding: 10px;
height: 80px;
}
.uni-button-group {
margin-top: 50px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.uni-button {
width: 184px;
}
</style>

View File

@ -0,0 +1,382 @@
<template>
<view class="container">
<unicloud-db ref="udb" v-slot:default="{data, loading, error, options}" :options="options"
:collection="collectionList"
field="infoName,infomation,infoSouce,infoType,createTime,createBy,updateTime,updateBy" :where="queryWhere"
:getone="true" :manual="true">
<view v-if="error">{{error.message}}</view>
<view v-else-if="loading">
<uni-load-more :contentText="loadMore" status="loading"></uni-load-more>
</view>
<view v-else-if="data">
<view>
<text>资料名称</text>
<text>{{data.infoName}}</text>
</view>
<view>
<text>资料内容</text>
<text>{{data.infomation}}</text>
</view>
<view>
<text>资料来源</text>
<text>{{data.infoSouce}}</text>
</view>
<view>
<text>资料类型</text>
<text>{{data.infoType}}</text>
</view>
<view>
<text>创建时间</text>
<text>{{data.createTime}}</text>
</view>
<view>
<text>创建人</text>
<text>{{data.createBy}}</text>
</view>
<view>
<text>更新时间</text>
<text>{{data.updateTime}}</text>
</view>
<view>
<text>更新人</text>
<text>{{data.updateBy}}</text>
</view>
</view>
</unicloud-db>
<view class="btns">
<button type="primary" @click="handleUpdate">修改</button>
<button type="warn" class="btn-delete" @click="handleDelete">删除</button>
</view>
<view class="table">
<!-- {{jsonData}} -->
<uni-table ref="table" border stripe type="selection" emptyText="暂无更多数据">
<!-- <uni-tr v-for="key,index in jsonKeys"> -->
<uni-tr >
<uni-th width="50" align="center" :key="index">{{key}}</uni-th>
<uni-th width="50" align="center" :key="index">{{key}}</uni-th>
</uni-tr>
<uni-tr v-for="key in jsonKeys">
<td v-for="item in jsonData">{{ item[key] }}</td>
</uni-tr>
</uni-table>
</view>
</view>
</template>
<script>
// schema2codeenum
import {
enumConverter
} from '../../js_sdk/validator/ngtools_information.js'
const db = uniCloud.database()
export default {
data() {
return {
queryWhere: '',
collectionList: "ngtools_information",
loadMore: {
contentdown: '',
contentrefresh: '',
contentnomore: ''
},
options: {
// scheme enum valuetext
...enumConverter
},
jsonKeys: [],
jsonData: [{
"序号": 1,
"组分": "甲烷",
"摩尔质量Mkg·kmol-I": 16.04246,
"原子个数a": 1,
"原子个数b": 4,
"原子个数C": 0,
"原子个数d": 0,
"原子个数e": 0
}, {
"序号": 2,
"组分": "乙烷",
"摩尔质量Mkg·kmol-I": 30.06904,
"原子个数a": 2,
"原子个数b": 6,
"原子个数C": 0,
"原子个数d": 0,
"原子个数e": 0
}],
tableData: [{
"date": "2020-09-01",
"name": "Dcloud1",
"address": "上海市普陀区金沙江路 1518 弄"
}, {
"date": "2020-09-02",
"name": "Dcloud2",
"address": "上海市普陀区金沙江路 1517 弄"
}, {
"date": "2020-09-03",
"name": "Dcloud3",
"address": "上海市普陀区金沙江路 1519 弄"
}, {
"date": "2020-09-04",
"name": "Dcloud4",
"address": "上海市普陀区金沙江路 1516 弄"
}, {
"date": "2020-09-05",
"name": "Dcloud5",
"address": "上海市普陀区金沙江路 1518 弄"
}, {
"date": "2020-09-06",
"name": "Dcloud6",
"address": "上海市普陀区金沙江路 1517 弄"
}, {
"date": "2020-09-07",
"name": "Dcloud7",
"address": "上海市普陀区金沙江路 1519 弄"
}, {
"date": "2020-09-08",
"name": "Dcloud8",
"address": "上海市普陀区金沙江路 1516 弄"
}, {
"date": "2020-09-09",
"name": "Dcloud9",
"address": "上海市普陀区金沙江路 1518 弄"
}, {
"date": "2020-09-10",
"name": "Dcloud10",
"address": "上海市普陀区金沙江路 1517 弄"
}, {
"date": "2020-09-11",
"name": "Dcloud11",
"address": "上海市普陀区金沙江路 1519 弄"
}, {
"date": "2020-09-12",
"name": "Dcloud12",
"address": "上海市普陀区金沙江路 1516 弄"
}, {
"date": "2020-09-13",
"name": "Dcloud13",
"address": "上海市普陀区金沙江路 1518 弄"
}, {
"date": "2020-09-14",
"name": "Dcloud14",
"address": "上海市普陀区金沙江路 1517 弄"
}, {
"date": "2020-09-15",
"name": "Dcloud15",
"address": "上海市普陀区金沙江路 1519 弄"
}, {
"date": "2020-09-16",
"name": "Dcloud16",
"address": "上海市普陀区金沙江路 1516 弄"
}, {
"date": "2020-09-01",
"name": "Dcloud17",
"address": "上海市普陀区金沙江路 1518 弄"
}, {
"date": "2020-09-02",
"name": "Dcloud18",
"address": "上海市普陀区金沙江路 1517 弄"
}, {
"date": "2020-09-03",
"name": "Dcloud19",
"address": "上海市普陀区金沙江路 1519 弄"
}, {
"date": "2020-09-04",
"name": "Dcloud20",
"address": "上海市普陀区金沙江路 1516 弄"
}, {
"date": "2020-09-05",
"name": "Dcloud21",
"address": "上海市普陀区金沙江路 1518 弄"
}, {
"date": "2020-09-06",
"name": "Dcloud22",
"address": "上海市普陀区金沙江路 1517 弄"
}, {
"date": "2020-09-07",
"name": "Dcloud23",
"address": "上海市普陀区金沙江路 1519 弄"
}, {
"date": "2020-09-08",
"name": "Dcloud24",
"address": "上海市普陀区金沙江路 1516 弄"
}, {
"date": "2020-09-09",
"name": "Dcloud25",
"address": "上海市普陀区金沙江路 1518 弄"
}, {
"date": "2020-09-10",
"name": "Dcloud26",
"address": "上海市普陀区金沙江路 1517 弄"
}, {
"date": "2020-09-11",
"name": "Dcloud27",
"address": "上海市普陀区金沙江路 1519 弄"
}, {
"date": "2020-09-12",
"name": "Dcloud28",
"address": "上海市普陀区金沙江路 1516 弄"
}, {
"date": "2020-09-13",
"name": "Dcloud29",
"address": "上海市普陀区金沙江路 1518 弄"
}, {
"date": "2020-09-14",
"name": "Dcloud30",
"address": "上海市普陀区金沙江路 1517 弄"
}, {
"date": "2020-09-15",
"name": "Dcloud31",
"address": "上海市普陀区金沙江路 1519 弄"
}, {
"date": "2020-09-16",
"name": "Dcloud32",
"address": "上海市普陀区金沙江路 1516 弄"
}, {
"date": "2020-09-01",
"name": "Dcloud33",
"address": "上海市普陀区金沙江路 1518 弄"
}, {
"date": "2020-09-02",
"name": "Dcloud34",
"address": "上海市普陀区金沙江路 1517 弄"
}, {
"date": "2020-09-03",
"name": "Dcloud35",
"address": "上海市普陀区金沙江路 1519 弄"
}, {
"date": "2020-09-04",
"name": "Dcloud36",
"address": "上海市普陀区金沙江路 1516 弄"
}, {
"date": "2020-09-05",
"name": "Dcloud37",
"address": "上海市普陀区金沙江路 1518 弄"
}, {
"date": "2020-09-06",
"name": "Dcloud38",
"address": "上海市普陀区金沙江路 1517 弄"
}, {
"date": "2020-09-07",
"name": "Dcloud39",
"address": "上海市普陀区金沙江路 1519 弄"
}, {
"date": "2020-09-08",
"name": "Dcloud40",
"address": "上海市普陀区金沙江路 1516 弄"
}, {
"date": "2020-09-09",
"name": "Dcloud41",
"address": "上海市普陀区金沙江路 1518 弄"
}, {
"date": "2020-09-10",
"name": "Dcloud42",
"address": "上海市普陀区金沙江路 1517 弄"
}, {
"date": "2020-09-11",
"name": "Dcloud43",
"address": "上海市普陀区金沙江路 1519 弄"
}, {
"date": "2020-09-12",
"name": "Dcloud44",
"address": "上海市普陀区金沙江路 1516 弄"
}, {
"date": "2020-09-13",
"name": "Dcloud45",
"address": "上海市普陀区金沙江路 1518 弄"
}, {
"date": "2020-09-14",
"name": "Dcloud46",
"address": "上海市普陀区金沙江路 1517 弄"
}, {
"date": "2020-09-15",
"name": "Dcloud47",
"address": "上海市普陀区金沙江路 1519 弄"
}, {
"date": "2020-09-16",
"name": "Dcloud48",
"address": "上海市普陀区金沙江路 1516 弄"
}]
}
},
onLoad(e) {
this._id = e.id
},
onReady() {
if (this._id) {
this.queryWhere = '_id=="' + this._id + '"'
}
this.getKeys(this.jsonData)
},
methods: {
getKeys(jsonData) {
this.jsonKeys = Object.keys(jsonData[0]);
console.log(this.jsonKeys)
},
handleUpdate() {
//
uni.navigateTo({
url: './edit?id=' + this._id,
events: {
// ,
refreshData: () => {
this.$refs.udb.loadData({
clear: true
})
}
}
})
},
handleDelete() {
this.$refs.udb.remove(this._id, {
success: (res) => {
// list
uni.navigateTo({
url: './list'
})
}
})
}
}
}
</script>
<style>
.container {
padding: 10px;
}
.table {
padding: 10px;
display: flex;
flex-wrap: nowrap;
}
.btns {
margin-top: 10px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
}
.btns button {
flex: 1;
}
.btn-delete {
margin-left: 10px;
}
</style>

View File

@ -0,0 +1,184 @@
<template>
<view class="uni-container">
<uni-forms ref="form" :model="formData" validate-trigger="submit" err-show-type="toast">
<uni-forms-item name="infoName" label="资料名称" required>
<uni-easyinput placeholder="资料名称" v-model="formData.infoName"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="infomation" label="资料内容">
<uni-easyinput placeholder="资料内容" v-model="formData.infomation" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="infoSouce" label="资料来源">
<uni-easyinput placeholder="资料来源" v-model="formData.infoSouce" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="infoType" label="资料类型">
<uni-easyinput placeholder="资料类型" v-model="formData.infoType" trim="both"></uni-easyinput>
</uni-forms-item>
<!-- <uni-forms-item name="createBy" label="创建人">
<uni-easyinput placeholder="创建人" v-model="formData.createBy" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="updateBy" label="更新人">
<uni-easyinput placeholder="更新人" v-model="formData.updateBy" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="createTime" label="创建时间">
<uni-datetime-picker v-model="formData.createTime"></uni-datetime-picker>
</uni-forms-item>
<uni-forms-item name="updateTime" label="更新时间">
<uni-datetime-picker v-model="formData.updateTime"></uni-datetime-picker>
</uni-forms-item> -->
<view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button>
</view>
</uni-forms>
</view>
</template>
<script>
import { validator } from '../../js_sdk/validator/ngtools_information.js';
const db = uniCloud.database();
const dbCollectionName = 'ngtools_information';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.indexOf(key) > -1) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"infoName": "",
"infomation": "",
"infoSouce": "",
"infoType": "",
"createTime": null,
"createBy": "",
"updateTime": null,
"updateBy": ""
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onLoad(e) {
if (e.id) {
const id = e.id
this.formDataId = id
this.getDetail(id)
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {
}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使 clientDB
return db.collection(dbCollectionName).doc(this.formDataId).update(value).then((res) => {
uni.showToast({
icon: 'none',
title: '修改成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
},
/**
* 获取表单数据
* @param {Object} id
*/
getDetail(id) {
uni.showLoading({
mask: true
})
db.collection(dbCollectionName).doc(id).field("infoName,infomation,infoSouce,infoType,createTime,createBy,updateTime,updateBy").get().then((res) => {
const data = res.result.data[0]
if (data) {
this.formData = data
}
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
}).finally(() => {
uni.hideLoading()
})
}
}
}
</script>
<style>
.uni-container {
padding: 15px;
}
.uni-input-border,
.uni-textarea-border {
width: 100%;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
box-sizing: border-box;
}
.uni-input-border {
padding: 0 10px;
height: 35px;
}
.uni-textarea-border {
padding: 10px;
height: 80px;
}
.uni-button-group {
margin-top: 50px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.uni-button {
width: 184px;
}
</style>

View File

@ -0,0 +1,81 @@
<template>
<view class="container">
<unicloud-db ref="udb" v-slot:default="{data, pagination, loading, hasMore, error}" :collection="collectionList"
field="infoName,infomation,infoSouce,infoType,createTime,createBy,updateTime,updateBy">
<view v-if="error">{{error.message}}</view>
<view v-else-if="data">
<uni-list>
<uni-list-item v-for="(item, index) in data" :key="index" showArrow :clickable="true"
@click="handleItemClick(item._id)">
<template v-slot:body>
<text>
<!-- 此处默认显示为_id请根据需要自行修改为其他字段 -->
<!-- 如果使用了联表查询请参考生成的 admin 项目中 list.vue 页面 -->
{{item.infoName}}
</text>
</template>
</uni-list-item>
</uni-list>
</view>
<uni-load-more :status="loading?'loading':(hasMore ? 'more' : 'noMore')"></uni-load-more>
</unicloud-db>
<uni-fab ref="fab" horizontal="right" vertical="bottom" :pop-menu="false" @fabClick="fabClick" />
</view>
</template>
<script>
const db = uniCloud.database()
export default {
data() {
return {
collectionList: "ngtools_information",
loadMore: {
contentdown: '',
contentrefresh: '',
contentnomore: ''
},
}
},
onPullDownRefresh() {
this.$refs.udb.loadData({
clear: true
}, () => {
uni.stopPullDownRefresh()
})
},
onReachBottom() {
this.$refs.udb.loadMore()
},
methods: {
handleItemClick(id) {
uni.navigateTo({
url: './detail?id=' + id
})
},
fabClick() {
//
uni.navigateTo({
url: './add',
events: {
// ,
refreshData: () => {
this.$refs.udb.loadData({
clear: true
})
}
}
})
}
}
}
</script>
<style>
</style>

View File

@ -0,0 +1,149 @@
<template>
<view class="uni-container">
<uni-forms ref="form" :model="formData" validate-trigger="submit" err-show-type="toast">
<uni-forms-item name="bannerfile" label="图片文件" required>
<uni-file-picker file-mediatype="image" return-type="object" v-model="formData.bannerfile"></uni-file-picker>
</uni-forms-item>
<uni-forms-item name="open_url" label="点击目标地址">
<uni-easyinput placeholder="点击跳转目标地址。如果是web地址则使用内置web-view打开如果是本地页面则跳转本地页面如果是schema地址则打开本地的app" v-model="formData.open_url" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="title" label="标题">
<uni-easyinput placeholder="注意标题文字颜色和背景图靠色导致看不清的问题" v-model="formData.title" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="sort" label="排序">
<uni-easyinput placeholder="数字越小,排序越前" type="number" v-model="formData.sort"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="category_id" label="分类id">
<uni-easyinput placeholder="多个栏目的banner都存在一个表里时可用这个字段区分" v-model="formData.category_id"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="status" label="生效状态">
<switch @change="binddata('status', $event.detail.value)" :checked="formData.status"></switch>
</uni-forms-item>
<uni-forms-item name="description" label="备注">
<uni-easyinput placeholder="维护者自用描述" v-model="formData.description" trim="both"></uni-easyinput>
</uni-forms-item>
<view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button>
</view>
</uni-forms>
</view>
</template>
<script>
import { validator } from '../../js_sdk/validator/opendb-banner.js';
const db = uniCloud.database();
const dbCollectionName = 'opendb-banner';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.indexOf(key) > -1) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"bannerfile": null,
"open_url": "",
"title": "",
"sort": null,
"category_id": "",
"status": true,
"description": ""
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {
}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使 clientDB
return db.collection(dbCollectionName).add(value).then((res) => {
uni.showToast({
icon: 'none',
title: '新增成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
}
}
}
</script>
<style>
.uni-container {
padding: 15px;
}
.uni-input-border,
.uni-textarea-border {
width: 100%;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
box-sizing: border-box;
}
.uni-input-border {
padding: 0 10px;
height: 35px;
}
.uni-textarea-border {
padding: 10px;
height: 80px;
}
.uni-button-group {
margin-top: 50px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.uni-button {
width: 184px;
}
</style>

View File

@ -0,0 +1,126 @@
<template>
<view class="container">
<unicloud-db ref="udb" v-slot:default="{data, loading, error, options}" :options="options" :collection="collectionList" field="bannerfile,open_url,title,sort,category_id,status,description" :where="queryWhere" :getone="true" :manual="true">
<view v-if="error">{{error.message}}</view>
<view v-else-if="loading">
<uni-load-more :contentText="loadMore" status="loading"></uni-load-more>
</view>
<view v-else-if="data">
<view>
<text>图片文件</text>
<uni-file-picker v-if="data.bannerfile && data.bannerfile.fileType == 'image'" :value="data.bannerfile" :file-mediatype="data.bannerfile && data.bannerfile.fileType" return-type="object" readonly></uni-file-picker>
<uni-link v-else-if="data.bannerfile" :href="data.bannerfile.url" :text="data.bannerfile.url"></uni-link>
<text v-else></text>
</view>
<view>
<text>点击目标地址</text>
<uni-link :href="data.open_url" :download="data.open_url" :text="data.open_url"></uni-link>
</view>
<view>
<text>标题</text>
<text>{{data.title}}</text>
</view>
<view>
<text>排序</text>
<text>{{data.sort}}</text>
</view>
<view>
<text>分类id</text>
<text>{{data.category_id}}</text>
</view>
<view>
<text>生效状态</text>
<text>{{data.status == true ? '✅' : '❌'}}</text>
</view>
<view>
<text>备注</text>
<text>{{data.description}}</text>
</view>
</view>
</unicloud-db>
<view class="btns">
<button type="primary" @click="handleUpdate">修改</button>
<button type="warn" class="btn-delete" @click="handleDelete">删除</button>
</view>
</view>
</template>
<script>
// schema2codeenum
import { enumConverter } from '../../js_sdk/validator/opendb-banner.js'
const db = uniCloud.database()
export default {
data() {
return {
queryWhere: '',
collectionList: "opendb-banner",
loadMore: {
contentdown: '',
contentrefresh: '',
contentnomore: ''
},
options: {
// scheme enum valuetext
...enumConverter
}
}
},
onLoad(e) {
this._id = e.id
},
onReady() {
if (this._id) {
this.queryWhere = '_id=="' + this._id + '"'
}
},
methods: {
handleUpdate() {
//
uni.navigateTo({
url: './edit?id=' + this._id,
events: {
// ,
refreshData: () => {
this.$refs.udb.loadData({
clear: true
})
}
}
})
},
handleDelete() {
this.$refs.udb.remove(this._id, {
success: (res) => {
// list
uni.navigateTo({
url: './list'
})
}
})
}
}
}
</script>
<style>
.container {
padding: 10px;
}
.btns {
margin-top: 10px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
}
.btns button {
flex: 1;
}
.btn-delete {
margin-left: 10px;
}
</style>

View File

@ -0,0 +1,180 @@
<template>
<view class="uni-container">
<uni-forms ref="form" :model="formData" validate-trigger="submit" err-show-type="toast">
<uni-forms-item name="bannerfile" label="图片文件" required>
<uni-file-picker file-mediatype="image" return-type="object" v-model="formData.bannerfile"></uni-file-picker>
</uni-forms-item>
<uni-forms-item name="open_url" label="点击目标地址">
<uni-easyinput placeholder="点击跳转目标地址。如果是web地址则使用内置web-view打开如果是本地页面则跳转本地页面如果是schema地址则打开本地的app" v-model="formData.open_url" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="title" label="标题">
<uni-easyinput placeholder="注意标题文字颜色和背景图靠色导致看不清的问题" v-model="formData.title" trim="both"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="sort" label="排序">
<uni-easyinput placeholder="数字越小,排序越前" type="number" v-model="formData.sort"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="category_id" label="分类id">
<uni-easyinput placeholder="多个栏目的banner都存在一个表里时可用这个字段区分" v-model="formData.category_id"></uni-easyinput>
</uni-forms-item>
<uni-forms-item name="status" label="生效状态">
<switch @change="binddata('status', $event.detail.value)" :checked="formData.status"></switch>
</uni-forms-item>
<uni-forms-item name="description" label="备注">
<uni-easyinput placeholder="维护者自用描述" v-model="formData.description" trim="both"></uni-easyinput>
</uni-forms-item>
<view class="uni-button-group">
<button type="primary" class="uni-button" @click="submit">提交</button>
</view>
</uni-forms>
</view>
</template>
<script>
import { validator } from '../../js_sdk/validator/opendb-banner.js';
const db = uniCloud.database();
const dbCollectionName = 'opendb-banner';
function getValidator(fields) {
let result = {}
for (let key in validator) {
if (fields.indexOf(key) > -1) {
result[key] = validator[key]
}
}
return result
}
export default {
data() {
let formData = {
"bannerfile": null,
"open_url": "",
"title": "",
"sort": null,
"category_id": "",
"status": true,
"description": ""
}
return {
formData,
formOptions: {},
rules: {
...getValidator(Object.keys(formData))
}
}
},
onLoad(e) {
if (e.id) {
const id = e.id
this.formDataId = id
this.getDetail(id)
}
},
onReady() {
this.$refs.form.setRules(this.rules)
},
methods: {
/**
* 验证表单并提交
*/
submit() {
uni.showLoading({
mask: true
})
this.$refs.form.validate().then((res) => {
return this.submitForm(res)
}).catch(() => {
}).finally(() => {
uni.hideLoading()
})
},
/**
* 提交表单
*/
submitForm(value) {
// 使 clientDB
return db.collection(dbCollectionName).doc(this.formDataId).update(value).then((res) => {
uni.showToast({
icon: 'none',
title: '修改成功'
})
this.getOpenerEventChannel().emit('refreshData')
setTimeout(() => uni.navigateBack(), 500)
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
})
},
/**
* 获取表单数据
* @param {Object} id
*/
getDetail(id) {
uni.showLoading({
mask: true
})
db.collection(dbCollectionName).doc(id).field("bannerfile,open_url,title,sort,category_id,status,description").get().then((res) => {
const data = res.result.data[0]
if (data) {
this.formData = data
}
}).catch((err) => {
uni.showModal({
content: err.message || '请求服务失败',
showCancel: false
})
}).finally(() => {
uni.hideLoading()
})
}
}
}
</script>
<style>
.uni-container {
padding: 15px;
}
.uni-input-border,
.uni-textarea-border {
width: 100%;
font-size: 14px;
color: #666;
border: 1px #e5e5e5 solid;
border-radius: 5px;
box-sizing: border-box;
}
.uni-input-border {
padding: 0 10px;
height: 35px;
}
.uni-textarea-border {
padding: 10px;
height: 80px;
}
.uni-button-group {
margin-top: 50px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
}
.uni-button {
width: 184px;
}
</style>

View File

@ -0,0 +1,72 @@
<template>
<view class="container">
<unicloud-db ref="udb" v-slot:default="{data, pagination, loading, hasMore, error}" :collection="collectionList" field="bannerfile,open_url,title,sort,category_id,status,description">
<view v-if="error">{{error.message}}</view>
<view v-else-if="data">
<uni-list>
<uni-list-item v-for="(item, index) in data" :key="index" showArrow :clickable="true" @click="handleItemClick(item._id)">
<template v-slot:body>
<text>
<!-- 此处默认显示为_id请根据需要自行修改为其他字段 -->
<!-- 如果使用了联表查询请参考生成的 admin 项目中 list.vue 页面 -->
{{item._id}}
</text>
</template>
</uni-list-item>
</uni-list>
</view>
<uni-load-more :status="loading?'loading':(hasMore ? 'more' : 'noMore')"></uni-load-more>
</unicloud-db>
<uni-fab ref="fab" horizontal="right" vertical="bottom" :pop-menu="false" @fabClick="fabClick" />
</view>
</template>
<script>
const db = uniCloud.database()
export default {
data() {
return {
collectionList: "opendb-banner",
loadMore: {
contentdown: '',
contentrefresh: '',
contentnomore: ''
}
}
},
onPullDownRefresh() {
this.$refs.udb.loadData({
clear: true
}, () => {
uni.stopPullDownRefresh()
})
},
onReachBottom() {
this.$refs.udb.loadMore()
},
methods: {
handleItemClick(id) {
uni.navigateTo({
url: './detail?id=' + id
})
},
fabClick() {
//
uni.navigateTo({
url: './add',
events: {
// ,
refreshData: () => {
this.$refs.udb.loadData({
clear: true
})
}
}
})
}
}
}
</script>
<style>
</style>

View File

@ -0,0 +1,12 @@
## 4.0.62022-12-12
修复`getDrawModules`,第一次获取结果正常,后续获取`tile`模块不存在的问题;
修复安卓type:normal因Canvas API使用了小数或为0的参数导致生成异常的问题安卓非2d Canvas部分API参数不支持携带小数部分API参数必须大于0
## 4.0.12022-11-28
优化组件loading属性的表现
新增组件type选项normal以便于在某些条件编译初始为type=2d时还可以选择使用非2d组件类型
修复组件条件编译在其他编辑器语法提示报错;
修复原生对es5的支持。
## 4.0.02022-11-21
v4版本源代码全面开放开源地址[https://github.com/Sansnn/uQRCode](https://github.com/Sansnn/uQRCode)
升级说明v4为大版本更新虽然已尽可能兼容上一代版本但不可避免的还是存在一些细节差异若更新后出现问题请参考对照[v3 文档](https://uqrcode.cn/doc/v3)[v4 文档](https://uqrcode.cn/doc)进行修改。

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