@ebiz/designer-components 0.1.68 → 0.1.74

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": "@ebiz/designer-components",
3
- "version": "0.1.68",
3
+ "version": "0.1.74",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -21,7 +21,7 @@
21
21
  "echarts": "^5.6.0",
22
22
  "pdfjs-dist": "^3.11.174",
23
23
  "vxe-table": "^4.13.31",
24
- "tdesign-vue-next": "^1.12.0",
24
+ "tdesign-vue-next": "^1.15.0",
25
25
  "unplugin-auto-import": "^19.0.0",
26
26
  "unplugin-vue-components": "^28.0.0",
27
27
  "vue": "^3.5.13",
@@ -0,0 +1,79 @@
1
+ <template>
2
+ <div>
3
+ <t-qrcode :bg-color="bgColor" :border-less="borderless" :color="color" :icon="icon" :icon-size="iconSize"
4
+ :level="level" :size="size" :type="type" :value="value" @refresh="onRefresh">
5
+ </t-qrcode>
6
+ </div>
7
+ </template>
8
+
9
+ <script>
10
+ export default {
11
+ name: 'EbizQrCode'
12
+ }
13
+ </script>
14
+
15
+ <script setup>
16
+ import { defineProps, defineEmits } from 'vue';
17
+ import { QRCode as TQrcode } from 'tdesign-vue-next';
18
+
19
+ const props = defineProps({
20
+ // 二维码背景颜色
21
+ bgColor: {
22
+ type: String,
23
+ default: ''
24
+ },
25
+ // 是否有边框
26
+ borderless: {
27
+ type: Boolean,
28
+ default: false
29
+ },
30
+ // 二维码颜色
31
+ color: {
32
+ type: String,
33
+ default: ''
34
+ },
35
+ // 二维码中图片的地址
36
+ icon: {
37
+ type: String,
38
+ default: ''
39
+ },
40
+ // 二维码中图片的大小。TS 类型:number | { width: number; height: number }
41
+ iconSize: {
42
+ type: Number,
43
+ default: 40
44
+ },
45
+ // 二维码纠错等级。可选项:L/M/Q/H
46
+ level: {
47
+ type: String,
48
+ default: M
49
+ },
50
+ // 二维码大小
51
+ size: {
52
+ type: Number,
53
+ default: 160
54
+ },
55
+ // 渲染类型。可选项:canvas/svg
56
+ type: {
57
+ type: String,
58
+ default: 'canvas'
59
+ },
60
+ // 扫描后的文本
61
+ value: {
62
+ type: String,
63
+ default: ''
64
+ }
65
+ })
66
+
67
+ const emit = defineEmits(['refresh'])
68
+
69
+ // 点击"点击刷新"的回调
70
+ const onRefresh = () => {
71
+ emit('refresh')
72
+ }
73
+
74
+ </script>
75
+ <!--
76
+
77
+ <style lang="scss" scoped>
78
+ /* 自定义样式 */
79
+ </style> -->
@@ -297,18 +297,23 @@ const currentId = ref(null)
297
297
  const currentParams = ref({})
298
298
  // 本地维护一份表单数据的副本
299
299
  const initFormData = ref(props.formData ? { ...props.formData } : {})
300
- const localFormDataValue = ref({ ...initFormData })
301
- const localFormData = computed({
302
- set(newValue) {
303
- localFormDataValue.value = newValue
304
- },
305
- get() {
306
- if (!props.formData) {
307
- return { ...localFormDataValue.value }
308
- }
309
- return { ...localFormDataValue.value, ...props.formData }
300
+ const localFormData = ref({ ...initFormData.value })
301
+
302
+ // 监听 props.formData 的变化,同步到本地数据
303
+ watch(() => props.formData, (newFormData) => {
304
+ if (newFormData) {
305
+ // 合并新的表单数据到本地数据
306
+ Object.keys(newFormData).forEach(key => {
307
+ localFormData.value[key] = newFormData[key]
308
+ })
310
309
  }
311
- })
310
+ }, { deep: true })
311
+
312
+ // 监听本地数据变化,同步到父组件
313
+ watch(localFormData, (newValue) => {
314
+ emit('update:formData', { ...newValue })
315
+ }, { deep: true })
316
+
312
317
  // 监听props的visible变化
313
318
  watch(() => props.visible, (newVal) => {
314
319
  dialogVisible.value = newVal
@@ -367,7 +372,7 @@ const callApi = async (config = props.apiConfig) => {
367
372
  console.log(localFormData.value)
368
373
 
369
374
  // 准备请求参数
370
- const fetchParams = { ...localFormData.value, ...props.formData }
375
+ const fetchParams = { ...localFormData.value }
371
376
 
372
377
  // 如果有ID,添加到请求参数中
373
378
  if (currentId.value) {
@@ -403,7 +408,9 @@ const callApi = async (config = props.apiConfig) => {
403
408
  }
404
409
 
405
410
  // 清空数据
406
- localFormData.value = {}
411
+ Object.keys(localFormData.value).forEach(key => {
412
+ delete localFormData.value[key]
413
+ })
407
414
 
408
415
  // 触发成功事件
409
416
  emit('api-success', response)
@@ -653,8 +660,12 @@ const resetFormData = () => {
653
660
  emit('reset', { type: 'manual' })
654
661
  }
655
662
 
656
- console.log("initFormData.value", initFormData.value)
657
- emit('update:formData', {})
663
+ // 重置本地表单数据
664
+ Object.keys(localFormData.value).forEach(key => {
665
+ delete localFormData.value[key]
666
+ })
667
+
668
+ emit('update:formData', { ...localFormData.value })
658
669
 
659
670
  return { success: true, message: '表单已重置' }
660
671
  }
package/src/index.js CHANGED
@@ -102,6 +102,7 @@ import EbizDetailItem from './components/EbizDetailItem.vue'
102
102
  import EbizPdfViewer from './components/EbizPdfViewer.vue'
103
103
  import EbizRichTextEditor from './components/EbizRichTextEditor.vue'
104
104
  import EbizVideo from './components/EbizVideo.vue'
105
+ import EbizQrCode from './components/EbizQrCode.vue'
105
106
 
106
107
  // 导出组件
107
108
  export {
@@ -248,5 +249,7 @@ export {
248
249
  // 富文本编辑器组件
249
250
  EbizRichTextEditor,
250
251
  // 视频播放器组件
251
- EbizVideo
252
+ EbizVideo,
253
+ // 二维码组件
254
+ EbizQrCode
252
255
  }