From f26f29d84e0a68831a6af14dab3eec5500496d2e Mon Sep 17 00:00:00 2001 From: spring <2396852758@qq.com> Date: 星期三, 28 五月 2025 16:48:52 +0800 Subject: [PATCH] 初始化项目 --- pages/sys/pigxUser/form.vue | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 156 insertions(+), 0 deletions(-) diff --git a/pages/sys/pigxUser/form.vue b/pages/sys/pigxUser/form.vue new file mode 100644 index 0000000..a40b76b --- /dev/null +++ b/pages/sys/pigxUser/form.vue @@ -0,0 +1,156 @@ +<template> + <view class="wrap"> + <u-form class="form" :model="model" :rules="rules" ref="uForm" label-position="left"> + <u-form-item label="userId" prop="userId" label-width="180"> + <u-input v-model="model.userId" type="text" maxlength="64" :disabled="true"></u-input> + </u-form-item> + <u-form-item label="濮撳悕" prop="username" label-width="180"> + <u-input placeholder="璇疯緭鍏ュ鍚�" v-model="model.username" type="text" maxlength="200"></u-input> + </u-form-item> + <u-form-item label="瀵嗙爜" prop="password" label-width="180"> + <u-input placeholder="璇疯緭鍏ュ瘑鐮�" v-model="model.password" type="password" maxlength="500"></u-input> + </u-form-item> + <u-form-item label="鎵嬫満鍙�" prop="phone" label-width="180"> + <u-input placeholder="璇疯緭鍏ユ墜鏈哄彿" v-model="model.phone" type="text" maxlength="200"></u-input> + </u-form-item> + <u-form-item label="鎵�灞為儴闂�" prop="deptId" label-width="260"> + <js-select v-model="model.deptId" placeholder="璇烽�夋嫨閮ㄩ棬" + itemLabel="name" itemValue="deptId" :items="deptList"></js-select> + </u-form-item> + <u-form-item label="宀椾綅" prop="post" label-width="180"> + <js-checkbox v-model="post" itemLabel="postName" itemValue="postId" :multiple="true" :items="postList"> + </js-checkbox> + </u-form-item> + <u-form-item label="瑙掕壊" prop="role" label-width="180"> + <js-checkbox v-model="role" itemLabel="roleName" itemValue="roleId" :multiple="true" :items="roleList"> + </js-checkbox> + </u-form-item> + <u-form-item label="鐘舵��" prop="lockFlag" label-width="180"> + <js-radio v-model="model.lockFlag" itemLabel="label" itemValue="value" :multiple="true" + :items="lockData"></js-radio> + </u-form-item> + <u-form-item label="鏄电О" prop="nickname" label-width="180"> + <u-input v-model="model.nickname" type="text" maxlength="64" placeholder="璇疯緭鍏ユ樀绉�"></u-input> + </u-form-item> + <u-form-item label="閭" prop="email" label-width="180"> + <u-input v-model="model.email" type="text" maxlength="64" placeholder="璇疯緭鍏ラ偖绠�"></u-input> + </u-form-item> + </u-form> + <view class="form-footer"> + <u-button class="btn" type="primary" @click="submit">鎻愪氦</u-button> + <u-button class="btn" type="default" @click="cancel">鍏抽棴</u-button> + </view> + </view> +</template> +<script> +export default { + data() { + return { + model: { + userId: '', + username: '', + password: '', + phone: '', + post: [], + role: [], + lockFlag: '', + nickname: '', + email: '', + createTime: '' + }, + rules: { + username: [{ + required: true, + message: '璇疯緭鍏ョ敤鎴峰悕', + trigger: ['change', 'blur'], + }], + password: [{ + required: true, + message: '璇疯緭鍏ュ瘑鐮�', + trigger: ['change', 'blur'], + }] + }, + lockData: [{ + label: '鏈夋晥', + value: '0' + }, { + label: '閿佸畾', + value: '9' + }], + post: '', + role: '', + deptList: [], + postList: [], + roleList: [], + officeSelectList: [], + userSelectList: [], + }; + }, + onLoad(params) { + if (params && params.id !== "undefined") { + this.type = 'edit' + this.$u.api.pigxUser.getOne(params).then(res => { + Object.assign(this.model, res.data); + this.model.password = '' + this.role = ''; + if (this.model.roleList && this.model.roleList.length > 0) { + this.role = this.model.roleList.map(item => item.roleId).join() + } + + this.post = '' + if (this.model.postList && this.model.postList.length > 0) { + this.post = this.model.postList.map(item => item.postId).join() + } + }); + } else { + this.type = 'add' + this.model = {} + } + + }, + onReady() { + this.$refs.uForm.setRules(this.rules); + // todo 鏌ヨ鏈烘瀯鏁版嵁 + this.$u.api.pigxDept.list().then(res => { + this.deptList = res.data; + }); + // 鏌ヨ宀椾綅淇℃伅 + this.$u.api.pigxPost.list().then(res => { + this.postList = res.data + }) + //鏌ヨ瑙掕壊鍒楄〃 + this.$u.api.pigxRole.list().then(res => { + this.roleList = res.data + }) + }, + methods: { + confirmSelect(e) { + this.show = false + }, + submit() { + this.$refs.uForm.validate(valid => { + if (valid) { + this.model.post = this.post.split(',') + this.model.role = this.role.split(',') + this.$u.api.pigxUser.putObj(this.model).then(res => { + uni.showModal({ + title: '鎻愮ず', + content: '淇敼鎴愬姛', + showCancel: false, + success: function () { + uni.setStorageSync('refreshList', true); + uni.navigateBack(); + } + }); + }); + } else { + this.$u.toast('鎮ㄥ~鍐欑殑淇℃伅鏈夎锛岃鏍规嵁鎻愮ず淇銆�'); + } + }); + }, + cancel() { + uni.navigateBack(); + } + } +}; +</script> -- Gitblit v1.9.3