Commit 3f59949d0bb45ef680dc14eedd1f4990ff2c2ab7

Authored by 杨泽宇
1 parent e5331ced

debug column edit

src/views/column/edit.vue
@@ -45,23 +45,37 @@ const rules = reactive({ @@ -45,23 +45,37 @@ const rules = reactive({
45 trigger: "blur", 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 cmsPageId: [ 62 cmsPageId: [
49 { 63 {
50 - required: true, 64 + required: form.data.cmsPageType === 4 && form.data.cmsColumnId? false: true,
51 message: "请填写CMS页面ID", 65 message: "请填写CMS页面ID",
52 - trigger: "blur", 66 + trigger: "change",
53 }, 67 },
54 ], 68 ],
55 cmsColumnId: [ 69 cmsColumnId: [
56 { 70 {
57 - required: true, 71 + required: form.data.cmsPageType === 4 && form.data.cmsPageId? false: true,
58 message: "请填写CMS栏目ID", 72 message: "请填写CMS栏目ID",
59 - trigger: "blur", 73 + trigger: "change",
60 }, 74 },
61 ], 75 ],
62 cmsPageUrl: [ 76 cmsPageUrl: [
63 { 77 {
64 - required: false, 78 + required: form.data.cmsPageType === 1? true: false,
65 message: "请填写CMS页面链接", 79 message: "请填写CMS页面链接",
66 trigger: "blur", 80 trigger: "blur",
67 }, 81 },
@@ -75,13 +89,41 @@ const rules = reactive({ @@ -75,13 +89,41 @@ const rules = reactive({
75 ], 89 ],
76 sort: [ 90 sort: [
77 { 91 {
78 - required: false, 92 + required: form.data.parentColumnId ? false : true,
79 message: "请填写数字排序值", 93 message: "请填写数字排序值",
80 trigger: "blur", 94 trigger: "blur",
81 type: "number", 95 type: "number",
82 min: 0, 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,15 +188,24 @@ onMounted(() => {
146 mlen.value = 6; 188 mlen.value = 6;
147 break; 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 watch( 202 watch(
152 () => form.data.cmsPageType, 203 () => form.data.cmsPageType,
153 (data) => { 204 (data) => {
154 if (~~data === 4) { 205 if (~~data === 4) {
155 rules.cmsPageUrl[0].required = false; 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 } else if (~~data === 1) { 209 } else if (~~data === 1) {
159 rules.cmsPageUrl[0].required = true; 210 rules.cmsPageUrl[0].required = true;
160 rules.cmsPageId[0].required = false; 211 rules.cmsPageId[0].required = false;
@@ -182,6 +233,7 @@ onMounted(() => { @@ -182,6 +233,7 @@ onMounted(() => {
182 } 233 }
183 } 234 }
184 ); 235 );
  236 + form.data.sort = ~~useRoute().query.sort;
185 }); 237 });
186 </script> 238 </script>
187 239
src/views/user/index.vue
@@ -57,29 +57,19 @@ const getList = async () =&gt; { @@ -57,29 +57,19 @@ const getList = async () =&gt; {
57 * 删除 57 * 删除
58 * @param {object} obj 要删除的数据对象 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 confirmButtonText: "确认", 62 confirmButtonText: "确认",
63 cancelButtonText: "取消", 63 cancelButtonText: "取消",
64 type: "warning", 64 type: "warning",
65 }) 65 })
66 .then(async () => { 66 .then(async () => {
67 try { 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 } else { 71 } else {
79 - ElMessage({  
80 - type: "error",  
81 - message: "操作失败",  
82 - }); 72 + handleUpdate(obj, 'delete')
83 } 73 }
84 } catch (e) { 74 } catch (e) {
85 console.log(e); 75 console.log(e);
@@ -92,7 +82,7 @@ const handleDelete = (obj: any) =&gt; { @@ -92,7 +82,7 @@ const handleDelete = (obj: any) =&gt; {
92 /** 82 /**
93 * 修改 83 * 修改
94 * @param {object} obj 一条数据对象 84 * @param {object} obj 一条数据对象
95 - * @param {string} type 修改操作的类型,pwd修改密码,status修改状态 85 + * @param {string} type 修改操作的类型,pwd修改密码,status修改状态,delete删除
96 */ 86 */
97 const handleUpdate = async (obj: any, type: string) => { 87 const handleUpdate = async (obj: any, type: string) => {
98 try { 88 try {
@@ -106,6 +96,11 @@ const handleUpdate = async (obj: any, type: string) =&gt; { @@ -106,6 +96,11 @@ const handleUpdate = async (obj: any, type: string) =&gt; {
106 res = await userPwd({ 96 res = await userPwd({
107 userId: obj.id, 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 if (res?.data) { 105 if (res?.data) {
111 ElMessage({ 106 ElMessage({
@@ -209,7 +204,7 @@ onMounted(() =&gt; { @@ -209,7 +204,7 @@ onMounted(() =&gt; {
209 <el-button type="text" @click="handleUpdate(scope.row, 'status')">{{ 204 <el-button type="text" @click="handleUpdate(scope.row, 'status')">{{
210 scope.row.status ? "禁用" : "启用" 205 scope.row.status ? "禁用" : "启用"
211 }}</el-button> 206 }}</el-button>
212 - <el-button type="text" @click="handleUpdate(scope.row, 'pwd')" 207 + <el-button type="text" @click="handleDelete(scope.row, 'pwd')"
213 >初始密码</el-button 208 >初始密码</el-button
214 > 209 >
215 <el-button type="text" 210 <el-button type="text"
@@ -234,7 +229,7 @@ onMounted(() =&gt; { @@ -234,7 +229,7 @@ onMounted(() =&gt; {
234 <!-- 商务管理员 物业管理员 公益管理员 --> 229 <!-- 商务管理员 物业管理员 公益管理员 -->
235 <template v-if="~~scope.row.id === ~~asyncData.userInfo"> 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 >初始密码</el-button 233 >初始密码</el-button
239 > 234 >
240 </template> 235 </template>
@@ -249,7 +244,7 @@ onMounted(() =&gt; { @@ -249,7 +244,7 @@ onMounted(() =&gt; {
249 <el-button type="text" @click="handleUpdate(scope.row, 'status')">{{ 244 <el-button type="text" @click="handleUpdate(scope.row, 'status')">{{
250 scope.row.status ? "禁用" : "启用" 245 scope.row.status ? "禁用" : "启用"
251 }}</el-button> 246 }}</el-button>
252 - <el-button type="text" @click="handleUpdate(scope.row, 'pwd')" 247 + <el-button type="text" @click="handleDelete(scope.row, 'pwd')"
253 >初始密码</el-button 248 >初始密码</el-button
254 > 249 >
255 <el-button type="text" 250 <el-button type="text"