Commit 3f59949d0bb45ef680dc14eedd1f4990ff2c2ab7
1 parent
e5331ced
debug column edit
Showing
2 changed files
with
77 additions
and
30 deletions
src/views/column/edit.vue
| ... | ... | @@ -45,23 +45,37 @@ const rules = reactive({ |
| 45 | 45 | trigger: "blur", |
| 46 | 46 | }, |
| 47 | 47 | ], |
| 48 | + // cmsPageId: [ | |
| 49 | + // { | |
| 50 | + // required: false, | |
| 51 | + // message: "请填写CMS页面ID", | |
| 52 | + // trigger: "blur", | |
| 53 | + // }, | |
| 54 | + // ], | |
| 55 | + // cmsColumnId: [ | |
| 56 | + // { | |
| 57 | + // required: false, | |
| 58 | + // message: "请填写CMS栏目ID", | |
| 59 | + // trigger: "blur", | |
| 60 | + // }, | |
| 61 | + // ], | |
| 48 | 62 | cmsPageId: [ |
| 49 | 63 | { |
| 50 | - required: true, | |
| 64 | + required: form.data.cmsPageType === 4 && form.data.cmsColumnId? false: true, | |
| 51 | 65 | message: "请填写CMS页面ID", |
| 52 | - trigger: "blur", | |
| 66 | + trigger: "change", | |
| 53 | 67 | }, |
| 54 | 68 | ], |
| 55 | 69 | cmsColumnId: [ |
| 56 | 70 | { |
| 57 | - required: true, | |
| 71 | + required: form.data.cmsPageType === 4 && form.data.cmsPageId? false: true, | |
| 58 | 72 | message: "请填写CMS栏目ID", |
| 59 | - trigger: "blur", | |
| 73 | + trigger: "change", | |
| 60 | 74 | }, |
| 61 | 75 | ], |
| 62 | 76 | cmsPageUrl: [ |
| 63 | 77 | { |
| 64 | - required: false, | |
| 78 | + required: form.data.cmsPageType === 1? true: false, | |
| 65 | 79 | message: "请填写CMS页面链接", |
| 66 | 80 | trigger: "blur", |
| 67 | 81 | }, |
| ... | ... | @@ -75,13 +89,41 @@ const rules = reactive({ |
| 75 | 89 | ], |
| 76 | 90 | sort: [ |
| 77 | 91 | { |
| 78 | - required: false, | |
| 92 | + required: form.data.parentColumnId ? false : true, | |
| 79 | 93 | message: "请填写数字排序值", |
| 80 | 94 | trigger: "blur", |
| 81 | 95 | type: "number", |
| 82 | 96 | min: 0, |
| 83 | 97 | }, |
| 84 | 98 | ], |
| 99 | + columnImg: [ | |
| 100 | + { | |
| 101 | + required: form.data.parentColumnId ? false : true, | |
| 102 | + message: "请上传栏目选中LOGO图片", | |
| 103 | + trigger: "blur", | |
| 104 | + }, | |
| 105 | + ], | |
| 106 | + columnImgUncheck: [ | |
| 107 | + { | |
| 108 | + required: form.data.parentColumnId ? false : true, | |
| 109 | + message: "请上传栏目未选中LOGO图片", | |
| 110 | + trigger: "blur", | |
| 111 | + }, | |
| 112 | + ], | |
| 113 | + columnColour: [ | |
| 114 | + { | |
| 115 | + required: form.data.parentColumnId ? false : true, | |
| 116 | + message: "请选择栏目选中字色", | |
| 117 | + trigger: "blur", | |
| 118 | + }, | |
| 119 | + ], | |
| 120 | + columnColourUncheck: [ | |
| 121 | + { | |
| 122 | + required: form.data.parentColumnId ? false : true, | |
| 123 | + message: "请选择栏目未选中字色", | |
| 124 | + trigger: "blur", | |
| 125 | + }, | |
| 126 | + ], | |
| 85 | 127 | }); |
| 86 | 128 | /** |
| 87 | 129 | * 表单重置 |
| ... | ... | @@ -146,15 +188,24 @@ onMounted(() => { |
| 146 | 188 | mlen.value = 6; |
| 147 | 189 | break; |
| 148 | 190 | } |
| 149 | - // cms页面类型为【原生】时,cms栏目ID、cms页面ID必填一个,cms栏目名称选填 | |
| 150 | - // cms页面类型为【h5】时,页面url必填 | |
| 191 | + // cms页面类型为【原生 4】时,cms栏目ID、cms页面ID必填一个,cms栏目名称选填 | |
| 192 | + // cms页面类型为【h5 1】时,页面url必填 | |
| 193 | + if(~~form.data.cmsPageType === 4) { | |
| 194 | + rules.cmsPageUrl[0].required = false; | |
| 195 | + rules.cmsPageId[0].required = ~~form.data.cmsColumnId? false: true | |
| 196 | + rules.cmsColumnId[0].required = ~~form.data.cmsPageId? false: true | |
| 197 | + } else { | |
| 198 | + rules.cmsPageUrl[0].required = true | |
| 199 | + rules.cmsPageId[0].required = false | |
| 200 | + rules.cmsColumnId[0].required = false | |
| 201 | + } | |
| 151 | 202 | watch( |
| 152 | 203 | () => form.data.cmsPageType, |
| 153 | 204 | (data) => { |
| 154 | 205 | if (~~data === 4) { |
| 155 | 206 | rules.cmsPageUrl[0].required = false; |
| 156 | - rules.cmsPageId[0].required = true; | |
| 157 | - rules.cmsColumnId[0].required = true; | |
| 207 | + rules.cmsColumnId[0].required = form.data.cmsPageId? false: true | |
| 208 | + rules.cmsPageId[0].required = form.data.cmsColumnId? false: true | |
| 158 | 209 | } else if (~~data === 1) { |
| 159 | 210 | rules.cmsPageUrl[0].required = true; |
| 160 | 211 | rules.cmsPageId[0].required = false; |
| ... | ... | @@ -182,6 +233,7 @@ onMounted(() => { |
| 182 | 233 | } |
| 183 | 234 | } |
| 184 | 235 | ); |
| 236 | + form.data.sort = ~~useRoute().query.sort; | |
| 185 | 237 | }); |
| 186 | 238 | </script> |
| 187 | 239 | ... | ... |
src/views/user/index.vue
| ... | ... | @@ -57,29 +57,19 @@ const getList = async () => { |
| 57 | 57 | * 删除 |
| 58 | 58 | * @param {object} obj 要删除的数据对象 |
| 59 | 59 | */ |
| 60 | -const handleDelete = (obj: any) => { | |
| 61 | - ElMessageBox.confirm("确认删除吗?", "警告", { | |
| 60 | +const handleDelete = (obj: any, type: string) => { | |
| 61 | + ElMessageBox.confirm(`确认${type? '初始化密码': '删除'}吗?`, "警告", { | |
| 62 | 62 | confirmButtonText: "确认", |
| 63 | 63 | cancelButtonText: "取消", |
| 64 | 64 | type: "warning", |
| 65 | 65 | }) |
| 66 | 66 | .then(async () => { |
| 67 | 67 | try { |
| 68 | - let res = await userStatus({ | |
| 69 | - userId: obj.id, | |
| 70 | - status: 2, | |
| 71 | - }); | |
| 72 | - if (res?.data) { | |
| 73 | - ElMessage({ | |
| 74 | - type: "success", | |
| 75 | - message: "操作成功", | |
| 76 | - }); | |
| 77 | - getList(); | |
| 68 | + let res | |
| 69 | + if(type) { | |
| 70 | + handleUpdate(obj, type) | |
| 78 | 71 | } else { |
| 79 | - ElMessage({ | |
| 80 | - type: "error", | |
| 81 | - message: "操作失败", | |
| 82 | - }); | |
| 72 | + handleUpdate(obj, 'delete') | |
| 83 | 73 | } |
| 84 | 74 | } catch (e) { |
| 85 | 75 | console.log(e); |
| ... | ... | @@ -92,7 +82,7 @@ const handleDelete = (obj: any) => { |
| 92 | 82 | /** |
| 93 | 83 | * 修改 |
| 94 | 84 | * @param {object} obj 一条数据对象 |
| 95 | - * @param {string} type 修改操作的类型,pwd修改密码,status修改状态 | |
| 85 | + * @param {string} type 修改操作的类型,pwd修改密码,status修改状态,delete删除 | |
| 96 | 86 | */ |
| 97 | 87 | const handleUpdate = async (obj: any, type: string) => { |
| 98 | 88 | try { |
| ... | ... | @@ -106,6 +96,11 @@ const handleUpdate = async (obj: any, type: string) => { |
| 106 | 96 | res = await userPwd({ |
| 107 | 97 | userId: obj.id, |
| 108 | 98 | }); |
| 99 | + } else if (type === 'delete') { | |
| 100 | + res = await userStatus({ | |
| 101 | + userId: obj.id, | |
| 102 | + status: 2 | |
| 103 | + }) | |
| 109 | 104 | } |
| 110 | 105 | if (res?.data) { |
| 111 | 106 | ElMessage({ |
| ... | ... | @@ -209,7 +204,7 @@ onMounted(() => { |
| 209 | 204 | <el-button type="text" @click="handleUpdate(scope.row, 'status')">{{ |
| 210 | 205 | scope.row.status ? "禁用" : "启用" |
| 211 | 206 | }}</el-button> |
| 212 | - <el-button type="text" @click="handleUpdate(scope.row, 'pwd')" | |
| 207 | + <el-button type="text" @click="handleDelete(scope.row, 'pwd')" | |
| 213 | 208 | >初始密码</el-button |
| 214 | 209 | > |
| 215 | 210 | <el-button type="text" |
| ... | ... | @@ -234,7 +229,7 @@ onMounted(() => { |
| 234 | 229 | <!-- 商务管理员 物业管理员 公益管理员 --> |
| 235 | 230 | <template v-if="~~scope.row.id === ~~asyncData.userInfo"> |
| 236 | 231 | <!-- 当前登录的人是三种管理员只能初始自己的密码, --> |
| 237 | - <el-button type="text" @click="handleUpdate(scope.row, 'pwd')" | |
| 232 | + <el-button type="text" @click="handleDelete(scope.row, 'pwd')" | |
| 238 | 233 | >初始密码</el-button |
| 239 | 234 | > |
| 240 | 235 | </template> |
| ... | ... | @@ -249,7 +244,7 @@ onMounted(() => { |
| 249 | 244 | <el-button type="text" @click="handleUpdate(scope.row, 'status')">{{ |
| 250 | 245 | scope.row.status ? "禁用" : "启用" |
| 251 | 246 | }}</el-button> |
| 252 | - <el-button type="text" @click="handleUpdate(scope.row, 'pwd')" | |
| 247 | + <el-button type="text" @click="handleDelete(scope.row, 'pwd')" | |
| 253 | 248 | >初始密码</el-button |
| 254 | 249 | > |
| 255 | 250 | <el-button type="text" | ... | ... |