Commit 9160be1976b5fa1e4d548fa18a2d0fafb56583dc
1 parent
b1f9f93e
feat(src/packages/): 信息下更多下加载组态新增是否公开开关'
Showing
3 changed files
with
90 additions
and
44 deletions
| ... | ... | @@ -7,7 +7,8 @@ enum Api { |
| 7 | 7 | DOWNLOAD = '/oss/download_file/', |
| 8 | 8 | AREALIST = '/area/list', |
| 9 | 9 | PLATFORM = '/platform/get', |
| 10 | - CONFIGURATION = '/configuration/center' | |
| 10 | + CONFIGURATION = '/configuration/center', | |
| 11 | + CONFIGURATION_SHARE = '/configuration/center/share/' | |
| 11 | 12 | } |
| 12 | 13 | |
| 13 | 14 | export const getDictItemByCode = (value: string) => { |
| ... | ... | @@ -45,3 +46,10 @@ export const getPlatformInfo = () => defHttp.get({ url: Api.PLATFORM }) |
| 45 | 46 | export const getConfigurationList = (params: object) => { |
| 46 | 47 | return defHttp.get({ url: `${Api.CONFIGURATION}`, params }) |
| 47 | 48 | } |
| 49 | +//组态设置是否公开或私有 | |
| 50 | +export const setConfigurationIsShare = (params: string,isShare:boolean,data:object) => { | |
| 51 | + return defHttp.post({ | |
| 52 | + url: `${Api.CONFIGURATION_SHARE}${params}?isShare=${isShare}`, | |
| 53 | + data | |
| 54 | + }) | |
| 55 | +} | ... | ... |
| 1 | -import { PublicConfigClass } from '@/packages/public' | |
| 2 | -import { CreateComponentType } from '@/packages/index.d' | |
| 3 | -import { chartInitConfig } from '@/settings/designSetting' | |
| 4 | -import { OverrideILoadConfigurationframeConfig } from './index' | |
| 1 | +import {PublicConfigClass} from '@/packages/public' | |
| 2 | +import {CreateComponentType} from '@/packages/index.d' | |
| 3 | +import {chartInitConfig} from '@/settings/designSetting' | |
| 4 | +import {OverrideILoadConfigurationframeConfig} from './index' | |
| 5 | 5 | import cloneDeep from 'lodash/cloneDeep' |
| 6 | 6 | |
| 7 | +export const enum shareEnum { | |
| 8 | + PRIVATE_VIEW = "PRIVATE_VIEW", | |
| 9 | +} | |
| 10 | + | |
| 7 | 11 | export const option = { |
| 8 | - // 网站路径 | |
| 9 | - dataset: '', | |
| 10 | - // 圆角 | |
| 11 | - borderRadius: 10, | |
| 12 | - pages: { | |
| 13 | - page: 1, | |
| 14 | - pageSize: 10 | |
| 15 | - }, | |
| 16 | - color: 'black' | |
| 12 | + // 网站路径 | |
| 13 | + dataset: '', | |
| 14 | + // 圆角 | |
| 15 | + borderRadius: 10, | |
| 16 | + pages: { | |
| 17 | + page: 1, | |
| 18 | + pageSize: 10 | |
| 19 | + }, | |
| 20 | + color: 'black', | |
| 21 | + isShare: false, | |
| 17 | 22 | } |
| 18 | 23 | |
| 19 | 24 | export default class Config extends PublicConfigClass implements CreateComponentType { |
| 20 | - public key = OverrideILoadConfigurationframeConfig.key | |
| 21 | - public attr = { ...chartInitConfig, w: 1200, h: 800, zIndex: -1 } | |
| 22 | - public chartConfig = cloneDeep(OverrideILoadConfigurationframeConfig) | |
| 23 | - public option = cloneDeep(option) | |
| 25 | + public key = OverrideILoadConfigurationframeConfig.key | |
| 26 | + public attr = {...chartInitConfig, w: 1200, h: 800, zIndex: -1} | |
| 27 | + public chartConfig = cloneDeep(OverrideILoadConfigurationframeConfig) | |
| 28 | + public option = cloneDeep(option) | |
| 24 | 29 | } | ... | ... |
| ... | ... | @@ -2,16 +2,22 @@ |
| 2 | 2 | <collapse-item name="属性" :expanded="true"> |
| 3 | 3 | <setting-item-box name="路径" :alone="true"> |
| 4 | 4 | <setting-item name="请选择要加载的组态"> |
| 5 | - <n-select filterable size="small" v-model:value="optionData.dataset" :options="configurationOptions" /> | |
| 5 | + <n-select label-in-value @change="handleUpdateValue" filterable size="small" v-model:value="optionData.dataset" | |
| 6 | + :options="configurationOptions"/> | |
| 7 | + </setting-item> | |
| 8 | + </setting-item-box> | |
| 9 | + <setting-item-box name="是否公开" :alone="true"> | |
| 10 | + <setting-item name=""> | |
| 11 | + <n-switch @change="handleChange" v-model:value="optionData.isShare" size="small"/> | |
| 6 | 12 | </setting-item> |
| 7 | 13 | </setting-item-box> |
| 8 | 14 | <setting-item-box name="样式"> |
| 9 | 15 | <setting-item name="圆角"> |
| 10 | 16 | <n-input-number |
| 11 | - v-model:value="optionData.borderRadius" | |
| 12 | - size="small" | |
| 13 | - :min="0" | |
| 14 | - placeholder="圆角" | |
| 17 | + v-model:value="optionData.borderRadius" | |
| 18 | + size="small" | |
| 19 | + :min="0" | |
| 20 | + placeholder="圆角" | |
| 15 | 21 | ></n-input-number> |
| 16 | 22 | </setting-item> |
| 17 | 23 | </setting-item-box> |
| ... | ... | @@ -21,11 +27,11 @@ |
| 21 | 27 | </setting-item> |
| 22 | 28 | <setting-item name="页数"> |
| 23 | 29 | <n-input-number |
| 24 | - disabled | |
| 25 | - v-model:value="optionData.pages.pageSize" | |
| 26 | - size="small" | |
| 27 | - :min="10" | |
| 28 | - placeholder="页数" | |
| 30 | + disabled | |
| 31 | + v-model:value="optionData.pages.pageSize" | |
| 32 | + size="small" | |
| 33 | + :min="10" | |
| 34 | + placeholder="页数" | |
| 29 | 35 | ></n-input-number> |
| 30 | 36 | </setting-item> |
| 31 | 37 | </setting-item-box> |
| ... | ... | @@ -34,17 +40,18 @@ |
| 34 | 40 | <n-color-picker size="small" :modes="['hex']" v-model:value="optionData.color"></n-color-picker> |
| 35 | 41 | </SettingItem> |
| 36 | 42 | <SettingItem> |
| 37 | - <n-button size="small" @click="optionData.color = 'black'"> 恢复默认 </n-button> | |
| 43 | + <n-button size="small" @click="optionData.color = 'black'"> 恢复默认</n-button> | |
| 38 | 44 | </SettingItem> |
| 39 | 45 | </setting-item-box> |
| 40 | 46 | </collapse-item> |
| 41 | 47 | </template> |
| 42 | 48 | |
| 43 | 49 | <script setup lang="ts"> |
| 44 | -import { PropType, onMounted, ref, watch } from 'vue' | |
| 45 | -import { option } from './config' | |
| 46 | -import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting' | |
| 47 | -import { getConfigurationList } from '@/api/external/common/index' | |
| 50 | +import {PropType, onMounted, ref, watch} from 'vue' | |
| 51 | +import {option, shareEnum} from './config' | |
| 52 | +import {CollapseItem, SettingItemBox, SettingItem} from '@/components/Pages/ChartItemSetting' | |
| 53 | +import {getConfigurationList, setConfigurationIsShare} from '@/api/external/common/index' | |
| 54 | +import {SelectOption} from 'naive-ui' | |
| 48 | 55 | |
| 49 | 56 | const props = defineProps({ |
| 50 | 57 | optionData: { |
| ... | ... | @@ -55,25 +62,51 @@ const props = defineProps({ |
| 55 | 62 | |
| 56 | 63 | const configurationOptions = ref([]) |
| 57 | 64 | |
| 65 | +const configurationId = ref('') | |
| 66 | + | |
| 58 | 67 | const getConfigurationOptions = async (params: object) => { |
| 59 | - const { items } = await getConfigurationList(params) | |
| 68 | + const {items} = await getConfigurationList(params) | |
| 60 | 69 | if (items) { |
| 61 | - configurationOptions.value = items.map((item: Record<string, string>) => ({ label: item.name, value: item.id })) | |
| 70 | + configurationOptions.value = items.map((item: SelectOption) => ({ | |
| 71 | + label: item.name, | |
| 72 | + value: item.id, | |
| 73 | + viewType: item.viewType | |
| 74 | + })) | |
| 62 | 75 | } |
| 63 | 76 | } |
| 64 | 77 | |
| 65 | 78 | watch( |
| 66 | - () => props.optionData.pages, | |
| 67 | - (newData: any) => { | |
| 68 | - getConfigurationOptions({ page: newData.page, pageSize: newData.pageSize }) | |
| 69 | - }, | |
| 70 | - { | |
| 71 | - deep: true, | |
| 72 | - immediate: true | |
| 73 | - } | |
| 79 | + () => props.optionData.pages, | |
| 80 | + (newData: any) => { | |
| 81 | + getConfigurationOptions({page: newData.page, pageSize: newData.pageSize}) | |
| 82 | + }, | |
| 83 | + { | |
| 84 | + deep: true, | |
| 85 | + immediate: true | |
| 86 | + } | |
| 74 | 87 | ) |
| 75 | 88 | |
| 76 | 89 | onMounted(() => { |
| 77 | - getConfigurationOptions({ page: props.optionData.pages.page, pageSize: props.optionData.pages.pageSize }) | |
| 90 | + getConfigurationOptions({page: props.optionData.pages.page, pageSize: props.optionData.pages.pageSize}) | |
| 78 | 91 | }) |
| 92 | + | |
| 93 | +const handleUpdateValue = (value: string, options: SelectOption) => { | |
| 94 | + const {viewType} = options | |
| 95 | + configurationId.value = value | |
| 96 | + if (viewType === shareEnum.PRIVATE_VIEW) { | |
| 97 | + props.optionData.isShare = false | |
| 98 | + } else { | |
| 99 | + props.optionData.isShare = true | |
| 100 | + } | |
| 101 | +} | |
| 102 | + | |
| 103 | +const handleChange = async (value: boolean) => { | |
| 104 | + const res = await setConfigurationIsShare(!configurationId.value ? props.optionData.dataset : configurationId.value, value, { | |
| 105 | + isShare: value | |
| 106 | + }) | |
| 107 | + if (res) { | |
| 108 | + window.$message.success('操作成功!') | |
| 109 | + await getConfigurationOptions({page: props.optionData.pages.page, pageSize: props.optionData.pages.pageSize}) | |
| 110 | + } | |
| 111 | +} | |
| 79 | 112 | </script> | ... | ... |