n20-common-lib 1.3.10 → 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 (262) 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 +2 -37
  251. package/src/components/ChildRange/style.scss +34 -0
  252. package/src/components/PageHeader/index.vue +2 -44
  253. package/src/components/PageHeader/style.scss +39 -0
  254. package/src/components/Search/index.vue +1 -97
  255. package/src/components/Search/style.scss +93 -0
  256. package/src/components/Table/ThSelectHeader.vue +2 -11
  257. package/src/components/Table/index.vue +4 -2
  258. package/src/directives/VTitle/index.js +14 -17
  259. package/style/css/normalize.scss +6 -6
  260. package/style/index.css +3 -3
  261. package/style/index.css.map +1 -1
  262. package/style/server-config.jsonc +527 -410
@@ -0,0 +1,650 @@
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
+ :from="from"
25
+ @after-leave="val => $emit('after-leave', val)"
26
+ @query-click="handleExpectQuery"
27
+ @add-click="$emit('add-click')"
28
+ @other-click="$emit('other-click')"
29
+ @enter-click="handleExpectQuery"
30
+ />
31
+
32
+ <div
33
+ v-if="isVertical && queryBtn"
34
+ :class="[
35
+ `form-item`,
36
+ `form-item-button`
37
+ ]"
38
+ >
39
+ <el-button
40
+ v-bind="queryBtn"
41
+ :loading="queryLoading"
42
+ :disabled="disableds.querybutton"
43
+ @click="handleExpectQuery"
44
+ >
45
+ {{ queryBtn.name || '查询' }}
46
+ </el-button>
47
+ </div>
48
+ </el-form>
49
+ </template>
50
+
51
+ <script>
52
+ // 注: 支持的类型 请查看configs.js
53
+ import BaseList from './ListSecond'
54
+
55
+ import { SUPPORT_TYPE, getDefaultValue } from './configsSecond'
56
+
57
+ const deepEquals = (a, b) => {
58
+ if (Array.isArray(a) && Array.isArray(b)) {
59
+ if (a.length !== b.length) {
60
+ return false
61
+ }
62
+
63
+ for (let i = 0; i < a.length; i++) {
64
+ if (a[i] !== b[i]) {
65
+ return false
66
+ }
67
+ }
68
+
69
+ return true
70
+ }
71
+
72
+ return a === b
73
+ }
74
+ export default {
75
+ name: 'NstcForm',
76
+
77
+ components: {
78
+ BaseList
79
+ },
80
+
81
+ inheritAttrs: false,
82
+
83
+ props: {
84
+ from: {
85
+ type: String,
86
+ default: null
87
+ },
88
+ config: {
89
+ type: Array,
90
+ default: () => []
91
+ },
92
+
93
+ popperClass: {
94
+ type: String,
95
+ default: ''
96
+ },
97
+
98
+ reset: {
99
+ type: Boolean,
100
+ default: false
101
+ },
102
+
103
+ // 组件加载完成时, 执行一次默认查询
104
+ mountAndQuery: {
105
+ type: Boolean,
106
+ default: true
107
+ },
108
+
109
+ // 用于表单异步时 手动触发查询
110
+ asyncQuery: {
111
+ default: false,
112
+ type: Boolean
113
+ },
114
+
115
+ // 样式 : 水平 | 垂直
116
+ mode: {
117
+ default: 'horizontal',
118
+ validator: function(val) {
119
+ return ['horizontal', 'vertical'].includes(val)
120
+ }
121
+ },
122
+
123
+ // 是否是纯净模式 (删除 renderable === false 的item.prop对应model的值)
124
+ pureable: {
125
+ default: false,
126
+ type: Boolean
127
+ },
128
+
129
+ value: {
130
+ default: () => ({}),
131
+ type: Object
132
+ },
133
+
134
+ showMessage: {
135
+ type: Boolean,
136
+ default: true
137
+ },
138
+
139
+ disabled: {
140
+ type: Boolean,
141
+ default: false
142
+ },
143
+
144
+ labelPosition: {
145
+ type: String,
146
+ default: 'right'
147
+ },
148
+
149
+ labelWidth: {
150
+ default: '136px',
151
+ type: [String, Number]
152
+ },
153
+
154
+ rules: {
155
+ type: Object,
156
+ default: undefined
157
+ }
158
+ },
159
+
160
+ data() {
161
+ return {
162
+ resets: {},
163
+
164
+ disableds: {
165
+ querybutton: false
166
+ },
167
+
168
+ formID: `formID-${Math.random()
169
+ .toString(36)
170
+ .slice(2)}`,
171
+
172
+ linkItems: [],
173
+ unwatchers: [],
174
+
175
+ queryBtn: null,
176
+
177
+ normalConfig: [],
178
+
179
+ uploadKeys: new Set([]),
180
+
181
+ isRendering: false,
182
+ queryLoading: false,
183
+ innerMountAndQuery: false,
184
+ isInit: true
185
+ }
186
+ },
187
+
188
+ computed: {
189
+ model: {
190
+ get() {
191
+ return this.value
192
+ },
193
+ set(val) {
194
+ this.$emit('input', val)
195
+ this.$emit('change', val)
196
+ }
197
+ },
198
+
199
+ isVertical() {
200
+ return this.mode === 'vertical'
201
+ },
202
+
203
+ computedPopperClass() {
204
+ return (this.isVertical ? ['form-custom-popper', this.popperClass] : []).join(' ')
205
+ },
206
+
207
+ innerLabelWidth() {
208
+ return (this.labelWidth + '').replace(/px/, '') + 'px'
209
+ }
210
+
211
+ },
212
+
213
+ watch: {
214
+ config: {
215
+ deep: true,
216
+ immediate: true,
217
+ handler: function(newVal, oldVal) {
218
+ if (!this.isRendering && newVal !== oldVal && newVal.length) {
219
+ this.init()
220
+ }
221
+ }
222
+ },
223
+
224
+ value: {
225
+ deep: true,
226
+ immediate: true,
227
+ handler: function(newVal) {
228
+ if (!this.isEmptyObject(newVal) && !this.isRendering && this.innerMountAndQuery) {
229
+ this.innerMountAndQuery = false
230
+ this.handleExpectQuery()
231
+ }
232
+ }
233
+ },
234
+
235
+ reset(newVal) {
236
+ console.log('__log_reset', newVal)
237
+ if (newVal) {
238
+ this.init()
239
+ console.log('__log_reset', newVal)
240
+
241
+ // temporary hack
242
+ this.setResets(true)
243
+
244
+ this.$emit('update:reset', false)
245
+ }
246
+ },
247
+
248
+ disabled(newVal, oldVal) {
249
+ if (newVal !== oldVal) {
250
+ this.setDisableds(newVal)
251
+
252
+ this.$emit('disabled')
253
+ }
254
+ },
255
+
256
+ asyncQuery(newVal) {
257
+ if (newVal) {
258
+ this.$nextTick(() => {
259
+ this.handleExpectQuery()
260
+ this.$emit('update:asyncQuery', false)
261
+ })
262
+ }
263
+ }
264
+ },
265
+
266
+ created() {
267
+ // this.innerMountAndQuery = this.mountAndQuery;
268
+ },
269
+
270
+ methods: {
271
+ init() {
272
+ if (!this.isRendering) {
273
+ this.isRendering = true
274
+
275
+ this.clearValidate()
276
+
277
+ this.uploadKeys.clear()
278
+
279
+ this.disableds = {
280
+ querybutton: this.disabled
281
+ }
282
+
283
+ const {
284
+ querybutton,
285
+ normalItems = []
286
+ } = this.separateAdvanceAndNormal(this.config)
287
+
288
+ this.normalConfig = normalItems
289
+
290
+ this.generateFormModel(normalItems)
291
+
292
+ this.queryBtn = querybutton
293
+
294
+ this.generateLink()
295
+
296
+ this.innerMountAndQuery = this.mountAndQuery
297
+
298
+ this.isInit = false
299
+
300
+ this.isRendering = false
301
+ }
302
+ },
303
+
304
+ generateFormModel(config) {
305
+ if (Array.isArray(config)) {
306
+ config.forEach(item => {
307
+ if (Array.isArray(item)) {
308
+ this.generateFormModel(item)
309
+ } else {
310
+ if (!item.mold) {
311
+ throw Error(
312
+ `Each config's child must has a 'mold' prop, it could be ${SUPPORT_TYPE.concat(
313
+ 'querybutton'
314
+ ).join('|')}`
315
+ )
316
+ }
317
+
318
+ item.mold = item.mold.toLowerCase()
319
+
320
+ this.setModel(item)
321
+
322
+ if (item.link) {
323
+ this.linkItems.push(item)
324
+ }
325
+ }
326
+ })
327
+ } else {
328
+ if (!Object.keys(config).length) {
329
+ return
330
+ }
331
+
332
+ if (!config.mold) {
333
+ throw Error(
334
+ `Each config's child must has a 'mold' prop, it could be ${SUPPORT_TYPE.concat(
335
+ 'querybutton'
336
+ ).join('|')}`
337
+ )
338
+ }
339
+
340
+ config.mold = config.mold.toLowerCase()
341
+
342
+ this.setModel(config)
343
+ }
344
+ },
345
+
346
+ generateLink() {
347
+ while (this.unwatchers.length) {
348
+ this.unwatchers.pop()()
349
+ }
350
+
351
+ this.linkItems.map(item => {
352
+ this.setWatchers(item)
353
+ })
354
+
355
+ this.linkItems = []
356
+ },
357
+
358
+ /**
359
+ * item
360
+ * setValue,(第二个参数)
361
+ */
362
+ setModel(item) {
363
+ let { prop, mold } = item
364
+
365
+ if (this.pureable) { // 纯净模式
366
+ if (item.renderable === false) {
367
+ this.$delete(this.model, prop)
368
+ return
369
+ }
370
+ }
371
+
372
+ prop = prop || mold
373
+
374
+ const matchedResult = getDefaultValue(item)
375
+
376
+ if (matchedResult !== null) {
377
+ if (!(this.isInit && this.model[prop] !== undefined)) {
378
+ this.$set(this.model, prop, matchedResult.value)
379
+ // this.$set(this.model, prop, (setValue ? this.model[prop] : matchedResult.value) || matchedResult.value);
380
+ }
381
+
382
+ this.$set(this.resets, prop, false)
383
+ this.$set(this.disableds, prop, this.disabled || item.disabled)
384
+ }
385
+ },
386
+
387
+ setWatchers(item) {
388
+ const { link, prop: itemProp } = item
389
+ let isOneToLinkAll = false
390
+ let links; let isComplex
391
+
392
+ if (Array.isArray(link)) {
393
+ links = link
394
+ isOneToLinkAll = links.every(item => item.mold)
395
+ isComplex = !!(links.find(item => item.mold) && links.find(item => !item.mold))
396
+ } else {
397
+ links = [link]
398
+ }
399
+
400
+ links.forEach(link =>
401
+ this.setSingleLinkWatch(link, itemProp, isOneToLinkAll, isComplex, link.mold)
402
+ )
403
+ },
404
+
405
+ setSingleLinkWatch(link, itemProp, isOneToLinkAll, isComplex, isModelEverGenerated) {
406
+ const { prop, handler, mold } = link
407
+
408
+ if (!this.isFunc(handler)) {
409
+ return
410
+ }
411
+
412
+ let targetProp, watchedProp
413
+
414
+ if (isOneToLinkAll) {
415
+ this.generateFormModel(link)
416
+ targetProp = itemProp
417
+ watchedProp = prop
418
+ } else if (isComplex) {
419
+ if (isModelEverGenerated) {
420
+ this.generateFormModel(link)
421
+ }
422
+ targetProp = itemProp
423
+ watchedProp = prop
424
+ } else {
425
+ if (mold) {
426
+ this.generateFormModel(link)
427
+ targetProp = prop
428
+ watchedProp = itemProp
429
+ } else {
430
+ targetProp = itemProp
431
+ watchedProp = prop
432
+ }
433
+ }
434
+
435
+ const unwatcher = this.$watch(`model.${targetProp}`, {
436
+ immediate: true,
437
+ deep: true,
438
+ handler: async function(newVal, oldVal) {
439
+ if (watchedProp) {
440
+ if (!deepEquals(newVal, oldVal)) {
441
+ const defaultAndOptions = await handler(newVal)
442
+
443
+ const newItem = {
444
+ prop: watchedProp,
445
+ ...defaultAndOptions
446
+ }
447
+
448
+ this.replaceOptions(newItem)
449
+ }
450
+ }
451
+ }
452
+ })
453
+
454
+ this.unwatchers.push(unwatcher)
455
+ },
456
+
457
+ replaceOptions({ prop, ...pramas }, config) {
458
+ let finded = false
459
+
460
+ const replaceOptionsHelper = ({ prop, pramas }, config) => {
461
+ if (finded) {
462
+ return
463
+ }
464
+
465
+ const tConfig = config || this.normalConfig
466
+
467
+ tConfig.forEach((item, idx) => {
468
+ if (Array.isArray(item)) {
469
+ replaceOptionsHelper(
470
+ {
471
+ prop,
472
+ pramas
473
+ },
474
+ item
475
+ )
476
+ } else if (Array.isArray(item.link) && !(item.prop === prop && item.mold)) {
477
+ replaceOptionsHelper(
478
+ {
479
+ prop,
480
+ pramas
481
+ },
482
+ item.link
483
+ )
484
+ } else {
485
+ if (item.prop === prop && item.mold) {
486
+ finded = true
487
+ const newItem = { ...item, ...pramas }
488
+
489
+ tConfig.splice(idx, 1, newItem)
490
+
491
+ if (newItem.mold) {
492
+ this.setModel(newItem, true)
493
+ }
494
+ }
495
+ }
496
+ })
497
+ }
498
+
499
+ replaceOptionsHelper({ prop, pramas }, config)
500
+ },
501
+
502
+ setResets(val = false, prop = null) {
503
+ if (prop) {
504
+ this.resets[prop] = val
505
+ } else {
506
+ Object.keys(this.resets).forEach(key => {
507
+ this.resets[key] = val
508
+ })
509
+ }
510
+ this.$nextTick(() => {
511
+ this.resetFields()
512
+ })
513
+ },
514
+
515
+ setDisableds(val = false, prop = null) {
516
+ if (prop) {
517
+ this.disableds[prop] = val
518
+ } else {
519
+ Object.keys(this.disableds).forEach(key => {
520
+ this.disableds[key] = val
521
+ })
522
+ }
523
+ },
524
+
525
+ separateAdvanceAndNormal(config = this.config) {
526
+ const isVertical = this.isVertical
527
+
528
+ const reducer = config => config.reduce(
529
+ (prev, item) => {
530
+ if (Array.isArray(item)) {
531
+ const { normalItems, ...rest } = reducer(item)
532
+
533
+ normalItems.length && prev.normalItems.push(normalItems)
534
+
535
+ return {
536
+ ...prev,
537
+ ...rest
538
+ }
539
+ } else {
540
+ const { mold } = item
541
+ // if (mold === "upload") {
542
+ // this.uploadKeys.add(prop);
543
+ // }
544
+
545
+ if (isVertical) {
546
+ if (mold === 'querybutton') {
547
+ prev[mold] = item
548
+ } else {
549
+ prev.normalItems.push(item)
550
+ }
551
+ } else {
552
+ prev.normalItems.push(item)
553
+ }
554
+ }
555
+
556
+ return prev
557
+ },
558
+ {
559
+ normalItems: []
560
+ }
561
+ )
562
+
563
+ return reducer(config)
564
+ },
565
+
566
+ isFunc(callBack) {
567
+ return callBack && typeof callBack === 'function'
568
+ },
569
+
570
+ isEmptyObject(obj) {
571
+ const isObj = Object.prototype.toString.call(obj).toLowerCase() !== '[object object]'
572
+ return !Object.keys(isObj ? {} : obj).length
573
+ },
574
+
575
+ async handleExpectQuery(config) {
576
+ this.queryLoading = true
577
+
578
+ try {
579
+ if (this.$listeners.query) {
580
+ await this.validate()
581
+
582
+ let model
583
+
584
+ if (this.uploadKeys.size) {
585
+ model = this.convertModelToFormData(this.model)
586
+ config = {
587
+ headers: {
588
+ 'Content-Type': 'multipart/form-data'
589
+ },
590
+ ...config
591
+ }
592
+ } else {
593
+ model = JSON.parse(JSON.stringify(this.model))
594
+ }
595
+
596
+ await this.$listeners.query(model, config)
597
+ } else {
598
+ throw new Error(
599
+ 'must specify @query event when there is a query button'
600
+ )
601
+ }
602
+ } catch (err) {
603
+ console.error('form custom error -> handleExpectQuery:', err)
604
+ } finally {
605
+ this.queryLoading = false
606
+ }
607
+ },
608
+
609
+ convertModelToFormData(model) {
610
+ const fd = new FormData()
611
+ Object.entries(model).forEach(([key, value]) => {
612
+ fd.append(key, value instanceof window.FormData ? value.get(key) : value)
613
+ })
614
+ return fd
615
+ },
616
+
617
+ clearValidate() {
618
+ if (this.rules && this.$refs[this.formID]) {
619
+ this.$refs[this.formID] && this.$refs[this.formID].clearValidate()
620
+ }
621
+ },
622
+
623
+ resetFields() {
624
+ console.log('__log_formID', this.formID, this.$refs[this.formID])
625
+ this.$refs[this.formID] && this.$refs[this.formID].resetFields()
626
+ },
627
+
628
+ validate() {
629
+ if (this.rules && this.$refs[this.formID]) {
630
+ return this.$refs[this.formID].validate()
631
+ }
632
+
633
+ return Promise.resolve()
634
+ },
635
+
636
+ /**
637
+ * 生成formId
638
+ */
639
+ createFormId() {
640
+ return `formID-${Math.random()
641
+ .toString(36)
642
+ .slice(2)}`
643
+ }
644
+ }
645
+ }
646
+ </script>
647
+
648
+ <style lang="scss">
649
+ @import "index";
650
+ </style>