123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685 |
- <!-- 运营管理 多频多台 -->
- <template>
- <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>{{ item.name }}</span>
- <span v-show="index + 1 !== scope.row.deviceList.length">,</span>
- </span>
- </template>
- </el-table-column>
- <!-- <el-table-column label="序号" align="center" prop="sort" /> -->
- <!-- <el-table-column label="序号" align="center">
- <template slot-scope="scope">
- <div v-if="editData.currentEditIndex !== scope.$index">
- <span style="margin-right: 8px">
- {{ scope.row.indexNum }}
- </span>
- <svg-icon
- icon-class="edit"
- @click.native="handleEditClick(scope.row, scope.$index)"
- />
- </div>
- <el-input
- v-else
- v-model="scope.row.indexNum"
- size="mini"
- style="width: 60px"
- type="number"
- @blur="onNumberBlur(scope.row, scope.$index)"
- @keyup.enter.native="onNumberBlurEnter(scope.row, scope.$index)"
- placeholder="序号"
- ref="numberInput"
- />
- </template>
- </el-table-column> -->
- <!-- <el-table-column label="序号" align="center">
- <template slot-scope="scope">
- <el-button type="text">{{ scope.row.sort }}</el-button>
- <el-button type="text" icon="el-icon-edit" />
- </template>
- </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
- >
- </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-form-item label="频道名称:" prop="name" style="width: 300px">
- <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>
- </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)"
- >
- {{ 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)"
- >
- {{ 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-button>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item>
- <div @click="getInputDialog(item)">编辑</div>
- </el-dropdown-item>
- <el-dropdown-item>
- <div @click="getDelete(item)">删除</div>
- </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
- >
- </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)"
- >
- {{ 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-button>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item>
- <div @click="getInputDialog(item)">编辑</div>
- </el-dropdown-item>
- <el-dropdown-item>
- <div @click="getDelete(item)">删除</div>
- </el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- <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" 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">
- <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"
- />
- </template>
- </el-table-column>
- </el-table>
- <div v-if="!readOnly" slot="footer">
- <el-button @click="getClose">取消</el-button>
- <el-button type="primary" @click="getSubmit">确定</el-button>
- </div>
- </el-dialog>
- <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>
- </el-form>
- <div slot="footer">
- <el-button @click="getInputClose">取消</el-button>
- <el-button type="primary" @click="getInputSubmit">确定</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import {
- change,
- channels,
- classEdit,
- classRemove,
- classSubmit,
- detail,
- dev,
- edit,
- list,
- remove,
- submit
- } from "@/api/operation/channels";
- import { dialogCallBack } from "@/utils/DialogUtil";
- export default {
- name: "OperationChannels",
- data() {
- return {
- editData: {
- currentEditIndex: -1,
- currentEditSort: 1,
- },
- // 遮罩层
- loading: false,
- // 列表
- tableData: [],
- // 全部设备列表
- allDevOptions: [],
- // 剔除已选的设备列表
- devOptions: [],
- // 弹窗
- dialogVisible: false,
- // 查看
- readOnly: false,
- // 弹窗名称
- title: "新增",
- classTitle: "新增",
- // 弹窗表单
- dialogForm: {
- deviceIds: [],
- },
- row: {},
- // 分类焦点
- active: 0,
- // 分类弹窗
- inputVisible: false,
- // 分类表单
- classForm: {},
- // 分类类型
- type: null,
- // 校验
- rules: {
- name: [
- {
- required: true,
- message: "请输入规则名称",
- trigger: "blur",
- },
- ],
- deviceIds: [
- {
- required: true,
- message: "请选择关联设备",
- trigger: "change",
- },
- ],
- },
- };
- },
- async mounted() {
- await this.getDev(1);
- this.getList();
- },
- methods: {
- // 设备列表
- async getDev(type) {
- await dev(type).then((res) => {
- if (type === 0) {
- this.devOptions = res.data;
- } else {
- this.allDevOptions = res.data;
- }
- });
- },
- // 列表
- getList() {
- this.loading = true;
- list().then((res) => {
- if (res.code === 0) {
- var data = res.data;
- for (var i = 0; i < data.length; i++) {
- data[i].indexNum = i + 1;
- }
- this.tableData = data;
- this.loading = false;
- }
- });
- },
- // 删除频道规则
- getRemove(row) {
- var that = this;
- dialogCallBack(that, function () {
- that.$confirm(`是否删除${row.name}?`, "提示:").then(() => {
- remove(row.id).then((res) => {
- if (res.code === 0) {
- that.$message.success("删除成功!");
- that.getList();
- }
- });
- });
- });
- },
- // 点击编辑图标显示输入框
- handleEditClick(row, index) {
- this.editData.currentEditIndex = index;
- this.editData.currentEditSort = row.indexNum;
- this.$nextTick(() => {
- this.$refs.numberInput.focus();
- });
- },
- onNumberBlurEnter(row, index) {
- this.editData.currentEditIndex = -1;
- },
- // 输入框失去焦点时隐藏
- onNumberBlur(row, index) {
- var newSort = row.indexNum;
- if (newSort === "") {
- row.indexNum = this.editData.currentEditSort;
- this.$message.warning("序号不能为空");
- return;
- }
- if (newSort <= 0) {
- row.indexNum = this.editData.currentEditSort;
- this.$message.warning("序号必须大于0");
- return;
- }
- if (newSort === this.editData.currentEditSort) {
- this.editData.currentEditIndex = -1;
- return;
- }
- ///删除第index个元素
- this.tableData.splice(index, 1);
- this.tableData.splice(newSort - 1, 0, row);
- for (var i = 0; i < this.tableData.length; i++) {
- this.tableData[i].indexNum = i + 1;
- }
- this.editData.currentEditIndex = -1;
- // channeledit(this.tableData).then((res) => {
- // console.log("编辑成功:", JSON.stringify(res));
- // if (res.code === 0) {
- // this.$message.success("编辑成功!");
- // this.getList();
- // }
- // });
- // 检查序号是否重复
- // const isDuplicate = this.tableData.some(
- // (item, i) => i !== index && item.sortIndex === newSort
- // );
- // if (isDuplicate) {
- // this.$message.warning("序号已存在");
- // } else {
- // // 更新到tableData
- // this.$set(this.tableData, index, {
- // ...row,
- // sortIndex: newSort,
- // });
- // console.log(
- // "序号修改成功:",
- // newSort,
- // "row.sortIndex",
- // row.sortIndex,
- // "this.tableData",
- // this.tableData[index].sortIndex
- // );
- // 隐藏编辑框
- // this.editData.currentEditIndex = -1;
- // }
- },
- // 弹窗
- async getDialog(row, boolean) {
- 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();
- }
- },
- //弹窗 详情
- getDetail() {
- detail(this.row.id).then((res) => {
- if (res.code === 0) {
- this.dialogForm = res.data;
- this.dialogForm.deviceIds = res.data.deviceIds.split(",");
- }
- });
- },
- //弹窗 获取焦点
- getActive(item) {
- this.active = item.sort;
- this.getChannels(item.channelTypeId);
- },
- //弹窗 12频道
- getChannels(id) {
- channels(id).then((res) => {
- if (res.code === 0) {
- this.dialogForm.defaultList = res.data;
- }
- });
- },
- // 打开分类弹窗
- getInputDialog(item) {
- this.inputVisible = true;
- this.classTitle = "编辑";
- this.classForm = JSON.parse(JSON.stringify(item));
- },
- getCreateDialog(type) {
- this.inputVisible = true;
- this.classTitle = "新增";
- this.type = type;
- },
- // 关闭分类表单
- getInputClose() {
- 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) => {
- if (res.code === 0) {
- this.getInputClose();
- this.$message.success("编辑成功!");
- this.getDetail();
- }
- });
- } else {
- classSubmit(
- this.classForm.channelTypeName,
- this.type,
- this.dialogForm.id
- ).then((res) => {
- if (res.code === 0) {
- this.getInputClose();
- this.$message.success("新增成功!");
- this.getDetail();
- }
- });
- }
- } else {
- return false;
- }
- });
- },
- // 提交
- getSubmit() {
- this.$refs.dialogForm.validate((valid) => {
- if (valid) {
- this.dialogForm.deviceIds = this.dialogForm.deviceIds.join(",");
- if (this.dialogForm.id) {
- edit(this.dialogForm).then((res) => {
- if (res.code === 0) {
- this.$message.success("编辑成功!");
- this.getClose();
- this.getList();
- }
- });
- } else {
- submit(this.dialogForm).then((res) => {
- if (res.code === 0) {
- this.$message.success("提交成功!");
- this.getClose();
- this.getList();
- }
- });
- }
- } else {
- return false;
- }
- });
- },
- // 取消
- getClose() {
- this.dialogVisible = false;
- this.dialogForm = {};
- this.$refs.dialogForm.resetFields();
- },
- // 删除
- getDelete(item) {
- var that = this;
- dialogCallBack(that, function () {
- that
- .$confirm(`是否删除${item.channelTypeName}?`, "提示:")
- .then(() => {
- classRemove(item.channelTypeId).then((res) => {
- if (res.code === 0) {
- that.$message.success("删除成功!");
- that.getDetail();
- }
- });
- })
- .catch(() => {});
- });
- },
- // 12频道详情
- getRouter(e, boolean) {
- this.$router.push({
- path: `/operation/channels/detail`,
- query: {
- channelId: e.row.id,
- audioType: e.row.channelType,
- index: e.$index,
- boolean: boolean,
- },
- });
- },
- // 排序
- getChange(row, sort) {
- change({
- id: row.id,
- sort: sort,
- }).then((res) => {
- if (res.code === 0) {
- this.$message.success("修改成功!");
- this.getChannels(row.templateCategoryId);
- }
- });
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .classList {
- ::v-deep .el-button {
- margin: 0 10px 10px 0;
- }
- }
- </style>
|