cnhis-design-vue 0.3.8-beta → 0.3.9-beta

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,477 @@
1
+ <template>
2
+ <div ref="settingView" class="setting-view">
3
+ <n-spin :show="state.spinning" tip="..." style="width: 100%; height: 100%">
4
+ <div class="fields-set-content">
5
+ <div class="fields-table">
6
+ <div class="setting-title" :class="{ 'seting-title-api': !state.isCustomSearch }">
7
+ <span class="width-show" style="width: 4%"></span>
8
+ <!-- 字段名称 -->
9
+ <span class="width-large">所有字段</span>
10
+ <!-- 显示 -->
11
+ <span class="width-show">
12
+ <n-checkbox
13
+ v-if="showCheckBox('isShow')"
14
+ :checked="calculateCheck('isShow')"
15
+ @update:checked="handleAllCheck($event, 'isShow')"
16
+ />
17
+ 显示
18
+ </span>
19
+ <!-- 排序 -->
20
+ <span class="width-show">
21
+ <n-checkbox
22
+ v-if="showCheckBox('isSort')"
23
+ :checked="calculateCheck('isSort')"
24
+ @update:checked="handleAllCheck($event, 'isSort')"
25
+ />
26
+ 排序
27
+ </span>
28
+ <!-- 固定 -->
29
+ <span class="width-showed">固定</span>
30
+ <slot>
31
+ <!-- 自定义标题 -->
32
+ <span class="width-word">自定义标题</span>
33
+ </slot>
34
+ <!-- 列宽 -->
35
+ <span class="width-showed">列宽</span>
36
+ </div>
37
+ <div ref="setShow" class="set-show" :class="{ 'set-show-api': !state.isCustomSearch }">
38
+ <draggable :list="state.fields" animation="150" item-key="sid" tag="ul">
39
+ <template #item="{ element }">
40
+ <li
41
+ class="left-style"
42
+ :style="leftStyle(element)"
43
+ @click="handleFieldClick(element)"
44
+ >
45
+ <span class="width-show drag-icon-wrap">
46
+ <n-tooltip trigger="hover">
47
+ <template #trigger>
48
+ <span
49
+ class="iconfont icon-a-menzhenyishengzhanxitongtubiaotuozhuai"
50
+ style="color: #000"
51
+ />
52
+ </template>
53
+ <!-- <c-icon type="pause" :rotate="90" /> -->
54
+ <span>拖拽调整顺序</span>
55
+ </n-tooltip>
56
+ </span>
57
+ <!-- 字段名称 -->
58
+ <span class="width-large title-item" :class="{ blue: element.extraField }">
59
+ <span style="width: 14px; margin-right: 6px"></span>
60
+ <span>
61
+ {{ element.title }}
62
+ </span>
63
+ </span>
64
+ <!-- 显示 -->
65
+ <span class="width-show">
66
+ <n-checkbox
67
+ v-show="element.sid != '0001'"
68
+ :default-checked="element.isShow == '1'"
69
+ :checked="element.isShow == '1' ? true : false"
70
+ @update:checked="onChangeShow($event, element)"
71
+ ></n-checkbox>
72
+ </span>
73
+ <!-- 排序 -->
74
+ <span class="width-show">
75
+ <n-checkbox
76
+ v-show="element.sid != '0001'"
77
+ :default-checked="element.isSort == '1'"
78
+ :disabled="element.notParticipatingSort == 1"
79
+ :checked="!!element.isSort"
80
+ @update:checked="onChangeSort($event, element)"
81
+ ></n-checkbox>
82
+ </span>
83
+
84
+ <!-- 固定 -->
85
+ <span class="width-showed">
86
+ <select v-model="element.isFixed" class="is-sort-style">
87
+ <option :value="0">不固定</option>
88
+ <option :value="1">左固定</option>
89
+ <option :value="2">右固定</option>
90
+ </select>
91
+ </span>
92
+ <slot>
93
+ <!-- 自定义标题 -->
94
+ <span class="width-word">
95
+ <input
96
+ v-show="element.sid != '0001'"
97
+ v-model="element.alias"
98
+ class="alias-style"
99
+ />
100
+ </span>
101
+ </slot>
102
+
103
+ <!-- 列宽 -->
104
+ <span class="width-showed">
105
+ <input v-model="element.colWidth" class="alias-style col-width-style" />
106
+ </span>
107
+ </li>
108
+ </template>
109
+ </draggable>
110
+ </div>
111
+ </div>
112
+ <div v-if="props.footerFlag" class="check-options">
113
+ <div class="btn-operate">
114
+ <n-button style="margin-right: 8px" @click="onCancle">取消</n-button>
115
+ <n-button type="primary" @click="handleFieldSave">保存</n-button>
116
+ </div>
117
+ </div>
118
+ </div>
119
+ </n-spin>
120
+ </div>
121
+ </template>
122
+
123
+ <script lang="ts">
124
+ import create from '@/core/create';
125
+ export default create({
126
+ name: "FieldSet"
127
+ })
128
+ </script>
129
+ <script lang="ts" setup>
130
+ import { reactive, onMounted, computed, ref, toRefs } from "vue";
131
+ import { useRoute, useRouter } from "vue-router";
132
+ import draggable from "vuedraggable";
133
+ import { NButton, NCheckbox, NSpin, NTooltip } from "naive-ui";
134
+
135
+ type Ifields = {
136
+ sid: string;
137
+ columnName: string; // 字段名
138
+ isShow: number; // 是否显示
139
+ isSort: number; // 是否能排序
140
+ title: string; // 别名
141
+ alias: string; // 别名
142
+ isFixed: number; // 固定位置
143
+ colWidth: number; // 列宽
144
+ [key: string]: any;
145
+ };
146
+
147
+ type ItableFields = {
148
+ id: string;
149
+ field: string;
150
+ visible: boolean;
151
+ sequence: number;
152
+ sortable: boolean;
153
+ title: string;
154
+ fixed: string;
155
+ minWidth: number;
156
+ }[];
157
+
158
+ type Iprops = {
159
+ fields: any[];
160
+ menuSource: string;
161
+ drawerDirection: string;
162
+ footerFlag: Boolean;
163
+ };
164
+
165
+ type Istate = {
166
+ spinning: boolean;
167
+ isCustomSearch: boolean;
168
+ clickItem: {
169
+ [key: string]: any;
170
+ };
171
+ fields: Ifields[];
172
+ };
173
+ const route = useRoute();
174
+
175
+ const emit = defineEmits(["onSave", "onClose"]);
176
+
177
+ const settingView = ref<HTMLInputElement | null>(null);
178
+
179
+ const props: Iprops = defineProps({
180
+ fields: {
181
+ type: Array,
182
+ default: function () {
183
+ return [];
184
+ },
185
+ },
186
+ menuSource: {
187
+ type: String,
188
+ default: "",
189
+ },
190
+ drawerDirection: {
191
+ type: String,
192
+ default: "right",
193
+ },
194
+ footerFlag: {
195
+ type: Boolean,
196
+ default: true,
197
+ },
198
+ });
199
+
200
+ const state: Istate = reactive({
201
+ spinning: false,
202
+ isCustomSearch: true,
203
+ clickItem: {},
204
+ fields: props.fields,
205
+ });
206
+
207
+ onMounted(() => {
208
+ hideTab();
209
+ });
210
+
211
+ const leftStyle = (ele: Ifields) => {
212
+ return {
213
+ background: state.clickItem.sid === ele.sid ? "#f2f2f2" : undefined,
214
+ };
215
+ };
216
+
217
+ const isMiddleAndAdmin = computed(() => props.menuSource == "middle");
218
+
219
+ const isMenuSource = computed(() => {
220
+ return route.fullPath.includes("middleListDetail");
221
+ });
222
+
223
+ const showCheckBox = (key: string) => {
224
+ return state.fields.some((i: Ifields) => Object.prototype.hasOwnProperty.call(i, key));
225
+ };
226
+
227
+ const hideTab = () => {
228
+ if (isMiddleAndAdmin.value) return;
229
+
230
+ if (props.drawerDirection === "right") {
231
+ // settingView.value?.style.setProperty('margin', '-16px 0px 0');
232
+ settingView.value?.style.setProperty("margin", "auto");
233
+ } else {
234
+ settingView.value?.style.setProperty("margin", "auto");
235
+ }
236
+ };
237
+ const handleFieldSave = () => {
238
+ let tableFields: ItableFields = [];
239
+ // let tableView = {};
240
+ if (state.fields.length > 0) {
241
+ state.fields.forEach((item: Ifields, i: number) => {
242
+ tableFields.push({
243
+ id: item.sid, // 字段id
244
+ field: item.columnName, // 字段名
245
+ visible: item.isShow == 1, // 是否显示
246
+ sequence: i, // 顺序位置
247
+ sortable: item.isSort == 1, // 是否能排序
248
+ title: item.alias || item.title, // 别名
249
+ fixed: item.isFixed ? (item.isFixed == 1 ? "left" : "right") : "", // 固定位置
250
+ minWidth: item.colWidth, // 列宽
251
+ });
252
+ });
253
+ }
254
+ // tableView = Object.assign({ pageSize: this.pageSize }, this.tableView);
255
+ console.log("tableFields", tableFields);
256
+ emit("onSave", { tableFields });
257
+ };
258
+ const onCancle = () => {
259
+ emit("onClose");
260
+ };
261
+ const onChangeShow = (e: boolean, ele: Ifields) => {
262
+ if (e == true) {
263
+ ele.isShow = 1;
264
+ } else {
265
+ ele.isShow = 0;
266
+ }
267
+ };
268
+ const onChangeSort = (e: boolean, ele: Ifields) => {
269
+ if (e == true) {
270
+ ele.isSort = 1;
271
+ } else {
272
+ ele.isSort = 0;
273
+ }
274
+ };
275
+ const onButtonChecked = (e: boolean, itemButton: Ifields) => {
276
+ if (e == true) {
277
+ itemButton.isShow = 1;
278
+ } else {
279
+ itemButton.isShow = 0;
280
+ }
281
+ };
282
+ const calculateCheck = (key: string) => {
283
+ if (!state.fields.length) return false;
284
+ return state.fields.every((i: Ifields) => {
285
+ if (!Object.prototype.hasOwnProperty.call(i, key)) return true;
286
+ return i[key];
287
+ });
288
+ };
289
+ const handleAllCheck = (e: boolean, key: string) => {
290
+ const value = e ? 1 : 0;
291
+ const data = state.fields.map((i: Ifields) => {
292
+ if (Object.prototype.hasOwnProperty.call(i, key)) {
293
+ i[key] = value;
294
+ }
295
+ return i;
296
+ });
297
+ state.fields = data;
298
+ };
299
+ const handleFieldClick = (item: Ifields) => {
300
+ state.clickItem = item;
301
+ };
302
+ </script>
303
+ <style scoped lang="less">
304
+ ul {
305
+ margin: 0;
306
+ padding: 0;
307
+ }
308
+
309
+ .fields-set-content {
310
+ height: 100%;
311
+ display: flex;
312
+ flex-direction: column;
313
+ overflow: hidden;
314
+ .fields-table {
315
+ flex: 1;
316
+ display: flex;
317
+ flex-direction: column;
318
+ overflow: auto;
319
+ }
320
+ }
321
+
322
+ .setting-view {
323
+ height: 100%;
324
+ position: relative;
325
+ :deep(.n-spin-container) {
326
+ width: 100%;
327
+ height: 100%;
328
+ }
329
+ :deep(.n-spin-content) {
330
+ height: 100%;
331
+ }
332
+ .setting-title {
333
+ background: #f2f2f4;
334
+ border: 1px solid #f2f2f2;
335
+ height: 52px;
336
+ line-height: 52px;
337
+ span {
338
+ display: inline-block;
339
+ }
340
+ &.seting-title-api {
341
+ .width-large {
342
+ width: 15%;
343
+ }
344
+ }
345
+ }
346
+ .set-show {
347
+ min-height: 100px;
348
+ overflow-y: auto;
349
+ &.set-show-api {
350
+ .width-large {
351
+ width: 15%;
352
+ }
353
+ }
354
+
355
+ .left-style.sortable-chosen {
356
+ background: #fafafa;
357
+ box-shadow: 0px 0px 10px 0px #d5d5d5;
358
+ }
359
+
360
+ li {
361
+ padding: 5px 0;
362
+ display: flex;
363
+ align-items: center;
364
+ border-bottom: 1px solid #e8e8e8;
365
+ height: 52px;
366
+ line-height: 52px;
367
+ }
368
+ .alias-style {
369
+ outline: none;
370
+ border-radius: 4px 4px 4px 4px;
371
+ border: solid 1px #d5d5d5;
372
+ height: 32px;
373
+ text-indent: 16px;
374
+ color: #38454f;
375
+ width: 100%;
376
+ }
377
+ .is-sort-style {
378
+ outline: none;
379
+ border-radius: 4px 4px 4px 4px;
380
+ border: solid 1px #d5d5d5;
381
+ height: 32px;
382
+ text-indent: 6px;
383
+ color: #38454f;
384
+ width: 87px;
385
+ margin-right: 5px;
386
+ &:disabled {
387
+ cursor: not-allowed;
388
+ background: #f5f5f5;
389
+ }
390
+ }
391
+ .col-width-style {
392
+ width: 70px;
393
+ }
394
+ .title-item {
395
+ display: inline-flex;
396
+ justify-content: flex-start;
397
+ align-items: center;
398
+ text-align: left;
399
+ > span {
400
+ display: inline-block;
401
+ max-width: calc(100% - 20px);
402
+ overflow: hidden;
403
+ white-space: nowrap;
404
+ text-overflow: ellipsis;
405
+ }
406
+ }
407
+ }
408
+ .alias-style {
409
+ outline: none;
410
+ border-radius: 4px 4px 4px 4px;
411
+ border: solid 1px rgba(212, 222, 229, 1);
412
+ height: 32px;
413
+ text-indent: 16px;
414
+ color: #38454f;
415
+ }
416
+ .btn-operate {
417
+ border-top: 1px solid #d5d5d5;
418
+ padding: 12px 0 12px;
419
+ }
420
+
421
+ .width-show {
422
+ display: inline-block;
423
+ width: 10%;
424
+ overflow: hidden;
425
+ white-space: nowrap;
426
+ text-overflow: ellipsis;
427
+ }
428
+ .drag-icon-wrap {
429
+ width: 5% !important;
430
+ cursor: pointer;
431
+ text-align: center;
432
+ }
433
+ .width-showed {
434
+ display: inline-block;
435
+ width: 15%;
436
+ overflow: hidden;
437
+ white-space: nowrap;
438
+ text-overflow: ellipsis;
439
+ select {
440
+ width: 90% !important;
441
+ }
442
+ }
443
+ .width-word {
444
+ display: inline-block;
445
+ width: 20%;
446
+ line-height: 52px;
447
+ overflow: hidden;
448
+ white-space: nowrap;
449
+ input {
450
+ width: 90% !important;
451
+ }
452
+ }
453
+ .width-large {
454
+ display: inline-block;
455
+ width: 20%;
456
+ overflow: hidden;
457
+ white-space: nowrap;
458
+ text-overflow: ellipsis;
459
+ }
460
+ }
461
+ </style>
462
+ <style>
463
+ .popver-content {
464
+ height: 400px;
465
+ overflow: hidden;
466
+ overflow-y: auto;
467
+ }
468
+ .popver-ul {
469
+ margin-bottom: 10px;
470
+ }
471
+ .ul-title {
472
+ font-size: 14px;
473
+ font-weight: 400;
474
+ color: rgba(145, 159, 190, 1);
475
+ line-height: 20px;
476
+ }
477
+ </style>
@@ -3,10 +3,10 @@ body {
3
3
  display: none !important;
4
4
  }
5
5
  }
6
- .big-table {
6
+ .custom-big-table {
7
7
  position: relative;
8
8
 
9
- &:deep(.img-wrap) {
9
+ .img-wrap {
10
10
  padding: 2px 0;
11
11
  line-height: 1;
12
12
  height: 100%;
@@ -54,21 +54,21 @@ body {
54
54
  }
55
55
 
56
56
  /* 行内表单样式 */
57
- &:deep(.base-form) {
57
+ .base-form {
58
58
  overflow: hidden !important;
59
59
  display: flex;
60
60
  align-items: center;
61
61
  width: 100%;
62
62
  }
63
- &:deep(.base-form-content) {
63
+ .base-form-content {
64
64
  width: 100%;
65
65
  }
66
- &:deep(textarea) {
66
+ textarea {
67
67
  height: 32px;
68
68
  margin-bottom: 0;
69
69
  resize: none;
70
70
  }
71
- &:deep(.formItem-select-multiple) {
71
+ .formItem-select-multiple {
72
72
  display: flex;
73
73
  align-items: center;
74
74
  width: 100%;
@@ -82,7 +82,7 @@ body {
82
82
  }
83
83
 
84
84
  &.expand-padding {
85
- &:deep(.vxe-table .vxe-body--expanded-cell) {
85
+ .vxe-table .vxe-body--expanded-cell {
86
86
  padding-left: 66px !important;
87
87
  padding-right: 66px !important;
88
88
  }
@@ -94,7 +94,7 @@ body {
94
94
  .row-btn {
95
95
  margin-right: 10px;
96
96
  }
97
- &:deep(.vxe-table) {
97
+ .vxe-table {
98
98
  transform: translateZ(0);
99
99
  .vxe-table--empty-content {
100
100
  width: 100%;
@@ -155,7 +155,7 @@ body {
155
155
  }
156
156
  }
157
157
  }
158
- &:deep(.filter-box) {
158
+ .filter-box {
159
159
  display: flex;
160
160
  align-items: center;
161
161
  width: 100%;
@@ -175,7 +175,7 @@ body {
175
175
  border-right-color: #5585f5;
176
176
  }
177
177
  }
178
- &:deep(.disabled-checked-tips) {
178
+ .disabled-checked-tips {
179
179
  position: absolute;
180
180
  left: 6px;
181
181
  top: 50%;
@@ -201,81 +201,77 @@ body {
201
201
  top: 0;
202
202
  }
203
203
  }
204
- }
205
-
206
- .refresh {
207
- display: flex;
208
- align-items: center;
209
- background-color: #fff;
210
- box-shadow: 0px 2px 4px 0px rgba(108, 108, 108, 0.13);
211
- color: #5585f5;
212
- font-size: 12px;
213
- height: 27px;
214
-
215
- position: absolute;
216
- right: 0;
217
- top: 6px;
218
- z-index: 1;
219
-
220
- padding-left: 14px;
221
- padding-right: 14px;
222
- border-top-left-radius: 14px;
223
- border-bottom-left-radius: 14px;
224
-
225
- cursor: pointer;
226
- }
227
- .refresh-row {
228
- margin-left: 3px;
229
- margin-bottom: 0;
230
- }
231
-
232
- .check-wrap {
233
- background: #ffffe9;
234
- display: block;
235
- width: 100%;
236
- line-height: 26px;
237
- display: flex;
238
- justify-content: center;
239
-
240
- position: absolute;
241
- margin-top: -26px;
242
-
243
- .check-wrap-title,
244
- .check-wrap-btn {
245
- color: #000000;
246
- font-size: 12px;
247
- margin-bottom: 0px;
248
- cursor: pointer;
204
+ .form-select-table {
205
+ .n-base-select-menu__empty {
206
+ display: none;
207
+ }
249
208
  }
250
-
251
- .check-wrap-btn {
209
+ .percent-wrap {
210
+ display: flex;
211
+ flex-direction: column;
212
+ justify-content: center;
213
+ align-items: center;
214
+ text-align: center;
215
+ .percent-value {
216
+ line-height: 1;
217
+ margin-bottom: -4px;
218
+ margin-top: 4px;
219
+ }
220
+ }
221
+ .refresh {
222
+ display: flex;
223
+ align-items: center;
224
+ background-color: #fff;
225
+ box-shadow: 0px 2px 4px 0px rgba(108, 108, 108, 0.13);
252
226
  color: #5585f5;
227
+ font-size: 12px;
228
+ height: 27px;
229
+
230
+ position: absolute;
231
+ right: 0;
232
+ top: 6px;
233
+ z-index: 1;
234
+
235
+ padding-left: 14px;
236
+ padding-right: 14px;
237
+ border-top-left-radius: 14px;
238
+ border-bottom-left-radius: 14px;
239
+
240
+ cursor: pointer;
253
241
  }
254
- }
255
-
256
- .percent-wrap {
257
- display: flex;
258
- flex-direction: column;
259
- justify-content: center;
260
- align-items: center;
261
- text-align: center;
262
- .percent-value {
263
- line-height: 1;
264
- margin-bottom: -4px;
265
- margin-top: 4px;
242
+ .refresh-row {
243
+ margin-left: 3px;
244
+ margin-bottom: 0;
266
245
  }
267
- }
268
- .domPropsInnerHTML-span {
269
- height: 100%;
270
- &:deep(img) {
271
- display: inline-block;
272
- height: var(--tableImageHeight);
273
- width: var(--tableImageWidth);
246
+ .check-wrap {
247
+ background: #ffffe9;
248
+ display: block;
249
+ width: 100%;
250
+ line-height: 26px;
251
+ display: flex;
252
+ justify-content: center;
253
+
254
+ position: absolute;
255
+ margin-top: -26px;
256
+
257
+ .check-wrap-title,
258
+ .check-wrap-btn {
259
+ color: #000000;
260
+ font-size: 12px;
261
+ margin-bottom: 0px;
262
+ cursor: pointer;
263
+ }
264
+
265
+ .check-wrap-btn {
266
+ color: #5585f5;
267
+ }
274
268
  }
275
- }
276
-
277
- .select-table {
278
- :deep(.n-base-select-menu__empty) {
279
- display: none;
269
+ .domPropsInnerHTML-span {
270
+ height: 100%;
271
+ img {
272
+ display: inline-block;
273
+ height: var(--tableImageHeight);
274
+ width: var(--tableImageWidth);
275
+ }
280
276
  }
281
277
  }
@@ -165,11 +165,3 @@
165
165
  height: 20px;
166
166
  }
167
167
  }
168
-
169
- .big-table {
170
- .form-select-table {
171
- .n-base-select-menu__empty {
172
- display: none;
173
- }
174
- }
175
- }