Quellcode durchsuchen

盲票列表新增操作项

hwb0 vor 3 Jahren
Ursprung
Commit
d09aece25d
2 geänderte Dateien mit 126 neuen und 43 gelöschten Zeilen
  1. 18 0
      src/api/business/ticket.js
  2. 108 43
      src/views/business/ticket/index.vue

+ 18 - 0
src/api/business/ticket.js

@@ -61,3 +61,21 @@ export function importTicket(data, config = {}){
     }
   })
 }
+
+// 上架、下架
+export function ticketBoxPut(data) {
+  return request({
+    url: '/api/v1/mp/admin/ticket/box/put',
+    method: 'post',
+    data
+  })
+}
+
+// 删除
+export function ticketBoxRemove(data) {
+  return request({
+    url: '/api/v1/mp/admin/ticket/box/remove',
+    method: 'post',
+    data
+  })
+}

+ 108 - 43
src/views/business/ticket/index.vue

@@ -82,7 +82,8 @@
           size="mini"
           @click="handleImport"
           v-hasPermi="['business:ticket:import']"
-        >导入</el-button>
+          >导入</el-button
+        >
       </el-col>
       <el-col :span="1.5">
         <el-button
@@ -93,7 +94,8 @@
           :loading="exportLoading"
           @click="handleExport"
           v-hasPermi="['business:ticket:export']"
-        >导出</el-button>
+          >导出</el-button
+        >
       </el-col>
       <right-toolbar
         :showSearch.sync="showSearch"
@@ -159,7 +161,10 @@
       </el-table-column>
       <el-table-column label="状态" prop="status" min-width="80">
         <template slot-scope="scope">
-          {{ scope.row.status.desc }}
+          <el-tag
+            :type="scope.row.status.value === 'on' ? 'success' : 'info'"
+            >{{ scope.row.status.desc }}</el-tag
+          >
         </template>
       </el-table-column>
 
@@ -171,15 +176,32 @@
         min-width="150"
         fixed="right"
       >
-        <template>
+        <template slot-scope="scope">
           <div>
             <el-button
-              size="mini"
+              v-if="
+                scope.row.status.value === 'off' ||
+                scope.row.status.value === 'done'
+              "
+              v-hasPermi="['business:ticket:on']"
+              type="text"
+              @click="setStatus(scope.row, 'on')"
+              >上架</el-button
+            >
+            <el-button
+              v-if="scope.row.status.value === 'on'"
+              v-hasPermi="['business:ticket:off']"
               type="text"
-              disabled
-              @click="handleDetail(scope.row)"
-              v-hasPermi="['']"
-              >查看</el-button
+              @click="setStatus(scope.row, 'off')"
+              >下架</el-button
+            >
+            <el-button
+              v-if="scope.row.status.value === 'done'"
+              v-hasPermi="['business:ticket:remove']"
+              type="text"
+              class="del"
+              @click="del(scope.row)"
+              >删除</el-button
             >
           </div>
         </template>
@@ -200,17 +222,21 @@
       :dialog-visible="importShow"
       @close="hideDialog"
     />
-
   </div>
 </template>
 <script>
-import { getTicketList , exportTicket} from "@/api/business/ticket";
+import {
+  getTicketList,
+  exportTicket,
+  ticketBoxPut,
+  ticketBoxRemove,
+} from "@/api/business/ticket";
 import { publicFileGetUrl } from "@/api/common";
-import TicketImport from './import'
+import TicketImport from "./import";
 export default {
   name: "Ticket",
   components: {
-   TicketImport
+    TicketImport,
   },
   data() {
     return {
@@ -232,7 +258,7 @@ export default {
       total: 0,
       list: [],
       ids: [],
-      importShow:false
+      importShow: false,
     };
   },
   created() {
@@ -267,9 +293,47 @@ export default {
           this.loading = false;
         });
     },
+
+    setStatus(item, status) {
+      this.$confirm(
+        `确认${status === "on" ? "上架" : "下架"}盲票 “${item.title}” 吗?`,
+        `${status === "on" ? "上架" : "下架"}盲票`,
+        {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning",
+        }
+      ).then(() => {
+        ticketBoxPut({
+          boxId: item.boxId,
+          status,
+        }).then((res) => {
+          if (res.code === 0) {
+            this.$message.success("操作已完成!");
+            this.getList();
+          }
+        });
+      });
+    },
+
+    del(item) {
+      this.$confirm(`确认删除盲票 “${item.title}” 吗?`, "删除盲票", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      }).then(() => {
+        ticketBoxRemove({ boxId: item.boxId }).then((res) => {
+          if (res.code === 0) {
+            this.$message.success("操作已完成!");
+            this.getList();
+          }
+        });
+      });
+    },
+
     // 搜索
     handleQuery() {
-      this.getList()
+      this.getList();
     },
     // 重置
     resetQuery() {},
@@ -278,48 +342,50 @@ export default {
       this.$router.push({ name: "TicketCreate" });
     },
     handleSelect(selection, row) {
-      const isSelect = selection.find(item => item.boxId === row.boxId)
-      this.$refs.table.clearSelection()
+      const isSelect = selection.find((item) => item.boxId === row.boxId);
+      this.$refs.table.clearSelection();
       if (isSelect) {
-        this.$refs.table.toggleRowSelection(row, true)
-        this.ids = row.boxId
+        this.$refs.table.toggleRowSelection(row, true);
+        this.ids = row.boxId;
       } else {
-        this.ids = ''
+        this.ids = "";
       }
     },
 
     handleDetail() {},
 
-    handleImport(){
-      console.log("handleImport ====================")
+    handleImport() {
+      console.log("handleImport ====================");
       this.importShow = true;
     },
 
-    hideDialog(){
+    hideDialog() {
       this.importShow = false;
     },
 
     /** 导出按钮操作 */
     handleExport() {
-     const boxIds = this.ids || [];
-     if(boxIds.length == 0){
-         this.$alert("请选择你要导出的盲票组!",'提示',{type:'warning'});
-     }else{
-       this.$confirm('是否确认导出所选盲票数据项?', "警告", {
-           confirmButtonText: "确定",
-           cancelButtonText: "取消",
-           type: "warning"
-         }).then(() => {
-           this.exportLoading = true;
-           return exportTicket({ids:boxIds});
-         }).then(response => {
-           this.download(response.msg);
-           this.exportLoading = false;
-         }).catch(() => {
-           this.exportLoading = false;
-         });
-     }
-
+      const boxIds = this.ids || [];
+      if (boxIds.length == 0) {
+        this.$alert("请选择你要导出的盲票组!", "提示", { type: "warning" });
+      } else {
+        this.$confirm("是否确认导出所选盲票数据项?", "警告", {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning",
+        })
+          .then(() => {
+            this.exportLoading = true;
+            return exportTicket({ ids: boxIds });
+          })
+          .then((response) => {
+            this.download(response.msg);
+            this.exportLoading = false;
+          })
+          .catch(() => {
+            this.exportLoading = false;
+          });
+      }
     },
   },
   mounted() {},
@@ -333,6 +399,5 @@ export default {
       display: none !important;
     }
   }
-
 }
 </style>