bri-components 1.2.54 → 1.2.56

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.
@@ -0,0 +1,375 @@
1
+ <template>
2
+ <div class="cascaderModal">
3
+ <div @click.stop="clickInput">
4
+ <slot>
5
+ <Input
6
+ v-model="inputStr"
7
+ :placeholder="selfPropsObj._placeholder"
8
+ :disabled="selfPropsObj._disabled"
9
+ :readonly="true"
10
+ :clearable="selfPropsObj._clearable"
11
+ :size="selfPropsObj._size"
12
+ ></Input>
13
+ </slot>
14
+ </div>
15
+
16
+ <dsh-modal
17
+ class="cascaderModal-modal"
18
+ v-model="showModal"
19
+ mode="middle"
20
+ :propsObj="modalPropsObj"
21
+ >
22
+ <div class="wrap">
23
+ <div class="wrap-header">
24
+ <!-- 搜索 -->
25
+ <div class="wrap-header-left">
26
+ <template v-if="filterable">
27
+ <!-- 搜索框 -->
28
+ <Input
29
+ class="search"
30
+ v-model="searchName"
31
+ placeholder="请输入关键字或标识"
32
+ search
33
+ @on-enter="search"
34
+ @on-search="search"
35
+ @on-change="search"
36
+ />
37
+
38
+ <!-- 模式切换 -->
39
+ <template>
40
+ <div
41
+ v-if="canUseModeSwitch"
42
+ class="mode"
43
+ @click="showMode = showMode === 'default' ? 'flat' : 'default'"
44
+ >
45
+ <dsh-icons :list="[{ icon: 'md-swap' }]" />
46
+ <span class="mode-name">
47
+ {{ showMode === "default" ? "按层级" : "按平级" }}
48
+ </span>
49
+ </div>
50
+
51
+ <Tooltip
52
+ v-else
53
+ style="margin-left: 5px; cursor: pointer;"
54
+ :content="modeTip"
55
+ max-width="250"
56
+ transfer
57
+ >
58
+ <Icon
59
+ class="item-header-help"
60
+ type="md-help-circle"
61
+ size="16"
62
+ ></Icon>
63
+ </Tooltip>
64
+ </template>
65
+ </template>
66
+ </div>
67
+
68
+ <!-- 按钮 -->
69
+ <dsh-buttons
70
+ class="wrap-header-right"
71
+ :list="$getOperationList()"
72
+ @click="$dispatchEvent($event)"
73
+ ></dsh-buttons>
74
+ </div>
75
+
76
+ <div class="wrap-content">
77
+ <!-- 左 -->
78
+ <div class="wrap-content-list">
79
+ <template v-if="showTreeData.length">
80
+ <!-- 拍平方式 -->
81
+ <div v-if="useFlatMode">
82
+ <div
83
+ v-for="nodeItem in showFlatData"
84
+ :key="nodeItem[valueKey]"
85
+ :class="{
86
+ 'item': true,
87
+ 'item-active': selectedLastOption && nodeItem[valueKey] === selectedLastOption[valueKey],
88
+ 'item-disabled': nodeItem.disabled
89
+ }"
90
+ @click="clickItem(nodeItem)"
91
+ >
92
+ <span class="item-name">
93
+ {{ nodeItem[nameKey] }}
94
+ </span>
95
+
96
+ <span class="item-icon">
97
+ <dsh-icons :list="[{
98
+ icon: selectedLastOption && nodeItem[valueKey] === selectedLastOption[valueKey]
99
+ ? 'md-checkmark'
100
+ : ''
101
+ }]" />
102
+ </span>
103
+ </div>
104
+ </div>
105
+
106
+ <!-- 层级方式 -->
107
+ <Tree
108
+ v-else
109
+ :data="showTreeData"
110
+ ></Tree>
111
+ </template>
112
+
113
+ <!-- 无数据 -->
114
+ <div
115
+ v-else
116
+ class="wrap-content-list-nodata"
117
+ >
118
+ 暂无可用的数据……
119
+ </div>
120
+ </div>
121
+
122
+ <!-- 右 描述 -->
123
+ <div class="wrap-content-right">
124
+ <div class="wrap-content-right-title">
125
+ {{ selectedName }}说明
126
+ </div>
127
+ <p
128
+ class="wrap-content-right-content"
129
+ v-html="description"
130
+ ></p>
131
+ </div>
132
+ </div>
133
+ </div>
134
+ </dsh-modal>
135
+ </div>
136
+ </template>
137
+
138
+ <script>
139
+ import cascaderPickerMixin from "./cascaderPickerMixin.js";
140
+
141
+ export default {
142
+ name: "cascaderModal",
143
+ mixins: [
144
+ cascaderPickerMixin
145
+ ],
146
+ components: {},
147
+ props: {},
148
+ data () {
149
+ return {
150
+ description: ""
151
+ };
152
+ },
153
+ computed: {
154
+ modalPropsObj () {
155
+ return {
156
+ title: this.selfPropsObj._name
157
+ };
158
+ },
159
+
160
+ initData () {
161
+ const loop = (data = [], newData = []) => {
162
+ return data.reduce((newData, item) => {
163
+ const newItem = {
164
+ ...item,
165
+ value: item[this.valueKey],
166
+ title: item[this.nameKey],
167
+ expand: false,
168
+ description: undefined,
169
+ render: (h, { root, node, data }) => {
170
+ return h("span", {
171
+ class: {
172
+ "ivu-tree-title-selected": JSON.stringify(data.keys) === JSON.stringify(this.selectedValue)
173
+ },
174
+ style: {
175
+ display: "inline-block",
176
+ width: "100%"
177
+ },
178
+ on: {
179
+ click: () => {
180
+ this.clickItem(data);
181
+ }
182
+ }
183
+ }, data.title);
184
+ },
185
+ children: loop(item.children)
186
+ };
187
+
188
+ return [...newData, newItem];
189
+ }, newData);
190
+ };
191
+
192
+ return loop(this.data);
193
+ }
194
+ },
195
+ created () {
196
+ this.init();
197
+ },
198
+ methods: {
199
+ init () {
200
+ this.selectedValue = this.activeValue;
201
+ this.selectedOptions.forEach(item => {
202
+ item.expand = true;
203
+ });
204
+ this.dealDescription();
205
+ },
206
+
207
+ search () {
208
+ this.selectedValue = [];
209
+ this.showMode = "default";
210
+ },
211
+ clickItemCb (node) {
212
+ this.dealDescription();
213
+ },
214
+ dealDescription () {
215
+ if (this.selectedValue.length && this.selectedLastOption.description == undefined) {
216
+ this.getDescription(this.selectedValue);
217
+ }
218
+ },
219
+ getDescription (nodeKeys) {
220
+ this.$https({
221
+ url: {
222
+ module: "sheet",
223
+ name: "getResourceDescription"
224
+ },
225
+ params: {
226
+ resourceKey: this.resourceKey,
227
+ nodeKeys
228
+ },
229
+ callback: data => {
230
+ this.description = data;
231
+ this.selectedLastOption.description = data;
232
+ }
233
+ });
234
+ }
235
+ }
236
+ };
237
+ </script>
238
+
239
+ <style lang="less">
240
+ .cascaderModal {
241
+ &-modal {
242
+ .wrap {
243
+ width: 100%;
244
+ height: 100%;
245
+ padding: 10px 24px;
246
+ display: flex;
247
+ flex-direction: column;
248
+
249
+ &-header {
250
+ width: 100%;
251
+ padding: 0px;
252
+ // border-bottom: 1px solid @borderColor;
253
+ display: flex;
254
+ justify-content: space-between;
255
+ align-items: center;
256
+
257
+ &-left {
258
+ width: 370px;
259
+ display: flex;
260
+ align-items: center;
261
+
262
+ .search {
263
+ width: 280px;
264
+ }
265
+
266
+ .mode {
267
+ width: 90px;
268
+ padding-top: 14px;
269
+ padding-left: 5px;
270
+ display: flex;
271
+ align-items: center;
272
+ cursor: pointer;
273
+
274
+ &-name {
275
+ font-size: 12px;
276
+ }
277
+ }
278
+ }
279
+
280
+ &-right {
281
+ padding-left: 10px;
282
+ display: flex;
283
+ justify-content: flex-end;
284
+ }
285
+ }
286
+
287
+ &-content {
288
+ flex: 1;
289
+ min-height: 0px;
290
+ margin: 10px 0px 24px;
291
+ border: 1px solid #E5E5E5;
292
+ display: flex;
293
+
294
+ &-list {
295
+ flex: 1;
296
+ min-width: 0px;
297
+ padding: 5px 10px;
298
+ border-right: 1px solid #E5E5E5;
299
+ overflow: auto;
300
+
301
+ .item {
302
+ padding: 8px 10px;
303
+ border-radius: @borderRadius;
304
+ line-height: 16px;
305
+ cursor: pointer;
306
+ display: flex;
307
+ flex-direction: row;
308
+ justify-content: space-between;
309
+ align-items: center;
310
+
311
+ &-name {
312
+ flex: 1;
313
+ min-width: 0px;
314
+ white-space: normal;
315
+ }
316
+
317
+ &-icon {
318
+ width: 40px;
319
+ padding-left: 10px;
320
+ text-align: right;
321
+ }
322
+
323
+ &:hover,
324
+ &-active {
325
+ background-color: @theme-focus;
326
+ color: @themeColor;
327
+ }
328
+
329
+ &-disabled {
330
+ background-color: @inputBg-disabled;
331
+ color: @textColor-disabled;
332
+
333
+ &:hover {
334
+ background-color: @inputBg-disabled;
335
+ color: @textColor-disabled;
336
+ }
337
+ }
338
+ }
339
+
340
+ &-nodata {
341
+ #dsh-nodata();
342
+ }
343
+ }
344
+
345
+ &-right {
346
+ flex: 1;
347
+ min-width: 0px;
348
+
349
+ &-title {
350
+ padding: 6px 16px;
351
+ border-bottom: 1px solid #E5E5E5;
352
+ font-weight: 700;
353
+ }
354
+
355
+ &-content {
356
+ height: calc(100% - 32px);
357
+ padding: 16px;
358
+ white-space: pre-line;
359
+ overflow: auto;
360
+ }
361
+ }
362
+
363
+ .ivu-tree-title-selected {
364
+ background-color: #eee;
365
+ color: #3D84EE;
366
+ }
367
+
368
+ .ivu-tree-empty {
369
+ text-align: center;
370
+ }
371
+ }
372
+ }
373
+ }
374
+ }
375
+ </style>