Files
dvcp_v2_webapp/packages/conv/AppDeviceConfig/components/videoList.vue

225 lines
7.8 KiB
Vue
Raw Normal View History

2022-06-28 10:40:13 +08:00
<template>
<ai-list class="videoList" isTabs>
<template slot="content">
<ai-search-bar bottomBorder>
<template #left>
2022-06-28 14:20:35 +08:00
<el-button type="primary" icon="iconfont iconAdd" size="small" @click="add('添加设备配置', {})">添加</el-button>
2022-06-28 10:40:13 +08:00
<el-button icon="el-icon-delete" class="delete-btn del-btn-list" :disabled="!Boolean(ids.length)" @click="remove(ids)">删除</el-button>
</template>
2022-06-28 16:13:03 +08:00
<template #right>
2022-06-28 15:08:13 +08:00
<el-input
v-model="search.condition"
class="search-input"
size="small"
v-throttle="() => {search.current = 1, getList()}"
placeholder="请输入CorpId"
clearable
@change="getList"
@clear="search.current = 1, search.condition = '', getList()"
suffix-icon="iconfont iconSearch">
</el-input>
</template>
2022-06-28 10:40:13 +08:00
</ai-search-bar>
<ai-table
:tableData="tableData"
:col-configs="colConfigs"
:total="total"
v-loading="loading"
style="margin-top: 16px;"
:current.sync="search.current"
:size.sync="search.size"
2022-06-28 11:53:49 +08:00
@getList="getList"
@selection-change="v=>ids=v.map(e=>e.id)">
2022-06-28 10:40:13 +08:00
<el-table-column slot="options" width="140px" fixed="right" label="操作" align="center">
<template slot-scope="{ row }">
<div class="table-options">
2022-08-10 11:10:36 +08:00
<el-button type="text" @click="add('编辑设备配置', row)">编辑</el-button>
2022-06-28 10:40:13 +08:00
<el-button type="text" @click="refresh(row)">刷新</el-button>
<el-button type="text" @click="remove(row.id)">删除</el-button>
</div>
</template>
</el-table-column>
2022-06-28 18:18:43 +08:00
<el-table-column slot="flag" align="center" label="状态" width="100">
<template v-slot="{ row }">
<el-switch v-model="row.flag" @change="onChange(row)" active-value="1" inactive-value="0"
active-color="#5088FF" inactive-color="#D0D4DC"></el-switch>
</template>
</el-table-column>
2022-06-28 10:40:13 +08:00
</ai-table>
<ai-dialog :title="dialogTitle" :visible.sync="dialog" width="800px" @onConfirm="addForm" @closed="dialogForm={}">
<el-form ref="addForm" :model="dialogForm" :rules="rules" size="small" label-width="160px">
2022-06-28 14:20:35 +08:00
<el-form-item label="CorpId" prop="corpId">
2022-06-28 10:40:13 +08:00
<el-input v-model.trim="dialogForm.corpId" placeholder="请输入..." clearable :maxLength="50"/>
</el-form-item>
2022-06-28 14:20:35 +08:00
<el-form-item required label="状态">
2022-06-28 10:40:13 +08:00
<el-radio-group v-model="dialogForm.flag">
<el-radio :label="0">关闭</el-radio>
<el-radio :label="1">开启</el-radio>
</el-radio-group>
</el-form-item>
2022-06-28 14:20:35 +08:00
<el-form-item label="用户ID">
2022-06-28 10:40:13 +08:00
<el-input v-model.trim="dialogForm.slwUserId" placeholder="请输入..." clearable :maxLength="50" />
</el-form-item>
2022-06-28 14:20:35 +08:00
<el-form-item label="地区编码">
<el-input v-model.trim="dialogForm.slwAreaId" placeholder="请输入..." clearable :maxLength="50" />
</el-form-item>
<el-form-item label="TOKEN">
2022-06-28 10:40:13 +08:00
<el-input v-model.trim="dialogForm.slwToken" placeholder="请输入..." clearable :maxLength="50" />
</el-form-item>
<el-form-item label="大喇叭账号">
<el-input v-model.trim="dialogForm.dlbName" placeholder="请输入..." clearable :maxLength="50" />
</el-form-item>
<el-form-item label="大喇叭密码">
<el-input v-model.trim="dialogForm.dlbPwd" placeholder="请输入..." clearable :maxLength="50" />
</el-form-item>
<el-form-item label="大喇叭Token">
<el-input v-model.trim="dialogForm.dlbToken" placeholder="请输入..." clearable :maxLength="50" />
</el-form-item>
</el-form>
</ai-dialog>
</template>
</ai-list>
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'eyeList',
props: {
instance: Function,
dict: Object,
areaId: String
},
data () {
return {
search: {
current: 1,
2022-06-28 15:08:13 +08:00
condition: '',
2022-06-28 10:40:13 +08:00
size: 10,
},
ids: [],
tableData: [],
total: 0,
loading: false,
dialog: false,
dialogTitle: '',
dialogForm: {}
}
},
computed: {
...mapState(['user']),
param () {
return this.search
},
rules() {
return {
2022-06-28 14:20:35 +08:00
corpId: [{required: true, message: "请输入CorpId"}],
2022-06-28 10:40:13 +08:00
}
},
colConfigs() {
return [
{type: "selection"},
2022-06-28 14:42:51 +08:00
{ prop: 'corpId', label: 'CorpId', fixed: 'left', width: 220 },
2022-06-28 18:18:43 +08:00
{ slot: 'flag', align: 'center', label: '状态', fixed: 'left', width: 120 },
2022-06-28 14:42:51 +08:00
{ prop: 'slwUserId', align: 'center', label: '用户ID', width: 180 },
{ prop: 'slwAreaId', align: 'center', label: '地区编码', width: 180 },
{ prop: 'slwToken', align: 'center', label: 'TOKEN', width: 220 },
{ prop: 'dlbName', align: 'center', label: '大喇叭账号', width: 140 },
{ prop: 'dlbPwd', align: 'center', label: '大喇叭密码', width: 140 },
{ prop: 'dlbToken', align: 'center', label: '大喇叭Token', width: 180 },
{ prop: 'createTime', align: 'center', label: '创建时间', width: 180 },
2022-06-28 10:40:13 +08:00
{ slot: 'options'},
]
}
},
created () {
this.getList()
},
methods: {
getListInit() {
2022-08-10 11:10:36 +08:00
this.search.current = 1
2022-06-28 10:40:13 +08:00
this.getList()
},
getList () {
this.instance.post(`/app/appzyaccountconfig/list`, null, {
params: {
...this.search,
2022-06-28 11:53:49 +08:00
type: 1
2022-06-28 10:40:13 +08:00
}
}).then(res => {
if (res.code == 0) {
this.tableData = res.data.records
this.total = res.data.total
this.loading = false
} else {
this.loading = false
}
}).catch(() => {
this.loading = false
})
},
remove(id) {
this.$confirm('确定删除该数据?').then(() => {
this.instance.post(`/app/appzyaccountconfig/delete?ids=${id}`).then(res => {
if (res.code == 0) {
this.$message.success('删除成功!')
this.getList()
}
})
})
},
add(title, item) {
this.dialog = true
this.dialogTitle = title
this.dialogForm = item
2022-06-28 14:20:35 +08:00
if(title == '添加设备配置') {
2022-06-28 10:40:13 +08:00
this.dialogForm.flag = 1
}
},
addForm() {
this.$refs.addForm.validate((valid) => {
if (valid) {
this.dialogForm.type = 1
this.instance.post(`/app/appzyaccountconfig/addOrUpdate`, this.dialogForm).then((res) => {
if (res.code == 0) {
this.$message.success(`${this.dialogForm.id ? '编辑成功' : '添加成功'}`)
this.getListInit()
this.dialog = false;
}
});
} else {
return false;
}
});
},
2022-06-28 11:53:49 +08:00
refresh(row) {
2022-06-28 10:40:13 +08:00
this.$confirm('确定刷新该数据token').then(() => {
2022-06-28 14:20:35 +08:00
this.instance.post(`/app/appzyaccountconfig/initSlwToken?id=${row.id}`).then(res => {
2022-06-28 11:53:49 +08:00
if (res.code == 0) {
this.$message.success('刷新成功!')
this.getList()
}
})
2022-06-28 10:40:13 +08:00
})
},
2022-06-28 18:18:43 +08:00
onChange(row) {
this.instance.post(`/app/appzyaccountconfig/setFlag`, null, {
params: {
id: row.id,
flag: row.flag
}
}).then((res) => {
if (res.code == 0) {
this.$message.success(+row.flag ? '已启用' : '已禁用');
this.getList();
}
})
}
2022-06-28 10:40:13 +08:00
}
}
</script>