Explorar el Código

feat: 设备分类新增排序功能

Damon hace 11 meses
padre
commit
0e2d41e2e1

+ 2 - 2
src/api/operation/channels.js

@@ -74,7 +74,7 @@ export function classRemove(id) {
   })
 }
 
-// 频道详情
+// 频道详情 排序
 // export function changeDetail(data) {
 //   return request({
 //     url: `/admin/config/channel/view`,
@@ -83,7 +83,7 @@ export function classRemove(id) {
 //   })
 // }
 
-// 频道详情 排序
+// 频道详情 
 export function changeDetail(data) {
   return request({
     url: `/admin/config/channel/channel/sortEdit`,

+ 64 - 26
src/views/device/category/index.vue

@@ -1,10 +1,17 @@
+<!-- 设备分类 -->
 <template>
   <div class="app-container">
     <!-- 搜索 -->
     <el-form inline label-width="100px" size="mini" @submit.native.prevent>
       <el-form-item>
-        <el-button type="primary" icon="el-icon-plus" plain @click="getChange()"
-          v-hasPermi="['device:category:add']">新增</el-button>
+        <el-button
+          type="primary"
+          icon="el-icon-plus"
+          plain
+          @click="getChange()"
+          v-hasPermi="['device:category:add']"
+          >新增</el-button
+        >
       </el-form-item>
     </el-form>
 
@@ -21,10 +28,18 @@
       </el-table-column>
       <el-table-column label="操作" align="center">
         <template slot-scope="scope">
-          <el-button type="text" @click="getChange(scope.row)" v-hasPermi="['device:category:edit']">
+          <el-button
+            type="text"
+            @click="getChange(scope.row)"
+            v-hasPermi="['device:category:edit']"
+          >
             编辑
           </el-button>
-          <el-button type="delete" @click="getDelete(scope.row.id)" v-hasPermi="['device:category:delete']">
+          <el-button
+            type="delete"
+            @click="getDelete(scope.row.id)"
+            v-hasPermi="['device:category:delete']"
+          >
             删除
           </el-button>
         </template>
@@ -32,7 +47,12 @@
     </el-table>
 
     <!-- 新增弹窗 -->
-    <el-dialog :title="title" :visible.sync="dialogVisible" width="500px" :before-close="getCancel">
+    <el-dialog
+      :title="title"
+      :visible.sync="dialogVisible"
+      width="500px"
+      :before-close="getCancel"
+    >
       <el-form :model="form" :rules="rules" ref="form" label-width="100px">
         <el-form-item label="分类名称:" prop="name">
           <el-input v-model="form.name" placeholder="请输入分类名称" />
@@ -43,22 +63,28 @@
             <el-radio :label="2">停用</el-radio>
           </el-radio-group>
         </el-form-item>
+
+        <el-form-item label="标签排序:" prop="sort">
+          <el-input-number
+            v-model="form.sort"
+            :min="1"
+            :step="1"
+            step-strictly
+          />
+        </el-form-item>
       </el-form>
       <div slot="footer">
         <el-button size="mini" @click="getCancel">取消</el-button>
-        <el-button type="primary" size="mini" @click="getCreate">确定</el-button>
+        <el-button type="primary" size="mini" @click="getCreate"
+          >确定</el-button
+        >
       </div>
     </el-dialog>
   </div>
 </template>
 
 <script>
-import {
-  list,
-  create,
-  edit,
-  remove,
-} from "@/api/device/category";
+import { create, edit, list, remove } from "@/api/device/category";
 export default {
   data() {
     return {
@@ -71,11 +97,18 @@ export default {
       title: "",
       // 提交表单
       form: {
-        name: '',
-        status: 1
+        name: "",
+        status: 1,
       },
       // 表单验证
       rules: {
+        sort: [
+          {
+            required: true,
+            message: "请选择标签排序",
+            trigger: "change",
+          },
+        ],
         name: [
           {
             required: true,
@@ -92,13 +125,16 @@ export default {
         ],
       },
       // 设备状态
-      statusOptions: [{
-        value: 1,
-        label: '正常'
-      }, {
-        value: 2,
-        label: '停用'
-      }]
+      statusOptions: [
+        {
+          value: 1,
+          label: "正常",
+        },
+        {
+          value: 2,
+          label: "停用",
+        },
+      ],
     };
   },
   mounted() {
@@ -119,10 +155,12 @@ export default {
     // 新增 / 编辑按钮
     getChange(row) {
       this.dialogVisible = true;
-      this.form = row ? row : {
-        name: '',
-        status: 1
-      };
+      this.form = row
+        ? row
+        : {
+            name: "",
+            status: 1,
+          };
       this.title = row ? "编辑" : "新增";
     },
 
@@ -174,7 +212,7 @@ export default {
             }
           });
         })
-        .catch(() => { });
+        .catch(() => {});
     },
   },
 };

+ 3 - 1
src/views/operation/channel/detail.vue

@@ -107,16 +107,18 @@
           <el-table-column label="操作" align="center">
             <template slot-scope="scope">
               <el-button type="delete" @click="getDelete(scope.row)"
-                >删除</el-button
+                >删除{{ form.list.length }}</el-button
               >
 
               <el-button
+                v-if="form.list.length > 1"
                 type="text"
                 icon="el-icon-caret-top"
                 @click="getChangeDetail(scope.row, scope.row.sort - 1)"
                 :disabled="disabled"
               />
               <el-button
+                v-if="form.list.length > 1"
                 type="text"
                 icon="el-icon-caret-bottom"
                 @click="getChangeDetail(scope.row, scope.row.sort + 1)"

+ 218 - 108
src/views/operation/channel/index.vue

@@ -1,59 +1,153 @@
 <template>
   <div class="app-container">
     <!-- 新增 -->
-    <el-button type="primary" icon="el-icon-plus" size="mini" @click="getDialog('新增')"
-      v-hasPermi="['operation:channel:add']">
+    <el-button
+      type="primary"
+      icon="el-icon-plus"
+      size="mini"
+      @click="getDialog('新增')"
+      v-hasPermi="['operation:channel:add']"
+    >
       新增频道配置
     </el-button>
     <!-- 列表 -->
     <el-table :data="tableData" v-loading="loading">
       <el-table-column label="序号" align="center" type="index" />
       <el-table-column label="频道配置名称" prop="name" align="center" />
-      <el-table-column label="部署形式" prop="type" align="center" :formatter="typeFormatter" />
-      <el-table-column label="设备" prop="deviceIds" align="center" :formatter="devFormatter" show-overflow-tooltip />
+      <el-table-column
+        label="部署形式"
+        prop="type"
+        align="center"
+        :formatter="typeFormatter"
+      />
+      <el-table-column
+        label="设备"
+        prop="deviceIds"
+        align="center"
+        :formatter="devFormatter"
+        show-overflow-tooltip
+      />
       <el-table-column label="操作" align="center">
         <template slot-scope="scope">
-          <el-button type="text" @click="getDialog('查看', scope.row, scope.$index, true)">查看</el-button>
-          <el-button type="text" @click="getDialog('编辑', scope.row, scope.$index)"
-            v-hasPermi="['operation:channel:edit']">编辑</el-button>
-          <el-button v-if="scope.$index !== 0" type="delete" @click="getDelete(scope.row)"
-            v-hasPermi="['operation:channel:delete']">
+          <el-button
+            type="text"
+            @click="getDialog('查看', scope.row, scope.$index, true)"
+            >查看</el-button
+          >
+          <el-button
+            type="text"
+            @click="getDialog('编辑', scope.row, scope.$index)"
+            v-hasPermi="['operation:channel:edit']"
+            >编辑</el-button
+          >
+          <el-button
+            v-if="scope.$index !== 0"
+            type="delete"
+            @click="getDelete(scope.row)"
+            v-hasPermi="['operation:channel:delete']"
+          >
             删除
           </el-button>
         </template>
       </el-table-column>
     </el-table>
     <!-- 弹窗 -->
-    <el-dialog :visible.sync="dialogVisible" :title="title" width="950px" :before-close="cancel">
+    <el-dialog
+      :visible.sync="dialogVisible"
+      :title="title"
+      width="950px"
+      :before-close="cancel"
+    >
       <el-form label-width="auto">
-        <el-form-item v-if="index !== 1" label="频道配置名称:" style="width: 300px">
-          <el-input v-model="dialogForm.name" placeholder="请输入规则名称" :disabled="disabled" />
+        <el-form-item
+          v-if="index !== 1"
+          label="频道配置名称:"
+          style="width: 300px"
+        >
+          <el-input
+            v-model="dialogForm.name"
+            placeholder="请输入规则名称"
+            :disabled="disabled"
+          />
         </el-form-item>
         <el-form-item v-if="index !== 1" label="关联设备:">
-          <el-select v-model="ids" filterable multiple placeholder="请选择关联设备" :disabled="disabled">
-            <el-option v-for="item in devOptions" :key="item.clientTypeId" :value="item.clientTypeId.toString()"
-              :label="item.name" />
+          <el-select
+            v-model="ids"
+            filterable
+            multiple
+            placeholder="请选择关联设备"
+            :disabled="disabled"
+          >
+            <el-option
+              v-for="item in devOptions"
+              :key="item.clientTypeId"
+              :value="item.clientTypeId.toString()"
+              :label="item.name"
+            />
           </el-select>
         </el-form-item>
-        <el-form-item v-if="title !== '新增'" label="内容列表:" style="height: 500px; overflow-y: auto;">
-          <el-table :data="list" v-loading="dialog_loading" lazy :default-sort="{ prop: 'sort' }">
-            <el-table-column label="序号" prop="sort" align="center" width="100px" />
-            <el-table-column label="频道数" prop="channelId" align="center" width="100px" />
-            <el-table-column label="频道名称" prop="aliasName" align="center" show-overflow-tooltip />
+        <el-form-item
+          v-if="title !== '新增'"
+          label="内容列表:"
+          style="height: 500px; overflow-y: auto"
+        >
+          <el-table
+            :data="list"
+            v-loading="dialog_loading"
+            lazy
+            :default-sort="{ prop: 'sort' }"
+          >
+            <el-table-column
+              label="序号"
+              prop="sort"
+              align="center"
+              width="100px"
+            />
+            <el-table-column
+              label="频道数"
+              prop="channelId"
+              align="center"
+              width="100px"
+            />
+            <el-table-column
+              label="频道名称"
+              prop="aliasName"
+              align="center"
+              show-overflow-tooltip
+            />
             <el-table-column label="频道封面" align="center" width="100px">
               <template slot-scope="scope">
                 <el-image :src="scope.row.pic"></el-image>
               </template>
             </el-table-column>
-            <el-table-column label="频道简介" prop="description" align="center" show-overflow-tooltip />
+            <el-table-column
+              label="频道简介"
+              prop="description"
+              align="center"
+              show-overflow-tooltip
+            />
             <el-table-column label="操作" align="center">
               <template slot-scope="scope">
-                <el-button type="text" @click="edit(scope, true)">查看</el-button>
-                <el-button type="text" @click="edit(scope)" :disabled="disabled">编辑</el-button>
-                <el-button v-if="scope.row.sort > 3" type="text" icon="el-icon-caret-top"
-                  @click="getChange(scope.row.id, scope.row.sort - 1)" :disabled="disabled" />
-                <el-button v-if="scope.row.sort > 2 && scope.row.sort < 12" type="text" icon="el-icon-caret-bottom"
-                  @click="getChange(scope.row.id, scope.row.sort + 1)" :disabled="disabled" />
+                <el-button type="text" @click="edit(scope, true)"
+                  >查看</el-button
+                >
+                <el-button type="text" @click="edit(scope)" :disabled="disabled"
+                  >编辑</el-button
+                >
+                <el-button
+                  v-if="scope.row.sort > 3"
+                  type="text"
+                  icon="el-icon-caret-top"
+                  @click="getChange(scope.row.id, scope.row.sort - 1)"
+                  :disabled="disabled"
+                />
+                <el-button
+                  v-if="scope.row.sort > 2 && scope.row.sort < 12"
+                  type="text"
+                  icon="el-icon-caret-bottom"
+                  @click="getChange(scope.row.id, scope.row.sort + 1)"
+                  :disabled="disabled"
+                />
               </template>
             </el-table-column>
           </el-table>
@@ -68,9 +162,17 @@
 </template>
 
 <script>
-import { change, channelPage, create, devList, editPage, getRemove, page } from '@/api/operation/channel';
+import {
+change,
+channelPage,
+create,
+devList,
+editPage,
+getRemove,
+page,
+} from "@/api/operation/channel";
 export default {
-  name: 'Channel',
+  name: "Channel",
   data() {
     return {
       // 遮罩层
@@ -81,14 +183,14 @@ export default {
       list: [],
       // 弹窗
       dialogVisible: false,
-      title: '',
+      title: "",
       // 设备
       devOptions: [],
       allDevOptions: [],
       // 表单
       form: {
         pageNum: 1,
-        pageSize: 10
+        pageSize: 10,
       },
       index: 0,
       dialogForm: {},
@@ -96,139 +198,142 @@ export default {
       // 频道规则Id
       obj: {},
       // 部署形式
-      typeOptions: [{
-        value: 0,
-        label: '注册用户-默认'
-      }, {
-        value: 1,
-        label: '绑定特定设备'
-      }],
+      typeOptions: [
+        {
+          value: 0,
+          label: "注册用户-默认",
+        },
+        {
+          value: 1,
+          label: "绑定特定设备",
+        },
+      ],
       // 只读
-      disabled: false
+      disabled: false,
     };
   },
   watch: {
     ids(val) {
-      this.dialogForm.deviceIds = val.join(',')
-    }
+      this.dialogForm.deviceIds = val.join(",");
+    },
   },
   mounted() {
-    this.getDevList()
-    this.getList()
+    this.getDevList();
+    this.getList();
   },
   methods: {
     // 列表
     getList() {
-      this.loading = true
-      page(this.form).then(res => {
+      this.loading = true;
+      page(this.form).then((res) => {
         if (res.code === 0) {
-          this.tableData = res.data
-          this.loading = false
+          this.tableData = res.data;
+          this.loading = false;
         }
-      })
+      });
     },
 
     // 全部设备
     getDevList() {
-      devList(1).then(res => {
+      devList(1).then((res) => {
         if (res.code === 0) {
-          this.allDevOptions = []
-          res.data.map(i => {
+          this.allDevOptions = [];
+          res.data.map((i) => {
             this.allDevOptions.push({
               value: i.clientTypeId,
-              label: i.name
-            })
-          })
+              label: i.name,
+            });
+          });
         }
-      })
+      });
     },
 
     // 编辑
     edit(e, boolean) {
-      this.dialogVisible = false
+      this.dialogVisible = false;
       this.$router.push({
         path: `/operation/channel/detail`,
         query: {
           channelId: e.row.id,
           audioType: e.row.channelType,
           index: e.$index,
-          boolean: boolean
-        }
-      })
+          boolean: boolean,
+        },
+      });
     },
 
     // 删除
     getDelete(row) {
-      this.$confirm(`是否删除${row.name}?`, '提示', {
-        type: 'warning'
+      this.$confirm(`是否删除${row.name}?`, "提示", {
+        type: "warning",
       }).then(() => {
-        getRemove(row.id).then(res => {
+        getRemove(row.id).then((res) => {
           if (res.code === 0) {
-            this.$message.success('删除成功!')
-            this.getList()
+            this.$message.success("删除成功!");
+            this.getList();
           }
-        })
-      })
+        });
+      });
     },
 
     // 弹窗
     getDialog(title, row, index, boolean) {
-      this.dialogVisible = true
-      this.title = title
-      this.index = index + 1
-      this.obj = row
-      this.disabled = boolean
+      this.dialogVisible = true;
+      this.title = title;
+      this.index = index + 1;
+      this.obj = row;
+      this.disabled = boolean;
       // 新增 / 编辑时的设备
-      devList(0).then(res => {
+      devList(0).then((res) => {
         if (res.code === 0) {
-          this.devOptions = res.data
-          if (this.title !== '新增') {
-            this.devOptions.unshift.apply(this.devOptions, row.deviceList)
+          this.devOptions = res.data;
+          if (this.title !== "新增") {
+            this.devOptions.unshift.apply(this.devOptions, row.deviceList);
           }
         }
-      })
+      });
 
-      if (title !== '新增') {
-        this.dialogForm = row
+      if (title !== "新增") {
+        this.dialogForm = row;
         if (this.index !== 1) {
-          this.ids = this.dialogForm.deviceIds.split(',')
+          this.ids = this.dialogForm.deviceIds.split(",");
         }
-        this.getPage(row)
+        this.getPage(row);
       }
     },
 
     // 十二频道
     getPage(row) {
-      channelPage(row.id).then(res => {
+      channelPage(row.id).then((res) => {
         if (res.code === 0) {
-          this.list = res.data
-          this.dialog_loading = false
+          this.list = res.data;
+          this.dialog_loading = false;
         }
-      })
+      });
     },
 
     // 创建
     getSubmit() {
-      if (this.title === '编辑') {
-        editPage(this.dialogForm).then(res => {
+      if (this.title === "编辑") {
+        editPage(this.dialogForm).then((res) => {
           if (res.code === 0) {
-            this.$message.success('修改成功!')
-            this.dialogVisible = false
-            this.getList()
+            this.$message.success("修改成功!");
+            this.dialogVisible = false;
+            this.getList();
           }
-        })
+        });
       } else {
         create({
           name: this.dialogForm.name,
           deviceIds: this.dialogForm.deviceIds,
-          type: 1
-        }).then(res => {
+          type: 1,
+        }).then((res) => {
           if (res.code === 0) {
-            this.$message.success('新增成功!')
-            this.dialogVisible = false
-            this.getList()
+            this.$message.success("新增成功!");
+            this.dialogVisible = false;
+            this.getList();
           }
-        })
+        });
       }
     },
 
@@ -236,30 +341,35 @@ export default {
     getChange(id, sort) {
       change({
         id: id,
-        sort: sort
-      }).then(res => {
+        sort: sort,
+      }).then((res) => {
         if (res.code === 0) {
-          this.$message.success('修改成功!')
-          this.getPage(this.obj)
+          this.$message.success("修改成功!");
+          this.getPage(this.obj);
         }
-      })
+      });
     },
 
     // 取消
     cancel() {
-      this.dialogVisible = false
-      this.ids = []
-      this.dialogForm = {}
-      this.getList()
+      this.dialogVisible = false;
+      this.ids = [];
+      this.dialogForm = {};
+      this.getList();
     },
 
     // 字典翻译
     typeFormatter(row) {
-      return this.selectDictLabel(this.typeOptions, row.type)
+      return this.selectDictLabel(this.typeOptions, row.type);
     },
     devFormatter(row) {
-      return row.deviceIds ? row.deviceIds.split(',').map(i => this.selectDictLabel(this.allDevOptions, i)).join(',') : ''
-    }
+      return row.deviceIds
+        ? row.deviceIds
+            .split(",")
+            .map((i) => this.selectDictLabel(this.allDevOptions, i))
+            .join(",")
+        : "";
+    },
   },
 };
 </script>

+ 5 - 3
src/views/operation/channels/detail.vue

@@ -1,3 +1,4 @@
+<!-- 多频多台 -->
 <template>
   <div class="app-container">
     <!-- 表单 -->
@@ -142,10 +143,11 @@
 
 <script>
 import {
-changeDetail,
-channelDetail,
-channeledit,
+  changeDetail,
+  channelDetail,
+  channeledit,
 } from "@/api/operation/channels";
+
 import Dialog from "@/components/Dialog/index.vue";
 import { disabledMixin, isFreeMixin, platformMixin } from "@/mixin/index";
 export default {

+ 2 - 1
src/views/operation/channels/index.vue

@@ -1,3 +1,4 @@
+<!-- 多频多台 -->
 <template>
   <div class='app-container'>
     <el-button type="primary" icon="el-icon-plus" size="mini" @click="getDialog()"
@@ -138,7 +139,7 @@
 </template>
 
 <script>
-import { list, dev, submit, edit, detail, change, remove, channels, classSubmit, classEdit, classRemove } from "@/api/operation/channels"
+import { change, channels, classEdit, classRemove, classSubmit, detail, dev, edit, list, remove, submit } from "@/api/operation/channels";
 export default {
   data() {
     return {

+ 3 - 3
src/views/operation/tag/detail.vue

@@ -68,9 +68,9 @@
 </template>
 
 <script>
-import Dialog from '@/components/Dialog/index.vue'
-import { submitThree, detail } from '@/api/operation/tag'
-import { platformMixin, isFreeMixin, audioMixin, disabledMixin } from '@/mixin/index'
+import { detail, submitThree } from '@/api/operation/tag';
+import Dialog from '@/components/Dialog/index.vue';
+import { audioMixin, disabledMixin, isFreeMixin, platformMixin } from '@/mixin/index';
 export default {
   components: {
     Dialog

+ 3 - 2
src/views/operation/tag/index.vue

@@ -1,3 +1,4 @@
+<!-- 标签分类 -->
 <template>
   <div class="app-container">
     <!-- 搜索 -->
@@ -90,8 +91,8 @@
 </template>
 
 <script>
-import { list, submitFirst, submitSecond, detail, change, remove } from '@/api/operation/tag'
-import { disabledMixin } from '@/mixin/index'
+import { change, detail, list, remove, submitFirst, submitSecond } from '@/api/operation/tag';
+import { disabledMixin } from '@/mixin/index';
 export default {
   mixins: [disabledMixin],
   data() {