n20-common-lib 1.3.8 → 1.3.11

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 (263) hide show
  1. package/nstc-g6/assets/svg/404.svg +1 -0
  2. package/nstc-g6/assets/svg/addFile.svg +32 -0
  3. package/nstc-g6/assets/svg/bug.svg +1 -0
  4. package/nstc-g6/assets/svg/chart.svg +1 -0
  5. package/nstc-g6/assets/svg/clipboard.svg +1 -0
  6. package/nstc-g6/assets/svg/component.svg +1 -0
  7. package/nstc-g6/assets/svg/dashboard.svg +1 -0
  8. package/nstc-g6/assets/svg/deleteFile.svg +28 -0
  9. package/nstc-g6/assets/svg/documentation.svg +1 -0
  10. package/nstc-g6/assets/svg/drag.svg +1 -0
  11. package/nstc-g6/assets/svg/edit.svg +1 -0
  12. package/nstc-g6/assets/svg/education.svg +1 -0
  13. package/nstc-g6/assets/svg/email.svg +1 -0
  14. package/nstc-g6/assets/svg/example.svg +1 -0
  15. package/nstc-g6/assets/svg/excel.svg +1 -0
  16. package/nstc-g6/assets/svg/exit-fullscreen.svg +1 -0
  17. package/nstc-g6/assets/svg/eye-open.svg +1 -0
  18. package/nstc-g6/assets/svg/eye.svg +1 -0
  19. package/nstc-g6/assets/svg/favorite.svg +1 -0
  20. package/nstc-g6/assets/svg/favorite_active.svg +1 -0
  21. package/nstc-g6/assets/svg/favorite_x400.svg +1 -0
  22. package/nstc-g6/assets/svg/favorite_x400_active.svg +1 -0
  23. package/nstc-g6/assets/svg/favorite_x400_blank.svg +1 -0
  24. package/nstc-g6/assets/svg/filter.svg +16 -0
  25. package/nstc-g6/assets/svg/filter@2x.png +0 -0
  26. package/nstc-g6/assets/svg/filterActive.svg +16 -0
  27. package/nstc-g6/assets/svg/filterClose@2x.png +0 -0
  28. package/nstc-g6/assets/svg/form.svg +1 -0
  29. package/nstc-g6/assets/svg/fullscreen.svg +1 -0
  30. package/nstc-g6/assets/svg/guide.svg +1 -0
  31. package/nstc-g6/assets/svg/hourglass.svg +19 -0
  32. package/nstc-g6/assets/svg/icon.svg +1 -0
  33. package/nstc-g6/assets/svg/international.svg +1 -0
  34. package/nstc-g6/assets/svg/language.svg +1 -0
  35. package/nstc-g6/assets/svg/left-dis.svg +1 -0
  36. package/nstc-g6/assets/svg/left.svg +1 -0
  37. package/nstc-g6/assets/svg/link.svg +1 -0
  38. package/nstc-g6/assets/svg/list.svg +1 -0
  39. package/nstc-g6/assets/svg/lock.svg +1 -0
  40. package/nstc-g6/assets/svg/message-t.svg +1 -0
  41. package/nstc-g6/assets/svg/money.svg +1 -0
  42. package/nstc-g6/assets/svg/money3.svg +1 -0
  43. package/nstc-g6/assets/svg/money4.svg +1 -0
  44. package/nstc-g6/assets/svg/moneyTwo.svg +1 -0
  45. package/nstc-g6/assets/svg/msg_white.svg +1 -0
  46. package/nstc-g6/assets/svg/nested.svg +1 -0
  47. package/nstc-g6/assets/svg/newsearch.svg +19 -0
  48. package/nstc-g6/assets/svg/password.svg +1 -0
  49. package/nstc-g6/assets/svg/pdf.svg +1 -0
  50. package/nstc-g6/assets/svg/people.svg +1 -0
  51. package/nstc-g6/assets/svg/peoples.svg +1 -0
  52. package/nstc-g6/assets/svg/phone.svg +1 -0
  53. package/nstc-g6/assets/svg/phone_msg.svg +1 -0
  54. package/nstc-g6/assets/svg/qq.svg +1 -0
  55. package/nstc-g6/assets/svg/right-dis.svg +1 -0
  56. package/nstc-g6/assets/svg/right.svg +1 -0
  57. package/nstc-g6/assets/svg/search.svg +1 -0
  58. package/nstc-g6/assets/svg/searchActive.svg +19 -0
  59. package/nstc-g6/assets/svg/shopping.svg +1 -0
  60. package/nstc-g6/assets/svg/size.svg +1 -0
  61. package/nstc-g6/assets/svg/skill.svg +1 -0
  62. package/nstc-g6/assets/svg/star.svg +1 -0
  63. package/nstc-g6/assets/svg/steam.svg +1 -0
  64. package/nstc-g6/assets/svg/tab.svg +1 -0
  65. package/nstc-g6/assets/svg/table.svg +1 -0
  66. package/nstc-g6/assets/svg/theme.svg +1 -0
  67. package/nstc-g6/assets/svg/tree-table.svg +1 -0
  68. package/nstc-g6/assets/svg/tree.svg +1 -0
  69. package/nstc-g6/assets/svg/user.svg +1 -0
  70. package/nstc-g6/assets/svg/wechat.svg +1 -0
  71. package/nstc-g6/assets/svg/z-left-2-dis.svg +1 -0
  72. package/nstc-g6/assets/svg/z-left-2.svg +1 -0
  73. package/nstc-g6/assets/svg/z-right-2-dis.svg +1 -0
  74. package/nstc-g6/assets/svg/z-right-2.svg +1 -0
  75. package/nstc-g6/assets/svg/z-right.svg +1 -0
  76. package/nstc-g6/assets/svg/zip.svg +1 -0
  77. package/nstc-g6/components/Calendar/index.js +8 -0
  78. package/nstc-g6/components/Calendar/src/basic/month-table.vue +129 -0
  79. package/nstc-g6/components/Calendar/src/basic/year-table.vue +126 -0
  80. package/nstc-g6/components/Calendar/src/main.vue +442 -0
  81. package/nstc-g6/components/DialogForm/index.js +8 -0
  82. package/nstc-g6/components/DialogForm/src/demo/index.vue +56 -0
  83. package/nstc-g6/components/DialogForm/src/main.vue +189 -0
  84. package/nstc-g6/components/Form/A_DEMO/component/originalForm.vue +281 -0
  85. package/nstc-g6/components/Form/A_DEMO/config/config_3.js +1222 -0
  86. package/nstc-g6/components/Form/A_DEMO/index.vue +803 -0
  87. package/nstc-g6/components/Form/AutocompleteCustom/index.vue +72 -0
  88. package/nstc-g6/components/Form/BusinessSpecific/InputMultiple.vue +191 -0
  89. package/nstc-g6/components/Form/BusinessSpecific/InputWithUnit.vue +128 -0
  90. package/nstc-g6/components/Form/BusinessSpecific/SelectTreeDialog.vue +233 -0
  91. package/nstc-g6/components/Form/BusinessSpecific/readme.md +7 -0
  92. package/nstc-g6/components/Form/CascaderCustom/index.vue +101 -0
  93. package/nstc-g6/components/Form/CheckboxCustom/index.vue +84 -0
  94. package/nstc-g6/components/Form/Component.vue +661 -0
  95. package/nstc-g6/components/Form/ComponentSecond.vue +650 -0
  96. package/nstc-g6/components/Form/DatepickerCustom/index.vue +130 -0
  97. package/nstc-g6/components/Form/InputAndDialog/index.js +15 -0
  98. package/nstc-g6/components/Form/InputAndDialog/src/main.vue +395 -0
  99. package/nstc-g6/components/Form/InputCustom/demo/index.vue +65 -0
  100. package/nstc-g6/components/Form/InputCustom/index.vue +307 -0
  101. package/nstc-g6/components/Form/IntervalinputCustom/demo/index.vue +31 -0
  102. package/nstc-g6/components/Form/IntervalinputCustom/index.vue +118 -0
  103. package/nstc-g6/components/Form/Item.vue +330 -0
  104. package/nstc-g6/components/Form/ItemSecond.vue +269 -0
  105. package/nstc-g6/components/Form/List.vue +146 -0
  106. package/nstc-g6/components/Form/ListSecond.vue +130 -0
  107. package/nstc-g6/components/Form/RadioCustom/index.vue +73 -0
  108. package/nstc-g6/components/Form/SelectAccount/index.js +15 -0
  109. package/nstc-g6/components/Form/SelectAccount/src/demo/index.vue +58 -0
  110. package/nstc-g6/components/Form/SelectAccount/src/main.vue +283 -0
  111. package/nstc-g6/components/Form/SelectAndDialog/index.js +15 -0
  112. package/nstc-g6/components/Form/SelectAndDialog/src/main.vue +384 -0
  113. package/nstc-g6/components/Form/SelectCashFlow/index.js +15 -0
  114. package/nstc-g6/components/Form/SelectCashFlow/src/demo/index.vue +42 -0
  115. package/nstc-g6/components/Form/SelectCashFlow/src/main.vue +126 -0
  116. package/nstc-g6/components/Form/SelectCustom/demo/index.vue +82 -0
  117. package/nstc-g6/components/Form/SelectCustom/index.vue +488 -0
  118. package/nstc-g6/components/Form/SelectSubject/index.js +15 -0
  119. package/nstc-g6/components/Form/SelectSubject/src/demo/index.vue +85 -0
  120. package/nstc-g6/components/Form/SelectSubject/src/main.vue +182 -0
  121. package/nstc-g6/components/Form/SelectindialogCustom/demo/index.vue +188 -0
  122. package/nstc-g6/components/Form/SelectindialogCustom/index.vue +650 -0
  123. package/nstc-g6/components/Form/SelectindialogCustom/install.js +7 -0
  124. package/nstc-g6/components/Form/TableRadioCustom/demo/index.vue +53 -0
  125. package/nstc-g6/components/Form/TableRadioCustom/index.vue +183 -0
  126. package/nstc-g6/components/Form/TextCustom/index.vue +38 -0
  127. package/nstc-g6/components/Form/UploadCustom/demo/index.vue +31 -0
  128. package/nstc-g6/components/Form/UploadCustom/iconxitongshezhi-yichu.png +0 -0
  129. package/nstc-g6/components/Form/UploadCustom/index.vue +506 -0
  130. package/nstc-g6/components/Form/configs.js +191 -0
  131. package/nstc-g6/components/Form/configsSecond.js +161 -0
  132. package/nstc-g6/components/Form/index.js +8 -0
  133. package/nstc-g6/components/Form/index.scss +29 -0
  134. package/nstc-g6/components/Form/payeePersonSelect/index.js +15 -0
  135. package/nstc-g6/components/Form/payeePersonSelect/src/demo/index.vue +164 -0
  136. package/nstc-g6/components/Form/payeePersonSelect/src/main.vue +185 -0
  137. package/nstc-g6/components/Form/readme.txt +4 -0
  138. package/nstc-g6/components/FormGroup/index.js +8 -0
  139. package/nstc-g6/components/FormGroup/src/demo/config.js +23 -0
  140. package/nstc-g6/components/FormGroup/src/demo/index.vue +85 -0
  141. package/nstc-g6/components/FormGroup/src/main.vue +639 -0
  142. package/nstc-g6/components/FormGroup/src/validate.js +23 -0
  143. package/nstc-g6/components/InputTag/InputTag.vue +270 -0
  144. package/nstc-g6/components/NstcApprovel/NstcApprovel.vue +24 -0
  145. package/nstc-g6/components/NstcBackToTop/NstcBackToTop.vue +150 -0
  146. package/nstc-g6/components/NstcBranchLazyLoad/NstcBranchLazyLoad.vue +123 -0
  147. package/nstc-g6/components/NstcCharts/NstcCharts.vue +162 -0
  148. package/nstc-g6/components/NstcCharts/define.js +74 -0
  149. package/nstc-g6/components/NstcCharts/mixins/resize.js +56 -0
  150. package/nstc-g6/components/NstcConfirm/NstcConfirm.vue +152 -0
  151. package/nstc-g6/components/NstcConfirm/index.js +25 -0
  152. package/nstc-g6/components/NstcDialog/NstcDialog.vue +185 -0
  153. package/nstc-g6/components/NstcDialogForm/NstcDialogForm.vue +176 -0
  154. package/nstc-g6/components/NstcDialogTable/NstcDialogTable.vue +280 -0
  155. package/nstc-g6/components/NstcDropdown/NstcDropdown.vue +52 -0
  156. package/nstc-g6/components/NstcDropdownTree/NstcDropdownTree.vue +396 -0
  157. package/nstc-g6/components/NstcElectronicFile/NstcElectronicFile.vue +591 -0
  158. package/nstc-g6/components/NstcExcelCustomImport/NstcExcelCustomImport.vue +475 -0
  159. package/nstc-g6/components/NstcExcelCustomImport/img/upload@2x.png +0 -0
  160. package/nstc-g6/components/NstcExcelExport/NstcExcelExport.vue +145 -0
  161. package/nstc-g6/components/NstcExcelImport/NstcExcelImport.vue +1074 -0
  162. package/nstc-g6/components/NstcExcelImport/img/upload@2x.png +0 -0
  163. package/nstc-g6/components/NstcExcelImportN/NstcExcelImportN.vue +1166 -0
  164. package/nstc-g6/components/NstcExpandCollapse/NstcExpandCollapse.vue +130 -0
  165. package/nstc-g6/components/NstcExpandCollapse/index.scss +77 -0
  166. package/nstc-g6/components/NstcFileUpload/NstcFileUpload.vue +989 -0
  167. package/nstc-g6/components/NstcFileUpload/img/addFile.svg +32 -0
  168. package/nstc-g6/components/NstcFileUpload/img/delete.svg +24 -0
  169. package/nstc-g6/components/NstcFileUpload/img/deleteFile.svg +28 -0
  170. package/nstc-g6/components/NstcFileUpload/img/download.svg +24 -0
  171. package/nstc-g6/components/NstcFileUpload/img/inputUpload.svg +30 -0
  172. package/nstc-g6/components/NstcFileUpload/img/look-diabled.svg +24 -0
  173. package/nstc-g6/components/NstcFileUpload/img/look.svg +24 -0
  174. package/nstc-g6/components/NstcForm/A_DEMO/component/originalForm.vue +281 -0
  175. package/nstc-g6/components/NstcForm/A_DEMO/config/config_3.js +1222 -0
  176. package/nstc-g6/components/NstcForm/A_DEMO/index.vue +796 -0
  177. package/nstc-g6/components/NstcForm/AutocompleteCustom/index.vue +68 -0
  178. package/nstc-g6/components/NstcForm/BusinessSpecific/InputMultiple.vue +189 -0
  179. package/nstc-g6/components/NstcForm/BusinessSpecific/InputWithUnit.vue +128 -0
  180. package/nstc-g6/components/NstcForm/BusinessSpecific/SelectTreeDialog.vue +233 -0
  181. package/nstc-g6/components/NstcForm/BusinessSpecific/readme.md +7 -0
  182. package/nstc-g6/components/NstcForm/CascaderCustom/index.vue +101 -0
  183. package/nstc-g6/components/NstcForm/CheckboxCustom/index.vue +84 -0
  184. package/nstc-g6/components/NstcForm/Component.vue +684 -0
  185. package/nstc-g6/components/NstcForm/ComponentSecond.vue +650 -0
  186. package/nstc-g6/components/NstcForm/DatepickerCustom/index.vue +130 -0
  187. package/nstc-g6/components/NstcForm/InputAndDialog/NstcInputAndDialog.vue +389 -0
  188. package/nstc-g6/components/NstcForm/InputCustom/index.vue +314 -0
  189. package/nstc-g6/components/NstcForm/IntervalInputCustom/index.vue +116 -0
  190. package/nstc-g6/components/NstcForm/Item.vue +327 -0
  191. package/nstc-g6/components/NstcForm/ItemSecond.vue +269 -0
  192. package/nstc-g6/components/NstcForm/List.vue +146 -0
  193. package/nstc-g6/components/NstcForm/ListSecond.vue +130 -0
  194. package/nstc-g6/components/NstcForm/RadioCustom/index.vue +73 -0
  195. package/nstc-g6/components/NstcForm/SelectAccount/NstcSelectAccount.vue +334 -0
  196. package/nstc-g6/components/NstcForm/SelectAndDialog/NstcSelectAndDialog.vue +377 -0
  197. package/nstc-g6/components/NstcForm/SelectCashFlow/NstcSelectCashFlow.vue +123 -0
  198. package/nstc-g6/components/NstcForm/SelectCustom/index.vue +460 -0
  199. package/nstc-g6/components/NstcForm/SelectSubject/NstcSelectSubject.vue +185 -0
  200. package/nstc-g6/components/NstcForm/SelectindialogCustom/index.vue +648 -0
  201. package/nstc-g6/components/NstcForm/TableRadioCustom/index.vue +183 -0
  202. package/nstc-g6/components/NstcForm/TextCustom/index.vue +38 -0
  203. package/nstc-g6/components/NstcForm/UploadCustom/iconxitongshezhi-yichu.png +0 -0
  204. package/nstc-g6/components/NstcForm/UploadCustom/index.vue +500 -0
  205. package/nstc-g6/components/NstcForm/configs.js +191 -0
  206. package/nstc-g6/components/NstcForm/configsSecond.js +161 -0
  207. package/nstc-g6/components/NstcForm/index.js +8 -0
  208. package/nstc-g6/components/NstcForm/index.scss +29 -0
  209. package/nstc-g6/components/NstcForm/payeePersonSelect/NstcPayeePerson.vue +188 -0
  210. package/nstc-g6/components/NstcForm/readme.txt +4 -0
  211. package/nstc-g6/components/NstcPagination/NstcPagination.vue +428 -0
  212. package/nstc-g6/components/NstcPagination/setPageNum.png +0 -0
  213. package/nstc-g6/components/NstcPagination/setpagedefault.png +0 -0
  214. package/nstc-g6/components/NstcScreenFull/NstcScreenFull.vue +70 -0
  215. package/nstc-g6/components/NstcSelectTree/NstcSelectTree.vue +729 -0
  216. package/nstc-g6/components/NstcSelectTreeList/NstcSelectTreeList.vue +676 -0
  217. package/nstc-g6/components/NstcSticky/NstcSticky.vue +97 -0
  218. package/nstc-g6/components/NstcSvgIcon/NstcSvgIcon.vue +72 -0
  219. package/nstc-g6/components/NstcTab/NstcTab.vue +80 -0
  220. package/nstc-g6/components/NstcTabWithBadge/NstcTabWithBadge.vue +45 -0
  221. package/nstc-g6/components/NstcTabWithBadge/index.scss +31 -0
  222. package/nstc-g6/components/NstcTable/ElTableColumnCustom/index.vue +292 -0
  223. package/nstc-g6/components/NstcTable/NstcTable.vue +460 -0
  224. package/nstc-g6/components/NstcTableSet/NstcTableSet.vue +801 -0
  225. package/nstc-g6/components/NstcThemePicker/NstcThemePicker.vue +186 -0
  226. package/nstc-g6/components/NstcUploadCustomExcel/NstcUploadCustomExcel.vue +330 -0
  227. package/nstc-g6/components/NstcUploadExcel/NstcUploadExcel.vue +145 -0
  228. package/nstc-g6/components/NstcWorkBench/NstcWorkBench.vue +176 -0
  229. package/nstc-g6/components/Search/NstcSearch.vue +583 -0
  230. package/nstc-g6/components/Search/src/demo/index copy.vue +101 -0
  231. package/nstc-g6/components/Search/src/demo/index.vue +103 -0
  232. package/nstc-g6/components/Search/src/main copy.vue +607 -0
  233. package/nstc-g6/components/approvelTwo/main.vue +220 -0
  234. package/nstc-g6/components/approvelTwo/progress.vue +154 -0
  235. package/nstc-g6/directives/VCopy/index.js +60 -0
  236. package/nstc-g6/directives/VNstcNumber/index.js +14 -0
  237. package/nstc-g6/directives/VNstcNumber/temp.js +446 -0
  238. package/nstc-g6/index.js +193 -0
  239. package/nstc-g6/utils/auth.js +2 -0
  240. package/nstc-g6/utils/axios.js +2 -0
  241. package/nstc-g6/utils/dateAndValidator.js +649 -0
  242. package/nstc-g6/utils/debounce.js +40 -0
  243. package/nstc-g6/utils/parseTime.js +48 -0
  244. package/nstc-g6/utils/validate/index.js +7 -0
  245. package/nstc-g6/utils/vendor/Export2Excel.js +229 -0
  246. package/nstc-g6/utils/vendor/Export2Zip.js +24 -0
  247. package/nstc-g6/utils/vue-bus.js +5 -0
  248. package/package.json +8 -2
  249. package/src/assets/css/_coreLib.scss +9 -1
  250. package/src/components/ChildRange/index.vue +28 -64
  251. package/src/components/ChildRange/style.scss +34 -0
  252. package/src/components/FileImport/index.vue +3 -1
  253. package/src/components/PageHeader/index.vue +3 -47
  254. package/src/components/PageHeader/style.scss +39 -0
  255. package/src/components/Search/index.vue +1 -97
  256. package/src/components/Search/style.scss +93 -0
  257. package/src/components/Table/ThSelectHeader.vue +28 -33
  258. package/src/components/Table/index.vue +4 -2
  259. package/src/directives/VTitle/index.js +14 -17
  260. package/style/css/normalize.scss +6 -6
  261. package/style/index.css +3 -3
  262. package/style/index.css.map +1 -1
  263. package/style/server-config.jsonc +527 -410
@@ -0,0 +1,684 @@
1
+ <template>
2
+ <el-form
3
+ :id="formID"
4
+ :key="formID"
5
+ :ref="formID"
6
+ :model="model"
7
+ :label-width="innerLabelWidth"
8
+ :label-position="labelPosition"
9
+ :rules="rules"
10
+ :show-message="showMessage"
11
+ v-bind="$attrs"
12
+ :class="['form-custom', `form-custom-${mode}`]"
13
+ v-on="$listeners"
14
+ @submit.native.prevent
15
+ >
16
+ <!-- 常规查询 -->
17
+ <BaseList
18
+ v-model="model"
19
+ :config="normalConfig"
20
+ :resets.sync="resets"
21
+ :loading="queryLoading"
22
+ :disableds="disableds"
23
+ :popper-class="computedPopperClass"
24
+ :form-data="formData"
25
+ :show-mode="showMode"
26
+ @after-leave="(val) => $emit('after-leave', val)"
27
+ @query-click="handleExpectQuery"
28
+ @add-click="$emit('add-click')"
29
+ @other-click="$emit('other-click')"
30
+ @enter-click="handleExpectQuery"
31
+ @tree-node-click="
32
+ (prop, data, node) => $emit('tree-node-click', prop, data, node)
33
+ "
34
+ />
35
+
36
+ <div
37
+ v-if="isVertical && queryBtn"
38
+ :class="[`form-item`, `form-item-button`]"
39
+ >
40
+ <el-button
41
+ v-bind="queryBtn"
42
+ :loading="queryLoading"
43
+ :disabled="disableds.querybutton"
44
+ @click="handleExpectQuery"
45
+ >
46
+ {{ queryBtn.name || '查询' }}
47
+ </el-button>
48
+ </div>
49
+ </el-form>
50
+ </template>
51
+
52
+ <script>
53
+ // 注: 支持的类型 请查看configs.js
54
+ import BaseList from './List'
55
+
56
+ import { SUPPORT_TYPE, getDefaultValue } from './configs'
57
+
58
+ const deepEquals = (a, b) => {
59
+ if (Array.isArray(a) && Array.isArray(b)) {
60
+ if (a.length !== b.length) {
61
+ return false
62
+ }
63
+
64
+ for (let i = 0; i < a.length; i++) {
65
+ if (a[i] !== b[i]) {
66
+ return false
67
+ }
68
+ }
69
+
70
+ return true
71
+ }
72
+
73
+ return a === b
74
+ }
75
+ export default {
76
+ name: 'NstcForm',
77
+
78
+ components: {
79
+ BaseList
80
+ },
81
+
82
+ inheritAttrs: false,
83
+
84
+ props: {
85
+ formData: {
86
+ type: Object,
87
+ default: () => ({})
88
+ },
89
+ from: {
90
+ type: String,
91
+ default: null
92
+ },
93
+ config: {
94
+ type: Array,
95
+ default: () => []
96
+ },
97
+
98
+ popperClass: {
99
+ type: String,
100
+ default: ''
101
+ },
102
+
103
+ reset: {
104
+ type: Boolean,
105
+ default: false
106
+ },
107
+
108
+ // 组件加载完成时, 执行一次默认查询
109
+ mountAndQuery: {
110
+ type: Boolean,
111
+ default: true
112
+ },
113
+
114
+ // 用于表单异步时 手动触发查询
115
+ asyncQuery: {
116
+ default: false,
117
+ type: Boolean
118
+ },
119
+
120
+ // 样式 : 水平 | 垂直
121
+ mode: {
122
+ default: 'horizontal',
123
+ validator: function (val) {
124
+ return ['horizontal', 'vertical'].includes(val)
125
+ }
126
+ },
127
+
128
+ // 是否是纯净模式 (删除 renderable === false 的item.prop对应model的值)
129
+ pureable: {
130
+ default: false,
131
+ type: Boolean
132
+ },
133
+
134
+ value: {
135
+ default: () => ({}),
136
+ type: Object
137
+ },
138
+
139
+ showMessage: {
140
+ type: Boolean,
141
+ default: true
142
+ },
143
+
144
+ disabled: {
145
+ type: Boolean,
146
+ default: false
147
+ },
148
+
149
+ labelPosition: {
150
+ type: String,
151
+ default: 'right'
152
+ },
153
+
154
+ labelWidth: {
155
+ default: '136px',
156
+ type: [String, Number]
157
+ },
158
+
159
+ rules: {
160
+ type: Object,
161
+ default: undefined
162
+ },
163
+
164
+ // 显示模式
165
+ showMode: {
166
+ type: String,
167
+ default: ''
168
+ }
169
+ },
170
+
171
+ data() {
172
+ return {
173
+ resets: {},
174
+
175
+ disableds: {
176
+ querybutton: false
177
+ },
178
+
179
+ formID: `formID-${Math.random().toString(36).slice(2)}`,
180
+
181
+ linkItems: [],
182
+ unwatchers: [],
183
+
184
+ queryBtn: null,
185
+
186
+ normalConfig: [],
187
+
188
+ uploadKeys: new Set([]),
189
+
190
+ isRendering: false,
191
+ queryLoading: false,
192
+ innerMountAndQuery: false,
193
+ isInit: true
194
+ }
195
+ },
196
+
197
+ computed: {
198
+ model: {
199
+ get() {
200
+ return this.value
201
+ },
202
+ set(val) {
203
+ this.$emit('input', val)
204
+ this.$emit('change', val)
205
+ }
206
+ },
207
+
208
+ isVertical() {
209
+ return this.mode === 'vertical'
210
+ },
211
+
212
+ computedPopperClass() {
213
+ return (
214
+ this.isVertical ? ['form-custom-popper input-w', this.popperClass] : []
215
+ ).join(' ')
216
+ },
217
+
218
+ innerLabelWidth() {
219
+ return (this.labelWidth + '').replace(/px/, '') + 'px'
220
+ }
221
+ },
222
+
223
+ watch: {
224
+ config: {
225
+ deep: true,
226
+ immediate: true,
227
+ handler: function (newVal) {
228
+ if (!this.isRendering && newVal.length) {
229
+ this.init()
230
+ }
231
+ }
232
+ },
233
+
234
+ value: {
235
+ deep: true,
236
+ immediate: true,
237
+ handler: function (newVal) {
238
+ if (
239
+ !this.isEmptyObject(newVal) &&
240
+ !this.isRendering &&
241
+ this.innerMountAndQuery
242
+ ) {
243
+ this.innerMountAndQuery = false
244
+ this.handleExpectQuery()
245
+ }
246
+ }
247
+ },
248
+
249
+ reset(newVal) {
250
+ console.log('__log_reset', newVal)
251
+ if (newVal) {
252
+ this.init()
253
+ console.log('__log_reset', newVal)
254
+
255
+ // temporary hack
256
+ this.setResets(true)
257
+
258
+ this.$emit('update:reset', false)
259
+ }
260
+ },
261
+
262
+ disabled(newVal, oldVal) {
263
+ if (newVal !== oldVal) {
264
+ this.setDisableds(newVal)
265
+
266
+ this.$emit('disabled')
267
+ }
268
+ },
269
+
270
+ asyncQuery(newVal) {
271
+ if (newVal) {
272
+ this.$nextTick(() => {
273
+ this.handleExpectQuery()
274
+ this.$emit('update:asyncQuery', false)
275
+ })
276
+ }
277
+ }
278
+ },
279
+
280
+ created() {
281
+ // this.innerMountAndQuery = this.mountAndQuery;
282
+ },
283
+
284
+ methods: {
285
+ init() {
286
+ if (!this.isRendering) {
287
+ this.isRendering = true
288
+
289
+ this.clearValidate()
290
+
291
+ this.uploadKeys.clear()
292
+
293
+ this.disableds = {
294
+ querybutton: this.disabled
295
+ }
296
+
297
+ const { querybutton, normalItems = [] } = this.separateAdvanceAndNormal(
298
+ this.config
299
+ )
300
+ this.normalConfig = normalItems
301
+
302
+ this.generateFormModel(normalItems)
303
+
304
+ this.queryBtn = querybutton
305
+
306
+ this.generateLink()
307
+
308
+ this.innerMountAndQuery = this.mountAndQuery
309
+
310
+ this.isInit = false
311
+
312
+ this.isRendering = false
313
+ }
314
+ },
315
+
316
+ generateFormModel(config) {
317
+ if (Array.isArray(config)) {
318
+ config.forEach((item) => {
319
+ if (Array.isArray(item)) {
320
+ this.generateFormModel(item)
321
+ } else {
322
+ if (!item.mold) {
323
+ throw Error(
324
+ `Each config's child must has a 'mold' prop, it could be ${SUPPORT_TYPE.concat(
325
+ 'querybutton'
326
+ ).join('|')}`
327
+ )
328
+ }
329
+
330
+ item.mold = item.mold.toLowerCase()
331
+
332
+ this.setModel(item)
333
+
334
+ if (item.link) {
335
+ this.linkItems.push(item)
336
+ }
337
+ }
338
+ })
339
+ } else {
340
+ if (!Object.keys(config).length) {
341
+ return
342
+ }
343
+
344
+ if (!config.mold) {
345
+ throw Error(
346
+ `Each config's child must has a 'mold' prop, it could be ${SUPPORT_TYPE.concat(
347
+ 'querybutton'
348
+ ).join('|')}`
349
+ )
350
+ }
351
+
352
+ config.mold = config.mold.toLowerCase()
353
+
354
+ this.setModel(config)
355
+ }
356
+ },
357
+
358
+ generateLink() {
359
+ while (this.unwatchers.length) {
360
+ this.unwatchers.pop()()
361
+ }
362
+
363
+ this.linkItems.map((item) => {
364
+ this.setWatchers(item)
365
+ })
366
+
367
+ this.linkItems = []
368
+ },
369
+
370
+ /**
371
+ * item
372
+ * setValue,(第二个参数)
373
+ */
374
+ setModel(item) {
375
+ let { prop, mold } = item
376
+
377
+ if (this.pureable) {
378
+ // 纯净模式
379
+ if (item.renderable === false) {
380
+ this.$delete(this.model, prop)
381
+ return
382
+ }
383
+ }
384
+
385
+ prop = prop || mold
386
+
387
+ const matchedResult = getDefaultValue(item)
388
+
389
+ if (matchedResult !== null) {
390
+ if (!(this.isInit && this.model[prop] !== undefined)) {
391
+ this.$set(this.model, prop, matchedResult.value)
392
+ // this.$set(this.model, prop, (setValue ? this.model[prop] : matchedResult.value) || matchedResult.value);
393
+ }
394
+
395
+ this.$set(this.resets, prop, false)
396
+ this.$set(this.disableds, prop, this.disabled || item.disabled)
397
+ }
398
+ },
399
+
400
+ setWatchers(item) {
401
+ const { link, prop: itemProp } = item
402
+ let isOneToLinkAll = false
403
+ let links
404
+ let isComplex
405
+
406
+ if (Array.isArray(link)) {
407
+ links = link
408
+ isOneToLinkAll = links.every((item) => item.mold)
409
+ isComplex = !!(
410
+ links.find((item) => item.mold) && links.find((item) => !item.mold)
411
+ )
412
+ } else {
413
+ links = [link]
414
+ }
415
+
416
+ links.forEach((link) =>
417
+ this.setSingleLinkWatch(
418
+ link,
419
+ itemProp,
420
+ isOneToLinkAll,
421
+ isComplex,
422
+ link.mold
423
+ )
424
+ )
425
+ },
426
+
427
+ setSingleLinkWatch(
428
+ link,
429
+ itemProp,
430
+ isOneToLinkAll,
431
+ isComplex,
432
+ isModelEverGenerated
433
+ ) {
434
+ const { prop, handler, mold } = link
435
+
436
+ if (!this.isFunc(handler)) {
437
+ return
438
+ }
439
+
440
+ let targetProp, watchedProp
441
+
442
+ if (isOneToLinkAll) {
443
+ this.generateFormModel(link)
444
+ targetProp = itemProp
445
+ watchedProp = prop
446
+ } else if (isComplex) {
447
+ if (isModelEverGenerated) {
448
+ this.generateFormModel(link)
449
+ }
450
+ targetProp = itemProp
451
+ watchedProp = prop
452
+ } else {
453
+ if (mold) {
454
+ this.generateFormModel(link)
455
+ targetProp = prop
456
+ watchedProp = itemProp
457
+ } else {
458
+ targetProp = itemProp
459
+ watchedProp = prop
460
+ }
461
+ }
462
+
463
+ const unwatcher = this.$watch(`model.${targetProp}`, {
464
+ immediate: true,
465
+ deep: true,
466
+ handler: async function (newVal, oldVal) {
467
+ if (watchedProp) {
468
+ if (!deepEquals(newVal, oldVal)) {
469
+ const defaultAndOptions = await handler(newVal)
470
+
471
+ const newItem = {
472
+ prop: watchedProp,
473
+ ...defaultAndOptions
474
+ }
475
+
476
+ this.replaceOptions(newItem)
477
+ }
478
+ }
479
+ }
480
+ })
481
+
482
+ this.unwatchers.push(unwatcher)
483
+ },
484
+
485
+ replaceOptions({ prop, ...pramas }, config) {
486
+ let finded = false
487
+
488
+ const replaceOptionsHelper = ({ prop, pramas }, config) => {
489
+ if (finded) {
490
+ return
491
+ }
492
+
493
+ const tConfig = config || this.normalConfig
494
+
495
+ tConfig.forEach((item, idx) => {
496
+ if (Array.isArray(item)) {
497
+ replaceOptionsHelper(
498
+ {
499
+ prop,
500
+ pramas
501
+ },
502
+ item
503
+ )
504
+ } else if (
505
+ Array.isArray(item.link) &&
506
+ !(item.prop === prop && item.mold)
507
+ ) {
508
+ replaceOptionsHelper(
509
+ {
510
+ prop,
511
+ pramas
512
+ },
513
+ item.link
514
+ )
515
+ } else {
516
+ if (item.prop === prop && item.mold) {
517
+ finded = true
518
+ const newItem = { ...item, ...pramas }
519
+
520
+ tConfig.splice(idx, 1, newItem)
521
+
522
+ if (newItem.mold) {
523
+ this.setModel(newItem, true)
524
+ }
525
+ }
526
+ }
527
+ })
528
+ }
529
+
530
+ replaceOptionsHelper({ prop, pramas }, config)
531
+ },
532
+
533
+ setResets(val = false, prop = null) {
534
+ if (prop) {
535
+ this.resets[prop] = val
536
+ } else {
537
+ Object.keys(this.resets).forEach((key) => {
538
+ this.resets[key] = val
539
+ })
540
+ }
541
+ this.$nextTick(() => {
542
+ this.resetFields()
543
+ })
544
+ },
545
+
546
+ setDisableds(val = false, prop = null) {
547
+ if (prop) {
548
+ this.disableds[prop] = val
549
+ } else {
550
+ Object.keys(this.disableds).forEach((key) => {
551
+ this.disableds[key] = val
552
+ })
553
+ }
554
+ },
555
+
556
+ separateAdvanceAndNormal(config = this.config) {
557
+ const isVertical = this.isVertical
558
+
559
+ const reducer = (config) =>
560
+ config.reduce(
561
+ (prev, item) => {
562
+ if (Array.isArray(item)) {
563
+ const { normalItems, ...rest } = reducer(item)
564
+
565
+ normalItems.length && prev.normalItems.push(normalItems)
566
+
567
+ return {
568
+ ...prev,
569
+ ...rest
570
+ }
571
+ } else {
572
+ const { mold } = item
573
+ // if (mold === "upload") {
574
+ // this.uploadKeys.add(prop);
575
+ // }
576
+
577
+ if (isVertical) {
578
+ if (mold === 'querybutton') {
579
+ prev[mold] = item
580
+ } else {
581
+ prev.normalItems.push(item)
582
+ }
583
+ } else {
584
+ prev.normalItems.push(item)
585
+ }
586
+ }
587
+
588
+ return prev
589
+ },
590
+ {
591
+ normalItems: []
592
+ }
593
+ )
594
+
595
+ return reducer(config)
596
+ },
597
+
598
+ isFunc(callBack) {
599
+ return callBack && typeof callBack === 'function'
600
+ },
601
+
602
+ isEmptyObject(obj) {
603
+ const isObj =
604
+ Object.prototype.toString.call(obj).toLowerCase() !== '[object object]'
605
+ return !Object.keys(isObj ? {} : obj).length
606
+ },
607
+
608
+ async handleExpectQuery(config) {
609
+ this.queryLoading = true
610
+
611
+ try {
612
+ if (this.$listeners.query) {
613
+ await this.validate()
614
+
615
+ let model
616
+
617
+ if (this.uploadKeys.size) {
618
+ model = this.convertModelToFormData(this.model)
619
+ config = {
620
+ headers: {
621
+ 'Content-Type': 'multipart/form-data'
622
+ },
623
+ ...config
624
+ }
625
+ } else {
626
+ model = JSON.parse(JSON.stringify(this.model))
627
+ }
628
+
629
+ await this.$listeners.query(model, config)
630
+ } else {
631
+ throw new Error(
632
+ 'must specify @query event when there is a query button'
633
+ )
634
+ }
635
+ } catch (err) {
636
+ console.error('form custom error -> handleExpectQuery:', err)
637
+ } finally {
638
+ this.queryLoading = false
639
+ }
640
+ },
641
+
642
+ convertModelToFormData(model) {
643
+ const fd = new FormData()
644
+ Object.entries(model).forEach(([key, value]) => {
645
+ fd.append(
646
+ key,
647
+ value instanceof window.FormData ? value.get(key) : value
648
+ )
649
+ })
650
+ return fd
651
+ },
652
+
653
+ clearValidate() {
654
+ if (this.rules && this.$refs[this.formID]) {
655
+ this.$refs[this.formID] && this.$refs[this.formID].clearValidate()
656
+ }
657
+ },
658
+
659
+ resetFields() {
660
+ console.log('__log_formID', this.formID, this.$refs[this.formID])
661
+ this.$refs[this.formID] && this.$refs[this.formID].resetFields()
662
+ },
663
+
664
+ validate() {
665
+ if (this.rules && this.$refs[this.formID]) {
666
+ return this.$refs[this.formID].validate()
667
+ }
668
+
669
+ return Promise.resolve()
670
+ },
671
+
672
+ /**
673
+ * 生成formId
674
+ */
675
+ createFormId() {
676
+ return `formID-${Math.random().toString(36).slice(2)}`
677
+ }
678
+ }
679
+ }
680
+ </script>
681
+
682
+ <style lang="scss">
683
+ @import 'index';
684
+ </style>