@leevan/jtui 2.0.33 → 2.0.35

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,508 @@
1
+ <!--
2
+ * @Author: leevan
3
+ * @Date: 2024-04-20 17:23:32
4
+ * @LastEditTime: 2024-05-27 17:18:15
5
+ * @LastEditors: leevan
6
+ * @FilePath: /jtui-pc/packages/Search-Type/index.vue
7
+ -->
8
+ <template>
9
+ <div class="search-tb" @keydown.enter="enterClick">
10
+ <div v-for="(im, index) in viewData" :key="index" class="search-tb-row">
11
+ <div style="display:inline-block">
12
+ <span v-if="index > 0">分组</span><el-checkbox v-if="index > 0" v-model="im.checked"></el-checkbox>
13
+ <el-radio-group style="margin-left:12px" v-if="index > 0" v-model="im.radio" size="mini">
14
+ <el-radio-button label="and">并且</el-radio-button>
15
+ <el-radio-button label="or">或者</el-radio-button>
16
+ </el-radio-group>
17
+
18
+ <span :style="{ marginLeft: index === 0 && viewData.length > 1 ? '189px' : 0 }" @click="getData">查询类型</span>
19
+ <el-select @change="typeChange(arguments, im)" size="mini" popper-class="max-height-popper search-base-slt"
20
+ v-model="im.search_type" placeholder="请选择">
21
+ <el-option v-for="(item, index) in options_type"
22
+ :key="index" :label="item.srname"
23
+ :value="item.rootpath">
24
+ </el-option>
25
+ </el-select>
26
+ </div>
27
+
28
+ <div style="display:inline-block" v-if="im.status == 1 || im.status == 2 || im.status == 8">
29
+ <jt-form-pc size="mini" id="form_s1" :collapseTags="true" :model="im.model" labelWidth="12"
30
+ @casChange="casChange(arguments, im)" :formConfig="im.formConfig">
31
+ </jt-form-pc>
32
+ </div>
33
+
34
+ <div style="display:inline-block;margin-left:10px;" v-if="im.status == 3 || im.status == 6">
35
+ <!-- <jt-form-pc size="mini" id="form_s2" :model="im.model_3"
36
+ labelWidth="12"
37
+ :formConfig="im.formConfig_3">
38
+ </jt-form-pc> -->
39
+ <el-input size="mini" v-model="im.model_3.input" placeholder="请输入"></el-input>
40
+ </div>
41
+
42
+ <div style="display:inline-block" v-if="im.status == 7">
43
+ <jt-form-pc size="mini" id="form_s3" :model="im.model_4" labelWidth="12" :formConfig="im.formConfig_4">
44
+ </jt-form-pc>
45
+ </div>
46
+
47
+ <div style="display:inline-block" v-if="im.status == 5">
48
+ <el-cascader-multi ref="type5Ref" style="margin-left:15px;width:300px" size="mini" collapse-tags
49
+ show-leaf-label :is-two-dimension-value="false" v-model="im.model_5.cascader"
50
+ :data="im.formConfig_5"> </el-cascader-multi>
51
+ </div>
52
+
53
+ <div style="display:inline-block;margin-left:12px;position:relative;"
54
+ v-if="im.status == 3 || im.status == 4 || im.status == 7">
55
+ <el-checkbox-group size="mini" v-model="im.stations">
56
+ <el-checkbox-button v-for="(item, index) in im.checkboxData" :key="index"
57
+ :label="item.value">{{ item.label }}</el-checkbox-button>
58
+ </el-checkbox-group>
59
+ </div>
60
+
61
+ <div style="display:inline-block;margin-left:12px;position:relative;"
62
+ v-if="im.status == 9">
63
+ <tree-select v-model="im.stations" :activeType="im.active_type"
64
+ :baseUrl="listuri"
65
+ :checked="im.checkboxData"/>
66
+ </div>
67
+
68
+ <div class="st-btns" v-show="options_type.length > 1 && options_type[0].value !== 'All'">
69
+ <i class="jtIcon iconjianshao" v-if="index > 0" @click="dec_type(index)"></i>
70
+ <i style="color:#586bd1;margin-left:6px;float: right;" class="jtIcon iconjia1" @click="add_type"></i>
71
+ </div>
72
+ </div>
73
+ </div>
74
+ </template>
75
+
76
+ <script>
77
+ import TreeSelect from './tree-select.vue'
78
+ import ElCascaderMulti from './el-cascader-multi/src/multi-cascader/multi-cascader.vue'
79
+ export default {
80
+ name:'search-type',
81
+ components:{
82
+ TreeSelect,
83
+ ElCascaderMulti
84
+ },
85
+ props: {
86
+ options_type: {
87
+ type: Array,
88
+ default: () => []
89
+ },
90
+ listuri: {
91
+ type: String,
92
+ default: '',
93
+ },
94
+ selected: {
95
+ type: String,
96
+ default: ''
97
+ }
98
+ },
99
+ data() {
100
+ return {
101
+ isInit: true,
102
+ viewData: [
103
+ {
104
+ active_type: null,
105
+ search_type: this.selected,
106
+ status: -1,
107
+ model: {
108
+ cascader: ''
109
+ },
110
+ model_3: {
111
+ input: ''
112
+ },
113
+ m_cas: [],
114
+ checkboxData: [],
115
+ stations: [],
116
+ formConfig: [
117
+ {
118
+ label: "",
119
+ modelKey: "cascader",
120
+ type: "cascader",
121
+ width: 300,
122
+ path: '',
123
+ childPath: '',
124
+ checkStrictly: false,
125
+ params: {},
126
+ placeholder: '',
127
+ multiple: true,
128
+ isEnd: true,
129
+ filterable: false
130
+ }
131
+ ],
132
+ formConfig_3: [
133
+ {
134
+ label: "",
135
+ modelKey: "input",
136
+ type: "input",
137
+ width: 200,
138
+ placeholder: '请输入关键字'
139
+ }
140
+ ],
141
+ model_4: {
142
+ select: ''
143
+ },
144
+ formConfig_4: [
145
+ {
146
+ label: "",
147
+ modelKey: "select",
148
+ type: "select_r",
149
+ width: 260,
150
+ options: [],
151
+ multiple: true,
152
+ collapse: true,
153
+ remoteMethod: () => { }
154
+ }
155
+ ],
156
+ model_5: {
157
+ cascader: []
158
+ },
159
+ formConfig_5: [],
160
+ }
161
+ ],
162
+
163
+ }
164
+ },
165
+ created() {
166
+ this.typeChange([this.selected], this.viewData[0])
167
+ },
168
+ methods: {
169
+ removeDuplicateObj(arr) {
170
+ let obj = {};
171
+ arr = arr.reduce((newArr, next) => {
172
+ obj[next.value] ? "" : (obj[next.value] = true && newArr.push(next));
173
+ return newArr;
174
+ }, []);
175
+ return arr;
176
+ },
177
+ // 监听本页面的回车事件
178
+ enterClick(e) {
179
+ if (e.keyCode === 13) {
180
+ this.$emit('initedData', this.getData());
181
+ }
182
+ },
183
+ add_type() {
184
+ this.viewData.push({
185
+ active_type: null,
186
+ checked: false,
187
+ search_type: '',
188
+ status: -1,
189
+ model: {
190
+ cascader: ''
191
+ },
192
+ model_3: {
193
+ input: ''
194
+ },
195
+ m_cas: [],
196
+ checkboxData: [],
197
+ stations: [],
198
+ radio: 'and',
199
+ formConfig: [
200
+ {
201
+ label: "",
202
+ modelKey: "cascader",
203
+ type: "cascader",
204
+ width: 300,
205
+ path: '',
206
+ childPath: '',
207
+ checkStrictly: false,
208
+ params: {},
209
+ placeholder: '',
210
+ multiple: true,
211
+ isEnd: true,
212
+ filterable: false
213
+ }
214
+ ],
215
+ formConfig_3: [
216
+ {
217
+ label: "",
218
+ modelKey: "input",
219
+ type: "input",
220
+ width: 200,
221
+ placeholder: '请输入关键字'
222
+ }
223
+ ],
224
+ model_4: {
225
+ select: ''
226
+ },
227
+ formConfig_4: [
228
+ {
229
+ label: "",
230
+ modelKey: "select",
231
+ type: "select_r",
232
+ width: 200,
233
+ options: [],
234
+ multiple: true,
235
+ collapse: true,
236
+ remoteMethod: () => { }
237
+ }
238
+ ],
239
+ model_5: {
240
+ cascader: []
241
+ },
242
+ formConfig_5: []
243
+ })
244
+ this.$emit('count', this.viewData.length);
245
+ this.$parentStore.state.main.JtMessage.emit('searchTypeAdd');
246
+ },
247
+ dec_type(index) {
248
+ this.viewData.splice(index, 1);
249
+ this.$emit('count', this.viewData.length);
250
+ this.$parentStore.state.main.JtMessage.emit('searchTypeAdd');
251
+ },
252
+ async typeChange(arg, im) {
253
+ const result = this.options_type.find(item => item.rootpath === arg[0]);
254
+ im.active_type = result;
255
+ im.status = -1;
256
+ im.formConfig[0].path = this.listuri;
257
+ im.formConfig[0].childPath = result.rootpath;
258
+ this.$nextTick(() => {
259
+ im.status = result.invlbz;
260
+ this.$nextTick(async () => {
261
+ if (result.invlbz === '1') {
262
+ im.formConfig[0].multiple = false;
263
+ } else if (result.invlbz === '2' || result.invlbz === '8') {
264
+ im.formConfig[0].multiple = true;
265
+ } else if (result.invlbz === '3') {
266
+ im.checkboxData = result.srfield;
267
+ im.stations = result.selected;
268
+ } else if (result.invlbz === '4') {
269
+ const { data: res } = await this.$axios.post(this.listuri + result.rootpath);
270
+ im.stations = res.filter(item => item.selected == '1').map(i => i.value);
271
+ im.checkboxData = res;
272
+ } else if (result.invlbz === '5') {
273
+ im.formConfig_5 = result.enumlists
274
+ if (Array.isArray(result.selected) && result.selected[0].label == '默认分组') {
275
+ im.model_5.cascader = result.selected[0].value
276
+ } else {
277
+ im.model_5.cascader = result.selected;
278
+ }
279
+ } else if (result.invlbz === '7') {
280
+ im.stations = result.selected;
281
+ im.formConfig_4[0].remoteMethod = (query) => (this.remoteMethod(query, im, result))
282
+ im.checkboxData = result.enumlists;
283
+ }else if(result.invlbz === '9') {
284
+ if(result.selected){
285
+ im.checkboxData = result.selected;
286
+ im.stations = result.selected;
287
+ }
288
+ }
289
+ this.$nextTick(() => {
290
+ if (this.isInit) {
291
+ this.$emit('initedData', this.getData());
292
+ this.isInit = false;
293
+ }
294
+ })
295
+ })
296
+
297
+ })
298
+ },
299
+ casChange(arg, im) {
300
+ const res = arg[0].map(item => item.value)
301
+ im.m_cas = res;
302
+ },
303
+ //获取查询下拉列表
304
+ getData() {
305
+ return this.viewData.map(this.handlerData);
306
+ },
307
+ handlerData(item, index) {
308
+ let pubObj = {
309
+ invlbz: item.status,
310
+ group: item.checked,
311
+ relation: item.radio,
312
+ }
313
+ switch (item.status) {
314
+ case '0': {
315
+ return Object.assign(pubObj, {
316
+ srfield: item.active_type.srfield,
317
+ invalue: item.active_type.srfield,
318
+ })
319
+ }
320
+ case '1': {
321
+ if (item.model.cascader.length === 0) {
322
+ return false
323
+ }
324
+ return Object.assign(pubObj, {
325
+ srfield: item.active_type.srfield,
326
+ invalue: item.model.cascader[0]
327
+ })
328
+ }
329
+ case '2': {
330
+ if (item.m_cas.length === 0) {
331
+ return false
332
+ }
333
+ let casParam;
334
+ if (item.active_type.invltp === '1') {
335
+ casParam = item.m_cas.map(items => `'${items}'`).join(',')
336
+ } else if (item.active_type.invltp === '2') {
337
+ casParam = item.m_cas.join(',');
338
+ }
339
+ return Object.assign(pubObj, {
340
+ srfield: item.active_type.srfield,
341
+ invalue: casParam
342
+ })
343
+ }
344
+ case '3': {
345
+ if (item.stations.length === 0 || item.model_3.input === '') {
346
+ return false
347
+ }
348
+ return Object.assign(pubObj, {
349
+ srfield: item.stations,
350
+ invalue: item.model_3.input
351
+ })
352
+ }
353
+ case '4': {
354
+ if (item.stations.length === 0) {
355
+ return false
356
+ }
357
+ return Object.assign(pubObj, {
358
+ srfield: item.active_type.srfield,
359
+ invalue: item.stations.join(',')
360
+ })
361
+ }
362
+ case '5': {
363
+ if (item.model_5.cascader.length === 0) {
364
+ return false
365
+ }
366
+ return Object.assign(pubObj, {
367
+ srfield: item.active_type.srfield,
368
+ invalue: item.model_5.cascader.join(',')
369
+ })
370
+ }
371
+ case '6': {
372
+ if (item.model_3.input === '') {
373
+ return false
374
+ }
375
+ return Object.assign(pubObj, {
376
+ srfield: item.active_type.srfield,
377
+ invalue: item.model_3.input
378
+ })
379
+ }
380
+ case '7': {
381
+ if (item.stations.length === 0 || item.model_4.select.length === 0) {
382
+ return false
383
+ }
384
+ let casParam;
385
+ if (item.active_type.invltp === '1') {
386
+ casParam = item.model_4.select.map(items => `'${items}'`).join(',')
387
+ } else if (item.active_type.invltp === '2') {
388
+ casParam = item.model_4.select.join(',');
389
+ }
390
+ return Object.assign(pubObj, {
391
+ srfield: item.active_type.srfield,
392
+ invalue: casParam
393
+ })
394
+ }
395
+ case '8': {
396
+ if (item.m_cas.length === 0) {
397
+ return false
398
+ }
399
+ let casParam;
400
+ if (item.active_type.invltp === '1') {
401
+ casParam = item.m_cas.map(items => `'${items}'`).join(',')
402
+ } else if (item.active_type.invltp === '2') {
403
+ casParam = item.m_cas.join(',');
404
+ }
405
+ return Object.assign(pubObj, {
406
+ srfield: item.active_type.srfield.replace(/invalue/, casParam),
407
+ invalue: casParam,
408
+ })
409
+ }
410
+ case '9': {
411
+ if(item.stations.length === 0){
412
+ return false
413
+ }
414
+ let casParam;
415
+ if (item.active_type.invltp === '1') {
416
+ casParam = item.stations.map(items => `'${items.id}'`).join(',')
417
+ } else if (item.active_type.invltp === '2') {
418
+ casParam = item.stations.join(',');
419
+ }
420
+ console.log(casParam)
421
+ return Object.assign(pubObj, {
422
+ srfield: item.active_type.srfield,
423
+ invalue: casParam
424
+ })
425
+ }
426
+ case -1: {
427
+ return false;
428
+ }
429
+ }
430
+ },
431
+ async remoteMethod(data, im, result) {
432
+ if (data == '') { im.formConfig_4[0].options = []; return; }
433
+ const { data: res1 } = await this.$axios.post(this.listuri + result.rootpath, {
434
+ searchs: im.stations,
435
+ invalue: data
436
+ });
437
+ im.formConfig_4[0].options = res1;
438
+ }
439
+ }
440
+ }
441
+ </script>
442
+
443
+ <style lang="scss" scoped>
444
+ span {
445
+ padding: 0 12px;
446
+ color:#666666;
447
+ font-size:14px;
448
+ }
449
+
450
+ .st-btns {
451
+ margin-left: auto;
452
+ margin-right: 10px;
453
+ width: 46px;
454
+ position: relative;
455
+
456
+ i {
457
+ font-size: 20px;
458
+ }
459
+ }
460
+
461
+ .search-tb-row {
462
+ height: 35px;
463
+ overflow: hidden;
464
+ display: flex;
465
+ align-items: center;
466
+ }
467
+
468
+ .search-tb-row ::v-deep .el-form-item {
469
+ margin: 0 !important;
470
+ }
471
+ </style>
472
+
473
+ <style>
474
+ .search-tb .el-cascader__tags,
475
+ .search-tb .el-select__tags {
476
+ flex-wrap: nowrap;
477
+ }
478
+
479
+ .search-tb .el-cascader__tags .el-tag,
480
+ .search-tb .el-select__tags .el-tag {
481
+ max-width: 75%;
482
+ }
483
+
484
+ .search-tb .el-tag:nth-child(1) .el-select__tags-text {
485
+ display: inline-block;
486
+ width: 120px;
487
+ overflow: hidden;
488
+ white-space: nowrap;
489
+ text-overflow: ellipsis;
490
+ }
491
+
492
+ .search-tb .el-tag:nth-child(2) {
493
+ position: relative;
494
+ left: 20px;
495
+ }
496
+
497
+ .search-tb .el-select__tags .el-tag .el-icon-close {
498
+ top: -5px;
499
+ }
500
+ .search-base-slt{
501
+ z-index:99999 !important;
502
+ }
503
+ </style>
504
+ <style lang="scss">
505
+ .max-height-popper .el-select-dropdown__wrap {
506
+ max-height: 540px;
507
+ }
508
+ </style>
@@ -0,0 +1,134 @@
1
+ <template>
2
+ <el-popover
3
+ placement="bottom"
4
+ width="400"
5
+ popper-class="tree-select"
6
+ trigger="click">
7
+ <div class="tree-box">
8
+ <el-tree
9
+ ref="treeRef"
10
+ :props="props"
11
+ :load="loadNode"
12
+ node-key="id"
13
+ lazy
14
+ :check-strictly="isStrictly"
15
+ @check="onTreecheck"
16
+ show-checkbox>
17
+ </el-tree>
18
+ </div>
19
+
20
+ <div class="label-input" slot="reference">
21
+ <div class="tag-box">
22
+ <span v-if="value.length == 0" style="color:#b1b1b1">请选择</span>
23
+ <el-tag size="mini" type="info" v-for="(tag,index) in value.slice(0,1)" :key="index">{{ tag.name }}</el-tag>
24
+ <el-tag size="mini" type="info" v-if="value.length > 1">+ {{ value.length - 1 }}</el-tag>
25
+ <span v-if="value.length > 0" class="jtIcon iconguanbi1 guanbi-icon" @click="clearTree"></span>
26
+ </div>
27
+ </div>
28
+ </el-popover>
29
+ </template>
30
+
31
+ <script>
32
+ export default {
33
+ props:['activeType','value','checked','baseUrl'],
34
+ created(){
35
+ console.log(this.activeType.rootpath)
36
+ },
37
+ data(){
38
+ return {
39
+ props: {
40
+ label: 'name',
41
+ children: 'id',
42
+ isLeaf: 'leaf'
43
+ },
44
+ isStrictly: this.activeType.config.isStrictly || false
45
+ }
46
+ },
47
+ methods:{
48
+ async loadNode(node, resolve) {
49
+ console.log(node)
50
+ let childPath
51
+ if(node.level == 0){
52
+ childPath = this.activeType.rootpath
53
+ }else{
54
+ childPath = node.data.path
55
+ }
56
+ const {data} = await this.$axios.post(this.baseUrl + childPath,this.activeType.params);
57
+ for(let i of this.checked){
58
+ for(let c of data){
59
+ if(i.id == c.id){
60
+ setTimeout(() => {
61
+ this.$refs.treeRef.setChecked(i.id,true)
62
+ },100)
63
+ break;
64
+ }
65
+ }
66
+ }
67
+ resolve(data.map(item => {
68
+ item.leaf = item.path === '-' || !item.path
69
+ item.disabled = this.activeType.config.parentDisabled ? false : (item.path === '-' || !item.path ? false : true)
70
+ return item
71
+ }));
72
+ },
73
+ onTreecheck(data,treeInfo){
74
+ if(this.activeType.config.mode == 'radio'){
75
+ this.$refs.treeRef.setCheckedKeys([data.id]);
76
+ this.$emit('input',[data])
77
+ }else{
78
+ const checkNodes = this.$refs.treeRef.getCheckedNodes()
79
+ this.$emit('input',checkNodes)
80
+ }
81
+ },
82
+ clearTree(){
83
+ this.$emit('input',[])
84
+ this.$refs.treeRef.setCheckedKeys([]);
85
+ }
86
+ }
87
+ }
88
+ </script>
89
+
90
+ <style lang="scss" scoped>
91
+ .label-input{
92
+ min-height: 28px;
93
+ width:200px ;
94
+ border: 1px solid #DCDFE6;
95
+ border-radius: 4px;
96
+ background-color: #FFF;
97
+ display: flex;
98
+ align-items: center;
99
+ padding-left:15px;
100
+ position: relative;
101
+ }
102
+ .tag-box{
103
+ .guanbi-icon{
104
+ position: absolute;
105
+ right:10px;
106
+ top:6px;
107
+ color:#d0d0d0;
108
+ cursor: pointer;
109
+ }
110
+ }
111
+ .tree-box{
112
+ max-height:70vh;
113
+ overflow: auto;
114
+ padding:10px;
115
+ &::-webkit-scrollbar {
116
+ width: 10px;
117
+ height: 10px;
118
+ display: none;
119
+ }
120
+ &:hover::-webkit-scrollbar{
121
+ display: block;
122
+ }
123
+ &::-webkit-scrollbar-thumb {
124
+ border-radius: 10px;
125
+ background: #d0d0d0;
126
+ }
127
+ }
128
+ </style>
129
+
130
+ <style lang="scss">
131
+ .tree-select{
132
+ padding:0;
133
+ }
134
+ </style>
package/packages/index.js CHANGED
@@ -4,6 +4,7 @@ import JtFormPc from './jt-form-pc';
4
4
  import JtUploadPc from './jt-upload-pc';
5
5
  import JtEchartsPc from './jt-echarts-pc';
6
6
  import JtOrgtreePc from './jt-orgtree-pc'
7
+ import SearchType from './Search-Type/index.js';
7
8
 
8
9
  //vex-table样式
9
10
  import 'vxe-table/lib/index.css';
@@ -30,7 +31,8 @@ const components = [
30
31
  JtFormPc,
31
32
  JtUploadPc,
32
33
  JtEchartsPc,
33
- JtOrgtreePc
34
+ JtOrgtreePc,
35
+ SearchType
34
36
  ]
35
37
 
36
38
  // 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,那么所有的组件都会被注册
@@ -54,5 +56,6 @@ export default {
54
56
  JtFormPc,
55
57
  JtUploadPc,
56
58
  JtEchartsPc,
57
- JtOrgtreePc
59
+ JtOrgtreePc,
60
+ SearchType
58
61
  }
@@ -1,3 +1,10 @@
1
+ /*
2
+ * @Author: leevan
3
+ * @Date: 2022-01-15 17:02:55
4
+ * @LastEditTime: 2024-04-21 14:31:38
5
+ * @LastEditors: leevan
6
+ * @FilePath: /jtui-pc/packages/jtaxios.js
7
+ */
1
8
  import axios from 'axios';
2
9
  import { Message } from 'element-ui';
3
10
  import { promises } from 'fs';
@@ -20,7 +27,6 @@ newAxios.interceptors.request.use(config=>{
20
27
  newAxios.interceptors.response.use(data=>{
21
28
  return data;
22
29
  },error=>{
23
- Nprogress.done();
24
30
  Message.error({
25
31
  message:'加载失败'
26
32
  })
package/vue.config.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * @Author: leevan
3
3
  * @Date: 2022-01-15 17:02:55
4
- * @LastEditTime: 2023-10-12 16:04:14
4
+ * @LastEditTime: 2024-04-21 13:27:28
5
5
  * @LastEditors: leevan
6
6
  * @FilePath: /jtui-pc/vue.config.js
7
7
  */