Ver código fonte

feat: 处理设备列表、设备分类多添加一层谨慎操作提示

Damon 9 meses atrás
pai
commit
74475f3e0d

+ 17 - 12
src/views/device/category/index.vue

@@ -85,6 +85,7 @@
 
 <script>
 import { create, edit, list, remove } from "@/api/device/category";
+import { dialogCallBack } from "@/utils/DialogUtil";
 export default {
   data() {
     return {
@@ -205,18 +206,22 @@ export default {
 
     // 删除
     getDelete(id) {
-      this.$confirm("确定要删除?", {
-        type: "warning",
-      })
-        .then(() => {
-          remove(id).then((res) => {
-            if (res.code === 0) {
-              this.getList();
-              this.$message.success("删除成功!");
-            }
-          });
-        })
-        .catch(() => {});
+      var that = this;
+      dialogCallBack(that, function () {
+        that
+          .$confirm(`是否删除?`, "提示:", {
+            type: "warning",
+          })
+          .then(() => {
+            remove(id).then((res) => {
+              if (res.code === 0) {
+                that.getList();
+                that.$message.success("删除成功!");
+              }
+            });
+          })
+          .catch(() => {});
+      });
     },
   },
 };

+ 186 - 81
src/views/device/list/index.vue

@@ -1,3 +1,4 @@
+<!-- 设备管理 设备分类 -->
 <template>
   <div class="app-container">
     <!-- 搜索表单 -->
@@ -6,43 +7,94 @@
         <el-input v-model="form.name" placeholder="请输入设备名称" clearable />
       </el-form-item>
       <el-form-item label="设备型号:">
-        <el-select v-model="form.clientTypeId" placeholder="请选择设备型号" filterable clearable>
-          <el-option v-for="item in devOptions" :key="item.value" :label="item.label" :value="item.value" />
+        <el-select
+          v-model="form.clientTypeId"
+          placeholder="请选择设备型号"
+          filterable
+          clearable
+        >
+          <el-option
+            v-for="item in devOptions"
+            :key="item.value"
+            :label="item.label"
+            :value="item.value"
+          />
         </el-select>
       </el-form-item>
       <el-form-item label="设备分类:">
-        <el-select v-model="form.categoryId" placeholder="请选择设备分类" clearable>
-          <el-option v-for="item in categoryOptions" :key="item.value" :value="item.value" :label="item.label" />
+        <el-select
+          v-model="form.categoryId"
+          placeholder="请选择设备分类"
+          clearable
+        >
+          <el-option
+            v-for="item in categoryOptions"
+            :key="item.value"
+            :value="item.value"
+            :label="item.label"
+          />
         </el-select>
       </el-form-item>
       <el-form-item label="当前状态:">
         <el-select v-model="form.status" placeholder="请选择当前状态" clearable>
-          <el-option v-for="item in onOrOffOptions" :key="item.value" :value="item.value" :label="item.label" />
+          <el-option
+            v-for="item in onOrOffOptions"
+            :key="item.value"
+            :value="item.value"
+            :label="item.label"
+          />
         </el-select>
       </el-form-item>
       <el-form-item label="是否热门:">
         <el-select v-model="form.isHot" placeholder="请选择是否热门" clearable>
-          <el-option v-for="item in yesOrNoOptions" :key="item.value" :value="item.value" :label="item.label" />
+          <el-option
+            v-for="item in yesOrNoOptions"
+            :key="item.value"
+            :value="item.value"
+            :label="item.label"
+          />
         </el-select>
       </el-form-item>
       <el-form-item>
-        <el-button type="primary" icon="el-icon-search" @click="getSearch">搜索</el-button>
+        <el-button type="primary" icon="el-icon-search" @click="getSearch"
+          >搜索</el-button
+        >
         <el-button icon="el-icon-refresh" @click="getRefresh">重置</el-button>
-        <el-button type="primary" icon="el-icon-plus" plain @click="getChange()" v-hasPermi="['device:list:add']">
+        <el-button
+          type="primary"
+          icon="el-icon-plus"
+          plain
+          @click="getChange()"
+          v-hasPermi="['device:list:add']"
+        >
           新增
         </el-button>
-        <el-button type="primary" icon="el-icon-top" @click="getShelves(1)" :disabled="isDisabled()"
-          v-hasPermi="['device:list:up']">
+        <el-button
+          type="primary"
+          icon="el-icon-top"
+          @click="getShelves(1)"
+          :disabled="isDisabled()"
+          v-hasPermi="['device:list:up']"
+        >
           批量上架
         </el-button>
-        <el-button type="primary" icon="el-icon-bottom" @click="getShelves(2)" :disabled="isDisabled()"
-          v-hasPermi="['device:list:down']">
+        <el-button
+          type="primary"
+          icon="el-icon-bottom"
+          @click="getShelves(2)"
+          :disabled="isDisabled()"
+          v-hasPermi="['device:list:down']"
+        >
           批量下架
         </el-button>
       </el-form-item>
     </el-form>
     <!-- 表格 -->
-    <el-table :data="tableData" v-loading="loading" @selection-change="handleSelectionChange">
+    <el-table
+      :data="tableData"
+      v-loading="loading"
+      @selection-change="handleSelectionChange"
+    >
       <el-table-column type="selection" align="center" />
       <el-table-column label="设备ID" prop="id" align="center" />
       <el-table-column label="设备型号" prop="clientType" align="center" />
@@ -54,40 +106,87 @@
         </template>
       </el-table-column>
       <el-table-column label="设备分类" prop="categoryName" align="center" />
-      <el-table-column label="设备类型" prop="deviceType" align="center" :formatter="deviceTypeFormatter" />
-      <el-table-column label="是否热门" prop="isHot" align="center" :formatter="hotFormatter" />
+      <el-table-column
+        label="设备类型"
+        prop="deviceType"
+        align="center"
+        :formatter="deviceTypeFormatter"
+      />
+      <el-table-column
+        label="是否热门"
+        prop="isHot"
+        align="center"
+        :formatter="hotFormatter"
+      />
       <el-table-column label="创建时间" prop="createTimeText" align="center" />
       <el-table-column label="操作" align="center">
         <template slot-scope="scope">
-          <el-button type="text" @click="getChange(scope.row.id, true)">查看</el-button>
-          <el-button v-if="scope.row.status === 2" type="text" @click="getChange(scope.row.id)"
-            v-hasPermi="['device:list:edit']">
+          <el-button type="text" @click="getChange(scope.row.id, true)"
+            >查看</el-button
+          >
+          <el-button
+            v-if="scope.row.status === 2"
+            type="text"
+            @click="getChange(scope.row.id)"
+            v-hasPermi="['device:list:edit']"
+          >
             编辑
           </el-button>
-          <el-button v-if="scope.row.status === 2" type="text" @click="getShelves(1, scope.row.id)"
-            v-hasPermi="['device:list:up']">
+          <el-button
+            v-if="scope.row.status === 2"
+            type="text"
+            @click="getShelves(1, scope.row.id)"
+            v-hasPermi="['device:list:up']"
+          >
             上架
           </el-button>
-          <el-button v-else type="text" @click="getShelves(2, scope.row.id)" v-hasPermi="['device:list:down']">
+          <el-button
+            v-else
+            type="text"
+            @click="getShelves(2, scope.row.id)"
+            v-hasPermi="['device:list:down']"
+          >
             下架
           </el-button>
-          <el-button v-if="scope.row.status === 2" type="delete" @click="getDelete(scope.row.id)"
-            v-hasPermi="['device:list:delete']">
+          <el-button
+            v-if="scope.row.status === 2"
+            type="delete"
+            @click="getDelete(scope.row.id)"
+            v-hasPermi="['device:list:delete']"
+          >
             删除
           </el-button>
         </template>
       </el-table-column>
     </el-table>
-    <pagination v-show="total > 0" :total="total" :page.sync="form.pageNum" :limit.sync="form.pageSize"
-      @pagination="getList" />
+    <pagination
+      v-show="total > 0"
+      :total="total"
+      :page.sync="form.pageNum"
+      :limit.sync="form.pageSize"
+      @pagination="getList"
+    />
   </div>
 </template>
 
 <script>
-import { list, remove, change } from '@/api/device/list'
-import { devMixin, onOrOffMixin, devTypeMixin, devCategoryMixin, yesOrNoMixin } from '@/mixin/index'
+import { change, list, remove } from "@/api/device/list";
+import {
+  devCategoryMixin,
+  devMixin,
+  devTypeMixin,
+  onOrOffMixin,
+  yesOrNoMixin,
+} from "@/mixin/index";
+import { dialogCallBack } from "@/utils/DialogUtil";
 export default {
-  mixins: [devMixin, onOrOffMixin, devTypeMixin, devCategoryMixin, yesOrNoMixin],
+  mixins: [
+    devMixin,
+    onOrOffMixin,
+    devTypeMixin,
+    devCategoryMixin,
+    yesOrNoMixin,
+  ],
   data() {
     return {
       // 遮罩层
@@ -99,66 +198,66 @@ export default {
       // 搜索表单
       form: {
         pageNum: 1,
-        pageSize: 10
+        pageSize: 10,
       },
       // 批量上下架
       changeForm: {
-        ids: '',
-        type: null
-      }
-    }
+        ids: "",
+        type: null,
+      },
+    };
   },
   mounted() {
-    this.getDevList()
-    this.getCateGory(1)
-    this.getList()
+    this.getDevList();
+    this.getCateGory(1);
+    this.getList();
   },
   methods: {
     // 列表
     getList() {
-      this.loading = true
-      list(this.form).then(res => {
-        this.tableData = res.data.records
-        this.total = res.data.total
-        this.loading = false
-      })
+      this.loading = true;
+      list(this.form).then((res) => {
+        this.tableData = res.data.records;
+        this.total = res.data.total;
+        this.loading = false;
+      });
     },
 
     // 搜索
     getSearch() {
-      this.form.pageNum = 1
-      this.form.pageSize = 10
-      this.getList()
+      this.form.pageNum = 1;
+      this.form.pageSize = 10;
+      this.getList();
     },
 
     // 重置
     getRefresh() {
       this.form = {
-        name: '',
+        name: "",
         pageNum: 1,
-        pageSize: 10
-      }
-      this.getList()
+        pageSize: 10,
+      };
+      this.getList();
     },
 
     // 禁用上下架功能
     isDisabled() {
-      return this.changeForm.ids === '' ? true : false
+      return this.changeForm.ids === "" ? true : false;
     },
 
     // 上下架
     getShelves(key, e) {
       if (e) {
-        this.changeForm.ids = e
+        this.changeForm.ids = e;
       }
-      let title = key === 1 ? '上架' : '下架'
-      this.changeForm.type = key
-      change(this.changeForm).then(res => {
+      let title = key === 1 ? "上架" : "下架";
+      this.changeForm.type = key;
+      change(this.changeForm).then((res) => {
         if (res.code === 0) {
-          this.$message.success(`${title}成功!`)
-          this.getList()
+          this.$message.success(`${title}成功!`);
+          this.getList();
         }
-      })
+      });
     },
 
     // 新增 / 编辑 / 查看
@@ -167,46 +266,52 @@ export default {
         path: `/device/deviceList/detail`,
         query: {
           id: id,
-          boolean: boolean
-        }
-      })
+          boolean: boolean,
+        },
+      });
     },
 
     // 多选
     handleSelectionChange(e) {
       if (e.length > 0) {
-        let arr = []
-        e.filter(i => {
-          arr.push(i.id)
-          this.changeForm.ids = arr.join(',')
-        })
+        let arr = [];
+        e.filter((i) => {
+          arr.push(i.id);
+          this.changeForm.ids = arr.join(",");
+        });
       } else {
-        this.changeForm.ids = ''
+        this.changeForm.ids = "";
       }
     },
 
     // 删除
     getDelete(id) {
-      this.$confirm('确定要删除?', {
-        type: 'warning'
-      }).then(() => {
-        remove(id).then(res => {
-          if (res.code === 0) {
-            this.getList()
-            this.$message.success('删除成功!')
-          }
-        })
-      }).catch(() => { })
+      var that = this;
+      dialogCallBack(that, function () {
+        that
+          .$confirm("确定要删除?", {
+            type: "warning",
+          })
+          .then(() => {
+            remove(id).then((res) => {
+              if (res.code === 0) {
+                that.getList();
+                that.$message.success("删除成功!");
+              }
+            });
+          })
+          .catch(() => {});
+      });
     },
 
     // 字典翻译
     hotFormatter(row) {
-      return this.selectDictLabel(this.yesOrNoOptions, row.isHot)
+      return this.selectDictLabel(this.yesOrNoOptions, row.isHot);
     },
 
     deviceTypeFormatter(row) {
-      return this.selectDictLabel(this.devTypeOptions, row.deviceType)
-    }
-  }
-}
+      return this.selectDictLabel(this.devTypeOptions, row.deviceType);
+    },
+  },
+};
 </script>

+ 113 - 64
src/views/registration/lottery/index.vue

@@ -1,9 +1,15 @@
+<!-- 签到管理 抽奖配置 -->
 <template>
   <div class="app-container">
     <el-form size="mini">
       <el-form-item>
-        <el-button type="primary" icon="el-icon-plus" @click="getDetail()"
-          v-hasPermi="['registration:lottery:add']">新增</el-button>
+        <el-button
+          type="primary"
+          icon="el-icon-plus"
+          @click="getDetail()"
+          v-hasPermi="['registration:lottery:add']"
+          >新增</el-button
+        >
       </el-form-item>
     </el-form>
     <!-- 列表 -->
@@ -15,22 +21,56 @@
           {{ scope.row.startTime }} - {{ scope.row.endTime }}
         </template>
       </el-table-column>
-      <el-table-column label="活动状态" prop="currentStatus" align="center" :formatter="currentFormatter" />
-      <el-table-column label="当前状态" prop="status" align="center" :formatter="statusFormatter" />
+      <el-table-column
+        label="活动状态"
+        prop="currentStatus"
+        align="center"
+        :formatter="currentFormatter"
+      />
+      <el-table-column
+        label="当前状态"
+        prop="status"
+        align="center"
+        :formatter="statusFormatter"
+      />
       <el-table-column label="操作" align="center">
         <template slot-scope="scope">
-          <el-button type="text" @click="getDetail(scope.row.id, true)">查看</el-button>
-          <span v-if="scope.row.status === 1" style="margin: 0 10px;">
-            <el-button type="text" @click="getDetail(scope.row.id)"
-              v-hasPermi="['registration:lottery:edit']">编辑</el-button>
-            <el-button type="text" @click="getChange(scope.row, 0)"
-              v-hasPermi="['registration:lottery:up']">上架</el-button>
-            <el-button type="delete" @click="getDelete(scope.row)"
-              v-hasPermi="['registration:lottery:delete']">删除</el-button>
+          <el-button type="text" @click="getDetail(scope.row.id, true)"
+            >查看</el-button
+          >
+          <span v-if="scope.row.status === 1" style="margin: 0 10px">
+            <el-button
+              type="text"
+              @click="getDetail(scope.row.id)"
+              v-hasPermi="['registration:lottery:edit']"
+              >编辑</el-button
+            >
+            <el-button
+              type="text"
+              @click="getChange(scope.row, 0)"
+              v-hasPermi="['registration:lottery:up']"
+              >上架</el-button
+            >
+            <el-button
+              type="delete"
+              @click="getDelete(scope.row)"
+              v-hasPermi="['registration:lottery:delete']"
+              >删除</el-button
+            >
           </span>
-          <el-button v-else type="text" @click="getChange(scope.row, 1)"
-            v-hasPermi="['registration:lottery:down']">下架</el-button>
-          <el-button type="text" @click="getCopy(scope.row.id)" v-hasPermi="[`registration:lottery:copy`]">复制</el-button>
+          <el-button
+            v-else
+            type="text"
+            @click="getChange(scope.row, 1)"
+            v-hasPermi="['registration:lottery:down']"
+            >下架</el-button
+          >
+          <el-button
+            type="text"
+            @click="getCopy(scope.row.id)"
+            v-hasPermi="[`registration:lottery:copy`]"
+            >复制</el-button
+          >
         </template>
       </el-table-column>
     </el-table>
@@ -38,8 +78,9 @@
 </template>
 
 <script>
-import { list, change, remove } from '@/api/registration/lottery'
-import { disabledMixin, currentMixin } from '@/mixin/index'
+import { change, list, remove } from "@/api/registration/lottery";
+import { currentMixin, disabledMixin } from "@/mixin/index";
+import { dialogCallBack } from "@/utils/DialogUtil";
 export default {
   mixins: [disabledMixin, currentMixin],
   data() {
@@ -49,28 +90,28 @@ export default {
       // 表单
       form: {
         pageNum: 1,
-        pageSize: 10
+        pageSize: 10,
       },
       // 总数据
       total: 0,
       // 列表
-      tableData: []
-    }
+      tableData: [],
+    };
   },
   mounted() {
-    this.getList()
+    this.getList();
   },
   methods: {
     // 列表
     getList() {
-      this.loading = true
-      list(this.form).then(res => {
+      this.loading = true;
+      list(this.form).then((res) => {
         if (res.code === 0) {
-          this.tableData = res.data.records
-          this.total = res.data.total
-          this.loading = false
+          this.tableData = res.data.records;
+          this.total = res.data.total;
+          this.loading = false;
         }
-      })
+      });
     },
 
     // 新增
@@ -79,43 +120,51 @@ export default {
         path: `/registration/lotteryConfig/detail`,
         query: {
           id: id,
-          disabled: boolean
-        }
-      })
+          disabled: boolean,
+        },
+      });
     },
 
     // 上下架
     getChange(row, status) {
-      let title = status === 0 ? '上架' : '下架'
-      this.$confirm(`是否${title}${row.name}?`, '提示', {
-        type: 'warning'
-      }).then(() => {
-        change({
-          id: row.id,
-          status: status
-        }).then(res => {
-          if (res.code === 0) {
-            this.$message.success(`${title}成功!`)
-            this.getList()
-          }
+      let title = status === 0 ? "上架" : "下架";
+      this.$confirm(`是否${title}${row.name}?`, "提示", {
+        type: "warning",
+      })
+        .then(() => {
+          change({
+            id: row.id,
+            status: status,
+          }).then((res) => {
+            if (res.code === 0) {
+              this.$message.success(`${title}成功!`);
+              this.getList();
+            }
+          });
         })
-      }).catch(() => { })
+        .catch(() => {});
     },
 
     // 删除
     getDelete(row) {
-      this.$confirm(`是否删除${row.name}?`, '提示', {
-        type: 'warning'
-      }).then(() => {
-        remove({
-          id: row.id
-        }).then(res => {
-          if (res.code === 0) {
-            this.$message.success('删除成功!')
-            this.getList()
-          }
-        })
-      }).catch(() => { })
+      var that = this;
+      dialogCallBack(that, function () {
+        that
+          .$confirm(`是否删除${row.name}?`, "提示:", {
+            type: "warning",
+          })
+          .then(() => {
+            remove({
+              id: row.id,
+            }).then((res) => {
+              if (res.code === 0) {
+                that.$message.success("删除成功!");
+                that.getList();
+              }
+            });
+          })
+          .catch(() => {});
+      });
     },
 
     // 复制
@@ -123,18 +172,18 @@ export default {
       this.$router.push({
         path: `/registration/lotteryConfig/detail`,
         query: {
-          copyId: id
-        }
-      })
+          copyId: id,
+        },
+      });
     },
 
     // 字典翻译
     statusFormatter(row) {
-      return this.selectDictLabel(this.disabledOptions, row.status)
+      return this.selectDictLabel(this.disabledOptions, row.status);
     },
     currentFormatter(row) {
-      return this.selectDictLabel(this.currentOptions, row.currentStatus)
-    }
-  }
-}
-</script>
+      return this.selectDictLabel(this.currentOptions, row.currentStatus);
+    },
+  },
+};
+</script>