| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365 |
- <template>
- <div class="ele-body">
- <el-card shadow="never" v-loading="loading">
- <ele-split-layout
- width="266px"
- allow-collapse
- :right-style="{ overflow: 'hidden' }"
- >
- <div>
- <div class="ele-border-lighter sys-organization-list">
- <div class="tree-title">区域列表</div>
- <el-tree
- ref="areaTree"
- :data="areaTreeList"
- :props="defaultProps"
- node-key="id"
- highlight-current
- default-expand-all
- :expand-on-click-node="false"
- @node-click="handleAreaClick"
- >
- </el-tree>
- </div>
- </div>
- <template v-slot:content>
- <!-- 搜索表单 -->
- <camera-search ref="searchRef" @search="reload" />
- <!-- 数据表格 -->
- <ele-pro-table
- :page-size="defPageSize"
- ref="table"
- :columns="columns"
- :datasource="datasource"
- :selection.sync="selection"
- :cache-key="cacheKeyUrl"
- :pageSizes="tablePageSizes"
- height="calc(100vh - 320px)"
- full-height="calc(100vh - 115px)"
- :response="{
- dataName: 'data.records', // 数据列表的字段名称,支持嵌套,例如:data.rows
- countName: 'data.total' // 数据总数的字段名称,例如:data.total
- }"
- >
- <!-- 表头工具栏 -->
- <template v-slot:toolbar>
- <el-button
- type="primary"
- icon="el-icon-plus"
- class="ele-btn-icon"
- v-if="$hasPermission('ledgerAssets:camera:create')"
- @click="openForm('create')"
- >
- 新建
- </el-button>
- <el-button
- type="danger"
- icon="el-icon-delete"
- class="ele-btn-icon"
- v-if="
- $hasPermission('ledgerAssets:camera:delete') &&
- selection.length
- "
- @click="handleBatchDelete"
- >
- 批量删除
- </el-button>
- </template>
- <!-- 摄像机状态列 -->
- <template v-slot:activityStatus="{ row }">
- <el-switch
- v-model="row.activityStatus"
- :active-value="1"
- :inactive-value="0"
- @change="handleStatusChange(row)"
- />
- </template>
- <!-- 操作列 -->
- <template v-slot:action="{ row }">
- <el-link
- type="primary"
- :underline="false"
- icon="el-icon-edit"
- v-if="$hasPermission('ledgerAssets:camera:update')"
- @click="openForm('update', row.id)"
- >
- 编辑
- </el-link>
- <el-link
- type="primary"
- :underline="false"
- icon="el-icon-delete"
- :style="{ color: delColor }"
- v-if="$hasPermission('ledgerAssets:camera:delete')"
- @click="handleDelete(row.id)"
- >
- 删除
- </el-link>
- </template>
- </ele-pro-table>
- </template>
- </ele-split-layout>
- </el-card>
- <!-- 表单弹窗:添加/修改 -->
- <formModel ref="formRef" @success="reload" />
- </div>
- </template>
- <script>
- import * as CameraApi from '@/api/ledgerAssets/camera';
- import { basicAreaPageAPI } from '@/api/factoryModel';
- import formModel from './components/formModel.vue';
- import cameraSearch from './components/camera-search.vue';
- export default {
- name: 'LedgerCamera',
- components: {
- formModel,
- cameraSearch
- },
- data() {
- return {
- cacheKeyUrl: 'ledgerCameraTable',
- delColor: '#F56C6C',
- selection: [],
- loading: false,
- // 当前选中的区域
- currentArea: null,
- // 区域树数据
- areaTreeList: [],
- defaultProps: {
- children: 'children',
- label: 'name'
- },
- // 表格列配置
- columns: [
- {
- width: 45,
- type: 'selection',
- columnKey: 'selection',
- align: 'center',
- fixed: 'left'
- },
- {
- columnKey: 'index',
- label: '序号',
- type: 'index',
- width: 55,
- align: 'center',
- showOverflowTooltip: true,
- fixed: 'left'
- },
- {
- prop: 'deviceCode',
- label: '摄像机编号',
- headerAlign: 'center',
- align: 'center',
- showOverflowTooltip: true,
- width: 180
- },
- {
- prop: 'name',
- label: '摄像机名称',
- headerAlign: 'center',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 200
- },
- {
- prop: 'areaName',
- label: '所属区域',
- headerAlign: 'center',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 160
- },
- {
- prop: 'brandName',
- label: '设备品牌',
- headerAlign: 'center',
- align: 'center',
- showOverflowTooltip: true,
- width: 180
- },
- {
- prop: 'modelName',
- label: '设备型号',
- headerAlign: 'center',
- align: 'center',
- showOverflowTooltip: true,
- width: 180
- },
- {
- prop: 'classifyName',
- label: '摄像机类型',
- headerAlign: 'center',
- align: 'center',
- showOverflowTooltip: true,
- width: 180
- },
- // {
- // prop: 'loadDeviceName',
- // label: '关联设备',
- // headerAlign: 'center',
- // align: 'center',
- // showOverflowTooltip: true,
- // width: 150
- // },
- {
- prop: 'activityStatus',
- label: '摄像机状态',
- align: 'center',
- showOverflowTooltip: true,
- width: 120,
- slot: 'activityStatus'
- },
- {
- columnKey: 'action',
- fixed: 'right',
- label: '操作',
- width: 160,
- align: 'center',
- resizable: false,
- slot: 'action',
- showOverflowTooltip: true
- }
- ]
- };
- },
- created() {
- this.getAreaTreeList();
- },
- methods: {
- /* 获取区域树 */
- getAreaTreeList() {
- this.loading = true;
- basicAreaPageAPI({
- pageNum: 1,
- size: 9999
- })
- .then((list) => {
- this.areaTreeList = this.$util.toTreeData({
- data: list || [],
- idField: 'id',
- parentIdField: 'parentId'
- });
- })
- .finally(() => {
- this.loading = false;
- });
- },
- /* 点击区域节点查询 */
- handleAreaClick(data) {
- this.currentArea = data;
- // 记录所选区域到搜索条件并刷新
- this.reload({
- areaId: data.id
- });
- },
- /* 表格数据源 */
- async datasource({ page, limit, where }) {
- return await CameraApi.getDevicePage({
- pageNum: page,
- size: limit,
- ...where
- });
- },
- /* 刷新表格 */
- reload(where) {
- this.$refs.table.reload({ page: 1, where });
- },
- /** 添加/修改操作 */
- openForm(type, id) {
- this.$refs.formRef.open(type, id, this.currentArea);
- },
- /** 状态切换 */
- handleStatusChange(row) {
- const text = row.activityStatus === 1 ? '启用' : '停用';
- this.$confirm('确认要' + text + '摄像机"' + row.name + '"吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- })
- .then(async () => {
- row.extInfo = row.extInfo || '{}';
- await CameraApi.updateDevice(row);
- this.$message.success(text + '成功');
- this.reload();
- })
- .catch(() => {
- row.activityStatus = row.activityStatus === 1 ? 0 : 1;
- });
- },
- /** 删除按钮操作 */
- handleDelete(id) {
- this.$confirm('是否确认删除该数据项?', '警告', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- })
- .then(async () => {
- await CameraApi.deletedDevice(id);
- this.$message.success('删除成功');
- this.reload();
- })
- .catch(() => {});
- },
- /** 批量删除按钮操作 */
- handleBatchDelete() {
- if (this.selection.length === 0) {
- this.$message.warning('请选择要删除的数据项');
- return;
- }
- this.$confirm('是否确认删除选中的数据项?', '警告', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- })
- .then(async () => {
- const ids = this.selection.map((item) => item.id);
- for (const id of ids) {
- await CameraApi.deletedDevice(id);
- }
- this.$message.success('删除成功');
- this.reload();
- })
- .catch(() => {});
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .sys-organization-list {
- position: absolute;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- box-sizing: border-box;
- border-width: 1px;
- border-style: solid;
- overflow: auto;
- }
- .tree-title {
- padding: 10px 12px;
- font-weight: bold;
- border-bottom: 1px solid #ebeef5;
- }
- .sys-organization-list :deep(.el-tree-node__content) {
- height: 36px;
- & > .el-tree-node__expand-icon {
- margin-left: 10px;
- }
- }
- </style>
|