| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466 |
- <template>
- <view class="">
- <view class="status_bar"></view>
- <view class="" style="position: relative;top: 64px;">
- <view style="position: fixed;z-index: 100;">
- <uni-nav-bar left-icon="back" left-text="返回" @clickLeft="clickLeft" title="用户详情"></uni-nav-bar>
- </view>
- <view class="useroperations">
- <u-form :model="user_meg" ref="uForm" class="uForm">
- <view class="uFormbg">
- <u-form-item label="姓名" left-icon="account" :left-icon-style="lefticonstyle" label-width="160rpx" :border-bottom="borderbottom"
- prop="name">
- <u-input v-model="user_meg.username" :clearable="clearable" input-align="right" :disabled="alterTF" :class="{'uuinput':alterTF==false}" />
- </u-form-item>
- </view>
- <view class="uFormbg">
- <u-form-item label="电话" left-icon="phone" :left-icon-style="lefticonstyle" label-width="160rpx" :border-bottom="borderbottom"
- prop="intro">
- <u-input v-model="user_meg.mobile" :clearable="clearable" input-align="right" :disabled="alterTF" :class="{'uuinput':alterTF==false}"
- @blur="bluechange(user_meg.mobile)" />
- </u-form-item>
- <p class="tishi" v-if="tishitf">手机格式错误</p>
- </view>
- <view class="uFormbg">
- <u-form-item label="主题" left-icon="calendar" :left-icon-style="lefticonstyle" label-width="160rpx" :border-bottom="borderbottom"
- prop="passwold">
- <u-input v-model="theme_items" :clearable="clearable" input-align="right" :disabled="true" :class="{'uuinput':alterTF==false}"
- type="selete" @click="theme_show = !alterTF" />
- <u-action-sheet :list="theme" v-model="theme_show" @click="themes" scroll-y="true"></u-action-sheet>
- </u-form-item>
- </view>
- <view class="uFormbg">
- <u-form-item label="用户类型" left-icon="grid" :left-icon-style="lefticonstyle" label-width="160rpx" :border-bottom="borderbottom">
- <u-input v-model="users_type[user_meg.user_type-1].text" :clearable="clearable" input-align="right" disabled />
- </u-form-item>
- </view>
- <view class="uFormbg">
- <u-form-item label="用户角色" left-icon="account-fill" :left-icon-style="lefticonstyle" label-width="160rpx"
- :border-bottom="borderbottom">
- <u-input v-model="user_meg.role_name" :clearable="clearable" input-align="right" placeholder="请选择主题" :disabled="true"
- :class="{'uuinput':alterTF==false}" @click="users_type_show = !alterTF" />
- </u-form-item>
- </view>
- <view class="uFormbg">
- <u-form-item label="是否可用" left-icon="order" :left-icon-style="lefticonstyle" label-width="160rpx" :border-bottom="borderbottom">
- <u-input v-model="tf" :clearable="clearable" input-align="right" disabled />
- </u-form-item>
- </view>
- <view class="uFormbg">
- <u-form-item label="创建时间" left-icon="clock" :left-icon-style="lefticonstyle" label-width="160rpx" :border-bottom="borderbottom">
- <u-input :clearable="clearable" input-align="right" disabled :value="user_meg.addtime|timeFormat()" />
- </u-form-item>
- </view>
- </u-form>
- </view>
- <view class="operation_group">
- <view class="group_one" v-if="btnTF">
- <view class="group_one_top">
- <!-- <button type="default" @click="recharge">充值</button> -->
- <button type="default" @click="compile">编辑</button>
- <button type="default" @click="forbidden" v-if="forbiddenTF" style="background-color: red;">禁用</button>
- <button type="default" @click="forbidden" v-else>可用</button>
- <button type="default" @click="changePassword">修改密码</button>
- </view>
- <view class="group_one_bot">
- <button type="default" @click="assignment">分配设备</button>
- </view>
- </view>
- <view class="group_two" v-else>
- <button type="default" @click="modification" :disabled="tijiaotf">确定</button>
- </view>
- </view>
- <u-popup v-model="users_type_show" mode="bottom" length="30%" class="pop-up">
- <scroll-view scroll-y="true" class="sheet">
- <view class="sheet-text" v-for="(item,index) in roles" :key="index">
- <p @click="typesofroles(index)">{{item.text}}</p>
- </view>
- </scroll-view>
- <button @click="users_type_show = false">取消</button>
- </u-popup>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- user_meg: {},
- lefticonstyle: {
- 'color': "#57C878"
- },
- borderbottom: false,
- clearable: false,
- tf: "",
- usersofrole_show: true,
- btnTF: true,
- users_type: [{
- text: '超级管理员'
- }, {
- text: '经销商'
- }, {
- text: '农林政府单位'
- }, {
- text: '普通用户'
- }],
- users_type_show: false,
- forbiddenTF: null,
- alterTF: true,
- theme: [],
- theme_show: false,
- theme_items: '--',
- roles: [],
- roles_id: null,
- tishitf: false,
- tijiaotf: false,
- quanxian:{//权限设置
- chongzhi :false,
- alters :false,
- off :false,
- pass: false,
- shebeiitems:false
- }
- }
- },
- methods: {
- async getForbidden() { //获取用户的使用状态
- const res = await this.$myRequest({
- url: '/api/api_gateway?method=user.login.users_statu_updata',
- data: {
- uid: this.user_meg.uid,
- state: this.user_meg.state == '1' ? 4 : 1 //1是正常 4是禁用
- }
- })
- console.log(res)
- if (this.user_meg.state == "1" && res == true) {
- this.user_meg.state = '4'
- console.log(this.user_meg.state)
- } else {
- this.user_meg.state = '1'
- console.log(this.user_meg.state)
- }
- if (this.user_meg.state == '1') {
- this.tf = "正常"
- this.forbiddenTF = true
- } else if (this.user_meg.state == '4') {
- this.tf = "禁止使用"
- this.forbiddenTF = false
- }
- },
- async getGroup() { //获取用户的主题信息
- const res = await this.$myRequest({
- url: '/api/api_gateway?method=pest.warning_record.rolemanage_view'
- })
- for (var i = 0; i < res.data.length; i++) {
- let obj = {}
- obj.text = res.data[i].role_describe
- obj.id = res.data[i].id
- if(obj.text != ''){
- this.theme.push(obj)
- }
- if (this.user_meg.user_group_id == res.data[i].id) { //根据主题id更改主题
- this.theme_items = res.data[i].role_describe
- }
- console.log(this.theme)
- }
- },
- async getThemes() { //获取用户角色
- const res = await this.$myRequest({
- url: '/api/api_gateway?method=user.perms.role_list'
- })
- for (var i = 0; i < res.length; i++) {
- let obj = {}
- obj.text = res[i].role_name
- obj.id = res[i].role_id
- this.roles.push(obj)
- }
- },
- compile() { //编辑按钮
- if(this.quanxian.alters){
- this.btnTF = !this.btnTF
- this.alterTF = false
- }else{
- uni.showToast({
- title: "您暂无权限进行此操作,如有需要,请联系管理员",
- icon: "none"
- })
- }
- },
- forbidden() { //禁用按钮
- if(this.quanxian.off){
- this.getForbidden()
- }else{
- uni.showToast({
- title: "您暂无权限进行此操作,如有需要,请联系管理员",
- icon: "none"
- })
- }
- },
- themes(index) { //主题下拉框
- this.theme_items = this.theme[index].text;
- this.user_meg.user_group_id_index = this.theme[index].id;
- },
- async getModification() { //修改用户
- const res = await this.$myRequest({
- url: '/api/api_gateway?method=user.login.users_info_updata',
- data: {
- username: this.user_meg.username,
- uid: this.user_meg.uid,
- mobile: this.user_meg.mobile,
- user_group_id: this.user_meg.user_group_id_index || '',
- user_type: this.user_meg.user_type,
- role_id: this.roles_id || this.user_meg.role_id
- },
- })
- },
- modification() { //修改用户确认按钮
- this.getModification()
- this.btnTF = true
- this.alterTF = true
- },
- typesofroles(idnex) { //主题下拉框选项按钮
- this.user_meg.role_name = this.roles[idnex].text
- this.users_type_show = false
- this.roles_id = this.roles[idnex].id
- },
- bluechange(str) { //手机号框失去焦点时检测手机号
- let regexp = /^1[23456789]\d{9}$/
- this.tishitf = !regexp.test(str)
- if (regexp.test(str)) {
- this.tijiaotf = !regexp.test(str)
- } else {
- this.tijiaotf = regexp.test(str)
- }
- },
- clickLeft() { //返回上一页按钮
- uni.navigateTo({
- url: './index'
- });
- },
- changePassword() { //修改密码
- if(this.quanxian.pass){
- uni.navigateTo({
- url: './changepasswold?item=' + JSON.stringify(this.user_meg)
- });
- }else{
- uni.showToast({
- title: "您暂无权限进行此操作,如有需要,请联系管理员",
- icon: "none"
- })
- }
- },
- assignment() { //分配设备
- if(this.quanxian.shebeiitems){
- uni.navigateTo({
- url: './assignment?item=' + JSON.stringify(this.user_meg)
- });
- }else{
- uni.showToast({
- title: "您暂无权限进行此操作,如有需要,请联系管理员",
- icon: "none"
- })
- }
- },
- async getRecharge() { //修改用户
- const res = await this.$myRequest({
- url: '/api/api_gateway?method=user.login.user_add_package_time',
- data: {
- uid: this.user_meg.uid,
- user_test: 1
- },
- })
- },
- // recharge() { //充值按钮
- // if(this.quanxian.chongzhi){
- // uni.showModal({
- // title: '提示',
- // content: '是否向该用户充值一年费用?',
- // success: function(res) {
- // if (res.confirm) {
- // this.getRecharge()
- // console.log('用户点击确定');
- // } else if (res.cancel) {
- // console.log('用户点击取消');
- // }
- // }
- // });
- // }else{
- // uni.showToast({
- // title: "您暂无权限进行此操作,如有需要,请联系管理员",
- // icon: "none"
- // })
- // }
- // }
- },
- onLoad(option) {
- this.user_meg = JSON.parse(option.item)
- console.log(this.user_meg)
- if (this.user_meg.state == '1') {
- this.tf = "正常"
- this.forbiddenTF = true
- } else if (this.user_meg.state == '4') {
- this.tf = "禁止使用"
- this.forbiddenTF = false
- }
- this.getGroup()
- this.getThemes()
- uni.getStorage({
- key:"jurisdiction",
- success:(res)=>{
- console.log(JSON.parse(res.data))
- let items = JSON.parse(res.data).filter((item)=>{
- return item.purview_name == "系统管理"
- })
- let items2 = items[0].children.filter((item)=>{
- return item.purview_name == "用户管理"
- })
- let shebeiitems = JSON.parse(res.data).filter((item)=>{
- return item.purview_name == "设备管理"
- })
- this.quanxian.shebeiitems = shebeiitems[0].children.some((item)=>{
- return item.purview_name == "分配设备"
- })
- var arr = items2[0].children
- console.log(items)
- for(var i =0;i<arr.length;i++){
- switch (arr[i].purview_name){
- case "充值":
- this.quanxian.chongzhi = true
- break
- case "编辑":
- this.quanxian.alters = true
- break
- case "禁用":
- this.quanxian.off = true
- break
- case "密码":
- this.quanxian.pass = true
- break
- }
- }
- },
- })
- },
- onBackPress(options) {
- if (options.from === 'navigateBack') {
- return false;
- }
- this.clickLeft();
- return true;
- },
- }
- </script>
- <style lang="scss">
- .useroperations {
- width: 100%;
- display: flex;
- justify-content: center;
- .uForm {
- margin-top: 44px;
- width: 95%;
- .uFormbg {
- width: 100%;
- background-color: #f3f3f3;
- margin-top: 20rpx;
- }
- .tishi {
- text-align: center;
- font-size: 24rpx;
- color: red;
- }
- .u-form-item {
- width: 95%;
- height: 80rpx;
- margin: 0 auto;
- padding: 5rpx 0;
- }
- .uuinput {
- background-color: white;
- }
- }
- }
- .operation_group {
- .group_one {
- .group_one_top {
- width: 90%;
- margin: 20rpx auto;
- display: flex;
- justify-content: space-around;
- button {
- width: 23%;
- height: 60rpx;
- line-height: 60rpx;
- background-color: $uni-color-success;
- color: white;
- font-size: 24rpx;
- }
- }
- .group_one_bot {
- width: 90%;
- margin: 20rpx auto;
- button {
- height: 60rpx;
- line-height: 60rpx;
- background-color: $uni-color-success;
- color: white;
- font-size: 30rpx;
- }
- }
- }
- .group_two {
- width: 90%;
- margin: 20rpx auto;
- button {
- background-color: $uni-color-success;
- color: white;
- height: 80rpx;
- line-height: 80rpx;
- font-size: 30rpx;
- }
- }
- }
- .pop-up {
- .sheet {
- background-color: white;
- height: 400rpx;
- overflow: hidden;
- .sheet-text {
- height: 80rpx;
- p {
- text-align: center;
- height: 80rpx;
- line-height: 80rpx;
- color: black;
- font-size: 16px;
- }
- }
- }
- button {
- color: black;
- position: absolute;
- bottom: 0;
- width: 100%;
- font-size: 16px;
- height: 80rpx;
- }
- }
- </style>
|