Merge branch 'master' of http://47.115.223.229:8888/yangjun/hldy_vue
This commit is contained in:
commit
a2e32fac92
|
@ -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 });
|
||||||
};
|
};
|
||||||
|
|
|
@ -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>
|
|
@ -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();
|
||||||
//刷新列表
|
//刷新列表
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -127,8 +127,3 @@ export const formSchema: FormSchema[] = [
|
||||||
dynamicDisabled: true
|
dynamicDisabled: true
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
// 项目基础表单
|
|
||||||
export const projectFormSchema: FormSchema[] = [
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in New Issue