tianheng-ui 0.1.0 → 0.1.2

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