gyyg-components 0.3.19 → 0.3.21

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": "gyyg-components",
3
- "version": "0.3.19",
3
+ "version": "0.3.21",
4
4
  "private": false,
5
5
  "main": "lib/gyyg-components.umd.js",
6
6
  "scripts": {
@@ -117,7 +117,6 @@ export default {
117
117
  mounted() {
118
118
  this.$nextTick(() => {
119
119
  this.btnWidth = this.$refs.btnGroup.offsetWidth
120
- console.log('width: calc(100% - (' + this.btnWidth + ' px))')
121
120
  })
122
121
  },
123
122
 
@@ -1,175 +1,225 @@
1
1
  <template>
2
- <div class="checkbox-group">
3
- <el-checkbox
4
- :indeterminate="isIndeterminate"
5
- v-if="isCheckAll"
6
- v-model="checkAll"
7
- @change="handleCheckAllChange">全选</el-checkbox>
8
- <div style="margin: 15px 0;" v-if="isCheckAll" ></div>
9
- <el-checkbox-group v-model="checkbox" @change="handleCheckedCitiesChange" :disabled="disabled">
10
- <el-checkbox v-for="(item, index) in option"
11
- :label="item[props.value]"
12
- :disabled="item.disabled"
13
- :key="index"
14
- >{{ item[props.label] }}</el-checkbox>
15
- <el-input
16
- v-if="showOther"
17
- v-model="inputValue"
18
- :disabled="inputDisabled"
19
- placeholder="请输入其他"
20
- @input="inputChange"
21
- style="display: inline-block; margin-left: 10px;" />
22
- </el-checkbox-group>
23
-
24
- </div>
2
+ <div class="checkbox-group">
3
+ <el-checkbox
4
+ :indeterminate="isIndeterminate"
5
+ v-if="isCheckAll"
6
+ v-model="checkAll"
7
+ @change="handleCheckAllChange"
8
+ >全选</el-checkbox
9
+ >
10
+ <div style="margin: 15px 0" v-if="isCheckAll"></div>
11
+ <el-checkbox-group
12
+ v-model="checkbox"
13
+ @change="handleCheckedCitiesChange"
14
+ :disabled="disabled"
15
+ >
16
+ <div v-if="isHover">
17
+ <el-tooltip
18
+ v-for="(item, index) in option"
19
+ :key="index"
20
+ class="item"
21
+ effect="dark"
22
+ :content="item[contentFileld]"
23
+ placement="top-start"
24
+ >
25
+ <el-checkbox
26
+ :label="item[props.value]"
27
+ :disabled="item.disabled"
28
+ @change="(val) => checkBoxChange(val, item)"
29
+ >{{ item[props.label] }}</el-checkbox
30
+ >
31
+ </el-tooltip>
32
+ </div>
33
+ <div v-else>
34
+ <el-checkbox
35
+ v-for="(item, index) in option"
36
+ :label="item[props.value]"
37
+ :disabled="item.disabled"
38
+ :key="index"
39
+ @change="(val) => checkBoxChange(val, item)"
40
+ >{{ item[props.label] }}</el-checkbox
41
+ >
42
+ </div>
43
+ <el-input
44
+ v-if="showOther"
45
+ v-model="inputValue"
46
+ :disabled="inputDisabled"
47
+ placeholder="请输入其他"
48
+ @input="inputChange"
49
+ style="display: inline-block; margin-left: 10px"
50
+ />
51
+ </el-checkbox-group>
52
+ </div>
25
53
  </template>
26
54
  <script>
27
55
  export default {
28
- name: 'mec-checkbox',
56
+ name: "mec-checkbox",
57
+ props: {
58
+ value: {},
59
+ options: {},
29
60
  props: {
30
- value: {},
31
- options: {},
32
- props: {
33
- default() {
34
- return {
35
- label: 'name',
36
- value: 'id'
37
- }
38
- }
39
- },
40
- isCheckAll: {
41
- default() {
42
- return false;
43
- }
44
- },
45
- showOther: {
46
- default() {
47
- return false;
48
- }
49
- },
50
- otherValue: {
51
- default() {
52
- return '';
53
- }
54
- },
55
- checkText: {
56
- default() {
57
- return '其他'
58
- }
59
- },
60
- disabled: {
61
- default() {
62
- return false;
63
- }
64
- }
65
- },
66
- data() {
61
+ default() {
67
62
  return {
68
- checkAll: false,
69
- checkbox: [],
70
- isIndeterminate: true,
71
- option: [],
72
- inputValue: '',
73
- inputDisabled: true
63
+ label: "name",
64
+ value: "id",
74
65
  };
66
+ },
75
67
  },
76
- watch: {
77
- value: {
78
- handler (val) {
79
- this.checkbox = [].concat(val)
80
- },
81
- immediate: true
82
- },
83
- options: {
84
- handler: function (val) {
85
- //判断options是否为promise
86
- if (typeof val !== 'function' && val && !val.then) {
87
- this.option = this.options;
88
- let nameList = this.getNameListByIds(this.value, this.option)
89
- this.inputDisabled = nameList.filter(item => {
90
- return item.includes(this.checkText)
91
- }).length == 0
92
- }
93
- },
94
- deep: true,
95
- immediate: true,
96
- },
97
- otherValue: {
98
- handler(val) {
99
- this.inputValue = val;
100
- console.log(val, 'otherValue')
101
- },
102
- immediate: true
103
- }
68
+ isCheckAll: {
69
+ default() {
70
+ return false;
71
+ },
104
72
  },
105
- mounted() {
106
- if (!Array.isArray(this.options) && this.options) {
107
- if(this.options instanceof Promise) {
108
- this.options.then(val => {
109
- this.option = val.data || val;
110
- let nameList = this.getNameListByIds(this.value, this.option)
111
- this.inputDisabled = nameList.filter(item => {
112
- return item.includes(this.checkText)
113
- }).length == 0
114
- });
115
- }
116
- if(typeof this.options == 'function') {
117
- this.options().then(val => {
118
- this.option = val.data || val;
119
- let nameList = this.getNameListByIds(this.value, this.option)
120
- this.inputDisabled = nameList.filter(item => {
121
- return item.includes(this.checkText)
122
- }).length == 0
123
- });
124
- }
125
-
126
- } else {
127
- this.option = this.options;
128
- }
129
-
73
+ showOther: {
74
+ default() {
75
+ return false;
76
+ },
77
+ },
78
+ otherValue: {
79
+ default() {
80
+ return "";
81
+ },
82
+ },
83
+ checkText: {
84
+ default() {
85
+ return "其他";
86
+ },
87
+ },
88
+ disabled: {
89
+ default() {
90
+ return false;
91
+ },
92
+ },
93
+ isHover: {
94
+ default() {
95
+ return false;
96
+ },
97
+ },
98
+ contentFileld: {
99
+ default() {
100
+ return "content";
101
+ },
130
102
  },
131
- computed: {
132
- checkboxAll () {
133
- return this.option.map(item => {
134
- return item[this.props.value]
135
- })
103
+ },
104
+ data() {
105
+ return {
106
+ checkAll: false,
107
+ checkbox: [],
108
+ isIndeterminate: true,
109
+ option: [],
110
+ inputValue: "",
111
+ inputDisabled: true,
112
+ };
113
+ },
114
+ watch: {
115
+ value: {
116
+ handler(val) {
117
+ this.checkbox = [].concat(val);
118
+ },
119
+ immediate: true,
120
+ },
121
+ options: {
122
+ handler: function (val) {
123
+ //判断options是否为promise
124
+ if (typeof val !== "function" && val && !val.then) {
125
+ this.option = this.options;
126
+ let nameList = this.getNameListByIds(this.value, this.option);
127
+ this.inputDisabled =
128
+ nameList.filter((item) => {
129
+ return item.includes(this.checkText);
130
+ }).length == 0;
136
131
  }
132
+ },
133
+ deep: true,
134
+ immediate: true,
135
+ },
136
+ otherValue: {
137
+ handler(val) {
138
+ this.inputValue = val;
139
+ console.log(val, "otherValue");
140
+ },
141
+ immediate: true,
137
142
  },
138
- methods: {
139
- handleCheckAllChange(val) {
140
- this.checkbox = val ? this.checkboxAll : [];
141
- this.isIndeterminate = false;
142
- },
143
- handleCheckedCitiesChange(value) {
144
- let checkedCount = value.length;
145
- this.checkAll = checkedCount === this.checkboxAll.length;
146
- this.isIndeterminate = checkedCount > 0 && checkedCount < this.checkboxAll.length;
147
- this.$emit('input', value)
148
- this.$emit('update:value', value)
149
- let nameList = this.getNameListByIds(value, this.option)
150
- this.inputDisabled = nameList.filter(item => {
151
- return item.includes(this.checkText)
152
- }).length == 0
153
- console.log(this.inputDisabled, 'this.inputDisabledthis.inputDisabledthis.inputDisabled')
154
- },
155
- // 根据 id 数组获取对应的 name 列表
156
- getNameListByIds(ids, array) {
157
- return ids.map(id => {
158
- const reason = array.find(item => item[this.props.value] === id);
159
- return reason ? reason[this.props.label] : '';
160
- }).filter(name => name); // 过滤掉空值
161
- },
162
- // 其他输入框输入
163
- inputChange(val) {
164
- this.$emit('update:otherValue', val)
165
- },
143
+ },
144
+ mounted() {
145
+ if (!Array.isArray(this.options) && this.options) {
146
+ if (this.options instanceof Promise) {
147
+ this.options.then((val) => {
148
+ this.option = val.data || val;
149
+ let nameList = this.getNameListByIds(this.value, this.option);
150
+ this.inputDisabled =
151
+ nameList.filter((item) => {
152
+ return item.includes(this.checkText);
153
+ }).length == 0;
154
+ });
155
+ }
156
+ if (typeof this.options == "function") {
157
+ this.options().then((val) => {
158
+ this.option = val.data || val;
159
+ let nameList = this.getNameListByIds(this.value, this.option);
160
+ this.inputDisabled =
161
+ nameList.filter((item) => {
162
+ return item.includes(this.checkText);
163
+ }).length == 0;
164
+ });
165
+ }
166
+ } else {
167
+ this.option = this.options;
166
168
  }
169
+ },
170
+ computed: {
171
+ checkboxAll() {
172
+ return this.option.map((item) => {
173
+ return item[this.props.value];
174
+ });
175
+ },
176
+ },
177
+ methods: {
178
+ handleCheckAllChange(val) {
179
+ this.checkbox = val ? this.checkboxAll : [];
180
+ this.isIndeterminate = false;
181
+ },
182
+ handleCheckedCitiesChange(value) {
183
+ let checkedCount = value.length;
184
+ this.checkAll = checkedCount === this.checkboxAll.length;
185
+ this.isIndeterminate =
186
+ checkedCount > 0 && checkedCount < this.checkboxAll.length;
187
+
188
+ this.$emit("input", value);
189
+ this.$emit("update:value", value);
190
+ let nameList = this.getNameListByIds(value, this.option);
191
+ this.inputDisabled =
192
+ nameList.filter((item) => {
193
+ return item.includes(this.checkText);
194
+ }).length == 0;
195
+ },
196
+ // 根据 id 数组获取对应的 name 列表
197
+ getNameListByIds(ids, array) {
198
+ return ids
199
+ .map((id) => {
200
+ const reason = array.find((item) => item[this.props.value] === id);
201
+ return reason ? reason[this.props.label] : "";
202
+ })
203
+ .filter((name) => name); // 过滤掉空值
204
+ },
205
+ // 其他输入框输入
206
+ inputChange(val) {
207
+ this.$emit("update:otherValue", val);
208
+ },
209
+ checkBoxChange(val, item) {
210
+ if (val) {
211
+ this.$emit("checkBoxSelect", item);
212
+ } else {
213
+ this.$emit("checkBoxSelect", {});
214
+ }
215
+ },
216
+ },
167
217
  };
168
218
  </script>
169
219
  <style lang="less" scoped>
170
220
  .checkbox-group {
171
- /deep/ .el-checkbox__label {
172
- font-weight: normal;
173
- }
174
- }
221
+ /deep/ .el-checkbox__label {
222
+ font-weight: normal;
223
+ }
224
+ }
175
225
  </style>
@@ -22,7 +22,10 @@
22
22
  export default {
23
23
  name: 'mec-date-picker',
24
24
  props: {
25
- value: {},
25
+ value: {
26
+ type: [String, Array],
27
+ default: ''
28
+ },
26
29
  dateType: {
27
30
  type: String,
28
31
  default: 'date'
@@ -0,0 +1,5 @@
1
+ import MecDrawer from "./MecDrawer.vue";
2
+
3
+ MecDrawer.install = Vue => Vue.component(MecDrawer.name, MecDrawer); //注册组件
4
+
5
+ export default MecDrawer;
@@ -0,0 +1,94 @@
1
+ <template>
2
+ <div>
3
+ <el-drawer :visible.sync="searchDrawerVisible" direction="rtl" :before-close="handleBeforeClose" :modal="true"
4
+ icon="el-icon-search" :size="width">
5
+ <!-- 标题区域 -->
6
+ <div slot="title" class="drawer-title">
7
+ <i class="el-icon-search" style="margin-right: 8px; color: #409EFF;font-size: 20px;"></i>
8
+ <span>{{title}}</span>
9
+ </div>
10
+
11
+ <!-- 内容区域:通过默认插槽自定义内容 -->
12
+ <div class="drawer-content">
13
+ <slot name="body"></slot>
14
+ </div>
15
+
16
+ <!-- 底部区域:通过具名插槽自定义内容(固定在底部) -->
17
+ <div class="searchBoxFooter">
18
+ <slot name="footer"></slot>
19
+ </div>
20
+ </el-drawer>
21
+ </div>
22
+ </template>
23
+
24
+ <script>
25
+
26
+ export default {
27
+ name: 'SearchDrawer',
28
+ props: {
29
+ width: {
30
+ type: String,
31
+ default: '20%'
32
+ },
33
+ title: {
34
+ type: String,
35
+ default: '筛选'
36
+ }
37
+ },
38
+ data() {
39
+ return {
40
+ searchDrawerVisible: false
41
+ }
42
+ },
43
+ methods: {
44
+ open() {
45
+ this.searchDrawerVisible = true;
46
+ },
47
+ close() {
48
+ this.searchDrawerVisible = false
49
+ },
50
+ handleBeforeClose(done) {
51
+ this.searchDrawerVisible = false;
52
+ done();
53
+ }
54
+ }
55
+ }
56
+ </script>
57
+
58
+ <style scoped>
59
+ ::v-deep .el-drawer__header {
60
+ align-items: center;
61
+ color: #72767b;
62
+ display: flex;
63
+ margin-bottom: 32px;
64
+ padding: 10px 20px;
65
+ background-color: #efefef !important;
66
+ }
67
+
68
+ .drawer-title {
69
+ display: flex;
70
+ align-items: baseline;
71
+ font-size: 18px;
72
+ }
73
+
74
+ .drawer-content {
75
+ height: calc(100% - 120px);
76
+ padding: 0 20px;
77
+ overflow-y: auto;
78
+ box-sizing: border-box;
79
+ }
80
+
81
+ .searchBoxFooter {
82
+ position: absolute;
83
+ bottom: 0;
84
+ right: 0;
85
+ width: 100%;
86
+ padding: 6px 15px;
87
+ background-color: #efefef;
88
+ border-top: 1px solid #e8e8e8;
89
+ display: flex;
90
+ justify-content: flex-end;
91
+ box-sizing: border-box;
92
+ z-index: 10;
93
+ }
94
+ </style>
@@ -40,10 +40,11 @@
40
40
  :is="item['componentName']"
41
41
  v-model="item.value"
42
42
  :value.sync="item.value"
43
- :otherValue.sync="item.otherValue"
43
+ :otherValue.sync="item.otherValue"
44
44
  :delIdList.sync="item.delIdList"
45
45
  v-bind="item"
46
46
  v-on="item.componentListeners"
47
+ :ref="item.componentRef"
47
48
  ></component>
48
49
  </el-form-item>
49
50
  </el-col>
@@ -112,6 +113,7 @@ export default {
112
113
  };
113
114
  </script>
114
115
  <style lang="less" scoped>
116
+
115
117
  ::v-deep.el-form::after {
116
118
  content: "";
117
119
  display: table;
@@ -9,6 +9,7 @@
9
9
  placement="bottom-end"
10
10
  @click="clickEvent"
11
11
  @command="changeItem"
12
+ @visible-change="visibleChange"
12
13
  >
13
14
  <span v-if="btnInfo.splitButton"><i :class="btnInfo.icon" style="margin-right: 5px;"></i>{{ btnInfo.text}}</span>
14
15
  <el-button :type="btnInfo.type" v-else>
@@ -39,6 +40,9 @@ export default {
39
40
  },
40
41
  changeItem(value) {
41
42
  this.btnInfo.callback(value)
43
+ },
44
+ visibleChange(value) {
45
+ this.$emit('visibleChange', value)
42
46
 
43
47
  }
44
48
  }