Commit 668ef9f89fd8c38181715762cec69c0f1e5abaf8

Authored by 杨泽宇
1 parent 2c5bc8de

debug

README.md
... ... @@ -6,6 +6,7 @@ cnlive-community-web-vue 中国网+智慧社区平台
6 6 + 技术栈
7 7 * vue3.x (vite)
8 8 * node v12.0.0+
  9 + * vite v2.7.0+
9 10 * element-plus v1.0.0+
10 11  
11 12 ## 项目特点
... ... @@ -27,15 +28,17 @@ cnlive-community-web-vue 中国网+智慧社区平台
27 28 + 测试:
28 29 + test.community.api.cnlive.com
29 30 + test.community.web.cnlive.com
  31 +
  32 +## 测试账号(超管)
  33 + * 账号 123
  34 + * 密码 cmnt123
  35 +
  36 +## 发布方式
30 37 + 服务器地址:120.92.119.11
31 38 + 服务器项目位置:cd /cnlive/cnlive-community-web-vue
32 39 + 账号:root
33 40 + 密码:du=K0dB1z
34 41  
35   -## 测试账号
36   -
37   -## 发布方式
38   -
39 42 ## 试用地址
40 43 * [测试环境](http://testweb.community.cnlive.com/#/dashboard "测试环境")
41 44  
... ... @@ -73,9 +76,15 @@ cnlive-community-web-vue 中国网+智慧社区平台
73 76 * validate.ts 格式验证方法
74 77 * scroll.ts 页面滚动
75 78 * views 业务逻辑页面
  79 + * community 小区管理
76 80 * dashboard 欢迎页
77   - * user 用户管理 包含登录注册
78 81 * error 错误提示页面 如404页
  82 + * ownerManagement 业主管理
  83 + * permission 权限管理
  84 + * property 物业管理
  85 + * role 角色管理
  86 + * system 系统设置
  87 + * user 用户管理 包含登录注册
79 88 * .env.development 本地开发环境配置
80 89 * .env.production 线上部署正式环境配置
81 90 * .env.staging 线上部署测试环境配置
... ...
src/views/dashboard/index.vue
1 1 <script setup lang="ts">
2 2 import {ref} from 'vue'
3   -import {propertyList } from '@/api/tengxi'
4 3 import router from '@/router'
5 4 const title = ref(import.meta.env.VITE_APP_TITLE).value
6   -propertyList().then(res => {
7   - console.log(res)
8   -}).catch(error => {
9   - console.log(error)
10   -})
11 5 console.log(router.getRoutes())
12 6 </script>
13 7  
... ...
src/views/permission/edit.vue
... ... @@ -80,6 +80,9 @@ onMounted(() =&gt; {
80 80 form.dataType = useRoute().query.dataType;
81 81 if (form.dataType === "add") {
82 82 form.data.parentId = useRoute().query.id;
  83 + if(useRoute().query.type.toString() === '1') {
  84 + form.data.type = '2'
  85 + }
83 86 } else {
84 87 Object.keys(form.data).map((key) => {
85 88 form.data[key] = useRoute().query[key];
... ... @@ -141,7 +144,7 @@ onMounted(() =&gt; {
141 144 />
142 145 </el-form-item>
143 146 <!-- 不支持创建一级菜单,编辑的时候不可以修改菜单类型 -->
144   - <!-- 一级菜单下只能创建二级菜单 -->
  147 + <!-- 一级菜单下只能创建二级菜单,这时候默认选中 -->
145 148 <!-- 二级菜单可以创建三级菜单或者按钮 -->
146 149 <!-- 三级菜单只能创建按钮 -->
147 150 <el-form-item label="权限类型" prop="type" style="width: 100%">
... ...
src/views/user/edit.vue
1 1 <script setup lang="ts">
2 2 import { reactive, ref, getCurrentInstance, onMounted } from "vue";
3   -import { userAdd } from "@/api/user/user";
  3 +import { userEdit, userAdd } from "@/api/user/user";
4 4 import { roleList } from "@/api/user/role";
5 5 import { getTableList } from "@/api/community/residence";
6 6 import { useRoute } from "vue-router";
... ... @@ -17,14 +17,14 @@ let form = reactive({
17 17 cellphone: "",
18 18 password: "",
19 19 roleIds: "",
20   - cIds: "",
  20 + neighborhoodIds: "",
21 21 userId: "",
22 22 },
23 23 dataType: "",
24 24 roles: [],
25 25 communities: [],
26 26 checkList: [],
27   - communityList: []
  27 + communityList: [],
28 28 });
29 29 const ruleFormRef = ref<InstanceType<typeof ElForm>>();
30 30 /**
... ... @@ -81,6 +81,7 @@ const rules = reactive({
81 81 const resetForm = (formEl: InstanceType<typeof ElForm> | undefined) => {
82 82 if (!formEl) return;
83 83 form.checkList = [];
  84 + form.communityList = [];
84 85 formEl.resetFields();
85 86 };
86 87 /**
... ... @@ -88,18 +89,30 @@ const resetForm = (formEl: InstanceType&lt;typeof ElForm&gt; | undefined) =&gt; {
88 89 */
89 90 const submitForm = (formEl: InstanceType<typeof ElForm> | undefined) => {
90 91 if (!formEl) return;
91   - formEl.validate((valid) => {
  92 + formEl.validate(async (valid) => {
92 93 if (valid) {
93   - userAdd(form.data)
94   - .then((res) => {
95   - if (res) {
96   - globalProperties.$message.success("操作成功");
97   - history.go(-1);
98   - }
99   - })
100   - .catch((error) => {
101   - console.log(error);
102   - });
  94 + let res;
  95 + try {
  96 + // 用户编辑和用户增加的接口不一样!参数也不一样!
  97 + if (form.dataType === "add") {
  98 + res = await userAdd(form.data);
  99 + } else if (form.dataType === "edit") {
  100 + res = await userEdit({
  101 + cellphone: form.data.cellphone,
  102 + password: form.data.password,
  103 + roleIds: form.data.roleIds,
  104 + userId: form.data.id,
  105 + userName: form.data.userName
  106 + });
  107 + }
  108 + } catch (e) {
  109 + console.log(e);
  110 + } finally {
  111 + if (res?.data) {
  112 + globalProperties.$message.success("操作成功");
  113 + history.go(-1);
  114 + }
  115 + }
103 116 } else {
104 117 globalProperties.$message.error("请检查表单格式");
105 118 return false;
... ... @@ -151,7 +164,8 @@ onMounted(() =&gt; {
151 164 form.dataType = "add";
152 165 } else {
153 166 form.dataType = "edit";
154   - form.checkList = form.data.roleIds.split(",").map((v) => v / 1);
  167 + form.checkList = form.data.roleIds? form.data.roleIds?.split(",").map((v) => v / 1): []
  168 + form.communityList = form.data.neighborhoodIds? form.data.neighborhoodIds.split(",").map((v) => v / 1): []
155 169 }
156 170 });
157 171 </script>
... ... @@ -183,7 +197,12 @@ onMounted(() =&gt; {
183 197 maxlength="15"
184 198 />
185 199 </el-form-item>
186   - <el-form-item label="密码" prop="password" style="width: 100%">
  200 + <el-form-item
  201 + label="密码"
  202 + prop="password"
  203 + style="width: 100%"
  204 + v-show="form.dataType === 'add'"
  205 + >
187 206 <el-input
188 207 v-model.trim="form.data.password"
189 208 placeholder="请填写密码"
... ... @@ -206,7 +225,7 @@ onMounted(() =&gt; {
206 225 <el-form-item label="小区" style="width: 100%">
207 226 <el-checkbox-group
208 227 v-model="form.communityList"
209   - @change="(data) => (form.data.cIds = data.join(','))"
  228 + @change="(data) => (form.data.neighborhoodIds = data.join(','))"
210 229 >
211 230 <el-checkbox
212 231 v-for="(item, index) in form.communities"
... ...