物联设备管理

This commit is contained in:
曹磊 2026-04-01 14:54:48 +08:00
parent 4804360e26
commit 0c03ca821f
13 changed files with 1594 additions and 0 deletions

View File

@ -0,0 +1,225 @@
<template>
<div class="p-2">
<div class="jeecg-basic-table-form-container">
<a-form ref="formRef" :model="queryParam" :label-col="labelCol"
:wrapper-col="wrapperCol">
<a-row :gutter="24">
<a-col :lg="6">
<a-form-item name="nuName">
<template #label><span title="区域名称">区域名称</span></template>
<a-input v-model:value="queryParam.nuName" placeholder="请输入区域名称" allow-clear />
</a-form-item>
</a-col>
<a-col :lg="6">
<a-form-item name="dimension">
<template #label><span title="设备维度">设备维度</span></template>
<a-select v-model:value="queryParam.dimension" placeholder="请选择设备维度" allow-clear>
<a-select-option value="机构维度">机构维度</a-select-option>
<a-select-option value="区域维度">区域维度</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="6">
<a-form-item name="deviceType">
<template #label><span title="设备类型">设备类型</span></template>
<j-dict-select-tag v-model:value="queryParam.deviceType" :showLabel="false" dictCode="tplink_device_type" placeholder="请选择设备类型" allow-clear />
</a-form-item>
</a-col>
<a-col :xl="6" :lg="7" :md="8" :sm="24">
<span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
<a-col :lg="6">
<a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery">查询</a-button>
<a-button type="primary" preIcon="ant-design:reload-outlined" @click="searchReset"
style="margin-left: 8px">重置</a-button>
</a-col>
</span>
</a-col>
</a-row>
</a-form>
</div>
<!--引用表格-->
<BasicTable @register="registerTable">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" preIcon="ant-design:database-outlined" @click="handleDevicePreview"> 设备清单</a-button>
<a-button type="primary" preIcon="ant-design:hdd-outlined" @click="handleDeviceLog"> 设备日志</a-button>
</template>
<template #bodyCell="{ column, record, index, text }">
</template>
<!--操作栏-->
<template #action="{ record }">
<TableAction :actions="getTableAction(record)"/>
</template>
</BasicTable>
<DevicePreviewModal ref="previewDrawer" @success="handleSuccess" />
<DeviceLogModal ref="logDrawer" @success="handleSuccess" />
<DeviceBrokenModal ref="brokenDrawer" @success="handleSuccess" />
<DeviceGhModal ref="ghDrawer" @success="handleSuccess" />
</div>
</template>
<script lang="ts" name="iot-nuIotElectricitynInfo" setup>
import {reactive, ref,h} from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { useUserStore } from '/@/store/modules/user';
import {Modal} from "ant-design-vue";
import {list, save} from './manager.api';
import { columns, searchFormSchema } from './manager.data';
import {useModal} from "@/components/Modal";
import DevicePreviewModal from "./components/preview/DevicePreviewModal.vue";
import DeviceLogModal from "./components/log/DeviceLogModal.vue";
import DeviceBrokenModal from "./components/DeviceBrokenModal.vue";
import DeviceGhModal from "./components/DeviceGhModal.vue";
import { defHttp } from '/@/utils/http/axios';
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
const formRef = ref();
const queryParam = reactive<any>({});
const previewDrawer = ref();
const logDrawer = ref();
const brokenDrawer = ref();
const ghDrawer = ref();
const tipVisible = ref(false);
//model
const [registerModal, {openModal}] = useModal();
//table
const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({
tableProps:{
title: '物联设备管理',
api: list,
columns,
canResize:false,
useSearchForm: false,
showIndexColumn: true,
pagination: {
current: 1,
pageSize: 15,
pageSizeOptions: ['15', '50', '70', '100'],
},
actionColumn: {
width: 290,
fixed:'right'
},
beforeFetch: (params) => {
return Object.assign(params, queryParam);
},
},
})
const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext
const labelCol = reactive({
xs:24,
sm:4,
xl:6,
xxl:4
});
const wrapperCol = reactive({
xs: 24,
sm: 20,
});
/**
* 查询
*/
function searchQuery() {
reload();
}
/**
* 重置
*/
function searchReset() {
formRef.value.resetFields();
//
reload();
}
function handleCancel() {
tipVisible.value = false;
}
/**
* 成功回调
*/
function handleSuccess() {
(selectedRowKeys.value = []) && reload();
}
/**
* 操作栏
*/
function getTableAction(record){
return [
{
label: '损坏',
onClick: handleDeviceBroken.bind(null, record),
ifShow: record.deviceStatus != '损坏'
},
{
label: '更换',
onClick: handleDeviceGh.bind(null, record),
ifShow: (record.dimension == '区域维度' && record.deviceStatus != '损坏')
},
]
}
/**
* 报损
*/
function handleDeviceBroken(record: Recordable) {
brokenDrawer.value.disableSubmit = false;
brokenDrawer.value.edit(record);
}
/**
* 更换
*/
function handleDeviceGh(record: Recordable) {
ghDrawer.value.disableSubmit = false;
ghDrawer.value.edit(record);
}
/**
* 设备清单
*/
function handleDevicePreview(record: Recordable) {
previewDrawer.value.disableSubmit = true;
previewDrawer.value.edit(record);
}
/**
* 设备日志
*/
function handleDeviceLog(record: Recordable) {
logDrawer.value.disableSubmit = true;
logDrawer.value.edit(record);
}
</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%;
}
}
</style>

View File

@ -0,0 +1,147 @@
<template>
<a-spin :spinning="confirmLoading">
<JFormContainer :disabled="disabled">
<template #detail>
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-row>
<a-col :span="24">
<a-form-item label="备注" v-bind="validateInfos.remarks" id="deviceBrokenForm-remarks" name="remarks">
<a-textarea v-model:value="formData.remarks" :auto-size="{ minRows: 3, maxRows: 6 }"></a-textarea>
</a-form-item>
</a-col>
</a-row>
</a-form>
</template>
</JFormContainer>
</a-spin>
</template>
<script lang="ts" setup>
import {ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted, unref} from 'vue';
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
import { getValueType } from '/@/utils';
import { saveLog } from '../manager.api';
import { Form } from 'ant-design-vue';
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
const isUpdate = ref<boolean>(false);
const props = defineProps({
formDisabled: { type: Boolean, default: false },
formData: { type: Object, default: ()=>{} },
formBpm: { type: Boolean, default: true }
});
const formRef = ref();
const useForm = Form.useForm;
const emit = defineEmits(['register', 'ok']);
const formData = reactive<Record<string, any>>({
remarks: undefined,
id: undefined,
nuId: undefined,
nuName: undefined,
dimension: undefined,
deviceType: undefined,
deviceModel: undefined,
factory: undefined,
sn: undefined,
optType: '损坏'
});
const { createMessage } = useMessage();
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } });
const confirmLoading = ref<boolean>(false);
//
const validatorRules = {
remarks: [{ required: true, message: '请填写备注!'},],
};
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: true });
//
const disabled = computed(()=>{
if(props.formBpm === true){
if(props.formData.disabled === false){
return false;
}else{
return true;
}
}
return props.formDisabled;
});
/**
* 新增
*/
function add() {
edit({});
}
/**
* 编辑
*/
function edit(record) {
isUpdate.value = true;
nextTick(() => {
resetFields();
//
const tmpData = {};
Object.keys(formData).forEach((key) => {
if(record.hasOwnProperty(key)){
tmpData[key] = record[key]
}
})
//
Object.assign(formData, tmpData);
formData.remarks = '';
});
}
/**
* 提交数据
*/
async function submitForm() {
try {
//
await validate();
} catch ({ errorFields }) {
if (errorFields) {
const firstField = errorFields[0];
if (firstField) {
formRef.value.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
}
}
return Promise.reject(errorFields);
}
confirmLoading.value = true;
//
let model = formData;
//
for (let data in model) {
//
if (model[data] instanceof Array) {
let valueType = getValueType(formRef.value.getProps, data);
//
if (valueType === 'string') {
model[data] = model[data].join(',');
}
}
}
let isUpdateVal = unref(isUpdate);
await saveLog(model,isUpdateVal)
.then((res) => {
emit('ok');
})
.finally(() => {
confirmLoading.value = false;
});
}
defineExpose({
add,
edit,
submitForm,
});
</script>
<style lang="less" scoped>
</style>

View File

@ -0,0 +1,84 @@
<template>
<a-drawer :title="title" :width="width" :visible="visible" :closable="true" :footer-style="{ textAlign: 'right' }"
:bodyStyle="{ padding: '14px' }" @close="handleCancel">
<template #footer>
<a-button type="primary" style="margin-right: 8px" @click="handleCancel">关闭</a-button>
<a-button type="primary" @click="handleOk" v-if="!disableSubmit">确认</a-button>
</template>
<DeviceBrokenForm v-if="visible" ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit"
:formBpm="false">
</DeviceBrokenForm>
</a-drawer>
</template>
<script lang="ts" setup>
import { ref, nextTick, defineExpose } from 'vue';
import DeviceBrokenForm from './DeviceBrokenForm.vue'
import JModal from '/@/components/Modal/src/JModal/JModal.vue';
const title = ref<string>('');
const width = ref<number>(800);
const visible = ref<boolean>(false);
const disableSubmit = ref<boolean>(false);
const registerForm = ref();
const configVisible = ref<boolean>(false);
const emit = defineEmits(['register', 'success']);
/**
* 新增
*/
function add(record) {
title.value = '新增区域维度';
visible.value = true;
nextTick(() => {
registerForm.value.add(record);
});
}
/**
* 编辑
* @param record
*/
function edit(record) {
title.value = disableSubmit.value ? '详情' : '报损';
visible.value = true;
nextTick(() => {
registerForm.value.edit(record);
});
}
/**
* 确定按钮点击事件
*/
function handleOk() {
registerForm.value.submitForm();
}
/**
* form保存回调事件
*/
function submitCallback() {
handleCancel();
emit('success');
}
/**
* 取消按钮回调事件
*/
function handleCancel() {
visible.value = false;
}
defineExpose({
add,
edit,
disableSubmit,
});
</script>
<style lang="less">
/**隐藏样式-modal确定按钮 */
.jee-hidden {
display: none !important;
}
</style>
<style lang="less" scoped></style>

View File

@ -0,0 +1,172 @@
<template>
<a-spin :spinning="confirmLoading">
<JFormContainer :disabled="disabled">
<template #detail>
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-row>
<a-col :span="24">
<a-form-item label="选择区域" v-bind="validateInfos.nuId" id="deviceGhForm-nuId" name="nuId">
<a-select ref="select" @change="handleChange"
placeholder="请选择区域"
v-model:value="formData.nuId">
<a-select-option :value="item.nuId" v-for="item in nuInfos" :key="item.nuName">{{item.nuName}}</a-select-option>
</a-select>
</a-form-item>
</a-col>
</a-row>
<a-row>
<a-col :span="24">
<a-form-item label="备注" v-bind="validateInfos.remarks" id="deviceGhForm-remarks" name="remarks">
<a-textarea v-model:value="formData.remarks" :auto-size="{ minRows: 3, maxRows: 6 }"></a-textarea>
</a-form-item>
</a-col>
</a-row>
</a-form>
</template>
</JFormContainer>
</a-spin>
</template>
<script lang="ts" setup>
import {ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted, unref} from 'vue';
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
import { getValueType } from '/@/utils';
import { saveLog,nuList } from '../manager.api';
import { Form } from 'ant-design-vue';
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
const isUpdate = ref<boolean>(false);
const props = defineProps({
formDisabled: { type: Boolean, default: false },
formData: { type: Object, default: ()=>{} },
formBpm: { type: Boolean, default: true }
});
const nuInfos = ref([]);
const formRef = ref();
const useForm = Form.useForm;
const emit = defineEmits(['register', 'ok']);
const formData = reactive<Record<string, any>>({
remarks: undefined,
id: undefined,
nuId: undefined,
nuName: undefined,
dimension: undefined,
deviceType: undefined,
deviceModel: undefined,
factory: undefined,
sn: undefined,
optType: '换绑'
});
const { createMessage } = useMessage();
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } });
const confirmLoading = ref<boolean>(false);
//
const validatorRules = {
nuId: [{ required: true, message: '请选择区域!'},],
remarks: [{ required: true, message: '请填写备注!'},],
};
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: true });
//
const disabled = computed(()=>{
if(props.formBpm === true){
if(props.formData.disabled === false){
return false;
}else{
return true;
}
}
return props.formDisabled;
});
/**
* 新增
*/
function add() {
edit({});
}
/**
* 编辑
*/
function edit(record) {
getNuInfos();
isUpdate.value = true;
nextTick(() => {
resetFields();
//
const tmpData = {};
Object.keys(formData).forEach((key) => {
if(record.hasOwnProperty(key)){
tmpData[key] = record[key]
}
})
//
Object.assign(formData, tmpData);
formData.remarks = '';
});
}
/**
* 提交数据
*/
async function submitForm() {
try {
//
await validate();
} catch ({ errorFields }) {
if (errorFields) {
const firstField = errorFields[0];
if (firstField) {
formRef.value.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
}
}
return Promise.reject(errorFields);
}
confirmLoading.value = true;
//
let model = formData;
//
for (let data in model) {
//
if (model[data] instanceof Array) {
let valueType = getValueType(formRef.value.getProps, data);
//
if (valueType === 'string') {
model[data] = model[data].join(',');
}
}
}
let isUpdateVal = unref(isUpdate);
await saveLog(model,isUpdateVal)
.then((res) => {
emit('ok');
})
.finally(() => {
confirmLoading.value = false;
});
}
function getNuInfos(){
nuList({}).then((res) =>{
nuInfos.value = res
})
}
function handleChange(key,record) {
formData.nuName = record.key;
}
defineExpose({
add,
edit,
submitForm,
});
</script>
<style lang="less" scoped>
</style>

View File

@ -0,0 +1,84 @@
<template>
<a-drawer :title="title" :width="width" :visible="visible" :closable="true" :footer-style="{ textAlign: 'right' }"
:bodyStyle="{ padding: '14px' }" @close="handleCancel">
<template #footer>
<a-button type="primary" style="margin-right: 8px" @click="handleCancel">关闭</a-button>
<a-button type="primary" @click="handleOk" v-if="!disableSubmit">确认</a-button>
</template>
<DeviceGhForm v-if="visible" ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit"
:formBpm="false">
</DeviceGhForm>
</a-drawer>
</template>
<script lang="ts" setup>
import { ref, nextTick, defineExpose } from 'vue';
import DeviceGhForm from './DeviceGhForm.vue'
import JModal from '/@/components/Modal/src/JModal/JModal.vue';
const title = ref<string>('');
const width = ref<number>(800);
const visible = ref<boolean>(false);
const disableSubmit = ref<boolean>(false);
const registerForm = ref();
const configVisible = ref<boolean>(false);
const emit = defineEmits(['register', 'success']);
/**
* 新增
*/
function add(record) {
title.value = '新增区域维度';
visible.value = true;
nextTick(() => {
registerForm.value.add(record);
});
}
/**
* 编辑
* @param record
*/
function edit(record) {
title.value = disableSubmit.value ? '详情' : '更换';
visible.value = true;
nextTick(() => {
registerForm.value.edit(record);
});
}
/**
* 确定按钮点击事件
*/
function handleOk() {
registerForm.value.submitForm();
}
/**
* form保存回调事件
*/
function submitCallback() {
handleCancel();
emit('success');
}
/**
* 取消按钮回调事件
*/
function handleCancel() {
visible.value = false;
}
defineExpose({
add,
edit,
disableSubmit,
});
</script>
<style lang="less">
/**隐藏样式-modal确定按钮 */
.jee-hidden {
display: none !important;
}
</style>
<style lang="less" scoped></style>

View File

@ -0,0 +1,86 @@
<template>
<div>
<!--引用表格-->
<BasicTable @register="registerTable">
<!--插槽:table标题-->
<template #tableTitle>
</template>
<!--操作栏-->
<template #action="{ record }">
<TableAction :actions="getTableAction(record)"/>
</template>
</BasicTable>
</div>
</template>
<script lang="ts" name="iot-weihu" setup>
import {onMounted, reactive, ref} from 'vue';
import { BasicTable, TableAction } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { bingLogList } from '../../manager.api';
import { logColumns} from '../../manager.data';
import { useDrawer } from "@/components/Drawer";
const [registerDrawer, { openDrawer }] = useDrawer();
const queryParam = reactive<any>({});
const selectedRows = ref<any[]>([]);
const remarksModal = ref();
//table
const { prefixCls,tableContext } = useListPage({
tableProps:{
title: '设备日志',
api: bingLogList,
columns: logColumns,
canResize:false,
showIndexColumn: true,
showActionColumn: false,
pagination: {
current: 1,
pageSize: 15,
pageSizeOptions: ['15', '50', '70', '100'],
},
actionColumn: {
width: 90,
fixed:'right'
},
beforeFetch: (params) => {
return Object.assign(params, queryParam);
},
},
})
const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext
/**
* 成功回调
*/
function handleSuccess() {
(selectedRowKeys.value = []) && reload();
}
/**
* 操作栏
*/
function getTableAction(record){
return [
];
}
function init(record) {
reload();
}
defineExpose({
init,
});
</script>
<style lang="less" scoped>
:deep(.selected-row) {
background-color: #e6f7ff !important;
&:hover td {
background-color: #e6f7ff !important;
}
}
</style>

View File

@ -0,0 +1,82 @@
<template>
<a-drawer :title="title" :width="width" :visible="visible" :closable="true" :footer-style="{ textAlign: 'right' }"
:bodyStyle="{ padding: '14px' }" @close="handleCancel">
<template #footer>
<a-button type="primary" style="margin-right: 8px" @click="handleCancel">关闭</a-button>
<a-button type="primary" @click="handleOk" v-if="!disableSubmit">确认</a-button>
</template>
<DeviceLogList v-if="visible" ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit"
:formBpm="false">
</DeviceLogList>
</a-drawer>
</template>
<script lang="ts" setup>
import { ref, nextTick, defineExpose } from 'vue';
import DeviceLogList from './DeviceLogList.vue'
const title = ref<string>('');
const width = ref<number>(1200);
const visible = ref<boolean>(false);
const disableSubmit = ref<boolean>(false);
const registerForm = ref();
const emit = defineEmits(['register', 'success']);
/**
* 新增
*/
function add() {
title.value = '新增';
visible.value = true;
nextTick(() => {
registerForm.value.add();
});
}
/**
* 编辑
* @param record
*/
function edit(record) {
title.value = disableSubmit.value ? '设备日志' : '编辑';
visible.value = true;
nextTick(() => {
registerForm.value.init(record);
});
}
/**
* 确定按钮点击事件
*/
function handleOk() {
registerForm.value.submitForm();
}
/**
* form保存回调事件
*/
function submitCallback() {
handleCancel();
emit('success');
}
/**
* 取消按钮回调事件
*/
function handleCancel() {
visible.value = false;
}
defineExpose({
add,
edit,
disableSubmit,
});
</script>
<style lang="less">
/**隐藏样式-modal确定按钮 */
.jee-hidden {
display: none !important;
}
</style>
<style lang="less" scoped></style>

View File

@ -0,0 +1,149 @@
<template>
<a-spin :spinning="confirmLoading">
<JFormContainer :disabled="disabled">
<template #detail>
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-row>
<a-col :span="24">
<a-form-item label="设备标识" v-bind="validateInfos.sn" id="devicePreviewForm-sn" name="sn">
<a-input v-model:value="formData.sn"></a-input>
</a-form-item>
</a-col>
</a-row>
<a-row>
<a-col :span="24">
<a-form-item label="备注" v-bind="validateInfos.dimension" id="devicePreviewForm-remarks" name="remarks">
<a-textarea v-model:value="formData.remarks" :auto-size="{ minRows: 3, maxRows: 6 }"></a-textarea>
</a-form-item>
</a-col>
</a-row>
</a-form>
</template>
</JFormContainer>
</a-spin>
</template>
<script lang="ts" setup>
import {ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted, unref} from 'vue';
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
import { getValueType } from '/@/utils';
import { save } from '../../manager.api';
import { Form } from 'ant-design-vue';
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
const isUpdate = ref<boolean>(false);
const orgCode = ref<any>('');
const deviceConfigs = ref([]);
const nuInfos = ref([]);
const props = defineProps({
formDisabled: { type: Boolean, default: false },
formData: { type: Object, default: ()=>{} },
formBpm: { type: Boolean, default: true }
});
const formRef = ref();
const useForm = Form.useForm;
const emit = defineEmits(['register', 'ok']);
const formData = reactive<Record<string, any>>({
id: undefined,
sn: undefined,
remarks: undefined,
});
const { createMessage } = useMessage();
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } });
const confirmLoading = ref<boolean>(false);
//
const validatorRules = {
sn: [{ required: true, message: '请填写设备标识!'},],
};
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: true });
//
const disabled = computed(()=>{
if(props.formBpm === true){
if(props.formData.disabled === false){
return false;
}else{
return true;
}
}
return props.formDisabled;
});
/**
* 新增
*/
function add() {
edit({});
}
/**
* 编辑
*/
function edit(record) {
isUpdate.value = true;
nextTick(() => {
resetFields();
//
const tmpData = {};
Object.keys(formData).forEach((key) => {
if(record.hasOwnProperty(key)){
tmpData[key] = record[key]
}
})
//
Object.assign(formData, tmpData);
});
}
/**
* 提交数据
*/
async function submitForm() {
try {
//
await validate();
} catch ({ errorFields }) {
if (errorFields) {
const firstField = errorFields[0];
if (firstField) {
formRef.value.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
}
}
return Promise.reject(errorFields);
}
confirmLoading.value = true;
//
let model = formData;
//
for (let data in model) {
//
if (model[data] instanceof Array) {
let valueType = getValueType(formRef.value.getProps, data);
//
if (valueType === 'string') {
model[data] = model[data].join(',');
}
}
}
let isUpdateVal = unref(isUpdate);
await save(model,isUpdateVal)
.then((res) => {
emit('ok');
})
.finally(() => {
confirmLoading.value = false;
});
}
defineExpose({
add,
edit,
submitForm,
});
</script>
<style lang="less" scoped>
</style>

View File

@ -0,0 +1,84 @@
<template>
<a-drawer :title="title" :width="width" :visible="visible" :closable="true" :footer-style="{ textAlign: 'right' }"
:bodyStyle="{ padding: '14px' }" @close="handleCancel">
<template #footer>
<a-button type="primary" style="margin-right: 8px" @click="handleCancel">关闭</a-button>
<a-button type="primary" @click="handleOk" v-if="!disableSubmit">确认</a-button>
</template>
<DevicePreviewForm v-if="visible" ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit"
:formBpm="false">
</DevicePreviewForm>
</a-drawer>
</template>
<script lang="ts" setup>
import { ref, nextTick, defineExpose } from 'vue';
import DevicePreviewForm from './DevicePreviewForm.vue'
import JModal from '/@/components/Modal/src/JModal/JModal.vue';
const title = ref<string>('');
const width = ref<number>(800);
const visible = ref<boolean>(false);
const disableSubmit = ref<boolean>(false);
const registerForm = ref();
const configVisible = ref<boolean>(false);
const emit = defineEmits(['register', 'success']);
/**
* 新增
*/
function add(record) {
title.value = '新增区域维度';
visible.value = true;
nextTick(() => {
registerForm.value.add(record);
});
}
/**
* 编辑
* @param record
*/
function edit(record) {
title.value = disableSubmit.value ? '详情' : '编辑';
visible.value = true;
nextTick(() => {
registerForm.value.edit(record);
});
}
/**
* 确定按钮点击事件
*/
function handleOk() {
registerForm.value.submitForm();
}
/**
* form保存回调事件
*/
function submitCallback() {
handleCancel();
emit('success');
}
/**
* 取消按钮回调事件
*/
function handleCancel() {
visible.value = false;
}
defineExpose({
add,
edit,
disableSubmit,
});
</script>
<style lang="less">
/**隐藏样式-modal确定按钮 */
.jee-hidden {
display: none !important;
}
</style>
<style lang="less" scoped></style>

View File

@ -0,0 +1,192 @@
<template>
<div>
<!--查询区域-->
<div class="jeecg-basic-table-form-container">
<a-form ref="formRef" :model="queryParam" :label-col="labelCol"
:wrapper-col="wrapperCol">
<a-row :gutter="24">
<a-col :lg="6">
<a-form-item name="dimension">
<template #label><span title="设备维度">设备维度</span></template>
<a-select v-model:value="queryParam.dimension" placeholder="请选择设备维度" allow-clear>
<a-select-option value="机构维度">机构维度</a-select-option>
<a-select-option value="区域维度">区域维度</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="6">
<a-form-item name="deviceType">
<template #label><span title="设备类型">设备类型</span></template>
<j-dict-select-tag v-model:value="queryParam.deviceType" :showLabel="false" dictCode="tplink_device_type" placeholder="请选择设备类型" allow-clear />
</a-form-item>
</a-col>
<a-col :xl="6" :lg="7" :md="8" :sm="24">
<span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
<a-col :lg="6">
<a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery">查询</a-button>
<a-button type="primary" preIcon="ant-design:reload-outlined" @click="searchReset"
style="margin-left: 8px">重置</a-button>
</a-col>
</span>
</a-col>
</a-row>
</a-form>
</div>
<!--引用表格-->
<BasicTable @register="registerTable">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
</template>
<!--操作栏-->
<template #action="{ record }">
<TableAction :actions="getTableAction(record)"/>
</template>
<template v-slot:bodyCell="{ column, record, index, text }">
</template>
</BasicTable>
<!-- 表单区域 -->
<DevicePreviewFormModal ref="formDrawer" @success="handleSuccess" />
</div>
</template>
<script lang="ts" name="iotManager-areaList" setup>
import {ref, reactive, defineExpose, nextTick, createVNode} from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { previewColumns } from '../../manager.data';
import { previewList,getExportUrl } from '../../manager.api';
import { useUserStore } from '/@/store/modules/user';
import DevicePreviewFormModal from './DevicePreviewFormModal.vue';
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
import {Modal} from "ant-design-vue";
import {ExclamationCircleOutlined} from "@ant-design/icons-vue";
const formRef = ref();
const queryParam = reactive<any>({});
const formDrawer = ref();
const orgCode = ref<any>('');
const userStore = useUserStore();
//table
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '设备清单',
api: previewList,
columns: previewColumns,
canResize: false,
useSearchForm: false,
showIndexColumn: true,
immediate: false,
pagination: {
current: 1,
pageSize: 15,
pageSizeOptions: ['15', '50', '70', '100'],
},
actionColumn: {
width: 180,
fixed: 'right',
},
beforeFetch: async (params) => {
return Object.assign(params, queryParam);
},
},
exportConfig: {
name:"设备清单",
url: getExportUrl,
params: queryParam,
},
});
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] = tableContext;
const labelCol = reactive({
xs:24,
sm:8,
xl:8,
xxl:8
});
const wrapperCol = reactive({
xs: 24,
sm: 16,
});
/**
* 成功回调
*/
function handleSuccess() {
reload();
}
/**
* 编辑
*/
function handleEdit(record) {
formDrawer.value.disableSubmit = false;
formDrawer.value.edit(record);
}
/**
* 操作栏
*/
function getTableAction(record) {
return [
{
label: '编辑',
onClick: handleEdit.bind(null, record),
},
];
}
/**
* 查询
*/
function searchQuery() {
queryParam.orgCode = orgCode.value;
reload();
}
/**
* 重置
*/
function searchReset() {
formRef.value.resetFields();
//
searchQuery();
}
//
function init(record) {
orgCode.value = record.orgCode;
searchQuery();
}
defineExpose({
init
});
</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%;
}
}
</style>

View File

@ -0,0 +1,83 @@
<template>
<a-drawer :title="title" :width="width" :visible="visible" :closable="true" :footer-style="{ textAlign: 'right' }"
:bodyStyle="{ padding: '14px' }" @close="handleCancel">
<template #footer>
<a-button type="primary" style="margin-right: 8px" @click="handleCancel">关闭</a-button>
<a-button type="primary" @click="handleOk" v-if="!disableSubmit">确认</a-button>
</template>
<DevicePreviewList v-if="visible" ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit"
:formBpm="false">
</DevicePreviewList>
</a-drawer>
</template>
<script lang="ts" setup>
import { ref, nextTick, defineExpose } from 'vue';
import DevicePreviewList from './DevicePreviewList.vue'
const title = ref<string>('');
const width = ref<number>(1200);
const visible = ref<boolean>(false);
const disableSubmit = ref<boolean>(false);
const registerForm = ref();
const emit = defineEmits(['register', 'success']);
/**
* 新增
*/
function add() {
title.value = '新增';
visible.value = true;
nextTick(() => {
registerForm.value.add();
});
}
/**
* 编辑
* @param record
*/
function edit(record) {
title.value = disableSubmit.value ? '设备清单' : '编辑';
visible.value = true;
nextTick(() => {
registerForm.value.init(record);
});
}
/**
* 确定按钮点击事件
*/
function handleOk() {
registerForm.value.submitForm();
}
/**
* form保存回调事件
*/
function submitCallback() {
handleCancel();
emit('success');
}
/**
* 取消按钮回调事件
*/
function handleCancel() {
visible.value = false;
emit('success');
}
defineExpose({
add,
edit,
disableSubmit,
});
</script>
<style lang="less">
/**隐藏样式-modal确定按钮 */
.jee-hidden {
display: none !important;
}
</style>
<style lang="less" scoped></style>

View File

@ -0,0 +1,37 @@
import { defHttp } from '/@/utils/http/axios';
enum Api {
list = '/iot/device/manager/list',
previewList = '/iot/device/manager/previewList',
add = '/iot/device/manager/add',
edit = '/iot/device/manager/edit',
delete = '/iot/device/manager/delete',
exportXls = '/iot/device/manager/exportXls',
bingLogList = '/iot/device/manager/bingLogList',
nuList = '/iot/device/manager/nuList',
addLog = '/iot/device/manager/addLog',
}
/**
* api
* @param params
*/
export const getExportUrl = Api.exportXls;
/**
*
* @param params
*/
export const list = (params) => defHttp.get({ url: Api.list, params });
export const previewList = (params) => defHttp.get({ url: Api.previewList, params });
export const bingLogList = (params) => defHttp.get({ url: Api.bingLogList, params });
export const nuList = (params) => defHttp.get({ url: Api.nuList, params });
/**
*
* @param params
*/
export const save = (params, isUpdate) => {
let url = isUpdate ? Api.edit : Api.add;
return defHttp.post({url: url, params});
}
export const saveLog = (params) => defHttp.post({ url: Api.addLog, params });

View File

@ -0,0 +1,169 @@
import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
//列表数据
export const columns: BasicColumn[] = [
{
title: '区域编码',
align: "center",
dataIndex: 'nuId',
customRender:({record})=>{
if(record.nuId==null || record.nuId==''){
return "-";
}else{
return record.nuId;
}
},
},
{
title: '区域名称',
align: "center",
dataIndex: 'nuName',
customRender:({record})=>{
if(record.nuName==null || record.nuName==''){
return "-";
}else{
return record.nuName;
}
},
},
{
title: '设备维度',
align: "center",
dataIndex: 'dimension',
},
{
title: '设备标识',
align: "center",
dataIndex: 'sn',
},
{
title: '设备类型',
align: "center",
dataIndex: 'deviceType_dictText',
},
{
title: '设备型号',
align: "center",
dataIndex: 'deviceModel',
},
{
title: '在线状态',
align: "center",
dataIndex: 'onlineStatus',
},
{
title: '设备状态',
align: "center",
dataIndex: 'deviceStatus',
},
];
//列表数据
export const previewColumns: BasicColumn[] = [
{
title: '设备类型',
align: "center",
dataIndex: 'deviceType_dictText',
},
{
title: '设备型号',
align: "center",
dataIndex: 'deviceModel',
},
{
title: '生产厂家',
align: "center",
dataIndex: 'factory',
},
{
title: '设备维度',
align: "center",
dataIndex: 'dimension',
},
{
title: '设备标识',
align: "center",
dataIndex: 'sn',
},
{
title: '时间',
align: "center",
dataIndex: 'updateTime',
},
{
title: '备注',
align: "center",
dataIndex: 'remarks',
},
];
//列表数据
export const logColumns: BasicColumn[] = [
{
title: '区域编码',
align: "center",
dataIndex: 'nuId',
customRender:({record})=>{
if(record.nuId==null || record.nuId==''){
return "-";
}else{
return record.nuId;
}
},
width: 100
},
{
title: '区域名称',
align: "center",
dataIndex: 'nuName',
customRender:({record})=>{
if(record.nuName==null || record.nuName==''){
return "-";
}else{
return record.nuName;
}
},
},
{
title: '设备维度',
align: "center",
dataIndex: 'dimension',
width: 100
},
{
title: '设备类型',
align: "center",
dataIndex: 'deviceType_dictText',
width: 100
},
{
title: '设备型号',
align: "center",
dataIndex: 'deviceModel',
},
{
title: '设备标识',
align: "center",
dataIndex: 'sn',
},
{
title: '生产厂家',
align: "center",
dataIndex: 'factory',
},
{
title: '操作时间',
align: "center",
dataIndex: 'optDate',
width: 150
},
{
title: '操作类型',
align: "center",
dataIndex: 'optType',
width: 100
},
];
export const searchFormSchema: FormSchema[] = [];