centaline-data-driven-v3 0.1.38 → 0.1.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "centaline-data-driven-v3",
3
- "version": "0.1.38",
3
+ "version": "0.1.39",
4
4
  "private": false,
5
5
  "description": "centaline-data-driven-v3",
6
6
  "main": "dist/centaline-data-driven-v3.umd.js",
@@ -21,7 +21,7 @@
21
21
  <template #tag>
22
22
  <template v-for="(v, i) in model.labelValue" :key="i">
23
23
  <el-tag class="ml-2" type="info" disable-transitions :closable="!v.locked && !model.locked"
24
- :style="{ marginRight: i+1==model.labelValue.length ? '20px' : '' }"
24
+ :style="{ marginRight: i + 1 == model.labelValue.length ? '20px' : '' }"
25
25
  @close="closeTag(v.code)">
26
26
  {{ v.name }}</el-tag>
27
27
  </template>
@@ -62,6 +62,7 @@ const refselect = ref()
62
62
  const open = ref(false)
63
63
  const isComposing = ref(false);
64
64
  const nodatatext = ref(' ')
65
+ const popperWidth = ref(null)
65
66
  model.value.itemKey = Math.random();
66
67
  let cancelTokenSource = null; // 用于存储取消令牌
67
68
 
@@ -77,6 +78,7 @@ onBeforeUnmount(() => {
77
78
 
78
79
  //下拉框出现/隐藏时触发
79
80
  function visibleChange(visible) {
81
+
80
82
  //是否有更多选择路由
81
83
  if (model.value.moreActionRouter) {
82
84
  refselect.value.popperRef.hidden = true
@@ -84,6 +86,9 @@ function visibleChange(visible) {
84
86
  else {
85
87
  //出现获取数据
86
88
  if (visible) {
89
+ if (refselect.value && popperWidth.value) {
90
+ refselect.value.popperSize = popperWidth.value;
91
+ }
87
92
  open.value = true;
88
93
  nodatatext.value = common.LocalizedString('加载中', '加載中');
89
94
  if (!model.value.filterable) {
@@ -256,9 +261,11 @@ function setminWidth() {
256
261
 
257
262
  if ((span.getBoundingClientRect().width + 40) <= refselect.value.selectRef.offsetWidth) {
258
263
  refselect.value.popperSize = refselect.value.selectRef.offsetWidth;
264
+ popperWidth.value = refselect.value.selectRef.offsetWidth;
259
265
  }
260
266
  else {
261
267
  refselect.value.popperSize = span.getBoundingClientRect().width + 40;
268
+ popperWidth.value = span.getBoundingClientRect().width + 40;
262
269
  }
263
270
 
264
271
  document.body.removeChild(span);
@@ -12,10 +12,10 @@
12
12
  <div style="display: flex; flex: 0 0 100%;" v-if="col.show !== false && col.lineFeed"></div>
13
13
  <div v-if="col.show !== false"
14
14
  :class="index > 0 && (col.controlLabel == '' || col.is == 'ct-button') ? 'complex-left-10' : ''"
15
- :style="{ 'width': (col.width && col.width>0 ? col.width + 'px' : ''), 'flex': (col.width && col.width>0? '0 0 ' + col.width + 'px' : '') }">
15
+ :style="{ 'width': (col.width && col.width > 0 ? col.width + 'px' : ''), 'flex': (col.width && col.width > 0 ? '0 0 ' + col.width + 'px' : '') }">
16
16
  <component ref="Fields" :is="col.is" :vmodel="col" :parameterAction="parameterAction"
17
- v-bind="col.bindPara" @fieldClick="fieldClickHandler(col)" @change="change(col)"
18
- @popupSearchList="popupSearchListHandler"></component>
17
+ :key="col.fieldItemKey" v-bind="col.bindPara" @fieldClick="fieldClickHandler(col)"
18
+ @change="change(col)" @popupSearchList="popupSearchListHandler"></component>
19
19
  </div>
20
20
  </template>
21
21
  </template>
@@ -28,10 +28,10 @@
28
28
  <div style="display: flex; flex: 0 0 100%;" v-if="col.show !== false && col.lineFeed"></div>
29
29
  <el-col v-if="col.show !== false"
30
30
  :class="[index > 0 && (col.controlLabel == '' || col.is == 'ct-btn') ? 'complex-left-10' : '', 'containerCol']"
31
- :style="{ 'width': (col.width && col.width>0 ? col.width + 'px' : '100%'), 'flex': (col.width && col.width>0 ? '0 0 ' + col.width + 'px' : '100%') }">
31
+ :style="{ 'width': (col.width && col.width > 0 ? col.width + 'px' : '100%'), 'flex': (col.width && col.width > 0 ? '0 0 ' + col.width + 'px' : '100%') }">
32
32
  <component ref="Fields" :is="col.is" :vmodel="col" :parameterAction="parameterAction"
33
- v-bind="col.bindPara" @fieldClick="fieldClickHandler(col)" @change="change(col)"
34
- @popupSearchList="popupSearchListHandler">
33
+ :key="col.fieldItemKey" v-bind="col.bindPara" @fieldClick="fieldClickHandler(col)"
34
+ @change="change(col)" @popupSearchList="popupSearchListHandler">
35
35
  </component>
36
36
  </el-col>
37
37
  </template>
@@ -5,16 +5,16 @@
5
5
  <div style="flex: 1; min-width: 0;">
6
6
  <div v-if="model !== null && !loading" class="ct-form">
7
7
  <el-affix target=".ct-form" v-if="model.tip" :offset="62">
8
- <div class="ct-form-tip">
8
+ <div class="ct-form-tip" ref="refTip">
9
9
  <span v-html="model.tip"></span>
10
10
  </div>
11
11
  </el-affix>
12
12
 
13
13
  <!--可根据场景判断显示el-card还是el-main-->
14
- <component :is="model.showTitle ? 'el-main' : 'el-card'">
15
- <div class="ct-from-title" v-if="typeof model.title !== 'undefined' && model.flagShowTitle">
14
+ <component :is="model.showTitle ? 'el-main' : 'el-card'" :key="itemKey">
15
+ <!-- <div class="ct-from-title" v-if="typeof model.title !== 'undefined' && model.flagShowTitle">
16
16
  <span style="font-weight:bold">{{ model.title }}</span>
17
- </div>
17
+ </div> -->
18
18
 
19
19
  <!--relationParentFormFields-->
20
20
  <el-row v-if="relationParentFormFields.length > 0">
@@ -23,9 +23,9 @@
23
23
  </div>
24
24
  <el-col v-if="col.show !== false" :span="col.colspan" style="padding:5px"
25
25
  :class="[col.is == 'ct-button' && col.labelPlacement == '1' ? 'el-col1' : '']">
26
- <component ref="Fields" :is="col.is" :vmodel="col" :key="itemKey" :listHeight="listHeight"
27
- :parameterAction="model.parameterAction" v-bind="col.bindPara"
28
- :fileData="getFileData(col)" @change="changeHandler"
26
+ <component ref="Fields" :is="col.is" :vmodel="col" :key="col.fieldItemKey"
27
+ :listHeight="listHeight" :parameterAction="model.parameterAction"
28
+ v-bind="col.bindPara" :fileData="getFileData(col)" @change="changeHandler"
29
29
  @importComplete="importComplete" @popupLocation="popupLocationHandler"
30
30
  @fieldClick="fieldClickHandler" @popupSearchList="popupSearchListHandler"
31
31
  @tableButtonClick="clickHandler" @popupGroupList="popupGroupListHandler"
@@ -42,9 +42,9 @@
42
42
  </div>
43
43
  <el-col v-if="col.show !== false" :span="col.colspan" style="padding:5px"
44
44
  :class="[col.is == 'ct-button' && col.labelPlacement == '1' ? 'el-col1' : '']">
45
- <component ref="Fields" :is="col.is" :vmodel="col" :key="itemKey" :listHeight="listHeight"
46
- :parameterAction="model.parameterAction" v-bind="col.bindPara"
47
- :fileData="getFileData(col)" @change="changeHandler"
45
+ <component ref="Fields" :is="col.is" :vmodel="col" :key="col.fieldItemKey"
46
+ :listHeight="listHeight" :parameterAction="model.parameterAction"
47
+ v-bind="col.bindPara" :fileData="getFileData(col)" @change="changeHandler"
48
48
  @importComplete="importComplete" @popupLocation="popupLocationHandler"
49
49
  @fieldClick="fieldClickHandler" @popupSearchList="popupSearchListHandler"
50
50
  @tableButtonClick="clickHandler" @popupGroupList="popupGroupListHandler"
@@ -54,37 +54,43 @@
54
54
  </template>
55
55
  </el-row>
56
56
  <!--tabs-->
57
- <el-tabs v-if="model.isHorizontalLayout" v-model="activeName" @tab-click="tabClick">
57
+ <template v-if="model.isHorizontalLayout">
58
+ <component :is="model.flagFixedTabOnHorizontalLayout ? 'el-affix' : 'div'"
59
+ v-bind="model.flagFixedTabOnHorizontalLayout ? { offset: tabTopHight, target: '.ct-form' } : {}">
60
+ <el-tabs v-model="activeName" @tab-click="tabClick" style="background: #fff;">
61
+ <template v-for="(item, index) in model.collapse" :key="index">
62
+ <el-tab-pane :name="index.toString()" :lazy="item.lazyLoad"
63
+ v-if="item.show !== false" :key="index">
64
+ <template #label>
65
+ <span v-html="item.controlLabel"></span>
66
+ </template>
67
+ </el-tab-pane>
68
+ </template>
69
+ </el-tabs>
70
+ </component>
58
71
  <template v-for="(item, index) in model.collapse" :key="index">
59
- <el-tab-pane :name="index.toString()" :lazy="item.lazyLoad" v-if="item.show !== false"
60
- :key="index">
61
- <template #label>
62
- <span v-html="item.controlLabel"></span>
72
+ <el-row v-show="activeName === index.toString()">
73
+ <template v-for="(col, i) in model.collapseFields[index + 1]" :key="i">
74
+ <div style="display: flex; flex: 0 0 100%;"
75
+ v-if="col.show !== false && col.lineFeed"></div>
76
+ <el-col :span="col.colspan" v-if="col.show !== false" style="padding:5px"
77
+ :class="[col.is == 'ct-button' && col.labelPlacement == '1' ? 'el-col1' : '']">
78
+ <component ref="Fields" :is="col.is" :vmodel="col" :key="col.fieldItemKey"
79
+ :listHeight="listHeight" :parameterAction="model.parameterAction"
80
+ v-bind="col.bindPara" :fileData="getFileData(col)"
81
+ @change="changeHandler" @fieldClick="fieldClickHandler"
82
+ @popupLocation="popupLocationHandler"
83
+ @popupSearchList="popupSearchListHandler"
84
+ @importComplete="importComplete" @popupGroupList="popupGroupListHandler"
85
+ @tableButtonClick="clickHandler"
86
+ @flagNotificationParentAfterContentChanged="flagNotificationParentAfterContentChanged">
87
+ </component>
88
+ </el-col>
63
89
  </template>
64
- <el-row>
65
- <template v-for="(col, i) in model.collapseFields[index + 1]" :key="i">
66
- <div style="display: flex; flex: 0 0 100%;"
67
- v-if="col.show !== false && col.lineFeed"></div>
68
- <el-col :span="col.colspan" v-if="col.show !== false" style="padding:5px"
69
- :class="[col.is == 'ct-button' && col.labelPlacement == '1' ? 'el-col1' : '']">
70
- <component ref="Fields" :is="col.is" :vmodel="col" :key="itemKey" :listHeight="listHeight"
71
- :parameterAction="model.parameterAction" v-bind="col.bindPara"
72
- :fileData="getFileData(col)" @change="changeHandler"
73
- @fieldClick="fieldClickHandler"
74
- @popupLocation="popupLocationHandler"
75
- @popupSearchList="popupSearchListHandler"
76
- @importComplete="importComplete"
77
- @popupGroupList="popupGroupListHandler"
78
- @tableButtonClick="clickHandler"
79
- @flagNotificationParentAfterContentChanged="flagNotificationParentAfterContentChanged">
80
- </component>
81
- </el-col>
82
- </template>
83
- </el-row>
84
- </el-tab-pane>
90
+ </el-row>
85
91
  </template>
86
- </el-tabs>
87
-
92
+ <div style="height: 34px;"> </div>
93
+ </template>
88
94
  <!--分组-->
89
95
  <el-collapse v-else v-model="model.collapseActiveNames"
90
96
  :class="model.flagHideSaveLine ? 'el-collapse-saveLine' : ''">
@@ -104,10 +110,10 @@
104
110
  v-if="col.show !== false && col.lineFeed"></div>
105
111
  <el-col :span="col.colspan" v-if="col.show !== false" style="padding:5px"
106
112
  :class="[col.is == 'ct-button' && col.labelPlacement == '1' ? 'el-col1' : '']">
107
- <component ref="Fields" :is="col.is" :vmodel="col" :key="itemKey" :listHeight="listHeight"
108
- :parameterAction="model.parameterAction" v-bind="col.bindPara"
109
- :fileData="getFileData(col)" @change="changeHandler"
110
- @fieldClick="fieldClickHandler"
113
+ <component ref="Fields" :is="col.is" :vmodel="col" :key="col.fieldItemKey"
114
+ :listHeight="listHeight" :parameterAction="model.parameterAction"
115
+ v-bind="col.bindPara" :fileData="getFileData(col)"
116
+ @change="changeHandler" @fieldClick="fieldClickHandler"
111
117
  @popupLocation="popupLocationHandler"
112
118
  @popupSearchList="popupSearchListHandler"
113
119
  @importComplete="importComplete"
@@ -130,7 +136,7 @@
130
136
  :class="[col.is == 'ct-button' && col.labelPlacement == '1' ? 'el-col1' : '']">
131
137
  <component ref="Fields" :is="col.is" :vmodel="col" :listHeight="listHeight"
132
138
  :parameterAction="model.parameterAction" v-bind="col.bindPara"
133
- @change="changeHandler" :key="itemKey" :fileData="getFileData(col)"
139
+ @change="changeHandler" :key="col.fieldItemKey" :fileData="getFileData(col)"
134
140
  @fieldClick="fieldClickHandler" @popupSearchList="popupSearchListHandler"
135
141
  @importComplete="importComplete" @tableButtonClick="clickHandler"
136
142
  @popupGroupList="popupGroupListHandler" @popupLocation="popupLocationHandler"
@@ -148,8 +154,7 @@
148
154
 
149
155
  </el-col>
150
156
  </el-row>
151
- <el-row v-if="model.buttons.findIndex((v) => { return v.show }) > -1"
152
- :class="isScroll ? 'button-absolute' : 'button-initial'"
157
+ <el-row v-if="model.buttons.findIndex((v) => { return v.show }) > -1" class="button-absolute"
153
158
  :style="['max-width:' + buttonsWidth(), isWebScroll ? 'position: fixed;' : '']">
154
159
  <el-col :span="24"
155
160
  style="text-align:center;padding-bottom: 1px;padding-left: 5px;padding-right: 5px;"
@@ -164,6 +169,12 @@
164
169
  <div v-if="isScroll && model.buttons.findIndex((v) => { return v.show }) > -1"
165
170
  style="height: 34px;">
166
171
  </div>
172
+ <el-affix target=".ct-form" position="bottom" v-if="model.bottomTip"
173
+ :offset="model.buttons.findIndex((v) => { return v.show }) > -1 ? 43 : 0">
174
+ <div class="ct-form-tip">
175
+ <span v-html="model.bottomTip"></span>
176
+ </div>
177
+ </el-affix>
167
178
  </component>
168
179
  </div>
169
180
 
@@ -276,6 +287,8 @@ const minHeight = ref('auto')
276
287
  const showAI = ref(false);
277
288
  const dialogHeight = ref(props.dialogHeight || (window.innerHeight - 60));
278
289
  const tabActiveNameKey = ref('')
290
+ const refTip = ref()
291
+ const tabTopHight = ref(52)
279
292
 
280
293
  const qrtimer1 = ref(null)
281
294
  const qrtimer2 = ref(null)
@@ -366,7 +379,11 @@ function load(data) {
366
379
 
367
380
  }
368
381
  }
369
-
382
+ nextTick(() => {
383
+ if (refTip.value) {
384
+ tabTopHight.value = tabTopHight.value + refTip.value.clientHeight + 10
385
+ }
386
+ })
370
387
  //通知父组件加载完成
371
388
  emit('loaded', model.value);
372
389
  }
@@ -686,6 +703,12 @@ function setCss() {
686
703
  if (props.topHeight > -1) {
687
704
  minHeight.value = (document.documentElement.clientHeight - props.topHeight - 20) + 'px';
688
705
  }
706
+ else if(props.dialogHeight){
707
+ minHeight.value = (props.dialogHeight) + 'px';
708
+ }
709
+ else{
710
+ minHeight.value = document.documentElement.clientHeight + 'px';
711
+ }
689
712
  }
690
713
 
691
714
 
@@ -1,36 +1,56 @@
1
- <template>
2
-
3
- <div class="josnViewerBox" :style="{ height: model.height || 'auto','max-height':(listHeight?listHeight-130+'px':'calc(100vh - 130px)') }" v-if="isRefresh">
4
- <JsonViewer :value="model.json" copyable show-array-index show-double-quotes theme="light" :expanded="true"
5
- :expand-depth="2" @onKeyClick="keyClick">
6
- <template #copy="{ copied }">
7
- <div class="btn-iocn"><el-icon title="复原到初始状态" @click.stop="resetJSON">
8
- <Refresh />
9
- </el-icon>
10
-
11
- <!-- 复制按钮 -->
12
- <el-icon :class="{ 'copied': copied }" title="复制JSON内容">
13
- <CopyDocument />
14
- </el-icon>
15
- </div>
16
- </template>
17
- </JsonViewer>
18
- </div>
1
+ <template>
2
+ <div class="josnViewerBox" ref="jsonContent" tabindex="-1"
3
+ :style="{ height: model.height || 'auto', 'max-height': ('calc(100vh - '+topDistance+'px)') }"
4
+ v-if="isRefresh">
5
+ <JsonViewer :value="model.json" copyable show-array-index show-double-quotes theme="light" :expanded="true"
6
+ :expand-depth="2" @onKeyClick="keyClick">
7
+ <template #copy="{ copied }">
8
+ <div class="btn-iocn"><el-icon title="复原到初始状态" @click.stop="resetJSON">
9
+ <Refresh />
10
+ </el-icon>
11
+
12
+ <!-- 复制按钮 -->
13
+ <el-icon :class="{ 'copied': copied }" title="复制JSON内容">
14
+ <CopyDocument />
15
+ </el-icon>
16
+ </div>
17
+ </template>
18
+ </JsonViewer>
19
+ </div>
19
20
  </template>
20
21
 
21
22
  <script setup>
22
23
  import { JsonViewer } from "vue3-json-viewer"
23
24
  import "vue3-json-viewer/dist/vue3-json-viewer.css";
24
- import { nextTick, ref } from "vue";
25
+ import { useDistanceCalculator } from '../../utils/distance-utils.js';
26
+
27
+ import { nextTick, ref, onMounted ,inject} from "vue";
25
28
  const props = defineProps({
26
29
  api: String,
27
30
  vmodel: Object,
28
31
  actionRouter: Array,
29
- listHeight: Number,
32
+ listHeight: Number,
30
33
  })
34
+
35
+ const jsonContent = ref(null);
36
+
31
37
  const model = ref({});
32
38
  const isRefresh = ref(true);
39
+ const topDistance = ref(0);
40
+ const { getAllDistances } = useDistanceCalculator(jsonContent);
41
+
42
+
43
+
44
+
45
+ // 在组件挂载后或需要时调用
46
+ onMounted(() => {
47
+ nextTick(() => {
48
+ setTimeout(() => {
49
+ topDistance.value = getAllDistances()?.elementInfo?.top+40;
50
+ }, 100);
51
+ });
33
52
 
53
+ });
34
54
 
35
55
  init()
36
56
  //初始化数据
@@ -47,12 +67,12 @@ function load(data) {
47
67
  }
48
68
  const resetJSON = () => {
49
69
  isRefresh.value = false;
50
- nextTick(() => {
70
+ nextTick(() => {
51
71
  isRefresh.value = true;
52
72
  });
53
73
  };
54
74
 
55
-
75
+
56
76
 
57
77
  const keyClick = (keyName) => {
58
78
  console.log(keyName, "it was click")
@@ -72,14 +92,14 @@ const keyClick = (keyName) => {
72
92
  z-index: 10;
73
93
  margin-left: auto;
74
94
  /* 辅助:确保靠右 */
75
- float: right;
95
+ float: right;
76
96
 
77
97
  }
78
98
 
79
-
99
+
80
100
 
81
101
  .josnViewerBox {
82
- overflow: auto;
102
+ overflow: auto;
83
103
  width: 100%;
84
104
  border: 1px solid #eee;
85
105
  border-radius: 4px;
@@ -89,14 +109,15 @@ const keyClick = (keyName) => {
89
109
  box-sizing: border-box;
90
110
  background-color: #ffffff;
91
111
  }
112
+
92
113
  .josnViewerBox:focus {
93
114
  border: 1px solid #3D5ECC;
94
115
  }
95
116
 
96
117
 
97
118
  .btn-iocn {
98
- display: flex;
119
+ display: flex;
99
120
  gap: 10px;
100
-
121
+
101
122
  }
102
123
  </style>
@@ -98,6 +98,9 @@ function loadFromModel(source, isFormList) {
98
98
  }
99
99
 
100
100
  rtn1[attrKey] = attrValue;
101
+ if (rtn1.fieldItemKey) {
102
+ rtn1.fieldItemKey = Math.random()
103
+ }
101
104
 
102
105
  if (rtn1.controlType === Enum.ControlType.Tags) {
103
106
  rtn1["value"] = JSON.parse(attrValue);
@@ -533,10 +536,12 @@ function loadFromModel(source, isFormList) {
533
536
  if (f.controlType == Enum.ControlType.Compound || f.controlType == Enum.ControlType.ContainerControl) {
534
537
  if (f.fields) {
535
538
  f.fields.forEach((v) => {
539
+ v.fieldItemKey = Math.random();
536
540
  rtn._fieldsDic[v.fieldName1] = v;
537
541
  });
538
542
  }
539
543
  }
544
+ f.fieldItemKey = Math.random();
540
545
  rtn._fieldsDic[f.fieldName1] = f;
541
546
  });
542
547
  }
@@ -765,6 +770,12 @@ function loadFromModel(source, isFormList) {
765
770
  get tip() {
766
771
  return source.tip;
767
772
  },
773
+ get bottomTip() {
774
+ return source.bottomTip;
775
+ },
776
+ get flagFixedTabOnHorizontalLayout() {
777
+ return source.flagFixedTabOnHorizontalLayout === true;
778
+ },
768
779
  get flagAlertCloseWindowAfterSave() {
769
780
  return source.flagAlertCloseWindowAfterSave === true;
770
781
  },
@@ -301,7 +301,7 @@ const LibFunction = {
301
301
  else {
302
302
  num = 24 / colNum;
303
303
  }
304
- return num;
304
+ return parseInt(num);
305
305
  },
306
306
  get for() {
307
307
  return field.for;
@@ -1,7 +1,15 @@
1
-
1
+ import common from '../../utils/common';
2
2
  async function postFile(api, data, callback) {
3
3
  var xhr = window.XMLHttpRequest ? new XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP");
4
4
  xhr.open('POST', api, !0)
5
+
6
+ // let headers=common.getDataDrivenOpts().handler.getRequestHeaders(api);
7
+ // if(headers){
8
+ // for (const [key, value] of Object.entries(headers)) {
9
+ // xhr.setRequestHeader(key,value)
10
+ // }
11
+ // }
12
+
5
13
  xhr.onreadystatechange = function () {
6
14
  if (xhr.readyState != 4 || xhr.status < 200) {
7
15
  return false;
package/src/main.js CHANGED
@@ -21,7 +21,7 @@ for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
21
21
  }
22
22
 
23
23
  app.use(centaline, {
24
- baseUrl: "http://10.88.22.13:7080/ibs-api/",
24
+ baseUrl: "http://10.88.22.66/IBS.Mvc/api/",
25
25
  //baseUrl:"http://10.88.22.13:7070/onecard-api/",
26
26
  //baseUrl: "https://kq-api.centaline.com.cn/onecard-api/",
27
27
  //baseUrl: "http://10.88.22.13:6060/onecard-api/",
@@ -65,7 +65,7 @@ app.use(centaline, {
65
65
  //获取请求头
66
66
  getRequestHeaders: function () {
67
67
  return {
68
- authobject: '{token:"T5067-1993594422771769344",platform:"WEB"}',
68
+ authobject: '{EmpID:"Token_a3e4add3-642b-40b6-bc3f-32bdf8114668",MachineCode:"ae184643-f8e2-453c-a752-ba82612b592f",SSO_Token:"SSOToken_a3e4add3-642b-40b6-bc3f-32bdf8114668",Platform:"WEB"}',
69
69
  //oldToken: 'd92d4a3b-2274-42e8-96f0-100ffb579b6e',
70
70
  //authObject: '{token:"jiangzf-1958445358178844672",platform:"WEB"}',
71
71
  //authObject: '{EmpID:"Token_4e09499b-4b76-46df-9ce5-5498d48ed062",MachineCode:"ae184643-f8e2-453c-a752-ba82612b592f",SSO_Token:"SSOToken_4e09499b-4b76-46df-9ce5-5498d48ed062",Platform:"WEB"}',
@@ -278,7 +278,10 @@ const common = {
278
278
  */
279
279
  message(message, type, center, duration, showClose, dangerouslyUseHTMLString) {
280
280
  if (dataDrivenOpts.flagApp) {
281
- if (this.hasHtml(message)) {
281
+ if (typeof duration === 'undefined') {
282
+ duration = 3000;
283
+ }
284
+ if (duration == 0) {
282
285
  showDialog({ message: message, allowHtml: true });
283
286
  }
284
287
  else if (type == 'error') {
@@ -287,7 +290,7 @@ const common = {
287
290
  else {
288
291
  showToast({
289
292
  message: message,
290
- duration: 3000,
293
+ duration: duration,
291
294
  });
292
295
  }
293
296
 
@@ -303,9 +306,7 @@ const common = {
303
306
  showClose = false;
304
307
  }
305
308
  if (this.hasHtml(message)) {
306
- duration = 0;
307
309
  dangerouslyUseHTMLString = true;
308
- showClose = true;
309
310
  }
310
311
  ElMessage({
311
312
  message: message,//消息文字
@@ -0,0 +1,84 @@
1
+ export const useDistanceCalculator = (elementRef) => {
2
+ const getAllDistances = (retryCount = 0) => {
3
+ if (!elementRef?.value) {
4
+ console.warn('元素引用为空');
5
+ return null;
6
+ }
7
+
8
+ const element = elementRef.value;
9
+
10
+ // 检查元素是否在 DOM 中
11
+ if (!document.body.contains(element)) {
12
+ console.warn('元素不在 DOM 中');
13
+ return null;
14
+ }
15
+
16
+ const rect = element.getBoundingClientRect();
17
+ const scrollTop = window.pageYOffset;
18
+
19
+ // 检查是否有实际尺寸
20
+ const hasSize = rect.height > 0 && rect.width > 0;
21
+
22
+ if (!hasSize && retryCount < 3) {
23
+ console.warn(`元素尺寸为 0,尝试重试 (${retryCount + 1}/3)`);
24
+ // 延迟重试
25
+ setTimeout(() => getAllDistances(retryCount + 1), 50);
26
+ return null;
27
+ }
28
+
29
+ // 获取计算样式,检查是否隐藏
30
+ const computedStyle = window.getComputedStyle(element);
31
+ const isVisible = computedStyle.display !== 'none' &&
32
+ computedStyle.visibility !== 'hidden' &&
33
+ computedStyle.opacity !== '0';
34
+
35
+ if (!isVisible) {
36
+ console.warn('元素不可见,无法获取尺寸');
37
+ return null;
38
+ }
39
+
40
+ return {
41
+ // 到文档顶部的距离
42
+ toDocumentTop: rect.top + scrollTop,
43
+
44
+ // 到视口顶部的距离
45
+ toViewportTop: rect.top,
46
+
47
+ // 元素自身信息
48
+ elementInfo: {
49
+ height: rect.height,
50
+ width: rect.width,
51
+ top: rect.top,
52
+ right: rect.right,
53
+ bottom: rect.bottom,
54
+ left: rect.left,
55
+ // 添加更多诊断信息
56
+ hasSize,
57
+ isVisible,
58
+ displayStyle: computedStyle.display,
59
+ positionStyle: computedStyle.position
60
+ },
61
+
62
+ // 视口信息
63
+ viewportInfo: {
64
+ height: window.innerHeight,
65
+ width: window.innerWidth,
66
+ scrollTop: scrollTop
67
+ }
68
+ };
69
+ };
70
+
71
+ // 添加一个延迟获取的方法,用于异步内容
72
+ const getDistancesWithDelay = (delay = 100) => {
73
+ return new Promise((resolve) => {
74
+ setTimeout(() => {
75
+ resolve(getAllDistances());
76
+ }, delay);
77
+ });
78
+ };
79
+
80
+ return {
81
+ getAllDistances,
82
+ getDistancesWithDelay
83
+ };
84
+ };