Browse Source

部门,数据迁移

master
xh 2 days ago
parent
commit
bfe19d7ff9
  1. 24
      web/src/api/gas/handdetector/index.ts
  2. 112
      web/src/views/gas/handdetector/DataMigrateForm.vue
  3. 26
      web/src/views/gas/handdetector/index.vue
  4. 6
      web/src/views/gas/personnel/index.vue
  5. 4
      web/vite.config.ts

24
web/src/api/gas/handdetector/index.ts

@ -1,6 +1,5 @@
import request from '@/config/axios'
import request from '@/config/axios'
import qs from 'qs'
/** GAS手持探测器信息 */
export interface HandDetector {
id?: number // 主键ID
@ -41,10 +40,13 @@ export interface HandDetectorData extends HandDetector {
onlineStatus?: number //在线状态 (0:离线;1:在线)
statusStr?: string // 状态字符串 (normal, offline, gas_1,gas_2, battery_1, fence_1)
statusLabel?: string // 状态字符串 (正常, 离线, 气体报警, 电池报警, 围栏报警)
statusColor?: string // 状态颜色
statusColor?: string // 状态颜色
statusPriority?: number // 状态优先级, 越小优先级越高
}
export interface DataMigrateParams {
idList: number[]
tenantId?: number
}
// GAS手持探测器 API
export const HandDetectorApi = {
// 查询GAS手持探测器分页
@ -84,12 +86,22 @@ export const HandDetectorApi = {
// 综合监控数据展示
getMonitor: async () => {
return await request.get<{deviceCount: number}>({
return await request.get<{ deviceCount: number }>({
url: `/gas/hand-detector/getMonitor`
})
},
// 查询GAS手持探测器所有列表
getListAll: async () => {
return await request.get<HandDetector[]>({ url: `/gas/hand-detector/getListAll` })
},
// 数据迁移
dataMigrate: async (data: DataMigrateParams) => {
const params2 = {
idList: data.idList.join(','),
tenantId: data.tenantId
}
return await request.post({ url: `/gas/hand-detector/dataMigrate`,data })
// return await request.get({ url: `/gas/hand-detector/dataMigrate`+ qs.stringify(data, { indices: false }) })
}
}

112
web/src/views/gas/handdetector/DataMigrateForm.vue

@ -0,0 +1,112 @@
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible" :scroll="true">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
v-loading="formLoading"
>
<el-form-item label="租户" prop="tenantId">
<el-select v-model="formData.tenantId" clearable placeholder="请选择租户">
<el-option
v-for="person in TenantList"
:key="person.id"
:label="person.name"
:value="person.id"
/>
</el-select>
</el-form-item>
</el-form>
{{ formData }}
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import { HandDetectorApi, HandDetector, DataMigrateParams } from '@/api/gas/handdetector'
import { getTenantList, TenantVO } from '@/api/system/tenant'
/** GAS手持探测器 表单 */
defineOptions({ name: 'DataMigrateForm' })
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const props = defineProps({
// ids: {
// type: Array as PropType<number[]>,
// required: true
// }
})
const formData = ref<DataMigrateParams>({
idList: [],
tenantId: undefined
})
const formRules = reactive({
idList: [{ required: true, message: '请选择手持探测器', trigger: 'blur' }],
tenantId: [{ required: true, message: '请选择租户', trigger: 'blur' }]
})
const formRef = ref() // Ref
/** 打开弹窗 */
const open = async (type: string, idList?: number[]) => {
dialogVisible.value = true
dialogTitle.value ='数据迁移到租户'
formType.value = type
resetForm()
//
getTenantListFn()
if (idList && idList.length) {
formData.value.idList = idList
}
}
defineExpose({ open }) // open
const TenantList = ref<TenantVO[]>([])
//
function getTenantListFn() {
getTenantList().then((data) => {
TenantList.value = data || []
})
}
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
await formRef.value.validate()
//
formLoading.value = true
try {
const data = formData.value
// data.fenceIds = data.fenceIdsArray?.join(',')
await HandDetectorApi.dataMigrate(data)
message.success(t('common.createSuccess'))
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
idList: [],
tenantId: undefined
}
formRef.value?.resetFields()
}
</script>

26
web/src/views/gas/handdetector/index.vue

@ -31,7 +31,7 @@
<el-cascader
class="!w-240px"
v-model="queryParams.deptId"
:options="deptList"
:options="deptTree"
:props="{
checkStrictly: true,
label: 'name',
@ -64,6 +64,15 @@
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
<el-button
type="success"
plain
@click="dataMigrate"
v-hasPermi="['gas:hand-detector:dataMigrate']"
>
<Icon icon="ep:download" class="mr-5px" /> 数据迁移
</el-button>
<el-button
type="danger"
plain
:disabled="isEmpty(checkedIds)"
@ -169,6 +178,8 @@
<!-- 表单弹窗添加/修改 -->
<HandDetectorForm ref="formRef" @success="getList" :fences="fences" :gasTypes="gasTypes" />
<!-- 数据迁移弹窗 -->
<DataMigrateForm ref="dataMigrateFormRef" @success="getList" />
</template>
<script setup lang="ts">
@ -178,6 +189,7 @@ import { HandDetectorApi, HandDetector } from '@/api/gas/handdetector'
import { DeptVO, getSimpleDeptList } from '@/api/system/dept'
import HandDetectorForm from './HandDetectorForm.vue'
import DataMigrateForm from './DataMigrateForm.vue'
import { DICT_TYPE } from '@/utils/dict'
import { Fence } from '@/api/gas/fence'
import type { Type } from '@/api/gas/gastype'
@ -206,9 +218,11 @@ const exportLoading = ref(false) // 导出的加载中
const fences = ref<Fence[]>([])
const gasTypes = ref<Type[]>([])
const deptList = ref<DeptVO[]>([]) //
const deptTree = ref<DeptVO[]>([]) //
function getDeptList() {
getSimpleDeptList().then((res) => {
deptList.value = handleTree(res || [])
deptTree.value = handleTree(res || [])
deptList.value = res
})
}
@ -294,6 +308,14 @@ const handleExport = async () => {
exportLoading.value = false
}
}
const dataMigrateFormRef = ref()
const dataMigrate = async () => {
if (checkedIds.value.length === 0) {
message.warning('请选择要迁移的数据')
return
}
dataMigrateFormRef.value.open('migrate', checkedIds.value)
}
const getAllFences = async () => {
fences.value = await handDetectorStore.getAllFences()
}

6
web/src/views/gas/personnel/index.vue

@ -30,7 +30,7 @@
<el-cascader
class="!w-240px"
v-model="queryParams.deptId"
:options="deptList"
:options="deptTree"
:props="{
checkStrictly: true,
label: 'name',
@ -244,9 +244,11 @@ const exportLoading = ref(false) // 导出的加载中
const userList = ref<UserVO[]>([]) //
const deptList = ref<DeptVO[]>([]) //
const deptTree = ref<DeptVO[]>([]) //
function getDeptList() {
getSimpleDeptList().then((res) => {
deptList.value = handleTree(res || [])
deptList.value = res
deptTree.value = handleTree(res || [])
})
}
function getUserList() {

4
web/vite.config.ts

@ -35,8 +35,8 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
},
// 服务端渲染
server: {
port: env.VITE_PORT, // 端口号
host: "0.0.0.0",
// port: env.VITE_PORT, // 端口号
// host: "0.0.0.0",
open: env.VITE_OPEN === 'true',
// 本地跨域代理. 目前注释的原因:暂时没有用途,server 端已经支持跨域
// proxy: {

Loading…
Cancel
Save