提交 游客权限配置
This commit is contained in:
@@ -8,3 +8,28 @@ export function getDeviceDataTrend(data: any) {
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 查询游客配置
|
||||
export const getVisitorConfig = () => {
|
||||
return createAxios({
|
||||
url: '/cs-device-boot/csTouristData/queryAll',
|
||||
method: 'POST'
|
||||
})
|
||||
}
|
||||
|
||||
// 更新游客配置
|
||||
export const updateVisitorConfig = (data: any) => {
|
||||
return createAxios({
|
||||
url: '/cs-device-boot/csTouristData/add',
|
||||
method: 'POST',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
// * 根据用户获取营销数据
|
||||
export const queryByUseId = (data: any) => {
|
||||
return createAxios({
|
||||
url: 'cs-device-boot/csMarketData/queryByUseId',
|
||||
method: 'POST',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
@@ -29,3 +29,14 @@ export function refreshToken(): Promise<any> {
|
||||
username: adminInfo.username
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取营销用户列表
|
||||
* @returns {AxiosPromise}
|
||||
*/
|
||||
export const getMarketList = () => {
|
||||
return createAxios({
|
||||
url: '/user-boot/user/getMarketList',
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
<template>
|
||||
<Tree ref="treRef" :data="tree" />
|
||||
<Tree
|
||||
ref="treRef"
|
||||
@check-change="handleCheckChange"
|
||||
:default-checked-keys="defaultCheckedKeys"
|
||||
:show-checkbox="props.showCheckbox"
|
||||
:data="tree"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
@@ -10,7 +16,18 @@ import { useConfig } from '@/stores/config'
|
||||
defineOptions({
|
||||
name: 'govern/deviceTree'
|
||||
})
|
||||
const emit = defineEmits(['init'])
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
showCheckbox?: boolean
|
||||
defaultCheckedKeys?: any
|
||||
}>(),
|
||||
{
|
||||
showCheckbox: false,
|
||||
defaultCheckedKeys: []
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits(['init', 'checkChange'])
|
||||
const config = useConfig()
|
||||
const tree = ref()
|
||||
const treRef = ref()
|
||||
@@ -42,4 +59,11 @@ getDeviceTree().then(res => {
|
||||
})
|
||||
})
|
||||
})
|
||||
const handleCheckChange = (data: any, checked: any, indeterminate: any) => {
|
||||
emit('checkChange', {
|
||||
data,
|
||||
checked,
|
||||
indeterminate
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
29
src/components/tree/govern/getMarketList.vue
Normal file
29
src/components/tree/govern/getMarketList.vue
Normal file
@@ -0,0 +1,29 @@
|
||||
<template>
|
||||
<Tree ref="treRef" :data="tree" />
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { getMarketList } from '@/api/user'
|
||||
import Tree from '../index.vue'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { ref, reactive, nextTick } from 'vue'
|
||||
const config = useConfig()
|
||||
const tree = ref()
|
||||
const treRef = ref()
|
||||
const emit = defineEmits(['selectUser'])
|
||||
getMarketList().then((res: any) => {
|
||||
if (res.code === 'A0000') {
|
||||
tree.value = res.data.map((item: any) => {
|
||||
return {
|
||||
...item,
|
||||
icon: 'el-icon-User',
|
||||
color: 'royalblue'
|
||||
}
|
||||
})
|
||||
emit('selectUser', tree.value[0])
|
||||
nextTick(() => {
|
||||
treRef.value.treeRef.setCurrentKey(tree.value[0].id)
|
||||
})
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
71
src/views/govern/device/disposition/index.vue
Normal file
71
src/views/govern/device/disposition/index.vue
Normal file
@@ -0,0 +1,71 @@
|
||||
<template>
|
||||
<div class="default-main device-manage" :style="{ height: pageHeight.height }" v-loading="loading">
|
||||
<GetMarketList @node-click="selectUser" @selectUser="selectUser"></GetMarketList>
|
||||
<div class="device-manage-right" :style="{ height: tableHeight }">
|
||||
<el-descriptions title="用户基本信息" class="mb10" :column="2" border>
|
||||
<template #extra>
|
||||
<el-button type="primary" icon="el-icon-Plus" @click="getMarketEnginner">添加工程</el-button>
|
||||
</template>
|
||||
<el-descriptions-item label="名称">
|
||||
{{ user.name }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="手机号">
|
||||
{{ user.phone }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<vxe-table v-bind="defaultAttribute" :data="tableData" height="auto" style="width: 100%">
|
||||
<vxe-column field="enginerName" title="工程名称"></vxe-column>
|
||||
|
||||
<vxe-column field="deviceName" title="操作"></vxe-column>
|
||||
</vxe-table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
defineOptions({
|
||||
name: 'govern/disposition/index'
|
||||
})
|
||||
import { defaultAttribute } from '@/components/table/defaultAttribute'
|
||||
import GetMarketList from '@/components/tree/govern/getMarketList.vue'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import { queryByUseId } from '@/api/cs-harmonic-boot/datatrend'
|
||||
import { ref, onMounted } from 'vue'
|
||||
|
||||
const pageHeight = mainHeight(20)
|
||||
const loading = ref(true)
|
||||
|
||||
const tableHeight = mainHeight(20).height
|
||||
const user: any = ref({})
|
||||
const tableData = ref([])
|
||||
|
||||
const selectUser = (e: any) => {
|
||||
user.value = e
|
||||
loading.value = true
|
||||
queryByUseId({
|
||||
userId: e.id
|
||||
}).then(res => {
|
||||
loading.value = false
|
||||
tableData.value = res.data
|
||||
})
|
||||
}
|
||||
const getMarketEnginner = () => {}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.device-manage {
|
||||
display: flex;
|
||||
|
||||
&-right {
|
||||
overflow: hidden;
|
||||
flex: 1;
|
||||
padding: 10px 10px 10px 0;
|
||||
.el-descriptions__header {
|
||||
height: 36px;
|
||||
margin-bottom: 7px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
97
src/views/govern/device/tourist/index.vue
Normal file
97
src/views/govern/device/tourist/index.vue
Normal file
@@ -0,0 +1,97 @@
|
||||
<template>
|
||||
<div class="default-main device-manage" :style="{ height: pageHeight.height }" v-loading="loading">
|
||||
<DeviceTree
|
||||
:showCheckbox="true"
|
||||
:default-checked-keys="defaultCheckedKeys"
|
||||
@checkChange="checkChange"
|
||||
></DeviceTree>
|
||||
<div class="device-manage-right" :style="{ height: tableHeight }">
|
||||
<vxe-table v-bind="defaultAttribute" :data="tableData" height="auto" style="width: 100%">
|
||||
<vxe-column field="enginerName" title="工程名称"></vxe-column>
|
||||
<vxe-column field="projectName" title="项目名称"></vxe-column>
|
||||
<vxe-column field="deviceName" title="装置名称"></vxe-column>
|
||||
</vxe-table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
defineOptions({
|
||||
name: 'govern/tourist/index'
|
||||
})
|
||||
import { defaultAttribute } from '@/components/table/defaultAttribute'
|
||||
import DeviceTree from '@/components/tree/govern/deviceTree.vue'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import { getVisitorConfig, updateVisitorConfig } from '@/api/cs-harmonic-boot/datatrend'
|
||||
import { ref, onMounted } from 'vue'
|
||||
|
||||
const pageHeight = mainHeight(20)
|
||||
const loading = ref(true)
|
||||
|
||||
const tableHeight = mainHeight(20).height
|
||||
const defaultCheckedKeys: any = ref([])
|
||||
const tableData = ref([])
|
||||
|
||||
const checkChange = (data: any) => {
|
||||
if (data.data.level === 2) {
|
||||
if (data.checked) {
|
||||
defaultCheckedKeys.value.push(data.data.id)
|
||||
} else {
|
||||
defaultCheckedKeys.value.splice(defaultCheckedKeys.value.indexOf(data.data.id), 1)
|
||||
}
|
||||
loading.value = true
|
||||
updateVisitorConfigs()
|
||||
}
|
||||
}
|
||||
const updateVisitorConfigs = () => {
|
||||
const result = Array.from(new Set(defaultCheckedKeys.value))
|
||||
updateVisitorConfig(
|
||||
result.map(item => {
|
||||
return {
|
||||
deviceId: item
|
||||
}
|
||||
})
|
||||
).then((res: any) => {
|
||||
if (res.code === 'A0000') {
|
||||
getVisitorConfigs()
|
||||
}
|
||||
})
|
||||
}
|
||||
const getVisitorConfigs = () => {
|
||||
getVisitorConfig().then((res:any) => {
|
||||
if (res.code === 'A0000') {
|
||||
tableData.value = res.data
|
||||
loading.value = false
|
||||
if (defaultCheckedKeys.value.length > 0) return
|
||||
defaultCheckedKeys.value = [] // 清空
|
||||
res.data.forEach((item:any) => {
|
||||
defaultCheckedKeys.value.push(item.deviceId)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// if (!adminInfo.token) return router.push({ name: 'login' })
|
||||
|
||||
getVisitorConfigs()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.device-manage {
|
||||
display: flex;
|
||||
|
||||
&-right {
|
||||
overflow: hidden;
|
||||
flex: 1;
|
||||
padding: 10px 10px 10px 0;
|
||||
.el-descriptions__header {
|
||||
height: 36px;
|
||||
margin-bottom: 7px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user