123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <template>
- <view style="padding: 20rpx;">
- <view style="padding: 30rpx;background-color: white;border-radius:50rpx">
- <u--form labelPosition="left" :model="userInfo" ref="uForm" labelWidth='120'>
- <u-form-item label="用户账号:" prop="account" borderBottom ref="uItem" :required="true">
- <u--input v-model="userInfo.account" clearable border="none" placeholder="请输入用户账号"></u--input>
- </u-form-item>
- <u-form-item label="用户名称:" prop="name" borderBottom ref="uItem" :required="true">
- <u--input v-model="userInfo.name" border="none" placeholder="请输入用户名称"></u--input>
- </u-form-item>
- <u-form-item label="联系电话:" prop="phone" borderBottom ref="uItem">
- <u-input v-model="userInfo.phone" border="none" placeholder="请输入联系电话"></u-input>
- </u-form-item>
- <u-form-item label="是否管理员:" prop="adminType" borderBottom ref="uItem">
- <u-switch v-model="userInfo.adminType"></u-switch>
- </u-form-item>
- <u-button type="primary" text="提交" customStyle="margin-top: 50px" @click="submit"></u-button>
- <u-button type="error" text="重置" customStyle="margin-top: 10px" @click="reset"></u-button>
- </u--form>
- </view>
- <u-toast ref="uToast"></u-toast>
- </view>
- </template>
- <script>
- import {add,edit} from '@/api/system/user.js'
- export default {
- data() {
- return {
- userInfo: {
- },
- rules: {
- 'account': {
- type: 'string',
- required: true,
- message: '请填写用户账号',
- trigger: ['blur', 'change']
- },
- 'password': {
- type: 'string',
- required: true,
- message: '请填写用户密码',
- trigger: ['blur', 'change']
- },
- 'name': {
- type: 'string',
- required: true,
- message: '请填写用户名称',
- trigger: ['blur', 'change']
- },
- }
- }
- },
- methods: {
- submit(){
- this.$refs.uForm.validate().then(val => {
- edit(this.userInfo).then(res=>{
- if (res.success) {
- this.$refs.uToast.show({
- type: 'success',
- message: "修改成功",
- iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
- })
- } else {
- this.$refs.uToast.show({
- type: 'error',
- message: res.message,
- iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
- })
- }
- })
- })
- },
- reset(){}
- },
- onReady(){
- this.$refs.uForm.setRules(this.rules)
- },
- onLoad(option) {
- const userInfo = JSON.parse(decodeURIComponent(option.userInfo))
- this.userInfo = userInfo
- },
- }
- </script>
- <style>
- </style>
|