若依前端-APP中使用数据字典

news/2024/10/23 20:07:11/
 1 在main.js文件中注册有关字典的组件和相关的属性等,如下所示,有添加字典注解的地方
import Vue from 'vue'
import App from './App'
import wx from 'weixin-js-sdk'
import store from './store' // store
import plugins from './plugins' // plugins
import './permission' // permission
//字典
import { getDicts } from "@/api/system/dict/data"
// 字典标签组件
import DictTag from '@/components/DictTag'
// 字典数据组件
import DictData from '@/components/DictData'Vue.use(plugins)
//安装字典
DictData.install()Vue.config.productionTip = false
Vue.prototype.$store = store
Vue.prototype.getDicts = getDicts
//全局注册字典
Vue.component('DictTag', DictTag)App.mpType = 'app'const app = new Vue({...App
})app.$mount()
2  在D:\ideaProject\RuoYi-App-master\components目录,添加从前端的项目复制DictData,DictTag两个目录的全部文件
3在D:\ideaProject\RuoYi-App-master\utils目录,添加从前端的项目复制utils的文件,存在的文件就跳过
4 在组件文件中直接使用<dict-tag :options="dict.type.mes_order_status" value="CONFIRMED" />来表示字典显示的内容

4.1 定义字典的内容

dicts: ['mes_order_status','mes_workorder_sourcetype','mes_workorder_type'],

 4.2 在要显示标签的地方,写下dict-tag标签的语法,vaule属性可以使用变量

<dict-tag :options="dict.type.mes_order_status" value="CONFIRMED" />
<template><view class="normal-login-container"><view class="logo-content align-center justify-center flex"><image style="width: 100rpx;height: 100rpx;" :src="globalConfig.appInfo.logo" mode="widthFix"></image><text class="title">若依移动端登录</text><view><dict-tag :options="dict.type.mes_order_status" value="CONFIRMED" /></view></view><view class="login-form-content"><view class="input-item flex align-center"><view class="iconfont icon-user icon"></view><input v-model="loginForm.username" class="input" type="text" placeholder="请输入账号" maxlength="30" /></view><view class="input-item flex align-center"><view class="iconfont icon-password icon"></view><input v-model="loginForm.password" type="password" class="input" placeholder="请输入密码" maxlength="20" /></view><view class="input-item flex align-center" style="width: 60%;margin: 0px;" v-if="captchaEnabled"><view class="iconfont icon-code icon"></view><input v-model="loginForm.code" type="number" class="input" placeholder="请输入验证码" maxlength="4" /><view class="login-code"><image :src="codeUrl" @click="getCode" class="login-code-img"></image></view></view><view class="action-btn"><button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button></view><view class="reg text-center" v-if="register"><text class="text-grey1">没有账号?</text><text @click="handleUserRegister" class="text-blue">立即注册</text></view><view class="xieyi text-center"><text class="text-grey1">登录即代表同意</text><text @click="handleUserAgrement" class="text-blue">《用户协议》</text><text @click="handlePrivacy" class="text-blue">《隐私协议》</text></view></view></view>
</template><script>import {getCodeImg} from '@/api/login'export default {dicts: ['mes_order_status','mes_workorder_sourcetype','mes_workorder_type'],data() {return {codeUrl: "",captchaEnabled: true,// 用户注册开关register: false,globalConfig: getApp().globalData.config,loginForm: {username: "admin",password: "admin123",code: "",uuid: ''}}},created() {this.getCode()},methods: {// 用户注册handleUserRegister() {this.$tab.redirectTo(`/pages/register`)},// 隐私协议handlePrivacy() {let site = this.globalConfig.appInfo.agreements[0]this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)},// 用户协议handleUserAgrement() {let site = this.globalConfig.appInfo.agreements[1]this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)},// 获取图形验证码getCode() {getCodeImg().then(res => {this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabledif (this.captchaEnabled) {this.codeUrl = 'data:image/gif;base64,' + res.imgthis.loginForm.uuid = res.uuid}})},// 登录方法async handleLogin() {if (this.loginForm.username === "") {this.$modal.msgError("请输入您的账号")} else if (this.loginForm.password === "") {this.$modal.msgError("请输入您的密码")} else if (this.loginForm.code === "" && this.captchaEnabled) {this.$modal.msgError("请输入验证码")} else {this.$modal.loading("登录中,请耐心等待...")this.pwdLogin()}},// 密码登录async pwdLogin() {this.$store.dispatch('Login', this.loginForm).then(() => {this.$modal.closeLoading()this.loginSuccess()}).catch(() => {if (this.captchaEnabled) {this.getCode()}})},// 登录成功后,处理函数loginSuccess(result) {// 设置用户信息this.$store.dispatch('GetInfo').then(res => {this.$tab.reLaunch('/pages/index')})}}}
</script><style lang="scss">page {background-color: #ffffff;}.normal-login-container {width: 100%;.logo-content {width: 100%;font-size: 21px;text-align: center;padding-top: 15%;image {border-radius: 4px;}.title {margin-left: 10px;}}.login-form-content {text-align: center;margin: 20px auto;margin-top: 15%;width: 80%;.input-item {margin: 20px auto;background-color: #f5f6f7;height: 45px;border-radius: 20px;.icon {font-size: 38rpx;margin-left: 10px;color: #999;}.input {width: 100%;font-size: 14px;line-height: 20px;text-align: left;padding-left: 15px;}}.login-btn {margin-top: 40px;height: 45px;}.reg {margin-top: 15px;}.xieyi {color: #333;margin-top: 20px;}.login-code {height: 38px;float: right;.login-code-img {height: 38px;position: absolute;margin-left: 10px;width: 200rpx;}}}}
</style>


http://www.ppmy.cn/news/1456903.html

相关文章

Linux —— 信号(3)

Linux —— 信号&#xff08;3&#xff09; Core dump为什么core默认是被关闭的阻塞信号信号其他相关常见概念信号递达信号未决信号阻塞两者的区别信号的结构 信号集操作函数一个简单使用例子sigpending的使用例子 我们今天接着来了解信号&#xff1a; Core dump 大家不知道有…

CP AUTOSAR之CANXLDriver详细说明(正在更新中)

本文遵循autosar标准&#xff1a;R22-11 1 简介及功能概述 本规范描述了AUTOSAR 基础软件模块CAN XL 驱动程序的功能、API和配置。   本文档的基础是[1,CiA610-1]和[2,CiA611-1]。假设读者熟悉这些规范。本文档不会再次描述CAN XL 功能。   CAN XL 驱动程序是最低层的一部…

深拷贝和浅拷贝的区别,如何实现一个深拷贝

在JavaScript中&#xff0c;数据类型分为基本数据类型和引用数据类型。 基本数据类型是保存在栈内存中的&#xff0c;引用数据类型的变量是一个指向堆内存中实际对象的引用&#xff0c;这个引用是保存在栈内存中。 浅拷贝 浅拷贝&#xff0c;指的是创建新的数据。 如果原始…

三维SDMTSP:GWO灰狼优化算法求解三维单仓库多旅行商问题,可以更改数据集和起点(MATLAB代码)

一、单仓库多旅行商问题 多旅行商问题&#xff08;Multiple Traveling Salesman Problem, MTSP&#xff09;是著名的旅行商问题&#xff08;Traveling Salesman Problem, TSP&#xff09;的延伸&#xff0c;多旅行商问题定义为&#xff1a;给定一个&#x1d45b;座城市的城市集…

学习软考----数据库系统工程师22

关系运算 基本的关系代数运算 拓展的关系运算 除&#xff1a;需要S连接中属性为C和D的两个元组都与R连接一样&#xff0c;且在R连接中对应的另外的元素完全一致 总结

经常发文章的你是否想过定时发布是咋实现的?

前言 可乐他们团队最近在做一个文章社区平台,由于人手不够,前后端都是由前端同学来写。后端使用 nest 来实现。 某一天周五下午,可乐正在快乐摸鱼,想到周末即将来临,十分开心。然而,产品突然找到了他,说道:可乐,我们要做一个文章定时发布功能。 现在我先为你解释一…

利用 MyNodeQuery 搭建三网延迟监控 实时监控 VPS 网络情况

本文首发于只抄博客&#xff0c;欢迎点击原文链接了解更多内容。 前言 MyNodeQuery 是一款简洁好用的探针&#xff0c;可以作为 NodeQuery 关闭后的替代品&#xff0c;功能也基本参照 NodeQuery&#xff0c;支持节点离线通知、节点排序、自定义 Ping 节点&#xff0c;还有网速…

供应商管理软件:帮助企业确定供应商的可靠性

采用单一供应商还是多家供应商&#xff0c;是企业在供应链管理领域面临的一个关键决定。 在德勤对采购专业人士进行的一项调查中&#xff0c;70% 的受访者表示&#xff0c;他们使用多家供应商来管理供应链风险。然而&#xff0c;61% 的受访者表示&#xff0c;他们也使用单一采…