Commit 69cd3ba8893ffaad2a24f8743c9455ad5057eed6
1 parent
019aaa4c
add 列表发布
Showing
1 changed file
with
35 additions
and
7 deletions
src/views/event/handwork/index.vue
| 1 | <script setup lang="ts"> | 1 | <script setup lang="ts"> |
| 2 | -import { reactive, ref, onMounted } from "vue"; | ||
| 3 | -import { handworkList, handworkDelete, handworkCancel } from "@/api/event"; | 2 | +import { reactive, ref, onMounted, getCurrentInstance } from "vue"; |
| 3 | +import { | ||
| 4 | + handworkList, | ||
| 5 | + handworkDelete, | ||
| 6 | + handworkCancel, | ||
| 7 | + handworkEdit, | ||
| 8 | +} from "@/api/event"; | ||
| 4 | import { parseTime, globalFilters } from "@/utils/tool"; | 9 | import { parseTime, globalFilters } from "@/utils/tool"; |
| 5 | import { statusData, publishData } from "./../config"; | 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"; |
| 14 | +let instance: ComponentInternalInstance | null = getCurrentInstance(); | ||
| 9 | interface Form { | 15 | interface Form { |
| 10 | page: number; | 16 | page: number; |
| 11 | pageSize: number; | 17 | pageSize: number; |
| @@ -133,6 +139,23 @@ const handleDelete = (id: number | string) => { | @@ -133,6 +139,23 @@ const handleDelete = (id: number | string) => { | ||
| 133 | console.log(error); | 139 | console.log(error); |
| 134 | }); | 140 | }); |
| 135 | }; | 141 | }; |
| 142 | +/** | ||
| 143 | + * 活动发布 | ||
| 144 | + */ | ||
| 145 | +const issue = async (row: Object): void => { | ||
| 146 | + const currObj = JSON.parse(JSON.stringify(row)); | ||
| 147 | + currObj.status = 1; | ||
| 148 | + handworkEdit(currObj) | ||
| 149 | + .then((res) => { | ||
| 150 | + if (res) { | ||
| 151 | + instance?.proxy?.$message.success("发布成功"); | ||
| 152 | + getList(); | ||
| 153 | + } | ||
| 154 | + }) | ||
| 155 | + .catch((error) => { | ||
| 156 | + console.log(error); | ||
| 157 | + }); | ||
| 158 | +}; | ||
| 136 | onMounted(() => { | 159 | onMounted(() => { |
| 137 | getList(); | 160 | getList(); |
| 138 | }); | 161 | }); |
| @@ -180,13 +203,10 @@ onMounted(() => { | @@ -180,13 +203,10 @@ onMounted(() => { | ||
| 180 | </el-form-item> | 203 | </el-form-item> |
| 181 | <el-form-item> | 204 | <el-form-item> |
| 182 | <el-button type="primary" @click="getList">查询</el-button> | 205 | <el-button type="primary" @click="getList">查询</el-button> |
| 183 | - | ||
| 184 | </el-form-item> | 206 | </el-form-item> |
| 185 | <el-form-item> | 207 | <el-form-item> |
| 186 | - <router-link to="/event/handwork/edit"> | ||
| 187 | - <el-button type="primary"> | ||
| 188 | - 添加活动 | ||
| 189 | - </el-button> | 208 | + <router-link to="/event/handwork/edit"> |
| 209 | + <el-button type="primary"> 添加活动 </el-button> | ||
| 190 | </router-link> | 210 | </router-link> |
| 191 | </el-form-item> | 211 | </el-form-item> |
| 192 | </el-form> | 212 | </el-form> |
| @@ -278,6 +298,13 @@ onMounted(() => { | @@ -278,6 +298,13 @@ onMounted(() => { | ||
| 278 | </el-table-column> | 298 | </el-table-column> |
| 279 | <el-table-column label="操作" align="center"> | 299 | <el-table-column label="操作" align="center"> |
| 280 | <template #default="scope"> | 300 | <template #default="scope"> |
| 301 | + <el-button | ||
| 302 | + type="text" | ||
| 303 | + @click="issue(scope.row)" | ||
| 304 | + v-if="scope.row.status == 0" | ||
| 305 | + >发布</el-button | ||
| 306 | + > | ||
| 307 | + | ||
| 281 | <!-- 已发布的活动不能编辑和删除。 --> | 308 | <!-- 已发布的活动不能编辑和删除。 --> |
| 282 | <el-button type="text" v-show="~~scope.row.status === 0" | 309 | <el-button type="text" v-show="~~scope.row.status === 0" |
| 283 | ><router-link | 310 | ><router-link |
| @@ -316,6 +343,7 @@ onMounted(() => { | @@ -316,6 +343,7 @@ onMounted(() => { | ||
| 316 | v-show="~~scope.row.status === 0" | 343 | v-show="~~scope.row.status === 0" |
| 317 | >删除</el-button | 344 | >删除</el-button |
| 318 | > | 345 | > |
| 346 | + | ||
| 319 | <!-- 已发布的活动才能取消发布,取消了以后不能再重新发布 --> | 347 | <!-- 已发布的活动才能取消发布,取消了以后不能再重新发布 --> |
| 320 | <!-- 已结束的活动,不能取消发布。 --> | 348 | <!-- 已结束的活动,不能取消发布。 --> |
| 321 | <el-button | 349 | <el-button |