Forráskód Böngészése

feat: 点击多频多台查看\编辑,页面显示音乐分类,其实内容为广播分类内容

Damon 11 hónapja
szülő
commit
b52d968206
1 módosított fájl, 317 hozzáadás és 156 törlés
  1. 317 156
      src/views/operation/channels/index.vue

+ 317 - 156
src/views/operation/channels/index.vue

@@ -1,13 +1,22 @@
 <!-- 多频多台 -->
 <template>
-  <div class='app-container'>
-    <el-button type="primary" icon="el-icon-plus" size="mini" @click="getDialog()"
-      v-hasPermi="['operation:channels:add']">新增多频多台</el-button>
+  <div class="app-container">
+    <el-button
+      type="primary"
+      icon="el-icon-plus"
+      size="mini"
+      @click="getDialog()"
+      v-hasPermi="['operation:channels:add']"
+      >新增多频多台</el-button
+    >
     <el-table :data="tableData" v-loading="loading">
       <el-table-column label="频道名称" align="center" prop="name" />
       <el-table-column label="设备" align="center">
         <template slot-scope="scope">
-          <span v-for="(item, index) in scope.row.deviceList" :key="item.clientTypeId">
+          <span
+            v-for="(item, index) in scope.row.deviceList"
+            :key="item.clientTypeId"
+          >
             <span>{{ item.name }}</span>
             <span v-show="index + 1 !== scope.row.deviceList.length">,</span>
           </span>
@@ -15,47 +24,102 @@
       </el-table-column>
       <el-table-column label="操作" align="center">
         <template slot-scope="scope">
-          <el-button type="text" @click="getDialog(scope.row, true)">查看</el-button>
-          <el-button type="text" @click="getDialog(scope.row)" v-hasPermi="['operation:channels:edit']">编辑</el-button>
-          <el-button type="delete" @click="getRemove(scope.row)"
-            v-hasPermi="['operation:channels:delete']">删除</el-button>
+          <el-button type="text" @click="getDialog(scope.row, true)"
+            >查看</el-button
+          >
+          <el-button
+            type="text"
+            @click="getDialog(scope.row)"
+            v-hasPermi="['operation:channels:edit']"
+            >编辑</el-button
+          >
+          <el-button
+            type="delete"
+            @click="getRemove(scope.row)"
+            v-hasPermi="['operation:channels:delete']"
+            >删除</el-button
+          >
         </template>
       </el-table-column>
     </el-table>
 
     <!-- 弹窗 -->
-    <el-dialog :visible.sync="dialogVisible" :title="title" width="1000px" :before-close="getClose">
-      <el-form :model="dialogForm" ref="dialogForm" :rules="rules" label-width="auto">
+    <el-dialog
+      :visible.sync="dialogVisible"
+      :title="title"
+      width="1000px"
+      :before-close="getClose"
+    >
+      <el-form
+        :model="dialogForm"
+        ref="dialogForm"
+        :rules="rules"
+        label-width="auto"
+      >
         <el-form-item label="频道名称:" prop="name" style="width: 300px">
-          <el-input v-model="dialogForm.name" placeholder="请输入规则名称" :disabled="readOnly" />
+          <el-input
+            v-model="dialogForm.name"
+            placeholder="请输入规则名称"
+            :disabled="readOnly"
+          />
         </el-form-item>
 
         <el-form-item label="关联设备:" prop="deviceIds">
-          <el-select v-model="dialogForm.deviceIds" filterable multiple placeholder="请选择关联设备" :disabled="readOnly">
-            <el-option v-for="item in devOptions" :key="item.clientTypeId" :value="item.clientTypeId"
-              :label="item.name" />
+          <el-select
+            v-model="dialogForm.deviceIds"
+            filterable
+            multiple
+            placeholder="请选择关联设备"
+            :disabled="readOnly"
+          >
+            <el-option
+              v-for="item in devOptions"
+              :key="item.clientTypeId"
+              :value="item.clientTypeId"
+              :label="item.name"
+            />
           </el-select>
         </el-form-item>
 
         <el-form-item v-if="dialogForm.id" label="个人频道分类:">
           <div class="classList" v-if="readOnly">
-            <el-button v-for="item in dialogForm.personalChannelList" :key="item.channelTypeId"
-              :type="active === item.sort ? 'primary' : ''" size="small" @click="getActive(item)">
+            <el-button
+              v-for="item in dialogForm.personalChannelList"
+              :key="item.channelTypeId"
+              :type="active === item.sort ? 'primary' : ''"
+              size="small"
+              @click="getActive(item)"
+            >
               {{ item.channelTypeName }}
             </el-button>
           </div>
           <div class="classList" v-else>
             <!-- isFix:0 不可以编辑删除 -->
-            <el-button :type="active === item.sort ? 'primary' : ''"
-              v-for="item in dialogForm.personalChannelList.filter(i => i.isFix === 0)" :key="item.channelTypeId"
-              size="small" @click="getActive(item)">
+            <el-button
+              :type="active === item.sort ? 'primary' : ''"
+              v-for="item in dialogForm.personalChannelList.filter(
+                (i) => i.isFix === 0
+              )"
+              :key="item.channelTypeId"
+              size="small"
+              @click="getActive(item)"
+            >
               {{ item.channelTypeName }}
             </el-button>
             <!-- isFix:1 可以编辑删除 -->
-            <el-dropdown v-for="item in dialogForm.personalChannelList.filter(i => i.isFix === 1)"
-              :key="item.channelTypeId">
-              <el-button :type="active === item.sort ? 'primary' : ''" size="small" @click="getActive(item)">
-                {{ item.channelTypeName }}<i class="el-icon-arrow-down" style="margin-left: 10px;" />
+            <el-dropdown
+              v-for="item in dialogForm.personalChannelList.filter(
+                (i) => i.isFix === 1
+              )"
+              :key="item.channelTypeId"
+            >
+              <el-button
+                :type="active === item.sort ? 'primary' : ''"
+                size="small"
+                @click="getActive(item)"
+              >
+                {{ item.channelTypeName
+                }}<i class="el-icon-arrow-down" style="margin-left: 10px" />
               </el-button>
               <el-dropdown-menu slot="dropdown">
                 <el-dropdown-item>
@@ -66,22 +130,40 @@
                 </el-dropdown-item>
               </el-dropdown-menu>
             </el-dropdown>
-            <el-button v-if="dialogForm.personalChannelList.length < 9" icon="el-icon-plus" size="small"
-              @click="getCreateDialog(0)">新增</el-button>
+            <el-button
+              v-if="dialogForm.personalChannelList.length < 9"
+              icon="el-icon-plus"
+              size="small"
+              @click="getCreateDialog(0)"
+              >新增</el-button
+            >
           </div>
         </el-form-item>
 
         <el-form-item v-if="dialogForm.id" label="其他频道分类:">
           <div class="classList" v-if="readOnly">
-            <el-button v-for="item in dialogForm.otherChannelList" :key="item.channelTypeId"
-              :type="active === item.sort ? 'primary' : ''" size="small" @click="getActive(item)">
+            <el-button
+              v-for="item in dialogForm.otherChannelList"
+              :key="item.channelTypeId"
+              :type="active === item.sort ? 'primary' : ''"
+              size="small"
+              @click="getActive(item)"
+            >
               {{ item.channelTypeName }}
             </el-button>
           </div>
           <div class="classList" v-else>
-            <el-dropdown v-for="item in dialogForm.otherChannelList" :key="item.channelTypeId">
-              <el-button :type="active === item.sort ? 'primary' : ''" size="small" @click="getActive(item)">
-                {{ item.channelTypeName }}<i class="el-icon-arrow-down" style="margin-left: 10px;" />
+            <el-dropdown
+              v-for="item in dialogForm.otherChannelList"
+              :key="item.channelTypeId"
+            >
+              <el-button
+                :type="active === item.sort ? 'primary' : ''"
+                size="small"
+                @click="getActive(item)"
+              >
+                {{ item.channelTypeName
+                }}<i class="el-icon-arrow-down" style="margin-left: 10px" />
               </el-button>
               <el-dropdown-menu slot="dropdown">
                 <el-dropdown-item>
@@ -92,28 +174,65 @@
                 </el-dropdown-item>
               </el-dropdown-menu>
             </el-dropdown>
-            <el-button icon="el-icon-plus" size="small" @click="getCreateDialog(1)">新增</el-button>
+            <el-button
+              icon="el-icon-plus"
+              size="small"
+              @click="getCreateDialog(1)"
+              >新增</el-button
+            >
           </div>
         </el-form-item>
       </el-form>
 
       <el-table v-show="dialogForm.id" :data="dialogForm.defaultList">
-        <el-table-column label="频道号" align="center" prop="channelId" width="75px" />
-        <el-table-column label="频道名称" align="center" prop="aliasName" show-overflow-tooltip />
+        <el-table-column
+          label="频道号"
+          align="center"
+          prop="channelId"
+          width="75px"
+        />
+        <el-table-column
+          label="频道名称"
+          align="center"
+          prop="aliasName"
+          show-overflow-tooltip
+        />
         <el-table-column label="频道封面" align="center" width="100px">
           <template slot-scope="scope">
             <el-image :src="scope.row.pic" />
           </template>
         </el-table-column>
-        <el-table-column label="频道简介" align="center" prop="description" show-overflow-tooltip />
+        <el-table-column
+          label="频道简介"
+          align="center"
+          prop="description"
+          show-overflow-tooltip
+        />
         <el-table-column label="操作" align="center">
           <template slot-scope="scope">
-            <el-button type="text" @click="getRouter(scope, true)">查看</el-button>
-            <el-button type="text" @click="getRouter(scope)" :disabled="readOnly">编辑</el-button>
-            <el-button v-if="scope.row.sort > 3" type="text" icon="el-icon-caret-top"
-              @click="getChange(scope.row, scope.row.sort - 1)" :disabled="readOnly" />
-            <el-button v-if="scope.row.sort > 2 && scope.row.sort < 12" type="text" icon="el-icon-caret-bottom"
-              @click="getChange(scope.row, scope.row.sort + 1)" :disabled="readOnly" />
+            <el-button type="text" @click="getRouter(scope, true)"
+              >查看</el-button
+            >
+            <el-button
+              type="text"
+              @click="getRouter(scope)"
+              :disabled="readOnly"
+              >编辑</el-button
+            >
+            <el-button
+              v-if="scope.row.sort > 3"
+              type="text"
+              icon="el-icon-caret-top"
+              @click="getChange(scope.row, scope.row.sort - 1)"
+              :disabled="readOnly"
+            />
+            <el-button
+              v-if="scope.row.sort > 2 && scope.row.sort < 12"
+              type="text"
+              icon="el-icon-caret-bottom"
+              @click="getChange(scope.row, scope.row.sort + 1)"
+              :disabled="readOnly"
+            />
           </template>
         </el-table-column>
       </el-table>
@@ -123,11 +242,25 @@
       </div>
     </el-dialog>
 
-    <el-dialog :visible.sync="inputVisible" :title="classTitle" width="500px" :before-close="getInputClose">
+    <el-dialog
+      :visible.sync="inputVisible"
+      :title="classTitle"
+      width="500px"
+      :before-close="getInputClose"
+    >
       <el-form :model="classForm" ref="classForm" label-width="auto">
-        <el-form-item label="分类名称:" prop="channelTypeName"
-          :rules="[{ required: true, message: '请输入分类名称', trigger: 'blur' }, { max: 6, message: '不可超过6个字符', trigger: 'blur' }]">
-          <el-input v-model="classForm.channelTypeName" placeholder="请输入分类名称" />
+        <el-form-item
+          label="分类名称:"
+          prop="channelTypeName"
+          :rules="[
+            { required: true, message: '请输入分类名称', trigger: 'blur' },
+            { max: 6, message: '不可超过6个字符', trigger: 'blur' },
+          ]"
+        >
+          <el-input
+            v-model="classForm.channelTypeName"
+            placeholder="请输入分类名称"
+          />
         </el-form-item>
       </el-form>
       <div slot="footer">
@@ -139,7 +272,19 @@
 </template>
 
 <script>
-import { change, channels, classEdit, classRemove, classSubmit, detail, dev, edit, list, remove, submit } from "@/api/operation/channels";
+import {
+change,
+channels,
+classEdit,
+classRemove,
+classSubmit,
+detail,
+dev,
+edit,
+list,
+remove,
+submit,
+} from "@/api/operation/channels";
 export default {
   data() {
     return {
@@ -156,15 +301,16 @@ export default {
       // 查看
       readOnly: false,
       // 弹窗名称
-      title: '新增',
-      classTitle: '新增',
+      title: "新增",
+      classTitle: "新增",
       // 弹窗表单
       dialogForm: {
-        deviceIds: []
+        deviceIds: [],
       },
       row: {},
+
       // 分类焦点
-      active: 1,
+      active: 0,
       // 分类弹窗
       inputVisible: false,
       // 分类表单
@@ -173,183 +319,199 @@ export default {
       type: null,
       // 校验
       rules: {
-        name: [{
-          required: true, message: '请输入规则名称', trigger: 'blur'
-        }],
-        deviceIds: [{
-          required: true, message: '请选择关联设备', trigger: 'change'
-        }]
-      }
-    }
+        name: [
+          {
+            required: true,
+            message: "请输入规则名称",
+            trigger: "blur",
+          },
+        ],
+        deviceIds: [
+          {
+            required: true,
+            message: "请选择关联设备",
+            trigger: "change",
+          },
+        ],
+      },
+    };
   },
   async mounted() {
-    await this.getDev(1)
-    this.getList()
+    await this.getDev(1);
+    this.getList();
   },
   methods: {
-    // 列表
-    getList() {
-      this.loading = true
-      list().then(res => {
-        if (res.code === 0) {
-          this.tableData = res.data
-          this.loading = false
-        }
-      })
-    },
-
     // 设备列表
     async getDev(type) {
-      await dev(type).then(res => {
+      await dev(type).then((res) => {
         if (type === 0) {
-          this.devOptions = res.data
+          this.devOptions = res.data;
         } else {
-          this.allDevOptions = res.data
+          this.allDevOptions = res.data;
+        }
+      });
+    },
+
+    // 列表
+    getList() {
+      this.loading = true;
+      list().then((res) => {
+        if (res.code === 0) {
+          this.tableData = res.data;
+          this.loading = false;
         }
-      })
+      });
     },
 
     // 删除频道规则
     getRemove(row) {
-      this.$confirm(`是否删除${row.name}?`, '提示').then(() => {
-        remove(row.id).then(res => {
+      this.$confirm(`是否删除${row.name}?`, "提示").then(() => {
+        remove(row.id).then((res) => {
           if (res.code === 0) {
-            this.$message.success('删除成功!')
-            this.getList()
+            this.$message.success("删除成功!");
+            this.getList();
           }
-        })
-      })
+        });
+      });
     },
 
     // 弹窗
     async getDialog(row, boolean) {
-      this.dialogVisible = true
-      this.readOnly = boolean
-      await this.getDev(0)
+      this.dialogVisible = true;
+      this.readOnly = boolean;
+      await this.getDev(0);
       if (row !== undefined) {
-        this.row = row
-        this.devOptions.unshift.apply(this.devOptions, this.row.deviceList)
-        this.getDetail()
+        this.row = row;
+        this.devOptions.unshift.apply(this.devOptions, this.row.deviceList);
+        this.getDetail();
       }
     },
 
-    // 详情
+    // console.log("列表弹窗展示===00===" + JSON.stringify(res));
+    //弹窗 详情
     getDetail() {
-      detail(this.row.id).then(res => {
+      detail(this.row.id).then((res) => {
         if (res.code === 0) {
-          this.active = 1
-          this.dialogForm = res.data
-          this.dialogForm.deviceIds = res.data.deviceIds.split(',')
+          this.dialogForm = res.data;
+          this.dialogForm.deviceIds = res.data.deviceIds.split(",");
         }
-      })
+      });
     },
 
-    // 获取焦点
+    //弹窗 获取焦点
     getActive(item) {
-      this.active = item.sort
-      this.getChannels(item.channelTypeId)
+      this.active = item.sort;
+      this.getChannels(item.channelTypeId);
     },
 
-    // 12频道
+    //弹窗 12频道
     getChannels(id) {
-      channels(id).then(res => {
+      channels(id).then((res) => {
         if (res.code === 0) {
-          this.dialogForm.defaultList = res.data
+          this.dialogForm.defaultList = res.data;
         }
-      })
+      });
     },
 
     // 打开分类弹窗
     getInputDialog(item) {
-      this.inputVisible = true
-      this.classTitle = '编辑'
-      this.classForm = JSON.parse(JSON.stringify(item))
+      this.inputVisible = true;
+      this.classTitle = "编辑";
+      this.classForm = JSON.parse(JSON.stringify(item));
     },
     getCreateDialog(type) {
-      this.inputVisible = true
-      this.classTitle = '新增'
-      this.type = type
+      this.inputVisible = true;
+      this.classTitle = "新增";
+      this.type = type;
     },
     // 关闭分类表单
     getInputClose() {
-      this.inputVisible = false
-      this.type = null
-      this.classForm = {}
-      this.$refs.classForm.resetFields()
+      this.inputVisible = false;
+      this.type = null;
+      this.classForm = {};
+      this.$refs.classForm.resetFields();
     },
     // 提交分类表单
     getInputSubmit() {
       this.$refs.classForm.validate((valid) => {
         if (valid) {
           if (this.type === null) {
-            classEdit(this.classForm.channelTypeName, this.classForm.channelTypeId).then(res => {
+            classEdit(
+              this.classForm.channelTypeName,
+              this.classForm.channelTypeId
+            ).then((res) => {
               if (res.code === 0) {
-                this.getInputClose()
-                this.$message.success('编辑成功!')
-                this.getDetail()
+                this.getInputClose();
+                this.$message.success("编辑成功!");
+                this.getDetail();
               }
-            })
+            });
           } else {
-            classSubmit(this.classForm.channelTypeName, this.type, this.dialogForm.id).then(res => {
+            classSubmit(
+              this.classForm.channelTypeName,
+              this.type,
+              this.dialogForm.id
+            ).then((res) => {
               if (res.code === 0) {
-                this.getInputClose()
-                this.$message.success('新增成功!')
-                this.getDetail()
+                this.getInputClose();
+                this.$message.success("新增成功!");
+                this.getDetail();
               }
-            })
+            });
           }
         } else {
-          return false
+          return false;
         }
-      })
+      });
     },
 
     // 提交
     getSubmit() {
       this.$refs.dialogForm.validate((valid) => {
         if (valid) {
-          this.dialogForm.deviceIds = this.dialogForm.deviceIds.join(',')
+          this.dialogForm.deviceIds = this.dialogForm.deviceIds.join(",");
           if (this.dialogForm.id) {
-            edit(this.dialogForm).then(res => {
+            edit(this.dialogForm).then((res) => {
               if (res.code === 0) {
-                this.$message.success('编辑成功!')
-                this.getClose()
-                this.getList()
+                this.$message.success("编辑成功!");
+                this.getClose();
+                this.getList();
               }
-            })
+            });
           } else {
-            submit(this.dialogForm).then(res => {
+            submit(this.dialogForm).then((res) => {
               if (res.code === 0) {
-                this.$message.success('提交成功!')
-                this.getClose()
-                this.getList()
+                this.$message.success("提交成功!");
+                this.getClose();
+                this.getList();
               }
-            })
+            });
           }
-
         } else {
-          return false
+          return false;
         }
-      })
+      });
     },
 
     // 取消
     getClose() {
-      this.dialogVisible = false
-      this.dialogForm = {}
-      this.$refs.dialogForm.resetFields()
+      this.dialogVisible = false;
+      this.dialogForm = {};
+      this.$refs.dialogForm.resetFields();
     },
 
     // 删除
     getDelete(item) {
-      this.$confirm(`是否删除${item.channelTypeName}?`, '提示').then(() => {
-        classRemove(item.channelTypeId).then(res => {
-          if (res.code === 0) {
-            this.$message.success('删除成功!')
-            this.getDetail()
-          }
+      this.$confirm(`是否删除${item.channelTypeName}?`, "提示")
+        .then(() => {
+          classRemove(item.channelTypeId).then((res) => {
+            if (res.code === 0) {
+              this.$message.success("删除成功!");
+              this.getDetail();
+            }
+          });
         })
-      }).catch(() => { })
+        .catch(() => {});
     },
 
     // 12频道详情
@@ -360,26 +522,25 @@ export default {
           channelId: e.row.id,
           audioType: e.row.channelType,
           index: e.$index,
-          boolean: boolean
-        }
-      })
+          boolean: boolean,
+        },
+      });
     },
 
     // 排序
     getChange(row, sort) {
       change({
         id: row.id,
-        sort: sort
-      }).then(res => {
+        sort: sort,
+      }).then((res) => {
         if (res.code === 0) {
-          this.$message.success('修改成功!')
-          this.getChannels(row.templateCategoryId)
+          this.$message.success("修改成功!");
+          this.getChannels(row.templateCategoryId);
         }
-      })
+      });
     },
-
-  }
-}
+  },
+};
 </script>
 
 <style lang="scss" scoped>