123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 |
- <template>
- <div class="cameraBrand">
- <!-- 查询 -->
- <query-conditions :formItems="searchList" @getQueryParams="handleQuery"></query-conditions>
- <!-- 表格 -->
- <new-table :height="600" :title="title" :listData="brandLists" :tableItems="tableItems" :shows="tableShows" @selectionChange="selectionChange">
- <template #right>
- <div>
- <el-button size="mini" type="primary" v-if="hasPerm('brand:add')" @click="dialogVisible = true">添加品牌</el-button>
- <el-button size="mini" type="danger" v-if="hasPerm('brand:del')" @click="delAll">批量删除</el-button>
- </div>
- </template>
- <template #streamType="scope">
- <div>
- <span v-if="scope.row.streamType === 0">主码流</span>
- <span v-else>辅码流</span>
- </div>
- </template>
- <template #handler="scope">
- <el-button size="mini" @click="edit(scope.row)" v-if="hasPerm('brand:edit')" style="margin-right: 10px">编辑</el-button>
- <el-popconfirm
- title=" 确定要删除这个区域吗?"
- @confirm="del(scope.row)"
- >
- <el-button type="danger" v-if="hasPerm('brand:del')" size="mini" slot="reference">删除</el-button>
- </el-popconfirm>
- </template>
- </new-table>
- <table-footer
- :totals="total"
- :size="pageSize"
- @sizeChange="sizeChange"
- @pageChange="pageChange"></table-footer>
- <!-- 新增编辑 -->
- <el-dialog
- :title="showType ? '编 辑' : '新 增'"
- :visible.sync="dialogVisible"
- width="30%">
- <div>
- <el-form ref="form" :model="form" :rules="rules" label-width="80px" size="mini">
- <el-form-item label="品牌名称" prop="brandName">
- <el-input v-model="form.brandName"></el-input>
- </el-form-item>
- <el-form-item label="主码流" prop="mainStream">
- <el-input v-model="form.mainStream"></el-input>
- </el-form-item>
- <el-form-item label="副码流" prop="assistStream">
- <el-input v-model="form.assistStream"></el-input>
- </el-form-item>
- <el-form-item label="所用码流" prop="streamType">
- <el-select v-model="form.streamType">
- <el-option v-for="item in options" :label="item.name" :value="item.id" :key="item.id"></el-option>
- </el-select>
- </el-form-item>
- <!-- <el-form-item label="主码流">-->
- <!-- <el-input v-model="form.mainStream"></el-input>-->
- <!-- </el-form-item>-->
- </el-form>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="reset">取 消</el-button>
- <el-button type="primary" @click="onSubmit('form')">{{showType ? '更 新' : '新 增'}}</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import QueryConditions from "@/components/bioSafety/QueryConditions";
- import NewTable from "@/components/newTable/NewTable";
- import TableFooter from "@/components/TableFooter";
- import {brandList, addBarand, delBarand, editBarand } from '../../utils/api.js';
- import {arrToIds} from "@/utils";
- export default {
- name: "CameraBrand",
- components: {
- QueryConditions,
- NewTable,
- TableFooter
- },
- data() {
- return {
- searchList: [
- {
- type: 'input',
- label: '品牌搜索:',
- placeholder: '请输入品牌',
- field: 'keyWord'
- },
- ],
- brandLists: [],
- title: '摄像头品牌列表',
- tableItems: [
- {
- prop: 'brandName',
- label: '品牌名称',
- minWidth: '150',
- slotName: 'brandName'
- },
- {
- prop: 'mainStream',
- label: '主码流',
- minWidth: '150',
- slotName: 'mainStream'
- },
- {
- prop: 'assistStream',
- label: '副码流',
- minWidth: '150',
- slotName: 'assistStream'
- },
- {
- prop: 'streamType',
- label: '所用码流',
- minWidth: '150',
- slotName: 'streamType'
- },
- {
- label: '操作',
- minWidth: '150',
- slotName: 'handler'
- }
- ],
- tableShows: {
- showIndex: false,
- showSelect: true
- },
- pageNum: 1,
- pageSize: 20,
- total: 0,
- keyWord: '',
- form: {
- brandName: '',
- mainStream: '',
- assistStream: '',
- streamType: 0,
- },
- rules: {
- brandName: [
- { required: true, message: '品牌名称不能为空', trigger: 'blur' }
- ],
- mainStream: [
- { required: true, message: '主码流不能为空', trigger: 'blur' }
- ],
- assistStream: [
- { required: true, message: '副码流不能为空', trigger: 'blur' }
- ],
- streamType: [
- { required: true, message: '所用码流不能为空', trigger: 'change' }
- ]
- },
- options: [
- {
- id: 0,
- name: '主码流'
- },
- {
- id: 1,
- name: '辅码流'
- }
- ],
- dialogVisible: false,
- showType: false,
- selectList: []
- }
- },
- methods: {
- // 修改size
- sizeChange(val) {
- this.pageSize = val;
- this.init();
- },
- // 修改页数
- pageChange(val) {
- this.pageNum= val;
- this.init();
- },
- handleQuery(data) {
- this.keyWord = data.keyWord;
- this.pageNum = 1;
- this.init()
- },
- init() {
- let params = {
- current: this.pageNum,
- size: this.pageSize,
- brandName: this.keyWord
- }
- brandList(params).then(res => {
- if(res.code === 10000) {
- this.brandLists = res.data.records;
- this.total = res.data.total;
- }
- })
- },
- edit(row) {
- this.form = {
- id: row.id,
- brandName: row.brandName,
- mainStream: row.mainStream,
- assistStream: row.assistStream,
- streamType: row.streamType,
- }
- this.dialogVisible = true;
- this.showType = true;
- },
- // 批量选择
- selectionChange(rows) {
- this.selectList = rows;
- },
- // 批量删除
- delAll() {
- if(this.selectList.length > 0) {
- this.$confirm('此操作将永久删除这些品牌,是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- let ids = arrToIds(this.selectList);
- let params = {
- ids: ids
- }
- delBarand(params).then(res => {
- if(res.code === 10000) {
- this.init();
- this.$message.success(res.message)
- } else {
- this.$message.error(res.message)
- }
- })
- }).catch(() => {
- this.$message({
- type: 'info',
- message: '已取消删除'
- });
- })
- // delArea()
- } else {
- this.$message.error('请勾选需要删除的区域');
- return;
- }
- },
- onSubmit(formName) {
- this.$refs[formName].validate((valid) => {
- if (valid) {
- if (this.showType) {
- // 编辑
- let params = {
- id: this.form.id,
- brandName: this.form.brandName,
- mainStream: this.form.mainStream,
- assistStream: this.form.assistStream,
- streamType: this.form.streamType,
- }
- editBarand(params).then(res => {
- this.reset()
- if(res.code === 10000) {
- this.init();
- this.$message.success(res.message)
- } else {
- this.$message.error(res.message)
- }
- })
- } else {
- // 新增
- let params = {
- brandName: this.form.brandName,
- mainStream: this.form.mainStream,
- assistStream: this.form.assistStream,
- streamType: this.form.streamType
- }
- addBarand(params).then(res => {
- this.reset();
- if(res.code === 10000) {
- this.init();
- this.$message.success(res.message);
- } else {
- this.$message.error(res.message)
- }
- })
- }
- } else {
- console.log('error submit!!');
- return false;
- }
- })
- },
- reset() {
- this.showType = false;
- this.dialogVisible = false;
- this.form = {
- brandName: '',
- mainStream: '',
- assistStream: '',
- streamType: 0,
- }
- },
- del(row) {
- let params = {
- ids: row.id
- }
- delBarand(params).then(res =>{
- if(res.code === 10000) {
- this.init()
- this.$message.success(res.message)
- } else {
- this.$message.error('删除失败')
- }
- })
- }
- },
- mounted() {
- this.init()
- }
- }
- </script>
- <style scoped>
- .cameraBrand {
- width: 100%;
- height: 100%;
- box-sizing: border-box;
- padding: 20px;
- }
- </style>
|