hldy_yunwei_vue/src/views/iot/tplink/plan/index.vue

226 lines
5.5 KiB
Vue
Raw Normal View History

2025-07-09 08:53:04 +08:00
<!--
2025-07-03 17:40:00 +08:00
<template>
<a-row class="p-2" type="flex" :gutter="10">
<a-col :xl="4" :lg="24" :md="24" style="margin-bottom: 10px">
<PlanLeftTree ref="leftTree" @select="onTreeSelect" @rootTreeData="onRootTreeData" />
</a-col>
<a-col :xl="20" :lg="24" :md="24" style="margin-bottom: 10px">
<div v-show="planData != null">
<PlanList :data="planData" />
</div>
<div v-show="planData == null" style="padding-top: 40px">
<a-empty description="请选择区域" />
</div>
</a-col>
</a-row>
</template>
<script lang="ts" name="iot-nuIotCameraInfo" setup>
import { ref } from 'vue';
import { useDesign } from '/@/hooks/web/useDesign';
import PlanLeftTree from './components/PlanLeftTree.vue'
import PlanList from './components/PlanList.vue';
// 给子组件定义一个ref变量
const leftTree = ref();
// 当前选中的区域信息
const planData = ref({});
const rootTreeData = ref<any[]>([]);
// 左侧树选择后触发
function onTreeSelect(data) {
planData.value = data;
}
// 左侧树rootTreeData触发
function onRootTreeData(data) {
rootTreeData.value = data;
}
</script>
<style lang="less" scoped>
.p-2{
height: calc(100vh - 120px);
}
</style>
2025-07-09 08:53:04 +08:00
-->
<template>
<div>
<!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" preIcon="ant-design:plus-outlined" @click="handleAdd"> 新增</a-button>
<a-button v-if="selectedRowKeys.length > 0" preIcon="ant-design:delete-outlined" @click="batchHandleDelete"> 删除</a-button>
</template>
<!--操作栏-->
<template #action="{ record }"></template>
<template v-slot:bodyCell="{ column, record, index, text }">
<template v-if="column.dataIndex === 'recordSwitchBoolean'">
<a-switch
v-model:checked="record.recordSwitchBoolean"
checked-children="开"
un-checked-children="关"
@change="(checked) => handleSwitchChange(checked, record)"
/>
</template>
</template>
<!-- <template #recordSlot="{ text, record }">
<a-switch
v-model:checked="record.recordSwitch"
checked-children="启用"
un-checked-children="停用"
/>
</template>-->
</BasicTable>
<!-- 表单区域 -->
<PlanModal ref="registerModal"></PlanModal>
</div>
</template>
<script lang="ts" name="iot-nuIotCameraInfo" setup>
import { ref, reactive, createVNode, h, onMounted, watch, unref } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { columns } from './plan.data';
import {batchDeleteCfgs, editRecordCfgs, list} from './plan.api';
import { useUserStore } from '/@/store/modules/user';
import { useDrawer } from "@/components/Drawer";
import { useRouter } from 'vue-router';
import PlanModal from './components/PlanModal.vue';
//注册drawer
const [registerDrawer, { openDrawer }] = useDrawer();
let router = useRouter();
const queryParam = reactive<any>({});
const registerModal = ref();
const userStore = useUserStore();
//注册table数据
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '物联管理-录像计划',
api: list,
columns,
rowKey : "ids",
canResize: false,
showActionColumn: false,
actionColumn: {
width: 180,
fixed: 'right',
},
beforeFetch: async (params) => {
return Object.assign(params, queryParam);
},
},
});
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource, getSelectRows }, { rowSelection, selectedRowKeys }] = tableContext;
const labelCol = reactive({
xs:24,
sm:4,
xl:6,
xxl:4
});
const wrapperCol = reactive({
xs: 24,
sm: 20,
});
/**
* 新增
*/
function handleAdd(record: Recordable) {
registerModal.value.disableSubmit = false;
registerModal.value.edit(record);
}
/**
* 编辑
*/
function handleEdit(record: Recordable) {
openDrawer(true, {
record,
isUpdate: true,
showFooter: true,
tenantSaas: false,
});
}
/**
* 批量删除事件
*/
async function batchHandleDelete() {
const selectRows = getSelectRows();
let ids = [];
let devIds = [];
if(selectRows.length>0){
selectRows.forEach(function(element) {
ids.push(element.ids);
devIds.push(element.deviceIndex);
})
let params = { ids: ids.join(","), deviceIndex: devIds.join(",")};
console.log(params);
await batchDeleteCfgs(params);
}
}
/**
* 成功回调
*/
function handleSuccess() {
reload();
}
/**
* 操作栏
*/
function getTableAction(record) {
return [
];
}
function handleSwitchChange(checked, record) {
let recordSwitch = 0;
if(checked){
recordSwitch = 1;
}
editRecordCfgs({ ids: record.ids, recordSwitch: recordSwitch });
}
</script>
<style lang="less" scoped>
.jeecg-basic-table-form-container {
padding: 0;
.table-page-search-submitButtons {
display: block;
margin-bottom: 24px;
white-space: nowrap;
}
.query-group-cust{
min-width: 100px !important;
}
.query-group-split-cust{
width: 30px;
display: inline-block;
text-align: center
}
.ant-form-item:not(.ant-form-item-with-help){
margin-bottom: 16px;
height: 32px;
}
:deep(.ant-picker),:deep(.ant-input-number){
width: 100%;
}
}
.p-2{
height: calc(100vh - 120px);
}
</style>