This commit is contained in:
1378012178@qq.com 2025-03-21 10:45:23 +08:00
commit a2e32fac92
8 changed files with 142 additions and 37 deletions

View File

@ -24,7 +24,7 @@ export const sync = (params) => defHttp.get({ url: Api.sync, params });
* *
* @param params * @param params
*/ */
export const saveOrUpdatePrject = (params, isUpdate) => { export const saveOrUpdateProject = (params, isUpdate) => {
let url = isUpdate ? Api.edit : Api.add; let url = isUpdate ? Api.edit : Api.add;
return defHttp.post({ url: url, params }); return defHttp.post({ url: url, params });
}; };

View File

@ -0,0 +1,79 @@
<template>
<a-spin :spinning="loading">
<BasicForm @register="registerForm" />
<div class="j-box-bottom-button offset-20" style="margin-top: 30px">
<div class="j-box-bottom-button-float">
<a-button preIcon="ant-design:sync-outlined" @click="onReset">重置</a-button>
<a-button type="primary" preIcon="ant-design:save-filled" @click="onSubmit">保存</a-button>
</div>
</div>
</a-spin>
</template>
<script lang="ts" setup>
import { watch, computed, inject, ref, unref, onMounted } from 'vue';
import { BasicForm, useForm } from '/@/components/Form/index';
import { saveOrUpdateProject } from '@/views/iot/tplink/project/ProjectInfo.api';
import { formSchema } from '@/views/iot/tplink/project/ProjectInfo.data';
import { useDesign } from '/@/hooks/web/useDesign';
const emit = defineEmits(['success']);
const props = defineProps({
data: { type: Object, default: () => ({}) },
rootTreeData: { type: Array, default: () => [] },
});
const loading = ref<boolean>(false);
//
const isUpdate = ref<boolean>(true);
//
const model = ref<object>({});
//
const [registerForm, { resetFields, setFieldsValue, validate, updateSchema }] = useForm({
schemas: formSchema,
showActionButtonGroup: false
});
onMounted(() => {
// data
watch(
() => props.data,
async () => {
let record = unref(props.data);
if (typeof record !== 'object') {
record = {};
}
model.value = record;
await resetFields();
await setFieldsValue({ ...record });
},
{ deep: true, immediate: true }
);
});
//
async function onReset() {
await resetFields();
await setFieldsValue({ ...model.value });
}
//
async function onSubmit() {
try {
loading.value = true;
let values = await validate();
values = Object.assign({}, model.value, values);
//
await saveOrUpdateProject(values, isUpdate.value);
//
emit('success');
Object.assign(model.value, values);
} finally {
loading.value = false;
}
}
</script>
<style lang="less">
</style>

View File

@ -19,7 +19,7 @@ import { formSchema } from "@/views/iot/tplink/project/ProjectInfo.data";
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
import { useDrawerAdaptiveWidth } from '/@/hooks/jeecg/useAdaptiveWidth'; import { useDrawerAdaptiveWidth } from '/@/hooks/jeecg/useAdaptiveWidth';
import { getTenantId } from "/@/utils/auth"; import { getTenantId } from "/@/utils/auth";
import { saveOrUpdatePrject } from "@/views/iot/tplink/project/ProjectInfo.api"; import { saveOrUpdateProject } from "@/views/iot/tplink/project/ProjectInfo.api";
// Emits // Emits
const emit = defineEmits(['success', 'register']); const emit = defineEmits(['success', 'register']);
@ -67,7 +67,7 @@ async function handleSubmit() {
setDrawerProps({ confirmLoading: true }); setDrawerProps({ confirmLoading: true });
let params = values; let params = values;
let isUpdateVal = unref(isUpdate); let isUpdateVal = unref(isUpdate);
await saveOrUpdatePrject(params,isUpdateVal); await saveOrUpdateProject(params,isUpdateVal);
// //
closeDrawer(); closeDrawer();
// //

View File

@ -1,6 +1,11 @@
import { defHttp } from '/@/utils/http/axios'; import { defHttp } from '/@/utils/http/axios';
enum Api { enum Api {
queryProjectTreeSync = '/iot/projectInfo/queryRegionTreeSync',
queryRegionTreeSync = '/iot/regionInfo/queryRegionTreeSync',
syncProject = '/iot/projectInfo/sync',
syncRegion = '/iot/regionInfo/sync',
syncRegionChildren = '/iot/regionInfo/syncChildren',
list = '/iot/regionInfo/list', list = '/iot/regionInfo/list',
sync = '/iot/regionInfo/sync', sync = '/iot/regionInfo/sync',
add = '/iot/regionInfo/add', add = '/iot/regionInfo/add',
@ -8,6 +13,32 @@ enum Api {
delete = '/iot/regionInfo/delete', delete = '/iot/regionInfo/delete',
} }
/**
*
* @param params
*/
export const queryProjectTreeSync = (params?) => defHttp.get({ url: Api.queryProjectTreeSync, params });
/**
*
* @param params
*/
export const queryRegionTreeSync = (params?) => defHttp.get({ url: Api.queryRegionTreeSync, params });
/**
*
* @param params
*/
export const syncProject = (params?) => defHttp.get({ url: Api.syncProject, params });
/**
*
* @param params
*/
export const syncRegion = (params?) => defHttp.get({ url: Api.syncRegion, params });
/** /**
* *
* @param params * @param params

View File

@ -127,8 +127,3 @@ export const formSchema: FormSchema[] = [
dynamicDisabled: true dynamicDisabled: true
}, },
]; ];
// 项目基础表单
export const projectFormSchema: FormSchema[] = [
];

View File

@ -34,20 +34,7 @@
showActionButtonGroup: false showActionButtonGroup: false
}); });
// const categoryOptions = computed(() => {
// if (!!props?.data?.parentId) {
// return orgCategoryOptions.child;
// } else {
// return orgCategoryOptions.root;
// }
// });
onMounted(() => { onMounted(() => {
//
updateSchema([
{ field: 'parentId', componentProps: { disabled: true } },
{ field: 'orgCode', componentProps: { disabled: true } },
]);
// data // data
watch( watch(
() => props.data, () => props.data,

View File

@ -2,10 +2,10 @@
<a-card :bordered="false" style="height: 100%"> <a-card :bordered="false" style="height: 100%">
<a-spin :spinning="syncoading"> <a-spin :spinning="syncoading">
<div class="j-table-operator" style="width: 100%"> <div class="j-table-operator" style="width: 100%">
<!-- <a-button preIcon="ant-design:sync-outlined" @click="loadRootTreeData">刷新</a-button>--> <a-button preIcon="ant-design:sync-outlined" @click="loadRootTreeData">刷新</a-button>
<a-button type="primary" preIcon="ant-design:plus-outlined" @click="syncProjectInfo">新增</a-button> <a-button type="primary" preIcon="ant-design:plus-outlined" @click="addProjectInfo">新增</a-button>
<a-button preIcon="ant-design:sync-outlined" @click="syncProjectInfo">同步</a-button> <a-button preIcon="ant-design:sync-outlined" @click="syncProjectInfo">同步</a-button>
<a-button type="primary" preIcon="ant-design:plus-outlined" @click="syncProjectInfo">新增下级</a-button> <a-button type="primary" preIcon="ant-design:plus-outlined" @click="addRegionInfo">新增下级</a-button>
<template v-if="currentRegion !=null"> <template v-if="currentRegion !=null">
<a-button preIcon="ant-design:sync-outlined" @click="syncRegionInfo">同步下级</a-button> <a-button preIcon="ant-design:sync-outlined" @click="syncRegionInfo">同步下级</a-button>
</template> </template>
@ -39,7 +39,7 @@
import { useMessage } from '/@/hooks/web/useMessage'; import { useMessage } from '/@/hooks/web/useMessage';
import { useMethods } from '/@/hooks/system/useMethods'; import { useMethods } from '/@/hooks/system/useMethods';
const { createMessage } = useMessage(); const { createMessage } = useMessage();
import { queryProjectTreeSync, queryRegionTreeSync, syncProject, syncRegion } from '@/views/iot/tplink/camera/camera.api'; import { queryProjectTreeSync, queryRegionTreeSync, syncProject, syncRegion, syncRegionChildren } from '@/views/iot/tplink/region/RegionInfo.api';
const emit = defineEmits(['select', 'rootTreeData']); const emit = defineEmits(['select', 'rootTreeData']);
const syncoading = ref<boolean>(false); const syncoading = ref<boolean>(false);
@ -179,11 +179,11 @@
/** /**
* 同步项目 * 同步项目
*/ */
// async function syncProjectInfo(){ async function syncProjectInfo(){
// syncoading.value = true; syncoading.value = true;
// await syncProject(); await syncProject();
// await loadRootTreeData(); await loadRootTreeData();
// } }
/** /**
* 同步区域 * 同步区域
@ -198,8 +198,13 @@
projectId: data.projectId, projectId: data.projectId,
regionId: data.regionId regionId: data.regionId
}; };
syncoading.value = true; if(data.regionId == null){
await syncRegion(record); await syncRegion(record);
}else{
await syncRegionChildren(record);
}
syncoading.value = true;
await loadRootTreeData(); await loadRootTreeData();
} }

View File

@ -5,14 +5,17 @@
</a-col> </a-col>
<a-col :xl="12" :lg="24" :md="24" style="margin-bottom: 10px"> <a-col :xl="12" :lg="24" :md="24" style="margin-bottom: 10px">
<div style="height: 100%;" class="form-content"> <div style="height: 100%;" class="form-content">
<a-tabs v-show="regionData != null" defaultActiveKey="base-info"> <a-tabs v-show="nodeData != null" defaultActiveKey="base-info">
<a-tab-pane tab="基本信息" key="base-info" forceRender style="position: relative"> <a-tab-pane tab="基本信息" key="base-info" forceRender style="position: relative">
<div style="padding: 20px"> <div style="padding: 20px" v-show="nodeData.regionId != null">
<RegionForm :data="regionData" :rootTreeData="rootTreeData" @success="onSuccess" /> <RegionForm :data="nodeData" :rootTreeData="rootTreeData" @success="onSuccess" />
</div>
<div style="padding: 20px" v-show="nodeData.regionId == null">
<ProjectForm :data="nodeData" :rootTreeData="rootTreeData" @success="onSuccess" />
</div> </div>
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
<div v-show="regionData == null" style="padding-top: 40px"> <div v-show="nodeData == null" style="padding-top: 40px">
<a-empty description="请选择区域" /> <a-empty description="请选择区域" />
</div> </div>
</div> </div>
@ -25,22 +28,27 @@
import { useDesign } from '/@/hooks/web/useDesign'; import { useDesign } from '/@/hooks/web/useDesign';
import RegionLeftTree from './components/RegionLeftTree.vue' import RegionLeftTree from './components/RegionLeftTree.vue'
import RegionForm from "@/views/iot/tplink/region/components/RegionForm.vue"; import RegionForm from "@/views/iot/tplink/region/components/RegionForm.vue";
import ProjectForm from "@/views/iot/tplink/project/components/ProjectForm.vue";
// ref // ref
const leftTree = ref(); const leftTree = ref();
// //
const regionData = ref({}); const nodeData = ref({});
const rootTreeData = ref<any[]>([]); const rootTreeData = ref<any[]>([]);
// //
function onTreeSelect(data) { function onTreeSelect(data) {
console.log('onTreeSelect: ', data); console.log('onTreeSelect: ', data);
regionData.value = data; nodeData.value = data;
} }
// rootTreeData // rootTreeData
function onRootTreeData(data) { function onRootTreeData(data) {
rootTreeData.value = data; rootTreeData.value = data;
} }
function onSuccess() {
leftTree.value.loadRootTreeData();
}
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>