centaline-data-driven-v3 0.0.82 → 0.0.84

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.0.82",
3
+ "version": "0.0.84",
4
4
  "private": false,
5
5
  "description": "centaline-data-driven-v3",
6
6
  "main": "dist/centaline-data-driven-v3.umd.js",
@@ -301,11 +301,9 @@ function clickHandler(routerKey, rowindex, forname, forrowindex, flagHaveAlert)
301
301
  if (typeof rowindex !== "undefined") {
302
302
  if (props.flagFormList) {
303
303
  emit("rolRouterclick", routerKey, rowindex, props.vmodel.$sourceIndex);
304
-
305
304
  }
306
305
  else {
307
- emit("rolRouterclick", routerKey, rowindex, forname, forrowindex, flagHaveAlert);
308
-
306
+ emit("rolRouterclick", routerKey, rowindex, forname, forrowindex, flagHaveAlert,props.vmodel,props.actionRouter);
309
307
  }
310
308
  }
311
309
  }
@@ -3,12 +3,10 @@
3
3
  <!-- 头部 -->
4
4
  <div class="header">
5
5
  <div class="header-item">
6
- <el-icon class="ico-button" @click="hideAI()">
7
- <DArrowLeft />
8
- </el-icon>
6
+ <img class="ico-button" :src="util.getAssetsImage('AIChat.png')" @click="hideAI()">
9
7
  </div>
10
8
  <div class="header-item" v-if="model.controlLabel">
11
- <h3 style="line-height: 25px;">
9
+ <h3 style="line-height: 35px;">
12
10
  {{ model.controlLabel }}</h3>
13
11
  </div>
14
12
  </div>
@@ -17,24 +15,36 @@
17
15
  <template v-for="message in model.messages">
18
16
  <div :key="message.id" class="message" v-if="message.content"
19
17
  :class="{ 'user-message': message.sender === 'user', 'ai-message': message.sender === 'ai' }">
20
- <div class="chat-message" :style="{ color: message.type == 'error' ? 'red' : '' }"
21
- v-html="htmlContent(message)">
22
- </div>
23
- </div>
24
- <div v-else class="loading-container">
25
- <div class="loading-circle"></div>
18
+ <template v-if="message.type == 'table'">
19
+ <div :style="{ 'width': tablewidth - 70 + 'px' }">
20
+ <div v-if="JSON.parse(message.content).title" style="margin-bottom: 10px;"
21
+ v-html="JSON.parse(message.content).title"></div>
22
+ <template v-for="(row, rowindex) in JSON.parse(message.content).rows" :key="rowindex">
23
+ <ct-layout :vmodel="row" :cellLayout="JSON.parse(message.content).cellLayout"
24
+ :rowindex="rowindex" @rolRouterclick="rolRouterCellClickHandler"
25
+ :actionRouter="JSON.parse(message.content).actionRouters">
26
+ </ct-layout>
27
+ </template>
28
+ </div>
29
+ </template>
30
+ <template v-else>
31
+ <div class="chat-message" :style="{ color: message.type == 'error' ? 'red' : '' }"
32
+ v-html="htmlContent(message)">
33
+ </div>
34
+ </template>
26
35
  </div>
27
36
  </template>
37
+ <div v-if="afoot" class="loading-container">
38
+ <div class="loading-circle"></div>
39
+ </div>
28
40
  </div>
29
41
 
30
42
  <!-- 输入区域 -->
31
43
  <div class="chat-editor" v-if="showAI">
32
44
  <div class="chat-input-editor-container">
33
- <textarea ref="textareaRef" class="chat-input"
34
- v-model="inputMessage" @keydown="handleKeydown"
45
+ <textarea ref="textareaRef" class="chat-input" v-model="inputMessage" @keydown="handleKeydown"
35
46
  :placeholder="model.placeholder"></textarea>
36
47
 
37
-
38
48
  </div>
39
49
  <div class="chat-editor-action">
40
50
 
@@ -57,11 +67,14 @@
57
67
 
58
68
 
59
69
  <script setup lang="ts">
60
- import { ref, onActivated, nextTick, watch, computed } from 'vue'
70
+ import { ref, onActivated, nextTick, watch, computed, onMounted } from 'vue'
61
71
  import AIChat from '../../loader/src/AIChat'
62
72
  import common from '../../utils/common'
63
73
  import { marked } from 'marked';
64
74
  import DOMPurify from 'dompurify'
75
+ import Router from '../../loader/src/Router';
76
+ import { RouterClickHandler } from '../../utils/mixins';
77
+ import util from '../../utils/pub-use'
65
78
 
66
79
 
67
80
  const emit = defineEmits(['loaded', "getRefFieldPara", "hideAI"])
@@ -70,6 +83,11 @@ const props = defineProps({
70
83
  router: Object,
71
84
  actionRouters: Array,
72
85
  form: Object,
86
+ tablewidth: Number,
87
+ isVisible: {
88
+ Boolean,
89
+ default: false,
90
+ },
73
91
  })
74
92
  interface StreamEventData {
75
93
  event: string
@@ -141,13 +159,7 @@ function load(data) {
141
159
  action();
142
160
  }
143
161
 
144
- onActivated(() => {
145
- nextTick(() => {
146
- if (inputMessage.value) {
147
- inputMessage.value.focus();
148
- }
149
- })
150
- })
162
+
151
163
  // Marked 配置
152
164
  marked.setOptions({
153
165
  breaks: true,
@@ -158,12 +170,20 @@ marked.setOptions({
158
170
  function htmlContent(message) {
159
171
  return DOMPurify.sanitize(marked(message.content) + '')
160
172
  };
161
- // 监听内容变化,调整 textarea 高度
162
- watch(inputMessage, () => {
173
+
174
+ // 监听多个值并执行不同逻辑
175
+ watch([() => inputMessage, () => props.isVisible], ([newVal1, newVal2], [oldVal1, oldVal2]) => {
163
176
  nextTick(() => {
164
- adjustTextareaHeight();
177
+ if (newVal1 !== oldVal1) {
178
+ adjustTextareaHeight();
179
+ }
180
+ if (newVal2) {
181
+ if (textareaRef.value) {
182
+ textareaRef.value.focus();
183
+ }
184
+ }
165
185
  });
166
- });
186
+ }, { flush: 'sync' }); // 控制监听的时机
167
187
 
168
188
  // 调整 textarea 高度
169
189
  const adjustTextareaHeight = () => {
@@ -219,8 +239,10 @@ const addMessage = (message) => {
219
239
  }
220
240
  // 添加消息通用方法
221
241
  const appendMessage = (message) => {
222
- model.value.messages[model.value.messages.length - 1].content = model.value.messages[model.value.messages.length - 1].content + message;
223
- scheduleScroll()
242
+ if (!isStopped) {
243
+ model.value.messages[model.value.messages.length - 1].content = model.value.messages[model.value.messages.length - 1].content + message;
244
+ scheduleScroll()
245
+ }
224
246
  }
225
247
 
226
248
  const UpdateMessageType = (type) => {
@@ -233,11 +255,10 @@ const UpdateMessageType = (type) => {
233
255
  const scheduleScroll = (flagScroll) => {
234
256
  if (!scrollPending) {
235
257
  if (messagesContainer.value) {
236
- const container = messagesContainer.value;
237
-
238
- const distanceToBottom = container.scrollHeight - (container.scrollTop + container.clientHeight);
258
+ const distanceToBottom = getDistanceToBottom();
259
+ console.log(flagScroll, distanceToBottom)
239
260
  if (flagScroll || distanceToBottom <= 20) {
240
- scrollPending = true
261
+ scrollPending = true;
241
262
  nextTick(() => {
242
263
  if (messagesContainer.value) {
243
264
  messagesContainer.value.scrollTop = messagesContainer.value.scrollHeight
@@ -249,6 +270,18 @@ const scheduleScroll = (flagScroll) => {
249
270
  }
250
271
  }
251
272
 
273
+ const getDistanceToBottom = () => {
274
+ let rtn = 0;
275
+
276
+ if (messagesContainer.value) {
277
+ const container = messagesContainer.value;
278
+
279
+ rtn = container.scrollHeight - (container.scrollTop + container.clientHeight);
280
+ }
281
+
282
+ return rtn;
283
+
284
+ }
252
285
  //获取关联列返回对象
253
286
  function getRefFieldJson() {
254
287
  let rtn = {};
@@ -314,7 +347,8 @@ const fetchAIResponse = async (params) => {
314
347
  })
315
348
  }).then(response => {
316
349
  if (!response.ok) {
317
- throw new Error('Network response was not ok');
350
+ common.message('网络响应不正常', 'error');
351
+ return;
318
352
  }
319
353
 
320
354
  // 获取响应的 ReadableStream
@@ -329,8 +363,6 @@ const fetchAIResponse = async (params) => {
329
363
  if (isStopped) {
330
364
  // 如果停止标志为 true,直接返回
331
365
  outtext.value += "\n\n用户停止"
332
- startTypingEffect(outtext.value);
333
- outtext.value = '';
334
366
  resolve();
335
367
  return;
336
368
  }
@@ -366,12 +398,32 @@ const fetchAIResponse = async (params) => {
366
398
  });
367
399
  }).then(() => {
368
400
  // 在所有行处理完毕后执行 startTypingEffect
369
- if (outtext.value == '') {
370
- outtext.value = ' ';
401
+
402
+ let TemplateType = getTemplateType(outtext.value);
403
+ UpdateMessageType(TemplateType);
404
+
405
+ let type = model.value.messages[model.value.messages.length - 1].type;
406
+ if (type == "table" || type == "form") {
407
+ var data = JSON.parse(outtext.value).content;
408
+ if (type == "table") {
409
+ var actionRouters = [];
410
+ data.actionRouters.forEach((v) => {
411
+ var router = Router(v);
412
+ router.is = "ct-button";
413
+ actionRouters.push(router);
414
+ });
415
+ data.actionRouters = actionRouters
416
+ }
417
+ const flagScroll = (getDistanceToBottom() <= 20) ? true : false;
418
+ appendMessage(JSON.stringify(data));
419
+
420
+
421
+ setTimeout(() => scheduleScroll(flagScroll), 500);
422
+
423
+ } else {
424
+ startTypingEffect(outtext.value);
371
425
  }
372
- UpdateMessageType('message');
373
- startTypingEffect(outtext.value);
374
- outtext.value = '';
426
+ afoot.value = false;
375
427
  }).catch(error => {
376
428
  UpdateMessageType('error');
377
429
  if (error.name === 'AbortError') {
@@ -395,7 +447,7 @@ function stopRequest() {
395
447
  }).then(response => response.json()) // 将响应转换为 JSON
396
448
  .then(data => {
397
449
  if (data.result == 'success') {
398
- afoot.value = true;
450
+ afoot.value = false;
399
451
  }
400
452
 
401
453
  // 如果服务器返回 { result: "success" },这里会输出这个对象
@@ -459,44 +511,84 @@ const handleStreamEvent = (eventData: StreamEventData) => {
459
511
  }
460
512
 
461
513
  const getTemplateType = (fullText) => {
514
+ var rtn = "message";
515
+ try {
516
+ const eventData = JSON.parse(fullText)
517
+ if (eventData) {
518
+ if (eventData.content?.rows) {
519
+ rtn = 'table';
520
+ }
521
+ else if (eventData.content?.fields) {
522
+ rtn = 'form';
523
+ }
524
+ }
462
525
 
526
+ } catch (error) {
463
527
 
528
+ }
529
+
530
+ return rtn;
464
531
 
465
532
  }
466
533
 
467
534
 
468
535
  function startTypingEffect(fullText) {
469
536
  let index = 0;
470
- let timer = setInterval(() => {
471
- // 检查索引是否超出字符串长度
472
- if (index >= fullText.length) {
473
- clearInterval(timer); // 清除定时器
474
- return;
475
- }
537
+ outtext.value = ''; // 清空内容
476
538
 
539
+ function typeNext() {
477
540
  // 随机生成3到10之间的字符数
478
- const randomChars = Math.floor(Math.random() * 8) + 3; // 3到10(包括3和10)
541
+ const randomChars = Math.floor(Math.random() * 5) + 8;
479
542
  const charsToLoad = Math.min(randomChars, fullText.length - index);
480
543
 
481
- // 获取当前要加载的字符
544
+ // 获取并显示当前字符
482
545
  const currentChars = fullText.substring(index, index + charsToLoad);
483
- // 显示字符
484
546
  appendMessage(currentChars);
485
- // 更新索引
486
547
  index += charsToLoad;
487
548
 
488
- // 检查是否已经加载完成
489
- if (index >= fullText.length) {
490
- clearInterval(timer); // 清除定时器
549
+ // 递归条件判断
550
+ if (index < fullText.length && !isStopped) {
551
+ setTimeout(typeNext, 100); // 继续下一次迭代
552
+ } else {
553
+ // 全部完成后执行
554
+ outtext.value = '';
491
555
  }
492
- }, 100); // 每100毫秒加载10个字符
493
- afoot.value = false;
556
+ }
557
+
558
+ // 启动首次调用
559
+ setTimeout(typeNext, 100);
494
560
  }
495
561
 
562
+
496
563
  function hideAI() {
497
564
  emit("hideAI", false);
498
565
 
499
566
  }
567
+ //layout组件 路由操作
568
+ function rolRouterCellClickHandler(routerKey, rowindex, forname, forrowindex, flagHaveAlert, rowData, actionRouter) {
569
+ var submitData = {};
570
+ let field = actionRouter.find((b) => {
571
+ return b.key === routerKey;
572
+ });
573
+ field = Router(field);
574
+ if (typeof forname !== "undefined") {
575
+ field.submitListField.forEach((k) => {
576
+ submitData[k] = rowData[forname][forrowindex][k];
577
+ });
578
+ } else {
579
+ field.submitListField.forEach((k) => {
580
+ submitData[k] = rowData[k];
581
+ });
582
+ }
583
+ if (field.isCallTel) {
584
+ submitData.flagHaveAlert = flagHaveAlert || false;
585
+ }
586
+ let action = field.action;
587
+ if (field.actionField) {
588
+ action = rowData[field.actionField];
589
+ }
590
+ RouterClickHandler(field, submitData, action, model.value, 'table')
591
+ }
500
592
  </script>
501
593
 
502
594
  <style scoped>
@@ -520,7 +612,7 @@ function hideAI() {
520
612
 
521
613
  /* 子元素之间的间距为5像素 */
522
614
  .header-item {
523
- padding: 10px 0px 10px 10px;
615
+ padding: 3px 0px 0px 8px;
524
616
  }
525
617
  }
526
618
 
@@ -532,6 +624,7 @@ function hideAI() {
532
624
  display: flex;
533
625
  flex-direction: column;
534
626
  gap: 1rem;
627
+
535
628
  }
536
629
 
537
630
  /* 隐藏滚动条 */
@@ -554,6 +647,10 @@ function hideAI() {
554
647
  max-height: none;
555
648
  /* 不限制子级高度 */
556
649
  border-radius: 10px;
650
+ word-wrap: break-word;
651
+ /* 确保内容自动换行 */
652
+ word-break: break-word;
653
+ /* 长单词或连续字符也能换行 */
557
654
 
558
655
  }
559
656
 
@@ -567,6 +664,10 @@ function hideAI() {
567
664
  align-self: flex-start;
568
665
  background-color: white;
569
666
  border: 1px solid #e0e0e0;
667
+ max-width: 100%;
668
+ /* 确保不超出父级宽度 */
669
+ width: auto;
670
+ /* 去掉固定宽度 */
570
671
  }
571
672
 
572
673
  .chat-message {
@@ -657,9 +758,10 @@ function hideAI() {
657
758
  }
658
759
 
659
760
  .chat-input::placeholder {
660
- color: #a8abb2;
661
- opacity: 1;
761
+ color: #a8abb2;
762
+ opacity: 1;
662
763
  }
764
+
663
765
  .chat-editor-action {
664
766
  display: flex;
665
767
  justify-content: space-between;
@@ -705,9 +807,8 @@ function hideAI() {
705
807
 
706
808
  .ico-button {
707
809
  cursor: pointer;
708
- width: 25px;
709
- height: 25px;
710
- background-color: #DBEAFE;
810
+ width: 35px;
811
+ height: 35px;
711
812
  }
712
813
 
713
814
 
@@ -48,6 +48,7 @@ import Axios from 'axios';
48
48
  import { ref, nextTick } from 'vue'
49
49
  import { Search } from '@element-plus/icons-vue'
50
50
  import { initData, changeHandler } from '../../utils/mixins';
51
+ import common from '../../utils/common'
51
52
  import ComboBox from '../../loader/src/ComboBox';
52
53
  const emit = defineEmits(['click', 'input', 'change', 'popupSearchList', 'search'])
53
54
  const props = defineProps({
@@ -125,7 +126,7 @@ function getOptions(key) {
125
126
  }
126
127
 
127
128
  if(data.length==0){
128
- nodatatext.value = '无数据';
129
+ nodatatext.value = common.LocalizedString('无数据', '無數據');
129
130
  }
130
131
 
131
132
  nextTick(function () {
@@ -133,7 +134,7 @@ function getOptions(key) {
133
134
  });
134
135
  }
135
136
  else{
136
- nodatatext.value = '无数据';
137
+ nodatatext.value = common.LocalizedString('无数据', '無數據');
137
138
  }
138
139
  })
139
140
  }
@@ -157,14 +157,14 @@
157
157
 
158
158
  </div>
159
159
  <template v-if="model?.aiAttr?.showAI">
160
- <div :style="{ flex: ' 0 0 ' + model.aiAttr.width + 'px', position: 'sticky', top: '0' ,'margin-left': '10px'}"
160
+ <div :style="{ flex: ' 0 0 ' + model.aiAttr.width + 'px', position: 'sticky', top: '0' ,'box-shadow': '-10px 0 5px -9px rgba(0, 0, 0, 0.3)' }"
161
161
  v-show="showAI">
162
162
  <div
163
163
  :style="{ position: 'sticky', top: '0', height: dialogHeight + 'px', overflow: 'hidden', 'border-bottom-right-radius': '4px' }">
164
164
  <AIChat :height="dialogHeight"
165
165
  :style="{ position: 'sticky', top: '0', height: dialogHeight + 'px' }"
166
166
  :field="model.aiChat" :router="model.aiRouter" :actionRouter="model.actionRouters" :form="model"
167
- @hideAI="AIToggle">
167
+ @hideAI="AIToggle" :isVisible="showAI" :tablewidth="model.aiAttr.width">
168
168
 
169
169
  </AIChat>
170
170
  </div>
@@ -19,7 +19,7 @@ onActivated(() => {
19
19
  })
20
20
  function close() {
21
21
  emit('close', props);
22
- if (props.vmodel.content[0].attrs && typeof props.vmodel.content[0].attrs["onCloseDialog"] === "function") {
22
+ if (props.vmodel.content[0].component != 'ct-iframe' && props.vmodel.content[0].attrs && typeof props.vmodel.content[0].attrs["onCloseDialog"] === "function") {
23
23
  props.vmodel.content[0].attrs["onCloseDialog"]();
24
24
  }
25
25
  }
@@ -145,11 +145,11 @@ const render = () => {
145
145
  //AI弹框宽度自适应
146
146
  if (!item.attrs.onAIToggle) {
147
147
  item.attrs.onAIToggle = (newWidth) => {
148
-
148
+
149
149
  item.width = parseFloat(item.width) + newWidth + 'px';
150
150
  }
151
151
  }
152
-
152
+
153
153
  //加载失败关闭弹框
154
154
  if (!item.attrs.onFailLoad) {
155
155
  item.attrs.onFailLoad = () => {
@@ -195,8 +195,8 @@ const render = () => {
195
195
  item.documentWidth = (props.vmodel.pane.clientWidth - 20) + 'px';
196
196
  }
197
197
  }
198
- item.attrs.dialoWidth = parseInt((item.width||0).replace('px', ''));
199
- item.attrs.dialogHeight = parseInt((item.height||0).replace('px', ''));
198
+ item.attrs.dialoWidth = parseInt((item.width || 0).replace('px', ''));
199
+ item.attrs.dialogHeight = parseInt((item.height || 0).replace('px', ''));
200
200
  return h('div', {
201
201
  style: {
202
202
  width: item.width,
@@ -13,6 +13,9 @@ const Router = function (source) {
13
13
  get controlLabel() {
14
14
  return source.text;
15
15
  },
16
+ set controlLabel(v) {
17
+ return source.text=v;
18
+ },
16
19
  //动作对应的 控制器
17
20
  get action() {
18
21
  return source.action;
package/src/main.js CHANGED
@@ -22,16 +22,18 @@ for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
22
22
 
23
23
  app.use(centaline, {
24
24
  baseUrl:"http://10.88.22.66/IBS.Mvc/api/",
25
+ //baseUrl: "https://kq-api.centaline.com.cn/onecard-api/",
26
+ //baseUrl: "http://10.88.22.13:6060/onecard-api/",
25
27
  //baseUrl: "http://10.88.22.66:6060/xian/",
26
28
  //baseUrl: "http://10.1.245.50:38735/max-uplink-api/",
27
29
  //baseUrl: "http://10.1.245.111:38028/",
28
-
30
+
29
31
  flagRouterSelf: true,
30
- flagApp: false,//是否app端
32
+ flagApp: true,//是否app端
31
33
  zindex: 999,
32
34
  showRequestSuccessMessage: true,
33
35
  showRequestErrorMessage: true,
34
- language:'HK',
36
+ language: 'HK',
35
37
  handler: {
36
38
  // 打开tab页
37
39
  openTab: function (action) {
@@ -64,10 +66,13 @@ app.use(centaline, {
64
66
  return {
65
67
  //authObject: '{token:"aplus eyJhbGciOiJIUzI1NiIsInppcCI6IkRFRiJ9.eNrEjjsOwjAQBe-ydVay1xvvOl3sJA2HiPIxElSIJBIIcXdAQEfPFK-YZt4Nlm2EChqtDafOYWqpRG6kxLoTxZhUTSRxHLUPH_DHfOmt5SDWt1gHScieHapNiol94q5pXYoNFJAvJ6isGHWmNMYVcBjWtyCr_iW2JZ93-fqPc8f18MwGIqFRCIO1GXmWGYd9npCZJ6N5JjYZ7g8AAAD__w.HgtNKtHWooj8c9Hy_vB8CfKq-qOeHMp0irnW0DfXtHo"}',
66
68
  //oldToken: 'd92d4a3b-2274-42e8-96f0-100ffb579b6e',
67
- //authObject: '{token:"1-a7289bb2-9f1e-4a04-9016-1e555bf39188"}',
68
- authObject: '{EmpID:"Token_43406e81-3337-4d1f-8917-edc5bfec9c9f",MachineCode:"e1f39b75-7069-4c4f-b5d5-c590da2d9aa2",SSO_Token:"SSOToken_43406e81-3337-4d1f-8917-edc5bfec9c9f",Platform:"web"}',
69
+ //authObject: '{token:"1647-1907352839429165056",platform:"WEB"}',
70
+ authObject: '{EmpID:"Token_2fa5c93f-ae55-4e77-98a4-ef9c8b3bec34",MachineCode:"7c4b2ffd-920a-462c-a586-37bbfb45c4fe",SSO_Token:"SSOToken_2fa5c93f-ae55-4e77-98a4-ef9c8b3bec34",Platform:"IOS"}',
69
71
  };
70
72
  },
73
+ getToken() {
74
+ return "1647-1907319603235786752"
75
+ },
71
76
  // 请求完成事件,可判断是否登录过期执行响应操作
72
77
  requestComplete: function (response) {
73
78
  // console.log(response);
@@ -6,6 +6,10 @@
6
6
 
7
7
  <ct-searchlist :apiParam="apiParam" :searchConditionApi="'/propertyTenderList/getLayoutOfSearch'"
8
8
  :searchDataApi="'/propertyTenderList/getListOfSearchModel'"></ct-searchlist>
9
+
10
+
11
+ <!-- <ct-searchlist :apiParam="apiParam" :searchConditionApi="'/EmployeeAttendanceBillList/getLayoutOfSearchForMy'"
12
+ :searchDataApi="'/EmployeeAttendanceBillList/getListOfSearchModelForMy'"></ct-searchlist> -->
9
13
  <ct-dialoglist ref="dialogList"></ct-dialoglist>
10
14
 
11
15
  </div>