gyyg-components 0.2.7 → 0.2.8

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.2.7",
3
+ "version": "0.2.8",
4
4
  "private": false,
5
5
  "main": "lib/gyyg-components.umd.js",
6
6
  "scripts": {
@@ -19,7 +19,7 @@
19
19
  "devDependencies": {
20
20
  "@vue/cli-plugin-babel": "~4.5.15",
21
21
  "@vue/cli-plugin-eslint": "~4.5.15",
22
- "@vue/cli-service": "~4.5.15",
22
+ "@vue/cli-service": "^4.5.15",
23
23
  "babel-eslint": "^10.1.0",
24
24
  "eslint": "^6.7.2",
25
25
  "eslint-plugin-vue": "^6.2.2",
package/src/App.vue CHANGED
@@ -12,113 +12,39 @@
12
12
  @page-change="handlePageChange"
13
13
  @show="show"
14
14
  ></mec-input-table>-->
15
- <mec-search-form
16
- :formGroups="formGroups"
17
- >
15
+ <!-- <mec-form :formData="formData" :showBtn="true" @submit="submit"></mec-form> -->
16
+ <mec-search-form :formGroups="formGroups"></mec-search-form>
18
17
 
19
- </mec-search-form>
20
18
  </div>
21
-
22
19
  </template>
23
20
 
24
21
  <script>
25
-
26
22
  export default {
27
23
  data() {
28
- const _this = this
24
+ const _this = this;
29
25
  return {
30
- formGroups: [
31
- {
32
- componentName: 'mec-select',
33
- value: '',
34
- prop: 'a',
35
- componentProps: {
36
- options: [
37
- { id: 'option1', name: '选项1' },
38
- { id: 'option2', name: '选项2' },
39
- { id: 'option3', name: '选项3' }
40
- ],
41
- placeholder: '请选择一个选项',
42
- clearable: true,
43
- filterable: true,
44
- props: {
45
- label: 'name',
46
- value: 'id'
47
- }
48
- },
49
- componentListeners: {
50
- change: (val) => {
51
- this.formGroups[0].value = val
52
- console.log(this.formGroups[0].value);
53
- },
54
- clear: () => {
55
- console.log(_this);
56
- }
57
- }
58
- },
59
- {
60
- label: '选择项',
61
- componentName: 'MecInputTable',
62
- value: '',
63
- prop: 'b',
64
- componentProps: {
65
- tableData: [
66
- { name: 'John', age: 30, address: 'New York' },
67
- { name: 'Tom', age: 25, address: 'London' },
68
- { name: 'Jerry', age: 35, address: 'Paris' }
69
- ],
70
- columns: [
71
- { label: '姓名', bind: 'name' },
72
- { label: '年龄', bind: 'age' },
73
- { label: '地址', bind: 'address' }
74
- ],
75
- inputInfo: {
76
- inputPlaceholder: '点击选择',
77
- tablePlaceholder: '请输入',
78
- },
79
- showSearch: true,
80
- page: {
81
- currentPage: 1,
82
- pageSize: 10,
83
- total: 3
84
- }
85
- },
86
- componentListeners: {
87
- 'row-click': (row) => {
88
- _this.formGroups[1].value = row.name
89
- console.log('Row clicked:', row);
90
- },
91
- 'size-change': (val) => {
92
- console.log('Page size changed:', val);
26
+ formGroups: {
27
+ abLifeSupport: {
28
+ componentName: 'mec-radio',
29
+ label: '生命支持',
30
+ labelWidth: "100px",
31
+ options: [
32
+ {
33
+ label: '',
34
+ value: true
93
35
  },
94
- 'current-change': (val) => {
95
- console.log('Page changed:', val);
36
+ {
37
+ label: '否',
38
+ value: false
96
39
  },
97
- 'show': () => {
98
- console.log('Dropdown shown');
99
- },
100
- 'input': (val) => {
101
- console.log('Input changed:', val);
102
- },
103
- 'search': (val) => {
104
- console.log('Search:', val);
105
- },
106
- 'refresh': () => {
107
- console.log('Refreshed');
108
- }
109
- }
40
+ ],
41
+ value: '',
110
42
  }
111
- ]
43
+ }
112
44
  };
113
45
  },
114
46
  methods: {
115
- handleSelectChange(val) {
116
- console.log('Selected value changed:', val);
117
- },
118
- handleSelectClear() {
119
- console.log('Selection cleared');
120
- }
121
- }
47
+ },
122
48
  // methods: {
123
49
  // handleRowClick(row) {
124
50
  // console.log('Row clicked:', row);
@@ -135,7 +61,7 @@ export default {
135
61
  // },
136
62
  // show() {
137
63
  // console.log('显示');
138
-
64
+
139
65
  // }
140
66
  // }
141
67
  };
@@ -0,0 +1,5 @@
1
+ import MECDefaultText from "./MECDefaultText.vue";
2
+
3
+ MECDefaultText.install = Vue => Vue.component(MECDefaultText.name, MECDefaultText); //注册组件
4
+
5
+ export default MECDefaultText;
@@ -0,0 +1,9 @@
1
+ <template>
2
+ <div>{{ value }}</div>
3
+ </template>
4
+ <script>
5
+ export default {
6
+ name: 'mec-defaultText',
7
+ props:['value']
8
+ }
9
+ </script>
@@ -0,0 +1,5 @@
1
+ import MecCheckbox from "./MecCheckbox.vue";
2
+
3
+ MecCheckbox.install = Vue => Vue.component(MecCheckbox.name, MecCheckbox); //注册组件
4
+
5
+ export default MecCheckbox;
@@ -0,0 +1,86 @@
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">
10
+ <el-checkbox v-for="(item, index) in options"
11
+ :label="item[props.value]"
12
+ :disabled="item.disabled"
13
+ :key="index">{{ item[props.label] }}</el-checkbox>
14
+ </el-checkbox-group>
15
+ </div>
16
+ </template>
17
+ <script>
18
+ const cityOptions = ['上海', '北京', '广州', '深圳'];
19
+ export default {
20
+ name: 'mec-checkbox',
21
+ props: {
22
+ value: {},
23
+ options: {
24
+ type: Array,
25
+ default() {
26
+ return [];
27
+ }
28
+ },
29
+ props: {
30
+ default() {
31
+ return {
32
+ label: 'label',
33
+ value: 'value'
34
+ }
35
+ }
36
+ },
37
+ isCheckAll: {
38
+ default() {
39
+ return false;
40
+ }
41
+ },
42
+ },
43
+ data() {
44
+ return {
45
+ checkAll: false,
46
+ checkbox: [],
47
+ isIndeterminate: true
48
+ };
49
+ },
50
+ watch: {
51
+ value: {
52
+ handler (val) {
53
+ this.checkbox = [].concat(val);
54
+ },
55
+ immediate: true
56
+ },
57
+ },
58
+ computed: {
59
+ checkboxAll () {
60
+ return this.options.map(item => {
61
+ return item[this.props.value]
62
+ })
63
+ }
64
+ },
65
+ methods: {
66
+ handleCheckAllChange(val) {
67
+ this.checkbox = val ? this.checkboxAll : [];
68
+ this.isIndeterminate = false;
69
+ },
70
+ handleCheckedCitiesChange(value) {
71
+ let checkedCount = value.length;
72
+ this.checkAll = checkedCount === this.checkboxAll.length;
73
+ this.isIndeterminate = checkedCount > 0 && checkedCount < this.checkboxAll.length;
74
+ this.$emit('input', value)
75
+ console.log(value)
76
+ }
77
+ }
78
+ };
79
+ </script>
80
+ <style lang="less" scoped>
81
+ .checkbox-group {
82
+ /deep/ .el-checkbox__label {
83
+ font-weight: normal;
84
+ }
85
+ }
86
+ </style>
@@ -0,0 +1,5 @@
1
+ import MecDatePicker from "./MecDatePicker.vue";
2
+
3
+ MecDatePicker.install = Vue => Vue.component(MecDatePicker.name, MecDatePicker); //注册组件
4
+
5
+ export default MecDatePicker;
@@ -0,0 +1,94 @@
1
+ <template>
2
+ <div>
3
+ <el-date-picker
4
+ v-model="date"
5
+ :type="dateType"
6
+ :placeholder="placeholder"
7
+ :disabled="disabled"
8
+ :readonly="readonly"
9
+ :size="size"
10
+ @change="change"
11
+ :picker-options="pickerOptions"
12
+ :start-placeholder="startPlaceholder"
13
+ :end-placeholder="endPlaceholder"
14
+ :range-separator="rangeSeparator"
15
+ :value-format="valueFormat"
16
+ style="width: 100%;">
17
+ </el-date-picker>
18
+ </div>
19
+ </template>
20
+ <script>
21
+ export default {
22
+ name: 'mec-date-picker',
23
+ props: {
24
+ value: {},
25
+ dateType: {
26
+ type: String,
27
+ default: 'date'
28
+ },
29
+ placeholder: {
30
+ type: String,
31
+ default: '选择日期时间'
32
+ },
33
+ disabled: {
34
+ type: Boolean,
35
+ default: false
36
+ },
37
+ readonly: {
38
+ type: Boolean,
39
+ default: false
40
+ },
41
+ size: {
42
+ type: String,
43
+ },
44
+ pickerOptions: {
45
+ type: Object,
46
+
47
+ },
48
+ startPlaceholder: {
49
+ type: String,
50
+ default: '开始日期'
51
+ },
52
+ endPlaceholder: {
53
+ type: String,
54
+ default: '结束日期'
55
+
56
+ },
57
+ rangeSeparator: {
58
+ type: String,
59
+ default: '至'
60
+ },
61
+ valueFormat: {
62
+ type: String,
63
+ default: 'yyyy-MM-dd'
64
+ }
65
+
66
+ },
67
+ data() {
68
+ return {
69
+ date: ''
70
+ }
71
+ },
72
+ methods: {
73
+ change(val) {
74
+ this.$emit('change', val);
75
+ }
76
+ },
77
+ watch: {
78
+ value: {
79
+ handler(val) {
80
+ this.date = val;
81
+ },
82
+ immediate: true
83
+ },
84
+ date: {
85
+ handler(val) {
86
+ this.$emit('input', val);
87
+ }
88
+
89
+ }
90
+ }
91
+ }
92
+ </script>
93
+ <style lang="less" scoped>
94
+ </style>
@@ -0,0 +1,5 @@
1
+ import MecDialog from "./MecDialog.vue";
2
+
3
+ MecDialog.install = Vue => Vue.component(MecDialog.name, MecDialog); //注册组件
4
+
5
+ export default MecDialog;
@@ -0,0 +1,226 @@
1
+ <template>
2
+ <div class="base-dialog">
3
+ <el-dialog
4
+ :class="dialogClass"
5
+ v-el-drag-dialog="dragDialog"
6
+ :type="type"
7
+ :width="width"
8
+ :custom-class="customClass"
9
+ :fullscreen="fullscreen"
10
+ :title="title"
11
+ :close-on-click-modal="closeOnClickModal"
12
+ :append-to-body="appendToBody"
13
+ :visible.sync="visible"
14
+ :before-close="beforeClose"
15
+ :show-close="showClose"
16
+ v-if="visible"
17
+ @closed="closed"
18
+ @close="closeMethod"
19
+ :destroy-on-close="destroyOnClose"
20
+ :modal='modal'
21
+ >
22
+ <slot name="body" />
23
+ <div v-if="footer" slot="footer" class="dialog-footer">
24
+ <slot name="footer" />
25
+ </div>
26
+ </el-dialog>
27
+ </div>
28
+ </template>
29
+
30
+ <script>
31
+ import elDragDialog from "@/directive/el-drag-dialog"; // 引入拖拽指令
32
+ export default {
33
+ name: "mec-dialog",
34
+ directives: { elDragDialog },
35
+ props: {
36
+ appendToBody: {
37
+ type: Boolean,
38
+ default: false,
39
+ }, // 是否嵌套
40
+ closeOnClickModal: {
41
+ type: Boolean,
42
+ default: false,
43
+ }, // 是否可以点击关闭
44
+ footer: {
45
+ type: Boolean,
46
+ default: true,
47
+ }, // 是否显示底部
48
+ title: {
49
+ type: String,
50
+ default: "",
51
+ }, // 对话框title
52
+ type: {
53
+ type: String,
54
+ default: "",
55
+ }, // 对话框类型:1.基础表单[base-dialog-form] 2.表格[base-dialog-table] 3.全屏 [base-dialog-fullscreen]
56
+ width: {
57
+ type: String,
58
+ default: "",
59
+ }, // 对话框宽度800px 或 50%
60
+ destroyOnClose: {
61
+ type: Boolean,
62
+ default: true,
63
+ },
64
+ beforeClose: Function, // 关闭回调函数
65
+ dialogClass: {
66
+ //class
67
+ type: String,
68
+ default: "",
69
+ },
70
+ // 是否显示叉号
71
+ showClose: {
72
+ default: true,
73
+ type: Boolean
74
+ },
75
+ //是否需要遮罩层
76
+ modal:{
77
+ default: true,
78
+ type: Boolean
79
+ },
80
+ dragDialog: {
81
+ type: Boolean,
82
+ default: true,
83
+ },
84
+ },
85
+ data() {
86
+ return {
87
+ visible: false,
88
+ fullscreen: false,
89
+ };
90
+ },
91
+ computed: {
92
+ customClass() {
93
+ let className = "";
94
+ switch (this.type) {
95
+ case "form":
96
+ className = "base-dialog-form";
97
+ break;
98
+ case "table":
99
+ className = "base-dialog-table";
100
+ break;
101
+ case "fullscreen":
102
+ className = "base-dialog-fullscreen";
103
+ break;
104
+ }
105
+ return className;
106
+ },
107
+ },
108
+ created() {
109
+ this.type === "fullscreen" && (this.fullscreen = true);
110
+ },
111
+ methods: {
112
+ open() {
113
+ this.visible = true;
114
+ },
115
+ close() {
116
+ this.visible = false;
117
+ },
118
+ closed() {
119
+ this.$emit("closed");
120
+ },
121
+ closeMethod() {
122
+ this.$emit("close");
123
+ },
124
+ },
125
+ };
126
+ </script>
127
+
128
+ <style lang="less" scoped>
129
+ .base-dialog {
130
+ text-align: left;
131
+ }
132
+ .el-dialog__wrapper {
133
+ overflow: hidden;
134
+ display: flex;
135
+ justify-content: center;
136
+ align-items: center;
137
+ .el-dialog {
138
+ display: flex;
139
+ flex-direction: column;
140
+ border-radius: 8px;
141
+ margin: 0;
142
+ margin-top: 0 !important;
143
+ .el-dialog__header {
144
+ text-align: left;
145
+ background-color: #efefef;
146
+ height: 48px;
147
+ line-height: 48px;
148
+ padding: 0 20px;
149
+ color: #fff;
150
+ border-top-left-radius: 8px;
151
+ border-top-right-radius: 8px;
152
+ font-weight: bold;
153
+
154
+ .el-dialog__title {
155
+ font-size: 16px;
156
+ // font-weight: bold;
157
+ }
158
+
159
+ .el-dialog__headerbtn {
160
+ top: 12px;
161
+ }
162
+ }
163
+
164
+ .el-dialog__body {
165
+ flex: 1;
166
+ overflow: auto;
167
+ padding: 20px;
168
+ }
169
+
170
+ .el-dialog__footer {
171
+ flex-shrink: 0;
172
+ box-sizing: content-box;
173
+ height: 32px;
174
+ padding: 10px;
175
+ border: none;
176
+ background-color: #efefef;
177
+ border-bottom-left-radius: 8px;
178
+ border-bottom-right-radius: 8px;
179
+ }
180
+ }
181
+
182
+ .base-dialog-form {
183
+ height: auto;
184
+
185
+ .el-dialog__body {
186
+ padding: 20px 20px 0 20px;
187
+ }
188
+
189
+ .el-dialog__footer {
190
+ height: 32px;
191
+ border: none;
192
+ background-color: #efefef;
193
+ border-bottom-left-radius: 8px;
194
+ border-bottom-right-radius: 8px;
195
+ }
196
+
197
+ .custom-table {
198
+ // 取消表格下边线
199
+ tbody tr:last-child td {
200
+ border-bottom: none !important;
201
+ }
202
+ }
203
+ }
204
+
205
+ .base-dialog-table {
206
+ height: 90vh;
207
+ margin-top: 5vh !important;
208
+ }
209
+
210
+ .base-dialog-fullscreen {
211
+ height: 100vh;
212
+ width: 100vw;
213
+
214
+ .el-dialog__body {
215
+ padding: 10px;
216
+ }
217
+ .el-dialog__footer {
218
+ padding: 10px;
219
+ border: none;
220
+ background-color: #efefef;
221
+ border-bottom-left-radius: 8px;
222
+ border-bottom-right-radius: 8px;
223
+ }
224
+ }
225
+ }
226
+ </style>
@@ -0,0 +1,5 @@
1
+ import MecForm from "./MecForm.vue";
2
+
3
+ MecForm.install = Vue => Vue.component(MecForm.name, MecForm); //注册组件
4
+
5
+ export default MecForm;
@@ -0,0 +1,77 @@
1
+ <template>
2
+ <el-form
3
+ ref="formData"
4
+ :model="formData"
5
+ :label-width="labelWidth"
6
+ :label-position="labelPosition"
7
+ >
8
+ <template v-for="(item, index) in formData">
9
+ <el-col
10
+ v-if="typeof item.displayWith !== 'function' || item.displayWith(formData, item)"
11
+ :span="item.col"
12
+ :style="item.style"
13
+ :key="index"
14
+ >
15
+ <el-form-item v-bind="item" :prop="getProp(item, index)" :rules="item.rules" :class="item.class">
16
+ <template slot="label">
17
+ <span v-if="item.label">
18
+ {{ item.label }}
19
+ <el-tooltip v-if="item.tooltip" class="item" effect="dark" :content="item.tooltip" placement="top">
20
+ <i class="el-icon-question"></i>
21
+ </el-tooltip>
22
+ </span>
23
+ </template>
24
+ <component
25
+ :is="item['componentName']"
26
+ v-model="item.value"
27
+ v-bind="item"
28
+ v-on="item.componentListeners"
29
+ ></component>
30
+ </el-form-item>
31
+ </el-col>
32
+ </template>
33
+ </el-form>
34
+ </template>
35
+ <script>
36
+ export default {
37
+ name: 'mec-form',
38
+ props: {
39
+ formData: {
40
+ required: true,
41
+ },
42
+ labelWidth: {
43
+ type: String,
44
+ default: '150px',
45
+ },
46
+ labelPosition: {
47
+ type: String,
48
+ default: 'right',
49
+ },
50
+ },
51
+ data() {
52
+ return {
53
+ loading: false,
54
+ };
55
+ },
56
+ computed: {},
57
+ methods: {
58
+ getProp(item, index) {
59
+ let propName = item.prop ? item.prop : index + ".value";
60
+ return propName;
61
+ },
62
+ validate() {
63
+ return new Promise((resolve, reject) => {
64
+ this.$refs.formData.validate(valid => {
65
+ if (valid) {
66
+ resolve(true);
67
+ } else {
68
+ resolve(false);
69
+ }
70
+ });
71
+ });
72
+ }
73
+ },
74
+ };
75
+ </script>
76
+ <style lang="less">
77
+ </style>