Commit e6908aa1339ac03e2b547325228c9dcce00a6691

Authored by 杨泽宇
1 parent 13a97f8d

活动取消发布

docs/develop/dict.md
@@ -145,15 +145,19 @@ @@ -145,15 +145,19 @@
145 | 支付宝 | 3 | 145 | 支付宝 | 3 |
146 146
147 ## 活动管理 147 ## 活动管理
148 - * 活动状态和总结状态 `statusData: Array` [查看代码](http://bj.gitlab.cnlive.com/cnlive_project/cnlive-community-web-vue/blob/dev/src/views/event/config.ts)  
149 - | 活动状态 | 总结状态 | value |  
150 - | :-----: | :------: | :---: |  
151 - | 草稿 | | 0 |  
152 - | 提交未开始 | | 1 |  
153 - | 进行中 | | 2 |  
154 - | 已结束 | | 3 |  
155 - | 活动结束 | 草稿 | 4 |  
156 - | 活动结束 | 发布 | 5 | 148 + * 活动状态 `statusData: Array` [查看代码](http://bj.gitlab.cnlive.com/cnlive_project/cnlive-community-web-vue/blob/dev/src/views/event/config.ts)
  149 + | 活动状态 | value |
  150 + | :-----: | :---: |
  151 + | 未开始 | 0 |
  152 + | 进行中 | 1 |
  153 + | 已结束 | 2 |
  154 +
  155 + * 发布状态 `publishData: Array` [查看代码](http://bj.gitlab.cnlive.com/cnlive_project/cnlive-community-web-vue/blob/dev/src/views/event/config.ts)
  156 + | 活动状态 | value |
  157 + | :-----: | :---: |
  158 + | 草稿 | 0 |
  159 + | 已发布 | 1 |
  160 + | 取消发布 | 2 |
157 161
158 * 活动评价展示到前台状态 `onlineStatus: Array` [查看代码](http://bj.gitlab.cnlive.com/cnlive_project/cnlive-community-web-vue/blob/dev/src/views/event/config.ts) 162 * 活动评价展示到前台状态 `onlineStatus: Array` [查看代码](http://bj.gitlab.cnlive.com/cnlive_project/cnlive-community-web-vue/blob/dev/src/views/event/config.ts)
159 | 活动状态 | value | 163 | 活动状态 | value |
docs/develop/discuss.md
@@ -51,4 +51,10 @@ @@ -51,4 +51,10 @@
51 ## 活动管理 51 ## 活动管理
52 **活动列表** 52 **活动列表**
53 > * 添加活动时,被禁用的活动分类不可以被选择。 53 > * 添加活动时,被禁用的活动分类不可以被选择。
54 - > * 要验证活动结束时间晚于活动开始时间,报名结束时间要晚于报名开始时间,没有验证和【现在】时间的前后关系。  
55 \ No newline at end of file 54 \ No newline at end of file
  55 + > * 新增活动的时候,只有保存操作,编辑活动的时候,可以保存、可以发布,提交接口用status区分,1为发布,需要二次确认,0为保存。
  56 + > * 已发布的活动才能取消发布,取消了以后不能再重新发布。
  57 + > * 活动取消发布了以后,只能查看人员。
  58 + > * 活动状态值是当前时间和活动开始结束时间对比的结果
  59 + * 当前时间晚于活动结束时间,即活动已结束,
  60 + * 当前时间早于活动开始时间,即活动未开始,
  61 + * 当前时间介于活动开始、结束时间之间(含),即活动进行中。
56 \ No newline at end of file 62 \ No newline at end of file
src/api/event/index.ts
@@ -143,4 +143,17 @@ export const signupList = async (params: any) => { @@ -143,4 +143,17 @@ export const signupList = async (params: any) => {
143 params: params 143 params: params
144 }) 144 })
145 return res 145 return res
  146 +}
  147 +
  148 +/**
  149 + * @description 取消发布活动
  150 + * @function handworkCancel
  151 + */
  152 + export const handworkCancel = async (params: any) => {
  153 + let res: any = await request({
  154 + method: 'put',
  155 + url: '/handwork/canelPublish',
  156 + params: params
  157 + })
  158 + return res
146 } 159 }
147 \ No newline at end of file 160 \ No newline at end of file
src/views/event/config.ts
1 import type { EnumArrayItem } from "@/@type/module/basic" 1 import type { EnumArrayItem } from "@/@type/module/basic"
2 2
3 -// 活动状态和总结状态 3 +// 活动状态
4 export const statusData: EnumArrayItem[] = [ 4 export const statusData: EnumArrayItem[] = [
5 { 5 {
6 label: '未开始', 6 label: '未开始',
@@ -16,6 +16,20 @@ export const statusData: EnumArrayItem[] = [ @@ -16,6 +16,20 @@ export const statusData: EnumArrayItem[] = [
16 }, 16 },
17 ] 17 ]
18 18
  19 +// 活动发布状态
  20 +export const publishData: EnumArrayItem[] = [
  21 + {
  22 + label: '草稿',
  23 + value: 0
  24 + }, {
  25 + label: '已发布',
  26 + value: 1
  27 + }, {
  28 + label: '取消发布',
  29 + value: 2
  30 + }
  31 +]
  32 +
19 // 活动评价展示到前台状态 33 // 活动评价展示到前台状态
20 export const onlineStatus: EnumArrayItem[] = [ 34 export const onlineStatus: EnumArrayItem[] = [
21 { 35 {
src/views/event/handwork/index.vue
1 <script setup lang="ts"> 1 <script setup lang="ts">
2 import { reactive, ref, onMounted } from "vue"; 2 import { reactive, ref, onMounted } from "vue";
3 -import { handworkList, eventCategory, handworkDelete } from "@/api/event";  
4 -import { parseTime } from "@/utils/tool";  
5 -import { statusData } from "./../config"; 3 +import {
  4 + handworkList,
  5 + eventCategory,
  6 + handworkDelete,
  7 + handworkCancel,
  8 +} from "@/api/event";
  9 +import { parseTime, globalFilters } from "@/utils/tool";
  10 +import { statusData, publishData } from "./../config";
6 import { useLoginStore } from "@/pinia/login"; 11 import { useLoginStore } from "@/pinia/login";
7 import Pagination from "@/components/Pagination/index.vue"; 12 import Pagination from "@/components/Pagination/index.vue";
8 import { ElMessageBox, ElMessage } from "element-plus"; 13 import { ElMessageBox, ElMessage } from "element-plus";
@@ -89,6 +94,37 @@ const getCategory = async (pageSize: number = 20) =&gt; { @@ -89,6 +94,37 @@ const getCategory = async (pageSize: number = 20) =&gt; {
89 } 94 }
90 }; 95 };
91 /** 96 /**
  97 + * 取消发布
  98 + */
  99 +const handleCancel = (id: number) => {
  100 + ElMessageBox.confirm("是否确定删除该活动?", "提示", {
  101 + confirmButtonText: "确认",
  102 + cancelButtonText: "取消",
  103 + type: "warning",
  104 + }).then(async () => {
  105 + try {
  106 + const res = await handworkCancel({
  107 + handworkId: id,
  108 + status: 2,
  109 + });
  110 + if (res?.data) {
  111 + ElMessage({
  112 + type: "success",
  113 + message: "操作成功",
  114 + });
  115 + getList();
  116 + } else {
  117 + ElMessage({
  118 + type: "error",
  119 + message: "操作失败",
  120 + });
  121 + }
  122 + } catch (e) {
  123 + console.log(e);
  124 + }
  125 + });
  126 +};
  127 +/**
92 * 活动删除 128 * 活动删除
93 * @param {number | string} id 活动id 129 * @param {number | string} id 活动id
94 */ 130 */
@@ -108,7 +144,7 @@ const handleDelete = (id: number | string) =&gt; { @@ -108,7 +144,7 @@ const handleDelete = (id: number | string) =&gt; {
108 type: "success", 144 type: "success",
109 message: "操作成功", 145 message: "操作成功",
110 }); 146 });
111 - getList() 147 + getList();
112 } else { 148 } else {
113 ElMessage({ 149 ElMessage({
114 type: "error", 150 type: "error",
@@ -200,6 +236,11 @@ onMounted(() =&gt; { @@ -200,6 +236,11 @@ onMounted(() =&gt; {
200 </template> 236 </template>
201 </el-table-column> 237 </el-table-column>
202 <el-table-column 238 <el-table-column
  239 + prop="personLimit"
  240 + label="活动人数"
  241 + align="center"
  242 + ></el-table-column>
  243 + <el-table-column
203 prop="signupNum" 244 prop="signupNum"
204 label="参与人数" 245 label="参与人数"
205 align="center" 246 align="center"
@@ -231,34 +272,58 @@ onMounted(() =&gt; { @@ -231,34 +272,58 @@ onMounted(() =&gt; {
231 label="活动地址" 272 label="活动地址"
232 align="center" 273 align="center"
233 ></el-table-column> 274 ></el-table-column>
234 - <el-table-column prop="status" label="活动状态" align="center"> 275 + <el-table-column label="活动状态" align="center">
235 <!-- 活动状态值是当前时间和活动开始结束时间对比的结果 276 <!-- 活动状态值是当前时间和活动开始结束时间对比的结果
236 当前时间晚于活动结束时间,即活动已结束 277 当前时间晚于活动结束时间,即活动已结束
237 当前时间早于活动开始时间,即活动未开始 278 当前时间早于活动开始时间,即活动未开始
238 当前时间介于活动开始、结束时间之间(含),即活动进行中 --> 279 当前时间介于活动开始、结束时间之间(含),即活动进行中 -->
239 <template #default="scope"> 280 <template #default="scope">
240 <span v-show="new Date(scope.row.endTime) < new Date()">已结束</span> 281 <span v-show="new Date(scope.row.endTime) < new Date()">已结束</span>
241 - <span v-show="new Date(scope.row.startTime) > new Date()">未开始</span>  
242 - <span v-show="new Date(scope.row.startTime) <= new Date() && new Date(scope.row.endTime) >= new Date()">进行中</span> 282 + <span v-show="new Date(scope.row.startTime) > new Date()"
  283 + >未开始</span
  284 + >
  285 + <span
  286 + v-show="
  287 + new Date(scope.row.startTime) <= new Date() &&
  288 + new Date(scope.row.endTime) >= new Date()
  289 + "
  290 + >进行中</span
  291 + >
  292 + </template>
  293 + </el-table-column>
  294 + <el-table-column prop="status" label="发布状态" align="center">
  295 + <template #default="scope">
  296 + {{ globalFilters(scope.row.status, publishData) }}
243 </template> 297 </template>
244 </el-table-column> 298 </el-table-column>
245 <el-table-column label="操作" align="center"> 299 <el-table-column label="操作" align="center">
246 <template #default="scope"> 300 <template #default="scope">
247 - <el-button type="text" 301 + <el-button type="text" v-show="~~scope.row.status !== 2"
248 ><router-link 302 ><router-link
249 :to="{ path: '/event/handwork/edit', query: scope.row }" 303 :to="{ path: '/event/handwork/edit', query: scope.row }"
250 >编辑</router-link 304 >编辑</router-link
251 ></el-button 305 ></el-button
252 > 306 >
  307 + <!-- 活动取消发布了以后,只能查看人员 -->
253 <el-button type="text" 308 <el-button type="text"
254 ><router-link 309 ><router-link
255 :to="{ path: '/event/signup', query: { id: scope.row.id } }" 310 :to="{ path: '/event/signup', query: { id: scope.row.id } }"
256 >查看人员</router-link 311 >查看人员</router-link
257 ></el-button 312 ></el-button
258 > 313 >
259 - <el-button type="text" @click="handleDelete(scope.row.id)" 314 + <el-button
  315 + type="text"
  316 + @click="handleDelete(scope.row.id)"
  317 + v-show="~~scope.row.status !== 2"
260 >删除</el-button 318 >删除</el-button
261 > 319 >
  320 + <!-- 已发布的活动才能取消发布,取消了以后不能再重新发布 -->
  321 + <el-button
  322 + type="text"
  323 + @click="handleCancel(scope.row.id)"
  324 + v-show="~~scope.row.status === 1"
  325 + >取消发布</el-button
  326 + >
262 </template> 327 </template>
263 </el-table-column> 328 </el-table-column>
264 </el-table> 329 </el-table>