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 <script lang="ts">
14 14 import { defineComponent, ref, computed, unref } from 'vue';
15 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 17 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
18 18 import { useMessage } from '/@/hooks/web/useMessage';
19 19 import { saveOrUpdateConfigurationCenter } from '/@/api/configuration/center/configurationCenter';
20 20 import { FileItem } from '/@/components/Form/src/components/ApiUpload.vue';
21 21 import { buildUUID } from '/@/utils/uuid';
22 22 import { getDeviceProfile } from '/@/api/alarm/position';
  23 + import { PC_DEFAULT_CONTENT, PHONE_DEFAULT_CONTENT, Platform } from '../center/center.data';
23 24
24 25 export default defineComponent({
25 26 name: 'ConfigurationDrawer',
... ...
... ... @@ -5,28 +5,17 @@ import { uploadThumbnail } from '/@/api/configuration/center/configurationCenter
5 5 import { useComponentRegister } from '/@/components/Form';
6 6 import { OrgTreeSelect } from '../../common/OrgTreeSelect';
7 7 import { getDeviceProfile } from '/@/api/alarm/position';
  8 +import { Platform } from '../center/center.data';
8 9
9 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 20 export const columns: BasicColumn[] = [
32 21 {
... ...
... ... @@ -6,12 +6,11 @@
6 6 import {
7 7 deleteConfigurationCenter,
8 8 getPage,
9   - shareConfiguration,
10 9 } from '/@/api/configuration/center/configurationCenter';
11 10 import { ConfigurationCenterItemsModal } from '/@/api/configuration/center/model/configurationCenterModal';
12 11 import { PageWrapper } from '/@/components/Page';
13 12 import { BasicForm, useForm } from '/@/components/Form';
14   - import { ConfigurationPermission, Platform, searchFormSchema } from './center.data';
  13 + import { searchFormSchema, ConfigurationTemplatePermission } from './center.data';
15 14 import { useMessage } from '/@/hooks/web/useMessage';
16 15 import { Authority } from '/@/components/Authority';
17 16 import ConfigurationCenterDrawer from './ConfigurationCenterDrawer.vue';
... ... @@ -22,10 +21,10 @@
22 21 import { usePermission } from '/@/hooks/web/usePermission';
23 22 import { AuthIcon, CardLayoutButton } from '/@/components/Widget';
24 23 import AuthDropDown from '/@/components/Widget/AuthDropDown.vue';
25   - import { ShareModal } from '/@/views/common/ShareModal';
26 24 import { useRole } from '/@/hooks/business/useRole';
27 25 import { Icon } from '/@/components/Icon';
28 26 import { createScadaPageLink, ScadaModeEnum } from './help';
  27 + import { Platform } from '../center/center.data';
29 28
30 29 const listColumn = ref(5);
31 30
... ... @@ -102,11 +101,11 @@
102 101 const { hasPermission } = usePermission();
103 102
104 103 const getPreviewFlag = computed(() => {
105   - return hasPermission(ConfigurationPermission.PREVIEW);
  104 + return hasPermission(ConfigurationTemplatePermission.PREVIEW);
106 105 });
107 106
108 107 const getDesignFlag = computed(() => {
109   - return hasPermission(ConfigurationPermission.DESIGN);
  108 + return hasPermission(ConfigurationTemplatePermission.DESIGN);
110 109 });
111 110
112 111 const handleCreateOrUpdate = (record?: ConfigurationCenterItemsModal) => {
... ... @@ -185,7 +184,7 @@
185 184 >
186 185 <template #header>
187 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 188 <Button type="primary" @click="handleCreateOrUpdate()">新增模板</Button>
190 189 </Authority>
191 190 <CardLayoutButton v-model:value="listColumn" @change="handleCardLayoutChange" />
... ... @@ -225,7 +224,7 @@
225 224 <template class="ant-card-actions" #actions>
226 225 <Tooltip v-if="!isCustomerUser" title="设计">
227 226 <AuthIcon
228   - :auth="ConfigurationPermission.DESIGN"
  227 + :auth="ConfigurationTemplatePermission.DESIGN"
229 228 class="!text-lg"
230 229 icon="ant-design:edit-outlined"
231 230 @click="handleDesign(item)"
... ... @@ -236,14 +235,14 @@
236 235 :dropMenuList="[
237 236 {
238 237 text: '编辑',
239   - auth: ConfigurationPermission.UPDATE,
  238 + auth: ConfigurationTemplatePermission.UPDATE,
240 239 icon: 'clarity:note-edit-line',
241 240 event: '',
242 241 onClick: handleCreateOrUpdate.bind(null, item),
243 242 },
244 243 {
245 244 text: '删除',
246   - auth: ConfigurationPermission.DELETE,
  245 + auth: ConfigurationTemplatePermission.DELETE,
247 246 icon: 'ant-design:delete-outlined',
248 247 event: '',
249 248 popconfirm: {
... ... @@ -281,11 +280,6 @@
281 280 </List>
282 281 </section>
283 282 <ConfigurationCenterDrawer @register="registerDrawer" @success="getListData" />
284   - <ShareModal
285   - @register="registerShareModal"
286   - :shareApi="shareConfiguration"
287   - @success="getListData"
288   - />
289 283 </PageWrapper>
290 284 </template>
291 285
... ...
... ... @@ -15,6 +15,7 @@ export const option: PublicPresetOptions = {
15 15 [ComponentConfigFieldEnum.SHOW_TIME]: false,
16 16 [ComponentConfigFieldEnum.FONT_SIZE]: 14,
17 17 [ComponentConfigFieldEnum.VALUE_SIZE]: 20,
  18 + [ComponentConfigFieldEnum.MAX_NUMBER]: 120,
18 19 };
19 20
20 21 export default class Config extends PublicConfigClass implements CreateComponentType {
... ...
... ... @@ -18,16 +18,38 @@
18 18
19 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 38 const getValue = computed(() => {
22 39 const maxHeight = 190;
23 40 const minHeight = 15;
  41 +
24 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 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 54 return transformValue >= maxHeight
33 55 ? maxHeight
... ... @@ -184,7 +206,9 @@
184 206 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px"
185 207 />
186 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 212 </foreignObject>
189 213 </g>
190 214 <g class="tick" opacity="1" transform="translate(0,165)">
... ... @@ -204,7 +228,9 @@
204 228 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px"
205 229 />
206 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 234 </foreignObject>
209 235 </g>
210 236 <g class="tick" opacity="1" transform="translate(0,115)">
... ... @@ -214,7 +240,9 @@
214 240 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px"
215 241 />
216 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 246 </foreignObject>
219 247 </g>
220 248 <g class="tick" opacity="1" transform="translate(0,90)">
... ... @@ -224,7 +252,9 @@
224 252 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px"
225 253 />
226 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 258 </foreignObject>
229 259 </g>
230 260 <g class="tick" opacity="1" transform="translate(0,65)">
... ... @@ -234,7 +264,9 @@
234 264 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px"
235 265 />
236 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 270 </foreignObject>
239 271 </g>
240 272 <g class="tick" opacity="1" transform="translate(0,40)">
... ... @@ -244,7 +276,9 @@
244 276 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px"
245 277 />
246 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 282 </foreignObject>
249 283 </g>
250 284 <g class="tick" opacity="1" transform="translate(0,15)">
... ... @@ -254,7 +288,9 @@
254 288 style="stroke: rgb(136, 136, 136); shape-rendering: crispEdges; stroke-width: 1px"
255 289 />
256 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 294 </foreignObject>
259 295 </g>
260 296 </g>
... ...
... ... @@ -10,7 +10,7 @@ export function useSendCommand() {
10 10 const loading = ref(false);
11 11
12 12 const error = () => {
13   - createMessage.error('下发指令失败');
  13 + // createMessage.error('下发指令失败');
14 14 return false;
15 15 };
16 16
... ... @@ -52,6 +52,7 @@ export function useSendCommand() {
52 52 createMessage.success('命令下发成功');
53 53 return true;
54 54 } catch (msg) {
  55 + console.error(msg);
55 56 return error();
56 57 } finally {
57 58 loading.value = false;
... ...