gcs-ui-lib 1.0.1

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 (231) hide show
  1. package/.env.development +5 -0
  2. package/.env.production +7 -0
  3. package/.eslintrc.js +5 -0
  4. package/README.md +97 -0
  5. package/_webpack.config.js +135 -0
  6. package/babel.config.js +16 -0
  7. package/lib/demo.html +10 -0
  8. package/lib/fonts/SIMSUN.5e0c362c.5e0c362c.ttf +0 -0
  9. package/lib/fonts/element-icons.535877f5.535877f5.woff +0 -0
  10. package/lib/fonts/element-icons.732389de.732389de.ttf +0 -0
  11. package/lib/fonts/iconfont.09d221ee.09d221ee.woff +0 -0
  12. package/lib/fonts/iconfont.1c4bfacc.1c4bfacc.ttf +0 -0
  13. package/lib/fonts/iconfont.a6f34dc7.a6f34dc7.woff2 +0 -0
  14. package/lib/fonts/iconfont.f4c32765.f4c32765.ttf +0 -0
  15. package/lib/gcs-ui-lib.common.js +106776 -0
  16. package/lib/gcs-ui-lib.css +3 -0
  17. package/lib/gcs-ui-lib.umd.js +106786 -0
  18. package/lib/gcs-ui-lib.umd.min.js +330 -0
  19. package/lib/img/bankbackground(1).e1f6e40f.jpg +0 -0
  20. package/lib/img/busibackground(2).7e09bf1f.jpg +0 -0
  21. package/lib/img/document.193a282d.svg +8 -0
  22. package/lib/img/folder.8e019792.svg +9 -0
  23. package/lib/img/icon.fc86764f.gif +0 -0
  24. package/npm +1 -0
  25. package/package.json +101 -0
  26. package/packages/AutoFillDetail/index.js +7 -0
  27. package/packages/AutoFillDetail/src/components/fillDetail.vue +188 -0
  28. package/packages/AutoFillDetail/src/demo/index.vue +18 -0
  29. package/packages/AutoFillDetail/src/main.vue +283 -0
  30. package/packages/AutoFillDetection/index.js +7 -0
  31. package/packages/AutoFillDetection/src/components/FillInfo.vue +36 -0
  32. package/packages/AutoFillDetection/src/components/HandEntred.vue +226 -0
  33. package/packages/AutoFillDetection/src/components/RuleHit.vue +105 -0
  34. package/packages/AutoFillDetection/src/components/SelectEntries.vue +192 -0
  35. package/packages/AutoFillDetection/src/components/config.js +359 -0
  36. package/packages/AutoFillDetection/src/demo/index.vue +18 -0
  37. package/packages/AutoFillDetection/src/main.vue +130 -0
  38. package/packages/AutoFillList/index.js +7 -0
  39. package/packages/AutoFillList/src/components/ImportRules.vue +407 -0
  40. package/packages/AutoFillList/src/components/ImportRulesDialog.vue +40 -0
  41. package/packages/AutoFillList/src/components/config.js +616 -0
  42. package/packages/AutoFillList/src/demo/index.vue +28 -0
  43. package/packages/AutoFillList/src/main.vue +559 -0
  44. package/packages/AutoFillRuleHistory/index.js +7 -0
  45. package/packages/AutoFillRuleHistory/src/demo/index.vue +23 -0
  46. package/packages/AutoFillRuleHistory/src/main.vue +422 -0
  47. package/packages/AutoFillService/index.js +7 -0
  48. package/packages/AutoFillService/src/components/BudgetAccountDialogForSetting.vue +588 -0
  49. package/packages/AutoFillService/src/components/BudgetAccountSettingDialog.vue +377 -0
  50. package/packages/AutoFillService/src/components/ConditionGroup.vue +413 -0
  51. package/packages/AutoFillService/src/components/CustomInput.vue +191 -0
  52. package/packages/AutoFillService/src/components/FillComponent.vue +371 -0
  53. package/packages/AutoFillService/src/components/SelectBudgetAccountDialog.vue +161 -0
  54. package/packages/AutoFillService/src/components/SelectDialog.vue +211 -0
  55. package/packages/AutoFillService/src/components/basic.vue +308 -0
  56. package/packages/AutoFillService/src/components/config.js +549 -0
  57. package/packages/AutoFillService/src/components/fillDetail.vue +145 -0
  58. package/packages/AutoFillService/src/components/fillRules.vue +787 -0
  59. package/packages/AutoFillService/src/components/paymentCategory.vue +297 -0
  60. package/packages/AutoFillService/src/components/paymentCategoryT.vue +292 -0
  61. package/packages/AutoFillService/src/customTemplate/FillBigDecimal.vue +50 -0
  62. package/packages/AutoFillService/src/customTemplate/FillDate.vue +54 -0
  63. package/packages/AutoFillService/src/customTemplate/FillInput.vue +33 -0
  64. package/packages/AutoFillService/src/customTemplate/FillMultiSelect.vue +70 -0
  65. package/packages/AutoFillService/src/customTemplate/FillSelect.vue +72 -0
  66. package/packages/AutoFillService/src/demo/index.vue +30 -0
  67. package/packages/AutoFillService/src/main.vue +432 -0
  68. package/packages/Bank/index.js +7 -0
  69. package/packages/Bank/src/demo/index.vue +18 -0
  70. package/packages/Bank/src/main.vue +70 -0
  71. package/packages/BranchBank/index.js +7 -0
  72. package/packages/BranchBank/src/demo/index.vue +18 -0
  73. package/packages/BranchBank/src/main.vue +97 -0
  74. package/packages/ConfigurableForm/index.js +7 -0
  75. package/packages/ConfigurableForm/src/components/config.js +63 -0
  76. package/packages/ConfigurableForm/src/components/detail.vue +158 -0
  77. package/packages/ConfigurableForm/src/demo/index.vue +279 -0
  78. package/packages/ConfigurableForm/src/main.vue +529 -0
  79. package/packages/DynamicForm/index.js +7 -0
  80. package/packages/DynamicForm/src/components/Amount.vue +51 -0
  81. package/packages/DynamicForm/src/components/AmountRange.vue +76 -0
  82. package/packages/DynamicForm/src/components/CheckboxGroup.vue +63 -0
  83. package/packages/DynamicForm/src/components/DMY.vue +126 -0
  84. package/packages/DynamicForm/src/components/Date.vue +51 -0
  85. package/packages/DynamicForm/src/components/DateRange.vue +51 -0
  86. package/packages/DynamicForm/src/components/Dialog.vue +247 -0
  87. package/packages/DynamicForm/src/components/Input.vue +48 -0
  88. package/packages/DynamicForm/src/components/InputNumber.vue +69 -0
  89. package/packages/DynamicForm/src/components/InputNumberRange.vue +47 -0
  90. package/packages/DynamicForm/src/components/LazySelect.vue +311 -0
  91. package/packages/DynamicForm/src/components/RadioGroup.vue +43 -0
  92. package/packages/DynamicForm/src/components/Rate.vue +57 -0
  93. package/packages/DynamicForm/src/components/Select.vue +307 -0
  94. package/packages/DynamicForm/src/components/Switch.vue +32 -0
  95. package/packages/DynamicForm/src/components/Textarea.vue +58 -0
  96. package/packages/DynamicForm/src/components/TimeSelect.vue +61 -0
  97. package/packages/DynamicForm/src/components/unitTreeSelect.vue +141 -0
  98. package/packages/DynamicForm/src/components/urlLinkInput.vue +100 -0
  99. package/packages/DynamicForm/src/demo/index.vue +486 -0
  100. package/packages/DynamicForm/src/fileUpload.js +232 -0
  101. package/packages/DynamicForm/src/formConfig.js +2910 -0
  102. package/packages/DynamicForm/src/helpers.js +18 -0
  103. package/packages/DynamicForm/src/main.vue +1095 -0
  104. package/packages/FileImport/index.js +7 -0
  105. package/packages/FileImport/src/demo/index.vue +29 -0
  106. package/packages/FileImport/src/main.vue +306 -0
  107. package/packages/MultiCurrencyStatistics/index.js +7 -0
  108. package/packages/MultiCurrencyStatistics/src/demo/index.vue +320 -0
  109. package/packages/MultiCurrencyStatistics/src/main.vue +200 -0
  110. package/packages/SelectTicket/index.js +7 -0
  111. package/packages/SelectTicket/src/Tree/index.vue +13 -0
  112. package/packages/SelectTicket/src/demo/index.vue +139 -0
  113. package/packages/SelectTicket/src/header.js +276 -0
  114. package/packages/SelectTicket/src/main.vue +581 -0
  115. package/packages/SelectTicket/src/printDialog/dialogO.vue +116 -0
  116. package/packages/SelectTicket/src/printDialog/index.vue +69 -0
  117. package/packages/SelectTicket/src/ticketDetail/billInformation/README.MD +6 -0
  118. package/packages/SelectTicket/src/ticketDetail/billInformation/mixins/index.js +35 -0
  119. package/packages/SelectTicket/src/ticketDetail/billInformation/obverse.vue +768 -0
  120. package/packages/SelectTicket/src/ticketDetail/billInformation/overview.vue +115 -0
  121. package/packages/SelectTicket/src/ticketDetail/billInformation/printList.vue +127 -0
  122. package/packages/SelectTicket/src/ticketDetail/billInformation/reverse.vue +205 -0
  123. package/packages/SelectTicket/src/ticketDetail/billInformation//351/231/204/345/212/240/344/277/235/350/257/201/344/277/241/346/201/257/345/255/227/346/256/265/345/257/271/347/205/247.md +246 -0
  124. package/packages/SelectTicket/src/ticketDetail/dialog.vue +73 -0
  125. package/packages/SelectTicket/src/ticketDetail/img/bankbackground(1).jpg +0 -0
  126. package/packages/SelectTicket/src/ticketDetail/img/busibackground(2).jpg +0 -0
  127. package/packages/SelectTicket/src/ticketDetail/img/icon.gif +0 -0
  128. package/packages/SelectTicket/src/ticketDetail/img/icon2.png +0 -0
  129. package/packages/SelectTicket/src/ticketDetail/img/noData.png +0 -0
  130. package/packages/SelectTicket/src/ticketDetail/index.vue +188 -0
  131. package/packages/SelectTreeUnit/index.js +7 -0
  132. package/packages/SelectTreeUnit/src/Tree/document.svg +8 -0
  133. package/packages/SelectTreeUnit/src/Tree/folder.svg +9 -0
  134. package/packages/SelectTreeUnit/src/Tree/index.vue +239 -0
  135. package/packages/SelectTreeUnit/src/demo/index.vue +219 -0
  136. package/packages/SelectTreeUnit/src/forEachs.js +16 -0
  137. package/packages/SelectTreeUnit/src/main.vue +1136 -0
  138. package/packages/SelectTreeUnitForm/index.js +7 -0
  139. package/packages/SelectTreeUnitForm/src/Tree/document.svg +8 -0
  140. package/packages/SelectTreeUnitForm/src/Tree/folder.svg +9 -0
  141. package/packages/SelectTreeUnitForm/src/Tree/index.vue +254 -0
  142. package/packages/SelectTreeUnitForm/src/demo/index.vue +230 -0
  143. package/packages/SelectTreeUnitForm/src/forEachs.js +16 -0
  144. package/packages/SelectTreeUnitForm/src/main.vue +1068 -0
  145. package/packages/StreamRefill/index.js +7 -0
  146. package/packages/StreamRefill/src/components/FillBigDecimal.vue +50 -0
  147. package/packages/StreamRefill/src/components/FillDate.vue +56 -0
  148. package/packages/StreamRefill/src/components/FillInput.vue +36 -0
  149. package/packages/StreamRefill/src/components/FillMultiSelect.vue +54 -0
  150. package/packages/StreamRefill/src/components/FillSelect.vue +51 -0
  151. package/packages/StreamRefill/src/demo/index.vue +254 -0
  152. package/packages/StreamRefill/src/main.vue +335 -0
  153. package/packages/Trade/index.js +7 -0
  154. package/packages/Trade/src/components/all/index.vue +913 -0
  155. package/packages/Trade/src/components/dynamicColumnMixin.js +69 -0
  156. package/packages/Trade/src/components/getDCloumn.js +15 -0
  157. package/packages/Trade/src/components/i18n.json +3337 -0
  158. package/packages/Trade/src/components/pendingEvent/index.vue +934 -0
  159. package/packages/Trade/src/components/server-config.js +60 -0
  160. package/packages/Trade/src/components/setUnitName.js +10 -0
  161. package/packages/Trade/src/components/specialHandle.js +171 -0
  162. package/packages/Trade/src/components/topendingTabs.js +21 -0
  163. package/packages/Trade/src/demo/index.vue +43 -0
  164. package/packages/Trade/src/main.vue +86 -0
  165. package/packages/ValidateQuota/index.js +58 -0
  166. package/packages/ValidateQuota/src/demo/index.vue +190 -0
  167. package/packages/ValidateQuota/src/main.vue +71 -0
  168. package/packages/ZipImport/index.js +7 -0
  169. package/packages/ZipImport/src/demo/index.vue +139 -0
  170. package/packages/ZipImport/src/main.vue +330 -0
  171. package/packages/approvel/index.js +8 -0
  172. package/packages/approvel/src/demo/index.vue +28 -0
  173. package/packages/approvel/src/main.vue +26 -0
  174. package/packages/approvel/src/progress.vue +167 -0
  175. package/packages/approvel/src/url.json +29 -0
  176. package/packages/extends/ElSelect.vue +180 -0
  177. package/packages/imgs/list-select.png +0 -0
  178. package/packages/imgs/list-unselect.png +0 -0
  179. package/packages/imgs/list.png +0 -0
  180. package/packages/imgs/tree-select.png +0 -0
  181. package/packages/imgs/tree-unselect.png +0 -0
  182. package/packages/imgs/tree.png +0 -0
  183. package/packages/inputTag/index.js +7 -0
  184. package/packages/inputTag/src/demo/index.vue +355 -0
  185. package/packages/inputTag/src/main.vue +502 -0
  186. package/public/favicon.ico +0 -0
  187. package/public/index.html +19 -0
  188. package/src/App.vue +61 -0
  189. package/src/api/aims.js +8 -0
  190. package/src/api/common.js +254 -0
  191. package/src/api/fileApi.js +33 -0
  192. package/src/api/setting.js +249 -0
  193. package/src/config/appSettings.js +12 -0
  194. package/src/config/favicon.ico +0 -0
  195. package/src/css/autoFill.scss +252 -0
  196. package/src/css/selectTreeUnit.scss +254 -0
  197. package/src/filter/filter.js +1 -0
  198. package/src/filter/index.js +274 -0
  199. package/src/fonts/demo.css +539 -0
  200. package/src/fonts/iconfont.css +21 -0
  201. package/src/fonts/iconfont.js +1 -0
  202. package/src/fonts/iconfont.json +23 -0
  203. package/src/fonts/iconfont.ttf +0 -0
  204. package/src/index.js +161 -0
  205. package/src/locale/format.js +47 -0
  206. package/src/locale/index.js +48 -0
  207. package/src/locale/lang/cn2hk.json +1270 -0
  208. package/src/locale/lang/en.js +73 -0
  209. package/src/locale/lang/es.js +7 -0
  210. package/src/locale/lang/index.js +66 -0
  211. package/src/locale/lang/ja.js +7 -0
  212. package/src/locale/lang/zh.js +74 -0
  213. package/src/locale/lang/zht.js +27 -0
  214. package/src/main.js +49 -0
  215. package/src/preview/page/Aside/index.vue +60 -0
  216. package/src/preview/router.js +107 -0
  217. package/src/utils/auth.js +12 -0
  218. package/src/utils/directive/asciiWidth.js +107 -0
  219. package/src/utils/directive/clickOutside.js +21 -0
  220. package/src/utils/directive/vtitle.js +140 -0
  221. package/src/utils/excel.js +538 -0
  222. package/src/utils/index.js +581 -0
  223. package/src/utils/request.js +157 -0
  224. package/src/utils/requestCache.js +68 -0
  225. package/src/utils/session.js +36 -0
  226. package/src/utils/thems.js +62 -0
  227. package/src/utils/token.js +26 -0
  228. package/src/utils/tools.js +317 -0
  229. package/src/utils/utils.js +513 -0
  230. package/types/favicon.ico +0 -0
  231. package/vue.config.js +49 -0
@@ -0,0 +1,1136 @@
1
+ <template>
2
+ <el-select
3
+ ref="selectTreeUnit"
4
+ placeholder=""
5
+ v-model="valueShow"
6
+ v-loading="loading"
7
+ v-title="valueShow.length > 16 ? valueShow.slice(0, 15) : valueShow"
8
+ class="nstc-unit-select nstc-unit-select-fixed"
9
+ popper-class="nstc-unit-select-popper"
10
+ @visible-change="showOpt"
11
+ @outClick="outClick"
12
+ >
13
+ <div
14
+ v-loading="loading"
15
+ class="nstc-unit-box"
16
+ @click="selecetClick($event)"
17
+ >
18
+ <el-option :label="null" :value="null" style="display: none" />
19
+ <el-option
20
+ v-for="(item, i) in wCdList"
21
+ :key="i"
22
+ :label="item[defineProps.label]"
23
+ :value="item[defineProps.value]"
24
+ style="display: none"
25
+ />
26
+ <div class="nstc-unit-select-row">
27
+ <el-input
28
+ v-model="searchKey"
29
+ :validate-event="false"
30
+ :placeholder="$t('common_a_0004')"
31
+ clearable
32
+ @input="debounce(searchTree, 1000)"
33
+ class="input-w nstc-unit-search"
34
+ ></el-input>
35
+ <!-- <el-button @click="initList()">切换</el-button> -->
36
+ <div class="el-button-group n20-icon-group-button">
37
+ <button
38
+ type="button"
39
+ @click="changeType('tree')"
40
+ v-title="$t('common_a_0009')"
41
+ :class="
42
+ isList ? 'el-button--default is-plain' : 'el-button--primary'
43
+ "
44
+ class="el-button el-button--mini"
45
+ onlyicon=""
46
+ style="width: 31.5px"
47
+ >
48
+ <i class="iconfont icon-goujianshu"></i>
49
+ </button>
50
+ <button
51
+ type="button"
52
+ @click="changeType('list')"
53
+ v-title="$t('common_a_0010')"
54
+ :class="
55
+ isList ? 'el-button--primary' : 'el-button--default is-plain'
56
+ "
57
+ class="el-button el-button--mini"
58
+ onlyicon=""
59
+ style="width: 31.5px"
60
+ >
61
+ <i class="iconfont icon-liebiao"></i>
62
+ </button>
63
+ </div>
64
+ <!-- <div class="nstc-select-icon-box nstc-select-icon-box-fix">
65
+ <div class="nstc-select-icon-box">
66
+ <span
67
+ @click="changeType('tree')"
68
+ v-title="$t('common_a_0009')"
69
+ :class="isList ? 'nstc-select-icon-un' : ''"
70
+ class="nstc-select-icon"
71
+ >
72
+ <i class="iconfont icon-goujianshu"></i>
73
+ </span>
74
+ </div>
75
+ <div class="nstc-select-icon-box">
76
+ <span
77
+ @click="changeType('list')"
78
+ v-title="$t('common_a_0010')"
79
+ :class="isList ? '' : 'nstc-select-icon-un'"
80
+ class="nstc-select-icon"
81
+ >
82
+ <i class="iconfont icon-liebiao"></i>
83
+ </span>
84
+ </div>
85
+ </div> -->
86
+ </div>
87
+ <div class="nstc-unit-content">
88
+ <el-checkbox
89
+ ref="allcheck"
90
+ v-if="showAllCheck && !single"
91
+ v-model="checkD"
92
+ class="m-l-lg nstc-unit-content-heightfix"
93
+ :label="$t('common_a_0003')"
94
+ @change="handleCheckBox"
95
+ />
96
+ <Tree
97
+ ref="tree"
98
+ :data="data"
99
+ :isList="isList"
100
+ :single="single"
101
+ :node-key="nodeKey"
102
+ :showAllCheck="showAllCheck"
103
+ :show-checkbox="showCheckbox"
104
+ :props="defineProps"
105
+ :defaultExpandedKeys="defaultExpandedKeys"
106
+ @check="check"
107
+ @checkedBro="checkedBro"
108
+ @checkedChild="checkedChild"
109
+ @node-click="nodeClick"
110
+ :load="loadNode"
111
+ :lazy="isLazy"
112
+ v-on="$listeners"
113
+ />
114
+ </div>
115
+ <div class="nstc-unit-footer" v-if="!this.single">
116
+ <el-button type="primary" size="mini" @click="confirm">{{
117
+ $t("common_a_0001")
118
+ }}</el-button>
119
+ <el-button class="nstc-unit-cancel" size="mini" @click="cancel">{{
120
+ $t("common_a_0002")
121
+ }}</el-button>
122
+ </div>
123
+ </div>
124
+ </el-select>
125
+ </template>
126
+
127
+ <script>
128
+ import Tree from "./Tree/index.vue";
129
+ import ElSelect from "../../extends/ElSelect.vue";
130
+ import forEachs from "./forEachs";
131
+ // import axios from "axios";
132
+ import request from "@/utils/request";
133
+ import { getToken } from "@/utils/auth";
134
+ import { getCommonConfig } from "@/api/common";
135
+ import treeSelectImg from "./../../imgs/tree-select.png";
136
+ import treeUnSelectImg from "./../../imgs/tree-unselect.png";
137
+ import listSelectImg from "./../../imgs/list-select.png";
138
+ import listUnSelectImg from "./../../imgs/list-unselect.png";
139
+ export default {
140
+ name: "SelectTreeUnit",
141
+ components: { ElSelect, Tree },
142
+ props: {
143
+ url: {
144
+ type: String,
145
+ default: "/nstc-gtcp/1.0/fundTree",
146
+ },
147
+ listUrl: {
148
+ type: String,
149
+ default: "/api/nstc-gtcp/1.0/fundTree/list",
150
+ },
151
+ isUnitDataScope: {
152
+ type: String,
153
+ default: "0",
154
+ },
155
+ defaultSelectAll: {
156
+ type: Boolean,
157
+ default: false,
158
+ },
159
+ single: {
160
+ type: Boolean,
161
+ default: false,
162
+ },
163
+ selectFirst: {
164
+ type: Boolean,
165
+ default: false,
166
+ },
167
+ defaultSelect: {
168
+ type: Array,
169
+ default: () => [],
170
+ },
171
+ seachObj: {
172
+ type: Object,
173
+ default: () => {
174
+ return {};
175
+ },
176
+ },
177
+ moduleNo: {
178
+ type: String,
179
+ default: "bill-group", //bill-group,bill-collect
180
+ },
181
+ relaNo: {
182
+ type: String,
183
+ default: "",
184
+ },
185
+ value: {
186
+ type: [String, Number, Array],
187
+ default: () => [],
188
+ },
189
+ upDateValue: {
190
+ type: Array,
191
+ default: () => [],
192
+ },
193
+ multiple: {
194
+ type: Boolean,
195
+ default: true,
196
+ },
197
+ collapseTags: {
198
+ type: Boolean,
199
+ default: true,
200
+ },
201
+ nodeKey: {
202
+ type: String,
203
+ default: "id",
204
+ },
205
+ showCheckbox: {
206
+ type: Boolean,
207
+ default: true,
208
+ },
209
+ selectSelf: {
210
+ type: Boolean,
211
+ default: false,
212
+ },
213
+ defineProps: {
214
+ type: Object,
215
+ default: () => {
216
+ return {
217
+ label: "unitName",
218
+ value: "unitNo",
219
+ children: "children",
220
+ isLeaf: "isLeaf",
221
+ };
222
+ },
223
+ },
224
+ },
225
+ data() {
226
+ return {
227
+ mounseInTree: false,
228
+ mounseInList: false,
229
+ loading: false,
230
+ isList: false, //是否是平铺
231
+ isLazy: true, //默认开启懒加载
232
+ data: [],
233
+ show: false,
234
+ list: [],
235
+ expandedKeys: [],
236
+ wCdList: [],
237
+ checkD: false,
238
+ queryType: "0", //0,查询顶级单位;1,查询所有;2,查询直属下级(不含本身,包含子孙);3,查询所有下级(不含本身,不含子孙);4,查询兄弟级(不含子孙)5,查询直接父级
239
+ hasQueryAll: false, //是否已请求过全部数据,默认否
240
+ selectData: [],
241
+ selectDataCache: [],
242
+ valueShow: [],
243
+ searchKey: "",
244
+ showAllCheck: true, //是否展示全部单位
245
+ defaultExpandedKeys: [],
246
+ allUnit: [], //所有的单位的平面结构
247
+ page: {
248
+ current: 1,
249
+ size: -1,
250
+ },
251
+ treeSelectImg,
252
+ treeUnSelectImg,
253
+ listSelectImg,
254
+ listUnSelectImg,
255
+ };
256
+ },
257
+ computed: {
258
+ valueC: {
259
+ get() {
260
+ return this.value;
261
+ },
262
+ set(val) {
263
+ this.$emit("input", val);
264
+ this.$emit("dataChange", this.selectData);
265
+ },
266
+ },
267
+ },
268
+ watch: {
269
+ valueShow: {
270
+ handler(value) {
271
+ this.getTextWidth();
272
+ },
273
+ },
274
+ // value: {
275
+ // handler(value) {
276
+ // const dataList = []
277
+ // forEachs(this.data, d => dataList.push(d), this.defineProps.children)
278
+ // if (!this.multiple) {
279
+ // let valueObj = dataList.find(d => d[this.defineProps.value] === value)
280
+ // this.wCdList = valueObj ? [valueObj] : []
281
+ // this.$refs['tree'].setCurrentKey(value)
282
+ // } else {
283
+ // this.wCdList = dataList.filter(d => value.includes(d[this.defineProps.value]))
284
+ // }
285
+ // },
286
+ // immediate: true
287
+ // },
288
+ // data: {
289
+ // handler(value) {
290
+ // const dataList = []
291
+ // forEachs(value, d => dataList.push(d), this.defineProps.children)
292
+ // if (!this.multiple) {
293
+ // let valueObj = dataList.find(d => d[this.defineProps.value] === this.value)
294
+ // this.wCdList = valueObj ? [valueObj] : []
295
+ // } else {
296
+ // this.wCdList = dataList.filter(d => this.value.includes(d[this.defineProps.value]))
297
+ // }
298
+ // }
299
+ // }
300
+ },
301
+ mounted() {
302
+ if (!this.url) {
303
+ this.$message.error("请传入单位树请求地址!");
304
+ return;
305
+ }
306
+ //选自身和设置默认单位 只能存在一个
307
+ if (this.selectSelf) {
308
+ let userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
309
+ let map = {
310
+ unitNo: userInfo.cltNo,
311
+ unitName: userInfo.cltName,
312
+ };
313
+ this.selectData = [map];
314
+ // let checkData = this.defaultSelect.map((d) => {
315
+ // return d.unitNo;
316
+ // });
317
+ this.valueShow = map.unitName;
318
+ } else if (
319
+ this.defaultSelect &&
320
+ Array.isArray(this.defaultSelect) &&
321
+ this.defaultSelect.length > 0
322
+ ) {
323
+ this.selectData = [...this.defaultSelect];
324
+ let checkData = this.defaultSelect.map((d) => {
325
+ return d.unitNo;
326
+ });
327
+ this.valueShow = this.defaultSelect.map((d) => {
328
+ return d.unitName;
329
+ });
330
+ // this.$emit("input", checkData);
331
+ // this.$emit("dataChange", this.selectData);
332
+ }
333
+ new Promise((resolve) => {
334
+ this.getCommonConfig(resolve);
335
+ }).then(() => {
336
+ if (this.isList) {
337
+ console.log(2222);
338
+ if (this.defaultSelectAll) {
339
+ this.getListData("all");
340
+ } else {
341
+ this.getListData();
342
+ }
343
+ } else {
344
+ console.log(3333);
345
+ if (this.defaultSelectAll) {
346
+ //默认选择全部时,不会读取传的默认选项
347
+ console.log("选择全部--树");
348
+ this.checkD = true;
349
+ this.handleCheckBox("init");
350
+ return "end";
351
+ }
352
+ this.init();
353
+ }
354
+ }).catch(e=>{
355
+ console.log(e)
356
+ })
357
+ },
358
+ methods: {
359
+ init(type) {
360
+ new Promise((resolve) => {
361
+ this.getTreeData("1", { resolve });
362
+ }).then(() => {
363
+ // 初始化时,判断是否选择节点
364
+ let temp = [];
365
+ let flatTemp = [];
366
+ this.flatData(this.data, flatTemp);
367
+ // 传递的defaultSelect和upDateValue没有id,需要在加载时,重新对选择数据赋值
368
+ this.selectData.forEach((s, i) => {
369
+ flatTemp.forEach((d) => {
370
+ if (d.unitNo == s.unitNo) {
371
+ temp.push(d);
372
+ this.selectData[i] = d;
373
+ }
374
+ });
375
+ });
376
+ // console.log(temp)
377
+ //去除没有权限的单位
378
+ temp = temp.filter((s) => {
379
+ return !s.disabled;
380
+ });
381
+ if (this.selectFirst && !type) {
382
+ //切换时不需要
383
+ //初始化时没有传默认单位和all时,根据selectFirst 默认选择第一家单位
384
+ if (temp.length < 1) {
385
+ let first = null;
386
+ let flatTemp = [];
387
+ this.flatData(this.data, flatTemp);
388
+ // flatTemp.reverse(); //递归的第一个单位会放到最后去,所以要反排一次 顺序不对 反馈要注释
389
+ for (let i = 0; i < flatTemp.length; i++) {
390
+ if (!flatTemp[i].disabled) {
391
+ //取第一个有权限的单位
392
+ first = flatTemp[i];
393
+ break;
394
+ }
395
+ }
396
+ console.log(this.data, flatTemp);
397
+ if (first) {
398
+ temp.push(first);
399
+ }
400
+ }
401
+ }
402
+ // else{
403
+ // this.$refs.tree.setCheckedNodes(temp);
404
+ // }
405
+ // this.$refs.tree.setCheckedNodes(temp);
406
+ //根据后续测试情况,看是否放进判断条件内 -----
407
+ this.$refs.tree.setCheckedNodes(temp);
408
+ this.selectData = temp;
409
+ if (!type) {
410
+ //模式切换时,不更新值
411
+ this.valueShow = this.selectData.map((s) => s.unitName);
412
+ let data = this.selectData.map((s) => s.unitNo);
413
+ this.$emit("input", data);
414
+ this.$emit("dataChange", this.selectData);
415
+ }
416
+ });
417
+ },
418
+ changeType(type) {
419
+ if (type == "tree" && this.isList) {
420
+ this.data = [];
421
+ this.init(type);
422
+ this.isList = false;
423
+ } else if (type == "list" && !this.isList) {
424
+ this.data = [];
425
+ this.initList(type);
426
+ this.isList = true;
427
+ }
428
+ },
429
+ async getCommonConfig(resolve) {
430
+ let res = await getCommonConfig();
431
+ if (res && res.length > 0) {
432
+ res.forEach((r) => {
433
+ if (r.configGroupName.includes("单位树")) {
434
+ if (r.configs && r.configs.length > 0) {
435
+ r.configs.forEach((c) => {
436
+ if (c.configGroupName.includes("单位树")) {
437
+ if (c.configValue == "1") {
438
+ this.isList = true;
439
+ } else {
440
+ this.isList = false;
441
+ }
442
+ }
443
+ });
444
+ }
445
+ }
446
+ });
447
+ }
448
+ resolve();
449
+ },
450
+ selecetClick(e) {
451
+ this.$refs.tree.showDropMenu = null;
452
+ },
453
+ outClick() {
454
+ // this.cancel()
455
+ },
456
+ getTextWidth() {
457
+ let text = this.valueShow;
458
+ const font = "bold 12pt Avenir, Helvetica, Arial, sans-serif";
459
+ const canvas = document.createElement("canvas");
460
+ const context = canvas.getContext("2d");
461
+ context.font = font;
462
+ const { width } = context.measureText(text);
463
+ // console.log(width);
464
+ let el = this.$refs.selectTreeUnit.$el;
465
+ if (width > 210) {
466
+ el.style.width = "210px";
467
+ // console.log(1111, el.style.width);
468
+ } else {
469
+ el.style.width = width + 40 + "px";
470
+ // console.log(2222, el.style.width);
471
+ }
472
+ },
473
+ /**
474
+ * @queryType 类型 //0,查询顶级单位;1,查询所有;2,查询直属下级(不含本身,不包含子孙);3,查询所有下级(不含本身,包含子孙);4,查询兄弟级(不含子孙)5,查询直接父级
475
+ */
476
+ getTreeData(queryType, dataT) {
477
+ this.loading = true;
478
+ let str =
479
+ "?moduleNo=" +
480
+ this.moduleNo +
481
+ "&isUnitDataScope=" +
482
+ this.isUnitDataScope;
483
+ if (queryType) {
484
+ str += "&queryType=" + queryType;
485
+ }
486
+ if (dataT) {
487
+ if (["2", "3", "4", "6", "7"].includes(queryType)) {
488
+ //节点懒加载展开
489
+ str += "&unitNo=" + dataT.unitNo;
490
+ if (!dataT.unitNo) {
491
+ return "end";
492
+ }
493
+ }
494
+ }
495
+ if (["1"].includes(queryType) && this.searchKey) {
496
+ //搜索是在查询全部的模式下进行
497
+ str += "&unitNameOrNoLike=" + this.searchKey;
498
+ }
499
+ const headers = {
500
+ relaNo: this.relaNo,
501
+ };
502
+ for (let i in this.seachObj) {
503
+ str += `&${i}=${this.seachObj[i]}`;
504
+ }
505
+ request({ url: this.url + str, method: "GET", cache:true, headers }).then((res) => {
506
+ this.loading = false;
507
+ let data = res.fundTreeVoList;
508
+ // if (code == 200) {
509
+ if (data && data.length > 0) {
510
+ data.forEach((d) => {
511
+ d.isLeaf = !Boolean(d.hasChild);
512
+ });
513
+ }
514
+ // console.log(data)
515
+ if (["0", "1"].includes(queryType)) {
516
+ //树赋值
517
+ this.data = data;
518
+ if (queryType == "1") {
519
+ //查询过全部,就关闭懒加载
520
+ this.$refs.tree.$refs.tree.store.lazy = false;
521
+ this.hasQueryAll = true;
522
+ const allUnits = [];
523
+ this.flatData(data || [], allUnits);
524
+ this.allUnit = allUnits.filter((s) => {
525
+ return !s.disabled;
526
+ });
527
+ }
528
+ if (dataT.expandFlag) {
529
+ //筛选时,将展开单位传入
530
+ dataT.resolve(res.firstAuthUnit);
531
+ } else {
532
+ dataT.resolve(data);
533
+ if (res.onlyUnit) {
534
+ //如果只有一家单位的权限时,默认勾选
535
+ this.showAllCheck = false;
536
+ this.data = [res.onlyUnit];
537
+ this.selectData = [res.onlyUnit];
538
+ this.$refs.tree.setCheckedNodes(this.selectData);
539
+ let cdata = this.selectData.map((s) => s.unitNo);
540
+ this.valueShow = this.selectData.map((s) => s.unitName);
541
+ this.$emit("input", cdata);
542
+ this.$emit("dataChange", this.selectData, "onlyOne");
543
+ }
544
+ }
545
+ }
546
+ if (queryType == "2" && dataT) {
547
+ if (dataT.type && dataT.type == "direct") {
548
+ //查询直接下级,并勾选,抛到方法里面去做
549
+ dataT.resolve(data);
550
+ } else {
551
+ //节点懒加载展开,只更新直属子节点
552
+ // console.log(11111, data)
553
+ dataT.resolve(data);
554
+ //更新子节点后根据选择的数据,确定节点选择状态
555
+ // 传递的defaultSelect没有id,需要在加载时,重新对选择数据赋值
556
+ this.selectData.forEach((s, i) => {
557
+ data.forEach((d) => {
558
+ if (s.unitNo == d.unitNo) {
559
+ this.selectData[i] = d;
560
+ }
561
+ });
562
+ });
563
+ this.$nextTick(() => {
564
+ if (this.selectData.length > 0) {
565
+ //去除没有权限的单位
566
+ this.selectData = this.selectData.filter((s) => {
567
+ return !s.disabled;
568
+ });
569
+ this.$refs.tree.setCheckedNodes(this.selectData);
570
+ }
571
+ });
572
+ return;
573
+ }
574
+ }
575
+ if (queryType == "4" && dataT) {
576
+ //兄弟节点
577
+ dataT.resolve(data);
578
+ return;
579
+ }
580
+ if (queryType == "3" && dataT) {
581
+ //所有下级节点
582
+ dataT.resolve(data);
583
+ return;
584
+ }
585
+ if (queryType == "6" && dataT) {
586
+ //所有下级节点
587
+ dataT.resolve(data);
588
+ return;
589
+ }
590
+ if (queryType == "7" && dataT) {
591
+ //所有下级节点
592
+ dataT.resolve(data);
593
+ return;
594
+ }
595
+ });
596
+ },
597
+ debounce(fn, delay) {
598
+ let context = this;
599
+ clearTimeout(context.timer);
600
+ context.timer = setTimeout(() => {
601
+ fn.apply(context);
602
+ }, delay);
603
+ },
604
+ searchTree() {
605
+ if (this.isList) {
606
+ this.selectData = [];
607
+ this.checkD = false;
608
+ this.$refs.tree.setCheckedNodes([]);
609
+ this.getListData("search");
610
+ } else {
611
+ //搜索取消所有选中状态
612
+ this.checkD = false;
613
+ this.selectData = [];
614
+ this.$refs.tree.setCheckedNodes([]);
615
+ new Promise((resolve) => {
616
+ // if (this.searchUnitNo) {
617
+ // //指定单位编号的搜索
618
+ // this.getTreeData("6", {
619
+ // unitNo: this.searchUnitNo,
620
+ // resolve,
621
+ // expandFlag: true,
622
+ // });
623
+ // } else {
624
+ this.getTreeData("1", { resolve, expandFlag: true });
625
+ // }
626
+ }).then((data) => {
627
+ if (data) {
628
+ //默认展开节点
629
+ this.defaultExpandedKeys = [data.id];
630
+ }
631
+ });
632
+ }
633
+ },
634
+ nodeClick(data) {
635
+ this.$refs.tree.showDropMenu = null;
636
+ //单选才会进入
637
+ if (!this.single) {
638
+ return;
639
+ }
640
+ if (!data.disabled) {
641
+ //有权限的单位才返回
642
+ this.selectData = [data];
643
+ this.valueShow = data.unitName;
644
+ this.$emit("input", data.unitNo);
645
+ this.$emit("dataChange", this.selectData);
646
+ this.$refs.selectTreeUnit.blur();
647
+ }
648
+ },
649
+ loadNode(node, resolve) {
650
+ //懒加载,查询子节点
651
+ this.getTreeData("2", { unitNo: node.data.unitNo, resolve: resolve });
652
+ },
653
+ check(data, { checkedKeys }) {
654
+ // console.log(data, checkedKeys);
655
+ // let checkData = [...this.valueC]
656
+ if (checkedKeys.includes(data.id)) {
657
+ // console.log("add");
658
+ // this.valueShow.push(data.unitName)
659
+ this.selectData.push(data);
660
+ let hash = {};
661
+ let temp = [];
662
+ this.selectData.forEach((s) => {
663
+ //去重
664
+ if (!hash[s.unitNo + ""]) {
665
+ hash[s.unitNo + ""] = true;
666
+ temp.push(s);
667
+ }
668
+ });
669
+ this.selectData = temp;
670
+ // checkData.push(data.unitNo)
671
+ } else {
672
+ // console.log("del");
673
+ let temp = this.selectData.filter((s) => s.unitNo != data.unitNo);
674
+ this.selectData = temp;
675
+ // this.valueShow = temp.map(t => t.unitName)
676
+ // checkData = temp.map(t => t.unitNo)
677
+ }
678
+ // console.log(checkData, this.valueShow, checkedKeys, data)
679
+ // this.$emit('input', checkData)
680
+ },
681
+ showOpt(flag) {
682
+ this.$refs.tree.showDropMenu = null;
683
+ console.log(11111111, flag);
684
+ if (flag) {
685
+ //打开时暂存选择的节点
686
+ this.selectDataCache = JSON.parse(JSON.stringify(this.selectData));
687
+ } else {
688
+ //关闭时清空暂存
689
+ this.selectDataCache = [];
690
+ }
691
+ // debugger
692
+ // if (this.show) return
693
+ // this.show = true
694
+ // this.$refs['tree'].setCheckedKeys(this.value)
695
+ },
696
+ handleCheckBox(key) {
697
+ // debugger
698
+ if (key) {
699
+ if(this.isList){
700
+ let temp = [];
701
+ this.flatData(this.data, temp);
702
+ //去除没有权限的单位
703
+ temp = temp.filter((s) => {
704
+ return !s.disabled;
705
+ });
706
+ this.$refs.tree.setCheckedNodes(temp);
707
+ // const data = this.$refs.tree.getCheckedKeys()
708
+ this.selectData = temp;
709
+ return
710
+ }
711
+ //全选时,需要先查全部数据
712
+ if (!this.hasQueryAll) {
713
+ new Promise((resolve) => {
714
+ this.getTreeData("1", { resolve });
715
+ }).then(() => {
716
+ this.$nextTick(() => {
717
+ // console.log(this.data);
718
+ let temp = [];
719
+ this.flatData(this.data, temp);
720
+ setTimeout(() => {
721
+ //默认全选时,选中数据
722
+ // console.log(temp, this.$refs.tree);
723
+ //去除没有权限的单位
724
+ temp = temp.filter((s) => {
725
+ return !s.disabled;
726
+ });
727
+ this.$refs.tree.setCheckedNodes(temp);
728
+ });
729
+ // const data = this.$refs.tree.getCheckedKeys()
730
+ this.selectData = temp;
731
+ if (key == "init") {
732
+ //去除没有权限的单位
733
+ this.selectData = this.selectData.filter((s) => {
734
+ return !s.disabled;
735
+ });
736
+ let data = this.selectData.map((s) => s.unitNo);
737
+ this.$emit("input", data);
738
+ this.$emit("dataChange", this.selectData);
739
+ }
740
+ if (this.showAllCheck) {
741
+ this.valueShow = this.$t("common_a_0003");
742
+ }
743
+ // let s = temp.map((t) => {
744
+ // return t.unitNo;
745
+ // });
746
+ // this.valueShow = temp.map(t => {
747
+ // return t.unitName
748
+ // })
749
+ // console.log(22222222222222222, data)
750
+ // this.$emit('input', s)
751
+ });
752
+ });
753
+ } else {
754
+ let temp = [];
755
+ this.flatData(this.data, temp);
756
+ //去除没有权限的单位
757
+ temp = temp.filter((s) => {
758
+ return !s.disabled;
759
+ });
760
+ this.$refs.tree.setCheckedNodes(temp);
761
+ // const data = this.$refs.tree.getCheckedKeys()
762
+ this.selectData = temp;
763
+ // let s = temp.map((t) => {
764
+ // return t.unitNo;
765
+ // });
766
+ // this.valueShow = temp.map(t => {
767
+ // return t.unitName
768
+ // })
769
+ // this.$emit('input', s)
770
+ }
771
+
772
+ // console.log(data)
773
+ } else {
774
+ this.$refs.tree.setCheckedNodes([]);
775
+ this.selectData = [];
776
+ // this.valueShow = []
777
+ // this.$emit('input', [])
778
+ // this.$message.warning(this.$t("common_a_0005"));
779
+ }
780
+ },
781
+ // 选择自身以及下级单位
782
+ checkSelfAndChild(data) {
783
+ const { queryType = "6", unitNo = "" } = data;
784
+ this.selectData = [];
785
+ this.valueShow = "";
786
+ new Promise((resolve) => {
787
+ this.getTreeData(queryType, { unitNo: data.unitNo, resolve });
788
+ }).then((child) => {
789
+ if (!child || child.length < 1) {
790
+ this.checkD = false;
791
+ this.$refs.tree.setCheckedNodes([]);
792
+ this.$emit("input", this.multiple ? [] : undefined);
793
+ this.$emit("dataChange", []);
794
+ return "end";
795
+ }
796
+ // 选择一个单位
797
+ if (queryType == "1") {
798
+ this.checkD = false;
799
+ const units = [];
800
+ this.flatData(child, units);
801
+ this.selectData = units.filter((unit) => unit.unitNo === unitNo);
802
+ const datas = this.selectData.map((s) => s.unitNo);
803
+ this.valueShow = this.selectData.map((s) => s.unitName);
804
+ this.$emit("input", this.multiple ? datas : datas[0]);
805
+ this.$emit("dataChange", this.selectData);
806
+ this.$refs.tree.setCheckedNodes(this.selectData);
807
+ return;
808
+ }
809
+
810
+ let temp1 = [];
811
+ this.flatData(child, temp1);
812
+ this.selectData = this.selectData.concat(temp1);
813
+ let hash = {};
814
+ let temp = [];
815
+ this.selectData.forEach((s) => {
816
+ //去重
817
+ if (!hash[s.unitNo + ""]) {
818
+ hash[s.unitNo + ""] = true;
819
+ temp.push(s);
820
+ }
821
+ });
822
+ this.selectData = temp;
823
+ this.checkD = this.allUnit.length === temp1.length;
824
+ this.valueShow = this.checkD
825
+ ? this.$t("common_a_0003")
826
+ : this.selectData.map((s) => s.unitName);
827
+ //去除没有权限的单位
828
+ this.selectData = this.selectData.filter((s) => {
829
+ return !s.disabled;
830
+ });
831
+ this.$refs.tree.setCheckedNodes(this.selectData);
832
+ const data = this.selectData.map((s) => s.unitNo);
833
+ this.$emit("input", this.multiple ? data : data[0]);
834
+ this.$emit("dataChange", this.selectData);
835
+ });
836
+ },
837
+ checkedBro(data) {
838
+ this.$refs.selectTreeUnit.handleClose(false);
839
+ // console.log(data)
840
+ new Promise((resolve) => {
841
+ this.getTreeData("4", { unitNo: data.unitNo, resolve });
842
+ }).then((bro) => {
843
+ console.log(this.selectData);
844
+ this.selectData = this.selectData.concat(bro);
845
+ let hash = {};
846
+ let temp = [];
847
+ this.selectData.forEach((s) => {
848
+ //去重
849
+ if (!hash[s.unitNo + ""]) {
850
+ hash[s.unitNo + ""] = true;
851
+ temp.push(s);
852
+ }
853
+ });
854
+ this.selectData = temp;
855
+ //去除没有权限的单位
856
+ this.selectData = this.selectData.filter((s) => {
857
+ return !s.disabled;
858
+ });
859
+ this.$refs.tree.setCheckedNodes(this.selectData);
860
+ const data = this.$refs.tree.getCheckedKeys();
861
+ // this.$emit('input', data)
862
+ });
863
+ },
864
+ checkedChild(obj) {
865
+ this.$refs.selectTreeUnit.handleClose(false);
866
+ //所有下级未完成开发todo
867
+ // console.log(obj);
868
+ if (obj.type === "cancel") {
869
+ //取消勾选所有下级
870
+ new Promise((resolve) => {
871
+ this.getTreeData("3", { unitNo: obj.data.unitNo, resolve });
872
+ }).then((child) => {
873
+ if (!child || child.length < 1) {
874
+ return "end";
875
+ }
876
+ // console.log(child)
877
+ let temp1 = [];
878
+ this.flatData(child, temp1);
879
+ let ids = temp1.map((t) => t.id);
880
+ this.selectData = this.selectData.filter((s) => {
881
+ return !ids.includes(s.id);
882
+ });
883
+ // console.log(21212,this.selectData)
884
+ this.$refs.tree.setCheckedNodes(this.selectData);
885
+ // const data = this.$refs.tree.getCheckedKeys()
886
+ // this.$emit('input', data)
887
+ });
888
+ } else if (obj.type === "all") {
889
+ //勾选所有下级单位时,会先请求所有数据,取消懒加载模式,再请求对应的下级单位数据再勾选(包括已经勾选的数据)
890
+ new Promise((resolve) => {
891
+ this.getTreeData("3", { unitNo: obj.data.unitNo, resolve });
892
+ }).then((child) => {
893
+ if (!child || child.length < 1) {
894
+ return "end";
895
+ }
896
+ // console.log(child)
897
+ let temp1 = [];
898
+ this.flatData(child, temp1);
899
+ this.selectData = this.selectData.concat(temp1);
900
+ let hash = {};
901
+ let temp = [];
902
+ this.selectData.forEach((s) => {
903
+ //去重
904
+ if (!hash[s.unitNo + ""]) {
905
+ hash[s.unitNo + ""] = true;
906
+ temp.push(s);
907
+ }
908
+ });
909
+ this.selectData = temp;
910
+ //去除没有权限的单位
911
+ this.selectData = this.selectData.filter((s) => {
912
+ return !s.disabled;
913
+ });
914
+ this.$refs.tree.setCheckedNodes(this.selectData);
915
+ // const data = this.$refs.tree.getCheckedKeys()
916
+ // this.$emit('input', data)
917
+ });
918
+ } else {
919
+ // 勾选直接下级
920
+ new Promise((resolve) => {
921
+ this.getTreeData("2", {
922
+ unitNo: obj.data.unitNo,
923
+ resolve,
924
+ type: "direct",
925
+ });
926
+ }).then((child) => {
927
+ if (!child || child.length < 1) {
928
+ return "end";
929
+ }
930
+ // console.log(child)
931
+ let temp1 = [];
932
+ this.flatData(child, temp1);
933
+ this.selectData = this.selectData.concat(temp1);
934
+ let hash = {};
935
+ let temp = [];
936
+ this.selectData.forEach((s) => {
937
+ //去重
938
+ if (!hash[s.unitNo + ""]) {
939
+ hash[s.unitNo + ""] = true;
940
+ temp.push(s);
941
+ }
942
+ });
943
+ this.selectData = temp;
944
+ //去除没有权限的单位
945
+ this.selectData = this.selectData.filter((s) => {
946
+ return !s.disabled;
947
+ });
948
+ this.$refs.tree.setCheckedNodes(this.selectData);
949
+ // const data = this.$refs.tree.getCheckedKeys()
950
+ // this.$emit('input', data)
951
+ });
952
+ }
953
+ },
954
+ upDateShowValue(flag) {
955
+ let isEqual =
956
+ JSON.stringify(this.selectData) === JSON.stringify(this.upDateValue);
957
+ if (this.upDateValue && Array.isArray(this.upDateValue) && !isEqual) {
958
+ //更新值和选择值不相等时才触发,避免使用的死循环
959
+ this.selectData = [...this.upDateValue];
960
+ let checkData = this.upDateValue.map((d) => {
961
+ return d.unitNo;
962
+ });
963
+ this.valueShow = this.upDateValue.map((d) => {
964
+ return d.unitName;
965
+ });
966
+ this.$emit("input", this.multiple ? checkData : checkData[0]);
967
+ this.$emit("dataChange", this.selectData);
968
+ }
969
+ if (flag) {
970
+ if (this.isList) {
971
+ // 列表模式
972
+ this.$refs.tree.setCheckedNodes([]);
973
+ this.$refs.tree.setCheckedNodes(this.selectData);
974
+ } else {
975
+ //传true时,会刷新整个树的状态,更新选择状态,有权限的单位才会选中
976
+ new Promise((resolve) => {
977
+ this.getTreeData("1", { resolve });
978
+ }).then(() => {
979
+ // 只加载顶级节点时,判断是否选择顶级节点
980
+ let temp = [];
981
+ const datas = [];
982
+ this.flatData(this.data, datas);
983
+ this.selectData.forEach((s, i) => {
984
+ datas.forEach((d) => {
985
+ if (d.unitNo == s.unitNo) {
986
+ temp.push(d);
987
+ this.selectData[i] = d; //传进来的单位没有id,将请求的数据节点,赋值给selectData
988
+ }
989
+ });
990
+ });
991
+ // this.selectData = temp;
992
+ //去除没有权限的单位
993
+ temp = temp.filter((s) => {
994
+ return !s.disabled;
995
+ });
996
+ this.$refs.tree.setCheckedNodes(temp);
997
+ });
998
+ }
999
+ }
1000
+ },
1001
+ initList(type) {
1002
+ this.getListData(type);
1003
+ },
1004
+ getListData(type) {
1005
+ console.log(44444);
1006
+ this.loading = true;
1007
+ this.$refs.tree.store.lazy = false;
1008
+ let params = {
1009
+ current: this.page.current,
1010
+ size: this.page.size,
1011
+ ...this.seachObj,
1012
+ data: {
1013
+ ...this.seachObj,
1014
+ moduleNo: this.moduleNo,
1015
+ isUnitDataScope: this.isUnitDataScope,
1016
+ unitNameOrNoLike: this.searchKey,
1017
+ },
1018
+ };
1019
+ const headers = {
1020
+ relaNo: this.relaNo,
1021
+ };
1022
+ // console.log(5555,{
1023
+ // url: this.listUrl,
1024
+ // method: "POST",
1025
+ // data: params,
1026
+ // headers,
1027
+ // })
1028
+ request({
1029
+ url: this.listUrl,
1030
+ method: "POST",
1031
+ data: params,
1032
+ headers, cache:true,
1033
+ }).then((res) => {
1034
+ console.log(6666);
1035
+ this.loading = false;
1036
+ if (res.records && res.records.length > 0) {
1037
+ res.records.forEach((r) => {
1038
+ r.children = null;
1039
+ });
1040
+ this.data = res.records;
1041
+ } else {
1042
+ this.data = [];
1043
+ }
1044
+ //初始化设置时,传入进来的单位id可能不对,也可能不存在,用请求数据通过unitNo匹配重新设置选中数据
1045
+ this.selectData.forEach((s, i) => {
1046
+ this.data.forEach((d) => {
1047
+ if (d.unitNo == s.unitNo) {
1048
+ this.selectData[i] = d;
1049
+ // console.log(11111,d)
1050
+ }
1051
+ });
1052
+ });
1053
+ //去除没有权限的单位
1054
+ // this.selectData = this.selectData.filter((s) => {
1055
+ // return !s.disabled;
1056
+ // });
1057
+ //选中已选择的单位
1058
+ // console.log("LLLLLLLL", this.selectData);
1059
+ if (this.selectFirst && !type) {
1060
+ //切换时不需要
1061
+ //初始化时没有传默认单位和all时,根据selectFirst 默认选择第一家单位
1062
+ if (this.selectData.length < 1 && this.data.length > 0) {
1063
+ this.selectData = [this.data[0]];
1064
+ this.valueShow = this.selectData.map((s) => s.unitName);
1065
+ }
1066
+ }
1067
+ if (type == "all") {
1068
+ //默认选择全部时,不会读取传的默认选项
1069
+ console.log("选择全部--列表");
1070
+ this.checkD = true;
1071
+ this.selectData = JSON.parse(JSON.stringify(this.data));
1072
+ this.valueShow = this.$t("common_a_0003");
1073
+ }
1074
+
1075
+ let data = this.selectData.map((s) => s.unitNo);
1076
+ const onlyOne = this.selectData.length === 1;
1077
+ this.$emit("input", data);
1078
+ if (type !== "list") {
1079
+ this.$emit(
1080
+ "dataChange",
1081
+ this.selectData,
1082
+ onlyOne ? "onlyOne" : undefined
1083
+ );
1084
+ }
1085
+ this.$nextTick(() => {
1086
+ console.log(11111, this.selectData);
1087
+ this.$refs.tree.setCheckedNodes(this.selectData);
1088
+ });
1089
+ });
1090
+ },
1091
+ confirm() {
1092
+ // console.log("sss", this.selectData);
1093
+ if (this.selectData.length < 1) {
1094
+ this.$message.warning(this.$t("common_a_0005"));
1095
+ return;
1096
+ }
1097
+ this.checkD = this.allUnit.length === this.selectData.length;
1098
+ //去除没有权限的单位
1099
+ this.selectData = this.selectData.filter((s) => {
1100
+ return !s.disabled;
1101
+ });
1102
+ if (this.checkD) {
1103
+ this.valueShow = this.$t("common_a_0003");
1104
+ } else {
1105
+ this.valueShow = this.selectData.map((s) => s.unitName);
1106
+ }
1107
+ let data = this.selectData.map((s) => s.unitNo);
1108
+ this.$emit("input", data);
1109
+ this.$emit("dataChange", this.selectData, "confirm");
1110
+ this.$refs.selectTreeUnit.blur();
1111
+ },
1112
+ cancel() {
1113
+ this.selectData = JSON.parse(JSON.stringify(this.selectDataCache));
1114
+ //去除没有权限的单位
1115
+ this.selectData = this.selectData.filter((s) => {
1116
+ return !s.disabled;
1117
+ });
1118
+ this.$refs.tree.setCheckedNodes(this.selectData);
1119
+ this.$refs.selectTreeUnit.blur();
1120
+ },
1121
+ flatData(arr = [], temp) {
1122
+ arr.forEach((a) => {
1123
+ temp.push(a);
1124
+ if (
1125
+ a &&
1126
+ a.children &&
1127
+ Array.isArray(a.children) &&
1128
+ a.children.length > 0
1129
+ ) {
1130
+ this.flatData(a.children, temp);
1131
+ }
1132
+ });
1133
+ },
1134
+ },
1135
+ };
1136
+ </script>