@zhangqingcq/vgce 0.0.26 → 0.0.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. package/dist/style.css +2 -2
  2. package/dist/vgce.js +9271 -8810
  3. package/dist/vgce.umd.cjs +206 -98
  4. package/package.json +1 -4
  5. package/src/assets/svgs/alert-light.svg +39 -0
  6. package/src/assets/svgs/bot-9.svg +94 -0
  7. package/src/assets/svgs/common-table.svg +1 -7
  8. package/src/assets/svgs/el-button.svg +1 -10
  9. package/src/assets/svgs/hamburger.svg +1 -0
  10. package/src/assets/svgs/hotpot.svg +1 -0
  11. package/src/assets/svgs/now-time.svg +1 -9
  12. package/src/assets/svgs/pie-charts.svg +1 -10
  13. package/src/assets/svgs/progress-a.svg +1 -1
  14. package/src/assets/svgs/svg-text.svg +1 -1
  15. package/src/assets/svgs/switch-on.svg +12 -0
  16. package/src/assets/svgs/switch-r.svg +14 -0
  17. package/src/assets/svgs/thermometer.svg +22 -0
  18. package/src/assets/svgs/thermometer2.svg +16 -0
  19. package/src/components/config/index.ts +11 -0
  20. package/src/components/svg-editor/{center-panel/index.vue → center-panel.vue} +14 -8
  21. package/src/components/svg-editor/{handle-panel/index.vue → handle-panel.vue} +10 -0
  22. package/src/components/svg-editor/index.vue +8 -7
  23. package/src/components/svg-editor/{left-panel/index.vue → left-panel.vue} +2 -2
  24. package/src/components/svg-editor/right-panel/code-edit-modal.vue +2 -2
  25. package/src/components/svg-editor/right-panel/common-animate.vue +1 -1
  26. package/src/components/svg-editor/right-panel/dynamic-el-form-item.vue +22 -0
  27. package/src/components/svg-editor/right-panel/list.vue +1 -1
  28. package/src/components/svg-editor/{right-panel/index.vue → right-panel.vue} +47 -31
  29. package/src/components/svg-editor/{top-panel/index.vue → top-panel.vue} +11 -3
  30. package/src/components/{svg-viewer/index.vue → svg-viewer.vue} +8 -6
  31. package/src/config/files/common-table.vue +48 -48
  32. package/src/config/files/now-time.vue +71 -52
  33. package/src/config/files/pie-charts.vue +72 -71
  34. package/src/config/files/svg-text.vue +17 -37
  35. package/src/config/files/switch-r.vue +72 -0
  36. package/src/config/index.ts +2 -2
  37. package/src/config/svg/animation/index.ts +2 -2
  38. package/src/config/svg/{stateless/alternator.ts → animation/thermometer.ts} +4 -11
  39. package/src/config/svg/custom/index.ts +2 -2
  40. package/src/config/svg/custom/svg-text.ts +25 -1
  41. package/src/config/svg/custom/{switch-a.ts → switch-r.ts} +4 -4
  42. package/src/config/svg/stateful/alert-light.ts +33 -0
  43. package/src/config/svg/stateful/index.ts +2 -2
  44. package/src/config/svg/stateless/{house.ts → bot-9.ts} +3 -3
  45. package/src/config/svg/stateless/{sheet-border.ts → hamburger.ts} +3 -3
  46. package/src/config/svg/{stateful/circuit-breaker.ts → stateless/hotpot.ts} +4 -20
  47. package/src/config/svg/stateless/index.ts +4 -4
  48. package/src/config/types.ts +2 -9
  49. package/src/config/vue/component/button.ts +1 -1
  50. package/src/config/vue/component/common-table.ts +7 -7
  51. package/src/config/vue/component/now-time.ts +36 -2
  52. package/src/config/vue/component/progress.ts +2 -2
  53. package/src/index.ts +12 -12
  54. package/src/utils/index.ts +36 -37
  55. package/src/views/Preview.vue +1 -1
  56. package/src/assets/svgs/alternator.svg +0 -8
  57. package/src/assets/svgs/circuit-breaker.svg +0 -11
  58. package/src/assets/svgs/house.svg +0 -1
  59. package/src/assets/svgs/package.svg +0 -1
  60. package/src/assets/svgs/reservoir.svg +0 -10
  61. package/src/assets/svgs/sheet-border.svg +0 -1
  62. package/src/assets/svgs/switch-a.svg +0 -5
  63. package/src/components/svg-editor/center-panel/types.ts +0 -11
  64. package/src/config/files/switch-a.vue +0 -43
  65. package/src/config/svg/animation/reservoir.ts +0 -32
  66. /package/src/components/{ace-edit/index.ts → ace-edit.ts} +0 -0
  67. /package/src/components/{svg-analysis/index.vue → svg-analysis.vue} +0 -0
  68. /package/src/components/svg-editor/{component-tree/index.vue → component-tree.vue} +0 -0
  69. /package/src/components/svg-editor/{connection-line/index.vue → connection-line.vue} +0 -0
  70. /package/src/components/svg-editor/{connection-panel/index.vue → connection-panel.vue} +0 -0
  71. /package/src/components/svg-editor/{export-json/index.vue → export-json.vue} +0 -0
  72. /package/src/components/svg-editor/{import-json/index.vue → import-json.vue} +0 -0
  73. /package/src/components/{vue3-ruler-tool/index.vue → vue3-ruler-tool.vue} +0 -0
@@ -13,13 +13,13 @@
13
13
  } from 'element-plus'
14
14
  import 'element-plus/dist/index.css'
15
15
  import 'animate.css'
16
- import TopPanel from '@/components/svg-editor/top-panel/index.vue'
17
- import LeftPanel from '@/components/svg-editor/left-panel/index.vue'
18
- import CenterPanel from '@/components/svg-editor/center-panel/index.vue'
19
- import RightPanel from '@/components/svg-editor/right-panel/index.vue'
20
- import ExportJson from '@/components/svg-editor/export-json/index.vue'
21
- import ImportJson from '@/components/svg-editor/import-json/index.vue'
22
- import Vue3RulerTool from '@/components/vue3-ruler-tool/index.vue'
16
+ import TopPanel from '@/components/svg-editor/top-panel.vue'
17
+ import LeftPanel from '@/components/svg-editor/left-panel.vue'
18
+ import CenterPanel from '@/components/svg-editor/center-panel.vue'
19
+ import RightPanel from '@/components/svg-editor/right-panel.vue'
20
+ import ExportJson from '@/components/svg-editor/export-json.vue'
21
+ import ImportJson from '@/components/svg-editor/import-json.vue'
22
+ import Vue3RulerTool from '@/components/vue3-ruler-tool.vue'
23
23
  import { EVisibleConfKey } from '@/components/svg-editor/types'
24
24
  import type { IVisibleConf, IDataModel } from '@/components/svg-editor/types'
25
25
  import type { IConfig } from '@/config/types'
@@ -33,6 +33,7 @@
33
33
  import { fileRead, fileWrite } from '@/utils/file-read-write'
34
34
  import { useEditPrivateStore } from '@/stores/system'
35
35
 
36
+ //todo 优化自带组件使用体验
36
37
  const props = withDefaults(defineProps<{ customToolbar?: IConfig; data?: string; saveFile?: boolean }>(), {
37
38
  saveFile: false
38
39
  })
@@ -4,7 +4,7 @@
4
4
  import type { IConfig, IConfigItem } from '@/config/types'
5
5
  import { pinia } from '@/hooks'
6
6
  import { useGlobalStore } from '@/stores/global'
7
- import SvgAnalysis from '@/components/svg-analysis/index.vue'
7
+ import SvgAnalysis from '@/components/svg-analysis.vue'
8
8
  import { EGlobalStoreIntention } from '@/stores/global/types'
9
9
  import { prosToVBind } from '@/utils'
10
10
 
@@ -53,7 +53,7 @@
53
53
  :title="svg_item.title"
54
54
  >
55
55
  <el-icon :size="35" class="flex items-center">
56
- <svg-analysis :name="svg_item.name" :props="prosToVBind(svg_item)" />
56
+ <svg-analysis :name="svg_item.name" :props="prosToVBind(svg_item, ['width', 'height', 'maxHeight'])" />
57
57
  </el-icon>
58
58
  </div>
59
59
  </div>
@@ -9,7 +9,7 @@
9
9
  title: '编辑'
10
10
  })
11
11
  const open = ref(false)
12
- const emits = defineEmits(['update:modelValue'])
12
+ const emits = defineEmits(['update:modelValue', 'close'])
13
13
 
14
14
  const content = computed({
15
15
  get() {
@@ -31,7 +31,7 @@
31
31
  <template>
32
32
  <div>
33
33
  <el-button @click="open = true">···</el-button>
34
- <el-dialog class="modal-full" v-model="open" :title="props.title" width="60%">
34
+ <el-dialog class="modal-full" v-model="open" :title="props.title" width="60%" @close="emits('close')">
35
35
  <v-ace-editor
36
36
  v-model:value="content"
37
37
  :lang="props.lang"
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import { ElTag, ElDrawer, ElTabs, ElTabPane, ElScrollbar, ElIcon } from 'element-plus'
3
3
  import { common_animate_list } from '@/components/config'
4
- import SvgAnalysis from '@/components/svg-analysis/index.vue'
4
+ import SvgAnalysis from '@/components/svg-analysis.vue'
5
5
 
6
6
  const props = defineProps<{ val: string }>()
7
7
  const emits = defineEmits(['updateCommonAniVal'])
@@ -14,15 +14,25 @@
14
14
  import { getStringWidth } from '@/utils'
15
15
  import CodeEditModal from '@/components/svg-editor/right-panel/code-edit-modal.vue'
16
16
 
17
+ const emit = defineEmits(['change'])
17
18
  const props = withDefaults(defineProps<{ objInfo?: IConfigItemProps; hide?: string[]; code?: boolean }>(), {
18
19
  objInfo: () => ({}),
19
20
  hide: () => [],
20
21
  code: false
21
22
  })
23
+
24
+ function propsChangeHandle(e: any) {
25
+ let t: any = window.setTimeout(function () {
26
+ emit('change', e)
27
+ clearTimeout(t)
28
+ t = null
29
+ }, 200)
30
+ }
22
31
  </script>
23
32
 
24
33
  <template>
25
34
  <div v-for="(attr_item, key) in props.objInfo" :key="key">
35
+ <!--表单项上显示的灰色值-->
26
36
  <el-form-item v-if="props.code" class="props-row" size="small">
27
37
  <template #label>
28
38
  <el-tooltip
@@ -45,6 +55,7 @@
45
55
  </el-tooltip>
46
56
  <span v-else>{{ attr_item.val }}</span>
47
57
  </el-form-item>
58
+ <!--props-->
48
59
  <el-form-item :label="attr_item.title" size="small" v-if="props.hide.indexOf(String(key)) < 0">
49
60
  <el-select
50
61
  v-if="attr_item.type === EConfigItemPropsType.Select"
@@ -52,6 +63,7 @@
52
63
  placeholder="Select"
53
64
  size="small"
54
65
  :disabled="Boolean(attr_item?.disabled)"
66
+ @change="propsChangeHandle"
55
67
  >
56
68
  <el-option v-for="item in attr_item.options" :key="item.value" :label="item.label" :value="item.value" />
57
69
  </el-select>
@@ -59,11 +71,13 @@
59
71
  v-else-if="attr_item.type === EConfigItemPropsType.InputNumber"
60
72
  v-model="attr_item.val"
61
73
  :disabled="Boolean(attr_item?.disabled)"
74
+ @change="propsChangeHandle"
62
75
  />
63
76
  <el-input
64
77
  v-else-if="attr_item.type === EConfigItemPropsType.Input"
65
78
  v-model="attr_item.val"
66
79
  :disabled="Boolean(attr_item?.disabled)"
80
+ @change="propsChangeHandle"
67
81
  />
68
82
  <el-input
69
83
  v-else-if="attr_item.type === EConfigItemPropsType.Textarea"
@@ -71,21 +85,25 @@
71
85
  autosize
72
86
  type="textarea"
73
87
  :disabled="Boolean(attr_item?.disabled)"
88
+ @change="propsChangeHandle"
74
89
  />
75
90
  <el-color-picker
76
91
  v-else-if="attr_item.type === EConfigItemPropsType.Color"
77
92
  v-model="attr_item.val"
78
93
  :disabled="Boolean(attr_item?.disabled)"
94
+ @change="propsChangeHandle"
79
95
  />
80
96
  <el-switch
81
97
  v-else-if="attr_item.type === EConfigItemPropsType.Switch"
82
98
  v-model="attr_item.val"
83
99
  :disabled="Boolean(attr_item?.disabled)"
100
+ @change="propsChangeHandle"
84
101
  />
85
102
  <code-edit-modal
86
103
  v-else-if="attr_item.type === EConfigItemPropsType.JsonEdit"
87
104
  v-model="attr_item.val"
88
105
  :disabled="Boolean(attr_item?.disabled)"
106
+ @close="propsChangeHandle"
89
107
  />
90
108
  </el-form-item>
91
109
  </div>
@@ -101,4 +119,8 @@
101
119
  .props-popper {
102
120
  max-width: 350px;
103
121
  }
122
+ sdf {
123
+ color: rgb(245, 247, 250);
124
+ background-color: rgb(92, 184, 122);
125
+ }
104
126
  </style>
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import type { IAttrItem } from '@/config/types'
3
3
  import { ElIcon, ElInput } from 'element-plus'
4
- import SvgAnalysis from '@/components/svg-analysis/index.vue'
4
+ import SvgAnalysis from '@/components/svg-analysis.vue'
5
5
 
6
6
  const props = withDefaults(defineProps<{ modelValue: IAttrItem[] }>(), {
7
7
  modelValue: () => [
@@ -22,10 +22,10 @@
22
22
  import { moveAnchors, numberArray, setSvgActualInfo } from '@/utils'
23
23
  import type { IDoneJson } from '@/stores/global/types'
24
24
  import { EGlobalStoreIntention } from '@/stores/global/types'
25
- import DynamicElFormItem from './dynamic-el-form-item.vue'
26
- import CommonAnimate from './common-animate.vue'
27
- import ComponentTree from '@/components/svg-editor/component-tree/index.vue'
28
- import SvgAnalysis from '@/components/svg-analysis/index.vue'
25
+ import DynamicElFormItem from './right-panel/dynamic-el-form-item.vue'
26
+ import CommonAnimate from './right-panel/common-animate.vue'
27
+ import ComponentTree from '@/components/svg-editor/component-tree.vue'
28
+ import SvgAnalysis from '@/components/svg-analysis.vue'
29
29
  import List from '@/components/svg-editor/right-panel/list.vue'
30
30
  import Condition from '@/components/svg-editor/right-panel/condition.vue'
31
31
  import CodeEditModal from '@/components/svg-editor/right-panel/code-edit-modal.vue'
@@ -92,14 +92,24 @@
92
92
  }
93
93
  }
94
94
 
95
- const changHandle = () => {
96
- if (globalStore.handle_svg_info) {
97
- const done_json = globalStore.done_json[globalStore.handle_svg_info.index]
98
- nextTick(function () {
99
- setSvgActualInfo(done_json)
95
+ /**
96
+ * 右侧属性更改,改变画布中对应组件
97
+ * @param cur 当前值
98
+ * @param pre 之前的值
99
+ * @param resize 是否重新获取边框大小
100
+ */
101
+ const changHandle = (cur: any, pre: any, resize?: boolean) => {
102
+ nextTick(function () {
103
+ if (globalStore.handle_svg_info) {
104
+ const done_json = globalStore.done_json[globalStore.handle_svg_info.index]
105
+ if (resize) {
106
+ setSvgActualInfo(done_json, resize)
107
+ } else {
108
+ setSvgActualInfo(done_json)
109
+ }
100
110
  moveAnchors(done_json)
101
- })
102
- }
111
+ }
112
+ })
103
113
  }
104
114
  </script>
105
115
 
@@ -199,10 +209,10 @@
199
209
  <el-form-item label="Y坐标" size="small">
200
210
  <el-input-number v-model="globalStore.handle_svg_info!.info.y" @change="changHandle" />
201
211
  </el-form-item>
202
- <el-form-item label="X缩放" size="small">
212
+ <el-form-item label="X缩放" size="small" v-show="globalStore.handle_svg_info?.info?.config.can_zoom">
203
213
  <el-input-number v-model="globalStore.handle_svg_info!.info.scale_x" @change="changHandle" />
204
214
  </el-form-item>
205
- <el-form-item label="Y缩放" size="small">
215
+ <el-form-item label="Y缩放" size="small" v-show="globalStore.handle_svg_info?.info?.config.can_zoom">
206
216
  <el-input-number v-model="globalStore.handle_svg_info!.info.scale_y" @change="changHandle" />
207
217
  </el-form-item>
208
218
  <el-form-item label="旋转" size="small">
@@ -215,34 +225,40 @@
215
225
  </el-tab-pane>
216
226
  <el-tab-pane label="数据" name="data">
217
227
  <el-form label-width="90px" label-position="left">
228
+ <!--ID-->
218
229
  <el-form-item label="ID" size="small">
219
230
  <el-input v-model="globalStore.handle_svg_info!.info.id" />
220
231
  </el-form-item>
221
- <div
222
- v-for="(e, k) of globalStore.handle_svg_info!.info.state"
223
- :key="'state' + String(k)"
224
- v-if="globalStore.handle_svg_info!.info.state"
225
- >
226
- <el-form-item class="props-row" :label="String(k)" size="small"> {{ e!.default }}</el-form-item>
227
-
228
- <el-form-item
229
- v-if="k === 'OnOff'"
230
- :label="globalStore.handle_svg_info!.info.state?.OnOff!.title"
231
- size="small"
232
- >
233
- <el-switch v-model="globalStore.handle_svg_info!.info.state!.OnOff!.default"></el-switch>
234
- </el-form-item>
235
- </div>
236
-
232
+ <!--state-->
233
+ <el-form-item class="props-row" label="state" size="small" v-if="globalStore.handle_svg_info?.info?.state">
234
+ {{ globalStore.handle_svg_info!.info!.defaultState }}
235
+ </el-form-item>
236
+ <el-form-item v-if="globalStore.handle_svg_info?.info?.state" label="状态" size="small">
237
+ <el-select v-model="globalStore.handle_svg_info!.info!.defaultState" placeholder="Select" size="small">
238
+ <el-option
239
+ v-for="(e, k) of globalStore.handle_svg_info!.info.state"
240
+ :key="'state' + String(k)"
241
+ :label="e.label"
242
+ :value="k"
243
+ />
244
+ </el-select>
245
+ </el-form-item>
246
+ <!--文字插槽-->
237
247
  <div v-if="globalStore.handle_svg_info!.info?.hasOwnProperty('tag_slot')">
238
248
  <el-form-item class="props-row" label="tag_slot" size="small">
239
249
  {{ globalStore.handle_svg_info!.info.tag_slot }}
240
250
  </el-form-item>
241
251
  <el-form-item label="文字插槽" size="small">
242
- <el-input v-model="globalStore.handle_svg_info!.info.tag_slot" />
252
+ <el-input v-model="globalStore.handle_svg_info!.info.tag_slot" @input="changHandle($event, null, true)" />
243
253
  </el-form-item>
244
254
  </div>
245
- <dynamic-el-form-item :obj-info="globalStore.handle_svg_info!.info.props" code />
255
+ <!--props-->
256
+ <dynamic-el-form-item
257
+ :obj-info="globalStore.handle_svg_info!.info.props"
258
+ code
259
+ @change="changHandle($event, null, true)"
260
+ />
261
+ <!--连线动画效果-->
246
262
  <el-form-item
247
263
  :label="globalStore.handle_svg_info!.info.animations.type.title"
248
264
  size="small"
@@ -4,10 +4,10 @@
4
4
  import { useGlobalStore } from '@/stores/global'
5
5
  import { useEditPrivateStore } from '@/stores/system'
6
6
  import { ElIcon, ElDivider, ElDialog, ElScrollbar } from 'element-plus'
7
- import SvgAnalysis from '../../svg-analysis/index.vue'
7
+ import SvgAnalysis from '../svg-analysis.vue'
8
8
  import { useSvgEditLayoutStore } from '@/stores/svg-edit-layout'
9
- import { EVisibleConfKey } from '../types'
10
- import type { IDataModel } from '../types'
9
+ import { EVisibleConfKey } from './types'
10
+ import type { IDataModel } from './types'
11
11
  import { EGlobalStoreIntention } from '@/stores/global/types'
12
12
 
13
13
  const svgEditLayoutStore = useSvgEditLayoutStore(pinia)
@@ -167,6 +167,14 @@
167
167
  <div class="font-bold mb-10px text-15px guide-title">标尺辅助线</div>
168
168
  <div>在标尺区域按住鼠标左键并拖动即可创建标尺辅助线,将标尺辅助线拖动到标尺区域即可删除标尺辅助线</div>
169
169
  <div class="el-divider el-divider--horizontal" role="separator" style="--el-border-style: solid"></div>
170
+ <div class="font-bold mb-10px text-15px guide-title">组件尺寸</div>
171
+ <div
172
+ ><p>
173
+ 大多数组件可以通过选中组件然后拖动交互点或在右侧‘外观’栏改变外形尺寸,或通过右侧‘数据’栏直接或间接改变外形尺寸;</p
174
+ >
175
+ <p>少数特殊组件仅可通过右侧'数据'栏直接或间接改变外形尺寸</p></div
176
+ >
177
+ <div class="el-divider el-divider--horizontal" role="separator" style="--el-border-style: solid"></div>
170
178
  <div class="font-bold mb-10px text-15px guide-title">连线样式</div>
171
179
  <div
172
180
  >在右侧‘连线’栏可以统一配置连线样式,配置后先增加的线会应用新样式,之前的线样式不变,如需改变,可选中线手动更改或删除重画
@@ -6,7 +6,7 @@
6
6
  import { getCommonClass, prosToVBind, setArrItemByID, valFormat } from '@/utils'
7
7
 
8
8
  import { EDoneJsonType, EEventAction, EEventType } from '@/config/types'
9
- import ConnectionLine from '@/components/svg-editor/connection-line/index.vue'
9
+ import ConnectionLine from '@/components/svg-editor/connection-line.vue'
10
10
 
11
11
  import { vueComp } from '@/config'
12
12
  import type { IDataModel } from '@/components/svg-editor/types'
@@ -151,10 +151,10 @@
151
151
  }
152
152
  return { cursor: t ? 'pointer' : 'default' }
153
153
  }
154
- const eventHandle = (root: IDoneJson) => {
154
+ const eventHandle = (root: IDoneJson, type: EEventType) => {
155
155
  if (root.events?.length > 0) {
156
156
  for (let e of root.events) {
157
- if (e.type === EEventType.Click || e.type === EEventType.Change) {
157
+ if (e.type === type) {
158
158
  if (e.condition && e.condition.type !== 'None') {
159
159
  if (e.condition.type === 'Relation' && e.condition.Relation && e.condition.Relation.relation) {
160
160
  const k = e.condition.Relation.key
@@ -188,6 +188,8 @@
188
188
  continue
189
189
  }
190
190
 
191
+ console.log(t, e)
192
+
191
193
  for (let a of e.attrs) {
192
194
  if (t.state && t.state.hasOwnProperty(a.key)) {
193
195
  t.state[a.key].default = valFormat(a.val)
@@ -276,7 +278,7 @@
276
278
  :transform="`translate(${item.x},${item.y})rotate(0)scale(1)`"
277
279
  v-show="item.display"
278
280
  :style="getStyle(item)"
279
- @click="eventHandle(item)"
281
+ @click="eventHandle(item, EEventType.Click)"
280
282
  >
281
283
  <g :class="`${getCommonClass(item)}`">
282
284
  <g
@@ -309,7 +311,7 @@
309
311
  width="100"
310
312
  height="100"
311
313
  :id="item.id"
312
- @on-change="eventHandle(item)"
314
+ @on-change="eventHandle(item, EEventType.Change)"
313
315
  :transform="`translate(${item.actual_bound.x + item.actual_bound.width / 2},${
314
316
  item.actual_bound.y + item.actual_bound.height / 2
315
317
  }) scale(${item.scale_x},${item.scale_y}) translate(${-(
@@ -326,7 +328,7 @@
326
328
  :is="item.tag"
327
329
  v-bind="prosToVBind(item)"
328
330
  :id="item.id"
329
- @on-change="eventHandle(item)"
331
+ @on-change="eventHandle(item, EEventType.Change)"
330
332
  :transform="`translate(${item.actual_bound.x + item.actual_bound.width / 2},${
331
333
  item.actual_bound.y + item.actual_bound.height / 2
332
334
  }) scale(${item.scale_x},${item.scale_y}) translate(${-(
@@ -1,48 +1,48 @@
1
- <template>
2
- <el-table v-bind="table_props">
3
- <el-table-column v-for="item in props.colConfig" :key="item.prop" v-bind="item"></el-table-column>
4
- </el-table>
5
- </template>
6
- <script setup lang="ts">
7
- import { ElTable, ElTableColumn } from 'element-plus'
8
-
9
- const props = withDefaults(
10
- defineProps<{
11
- colConfig: ICol[]
12
- data: any[]
13
- height: number
14
- maxHeight: number
15
- stripe: boolean
16
- border: boolean
17
- size: string
18
- fit: boolean
19
- operateDisplay: boolean
20
- selectionData: any[]
21
- }>(),
22
- {
23
- colConfig: () => [],
24
- data: () => [],
25
- stripe: false,
26
- border: false,
27
- fit: false,
28
- operateDisplay: false,
29
- selectionData: () => []
30
- }
31
- )
32
- const table_props = ref({})
33
- watchEffect(() => {
34
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
35
- const { colConfig, ...temp_props } = props
36
- table_props.value = temp_props
37
- })
38
-
39
- interface ICol {
40
- prop: string
41
- label: string
42
- width: string
43
- fixed: string | boolean
44
- sortable: boolean
45
- 'show-overflow-tooltip': boolean
46
- }
47
- </script>
48
- <style scoped lang="scss"></style>
1
+ <script setup lang="ts">
2
+ import { ElTable, ElTableColumn } from 'element-plus'
3
+
4
+ const props = withDefaults(
5
+ defineProps<{
6
+ colConfig: ICol[]
7
+ data: any[]
8
+ height?: number
9
+ maxHeight?: number
10
+ stripe?: boolean
11
+ border?: boolean
12
+ size?: string
13
+ fit?: boolean
14
+ operateDisplay?: boolean
15
+ selectionData?: any[]
16
+ }>(),
17
+ {
18
+ colConfig: () => [],
19
+ data: () => [],
20
+ height: 200,
21
+ stripe: false,
22
+ border: false,
23
+ fit: false,
24
+ operateDisplay: false,
25
+ selectionData: () => []
26
+ }
27
+ )
28
+ const table_props = ref({})
29
+ watchEffect(() => {
30
+ const { colConfig, ...temp_props } = props
31
+ table_props.value = temp_props
32
+ })
33
+
34
+ interface ICol {
35
+ prop: string
36
+ label: string
37
+ width: string
38
+ fixed: string | boolean
39
+ sortable: boolean
40
+ 'show-overflow-tooltip': boolean
41
+ }
42
+ </script>
43
+
44
+ <template>
45
+ <el-table v-bind="table_props">
46
+ <el-table-column v-for="item in props.colConfig" :key="item.prop" v-bind="item"></el-table-column>
47
+ </el-table>
48
+ </template>
@@ -1,52 +1,71 @@
1
- <script setup lang="ts">
2
- const props = defineProps({
3
- fontColor: {
4
- type: String,
5
- default: '#000000'
6
- }
7
- })
8
- const now_date = ref(new Date())
9
- const timer = ref()
10
- const date = computed(() => {
11
- const year = now_date.value.getFullYear()
12
- const month = now_date.value.getMonth() + 1
13
- const day = now_date.value.getDate()
14
- const time = year.toString() + '' + month.toString() + '' + day.toString() + '日'
15
- return time
16
- })
17
- const week = computed(() => {
18
- const d = now_date.value.getDay()
19
- const weekday = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
20
- const time = weekday[d]
21
- return time
22
- })
23
- const time = computed(() => {
24
- const hour = now_date.value.getHours()
25
- const minute = now_date.value.getMinutes()
26
- const second = now_date.value.getSeconds()
27
- const time =
28
- (hour < 10 ? '0' + hour.toString() : hour.toString()) +
29
- ':' +
30
- (minute < 10 ? '0' + minute.toString() : minute.toString()) +
31
- ':' +
32
- (second < 10 ? '0' + second.toString() : second.toString())
33
- return time
34
- })
35
- onMounted(() => {
36
- timer.value = setInterval(() => {
37
- now_date.value = new Date() // 修改数据date
38
- }, 500)
39
- })
40
- onUnmounted(() => {
41
- clearInterval(timer.value)
42
- })
43
- </script>
44
- <template>
45
- <div>
46
- <div class="text-12px font-bold" :style="{ color: props.fontColor }">{{ date }}</div>
47
- <div class="flex mt-5px">
48
- <div class="text-12px font-bold" :style="{ color: props.fontColor }">{{ week }}</div>
49
- <div class="text-12px font-bold ml-5px" :style="{ color: props.fontColor }">{{ time }}</div>
50
- </div>
51
- </div>
52
- </template>
1
+ <script setup lang="ts">
2
+ const props = defineProps<{
3
+ width: number
4
+ fontFamily: string
5
+ color: string
6
+ fontSize: number
7
+ bold: boolean
8
+ }>()
9
+
10
+ const styles = computed(() => ({
11
+ fontFamily: props.fontFamily,
12
+ color: props.color,
13
+ fontSize: props.fontSize + 'px',
14
+ fontWeight: props.bold ? 'bold' : 'normal'
15
+ }))
16
+
17
+ const now_date = ref(new Date())
18
+ const timer = ref()
19
+ const date = computed(() => {
20
+ const year = now_date.value.getFullYear()
21
+ const month = now_date.value.getMonth() + 1
22
+ const day = now_date.value.getDate()
23
+ return year.toString() + '年' + month.toString() + '月' + day.toString() + '日'
24
+ })
25
+ const week = computed(() => {
26
+ const d = now_date.value.getDay()
27
+ const weekday = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
28
+ return weekday[d]
29
+ })
30
+ const time = computed(() => {
31
+ const hour = now_date.value.getHours()
32
+ const minute = now_date.value.getMinutes()
33
+ const second = now_date.value.getSeconds()
34
+ return (
35
+ (hour < 10 ? '0' + hour.toString() : hour.toString()) +
36
+ ':' +
37
+ (minute < 10 ? '0' + minute.toString() : minute.toString()) +
38
+ ':' +
39
+ (second < 10 ? '0' + second.toString() : second.toString())
40
+ )
41
+ })
42
+
43
+ onMounted(() => {
44
+ timer.value = setInterval(() => {
45
+ now_date.value = new Date() // 修改数据date
46
+ }, 500)
47
+ })
48
+ onUnmounted(() => {
49
+ clearInterval(timer.value)
50
+ })
51
+ </script>
52
+ <template>
53
+ <div class="now-time" :style="{ width: props.width + 'px' }">
54
+ <div :style="styles">{{ date }}</div>
55
+ <div class="flex mt-5px">
56
+ <div :style="styles">{{ week }}</div>
57
+ <div :style="styles">{{ time }}</div>
58
+ </div>
59
+ </div>
60
+ </template>
61
+ <style lang="less" scoped>
62
+ .now-time {
63
+ min-height: 40px;
64
+ min-width: 100px;
65
+ color: #c54e6a;
66
+
67
+ .flex {
68
+ justify-content: space-between;
69
+ }
70
+ }
71
+ </style>