Commit e2255bd04bf1f025dfae57074c5d7b46083c7c67

Authored by xp.Huang
2 parents 73ce7b23 7bc12e52

Merge branch 'fix/configuration-center' into 'main_dev'

fix: 修复组态权限区分

See merge request yunteng/thingskit-front!982
@@ -13,13 +13,14 @@ @@ -13,13 +13,14 @@
13 <script lang="ts"> 13 <script lang="ts">
14 import { defineComponent, ref, computed, unref } from 'vue'; 14 import { defineComponent, ref, computed, unref } from 'vue';
15 import { BasicForm, useForm } from '/@/components/Form'; 15 import { BasicForm, useForm } from '/@/components/Form';
16 - import { formSchema, PC_DEFAULT_CONTENT, PHONE_DEFAULT_CONTENT, Platform } from './center.data'; 16 + import { formSchema } from './center.data';
17 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; 17 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
18 import { useMessage } from '/@/hooks/web/useMessage'; 18 import { useMessage } from '/@/hooks/web/useMessage';
19 import { saveOrUpdateConfigurationCenter } from '/@/api/configuration/center/configurationCenter'; 19 import { saveOrUpdateConfigurationCenter } from '/@/api/configuration/center/configurationCenter';
20 import { FileItem } from '/@/components/Form/src/components/ApiUpload.vue'; 20 import { FileItem } from '/@/components/Form/src/components/ApiUpload.vue';
21 import { buildUUID } from '/@/utils/uuid'; 21 import { buildUUID } from '/@/utils/uuid';
22 import { getDeviceProfile } from '/@/api/alarm/position'; 22 import { getDeviceProfile } from '/@/api/alarm/position';
  23 + import { PC_DEFAULT_CONTENT, PHONE_DEFAULT_CONTENT, Platform } from '../center/center.data';
23 24
24 export default defineComponent({ 25 export default defineComponent({
25 name: 'ConfigurationDrawer', 26 name: 'ConfigurationDrawer',
@@ -5,28 +5,17 @@ import { uploadThumbnail } from '/@/api/configuration/center/configurationCenter @@ -5,28 +5,17 @@ import { uploadThumbnail } from '/@/api/configuration/center/configurationCenter
5 import { useComponentRegister } from '/@/components/Form'; 5 import { useComponentRegister } from '/@/components/Form';
6 import { OrgTreeSelect } from '../../common/OrgTreeSelect'; 6 import { OrgTreeSelect } from '../../common/OrgTreeSelect';
7 import { getDeviceProfile } from '/@/api/alarm/position'; 7 import { getDeviceProfile } from '/@/api/alarm/position';
  8 +import { Platform } from '../center/center.data';
8 9
9 useComponentRegister('OrgTreeSelect', OrgTreeSelect); 10 useComponentRegister('OrgTreeSelect', OrgTreeSelect);
10 -export enum Platform {  
11 - PHONE = 'phone',  
12 - PC = 'pc',  
13 -}  
14 11
15 -export enum ConfigurationPermission {  
16 - CREATE = 'api:yt:configuration:center:post',  
17 - UPDATE = 'api:yt:configuration:center:update',  
18 - DELETE = 'api:yt:configuration:center:delete',  
19 - DESIGN = 'api:yt:configuration:center:get_configuration_info:design',  
20 - PREVIEW = 'api:yt:configuration:center:get_configuration_info:preview',  
21 - SHARE = 'api:yt:configuration:center:share',  
22 - UN_SHARE = 'api:yt:configuration:center:monopoly', 12 +export enum ConfigurationTemplatePermission {
  13 + CREATE = 'api:yt:configuration:template:center:post',
  14 + UPDATE = 'api:yt:configuration:template:center:update',
  15 + DELETE = 'api:yt:configuration:template:center:delete',
  16 + DESIGN = 'api:yt:configuration:template:center:get_configuration_info:design',
  17 + PREVIEW = 'api:yt:configuration:template:center:get_configuration_info:preview',
23 } 18 }
24 -  
25 -export const PC_DEFAULT_CONTENT =  
26 - '<mxfile><diagram>dZHBDsIgDIafhvuEzOh5Tr142sEzGXWQsHVhmKFP7xbAidMT5fv/UtoSVrTuZHgvLyhAE5oJR9iBUMrybT4dM3l4stnTzJPGKBHYAir1hACj7a4EDInRImqr+hTW2HVQ24RxY3BMbTfUadWeN7ACVc31ml6VsPK7jVk4g2pkLJ3tgtLy6A5gkFzg+IFYSVhhEK2PWleAnscXB+Pzjn/U988MdPZHwhQsb0+XZEesfAE=</diagram></mxfile>';  
27 -  
28 -export const PHONE_DEFAULT_CONTENT =  
29 - '<mxfile><diagram>dZHBEoIgEEC/hru6lXU2q0snD50Z2YQZdB2k0fr6dMCMsU4sb9+ysDDI6uFseCuvJFCzJBIDgyNLkjjdw7hM5OnIYRc5UBklvLSAQr3Qw1l7KIFdIFoibVUbwpKaBksbMG4M9aF2Jx12bXmFK1CUXK/pTQkrHd3E24VfUFXSd04hdYmaz65/SCe5oP4LQc4gM0TWRfWQoZ5mN4/F1Z3+ZD/3MtjYHwVjsJw9boIPgvwN</diagram></mxfile>';  
30 // 表格列数据 19 // 表格列数据
31 export const columns: BasicColumn[] = [ 20 export const columns: BasicColumn[] = [
32 { 21 {
@@ -6,12 +6,11 @@ @@ -6,12 +6,11 @@
6 import { 6 import {
7 deleteConfigurationCenter, 7 deleteConfigurationCenter,
8 getPage, 8 getPage,
9 - shareConfiguration,  
10 } from '/@/api/configuration/center/configurationCenter'; 9 } from '/@/api/configuration/center/configurationCenter';
11 import { ConfigurationCenterItemsModal } from '/@/api/configuration/center/model/configurationCenterModal'; 10 import { ConfigurationCenterItemsModal } from '/@/api/configuration/center/model/configurationCenterModal';
12 import { PageWrapper } from '/@/components/Page'; 11 import { PageWrapper } from '/@/components/Page';
13 import { BasicForm, useForm } from '/@/components/Form'; 12 import { BasicForm, useForm } from '/@/components/Form';
14 - import { ConfigurationPermission, Platform, searchFormSchema } from './center.data'; 13 + import { searchFormSchema, ConfigurationTemplatePermission } from './center.data';
15 import { useMessage } from '/@/hooks/web/useMessage'; 14 import { useMessage } from '/@/hooks/web/useMessage';
16 import { Authority } from '/@/components/Authority'; 15 import { Authority } from '/@/components/Authority';
17 import ConfigurationCenterDrawer from './ConfigurationCenterDrawer.vue'; 16 import ConfigurationCenterDrawer from './ConfigurationCenterDrawer.vue';
@@ -22,10 +21,10 @@ @@ -22,10 +21,10 @@
22 import { usePermission } from '/@/hooks/web/usePermission'; 21 import { usePermission } from '/@/hooks/web/usePermission';
23 import { AuthIcon, CardLayoutButton } from '/@/components/Widget'; 22 import { AuthIcon, CardLayoutButton } from '/@/components/Widget';
24 import AuthDropDown from '/@/components/Widget/AuthDropDown.vue'; 23 import AuthDropDown from '/@/components/Widget/AuthDropDown.vue';
25 - import { ShareModal } from '/@/views/common/ShareModal';  
26 import { useRole } from '/@/hooks/business/useRole'; 24 import { useRole } from '/@/hooks/business/useRole';
27 import { Icon } from '/@/components/Icon'; 25 import { Icon } from '/@/components/Icon';
28 import { createScadaPageLink, ScadaModeEnum } from './help'; 26 import { createScadaPageLink, ScadaModeEnum } from './help';
  27 + import { Platform } from '../center/center.data';
29 28
30 const listColumn = ref(5); 29 const listColumn = ref(5);
31 30
@@ -102,11 +101,11 @@ @@ -102,11 +101,11 @@
102 const { hasPermission } = usePermission(); 101 const { hasPermission } = usePermission();
103 102
104 const getPreviewFlag = computed(() => { 103 const getPreviewFlag = computed(() => {
105 - return hasPermission(ConfigurationPermission.PREVIEW); 104 + return hasPermission(ConfigurationTemplatePermission.PREVIEW);
106 }); 105 });
107 106
108 const getDesignFlag = computed(() => { 107 const getDesignFlag = computed(() => {
109 - return hasPermission(ConfigurationPermission.DESIGN); 108 + return hasPermission(ConfigurationTemplatePermission.DESIGN);
110 }); 109 });
111 110
112 const handleCreateOrUpdate = (record?: ConfigurationCenterItemsModal) => { 111 const handleCreateOrUpdate = (record?: ConfigurationCenterItemsModal) => {
@@ -185,7 +184,7 @@ @@ -185,7 +184,7 @@
185 > 184 >
186 <template #header> 185 <template #header>
187 <div class="flex gap-3 justify-end"> 186 <div class="flex gap-3 justify-end">
188 - <Authority v-if="!isCustomerUser" :value="ConfigurationPermission.CREATE"> 187 + <Authority v-if="!isCustomerUser" :value="ConfigurationTemplatePermission.CREATE">
189 <Button type="primary" @click="handleCreateOrUpdate()">新增模板</Button> 188 <Button type="primary" @click="handleCreateOrUpdate()">新增模板</Button>
190 </Authority> 189 </Authority>
191 <CardLayoutButton v-model:value="listColumn" @change="handleCardLayoutChange" /> 190 <CardLayoutButton v-model:value="listColumn" @change="handleCardLayoutChange" />
@@ -225,7 +224,7 @@ @@ -225,7 +224,7 @@
225 <template class="ant-card-actions" #actions> 224 <template class="ant-card-actions" #actions>
226 <Tooltip v-if="!isCustomerUser" title="设计"> 225 <Tooltip v-if="!isCustomerUser" title="设计">
227 <AuthIcon 226 <AuthIcon
228 - :auth="ConfigurationPermission.DESIGN" 227 + :auth="ConfigurationTemplatePermission.DESIGN"
229 class="!text-lg" 228 class="!text-lg"
230 icon="ant-design:edit-outlined" 229 icon="ant-design:edit-outlined"
231 @click="handleDesign(item)" 230 @click="handleDesign(item)"
@@ -236,14 +235,14 @@ @@ -236,14 +235,14 @@
236 :dropMenuList="[ 235 :dropMenuList="[
237 { 236 {
238 text: '编辑', 237 text: '编辑',
239 - auth: ConfigurationPermission.UPDATE, 238 + auth: ConfigurationTemplatePermission.UPDATE,
240 icon: 'clarity:note-edit-line', 239 icon: 'clarity:note-edit-line',
241 event: '', 240 event: '',
242 onClick: handleCreateOrUpdate.bind(null, item), 241 onClick: handleCreateOrUpdate.bind(null, item),
243 }, 242 },
244 { 243 {
245 text: '删除', 244 text: '删除',
246 - auth: ConfigurationPermission.DELETE, 245 + auth: ConfigurationTemplatePermission.DELETE,
247 icon: 'ant-design:delete-outlined', 246 icon: 'ant-design:delete-outlined',
248 event: '', 247 event: '',
249 popconfirm: { 248 popconfirm: {
@@ -281,11 +280,6 @@ @@ -281,11 +280,6 @@
281 </List> 280 </List>
282 </section> 281 </section>
283 <ConfigurationCenterDrawer @register="registerDrawer" @success="getListData" /> 282 <ConfigurationCenterDrawer @register="registerDrawer" @success="getListData" />
284 - <ShareModal  
285 - @register="registerShareModal"  
286 - :shareApi="shareConfiguration"  
287 - @success="getListData"  
288 - />  
289 </PageWrapper> 283 </PageWrapper>
290 </template> 284 </template>
291 285
@@ -15,6 +15,7 @@ export const option: PublicPresetOptions = { @@ -15,6 +15,7 @@ export const option: PublicPresetOptions = {
15 [ComponentConfigFieldEnum.SHOW_TIME]: false, 15 [ComponentConfigFieldEnum.SHOW_TIME]: false,
16 [ComponentConfigFieldEnum.FONT_SIZE]: 14, 16 [ComponentConfigFieldEnum.FONT_SIZE]: 14,
17 [ComponentConfigFieldEnum.VALUE_SIZE]: 20, 17 [ComponentConfigFieldEnum.VALUE_SIZE]: 20,
  18 + [ComponentConfigFieldEnum.MAX_NUMBER]: 120,
18 }; 19 };
19 20
20 export default class Config extends PublicConfigClass implements CreateComponentType { 21 export default class Config extends PublicConfigClass implements CreateComponentType {
@@ -18,16 +18,38 @@ @@ -18,16 +18,38 @@
18 18
19 const time = ref<Nullable<number>>(null); 19 const time = ref<Nullable<number>>(null);
20 20
  21 + const POSITIVE_NUMBER = 6;
  22 +
  23 + const ALL_PART = 7;
  24 +
  25 + const DEFAULT_PART_VALUE = 20;
  26 +
  27 + const partValue = computed(() => {
  28 + const { config } = props;
  29 + const { option } = config;
  30 + const { componentInfo } = option;
  31 + const { maxNumber = 120 } = componentInfo || {};
  32 + let value = maxNumber / POSITIVE_NUMBER;
  33 + return value % 10 > 0 ? Math.floor(value / 10) * 10 + 10 : value + 10;
  34 + });
  35 +
  36 + const maxValueScale = computed(() => unref(partValue) / DEFAULT_PART_VALUE);
  37 +
21 const getValue = computed(() => { 38 const getValue = computed(() => {
22 const maxHeight = 190; 39 const maxHeight = 190;
23 const minHeight = 15; 40 const minHeight = 15;
  41 +
24 const height = maxHeight - minHeight; 42 const height = maxHeight - minHeight;
25 - const rangeNumber = 7;  
26 - const itemRange = 20;  
27 - const itemHeight = height / (rangeNumber * itemRange); 43 +
  44 + const itemHeight = height / (ALL_PART * (DEFAULT_PART_VALUE * unref(maxValueScale)));
  45 +
28 const value = unref(currentValue); 46 const value = unref(currentValue);
29 - const transformValue =  
30 - maxHeight - (value >= 0 ? value + 20 : itemRange - Math.abs(value)) * itemHeight; 47 + let transformValue =
  48 + maxHeight -
  49 + (value >= 0
  50 + ? value + unref(DEFAULT_PART_VALUE * unref(maxValueScale))
  51 + : DEFAULT_PART_VALUE * unref(maxValueScale) - Math.abs(value)) *
  52 + itemHeight;
31 53
32 return transformValue >= maxHeight 54 return transformValue >= maxHeight
33 ? maxHeight 55 ? maxHeight
@@ -184,7 +206,9 @@ @@ -184,7 +206,9 @@
184 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px" 206 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px"
185 /> 207 />
186 <foreignObject xmlns="http://www.w3.org/2000/svg" x="-55" y="-10" width="45" height="20"> 208 <foreignObject xmlns="http://www.w3.org/2000/svg" x="-55" y="-10" width="45" height="20">
187 - <div class="tick-label" xmlns="http://www.w3.org/1999/xhtml">-20</div> 209 + <div class="tick-label" xmlns="http://www.w3.org/1999/xhtml">
  210 + {{ partValue * -1 }}
  211 + </div>
188 </foreignObject> 212 </foreignObject>
189 </g> 213 </g>
190 <g class="tick" opacity="1" transform="translate(0,165)"> 214 <g class="tick" opacity="1" transform="translate(0,165)">
@@ -204,7 +228,9 @@ @@ -204,7 +228,9 @@
204 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px" 228 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px"
205 /> 229 />
206 <foreignObject xmlns="http://www.w3.org/2000/svg" x="-55" y="-10" width="45" height="20"> 230 <foreignObject xmlns="http://www.w3.org/2000/svg" x="-55" y="-10" width="45" height="20">
207 - <div class="tick-label" xmlns="http://www.w3.org/1999/xhtml">20</div> 231 + <div class="tick-label" xmlns="http://www.w3.org/1999/xhtml">
  232 + {{ partValue }}
  233 + </div>
208 </foreignObject> 234 </foreignObject>
209 </g> 235 </g>
210 <g class="tick" opacity="1" transform="translate(0,115)"> 236 <g class="tick" opacity="1" transform="translate(0,115)">
@@ -214,7 +240,9 @@ @@ -214,7 +240,9 @@
214 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px" 240 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px"
215 /> 241 />
216 <foreignObject xmlns="http://www.w3.org/2000/svg" x="-55" y="-10" width="45" height="20"> 242 <foreignObject xmlns="http://www.w3.org/2000/svg" x="-55" y="-10" width="45" height="20">
217 - <div class="tick-label" xmlns="http://www.w3.org/1999/xhtml">40</div> 243 + <div class="tick-label" xmlns="http://www.w3.org/1999/xhtml">
  244 + {{ partValue * 2 }}
  245 + </div>
218 </foreignObject> 246 </foreignObject>
219 </g> 247 </g>
220 <g class="tick" opacity="1" transform="translate(0,90)"> 248 <g class="tick" opacity="1" transform="translate(0,90)">
@@ -224,7 +252,9 @@ @@ -224,7 +252,9 @@
224 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px" 252 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px"
225 /> 253 />
226 <foreignObject xmlns="http://www.w3.org/2000/svg" x="-55" y="-10" width="45" height="20"> 254 <foreignObject xmlns="http://www.w3.org/2000/svg" x="-55" y="-10" width="45" height="20">
227 - <div class="tick-label" xmlns="http://www.w3.org/1999/xhtml">60</div> 255 + <div class="tick-label" xmlns="http://www.w3.org/1999/xhtml">
  256 + {{ partValue * 3 }}
  257 + </div>
228 </foreignObject> 258 </foreignObject>
229 </g> 259 </g>
230 <g class="tick" opacity="1" transform="translate(0,65)"> 260 <g class="tick" opacity="1" transform="translate(0,65)">
@@ -234,7 +264,9 @@ @@ -234,7 +264,9 @@
234 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px" 264 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px"
235 /> 265 />
236 <foreignObject xmlns="http://www.w3.org/2000/svg" x="-55" y="-10" width="45" height="20"> 266 <foreignObject xmlns="http://www.w3.org/2000/svg" x="-55" y="-10" width="45" height="20">
237 - <div class="tick-label" xmlns="http://www.w3.org/1999/xhtml">80</div> 267 + <div class="tick-label" xmlns="http://www.w3.org/1999/xhtml">
  268 + {{ partValue * 4 }}
  269 + </div>
238 </foreignObject> 270 </foreignObject>
239 </g> 271 </g>
240 <g class="tick" opacity="1" transform="translate(0,40)"> 272 <g class="tick" opacity="1" transform="translate(0,40)">
@@ -244,7 +276,9 @@ @@ -244,7 +276,9 @@
244 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px" 276 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px"
245 /> 277 />
246 <foreignObject xmlns="http://www.w3.org/2000/svg" x="-55" y="-10" width="45" height="20"> 278 <foreignObject xmlns="http://www.w3.org/2000/svg" x="-55" y="-10" width="45" height="20">
247 - <div class="tick-label" xmlns="http://www.w3.org/1999/xhtml">100</div> 279 + <div class="tick-label" xmlns="http://www.w3.org/1999/xhtml">
  280 + {{ partValue * 5 }}
  281 + </div>
248 </foreignObject> 282 </foreignObject>
249 </g> 283 </g>
250 <g class="tick" opacity="1" transform="translate(0,15)"> 284 <g class="tick" opacity="1" transform="translate(0,15)">
@@ -254,7 +288,9 @@ @@ -254,7 +288,9 @@
254 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px" 288 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px"
255 /> 289 />
256 <foreignObject xmlns="http://www.w3.org/2000/svg" x="-55" y="-10" width="45" height="20"> 290 <foreignObject xmlns="http://www.w3.org/2000/svg" x="-55" y="-10" width="45" height="20">
257 - <div class="tick-label" xmlns="http://www.w3.org/1999/xhtml">120</div> 291 + <div class="tick-label" xmlns="http://www.w3.org/1999/xhtml">
  292 + {{ partValue * 6 }}
  293 + </div>
258 </foreignObject> 294 </foreignObject>
259 </g> 295 </g>
260 </g> 296 </g>
@@ -10,7 +10,7 @@ export function useSendCommand() { @@ -10,7 +10,7 @@ export function useSendCommand() {
10 const loading = ref(false); 10 const loading = ref(false);
11 11
12 const error = () => { 12 const error = () => {
13 - createMessage.error('下发指令失败'); 13 + // createMessage.error('下发指令失败');
14 return false; 14 return false;
15 }; 15 };
16 16
@@ -52,6 +52,7 @@ export function useSendCommand() { @@ -52,6 +52,7 @@ export function useSendCommand() {
52 createMessage.success('命令下发成功'); 52 createMessage.success('命令下发成功');
53 return true; 53 return true;
54 } catch (msg) { 54 } catch (msg) {
  55 + console.error(msg);
55 return error(); 56 return error();
56 } finally { 57 } finally {
57 loading.value = false; 58 loading.value = false;