tianheng-ui 0.0.56 → 0.0.58

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.
Files changed (239) hide show
  1. package/lib/039af9192b9bb277966ceb4e4ce29c41.js +16 -0
  2. package/lib/{c755e7fc08446566ee8dd3a8aa8fe43f.js → 2d84c80112a372bc149cad3464e90fa3.js} +404 -502
  3. package/lib/5977b934a4c6b480790864ea01303173.js +10834 -0
  4. package/lib/7745f3e776488705a38e62f85adad54d.js +16 -0
  5. package/lib/de8dee841ffdaaede3a2254deef30376.js +15395 -0
  6. package/lib/e78eab250e7f8ccac3d918dfdb06ca10.js +8904 -0
  7. package/lib/index.js +4 -2
  8. package/lib/theme-chalk/fonts/PingFang.ttf +0 -0
  9. package/lib/theme-chalk/fonts/bpmn.eot +0 -0
  10. package/lib/theme-chalk/fonts/bpmn.svg +224 -0
  11. package/lib/theme-chalk/fonts/bpmn.ttf +0 -0
  12. package/lib/theme-chalk/fonts/bpmn.woff +0 -0
  13. package/lib/theme-chalk/fonts/bpmn.woff2 +0 -0
  14. package/lib/theme-chalk/fonts/fontawesome-webfont.eot +0 -0
  15. package/lib/theme-chalk/fonts/fontawesome-webfont.svg +2671 -0
  16. package/lib/theme-chalk/fonts/fontawesome-webfont.ttf +0 -0
  17. package/lib/theme-chalk/fonts/fontawesome-webfont.woff +0 -0
  18. package/lib/theme-chalk/fonts/fontawesome-webfont.woff2 +0 -0
  19. package/lib/{iconfont.eot → theme-chalk/fonts/iconfont.eot} +0 -0
  20. package/lib/{iconfont.svg → theme-chalk/fonts/iconfont.svg} +0 -0
  21. package/lib/theme-chalk/fonts/iconfont.ttf +0 -0
  22. package/lib/theme-chalk/fonts/iconfont.woff +0 -0
  23. package/lib/theme-chalk/images/notData.png +0 -0
  24. package/lib/theme-chalk/index.scss +30 -0
  25. package/lib/theme-chalk/styles/button.scss +501 -0
  26. package/lib/theme-chalk/styles/card.scss +29 -0
  27. package/lib/theme-chalk/styles/cell.scss +54 -0
  28. package/lib/theme-chalk/styles/codeEditor.scss +9 -0
  29. package/lib/theme-chalk/styles/col.scss +151 -0
  30. package/lib/theme-chalk/styles/dialog.scss +59 -0
  31. package/lib/theme-chalk/styles/empty.scss +22 -0
  32. package/lib/theme-chalk/styles/feature.scss +42 -0
  33. package/lib/theme-chalk/styles/font.css +7 -0
  34. package/lib/theme-chalk/{icon.css → styles/icon.css} +3 -3
  35. package/lib/theme-chalk/styles/imagePreview.scss +113 -0
  36. package/lib/theme-chalk/styles/img.scss +35 -0
  37. package/lib/theme-chalk/styles/reset.scss +8 -0
  38. package/lib/theme-chalk/{root.css → styles/root.css} +2 -35
  39. package/lib/theme-chalk/styles/row.scss +23 -0
  40. package/lib/theme-chalk/styles/upload.scss +598 -0
  41. package/lib/theme-chalk/styles/variable.scss +80 -0
  42. package/lib/tianheng-ui.js +71 -9
  43. package/package.json +24 -4
  44. package/packages/Button/index.js +8 -0
  45. package/packages/Button/index.vue +80 -0
  46. package/packages/Card/index.js +8 -0
  47. package/packages/Card/index.vue +37 -0
  48. package/packages/{cell → Cell}/index.js +0 -0
  49. package/packages/Cell/index.vue +68 -0
  50. package/packages/{codeEditor → CodeEditor}/index.js +0 -0
  51. package/packages/{codeEditor → CodeEditor}/index.vue +73 -108
  52. package/packages/Col/index.js +8 -0
  53. package/packages/Col/index.vue +41 -0
  54. package/packages/{dialog → Dialog}/index.js +0 -0
  55. package/packages/{dialog → Dialog}/index.vue +19 -10
  56. package/packages/Empty/images/notData.png +0 -0
  57. package/packages/{empty → Empty}/index.js +0 -0
  58. package/packages/Empty/index.vue +35 -0
  59. package/packages/FormMaking/Container.vue +755 -0
  60. package/packages/{formMaking → FormMaking}/FormConfig.vue +22 -6
  61. package/packages/FormMaking/GenerateForm.vue +247 -0
  62. package/packages/{formMaking → FormMaking}/GenerateFormItem.vue +340 -172
  63. package/packages/FormMaking/GenerateFormItemH5.vue +828 -0
  64. package/packages/{formMaking → FormMaking}/Upload/index.vue +0 -0
  65. package/packages/FormMaking/WidgetConfig.vue +473 -0
  66. package/packages/{formMaking → FormMaking}/WidgetForm.vue +49 -31
  67. package/packages/FormMaking/WidgetFormItem.vue +157 -0
  68. package/packages/{formMaking/componentsConfig.js → FormMaking/custom/config.js} +379 -163
  69. package/packages/FormMaking/custom/configs/alliance.vue +0 -0
  70. package/packages/FormMaking/custom/configs/blank.vue +54 -0
  71. package/packages/FormMaking/custom/configs/button.vue +144 -0
  72. package/packages/FormMaking/custom/configs/cascader.vue +182 -0
  73. package/packages/FormMaking/custom/configs/cell.vue +81 -0
  74. package/packages/FormMaking/custom/configs/checkbox.vue +237 -0
  75. package/packages/FormMaking/custom/configs/color.vue +137 -0
  76. package/packages/FormMaking/custom/configs/date.vue +158 -0
  77. package/packages/FormMaking/custom/configs/divider.vue +61 -0
  78. package/packages/FormMaking/custom/configs/editor.vue +71 -0
  79. package/packages/FormMaking/custom/configs/filler.vue +52 -0
  80. package/packages/FormMaking/custom/configs/grid.vue +103 -0
  81. package/packages/FormMaking/custom/configs/image.vue +148 -0
  82. package/packages/FormMaking/custom/configs/input.vue +176 -0
  83. package/packages/FormMaking/custom/configs/number.vue +140 -0
  84. package/packages/FormMaking/custom/configs/radio.vue +215 -0
  85. package/packages/FormMaking/custom/configs/rate.vue +109 -0
  86. package/packages/FormMaking/custom/configs/select.vue +308 -0
  87. package/packages/FormMaking/custom/configs/slider.vue +142 -0
  88. package/packages/FormMaking/custom/configs/switch.vue +130 -0
  89. package/packages/FormMaking/custom/configs/table.vue +105 -0
  90. package/packages/FormMaking/custom/configs/table_h5.vue +102 -0
  91. package/packages/FormMaking/custom/configs/tabs.vue +175 -0
  92. package/packages/FormMaking/custom/configs/text.vue +71 -0
  93. package/packages/FormMaking/custom/configs/textarea.vue +167 -0
  94. package/packages/FormMaking/custom/configs/time.vue +153 -0
  95. package/packages/FormMaking/custom/configs/upload.vue +150 -0
  96. package/packages/FormMaking/custom/index.js +33 -0
  97. package/packages/FormMaking/custom/items/alliance.vue +132 -0
  98. package/packages/FormMaking/custom/items/blank.vue +16 -0
  99. package/packages/FormMaking/custom/items/button.vue +27 -0
  100. package/packages/FormMaking/custom/items/cascader.vue +29 -0
  101. package/packages/FormMaking/custom/items/cell.vue +18 -0
  102. package/packages/FormMaking/custom/items/checkbox.vue +46 -0
  103. package/packages/FormMaking/custom/items/color.vue +19 -0
  104. package/packages/FormMaking/custom/items/date.vue +29 -0
  105. package/packages/FormMaking/custom/items/divider.vue +14 -0
  106. package/packages/FormMaking/custom/items/editor.vue +22 -0
  107. package/packages/FormMaking/custom/items/filler.vue +17 -0
  108. package/packages/FormMaking/custom/items/grid.vue +129 -0
  109. package/packages/FormMaking/custom/items/image.vue +42 -0
  110. package/packages/FormMaking/custom/items/input.vue +36 -0
  111. package/packages/FormMaking/custom/items/login.vue +13 -0
  112. package/packages/FormMaking/custom/items/number.vue +24 -0
  113. package/packages/FormMaking/custom/items/radio.vue +44 -0
  114. package/packages/FormMaking/custom/items/rate.vue +20 -0
  115. package/packages/FormMaking/custom/items/select.vue +32 -0
  116. package/packages/FormMaking/custom/items/slider.vue +34 -0
  117. package/packages/FormMaking/custom/items/switch.vue +22 -0
  118. package/packages/FormMaking/custom/items/table.vue +106 -0
  119. package/packages/FormMaking/custom/items/table_h5.vue +126 -0
  120. package/packages/FormMaking/custom/items/tabs.vue +145 -0
  121. package/packages/FormMaking/custom/items/text.vue +18 -0
  122. package/packages/FormMaking/custom/items/textarea.vue +37 -0
  123. package/packages/FormMaking/custom/items/time.vue +32 -0
  124. package/packages/FormMaking/custom/items/upload.vue +83 -0
  125. package/packages/FormMaking/custom/mixins/index.js +61 -0
  126. package/packages/FormMaking/custom/register.js +18 -0
  127. package/packages/{formMaking → FormMaking}/iconfont/demo.css +0 -0
  128. package/packages/{formMaking → FormMaking}/iconfont/demo_index.html +0 -0
  129. package/packages/{formMaking → FormMaking}/iconfont/iconfont.css +0 -0
  130. package/packages/{formMaking → FormMaking}/iconfont/iconfont.eot +0 -0
  131. package/packages/{formMaking → FormMaking}/iconfont/iconfont.js +0 -0
  132. package/packages/{formMaking → FormMaking}/iconfont/iconfont.svg +0 -0
  133. package/{lib → packages/FormMaking/iconfont}/iconfont.ttf +0 -0
  134. package/{lib → packages/FormMaking/iconfont}/iconfont.woff +0 -0
  135. package/packages/{formMaking → FormMaking}/iconfont/iconfont.woff2 +0 -0
  136. package/packages/FormMaking/index.js +35 -0
  137. package/packages/{formMaking → FormMaking}/lang/en-US.js +1 -1
  138. package/packages/{formMaking → FormMaking}/lang/zh-CN.js +1 -1
  139. package/packages/{formMaking → FormMaking}/styles/cover.scss +1 -1
  140. package/packages/{formMaking → FormMaking}/styles/index.scss +445 -429
  141. package/packages/{formMaking → FormMaking/util}/generateCode.js +5 -5
  142. package/packages/{formMaking → FormMaking}/util/index.js +0 -0
  143. package/packages/{formMaking → FormMaking}/util/request.js +0 -0
  144. package/packages/{icons → Icons}/index.js +0 -0
  145. package/packages/{icons → Icons}/index.vue +26 -9
  146. package/packages/Image/index.js +8 -0
  147. package/packages/Image/index.vue +146 -0
  148. package/packages/ImagePreview/index.js +8 -0
  149. package/packages/ImagePreview/index.vue +386 -0
  150. package/packages/Row/index.js +8 -0
  151. package/packages/Row/index.vue +35 -0
  152. package/packages/{table → Table}/action.js +0 -0
  153. package/packages/{table → Table}/action.vue +1 -1
  154. package/packages/Table/column.vue +63 -0
  155. package/packages/{table → Table}/index.js +0 -0
  156. package/packages/{table → Table}/index.vue +25 -23
  157. package/packages/{table → Table}/search.js +0 -0
  158. package/packages/{table → Table}/search.vue +2 -2
  159. package/packages/{table → Table}/tools.js +0 -0
  160. package/packages/{table → Table}/tools.vue +0 -0
  161. package/packages/Workflow/Log.js +99 -0
  162. package/packages/Workflow/designer/ProcessDesigner.vue +628 -0
  163. package/packages/Workflow/designer/index.js +7 -0
  164. package/packages/Workflow/designer/plugins/content-pad/contentPadProvider.js +390 -0
  165. package/packages/Workflow/designer/plugins/content-pad/index.js +6 -0
  166. package/packages/Workflow/designer/plugins/defaultEmpty.js +24 -0
  167. package/packages/Workflow/designer/plugins/descriptor/activitiDescriptor.json +1071 -0
  168. package/packages/Workflow/designer/plugins/descriptor/camundaDescriptor.json +1087 -0
  169. package/packages/Workflow/designer/plugins/descriptor/flowableDescriptor.json +1215 -0
  170. package/packages/Workflow/designer/plugins/extension-moddle/activiti/activitiExtension.js +74 -0
  171. package/packages/Workflow/designer/plugins/extension-moddle/activiti/index.js +9 -0
  172. package/packages/Workflow/designer/plugins/extension-moddle/camunda/extension.js +148 -0
  173. package/packages/Workflow/designer/plugins/extension-moddle/camunda/index.js +6 -0
  174. package/packages/Workflow/designer/plugins/extension-moddle/flowable/flowableExtension.js +74 -0
  175. package/packages/Workflow/designer/plugins/extension-moddle/flowable/index.js +9 -0
  176. package/packages/Workflow/designer/plugins/palette/CustomPalette.js +156 -0
  177. package/packages/Workflow/designer/plugins/palette/index.js +6 -0
  178. package/packages/Workflow/designer/plugins/palette/paletteProvider.js +160 -0
  179. package/packages/Workflow/designer/plugins/translate/customTranslate.js +41 -0
  180. package/packages/Workflow/designer/plugins/translate/zh.js +238 -0
  181. package/packages/Workflow/highlight/index.js +5 -0
  182. package/packages/Workflow/index.js +26 -0
  183. package/packages/Workflow/index.vue +395 -0
  184. package/packages/Workflow/modules/auto-place/CustomAutoPlace.js +81 -0
  185. package/packages/Workflow/modules/auto-place/index.js +6 -0
  186. package/packages/Workflow/modules/custom-renderer/CustomRenderer.js +17 -0
  187. package/packages/Workflow/modules/custom-renderer/index.js +6 -0
  188. package/packages/Workflow/modules/rules/CustomRules.js +16 -0
  189. package/packages/Workflow/modules/rules/index.js +6 -0
  190. package/packages/Workflow/palette/ProcessPalette.vue +106 -0
  191. package/packages/Workflow/palette/index.js +7 -0
  192. package/packages/Workflow/penal/PropertiesPanel.vue +247 -0
  193. package/packages/Workflow/penal/base/ElementBaseInfo.vue +80 -0
  194. package/packages/Workflow/penal/flow-condition/FlowCondition.vue +142 -0
  195. package/packages/Workflow/penal/form/ElementForm.vue +367 -0
  196. package/packages/Workflow/penal/index.js +7 -0
  197. package/packages/Workflow/penal/listeners/ElementListeners.vue +299 -0
  198. package/packages/Workflow/penal/listeners/UserTaskListeners.vue +322 -0
  199. package/packages/Workflow/penal/listeners/template.js +178 -0
  200. package/packages/Workflow/penal/listeners/utilSelf.js +62 -0
  201. package/packages/Workflow/penal/multi-instance/ElementMultiInstance.vue +200 -0
  202. package/packages/Workflow/penal/other/ElementOtherConfig.vue +59 -0
  203. package/packages/Workflow/penal/properties/ElementProperties.vue +135 -0
  204. package/packages/Workflow/penal/signal-message/SignalAndMessage.vue +104 -0
  205. package/packages/Workflow/penal/task/ElementTask.vue +73 -0
  206. package/packages/Workflow/penal/task/task-components/ReceiveTask.vue +97 -0
  207. package/packages/Workflow/penal/task/task-components/ScriptTask.vue +85 -0
  208. package/packages/Workflow/penal/task/task-components/UserTask.vue +535 -0
  209. package/packages/Workflow/theme/element-variables.scss +70 -0
  210. package/packages/Workflow/theme/index.scss +2 -0
  211. package/packages/Workflow/theme/process-designer.scss +157 -0
  212. package/packages/Workflow/theme/process-panel.scss +107 -0
  213. package/packages/Workflow/translations.js +25 -0
  214. package/packages/Workflow/utils.js +71 -0
  215. package/packages/upload/ajax.js +85 -0
  216. package/packages/upload/index.js +8 -0
  217. package/packages/upload/index.vue +325 -0
  218. package/packages/upload/locale.js +9 -0
  219. package/packages/upload/upload-dragger.vue +70 -0
  220. package/packages/upload/upload-list.vue +123 -0
  221. package/packages/upload/upload.vue +211 -0
  222. package/lib/03250ed25fc1b305e9980cf7cf0dfb09.js +0 -1
  223. package/lib/theme-chalk/cell.css +0 -53
  224. package/lib/theme-chalk/dialog.css +0 -41
  225. package/lib/theme-chalk/empty.css +0 -27
  226. package/lib/theme-chalk/index.css +0 -6
  227. package/lib/theme-chalk/reset.css +0 -4
  228. package/lib/tianheng-ui.js.map +0 -1
  229. package/packages/cell/index.vue +0 -116
  230. package/packages/empty/index.vue +0 -33
  231. package/packages/formMaking/Container.vue +0 -591
  232. package/packages/formMaking/CusDialog.vue +0 -134
  233. package/packages/formMaking/GenerateForm.vue +0 -174
  234. package/packages/formMaking/WidgetConfig.vue +0 -1539
  235. package/packages/formMaking/WidgetFormItem.vue +0 -817
  236. package/packages/formMaking/iconfont/iconfont.ttf +0 -0
  237. package/packages/formMaking/iconfont/iconfont.woff +0 -0
  238. package/packages/formMaking/index.js +0 -77
  239. package/packages/table/column.vue +0 -111
@@ -0,0 +1,755 @@
1
+ <template>
2
+ <div class="fm-container">
3
+ <el-container class="container-box">
4
+ <el-main>
5
+ <el-container>
6
+ <!-- 左侧字段区 -->
7
+ <el-aside width="250px">
8
+ <div class="components-list">
9
+ <div v-if="basicFields.length">
10
+ <div class="widget-cate">基础字段</div>
11
+ <draggable
12
+ tag="ul"
13
+ :list="getBasicComponents"
14
+ v-bind="{
15
+ group: { name: 'people', pull: 'clone', put: false },
16
+ sort: false,
17
+ ghostClass: 'ghost'
18
+ }"
19
+ >
20
+ <li
21
+ v-for="(item, index) in getBasicComponents"
22
+ class="form-edit-widget-label"
23
+ :class="{
24
+ 'no-put': item.type == 'divider',
25
+ [item.type]: true
26
+ }"
27
+ :key="index"
28
+ >
29
+ <a>
30
+ <i class="icon iconfont" :class="item.icon"></i>
31
+ <span>{{ item.name }}</span>
32
+ </a>
33
+ </li>
34
+ </draggable>
35
+ </div>
36
+
37
+ <div v-if="advanceFields.length">
38
+ <div class="widget-cate">高级字段</div>
39
+ <draggable
40
+ tag="ul"
41
+ :list="getAdvanceComponents"
42
+ v-bind="{
43
+ group: { name: 'people', pull: 'clone', put: false },
44
+ sort: false,
45
+ ghostClass: 'ghost'
46
+ }"
47
+ >
48
+ <li
49
+ v-for="(item, index) in getAdvanceComponents"
50
+ class="form-edit-widget-label"
51
+ :class="{
52
+ 'no-put': ['table', 'table_h5', 'tabs'].includes(
53
+ item.type
54
+ ),
55
+ [item.type]: true
56
+ }"
57
+ :key="index"
58
+ >
59
+ <a>
60
+ <i class="icon iconfont" :class="item.icon"></i>
61
+ <span>{{ item.name }}</span>
62
+ </a>
63
+ </li>
64
+ </draggable>
65
+ </div>
66
+
67
+ <div v-if="layoutFields.length">
68
+ <div class="widget-cate">布局字段</div>
69
+ <draggable
70
+ tag="ul"
71
+ :list="getLayoutComponents"
72
+ v-bind="{
73
+ group: { name: 'people', pull: 'clone', put: false },
74
+ sort: false,
75
+ ghostClass: 'ghost'
76
+ }"
77
+ >
78
+ <li
79
+ v-for="(item, index) in getLayoutComponents"
80
+ class="form-edit-widget-label"
81
+ :class="{
82
+ 'no-put': ['alliance'].includes(item.type),
83
+ [item.type]: true
84
+ }"
85
+ :key="index"
86
+ >
87
+ <a>
88
+ <i class="icon iconfont" :class="item.icon"></i>
89
+ <span>{{ item.name }}</span>
90
+ </a>
91
+ </li>
92
+ </draggable>
93
+ </div>
94
+ </div>
95
+ </el-aside>
96
+
97
+ <!-- 中间视图区 -->
98
+ <el-container class="center-container" direction="vertical">
99
+ <!-- 操作区 -->
100
+ <el-header>
101
+ <div class="client">
102
+ <i
103
+ class="el-icon-monitor"
104
+ :class="{ active: client === 'monitor' }"
105
+ @click="client = 'monitor'"
106
+ ></i>
107
+ <i
108
+ class="el-icon-mobile"
109
+ :class="{ active: client === 'mobile' }"
110
+ @click="client = 'mobile'"
111
+ ></i>
112
+ </div>
113
+ <slot name="action"> </slot>
114
+ <el-popover placement="top" trigger="hover" style="margin:0 10px;">
115
+ <el-button
116
+ type="text"
117
+ size="medium"
118
+ icon="el-icon-upload2"
119
+ slot="reference"
120
+ >导入</el-button
121
+ >
122
+ <div>
123
+ <el-upload
124
+ action
125
+ accept=".xlsx, .xls"
126
+ :auto-upload="false"
127
+ :show-file-list="false"
128
+ :on-change="onExcelFileChange"
129
+ >
130
+ <el-button v-if="upload" type="text" size="medium"
131
+ >导入EXCEL
132
+ </el-button>
133
+ </el-upload>
134
+ <el-button
135
+ v-if="upload"
136
+ type="text"
137
+ size="medium"
138
+ @click="dialog.import.visible = true"
139
+ >导入JSON
140
+ </el-button>
141
+ </div>
142
+ </el-popover>
143
+
144
+ <el-button
145
+ v-if="clearable"
146
+ type="text"
147
+ size="medium"
148
+ icon="el-icon-delete"
149
+ @click="handleClear"
150
+ >清空
151
+ </el-button>
152
+ <el-button
153
+ v-if="preview"
154
+ type="text"
155
+ size="medium"
156
+ icon="el-icon-view"
157
+ @click="handlePreview"
158
+ >预览
159
+ </el-button>
160
+ <el-button
161
+ v-if="generateJson"
162
+ type="text"
163
+ size="medium"
164
+ icon="el-icon-tickets"
165
+ @click="handleGenerateJson"
166
+ >生成JSON</el-button
167
+ >
168
+ <el-button
169
+ v-if="generateCode"
170
+ type="text"
171
+ size="medium"
172
+ icon="el-icon-document"
173
+ @click="handleGenerateCode"
174
+ >生成代码</el-button
175
+ >
176
+ </el-header>
177
+
178
+ <!-- 工作区 -->
179
+ <el-main>
180
+ <widget-form
181
+ ref="widgetForm"
182
+ :data="widgetFormData"
183
+ :select.sync="widgetFormSelect"
184
+ :client="client"
185
+ >
186
+ </widget-form>
187
+ </el-main>
188
+ </el-container>
189
+
190
+ <!-- 右侧配置区 -->
191
+ <el-aside class="config-container">
192
+ <el-container>
193
+ <el-header height="45px">
194
+ <div
195
+ class="config-tab"
196
+ :class="{ active: configTab == 'widget' }"
197
+ @click="handleConfigSelect('widget')"
198
+ >
199
+ 字段属性
200
+ </div>
201
+ <div
202
+ class="config-tab"
203
+ :class="{ active: configTab == 'form' }"
204
+ @click="handleConfigSelect('form')"
205
+ >
206
+ 表单属性
207
+ </div>
208
+ </el-header>
209
+ <el-main class="config-container-content">
210
+ <widget-config
211
+ v-show="configTab == 'widget'"
212
+ :data="widgetFormSelect"
213
+ :remoteApis="remoteApis"
214
+ :config="widgetFormData.config"
215
+ >
216
+ </widget-config>
217
+ <form-config
218
+ v-show="configTab == 'form'"
219
+ :data="widgetFormData.config"
220
+ ></form-config>
221
+ </el-main>
222
+ </el-container>
223
+ </el-aside>
224
+
225
+ <!-- 导入JSON -->
226
+ <th-dialog
227
+ title="导入JSON"
228
+ :visible="dialog.import.visible"
229
+ @on-close="dialog.import.visible = false"
230
+ @on-affirm="handleUploadJson"
231
+ @on-fullscreen="$refs.valueCodeEditor.resize()"
232
+ >
233
+ <el-alert
234
+ type="info"
235
+ title="JSON格式如下,直接复制生成的json覆盖此处代码点击确定即可"
236
+ ></el-alert>
237
+ <th-code-editor
238
+ v-model="dialog.import.value"
239
+ ref="valueCodeEditor"
240
+ ></th-code-editor>
241
+ </th-dialog>
242
+
243
+ <!-- 预览 -->
244
+ <th-dialog
245
+ title="预览"
246
+ :visible="dialog.preview.visible"
247
+ @on-close="dialog.preview.visible = false"
248
+ >
249
+ <generate-form
250
+ v-if="dialog.preview.visible"
251
+ :data="widgetFormData"
252
+ :value="widgetValue"
253
+ :remote="remoteFuncs"
254
+ :slotKeys="slotKeys"
255
+ :client="client"
256
+ insite="true"
257
+ @on-change="handleDataChange"
258
+ ref="generateForm"
259
+ >
260
+ <template v-for="name in slotKeys" :slot="name">
261
+ <slot :name="name" />
262
+ </template>
263
+ </generate-form>
264
+
265
+ <template slot="footer">
266
+ <el-button type="primary" @click="handleGetData"
267
+ >获取数据</el-button
268
+ >
269
+ <el-button @click="handleReset">重置</el-button>
270
+ </template>
271
+ </th-dialog>
272
+
273
+ <!-- 获取数据 -->
274
+ <th-dialog
275
+ title="获取数据"
276
+ :visible="dialog.data.visible"
277
+ @on-close="dialog.data.visible = false"
278
+ @on-fullscreen="$refs.dataCodeEditor.resize()"
279
+ >
280
+ <th-code-editor
281
+ v-model="dialog.data.value"
282
+ ref="dataCodeEditor"
283
+ ></th-code-editor>
284
+
285
+ <template slot="footer">
286
+ <el-button
287
+ type="primary"
288
+ class="json-btn"
289
+ :data-clipboard-text="dialog.data.valueCopy"
290
+ >复制数据</el-button
291
+ >
292
+ </template>
293
+ </th-dialog>
294
+
295
+ <!-- 生成json -->
296
+ <th-dialog
297
+ title="生成JSON"
298
+ :visible="dialog.config.visible"
299
+ @on-close="dialog.config.visible = false"
300
+ @on-fullscreen="$refs.jsonCodeEditor.resize()"
301
+ >
302
+ <th-code-editor
303
+ v-model="dialog.config.value"
304
+ ref="jsonCodeEditor"
305
+ ></th-code-editor>
306
+
307
+ <template slot="footer">
308
+ <el-button
309
+ type="primary"
310
+ class="json-btn"
311
+ :data-clipboard-text="dialog.config.valueCopy"
312
+ >复制数据</el-button
313
+ >
314
+ </template>
315
+ </th-dialog>
316
+
317
+ <!-- 生成代码 -->
318
+ <th-dialog
319
+ class="codeDialog"
320
+ title="生成代码"
321
+ :visible="dialog.code.visible"
322
+ :showFooter="false"
323
+ @on-close="dialog.code.visible = false"
324
+ @on-fullscreen="handleDialogFullscreen"
325
+ >
326
+ <el-tabs
327
+ type="border-card"
328
+ style="box-shadow: none;"
329
+ v-model="dialog.code.type"
330
+ >
331
+ <el-tab-pane label="Vue Component" name="vue">
332
+ <th-code-editor
333
+ v-model="dialog.code.valueVue"
334
+ language="html"
335
+ readonly
336
+ ref="vueCodeEditor"
337
+ ></th-code-editor>
338
+ </el-tab-pane>
339
+ <el-tab-pane label="HTML" name="html">
340
+ <th-code-editor
341
+ v-model="dialog.code.valueHtml"
342
+ language="html"
343
+ readonly
344
+ ref="htmlCodeEditor"
345
+ ></th-code-editor>
346
+ </el-tab-pane>
347
+ </el-tabs>
348
+ </th-dialog>
349
+ </el-container>
350
+ </el-main>
351
+ </el-container>
352
+ </div>
353
+ </template>
354
+
355
+ <script>
356
+ import Draggable from "vuedraggable";
357
+ import Clipboard from "clipboard";
358
+ import WidgetConfig from "./WidgetConfig";
359
+ import FormConfig from "./FormConfig";
360
+ import WidgetForm from "./WidgetForm";
361
+ import GenerateForm from "./GenerateForm";
362
+ import ThDialog from "ui/dialog/index.vue";
363
+ import ThCodeEditor from "ui/codeEditor/index.vue";
364
+ import {
365
+ basicComponents,
366
+ advanceComponents,
367
+ layoutComponents,
368
+ baseConfig
369
+ } from "./custom/config";
370
+ import request from "./util/request";
371
+ import generateCode from "./util/generateCode.js";
372
+ import * as XLSX from "xlsx/xlsx.mjs";
373
+
374
+ export default {
375
+ name: "th-making-form",
376
+ components: {
377
+ Draggable,
378
+ WidgetConfig,
379
+ FormConfig,
380
+ WidgetForm,
381
+ GenerateForm,
382
+ ThDialog,
383
+ ThCodeEditor
384
+ },
385
+ props: {
386
+ preview: {
387
+ type: Boolean,
388
+ default: false
389
+ },
390
+ generateCode: {
391
+ type: Boolean,
392
+ default: false
393
+ },
394
+ generateJson: {
395
+ type: Boolean,
396
+ default: false
397
+ },
398
+ upload: {
399
+ type: Boolean,
400
+ default: false
401
+ },
402
+ clearable: {
403
+ type: Boolean,
404
+ default: false
405
+ },
406
+ basicFields: {
407
+ type: Array,
408
+ default: () => [
409
+ "input",
410
+ "textarea",
411
+ "cell",
412
+ "radio",
413
+ "checkbox",
414
+ "time",
415
+ "date",
416
+ "rate",
417
+ "number",
418
+ "color",
419
+ "select",
420
+ "switch",
421
+ "slider",
422
+ "text",
423
+ "button",
424
+ "filler",
425
+ "image",
426
+ "upload",
427
+ "editor",
428
+ "cascader"
429
+ ]
430
+ },
431
+ advanceFields: {
432
+ type: Array,
433
+ default: () => ["table", "table_h5", "tabs", "blank"]
434
+ },
435
+ layoutFields: {
436
+ type: Array,
437
+ default: () => ["grid", "alliance", "divider"]
438
+ },
439
+ remoteApis: {
440
+ type: Array,
441
+ default: () => []
442
+ }
443
+ },
444
+ data() {
445
+ return {
446
+ basicComponents,
447
+ layoutComponents,
448
+ advanceComponents,
449
+ widgetFormSelect: null,
450
+ widgetFormData: {
451
+ list: [],
452
+ config: baseConfig
453
+ },
454
+ widgetValue: {},
455
+ configTab: "widget",
456
+ client: "monitor",
457
+ dialog: {
458
+ import: { visible: false, value: "" },
459
+ preview: { visible: false, value: "" },
460
+ data: { visible: false, value: "", valueCopy: "" },
461
+ config: { visible: false, value: "", valueCopy: "" },
462
+ code: { visible: false, valueHtml: "", valueVue: "", type: "vue" }
463
+ },
464
+ remoteFuncs: {
465
+ func_test(resolve) {
466
+ setTimeout(() => {
467
+ const options = [
468
+ { id: "1", name: "1111" },
469
+ { id: "2", name: "2222" },
470
+ { id: "3", name: "3333" }
471
+ ];
472
+
473
+ resolve(options);
474
+ }, 2000);
475
+ },
476
+ funcGetToken(resolve) {
477
+ request
478
+ .get("http://tools-server.making.link/api/uptoken")
479
+ .then(res => {
480
+ resolve(res.uptoken);
481
+ });
482
+ },
483
+ upload_callback(response, file, fileList) {
484
+ console.log("callback", response, file, fileList);
485
+ }
486
+ },
487
+ jsonClipboard: null,
488
+ slotKeys: []
489
+ };
490
+ },
491
+ computed: {
492
+ getBasicComponents() {
493
+ const list = this.basicComponents.filter(e => {
494
+ return this.basicFields.includes(e.type);
495
+ });
496
+ return list;
497
+ },
498
+ getAdvanceComponents() {
499
+ const list = this.advanceComponents.filter(e => {
500
+ return this.advanceFields.includes(e.type);
501
+ });
502
+ return list;
503
+ },
504
+ getLayoutComponents() {
505
+ const list = this.layoutComponents.filter(e => {
506
+ return this.layoutFields.includes(e.type);
507
+ });
508
+ return list;
509
+ }
510
+ },
511
+ mounted() {},
512
+ methods: {
513
+ // 读取excel file
514
+ readExcelFile(file) {
515
+ //文件读取
516
+ return new Promise(resolve => {
517
+ let reader = new FileReader();
518
+ reader.readAsBinaryString(file); //以二进制的方式读取
519
+ reader.onload = ev => {
520
+ resolve(ev.target.result);
521
+ };
522
+ });
523
+ },
524
+ // excel 文件上传 改变监听
525
+ async onExcelFileChange(ev) {
526
+ let file = ev.raw;
527
+ if (!file) {
528
+ console.log("文件打开失败");
529
+ return;
530
+ } else {
531
+ let data = await this.readExcelFile(file);
532
+ //XLSX 文档 https://www.npmjs.com/package/xlsx
533
+ let workbook = XLSX.read(data, { type: "binary" }); //解析二进制格式数据
534
+ let worksheet = workbook.Sheets[workbook.SheetNames[0]]; //获取第一个Sheet
535
+
536
+ // console.log("XLSX.read => \n", workbook);
537
+ // console.log("sheet_to_json => \n", XLSX.utils.sheet_to_json(worksheet));
538
+ // console.log("sheet_to_csv => \n", XLSX.utils.sheet_to_csv(worksheet));
539
+ // console.log("sheet_to_txt => \n", XLSX.utils.sheet_to_txt(worksheet));
540
+ const xlsxDom = this.parseDom(XLSX.utils.sheet_to_html(worksheet));
541
+ // console.log("sheet_to_html => \n", xlsxDom);
542
+ const rowsDom = xlsxDom.getElementsByTagName("tr");
543
+ console.log("rowsDom =>", rowsDom);
544
+ let rowSpan = 0;
545
+ for (let i = 0; i < rowsDom[0].childNodes.length; i++) {
546
+ const col = rowsDom[0].childNodes[i];
547
+ rowSpan += col.colSpan || 1;
548
+ }
549
+ console.log("rowSpan =>", rowSpan);
550
+ const colSpan = 24 / rowSpan;
551
+
552
+ let config = {
553
+ list: [],
554
+ config: {
555
+ ui: "element",
556
+ title: "",
557
+ width: "",
558
+ labelWidth: 100,
559
+ labelPosition: "right",
560
+ labelSuffix: ":",
561
+ size: "small",
562
+ disabled: false,
563
+ hideLabel: false,
564
+ eventScript: [
565
+ {
566
+ key: "mounted",
567
+ name: "mounted",
568
+ func: ""
569
+ },
570
+ {
571
+ key: "refresh",
572
+ name: "refresh",
573
+ func: ""
574
+ }
575
+ ]
576
+ }
577
+ };
578
+
579
+ for (const row of rowsDom) {
580
+ const key =
581
+ Date.parse(new Date()) + "_" + Math.ceil(Math.random() * 99999);
582
+ let grid = this.getComponentsConfig("grid");
583
+ grid.columns = [];
584
+ grid.key = key;
585
+ grid.model = "grid_" + key;
586
+
587
+ const colsDom = row.childNodes;
588
+ console.log("colsDom =>", colsDom);
589
+ // continue;
590
+ let span = 0;
591
+ for (let i = 0; i < colsDom.length; i++) {
592
+ if (i % 2 === 0) span = 0;
593
+ else continue;
594
+
595
+ const colKey =
596
+ Date.parse(new Date()) + "_" + Math.ceil(Math.random() * 99999);
597
+ const col1 = colsDom[i];
598
+ const col2 = colsDom[i + 1];
599
+ if (!col1.innerText && !col2.innerText) continue;
600
+
601
+ if (colsDom[i + 1]) {
602
+ span = ((col1.colSpan || 1) + (col2.colSpan || 1)) * colSpan;
603
+
604
+ const data = this.getComponentsConfig("input");
605
+ data.name = col1.innerText;
606
+ data.options.defaultValue = col2.innerText;
607
+ data.key = colKey;
608
+ data.model = "input_" + colKey;
609
+ grid.columns.push({ span: span, list: [data] });
610
+ } else {
611
+ span = col1.colSpan * colSpan;
612
+
613
+ const data = this.getComponentsConfig("text");
614
+ data.name = col1.innerText;
615
+ data.options.defaultValue = col1.innerText;
616
+ data.options.hideLabel = true;
617
+ data.key = colKey;
618
+ data.model = "text_" + colKey;
619
+ grid.columns.push({ span: span, list: [data] });
620
+ }
621
+ }
622
+ if (grid.columns.length) {
623
+ config.list.push(grid);
624
+ } else {
625
+ const data = this.getComponentsConfig("filler");
626
+ data.name = "";
627
+ data.key = key;
628
+ data.model = "filler_" + key;
629
+ config.list.push(data);
630
+ }
631
+ }
632
+ this.setJSON(config);
633
+ }
634
+ },
635
+ getComponentsConfig(type) {
636
+ let data = null;
637
+ for (const item of this.basicComponents) {
638
+ if (type === item.type) {
639
+ data = JSON.parse(JSON.stringify(item));
640
+ return data;
641
+ }
642
+ }
643
+ for (const item of this.layoutComponents) {
644
+ if (type === item.type) {
645
+ data = JSON.parse(JSON.stringify(item));
646
+ return data;
647
+ }
648
+ }
649
+ return data;
650
+ },
651
+
652
+ parseDom(arg) {
653
+ var objE = document.createElement("div");
654
+ objE.innerHTML = arg;
655
+ return objE.childNodes[2];
656
+ },
657
+
658
+ initClipboard() {
659
+ if (!this.jsonClipboard) {
660
+ this.jsonClipboard = new Clipboard(".json-btn");
661
+ this.jsonClipboard.on("success", e => {
662
+ this.$message.success("复制成功");
663
+ });
664
+ }
665
+ },
666
+ handleConfigSelect(value) {
667
+ this.configTab = value;
668
+ },
669
+ handlePreview() {
670
+ this.slotKeys = Object.keys(this.$slots);
671
+ this.dialog.preview.visible = true;
672
+ },
673
+ handleGetData() {
674
+ this.$refs.generateForm.getData().then(data => {
675
+ this.dialog.data = {
676
+ visible: true,
677
+ value: JSON.stringify(data, null, 2),
678
+ valueCopy: JSON.stringify(data, null, 2)
679
+ };
680
+ this.$nextTick(() => {
681
+ this.initClipboard();
682
+ });
683
+ });
684
+ },
685
+ handleReset() {
686
+ this.$refs.generateForm.reset();
687
+ },
688
+ handleGenerateJson() {
689
+ this.dialog.config = {
690
+ visible: true,
691
+ value: JSON.stringify(this.widgetFormData, null, 2),
692
+ valueCopy: JSON.stringify(this.widgetFormData, null, 2)
693
+ };
694
+ this.$nextTick(() => {
695
+ this.initClipboard();
696
+ });
697
+ },
698
+ handleGenerateCode() {
699
+ this.dialog.code = {
700
+ visible: true,
701
+ valueHtml: generateCode(JSON.stringify(this.widgetFormData), "html"),
702
+ valueVue: generateCode(JSON.stringify(this.widgetFormData), "vue"),
703
+ type: "vue"
704
+ };
705
+ },
706
+ handleUploadJson() {
707
+ try {
708
+ this.setJSON(JSON.parse(this.dialog.import.value));
709
+ this.dialog.import.visible = false;
710
+ } catch (e) {
711
+ this.$message.error(e.message);
712
+ }
713
+ },
714
+ handleDialogFullscreen() {
715
+ this.$refs.vueCodeEditor.resize();
716
+ this.$refs.htmlCodeEditor.resize();
717
+ },
718
+ handleClear() {
719
+ this.widgetFormData = {
720
+ list: [],
721
+ config: baseConfig
722
+ };
723
+
724
+ this.widgetFormSelect = {};
725
+ },
726
+ clear() {
727
+ this.handleClear();
728
+ },
729
+ getJSON() {
730
+ return this.widgetFormData;
731
+ },
732
+ getHtml() {
733
+ return generateCode(JSON.stringify(this.widgetFormData));
734
+ },
735
+ setJSON(json) {
736
+ this.widgetFormData = json;
737
+
738
+ if (json.list.length > 0) {
739
+ this.widgetFormSelect = json.list[0];
740
+ }
741
+ },
742
+ handleDataChange(field, value, data) {
743
+ // console.log(field, value, data);
744
+ }
745
+ },
746
+ watch: {
747
+ widgetFormData: {
748
+ deep: true,
749
+ handler: function(val) {
750
+ // console.log(this.$refs.widgetForm);
751
+ }
752
+ }
753
+ }
754
+ };
755
+ </script>