n20-common-lib 2.5.0-beta.1 → 2.5.0-beta.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n20-common-lib",
3
- "version": "2.5.0-beta.1",
3
+ "version": "2.5.0-beta.3",
4
4
  "private": false,
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,8 +1,16 @@
1
1
  .cl-advanced_filter {
2
+ position: relative;
3
+ display: flex;
4
+ flex: 1;
2
5
  padding: 8px;
3
6
  &_list {
4
- width: 90%;
7
+ .el-form-item,
8
+ .el-form-item--small.el-form-item {
9
+ margin-bottom: 10px;
10
+ }
5
11
  &-item {
12
+ min-width: 200px;
13
+ max-width: 320px;
6
14
  border: 1px solid $--border-color-base;
7
15
  padding: 0 4px;
8
16
  border-radius: 4px;
@@ -12,9 +20,19 @@
12
20
  .el-input__inner:focus {
13
21
  box-shadow: none;
14
22
  }
23
+ :hover {
24
+ .cl-advanced_filter-close {
25
+ display: block;
26
+ }
27
+ }
28
+ }
29
+ :hover {
30
+ border-color: $--color-primary;
15
31
  }
16
32
  }
33
+
17
34
  &-close {
35
+ display: none;
18
36
  position: absolute;
19
37
  top: -10px;
20
38
  right: -10px;
@@ -22,3 +40,8 @@
22
40
  cursor: pointer;
23
41
  }
24
42
  }
43
+
44
+ .popover-check-box {
45
+ max-height: 300px;
46
+ overflow-y: auto;
47
+ }
@@ -47,3 +47,11 @@
47
47
  }
48
48
  }
49
49
  }
50
+
51
+ .el-select.input-w {
52
+ .el-select__tags {
53
+ .el-tag--info {
54
+ max-width: 150px;
55
+ }
56
+ }
57
+ }
@@ -1,29 +1,46 @@
1
1
  <template>
2
- <div>
2
+ <div class="popover-check-box">
3
3
  <el-checkbox-group v-model="checkList" class="flex-column" @change="checkChange">
4
- <el-checkbox v-for="(item, i) in filterList" :key="i" class="m-t-b" :label="item.label" />
4
+ <el-checkbox
5
+ v-for="(item, i) in filterList"
6
+ :key="i"
7
+ class="m-t-b"
8
+ :disabled="checkList.includes(item.label)"
9
+ :label="item.label"
10
+ />
5
11
  </el-checkbox-group>
6
12
  </div>
7
13
  </template>
8
14
 
9
15
  <script>
10
- import { $lc } from '../../utils/i18n/index.js'
11
16
  export default {
12
17
  name: 'FilterItem',
13
18
  props: {
14
19
  filterList: {
15
20
  type: Array,
16
21
  default: () => []
22
+ },
23
+ checkArray: {
24
+ type: Array,
25
+ default: () => []
17
26
  }
18
27
  },
19
28
  data() {
20
29
  return {
21
- checkList: []
30
+ checkList: ''
31
+ }
32
+ },
33
+ watch: {
34
+ checkArray: {
35
+ handler(val) {
36
+ this.checkList = val
37
+ },
38
+ deep: true
22
39
  }
23
40
  },
24
41
  methods: {
25
42
  checkChange(keys) {
26
- this.$emit('check', keys)
43
+ this.$emit('checked', keys)
27
44
  }
28
45
  }
29
46
  }
@@ -1,39 +1,118 @@
1
1
  <template>
2
2
  <el-form inline class="cl-advanced_filter_list">
3
- <el-form-item v-for="(item, i) in data" :key="i" class="cl-advanced_filter_list-item" :label="item.label">
3
+ <el-form-item v-for="(item, i) in dataC" :key="i" class="cl-advanced_filter_list-item" :label="item.label">
4
4
  <slot v-if="item.slotName" :name="item.slotName"></slot>
5
5
  <formItemInput v-else :form="form" :item="item" />
6
- <i class="cl-advanced_filter-close el-icon-error"></i>
6
+ <i class="cl-advanced_filter-close el-icon-error" @click="handleClose(item)"></i>
7
+ </el-form-item>
8
+ <el-form-item>
9
+ <el-button v-popover:advanced_popover onlyicon plain icon="el-icon-plus" />
10
+ <el-popover ref="advanced_popover" placement="bottom-start" trigger="click">
11
+ <el-form>
12
+ <InputSearch
13
+ v-model="search"
14
+ clearable
15
+ class="input-w m-b-s"
16
+ :placeholder="$l('搜索筛选条件')"
17
+ @change="searchFn"
18
+ />
19
+ <filterItem :filter-list="filterListC" :check-array.sync="checkList" @checked="check" />
20
+ </el-form>
21
+ </el-popover>
7
22
  </el-form-item>
8
23
  </el-form>
9
24
  </template>
10
25
 
11
26
  <script>
12
27
  import formItemInput from './form-item-input.vue'
28
+ import InputSearch from '../InputSearch/index.vue'
29
+ import filterItem from './filterItem.vue'
30
+ import mixins from './mixins/index.js'
13
31
  export default {
14
32
  name: 'FilterList',
15
33
  components: {
34
+ filterItem,
35
+ InputSearch,
16
36
  formItemInput
17
37
  },
38
+ mixins: [mixins],
18
39
  props: {
19
40
  data: {
20
41
  type: Array,
21
42
  default: () => []
43
+ },
44
+ form: {
45
+ type: Object,
46
+ default: () => ({})
47
+ },
48
+ width: {
49
+ type: String,
50
+ default: '90%'
51
+ },
52
+ filterList: {
53
+ type: Array,
54
+ default: () => []
55
+ },
56
+ filterId: {
57
+ type: String,
58
+ default: 'filterId'
22
59
  }
23
60
  },
24
61
  data() {
25
62
  return {
26
- form: {}
63
+ search: '',
64
+ dataC: [],
65
+ filterListC: []
27
66
  }
28
67
  },
29
- computed: {
30
- dataC: {
31
- get() {
32
- return this.data
68
+ watch: {
69
+ GroupData: {
70
+ handler(value) {
71
+ this.dataC = value
72
+ },
73
+ immediate: true
74
+ },
75
+ filterList: {
76
+ handler(value) {
77
+ this.filterListC = value
33
78
  },
34
- set(val) {
35
- console.log(val)
79
+ deep: true,
80
+ immediate: true
81
+ }
82
+ },
83
+ mounted() {
84
+ this.getFilterList()
85
+ },
86
+ methods: {
87
+ handleClose(item) {
88
+ let data = this.GroupData.filter((s) => {
89
+ return s.label !== item.label || s.value !== item.value
90
+ })
91
+ this.saveFilter(data).then(({ code }) => {
92
+ if (code === 200) {
93
+ this.getFilterList()
94
+ }
95
+ })
96
+ },
97
+ searchFn() {
98
+ console.log(this.search)
99
+ this.filterListC = this.cloneDeepFList.filter((r) => {
100
+ return r.label.includes(this.search)
101
+ })
102
+ },
103
+ check(keys) {
104
+ this.checkList = keys
105
+ let groupFilter = []
106
+ if (keys.length > 0) {
107
+ keys.forEach((k) => {
108
+ groupFilter.push(this.filterList.find((s) => s.label === k))
109
+ })
36
110
  }
111
+ this.saveFilter(groupFilter).then(({ code }) => {
112
+ if (code === 200) {
113
+ this.getFilterList()
114
+ }
115
+ })
37
116
  }
38
117
  }
39
118
  }
@@ -3,7 +3,6 @@
3
3
  v-if="item.type === 'text' || item.type === undefined"
4
4
  v-model="form[item.value]"
5
5
  :clearable="item | clearableF"
6
- style="width: 100%"
7
6
  v-bind="item.props"
8
7
  :placeholder="item.props && item.props.placeholder ? item.props.placeholder : $lc('请输入')"
9
8
  v-on="item.on"
@@ -12,7 +11,6 @@
12
11
  v-else-if="item.type === 'search'"
13
12
  v-model="form[item.value]"
14
13
  :clearable="item | clearableF"
15
- style="width: 100%"
16
14
  readonly
17
15
  v-bind="item.props"
18
16
  v-on="item.on"
@@ -32,7 +30,6 @@
32
30
  v-model="form[item.value]"
33
31
  :clearable="item | clearableF"
34
32
  :multiple="item.multiple"
35
- style="width: 100%"
36
33
  v-bind="item.props"
37
34
  v-on="item.on"
38
35
  >
@@ -58,7 +55,6 @@
58
55
  <inputNumber
59
56
  v-else-if="item.type === 'number'"
60
57
  v-model="form[item.value]"
61
- style="width: 100%"
62
58
  v-bind="item.props"
63
59
  v-on="item.on"
64
60
  />
@@ -74,7 +70,6 @@
74
70
  v-model="form[item.value]"
75
71
  :type="item.type"
76
72
  :clearable="item | clearableF"
77
- style="width: 100%"
78
73
  v-bind="item.props"
79
74
  v-on="item.on"
80
75
  />
@@ -84,7 +79,6 @@
84
79
  :start-date.sync="form[item.startDate]"
85
80
  :end-date.sync="form[item.endDate]"
86
81
  :clearable="item | clearableF"
87
- style="width: 100%"
88
82
  v-bind="item.props"
89
83
  v-on="item.on"
90
84
  />
@@ -1,45 +1,36 @@
1
1
  <template>
2
- <div class="cl-advanced_filter">
3
- <filterList :data="GroupData" />
4
- <el-popover
5
- ref="popover"
6
- v-model="showPop"
7
- trigger="manual"
8
- :width="widthAs"
9
- :popper-class="popperClass"
10
- placement="bottom-start"
11
- @show="show"
12
- >
13
- <template slot="reference">
14
- <el-button onlyicon plain icon="el-icon-plus" @click="clickBtn" />
2
+ <div :class="prefixCls">
3
+ <filterList v-if="visible" :width="width" :form="model" :filter-id="filterId" :filter-list="filterList">
4
+ <template v-for="(item, i) in GroupData">
5
+ <div v-if="item.slotName" :key="i" :slot="item.slotName">
6
+ <slot :name="item.slotName"></slot>
7
+ </div>
15
8
  </template>
16
- <el-form>
17
- <InputSearch v-model="search" clearable class="input-w" :placeholder="$l('搜索筛选条件')" @change="searchFn" />
18
- <filterItem :filter-list="cloneDeepFList" @check="check" />
19
- </el-form>
20
- </el-popover>
9
+ </filterList>
10
+ <div v-else :width="width"></div>
21
11
  </div>
22
12
  </template>
23
13
 
24
14
  <script>
25
15
  import filterList from './filterList.vue'
26
- import InputSearch from '../InputSearch/index.vue'
27
- import filterItem from './filterItem.vue'
28
- import getWidth from '../../utils/asciiWidth'
29
- import cloneDeep from 'lodash/cloneDeep'
30
- import axios from '../../utils/axios.js'
16
+
17
+ import mixins from './mixins/index.js'
18
+ const prefixCls = 'cl-advanced_filter'
31
19
  export default {
32
20
  name: 'AdvancedFilter',
33
21
  components: {
34
- filterList,
35
- filterItem,
36
- InputSearch
22
+ filterList
37
23
  },
24
+ mixins: [mixins],
38
25
  props: {
39
26
  type: {
40
27
  type: String,
41
28
  default: ''
42
29
  },
30
+ visible: {
31
+ type: Boolean,
32
+ default: false
33
+ },
43
34
  filterList: {
44
35
  type: Array,
45
36
  default: () => []
@@ -52,6 +43,14 @@ export default {
52
43
  type: [String, Number],
53
44
  default: undefined
54
45
  },
46
+ width: {
47
+ type: String,
48
+ default: '90%'
49
+ },
50
+ model: {
51
+ type: Object,
52
+ default: () => ({})
53
+ },
55
54
  filterId: {
56
55
  type: String,
57
56
  default: 'AdvancedFilter'
@@ -60,106 +59,16 @@ export default {
60
59
  data() {
61
60
  return {
62
61
  search: '',
63
- userNo: sessionStorage.getItem('userNo'),
64
62
  showPop: false,
65
63
  showPopC: false,
66
- popover: undefined,
67
- GroupData: [],
68
- cloneDeepFList: [],
64
+ prefixCls: prefixCls,
65
+ // popover: undefined,
69
66
  remoteList: [],
70
- popperClass: ('filters_popper_' + Date.now() + '_' + Math.random() + ' cl-advanced_filter_popover').replace(
71
- '.',
72
- ''
73
- )
67
+ checkList: []
74
68
  }
75
69
  },
76
- computed: {
77
- widthAs() {
78
- if (this.width !== undefined) return this.width
79
-
80
- return this.labelWidthAs + 180
81
- },
82
70
 
83
- labelWidthAs() {
84
- if (this.labelWidth !== undefined) {
85
- return /em$/.test(this.labelWidth) ? parseInt(this.labelWidth) * 14 : parseInt(this.labelWidth)
86
- }
87
-
88
- let maxW = Math.max(4 * 14, ...this.filterList.map((r) => getWidth(r.label)))
89
-
90
- return maxW + 14
91
- }
92
- },
93
- watch: {
94
- filterList: {
95
- handler(val) {
96
- if (val.length > 0) {
97
- this.cloneDeepFList = cloneDeep(val)
98
- }
99
- },
100
- immediate: true
101
- }
102
- },
103
- mounted() {
104
- this.getFilterList()
105
- },
106
71
  methods: {
107
- show() {
108
- this.showPopC = true
109
- },
110
- clickBtn() {
111
- if (!this.showPop) {
112
- setTimeout(() => {
113
- this.showPop = true
114
- }, 60)
115
- }
116
- },
117
- searchFn() {
118
- if (this.search) {
119
- this.cloneDeepFList = cloneDeep(this.filterList).filter((r) => r.label.includes(this.search))
120
- } else {
121
- this.cloneDeepFList = cloneDeep(this.filterList)
122
- }
123
- },
124
- check(keys) {
125
- if (keys.length > 0) {
126
- let groupFilter = []
127
- keys.forEach((k) => {
128
- groupFilter.push(this.filterList.find((s) => s.label === k))
129
- })
130
- this.saveFilter(groupFilter)
131
- this.getFilterList()
132
- }
133
- },
134
- saveFilter(data) {
135
- axios.post(
136
- `/bems/prod_1.0/user/pageHabit?t=${Date.now()}`,
137
- {
138
- userNo: this.userNo,
139
- pageId: this.filterId,
140
- showStructure: JSON.stringify(data)
141
- },
142
- { loading: false, noMsg: true }
143
- )
144
- },
145
- getFilterList() {
146
- axios
147
- .post(
148
- `/bems/prod_1.0/user/pageHabit/list?t=${Date.now()}`,
149
- {
150
- userNo: this.userNo,
151
- pageId: this.filterId
152
- },
153
- { loading: false, noMsg: true }
154
- )
155
- .then(({ data }) => {
156
- if (data) {
157
- let _data = JSON.parse(data)
158
- console.log(_data)
159
- this.GroupData = _data
160
- }
161
- })
162
- },
163
72
  setOptions(key, opts) {
164
73
  let item = this.filterList.find((f) => f.value === key)
165
74
  if (item) {
@@ -0,0 +1,73 @@
1
+ import axios from '../../../utils/axios.js'
2
+ import cloneDeep from 'lodash/cloneDeep'
3
+ export default {
4
+ watch: {
5
+ filterList: {
6
+ handler(val) {
7
+ if (val.length > 0) {
8
+ this.cloneDeepFList = cloneDeep(val)
9
+ }
10
+ },
11
+ immediate: true
12
+ },
13
+ model: {
14
+ handler(val) {
15
+ this.$emit('change', val)
16
+ }
17
+ }
18
+ },
19
+ data() {
20
+ return {
21
+ cloneDeepFList: [],
22
+ GroupData: [],
23
+ checkList: [],
24
+ userNo: sessionStorage.getItem('userNo')
25
+ }
26
+ },
27
+ methods: {
28
+ /**
29
+ * 保存筛选条件
30
+ * @param data
31
+ */
32
+ saveFilter(data) {
33
+ return new Promise((resolve) => {
34
+ axios
35
+ .post(
36
+ `/bems/prod_1.0/user/pageHabit?t=${Date.now()}`,
37
+ {
38
+ userNo: this.userNo,
39
+ pageId: this.filterId,
40
+ showStructure: JSON.stringify(data)
41
+ },
42
+ { loading: false, noMsg: true }
43
+ )
44
+ .then((res) => {
45
+ resolve(res)
46
+ })
47
+ })
48
+ },
49
+ /**
50
+ * 获取筛选条件
51
+ */
52
+ getFilterList() {
53
+ axios
54
+ .post(
55
+ `/bems/prod_1.0/user/pageHabit/list?t=${Date.now()}`,
56
+ {
57
+ userNo: this.userNo,
58
+ pageId: this.filterId
59
+ },
60
+ { loading: false, noMsg: true }
61
+ )
62
+ .then(({ data }) => {
63
+ if (data) {
64
+ let _data = JSON.parse(data)
65
+ this.GroupData = _data
66
+ this.checkList = _data.map((s) => {
67
+ return s.label
68
+ })
69
+ }
70
+ })
71
+ }
72
+ }
73
+ }
package/src/index.js CHANGED
@@ -64,7 +64,7 @@ import WornPagination from './components/WornPagination/index.vue'
64
64
 
65
65
  import Tree from './components/Tree/index.vue'
66
66
  import SelectTreePro from './components/SelectTree/pro.vue'
67
- // import AdvancedFilter from './components/AdvancedFilter/index.vue'
67
+ import AdvancedFilter from './components/AdvancedFilter/index.vue'
68
68
 
69
69
  // 新版日期选择框
70
70
  import BusiDatePicker from './components/DateSelect/busiDate.vue'
@@ -198,7 +198,7 @@ const components = [
198
198
  UploadMsg,
199
199
  Tree,
200
200
  SelectTreePro,
201
- // AdvancedFilter,
201
+ AdvancedFilter,
202
202
  /* old */
203
203
  TableO,
204
204
  FiltersO,
@@ -351,6 +351,6 @@ export {
351
351
  refreshTab,
352
352
  Tree,
353
353
  SelectTreePro,
354
- // AdvancedFilter,
354
+ AdvancedFilter,
355
355
  version
356
356
  }