vue2-client 1.8.259 → 1.8.261

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 (210) hide show
  1. package/.env +19 -19
  2. package/.eslintrc.js +90 -90
  3. package/CHANGELOG.md +824 -824
  4. package/Components.md +60 -60
  5. package/babel.config.js +21 -21
  6. package/docs/index.md +30 -30
  7. package/docs/lowcode.md +188 -188
  8. package/docs/lowcodeForDeveloper.md +200 -192
  9. package/index.js +31 -31
  10. package/jest-transform-stub.js +8 -8
  11. package/jest.config.js +21 -21
  12. package/jest.setup.js +7 -7
  13. package/package.json +95 -95
  14. package/public/index.html +27 -27
  15. package/src/App.vue +188 -188
  16. package/src/ReportView.js +19 -19
  17. package/src/assets/img/querySlotDemo.svg +15 -15
  18. package/src/assets/svg/badtwo.svg +1 -1
  19. package/src/assets/svg/goodtwo.svg +1 -1
  20. package/src/base-client/components/common/AMisRender/index.js +3 -3
  21. package/src/base-client/components/common/AMisRender/index.vue +263 -263
  22. package/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox.vue +413 -413
  23. package/src/base-client/components/common/AddressSearchCombobox/demo.vue +36 -36
  24. package/src/base-client/components/common/AmapMarker/AmapPointRendering.vue +120 -120
  25. package/src/base-client/components/common/CitySelect/CitySelect.vue +348 -348
  26. package/src/base-client/components/common/CitySelect/index.js +3 -3
  27. package/src/base-client/components/common/CitySelect/index.md +109 -109
  28. package/src/base-client/components/common/CreateQuery/CreateQuery.vue +669 -669
  29. package/src/base-client/components/common/CreateQuery/CreateQueryItem.vue +1014 -1014
  30. package/src/base-client/components/common/CreateQuery/index.js +3 -3
  31. package/src/base-client/components/common/CreateQuery/index.md +42 -42
  32. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQuery.vue +452 -452
  33. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQueryItem.vue +511 -511
  34. package/src/base-client/components/common/CreateSimpleFormQuery/index.js +3 -3
  35. package/src/base-client/components/common/CreateSimpleFormQuery/index.md +42 -42
  36. package/src/base-client/components/common/FormGroupEdit/FormGroupEdit.vue +149 -149
  37. package/src/base-client/components/common/FormGroupEdit/index.js +3 -3
  38. package/src/base-client/components/common/FormGroupEdit/index.md +43 -43
  39. package/src/base-client/components/common/FormGroupQuery/FormGroupQuery.vue +166 -166
  40. package/src/base-client/components/common/FormGroupQuery/index.js +3 -3
  41. package/src/base-client/components/common/FormGroupQuery/index.md +43 -43
  42. package/src/base-client/components/common/JSONToTree/jsontotree.vue +271 -271
  43. package/src/base-client/components/common/LowCodeComponent/LowCodePageOrganization.vue +394 -355
  44. package/src/base-client/components/common/LowCodePageRender/LowCodePageRender.vue +29 -29
  45. package/src/base-client/components/common/LowCodePageRender/editorPageRender.vue +533 -467
  46. package/src/base-client/components/common/LowCodePageRender/index.js +3 -3
  47. package/src/base-client/components/common/PersonSetting/PersonSetting.vue +208 -208
  48. package/src/base-client/components/common/PersonSetting/index.js +3 -3
  49. package/src/base-client/components/common/Tree/Tree.vue +149 -149
  50. package/src/base-client/components/common/Tree/index.js +2 -2
  51. package/src/base-client/components/common/Upload/Upload.vue +197 -197
  52. package/src/base-client/components/common/Upload/index.js +3 -3
  53. package/src/base-client/components/common/XAddForm/XAddForm.vue +98 -98
  54. package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +732 -732
  55. package/src/base-client/components/common/XAddNativeForm/index.md +146 -146
  56. package/src/base-client/components/common/XAddNativeForm/lowcodeEditorRegister.js +16 -12
  57. package/src/base-client/components/common/XAddNativeFormOA/XAddNativeFormOA.vue +303 -303
  58. package/src/base-client/components/common/XAddNativeFormOA/index.js +3 -3
  59. package/src/base-client/components/common/XAddNativeFormOA/index.md +146 -146
  60. package/src/base-client/components/common/XBadge/XBadge.vue +78 -78
  61. package/src/base-client/components/common/XCard/XCard.vue +64 -64
  62. package/src/base-client/components/common/XDataDrawer/XDataDrawer.vue +180 -180
  63. package/src/base-client/components/common/XDataDrawer/index.js +3 -3
  64. package/src/base-client/components/common/XDataDrawer/index.md +41 -41
  65. package/src/base-client/components/common/XDescriptions/XDescriptions.vue +167 -167
  66. package/src/base-client/components/common/XDescriptions/XDescriptionsGroup.vue +299 -299
  67. package/src/base-client/components/common/XDescriptions/demo.vue +50 -50
  68. package/src/base-client/components/common/XDescriptions/index.js +3 -3
  69. package/src/base-client/components/common/XDescriptions/index.md +83 -83
  70. package/src/base-client/components/common/XDescriptions/lowcodeEditorRegister.js +15 -5
  71. package/src/base-client/components/common/XDetailsView/XDetailsView.vue +214 -214
  72. package/src/base-client/components/common/XDetailsView/index.js +3 -3
  73. package/src/base-client/components/common/XForm/XForm.vue +281 -281
  74. package/src/base-client/components/common/XForm/XFormItem.vue +807 -807
  75. package/src/base-client/components/common/XForm/XTreeSelect.vue +206 -206
  76. package/src/base-client/components/common/XForm/index.md +178 -178
  77. package/src/base-client/components/common/XFormCol/XFormCol.vue +36 -36
  78. package/src/base-client/components/common/XFormGroup/XFormGroup.vue +241 -241
  79. package/src/base-client/components/common/XFormGroup/demo.vue +40 -40
  80. package/src/base-client/components/common/XFormGroup/index.js +3 -3
  81. package/src/base-client/components/common/XFormGroup/index.md +38 -38
  82. package/src/base-client/components/common/XFormGroupDetails/XFormGroupDetails.vue +72 -72
  83. package/src/base-client/components/common/XFormGroupDetails/index.js +3 -3
  84. package/src/base-client/components/common/XFormTable/XFormTable.vue +519 -519
  85. package/src/base-client/components/common/XFormTable/index.md +98 -98
  86. package/src/base-client/components/common/XFormTable/lowcodeEditorRegister.js +16 -12
  87. package/src/base-client/components/common/XImportExcel/XImportExcel.vue +147 -147
  88. package/src/base-client/components/common/XReport/XReport.vue +843 -843
  89. package/src/base-client/components/common/XReport/XReportDemo.vue +2233 -2233
  90. package/src/base-client/components/common/XReport/XReportDesign.vue +470 -470
  91. package/src/base-client/components/common/XReport/XReportJsonRender.vue +267 -267
  92. package/src/base-client/components/common/XReport/XReportTrGroup.vue +745 -742
  93. package/src/base-client/components/common/XReport/index.js +3 -3
  94. package/src/base-client/components/common/XReport/index.md +44 -44
  95. package/src/base-client/components/common/XReportSlot/XReportSlot.vue +110 -110
  96. package/src/base-client/components/common/XReportSlot/index.js +3 -3
  97. package/src/base-client/components/common/XStepView/XStepView.vue +252 -252
  98. package/src/base-client/components/common/XStepView/index.js +3 -3
  99. package/src/base-client/components/common/XStepView/index.md +31 -31
  100. package/src/base-client/components/common/XTable/XTable.vue +636 -636
  101. package/src/base-client/components/common/XTable/index.md +255 -255
  102. package/src/base-client/components/common/XTree/XTree.vue +318 -318
  103. package/src/base-client/components/common/XTree/index.js +3 -3
  104. package/src/base-client/components/common/XTree/index.md +36 -36
  105. package/src/base-client/components/common/XTreeOne/XTreeOne.vue +114 -114
  106. package/src/base-client/components/common/XTreeOne/lowcodeEditorRegister.js +11 -9
  107. package/src/base-client/components/index.js +51 -51
  108. package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +232 -232
  109. package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +281 -281
  110. package/src/base-client/plugins/AppData.js +115 -115
  111. package/src/base-client/plugins/Config.js +19 -19
  112. package/src/base-client/plugins/GetLoginInfoService.js +183 -183
  113. package/src/base-client/plugins/tabs-page-plugin.js +39 -39
  114. package/src/bootstrap.js +39 -39
  115. package/src/components/CodeMirror/inedx.vue +118 -118
  116. package/src/components/CodeMirror/setting.js +40 -40
  117. package/src/components/FilePreview/FilePreview.vue +166 -166
  118. package/src/components/NumberInfo/NumberInfo.vue +54 -54
  119. package/src/components/STable/index.js +323 -323
  120. package/src/components/checkbox/ColorCheckbox.vue +157 -157
  121. package/src/components/checkbox/ImgCheckbox.vue +163 -163
  122. package/src/components/menu/SideMenu.vue +75 -75
  123. package/src/components/menu/menu.js +273 -273
  124. package/src/components/tool/AStepItem.vue +60 -60
  125. package/src/config/CreateQueryConfig.js +322 -322
  126. package/src/config/default/antd.config.js +89 -89
  127. package/src/config/default/setting.config.js +55 -55
  128. package/src/font-style/font.css +4 -4
  129. package/src/layouts/CommonLayout.vue +56 -56
  130. package/src/layouts/PageLayout.vue +151 -151
  131. package/src/layouts/SinglePageView.vue +138 -138
  132. package/src/layouts/header/AdminHeader.vue +132 -132
  133. package/src/layouts/header/HeaderNotice.vue +177 -177
  134. package/src/layouts/tabs/TabsHead.vue +189 -189
  135. package/src/layouts/tabs/TabsView.vue +387 -387
  136. package/src/lib.js +1 -1
  137. package/src/main.js +26 -26
  138. package/src/mock/extend/index.js +84 -84
  139. package/src/mock/goods/index.js +108 -108
  140. package/src/pages/AMisDemo/AMisDemo.vue +325 -325
  141. package/src/pages/AMisDemo/AMisDemo2.vue +74 -74
  142. package/src/pages/DynamicStatistics/ChartSelector.vue +331 -331
  143. package/src/pages/DynamicStatistics/DataTabs.vue +83 -83
  144. package/src/pages/DynamicStatistics/DynamicTable.vue +128 -128
  145. package/src/pages/DynamicStatistics/EvaluationArea.vue +69 -69
  146. package/src/pages/DynamicStatistics/FavoriteList.vue +51 -51
  147. package/src/pages/DynamicStatistics/QuestionHistoryAndFavorites.vue +591 -591
  148. package/src/pages/DynamicStatistics/SearchBar.vue +192 -192
  149. package/src/pages/DynamicStatistics/index.vue +282 -282
  150. package/src/pages/Example/index.vue +32 -32
  151. package/src/pages/NewDynamicStatistics/ChartSelector.vue +331 -331
  152. package/src/pages/NewDynamicStatistics/DataTabs.vue +122 -122
  153. package/src/pages/NewDynamicStatistics/DynamicTable.vue +128 -128
  154. package/src/pages/NewDynamicStatistics/EvaluationArea.vue +69 -69
  155. package/src/pages/NewDynamicStatistics/FavoriteList.vue +51 -51
  156. package/src/pages/NewDynamicStatistics/QuestionHistoryAndFavorites.vue +289 -289
  157. package/src/pages/NewDynamicStatistics/SearchBar.vue +193 -193
  158. package/src/pages/NewDynamicStatistics/index.vue +258 -258
  159. package/src/pages/ServiceReview/index.vue +284 -284
  160. package/src/pages/XReportView/index.vue +62 -62
  161. package/src/pages/login/Login.vue +378 -378
  162. package/src/pages/login/LoginV3.vue +389 -389
  163. package/src/pages/lowCode/lowCodeEditor.vue +1501 -1285
  164. package/src/pages/lowCode/lowCodeRender.vue +39 -39
  165. package/src/pages/resourceManage/orgListManage.vue +98 -98
  166. package/src/pages/system/dictionary/index.vue +44 -44
  167. package/src/pages/system/monitor/loginInfor/index.vue +37 -37
  168. package/src/pages/system/monitor/operLog/index.vue +37 -37
  169. package/src/pages/system/settings/modifyPassword.vue +117 -117
  170. package/src/pages/system/ticket/index.vue +480 -480
  171. package/src/pages/system/ticket/submitTicketSuccess.vue +484 -484
  172. package/src/router/async/config.async.js +33 -33
  173. package/src/router/async/router.map.js +107 -107
  174. package/src/router/guards.js +220 -220
  175. package/src/router/index.js +27 -27
  176. package/src/router.js +19 -19
  177. package/src/services/api/TicketDetailsViewApi.js +46 -46
  178. package/src/services/api/cas.js +79 -79
  179. package/src/services/api/common.js +284 -284
  180. package/src/services/api/entity.js +18 -18
  181. package/src/services/api/index.js +17 -17
  182. package/src/services/api/restTools.js +46 -46
  183. package/src/services/apiService.js +14 -14
  184. package/src/services/user.js +71 -71
  185. package/src/store/modules/setting.js +119 -119
  186. package/src/theme/default/style.less +57 -57
  187. package/src/theme/global.less +130 -130
  188. package/src/utils/authority-utils.js +85 -85
  189. package/src/utils/errorCode.js +6 -6
  190. package/src/utils/htmlToPDF.js +108 -108
  191. package/src/utils/htmlToPDFApi.js +5 -5
  192. package/src/utils/indexedDB.js +201 -201
  193. package/src/utils/login.js +144 -144
  194. package/src/utils/lowcode/lowcodeComponentMixin.js +112 -78
  195. package/src/utils/lowcode/lowcodeLog.js +29 -29
  196. package/src/utils/lowcode/lowcodeUtils.js +276 -129
  197. package/src/utils/lowcode/registerComponentForEditor.js +11 -11
  198. package/src/utils/lowcode/registerComponentForRender.js +11 -11
  199. package/src/utils/map-utils.js +47 -47
  200. package/src/utils/reg.js +19 -19
  201. package/src/utils/request.js +343 -343
  202. package/src/utils/routerUtil.js +435 -435
  203. package/src/utils/runEvalFunction.js +6 -6
  204. package/src/utils/util.js +241 -241
  205. package/src/utils/waterMark.js +31 -31
  206. package/test/Amis.spec.js +163 -163
  207. package/test/Tree.spec.js +167 -167
  208. package/test/myDialog.spec.js +46 -46
  209. package/vue.config.js +177 -177
  210. package//350/277/201/347/247/273/346/227/245/345/277/227.md +15 -15
@@ -1,807 +1,807 @@
1
- <template>
2
- <!-- 输入框 -->
3
- <x-form-col
4
- v-if="attr.type === 'input' && show"
5
- :flex="attr.flex">
6
- <a-form-model-item
7
- :ref="attr.model"
8
- :label="attr.name"
9
- :labelCol="layout === 'inline' && attr.occupyCol ? labelAndWrapperCol[attr.occupyCol].labelCol:undefined"
10
- :wrapperCol="layout === 'inline'&& attr.occupyCol ? labelAndWrapperCol[attr.occupyCol].wrapperCol:undefined"
11
- :style="layout === 'inline'&& attr.occupyCol && attr.occupyCol > 1? {width:`calc(100% - ${attr.occupyCol * 1.533}rem)`}:{}"
12
- :prop="attr.prop ? attr.prop : attr.model">
13
- <!-- 如果配置了后置按钮插槽 -->
14
- <a-input-group
15
- v-if="(attr.inputOnAfterName && attr.inputOnAfterFunc) || (attr.inputOnAfterIcon && attr.inputOnAfterIconFunc)"
16
- style="display: flex; width: 100%;"
17
- compact>
18
- <a-input
19
- v-model="form[attr.model]"
20
- :read-only="readOnly"
21
- :disabled="disabled && !readOnly"
22
- style="flex: 1; width: auto; min-width: 0;"
23
- :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"/>
24
- <a-button
25
- v-if="attr.inputOnAfterName && attr.inputOnAfterFunc"
26
- style="flex: 1; width: auto; min-width: 4rem;max-width: 6rem"
27
- type="primary"
28
- @click="emitFunc(attr.inputOnAfterFunc,form[attr.model])">
29
- {{ attr.inputOnAfterName }}
30
- </a-button>
31
- <!-- 仅可以配置 一个按钮 以及 一个图标插槽 -->
32
- <a-button
33
- style="width: 2rem; flex-shrink: 0;"
34
- v-if="attr.inputOnAfterIcon"
35
- :type="attr.inputOnAfterIcon && attr.inputOnAfterName ? 'primary' :''"
36
- :icon="attr.inputOnAfterIcon || 'question'"
37
- @click="emitFunc(attr.inputOnAfterIconFunc,form[attr.model])">
38
- </a-button>
39
- </a-input-group>
40
- <a-input
41
- v-else
42
- v-model="form[attr.model]"
43
- :read-only="readOnly"
44
- :disabled="disabled && !readOnly"
45
- style="width:100%"
46
- :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"/>
47
-
48
- </a-form-model-item>
49
- </x-form-col>
50
- <!-- 下拉框 -->
51
- <x-form-col
52
- v-else-if="(attr.type === 'select' || (attr.type === 'rate' && mode==='查询')) && show"
53
- :flex="attr.flex">
54
- <a-form-model-item
55
- :ref="attr.model"
56
- :label="attr.name"
57
- :prop="attr.prop ? attr.prop : attr.model">
58
- <a-select
59
- v-if="!attr.lazyLoad || attr.lazyLoad === 'false'"
60
- v-model="form[attr.model]"
61
- :disabled="disabled"
62
- :filter-option="filterOption"
63
- :getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
64
- :placeholder="attr.placeholder ? attr.placeholder : '请选择'"
65
- show-search
66
- >
67
- <a-select-option
68
- v-if="mode === '查询'"
69
- key="999999"
70
- value="全部">全部
71
- </a-select-option>
72
- <template v-if="attr.keys">
73
- <a-select-option
74
- v-for="(item,index) in attr.keys"
75
- :key="index.value"
76
- :value="item.value">
77
- {{ item.label }}
78
- </a-select-option>
79
- </template>
80
- <template v-else>
81
- <template
82
- v-if="attr.keyName.indexOf('logic@') !== -1 || attr.keyName.indexOf('config@') !== -1
83
- ||attr.keyName.indexOf('search@') !== -1 || attr.keyName.indexOf('search@') !== -1">
84
- <a-select-option
85
- v-for="(item,index) in option"
86
- :key="index.value"
87
- :value="item.value">
88
- <template v-if="attr.keyName.indexOf('config@') !== -1 && item.status">
89
- <!-- 徽标(badge) -->
90
- <a-badge v-if="item.status !== 'gary'" :color="item.status" :text="item.label"/>
91
- <a-badge v-else color="#D9D9D9" :text="item.label"/>
92
- </template>
93
- <template v-else>
94
- {{ item.label }}
95
- </template>
96
- </a-select-option>
97
- </template>
98
- <template
99
- v-else-if="attr.keyName.indexOf('async ') !== -1 || attr.keyName.indexOf('function ') !== -1">
100
- <a-select-option
101
- v-for="(item,index) in optionForFunc"
102
- :key="index.value"
103
- :value="item.value">
104
- <template>
105
- {{ item.label }}
106
- </template>
107
- </a-select-option>
108
- </template>
109
- <template v-else>
110
- <a-select-option
111
- v-for="item in $appdata.getDictionaryList(attr.keyName)"
112
- :key="item.value"
113
- :value="item.value">
114
- <!-- 徽标(badge) -->
115
- <x-badge :badge-key="attr.keyName" :replaceText="item.text" :value="item.value"/>
116
- </a-select-option>
117
- </template>
118
- </template>
119
- </a-select>
120
- <a-select
121
- v-else
122
- v-model="form[attr.model]"
123
- :disabled="disabled"
124
- :filter-option="filterOption"
125
- :getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
126
- :placeholder="attr.placeholder ? attr.placeholder : '搜索' + attr.name"
127
- show-search
128
- @search="fetchFunction"
129
- >
130
- <a-spin v-if="searching" slot="notFoundContent" size="small"/>
131
- <a-select-option
132
- v-if="mode === '查询'"
133
- key="999999"
134
- value="全部">全部
135
- </a-select-option>
136
- <a-select-option
137
- v-for="(item,index) in option"
138
- :key="index"
139
- :value="item.value">{{ item.label }}
140
- </a-select-option>
141
- </a-select>
142
- </a-form-model-item>
143
- </x-form-col>
144
- <!-- 多选框 -->
145
- <x-form-col
146
- v-else-if="attr.type === 'checkbox' && show"
147
- :flex="attr.flex">
148
- <a-form-model-item
149
- :ref="attr.model"
150
- :label="attr.name"
151
- :prop="attr.prop ? attr.prop : attr.model">
152
- <a-select
153
- v-if="!attr.lazyLoad || attr.lazyLoad === 'false'"
154
- v-model="form[attr.model]"
155
- :disabled="disabled"
156
- :filter-option="filterOption"
157
- :getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
158
- :placeholder="attr.placeholder ? attr.placeholder : '请选择'"
159
- mode="multiple"
160
- show-search
161
- allowClear
162
- >
163
- <template v-if="attr.keys">
164
- <a-select-option
165
- v-for="(item,index) in attr.keys"
166
- :key="index"
167
- :value="item.value">
168
- {{ item.label }}
169
- </a-select-option>
170
- </template>
171
- <template v-else>
172
- <template
173
- v-if="attr.keyName.indexOf('logic@') !== -1 || attr.keyName.indexOf('config@') !== -1
174
- ||attr.keyName.indexOf('search@') !== -1 || attr.keyName.indexOf('search@') !== -1">
175
- <a-select-option
176
- v-for="(item,index) in option"
177
- :key="index"
178
- :value="item.value">{{ item.label }}
179
- </a-select-option>
180
- </template>
181
- <template v-else>
182
- <a-select-option
183
- v-for="item in $appdata.getDictionaryList(attr.keyName)"
184
- :key="item.value"
185
- :value="item.value">{{ item.text }}
186
- </a-select-option>
187
- </template>
188
- </template>
189
- </a-select>
190
- <a-select
191
- v-else
192
- v-model="form[attr.model]"
193
- :disabled="disabled"
194
- :filter-option="filterOption"
195
- :getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
196
- :placeholder="attr.placeholder ? attr.placeholder : '搜索' + attr.name"
197
- mode="multiple"
198
- show-search
199
- allowClear
200
- @search="fetchFunction"
201
- >
202
- <a-spin v-if="searching" slot="notFoundContent" size="small"/>
203
- <a-select-option
204
- v-for="(item,index) in option"
205
- :key="index"
206
- :value="item.value">{{ item.label }}
207
- </a-select-option>
208
- </a-select>
209
- </a-form-model-item>
210
- </x-form-col>
211
- <!-- 单选框 -->
212
- <x-form-col
213
- v-else-if="attr.type === 'radio' && show"
214
- :flex="attr.flex">
215
- <a-form-model-item
216
- :ref="attr.model"
217
- :label="attr.name"
218
- :prop="attr.prop ? attr.prop : attr.model">
219
- <a-radio-group v-model="form[attr.model]">
220
- <template v-if="attr.keys">
221
- <a-radio v-for="(item,index) in attr.keys" :key="index" :value="item.value">
222
- {{ item.label }}
223
- </a-radio>
224
- </template>
225
- <template v-else>
226
- <template
227
- v-if="attr.keyName.indexOf('logic@') !== -1 || attr.keyName.indexOf('config@') !== -1
228
- ||attr.keyName.indexOf('search@') !== -1 || attr.keyName.indexOf('search@') !== -1">
229
- <a-radio v-for="(item,index) in option" :key="index" :value="item.value">
230
- {{ item.label }}
231
- </a-radio>
232
- </template>
233
- <template v-else>
234
- <a-radio v-for="(item,index) in $appdata.getDictionaryList(attr.keyName)" :key="index" :value="item.value">
235
- {{ item.text }}
236
- </a-radio>
237
- </template>
238
- </template>
239
- </a-radio-group>
240
- </a-form-model-item>
241
- </x-form-col>
242
- <!-- 日期范围选择器 -->
243
- <x-form-col
244
- v-else-if="attr.type === 'rangePicker' && show"
245
- :flex="attr.flex">
246
- <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.prop ? attr.prop : attr.model">
247
- <a-date-picker
248
- v-if="mode === '新增/修改'"
249
- v-model="form[attr.model]"
250
- :disabled="disabled"
251
- :show-time="true"
252
- style="width: 100%;"
253
- valueFormat="YYYY-MM-DD HH:mm:ss"/>
254
- <a-range-picker
255
- v-else
256
- v-model="form[attr.model]"
257
- :disabled="disabled"
258
- :show-time="true"
259
- valueFormat="YYYY-MM-DD HH:mm:ss"
260
- style="width: 100%;"
261
- />
262
- </a-form-model-item>
263
- </x-form-col>
264
- <!-- 月份选择器 -->
265
- <x-form-col
266
- v-else-if="attr.type === 'monthPicker' && show"
267
- :flex="attr.flex">
268
- <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.prop ? attr.prop : attr.model">
269
- <a-month-picker
270
- v-model="form[attr.model]"
271
- :disabled="disabled"
272
- :show-time="true"
273
- valueFormat="YYYY-MM"
274
- style="width: 100%;"
275
- />
276
- </a-form-model-item>
277
- </x-form-col>
278
- <!-- 年份选择器 -->
279
- <x-form-col
280
- v-else-if="attr.type === 'yearPicker' && show"
281
- :flex="attr.flex">
282
- <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.prop ? attr.prop : attr.model">
283
- <a-date-picker
284
- v-model="form[attr.model]"
285
- :disabled="disabled"
286
- format="YYYY"
287
- mode="year"
288
- v-decorator="['year']"
289
- placeholder="请选择年份"
290
- :open="yearShowOne"
291
- style="width: 100%;"
292
- @openChange="openChangeOne"
293
- @panelChange="panelChangeOne"/>
294
- </a-form-model-item>
295
- </x-form-col>
296
- <!-- 单日选择器 -->
297
- <x-form-col
298
- v-else-if="attr.type === 'datePicker' && show"
299
- :flex="attr.flex">
300
- <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.prop ? attr.prop : attr.model">
301
- <a-range-picker
302
- v-if="mode === '查询'"
303
- v-model="form[attr.model]"
304
- :disabled="disabled"
305
- :show-time="true"
306
- style="width: 100%;"
307
- format="YYYY-MM-DD"
308
- valueFormat="YYYY-MM-DD HH:mm:ss"/>
309
- <a-date-picker
310
- v-else
311
- v-model="form[attr.model]"
312
- :disabled="disabled"
313
- style="width: 100%;"
314
- :show-time="{ defaultValue: moment('00:00:00', 'HH:mm:ss') }"
315
- valueFormat="YYYY-MM-DD HH:mm:ss"/>
316
- </a-form-model-item>
317
- </x-form-col>
318
- <!-- 文本域 -->
319
- <a-col
320
- v-else-if="attr.type === 'textarea' && show"
321
- :xs="24"
322
- :sm="24"
323
- :md="24"
324
- :lg="24"
325
- :xl="24"
326
- :xxl="24">
327
- <a-form-model-item
328
- :labelCol="layout === 'inline'?{span:2}:undefined"
329
- :wrapperCol="layout === 'inline'?{span:22}:undefined"
330
- :ref="attr.model"
331
- :label="attr.name"
332
- :prop="attr.prop ? attr.prop : attr.model">
333
- <a-textarea
334
- v-model="form[attr.model]"
335
- style="width: 100%;"
336
- :disabled="disabled"
337
- :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"
338
- :rows="4"/>
339
- </a-form-model-item>
340
- </a-col>
341
- <!-- 文件上传 -->
342
- <a-col
343
- v-else-if="(attr.type === 'file' || attr.type === 'image') && show"
344
- :style="layout === 'inline'?{width:'calc(100% - 60px)'}:{}"
345
- :xs="24"
346
- :sm="24"
347
- :md="24"
348
- :lg="24"
349
- :xl="24"
350
- :xxl="24">
351
- <a-form-model-item
352
- :labelCol="layout === 'inline'?{span:2}:undefined"
353
- :wrapperCol="layout === 'inline'?{span:22}:undefined"
354
- :ref="attr.model"
355
- :label="attr.name"
356
- :prop="attr.prop ? attr.prop : attr.model">
357
- <upload
358
- :files="files"
359
- :images="images"
360
- :model="attr"
361
- :uploadStyle="attr.uploadStyle"
362
- :service-name="serviceName"
363
- @setFiles="setFiles"></upload>
364
- </a-form-model-item>
365
- </a-col>
366
- <!-- 省市区选择框 -->
367
- <x-form-col
368
- v-else-if="attr.type === 'citySelect' && show"
369
- :flex="attr.flex">
370
- <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.prop ? attr.prop : attr.model">
371
- <citySelect
372
- ref="citySelect"
373
- v-model="form[attr.model]"
374
- :contexts="attr.contexts"
375
- :value-type="attr.valueType"
376
- :default-value="form[attr.model]"></citySelect>
377
- </a-form-model-item>
378
- </x-form-col>
379
- <!-- 地点搜索框 -->
380
- <x-form-col
381
- v-else-if="attr.type === 'addressSearch' && show"
382
- :flex="attr.flex">
383
- <a-form-model-item
384
- :ref="attr.model"
385
- :label="attr.name"
386
- :prop="attr.prop ? attr.prop : attr.model"
387
- :labelCol="layout === 'inline' && attr.occupyCol ? labelAndWrapperCol[attr.occupyCol].labelCol:undefined"
388
- :wrapperCol="layout === 'inline'&& attr.occupyCol ? labelAndWrapperCol[attr.occupyCol].wrapperCol:undefined"
389
- :style="layout === 'inline'&& attr.occupyCol && attr.occupyCol > 1? {width:`calc(100% - ${attr.occupyCol * 1.533}rem)`}:{}">
390
- <address-search-combobox
391
- :emitFunc="emitFunc"
392
- :attr="attr"
393
- :read-only="readOnly"
394
- v-model="searchResult"
395
- :resultKeys="{ address: attr.model, coords: `${attr.model}_lng_lat` }"
396
- ref="addressSearchCombobox"
397
- searchResultType="Object"
398
- @onSelect="addressSearchComboboxSelect"
399
- @onDivisionsChange="onDivisionsChange"
400
- ></address-search-combobox>
401
- </a-form-model-item>
402
- </x-form-col>
403
- <!-- 人员选择框 -->
404
- <x-form-col
405
- v-else-if="attr.type === 'personSetting' && show"
406
- :flex="attr.flex">
407
- <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.prop ? attr.prop : attr.model">
408
- <PersonSetting v-model="form[attr.model]"></PersonSetting>
409
- </a-form-model-item>
410
- </x-form-col>
411
- <!-- 树形选择框 -->
412
- <x-form-col
413
- v-else-if="attr.type === 'treeSelect' && show"
414
- :flex="attr.flex">
415
- <x-tree-select
416
- v-model="form[attr.model]"
417
- :attr="attr"
418
- ref="xTreeSelect">
419
- </x-tree-select>
420
- </x-form-col>
421
- <!-- 评分框 -->
422
- <x-form-col
423
- v-else-if="attr.type === 'rate' && show"
424
- :flex="attr.flex">
425
- <a-form-model-item
426
- :ref="attr.model"
427
- :label="attr.name"
428
- :prop="attr.prop ? attr.prop : attr.model">
429
- <a-rate v-model="form[attr.model]"/>
430
- </a-form-model-item>
431
- </x-form-col>
432
- </template>
433
- <script>
434
-
435
- import { debounce } from 'ant-design-vue/lib/vc-table/src/utils'
436
- import XFormCol from '@vue2-client/base-client/components/common/XFormCol'
437
- import XBadge from '@vue2-client/base-client/components/common/XBadge'
438
- import CitySelect from '@vue2-client/base-client/components/common/CitySelect'
439
- import PersonSetting from '@vue2-client/base-client/components/common/PersonSetting'
440
- import AddressSearchCombobox from '@vue2-client/base-client/components/common/AddressSearchCombobox'
441
- import Upload from '@vue2-client/base-client/components/common/Upload'
442
- import moment from 'moment'
443
- import util from '.././../../../utils/util'
444
- import XTreeSelect from '@vue2-client/base-client/components/common/XForm/XTreeSelect'
445
- import { getConfigByName, runLogic } from '@vue2-client/services/api/common'
446
- import { searchToOption } from '@vue2-client/services/v3Api'
447
- import { mapState } from 'vuex'
448
- import executeStrFunction from '@vue2-client/utils/runEvalFunction'
449
-
450
- export default {
451
- name: 'XFormItem',
452
- components: {
453
- XTreeSelect,
454
- XFormCol,
455
- XBadge,
456
- CitySelect,
457
- PersonSetting,
458
- AddressSearchCombobox,
459
- Upload
460
- },
461
- data () {
462
- // 检索去抖
463
- this.fetchFunction = debounce(this.fetchFunction, 800)
464
- return {
465
- option: [],
466
- // 最后检索版本
467
- lastFetchId: 0,
468
- // 检索中
469
- searching: false,
470
- searchResult: '',
471
- yearShowOne: false,
472
- optionForFunc: [],
473
- // 控制当前表单项是否展示
474
- show: true,
475
- labelAndWrapperCol: [{
476
- labelCol: undefined,
477
- wrapperCol: undefined
478
- },
479
- {
480
- labelCol: undefined,
481
- wrapperCol: undefined
482
- },
483
- {
484
- labelCol: { span: 3 },
485
- wrapperCol: { span: 21 }
486
- },
487
- {
488
- labelCol: { span: 2 },
489
- wrapperCol: { span: 22 }
490
- }],
491
- // moment
492
- moment
493
- }
494
- },
495
- props: {
496
- attr: {
497
- type: Object,
498
- default:
499
- () => {
500
- return {}
501
- }
502
- },
503
- form: {
504
- type: Object,
505
- required:
506
- true
507
- },
508
- disabled: {
509
- type: Boolean,
510
- default:
511
- () => {
512
- return false
513
- }
514
- },
515
- readOnly: {
516
- type: Boolean,
517
- default:
518
- () => {
519
- return false
520
- }
521
- },
522
- mode: {
523
- type: String,
524
- default:
525
- () => {
526
- return '查询'
527
- }
528
- },
529
- files: {
530
- type: Array,
531
- default:
532
- () => {
533
- return []
534
- }
535
- },
536
- images: {
537
- type: Array,
538
- default:
539
- () => {
540
- return []
541
- }
542
- },
543
- serviceName: {
544
- type: String,
545
- default:
546
- undefined
547
- },
548
- // 调用logic获取数据源的追加参数
549
- getDataParams: {
550
- type: Object,
551
- default:
552
- undefined
553
- },
554
- // 布局
555
- layout: {
556
- type: String,
557
- default:
558
- 'horizontal'
559
- },
560
- // 环境
561
- env: {
562
- type: String,
563
- default:
564
- () => {
565
- return 'prod'
566
- }
567
- },
568
- // 设置表单值
569
- setForm: {
570
- type: Function,
571
- default: (val) => {
572
- console.log(val)
573
- }
574
- },
575
- },
576
- created () {
577
- this.init()
578
- if (this.attr.keyName && (this.attr?.keyName?.toString().indexOf('async ') !== -1 || this.attr?.keyName?.toString()?.indexOf('function') !== -1)) {
579
- this.debouncedUpdateOptions = debounce(this.updateOptions, 200)
580
- }
581
- if (this.attr.dataChangeFunc) {
582
- this.debouncedDataChangeFunc = debounce(this.dataChangeFunc, 200)
583
- }
584
- if (this.attr.showFormItemFunc) {
585
- this.debouncedShowFormItemFunc = debounce(this.showFormItemFunc, 100)
586
- // 执行一次
587
- debounce(this.showFormItemFunc, 100)()
588
- }
589
- },
590
- computed: {
591
- ...mapState('account', { currUser: 'user' })
592
- },
593
- watch: {
594
- attr: {
595
- handler () {
596
- this.init()
597
- },
598
- deep: true
599
- },
600
- form: {
601
- handler (newVal) {
602
- // 如果是从函数获取 options
603
- if (this.attr.keyName && (this.attr.keyName.toString().indexOf('async ') !== -1 || this.attr.keyName.toString().indexOf('function') !== -1)) {
604
- this.debouncedUpdateOptions()
605
- }
606
- // 如果有自定义函数变更函数
607
- if (this.attr.dataChangeFunc) {
608
- this.debouncedDataChangeFunc()
609
- }
610
- // 如果有自定义是否展示表单项函数
611
- if (this.attr.showFormItemFunc) {
612
- this.debouncedShowFormItemFunc()
613
- }
614
- // 地址搜索框赋值
615
- if (this.attr.type === 'addressSearch') {
616
- this.$refs.addressSearchCombobox.addressInput = this.form[this.attr.model]
617
- }
618
- },
619
- deep: true
620
- }
621
- },
622
- methods: {
623
- async updateOptions () {
624
- if (this.attr.keyName && (this.attr.keyName.indexOf('async ') !== -1 || this.attr.keyName.indexOf('function ') !== -1)) {
625
- this.optionForFunc = await executeStrFunction(this.attr.keyName, [this.form, runLogic])
626
- }
627
- },
628
- async dataChangeFunc () {
629
- if (this.attr.dataChangeFunc) {
630
- await executeStrFunction(this.attr.dataChangeFunc, [this.form, this.setForm, this.attr, util])
631
- }
632
- },
633
- async showFormItemFunc () {
634
- if (this.attr.showFormItemFunc) {
635
- this.show = executeStrFunction(this.attr.showFormItemFunc, [this.form, this.setForm, this.attr, util])
636
- } else {
637
- this.show = true
638
- }
639
- },
640
- init () {
641
- if (this.mode === '新增/修改' && !this.attr.flex) {
642
- if (['horizontal', 'vertical'].includes(this.layout)) {
643
- // 新增修改表单 horizontal 模式下默认为一行
644
- this.attr.flex = {
645
- xs: 24,
646
- sm: 24,
647
- md: 24,
648
- lg: 24,
649
- xl: 24,
650
- xxl: 24
651
- }
652
- } else {
653
- if (['input', 'addressSearch'] && this.attr.occupyCol) {
654
- // 如果是 input 看是否配置了 占用列配置
655
- this.attr.flex = {
656
- xs: 8 * this.attr.occupyCol,
657
- sm: 8 * this.attr.occupyCol,
658
- md: 8 * this.attr.occupyCol,
659
- lg: 8 * this.attr.occupyCol,
660
- xl: 8 * this.attr.occupyCol,
661
- xxl: 8 * this.attr.occupyCol
662
- }
663
- } else {
664
- // 新增修改表单 vertical 模式下默认为1列
665
- this.attr.flex = {
666
- xs: 24,
667
- sm: 24,
668
- md: 24,
669
- lg: 12,
670
- xl: 8,
671
- xxl: 8
672
- }
673
- }
674
- }
675
- }
676
- if (this.attr.keyName && this.attr.keyName.indexOf('logic@') !== -1) {
677
- this.getData({}, res => this.getDataCallback(res))
678
- }
679
- if (this.attr.keyName && this.attr.keyName.indexOf('search@') !== -1) {
680
- // `tool.getFullTree(this.getRights().where(row.getType()==$organization$))`
681
- searchToOption({
682
- source: this.attr.keyName.substring(7),
683
- userid: this.currUser.id
684
- }, res => this.getDataCallback(res))
685
- } else if (this.attr.keyName && this.attr.keyName.indexOf('config@') !== -1) {
686
- const configName = this.attr.keyName.substring(7)
687
- getConfigByName(configName, this.serviceName, res => {
688
- this.getDataCallback(res.value)
689
- }, this.env === 'dev')
690
- } else if (this.attr.keyName && (this.attr.keyName.indexOf('async ') !== -1 || this.attr.keyName.indexOf('function ') !== -1)) {
691
- this.updateOptions()
692
- } else {
693
- this.initRadioValue()
694
- }
695
- },
696
- addressSearchComboboxSelect (data) {
697
- this.form = Object.assign(this.form, JSON.parse(data))
698
- },
699
- onDivisionsChange (data) {
700
- this.emitFunc('addressSearchComboboxSelect', {
701
- key: this.attr.model,
702
- value: data
703
- })
704
- },
705
- getDataCallback (res) {
706
- this.option = res
707
- if (this.attr.type === 'treeSelect') {
708
- this.$refs.xTreeSelect.init({
709
- option: this.option,
710
- form: this.form,
711
- queryType: this.attr.queryType,
712
- name: this.attr.name,
713
- model: this.attr.model,
714
- mode: this.mode,
715
- disabled: this.disabled
716
- })
717
- } else if (this.attr.type === 'radio') {
718
- this.initRadioValue()
719
- }
720
- },
721
- initRadioValue () {
722
- const model = this.attr.model
723
- if (this.mode === '新增/修改' && this.attr.type === 'radio' && !this.form[model]) {
724
- if (this.attr.keys && this.attr.keys.length > 0) {
725
- this.form[model] = this.attr.keys[0].value
726
- } else if (this.option && this.option.length > 0) {
727
- this.form[model] = this.option[0].value
728
- } else if (this.attr.keyName) {
729
- const list = this.$appdata.getDictionaryList(this.attr.keyName)
730
- if (list.length > 0) {
731
- this.form[model] = list[0].value
732
- }
733
- }
734
- }
735
- },
736
- openChangeOne (status) {
737
- if (status) {
738
- this.yearShowOne = true
739
- }
740
- },
741
- // 得到年份选择器的值
742
- panelChangeOne (value) {
743
- this.yearShowOne = false
744
- this.form[this.attr.model] = value.format('YYYY')
745
- },
746
- // 文件框时设置上传组件的值
747
- setFiles (fileIds) {
748
- if (!this.form[this.attr.model]) {
749
- this.form[this.attr.model] = []
750
- }
751
- this.form[this.attr.model] = [...fileIds]
752
- },
753
- // 懒加载检索方法
754
- fetchFunction (value) {
755
- this.lastFetchId += 1
756
- const fetchId = this.lastFetchId
757
- this.option = []
758
- this.searching = true
759
- this.getData({
760
- word: value
761
- }, res => {
762
- if (fetchId !== this.lastFetchId) {
763
- return
764
- }
765
- this.option = res
766
- this.searching = false
767
- })
768
- },
769
- // 获取数据
770
- getData (value, callbackFun) {
771
- if (value !== '') {
772
- const logicName = this.attr.keyName
773
- const logic = logicName.substring(6)
774
- // 调用logic前设置参数
775
- if (this.getDataParams && this.getDataParams[this.attr.model]) {
776
- Object.assign(value, this.getDataParams[this.attr.model])
777
- }
778
- runLogic(logic, Object.assign(value, {
779
- orgId: this.currUser.orgid,
780
- userId: this.currUser.id
781
- }), this.serviceName, this.env === 'dev').then(res => {
782
- callbackFun(res)
783
- }).catch(e => {
784
- callbackFun([])
785
- console.error('获取数据失败:' + e)
786
- })
787
- }
788
- },
789
- filterOption (input, option) {
790
- const child = option.componentOptions.children[0]
791
- if (child.text) {
792
- return child.text.toLowerCase().indexOf(input.toLowerCase()) >= 0
793
- } else if (child.elm.innerText) {
794
- return child.elm.innerText.toLowerCase().indexOf(input.toLowerCase()) >= 0
795
- } else {
796
- return child.child.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
797
- }
798
- },
799
- emitFunc (func, data) {
800
- this.$emit('x-form-item-emit-func', func, data)
801
- }
802
- }
803
- }
804
- </script>
805
-
806
- <style lang="less" scoped>
807
- </style>
1
+ <template>
2
+ <!-- 输入框 -->
3
+ <x-form-col
4
+ v-if="attr.type === 'input' && show"
5
+ :flex="attr.flex">
6
+ <a-form-model-item
7
+ :ref="attr.model"
8
+ :label="attr.name"
9
+ :labelCol="layout === 'inline' && attr.occupyCol ? labelAndWrapperCol[attr.occupyCol].labelCol:undefined"
10
+ :wrapperCol="layout === 'inline'&& attr.occupyCol ? labelAndWrapperCol[attr.occupyCol].wrapperCol:undefined"
11
+ :style="layout === 'inline'&& attr.occupyCol && attr.occupyCol > 1? {width:`calc(100% - ${attr.occupyCol * 1.533}rem)`}:{}"
12
+ :prop="attr.prop ? attr.prop : attr.model">
13
+ <!-- 如果配置了后置按钮插槽 -->
14
+ <a-input-group
15
+ v-if="(attr.inputOnAfterName && attr.inputOnAfterFunc) || (attr.inputOnAfterIcon && attr.inputOnAfterIconFunc)"
16
+ style="display: flex; width: 100%;"
17
+ compact>
18
+ <a-input
19
+ v-model="form[attr.model]"
20
+ :read-only="readOnly"
21
+ :disabled="disabled && !readOnly"
22
+ style="flex: 1; width: auto; min-width: 0;"
23
+ :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"/>
24
+ <a-button
25
+ v-if="attr.inputOnAfterName && attr.inputOnAfterFunc"
26
+ style="flex: 1; width: auto; min-width: 4rem;max-width: 6rem"
27
+ type="primary"
28
+ @click="emitFunc(attr.inputOnAfterFunc,form[attr.model])">
29
+ {{ attr.inputOnAfterName }}
30
+ </a-button>
31
+ <!-- 仅可以配置 一个按钮 以及 一个图标插槽 -->
32
+ <a-button
33
+ style="width: 2rem; flex-shrink: 0;"
34
+ v-if="attr.inputOnAfterIcon"
35
+ :type="attr.inputOnAfterIcon && attr.inputOnAfterName ? 'primary' :''"
36
+ :icon="attr.inputOnAfterIcon || 'question'"
37
+ @click="emitFunc(attr.inputOnAfterIconFunc,form[attr.model])">
38
+ </a-button>
39
+ </a-input-group>
40
+ <a-input
41
+ v-else
42
+ v-model="form[attr.model]"
43
+ :read-only="readOnly"
44
+ :disabled="disabled && !readOnly"
45
+ style="width:100%"
46
+ :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"/>
47
+
48
+ </a-form-model-item>
49
+ </x-form-col>
50
+ <!-- 下拉框 -->
51
+ <x-form-col
52
+ v-else-if="(attr.type === 'select' || (attr.type === 'rate' && mode==='查询')) && show"
53
+ :flex="attr.flex">
54
+ <a-form-model-item
55
+ :ref="attr.model"
56
+ :label="attr.name"
57
+ :prop="attr.prop ? attr.prop : attr.model">
58
+ <a-select
59
+ v-if="!attr.lazyLoad || attr.lazyLoad === 'false'"
60
+ v-model="form[attr.model]"
61
+ :disabled="disabled"
62
+ :filter-option="filterOption"
63
+ :getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
64
+ :placeholder="attr.placeholder ? attr.placeholder : '请选择'"
65
+ show-search
66
+ >
67
+ <a-select-option
68
+ v-if="mode === '查询'"
69
+ key="999999"
70
+ value="全部">全部
71
+ </a-select-option>
72
+ <template v-if="attr.keys">
73
+ <a-select-option
74
+ v-for="(item,index) in attr.keys"
75
+ :key="index.value"
76
+ :value="item.value">
77
+ {{ item.label }}
78
+ </a-select-option>
79
+ </template>
80
+ <template v-else>
81
+ <template
82
+ v-if="attr.keyName.indexOf('logic@') !== -1 || attr.keyName.indexOf('config@') !== -1
83
+ ||attr.keyName.indexOf('search@') !== -1 || attr.keyName.indexOf('search@') !== -1">
84
+ <a-select-option
85
+ v-for="(item,index) in option"
86
+ :key="index.value"
87
+ :value="item.value">
88
+ <template v-if="attr.keyName.indexOf('config@') !== -1 && item.status">
89
+ <!-- 徽标(badge) -->
90
+ <a-badge v-if="item.status !== 'gary'" :color="item.status" :text="item.label"/>
91
+ <a-badge v-else color="#D9D9D9" :text="item.label"/>
92
+ </template>
93
+ <template v-else>
94
+ {{ item.label }}
95
+ </template>
96
+ </a-select-option>
97
+ </template>
98
+ <template
99
+ v-else-if="attr.keyName.indexOf('async ') !== -1 || attr.keyName.indexOf('function ') !== -1">
100
+ <a-select-option
101
+ v-for="(item,index) in optionForFunc"
102
+ :key="index.value"
103
+ :value="item.value">
104
+ <template>
105
+ {{ item.label }}
106
+ </template>
107
+ </a-select-option>
108
+ </template>
109
+ <template v-else>
110
+ <a-select-option
111
+ v-for="item in $appdata.getDictionaryList(attr.keyName)"
112
+ :key="item.value"
113
+ :value="item.value">
114
+ <!-- 徽标(badge) -->
115
+ <x-badge :badge-key="attr.keyName" :replaceText="item.text" :value="item.value"/>
116
+ </a-select-option>
117
+ </template>
118
+ </template>
119
+ </a-select>
120
+ <a-select
121
+ v-else
122
+ v-model="form[attr.model]"
123
+ :disabled="disabled"
124
+ :filter-option="filterOption"
125
+ :getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
126
+ :placeholder="attr.placeholder ? attr.placeholder : '搜索' + attr.name"
127
+ show-search
128
+ @search="fetchFunction"
129
+ >
130
+ <a-spin v-if="searching" slot="notFoundContent" size="small"/>
131
+ <a-select-option
132
+ v-if="mode === '查询'"
133
+ key="999999"
134
+ value="全部">全部
135
+ </a-select-option>
136
+ <a-select-option
137
+ v-for="(item,index) in option"
138
+ :key="index"
139
+ :value="item.value">{{ item.label }}
140
+ </a-select-option>
141
+ </a-select>
142
+ </a-form-model-item>
143
+ </x-form-col>
144
+ <!-- 多选框 -->
145
+ <x-form-col
146
+ v-else-if="attr.type === 'checkbox' && show"
147
+ :flex="attr.flex">
148
+ <a-form-model-item
149
+ :ref="attr.model"
150
+ :label="attr.name"
151
+ :prop="attr.prop ? attr.prop : attr.model">
152
+ <a-select
153
+ v-if="!attr.lazyLoad || attr.lazyLoad === 'false'"
154
+ v-model="form[attr.model]"
155
+ :disabled="disabled"
156
+ :filter-option="filterOption"
157
+ :getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
158
+ :placeholder="attr.placeholder ? attr.placeholder : '请选择'"
159
+ mode="multiple"
160
+ show-search
161
+ allowClear
162
+ >
163
+ <template v-if="attr.keys">
164
+ <a-select-option
165
+ v-for="(item,index) in attr.keys"
166
+ :key="index"
167
+ :value="item.value">
168
+ {{ item.label }}
169
+ </a-select-option>
170
+ </template>
171
+ <template v-else>
172
+ <template
173
+ v-if="attr.keyName.indexOf('logic@') !== -1 || attr.keyName.indexOf('config@') !== -1
174
+ ||attr.keyName.indexOf('search@') !== -1 || attr.keyName.indexOf('search@') !== -1">
175
+ <a-select-option
176
+ v-for="(item,index) in option"
177
+ :key="index"
178
+ :value="item.value">{{ item.label }}
179
+ </a-select-option>
180
+ </template>
181
+ <template v-else>
182
+ <a-select-option
183
+ v-for="item in $appdata.getDictionaryList(attr.keyName)"
184
+ :key="item.value"
185
+ :value="item.value">{{ item.text }}
186
+ </a-select-option>
187
+ </template>
188
+ </template>
189
+ </a-select>
190
+ <a-select
191
+ v-else
192
+ v-model="form[attr.model]"
193
+ :disabled="disabled"
194
+ :filter-option="filterOption"
195
+ :getPopupContainer=" triggerNode => { return triggerNode.parentNode } "
196
+ :placeholder="attr.placeholder ? attr.placeholder : '搜索' + attr.name"
197
+ mode="multiple"
198
+ show-search
199
+ allowClear
200
+ @search="fetchFunction"
201
+ >
202
+ <a-spin v-if="searching" slot="notFoundContent" size="small"/>
203
+ <a-select-option
204
+ v-for="(item,index) in option"
205
+ :key="index"
206
+ :value="item.value">{{ item.label }}
207
+ </a-select-option>
208
+ </a-select>
209
+ </a-form-model-item>
210
+ </x-form-col>
211
+ <!-- 单选框 -->
212
+ <x-form-col
213
+ v-else-if="attr.type === 'radio' && show"
214
+ :flex="attr.flex">
215
+ <a-form-model-item
216
+ :ref="attr.model"
217
+ :label="attr.name"
218
+ :prop="attr.prop ? attr.prop : attr.model">
219
+ <a-radio-group v-model="form[attr.model]">
220
+ <template v-if="attr.keys">
221
+ <a-radio v-for="(item,index) in attr.keys" :key="index" :value="item.value">
222
+ {{ item.label }}
223
+ </a-radio>
224
+ </template>
225
+ <template v-else>
226
+ <template
227
+ v-if="attr.keyName.indexOf('logic@') !== -1 || attr.keyName.indexOf('config@') !== -1
228
+ ||attr.keyName.indexOf('search@') !== -1 || attr.keyName.indexOf('search@') !== -1">
229
+ <a-radio v-for="(item,index) in option" :key="index" :value="item.value">
230
+ {{ item.label }}
231
+ </a-radio>
232
+ </template>
233
+ <template v-else>
234
+ <a-radio v-for="(item,index) in $appdata.getDictionaryList(attr.keyName)" :key="index" :value="item.value">
235
+ {{ item.text }}
236
+ </a-radio>
237
+ </template>
238
+ </template>
239
+ </a-radio-group>
240
+ </a-form-model-item>
241
+ </x-form-col>
242
+ <!-- 日期范围选择器 -->
243
+ <x-form-col
244
+ v-else-if="attr.type === 'rangePicker' && show"
245
+ :flex="attr.flex">
246
+ <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.prop ? attr.prop : attr.model">
247
+ <a-date-picker
248
+ v-if="mode === '新增/修改'"
249
+ v-model="form[attr.model]"
250
+ :disabled="disabled"
251
+ :show-time="true"
252
+ style="width: 100%;"
253
+ valueFormat="YYYY-MM-DD HH:mm:ss"/>
254
+ <a-range-picker
255
+ v-else
256
+ v-model="form[attr.model]"
257
+ :disabled="disabled"
258
+ :show-time="true"
259
+ valueFormat="YYYY-MM-DD HH:mm:ss"
260
+ style="width: 100%;"
261
+ />
262
+ </a-form-model-item>
263
+ </x-form-col>
264
+ <!-- 月份选择器 -->
265
+ <x-form-col
266
+ v-else-if="attr.type === 'monthPicker' && show"
267
+ :flex="attr.flex">
268
+ <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.prop ? attr.prop : attr.model">
269
+ <a-month-picker
270
+ v-model="form[attr.model]"
271
+ :disabled="disabled"
272
+ :show-time="true"
273
+ valueFormat="YYYY-MM"
274
+ style="width: 100%;"
275
+ />
276
+ </a-form-model-item>
277
+ </x-form-col>
278
+ <!-- 年份选择器 -->
279
+ <x-form-col
280
+ v-else-if="attr.type === 'yearPicker' && show"
281
+ :flex="attr.flex">
282
+ <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.prop ? attr.prop : attr.model">
283
+ <a-date-picker
284
+ v-model="form[attr.model]"
285
+ :disabled="disabled"
286
+ format="YYYY"
287
+ mode="year"
288
+ v-decorator="['year']"
289
+ placeholder="请选择年份"
290
+ :open="yearShowOne"
291
+ style="width: 100%;"
292
+ @openChange="openChangeOne"
293
+ @panelChange="panelChangeOne"/>
294
+ </a-form-model-item>
295
+ </x-form-col>
296
+ <!-- 单日选择器 -->
297
+ <x-form-col
298
+ v-else-if="attr.type === 'datePicker' && show"
299
+ :flex="attr.flex">
300
+ <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.prop ? attr.prop : attr.model">
301
+ <a-range-picker
302
+ v-if="mode === '查询'"
303
+ v-model="form[attr.model]"
304
+ :disabled="disabled"
305
+ :show-time="true"
306
+ style="width: 100%;"
307
+ format="YYYY-MM-DD"
308
+ valueFormat="YYYY-MM-DD HH:mm:ss"/>
309
+ <a-date-picker
310
+ v-else
311
+ v-model="form[attr.model]"
312
+ :disabled="disabled"
313
+ style="width: 100%;"
314
+ :show-time="{ defaultValue: moment('00:00:00', 'HH:mm:ss') }"
315
+ valueFormat="YYYY-MM-DD HH:mm:ss"/>
316
+ </a-form-model-item>
317
+ </x-form-col>
318
+ <!-- 文本域 -->
319
+ <a-col
320
+ v-else-if="attr.type === 'textarea' && show"
321
+ :xs="24"
322
+ :sm="24"
323
+ :md="24"
324
+ :lg="24"
325
+ :xl="24"
326
+ :xxl="24">
327
+ <a-form-model-item
328
+ :labelCol="layout === 'inline'?{span:2}:undefined"
329
+ :wrapperCol="layout === 'inline'?{span:22}:undefined"
330
+ :ref="attr.model"
331
+ :label="attr.name"
332
+ :prop="attr.prop ? attr.prop : attr.model">
333
+ <a-textarea
334
+ v-model="form[attr.model]"
335
+ style="width: 100%;"
336
+ :disabled="disabled"
337
+ :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')"
338
+ :rows="4"/>
339
+ </a-form-model-item>
340
+ </a-col>
341
+ <!-- 文件上传 -->
342
+ <a-col
343
+ v-else-if="(attr.type === 'file' || attr.type === 'image') && show"
344
+ :style="layout === 'inline'?{width:'calc(100% - 60px)'}:{}"
345
+ :xs="24"
346
+ :sm="24"
347
+ :md="24"
348
+ :lg="24"
349
+ :xl="24"
350
+ :xxl="24">
351
+ <a-form-model-item
352
+ :labelCol="layout === 'inline'?{span:2}:undefined"
353
+ :wrapperCol="layout === 'inline'?{span:22}:undefined"
354
+ :ref="attr.model"
355
+ :label="attr.name"
356
+ :prop="attr.prop ? attr.prop : attr.model">
357
+ <upload
358
+ :files="files"
359
+ :images="images"
360
+ :model="attr"
361
+ :uploadStyle="attr.uploadStyle"
362
+ :service-name="serviceName"
363
+ @setFiles="setFiles"></upload>
364
+ </a-form-model-item>
365
+ </a-col>
366
+ <!-- 省市区选择框 -->
367
+ <x-form-col
368
+ v-else-if="attr.type === 'citySelect' && show"
369
+ :flex="attr.flex">
370
+ <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.prop ? attr.prop : attr.model">
371
+ <citySelect
372
+ ref="citySelect"
373
+ v-model="form[attr.model]"
374
+ :contexts="attr.contexts"
375
+ :value-type="attr.valueType"
376
+ :default-value="form[attr.model]"></citySelect>
377
+ </a-form-model-item>
378
+ </x-form-col>
379
+ <!-- 地点搜索框 -->
380
+ <x-form-col
381
+ v-else-if="attr.type === 'addressSearch' && show"
382
+ :flex="attr.flex">
383
+ <a-form-model-item
384
+ :ref="attr.model"
385
+ :label="attr.name"
386
+ :prop="attr.prop ? attr.prop : attr.model"
387
+ :labelCol="layout === 'inline' && attr.occupyCol ? labelAndWrapperCol[attr.occupyCol].labelCol:undefined"
388
+ :wrapperCol="layout === 'inline'&& attr.occupyCol ? labelAndWrapperCol[attr.occupyCol].wrapperCol:undefined"
389
+ :style="layout === 'inline'&& attr.occupyCol && attr.occupyCol > 1? {width:`calc(100% - ${attr.occupyCol * 1.533}rem)`}:{}">
390
+ <address-search-combobox
391
+ :emitFunc="emitFunc"
392
+ :attr="attr"
393
+ :read-only="readOnly"
394
+ v-model="searchResult"
395
+ :resultKeys="{ address: attr.model, coords: `${attr.model}_lng_lat` }"
396
+ ref="addressSearchCombobox"
397
+ searchResultType="Object"
398
+ @onSelect="addressSearchComboboxSelect"
399
+ @onDivisionsChange="onDivisionsChange"
400
+ ></address-search-combobox>
401
+ </a-form-model-item>
402
+ </x-form-col>
403
+ <!-- 人员选择框 -->
404
+ <x-form-col
405
+ v-else-if="attr.type === 'personSetting' && show"
406
+ :flex="attr.flex">
407
+ <a-form-model-item :ref="attr.model" :label="attr.name" :prop="attr.prop ? attr.prop : attr.model">
408
+ <PersonSetting v-model="form[attr.model]"></PersonSetting>
409
+ </a-form-model-item>
410
+ </x-form-col>
411
+ <!-- 树形选择框 -->
412
+ <x-form-col
413
+ v-else-if="attr.type === 'treeSelect' && show"
414
+ :flex="attr.flex">
415
+ <x-tree-select
416
+ v-model="form[attr.model]"
417
+ :attr="attr"
418
+ ref="xTreeSelect">
419
+ </x-tree-select>
420
+ </x-form-col>
421
+ <!-- 评分框 -->
422
+ <x-form-col
423
+ v-else-if="attr.type === 'rate' && show"
424
+ :flex="attr.flex">
425
+ <a-form-model-item
426
+ :ref="attr.model"
427
+ :label="attr.name"
428
+ :prop="attr.prop ? attr.prop : attr.model">
429
+ <a-rate v-model="form[attr.model]"/>
430
+ </a-form-model-item>
431
+ </x-form-col>
432
+ </template>
433
+ <script>
434
+
435
+ import { debounce } from 'ant-design-vue/lib/vc-table/src/utils'
436
+ import XFormCol from '@vue2-client/base-client/components/common/XFormCol'
437
+ import XBadge from '@vue2-client/base-client/components/common/XBadge'
438
+ import CitySelect from '@vue2-client/base-client/components/common/CitySelect'
439
+ import PersonSetting from '@vue2-client/base-client/components/common/PersonSetting'
440
+ import AddressSearchCombobox from '@vue2-client/base-client/components/common/AddressSearchCombobox'
441
+ import Upload from '@vue2-client/base-client/components/common/Upload'
442
+ import moment from 'moment'
443
+ import util from '.././../../../utils/util'
444
+ import XTreeSelect from '@vue2-client/base-client/components/common/XForm/XTreeSelect'
445
+ import { getConfigByName, runLogic } from '@vue2-client/services/api/common'
446
+ import { searchToOption } from '@vue2-client/services/v3Api'
447
+ import { mapState } from 'vuex'
448
+ import executeStrFunction from '@vue2-client/utils/runEvalFunction'
449
+
450
+ export default {
451
+ name: 'XFormItem',
452
+ components: {
453
+ XTreeSelect,
454
+ XFormCol,
455
+ XBadge,
456
+ CitySelect,
457
+ PersonSetting,
458
+ AddressSearchCombobox,
459
+ Upload
460
+ },
461
+ data () {
462
+ // 检索去抖
463
+ this.fetchFunction = debounce(this.fetchFunction, 800)
464
+ return {
465
+ option: [],
466
+ // 最后检索版本
467
+ lastFetchId: 0,
468
+ // 检索中
469
+ searching: false,
470
+ searchResult: '',
471
+ yearShowOne: false,
472
+ optionForFunc: [],
473
+ // 控制当前表单项是否展示
474
+ show: true,
475
+ labelAndWrapperCol: [{
476
+ labelCol: undefined,
477
+ wrapperCol: undefined
478
+ },
479
+ {
480
+ labelCol: undefined,
481
+ wrapperCol: undefined
482
+ },
483
+ {
484
+ labelCol: { span: 3 },
485
+ wrapperCol: { span: 21 }
486
+ },
487
+ {
488
+ labelCol: { span: 2 },
489
+ wrapperCol: { span: 22 }
490
+ }],
491
+ // moment
492
+ moment
493
+ }
494
+ },
495
+ props: {
496
+ attr: {
497
+ type: Object,
498
+ default:
499
+ () => {
500
+ return {}
501
+ }
502
+ },
503
+ form: {
504
+ type: Object,
505
+ required:
506
+ true
507
+ },
508
+ disabled: {
509
+ type: Boolean,
510
+ default:
511
+ () => {
512
+ return false
513
+ }
514
+ },
515
+ readOnly: {
516
+ type: Boolean,
517
+ default:
518
+ () => {
519
+ return false
520
+ }
521
+ },
522
+ mode: {
523
+ type: String,
524
+ default:
525
+ () => {
526
+ return '查询'
527
+ }
528
+ },
529
+ files: {
530
+ type: Array,
531
+ default:
532
+ () => {
533
+ return []
534
+ }
535
+ },
536
+ images: {
537
+ type: Array,
538
+ default:
539
+ () => {
540
+ return []
541
+ }
542
+ },
543
+ serviceName: {
544
+ type: String,
545
+ default:
546
+ undefined
547
+ },
548
+ // 调用logic获取数据源的追加参数
549
+ getDataParams: {
550
+ type: Object,
551
+ default:
552
+ undefined
553
+ },
554
+ // 布局
555
+ layout: {
556
+ type: String,
557
+ default:
558
+ 'horizontal'
559
+ },
560
+ // 环境
561
+ env: {
562
+ type: String,
563
+ default:
564
+ () => {
565
+ return 'prod'
566
+ }
567
+ },
568
+ // 设置表单值
569
+ setForm: {
570
+ type: Function,
571
+ default: (val) => {
572
+ console.log(val)
573
+ }
574
+ },
575
+ },
576
+ created () {
577
+ this.init()
578
+ if (this.attr.keyName && (this.attr?.keyName?.toString().indexOf('async ') !== -1 || this.attr?.keyName?.toString()?.indexOf('function') !== -1)) {
579
+ this.debouncedUpdateOptions = debounce(this.updateOptions, 200)
580
+ }
581
+ if (this.attr.dataChangeFunc) {
582
+ this.debouncedDataChangeFunc = debounce(this.dataChangeFunc, 200)
583
+ }
584
+ if (this.attr.showFormItemFunc) {
585
+ this.debouncedShowFormItemFunc = debounce(this.showFormItemFunc, 100)
586
+ // 执行一次
587
+ debounce(this.showFormItemFunc, 100)()
588
+ }
589
+ },
590
+ computed: {
591
+ ...mapState('account', { currUser: 'user' })
592
+ },
593
+ watch: {
594
+ attr: {
595
+ handler () {
596
+ this.init()
597
+ },
598
+ deep: true
599
+ },
600
+ form: {
601
+ handler (newVal) {
602
+ // 如果是从函数获取 options
603
+ if (this.attr.keyName && (this.attr.keyName.toString().indexOf('async ') !== -1 || this.attr.keyName.toString().indexOf('function') !== -1)) {
604
+ this.debouncedUpdateOptions()
605
+ }
606
+ // 如果有自定义函数变更函数
607
+ if (this.attr.dataChangeFunc) {
608
+ this.debouncedDataChangeFunc()
609
+ }
610
+ // 如果有自定义是否展示表单项函数
611
+ if (this.attr.showFormItemFunc) {
612
+ this.debouncedShowFormItemFunc()
613
+ }
614
+ // 地址搜索框赋值
615
+ if (this.attr.type === 'addressSearch') {
616
+ this.$refs.addressSearchCombobox.addressInput = this.form[this.attr.model]
617
+ }
618
+ },
619
+ deep: true
620
+ }
621
+ },
622
+ methods: {
623
+ async updateOptions () {
624
+ if (this.attr.keyName && (this.attr.keyName.indexOf('async ') !== -1 || this.attr.keyName.indexOf('function ') !== -1)) {
625
+ this.optionForFunc = await executeStrFunction(this.attr.keyName, [this.form, runLogic])
626
+ }
627
+ },
628
+ async dataChangeFunc () {
629
+ if (this.attr.dataChangeFunc) {
630
+ await executeStrFunction(this.attr.dataChangeFunc, [this.form, this.setForm, this.attr, util])
631
+ }
632
+ },
633
+ async showFormItemFunc () {
634
+ if (this.attr.showFormItemFunc) {
635
+ this.show = executeStrFunction(this.attr.showFormItemFunc, [this.form, this.setForm, this.attr, util])
636
+ } else {
637
+ this.show = true
638
+ }
639
+ },
640
+ init () {
641
+ if (this.mode === '新增/修改' && !this.attr.flex) {
642
+ if (['horizontal', 'vertical'].includes(this.layout)) {
643
+ // 新增修改表单 horizontal 模式下默认为一行
644
+ this.attr.flex = {
645
+ xs: 24,
646
+ sm: 24,
647
+ md: 24,
648
+ lg: 24,
649
+ xl: 24,
650
+ xxl: 24
651
+ }
652
+ } else {
653
+ if (['input', 'addressSearch'] && this.attr.occupyCol) {
654
+ // 如果是 input 看是否配置了 占用列配置
655
+ this.attr.flex = {
656
+ xs: 8 * this.attr.occupyCol,
657
+ sm: 8 * this.attr.occupyCol,
658
+ md: 8 * this.attr.occupyCol,
659
+ lg: 8 * this.attr.occupyCol,
660
+ xl: 8 * this.attr.occupyCol,
661
+ xxl: 8 * this.attr.occupyCol
662
+ }
663
+ } else {
664
+ // 新增修改表单 vertical 模式下默认为1列
665
+ this.attr.flex = {
666
+ xs: 24,
667
+ sm: 24,
668
+ md: 24,
669
+ lg: 12,
670
+ xl: 8,
671
+ xxl: 8
672
+ }
673
+ }
674
+ }
675
+ }
676
+ if (this.attr.keyName && this.attr.keyName.indexOf('logic@') !== -1) {
677
+ this.getData({}, res => this.getDataCallback(res))
678
+ }
679
+ if (this.attr.keyName && this.attr.keyName.indexOf('search@') !== -1) {
680
+ // `tool.getFullTree(this.getRights().where(row.getType()==$organization$))`
681
+ searchToOption({
682
+ source: this.attr.keyName.substring(7),
683
+ userid: this.currUser.id
684
+ }, res => this.getDataCallback(res))
685
+ } else if (this.attr.keyName && this.attr.keyName.indexOf('config@') !== -1) {
686
+ const configName = this.attr.keyName.substring(7)
687
+ getConfigByName(configName, this.serviceName, res => {
688
+ this.getDataCallback(res.value)
689
+ }, this.env === 'dev')
690
+ } else if (this.attr.keyName && (this.attr.keyName.indexOf('async ') !== -1 || this.attr.keyName.indexOf('function ') !== -1)) {
691
+ this.updateOptions()
692
+ } else {
693
+ this.initRadioValue()
694
+ }
695
+ },
696
+ addressSearchComboboxSelect (data) {
697
+ this.form = Object.assign(this.form, JSON.parse(data))
698
+ },
699
+ onDivisionsChange (data) {
700
+ this.emitFunc('addressSearchComboboxSelect', {
701
+ key: this.attr.model,
702
+ value: data
703
+ })
704
+ },
705
+ getDataCallback (res) {
706
+ this.option = res
707
+ if (this.attr.type === 'treeSelect') {
708
+ this.$refs.xTreeSelect.init({
709
+ option: this.option,
710
+ form: this.form,
711
+ queryType: this.attr.queryType,
712
+ name: this.attr.name,
713
+ model: this.attr.model,
714
+ mode: this.mode,
715
+ disabled: this.disabled
716
+ })
717
+ } else if (this.attr.type === 'radio') {
718
+ this.initRadioValue()
719
+ }
720
+ },
721
+ initRadioValue () {
722
+ const model = this.attr.model
723
+ if (this.mode === '新增/修改' && this.attr.type === 'radio' && !this.form[model]) {
724
+ if (this.attr.keys && this.attr.keys.length > 0) {
725
+ this.form[model] = this.attr.keys[0].value
726
+ } else if (this.option && this.option.length > 0) {
727
+ this.form[model] = this.option[0].value
728
+ } else if (this.attr.keyName) {
729
+ const list = this.$appdata.getDictionaryList(this.attr.keyName)
730
+ if (list.length > 0) {
731
+ this.form[model] = list[0].value
732
+ }
733
+ }
734
+ }
735
+ },
736
+ openChangeOne (status) {
737
+ if (status) {
738
+ this.yearShowOne = true
739
+ }
740
+ },
741
+ // 得到年份选择器的值
742
+ panelChangeOne (value) {
743
+ this.yearShowOne = false
744
+ this.form[this.attr.model] = value.format('YYYY')
745
+ },
746
+ // 文件框时设置上传组件的值
747
+ setFiles (fileIds) {
748
+ if (!this.form[this.attr.model]) {
749
+ this.form[this.attr.model] = []
750
+ }
751
+ this.form[this.attr.model] = [...fileIds]
752
+ },
753
+ // 懒加载检索方法
754
+ fetchFunction (value) {
755
+ this.lastFetchId += 1
756
+ const fetchId = this.lastFetchId
757
+ this.option = []
758
+ this.searching = true
759
+ this.getData({
760
+ word: value
761
+ }, res => {
762
+ if (fetchId !== this.lastFetchId) {
763
+ return
764
+ }
765
+ this.option = res
766
+ this.searching = false
767
+ })
768
+ },
769
+ // 获取数据
770
+ getData (value, callbackFun) {
771
+ if (value !== '') {
772
+ const logicName = this.attr.keyName
773
+ const logic = logicName.substring(6)
774
+ // 调用logic前设置参数
775
+ if (this.getDataParams && this.getDataParams[this.attr.model]) {
776
+ Object.assign(value, this.getDataParams[this.attr.model])
777
+ }
778
+ runLogic(logic, Object.assign(value, {
779
+ orgId: this.currUser.orgid,
780
+ userId: this.currUser.id
781
+ }), this.serviceName, this.env === 'dev').then(res => {
782
+ callbackFun(res)
783
+ }).catch(e => {
784
+ callbackFun([])
785
+ console.error('获取数据失败:' + e)
786
+ })
787
+ }
788
+ },
789
+ filterOption (input, option) {
790
+ const child = option.componentOptions.children[0]
791
+ if (child.text) {
792
+ return child.text.toLowerCase().indexOf(input.toLowerCase()) >= 0
793
+ } else if (child.elm.innerText) {
794
+ return child.elm.innerText.toLowerCase().indexOf(input.toLowerCase()) >= 0
795
+ } else {
796
+ return child.child.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
797
+ }
798
+ },
799
+ emitFunc (func, data) {
800
+ this.$emit('x-form-item-emit-func', func, data)
801
+ }
802
+ }
803
+ }
804
+ </script>
805
+
806
+ <style lang="less" scoped>
807
+ </style>