Commit 69cd3ba8893ffaad2a24f8743c9455ad5057eed6

Authored by 张红振
1 parent 019aaa4c

add 列表发布

src/views/event/handwork/index.vue
1 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 9 import { parseTime, globalFilters } from "@/utils/tool";
5 10 import { statusData, publishData } from "./../config";
6 11 import { useLoginStore } from "@/pinia/login";
7 12 import Pagination from "@/components/Pagination/index.vue";
8 13 import { ElMessageBox, ElMessage } from "element-plus";
  14 +let instance: ComponentInternalInstance | null = getCurrentInstance();
9 15 interface Form {
10 16 page: number;
11 17 pageSize: number;
... ... @@ -133,6 +139,23 @@ const handleDelete = (id: number | string) =&gt; {
133 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 159 onMounted(() => {
137 160 getList();
138 161 });
... ... @@ -180,13 +203,10 @@ onMounted(() =&gt; {
180 203 </el-form-item>
181 204 <el-form-item>
182 205 <el-button type="primary" @click="getList">查询</el-button>
183   -
184 206 </el-form-item>
185 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 210 </router-link>
191 211 </el-form-item>
192 212 </el-form>
... ... @@ -278,6 +298,13 @@ onMounted(() =&gt; {
278 298 </el-table-column>
279 299 <el-table-column label="操作" align="center">
280 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 309 <el-button type="text" v-show="~~scope.row.status === 0"
283 310 ><router-link
... ... @@ -316,6 +343,7 @@ onMounted(() =&gt; {
316 343 v-show="~~scope.row.status === 0"
317 344 >删除</el-button
318 345 >
  346 +
319 347 <!-- 已发布的活动才能取消发布,取消了以后不能再重新发布 -->
320 348 <!-- 已结束的活动,不能取消发布。 -->
321 349 <el-button
... ...