gyyg-components 0.2.5 → 0.2.7

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.5",
3
+ "version": "0.2.7",
4
4
  "private": false,
5
5
  "main": "lib/gyyg-components.umd.js",
6
6
  "scripts": {
package/src/App.vue CHANGED
@@ -1,208 +1,142 @@
1
1
  <template>
2
- <div id="app" :key="key">
3
- <mec-input-table
4
- :tableData="tableData"
5
- :columns="columns"
6
- :inputInfo="inputInfo"
7
- @search="searchHandel"
8
- @refresh="refreshHandel"
9
- @show="showHandel"
10
- :showSearch="false"
11
- @row-click="rowClick"
12
- ></mec-input-table>
13
- <mec-button-group :btnList="btnList"></mec-button-group>
14
- <el-form ref="form" :model="formData" :rules="rules" label-width="100px">
15
- <el-form-item label="数字输入框" prop="numberInput">
16
- <mec-input placeholder="请输入数字" inputType="number" type="number" v-model="formData.numberInput"></mec-input>
17
- </el-form-item>
18
- <el-form-item label="汉字输入框" prop="chineseInput">
19
- <mec-input placeholder="请输入汉字" inputType="chinese" type="text" v-model="formData.chineseInput"></mec-input>
20
- </el-form-item>
21
- <el-form-item label="英文输入框" prop="englishInput">
22
- <mec-input placeholder="请输入英文" inputType="english" clearable type="text" v-model="formData.englishInput"></mec-input>
23
- </el-form-item>
24
- <el-form-item label="自定义正则输入框" prop="regexInput">
25
- <mec-input placeholder="请按正则输入" inputType="regex" type="text" :maxlength="11" v-model="formData.regexInput">
26
- </mec-input>
27
- </el-form-item>
28
- <el-form-item label="正常输入框" prop="input">
29
- <mec-input placeholder="输入" type="text" :clearable="true" v-model="formData.input" @clear="clear">
30
- </mec-input>
31
- </el-form-item>
32
- <el-form-item label="文本域" prop="input">
33
- <mec-input placeholder="输入" type="textarea" v-model="formData.textarea" :autosize="{minRows: 2, maxRows: 4}" :rows="2">
34
- </mec-input>
35
- </el-form-item>
36
- <el-button @click="submitForm">提交</el-button>
37
- </el-form>
38
- <mec-table
39
- :tableData="tableData"
40
- :columns="columns"
41
- :selection="true"
42
- @selection-change="selectionChange"
43
-
44
- :highlightSelectionRow="true"
45
- ></mec-table>
2
+ <div id="app">
3
+ <!-- <mec-input-table
4
+ :tableData="tableData"
5
+ :columns="columns"
6
+ :height="height"
7
+ :page="page"
8
+ :inputInfo="inputInfo"
9
+ :showSearch="showSearch"
10
+ @row-click="handleRowClick"
11
+ @page-size-change="handlePageSizeChange"
12
+ @page-change="handlePageChange"
13
+ @show="show"
14
+ ></mec-input-table>-->
15
+ <mec-search-form
16
+ :formGroups="formGroups"
17
+ >
18
+
19
+ </mec-search-form>
46
20
  </div>
21
+
47
22
  </template>
48
23
 
49
24
  <script>
50
25
 
51
26
  export default {
52
- name: 'App',
53
27
  data() {
54
- const _this = this;
28
+ const _this = this
55
29
  return {
56
- btnList: [
57
- // 按钮列表配置
58
- {
59
- text: '转资审租',
60
- componentType: 'mec-popover-button',
61
- size: 'medium',
62
- type: 'primary',
63
- disabled: false,
64
- id: 'popover',
65
- options: [
66
- {
67
- label: '转谈判组',
68
- value: '1',
69
- },
70
- {
71
- label: '转呈批组',
72
- value: '1',
73
- },
74
- {
75
- label: '转签约组',
76
- value: '1',
77
- },
78
- ],
79
- trigger() {
80
- console.log('按钮点击');
81
- },
82
- callback(row) {
83
- console.log(row);
84
-
85
- }
86
- }
87
- ],
88
- formData: {
89
- numberInput: '',
90
- chineseInput: '',
91
- regexInput: '',
92
- englishInput: '',
93
- input: '',
94
- textarea: ''
95
- },
96
- rules: {
97
- numberInput: [
98
- { required: true, message: '数字输入框不能为空', trigger: 'blur' },
99
- ],
100
- chineseInput: [
101
- { required: true, message: '汉字输入框不能为空', trigger: 'blur' },
102
- ],
103
- englishInput: [
104
- { required: true, message: '英文输入框不能为空', trigger: 'blur' },
105
- ],
106
- regexInput: [
107
- { required: true, message: '自定义正则输入框不能为空', trigger: 'blur' },
108
- { validator: this.validateRegex, message: '请按正则输入内容', trigger: 'blur' }
109
- ]
110
- },
111
- regexInfo: /^(?:(?:\+|00)86)?1[3-9]\d{9}$/,
112
- tableData: [],
113
- columns: [
114
- {
115
- label: '编码',
116
- bind: 'sdDeptCode'
117
- },
118
- {
119
- label: '名称',
120
- bind: 'sdDeptName',
121
- },
30
+ formGroups: [
122
31
  {
123
- label: '负责人',
124
- bind: 'sdPrincipal'
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
+ }
125
58
  },
126
59
  {
127
- label: '院区',
128
- bind: 'sdOrgName',
129
- width: '150'
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);
93
+ },
94
+ 'current-change': (val) => {
95
+ console.log('Page changed:', val);
96
+ },
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
+ }
130
110
  }
131
- ],
132
- inputInfo: {
133
- inputPlaceholder: '科室',
134
- tablePlaceholder: '编码/名称',
135
- inputValue: ''
136
- },
137
- key: 0
111
+ ]
138
112
  };
139
113
  },
140
114
  methods: {
141
- change(val) {
142
- console.log(val);
143
- },
144
- validateRegex(rule, value, callback) {
145
- const reg = this.regexInfo;
146
- if (reg.test(value)) {
147
- callback();
148
- } else {
149
- callback(new Error('请按正则输入内容'));
150
- }
151
- },
152
- submitForm() {
153
- this.$refs.form.validate((valid) => {
154
- if (valid) {
155
- console.log('表单验证通过');
156
- } else {
157
- console.log('表单验证失败');
158
- }
159
- });
160
- },
161
- updateArrayById(arr, updateConfigs) {
162
- const newArray = arr.map(item => ({ ...item }));
163
- updateConfigs.forEach(config => {
164
- const index = newArray.findIndex(el => el.id === config.id);
165
- if (index !== -1) {
166
- for (const key in config) {
167
- if (key !== 'id') {
168
- newArray[index][key] = config[key];
169
- }
170
- }
171
- }
172
- });
173
- return newArray;
174
- },
175
- clear() {
176
- console.log('清除操作');
177
- this.key++
178
- },
179
- searchHandel(val) {
180
- console.log(val);
181
- },
182
- refreshHandel() {
183
- console.log('重置')
115
+ handleSelectChange(val) {
116
+ console.log('Selected value changed:', val);
184
117
  },
185
- rowClick(row) {
186
- console.log(row);
187
- this.inputInfo.inputValue = row.sdDeptName // 赋值操作
188
- },
189
- selectionChange(val) {
190
- console.log(val, 123);
191
- },
192
- showHandel() {
193
- this.tableData = [
194
- {
195
- id: "99a4bdb4513e17ad1c2a2436a735a86f",
196
- sdDeptCode: "1232131",
197
- sdDeptName: "a1111",
198
- sdOrgId: "069fcbfce1d4e0233546bc5dba114a75",
199
- sdOrgName: "国药医工第一院区",
200
- sdPrincipal: "张三"
201
- }
202
- ]
203
-
118
+ handleSelectClear() {
119
+ console.log('Selection cleared');
204
120
  }
205
-
206
121
  }
122
+ // methods: {
123
+ // handleRowClick(row) {
124
+ // console.log('Row clicked:', row);
125
+ // },
126
+ // handlePageSizeChange(val) {
127
+ // console.log('Page size changed:', val);
128
+ // // 在这里处理 page-size-change 事件
129
+ // },
130
+ // handlePageChange(val) {
131
+ // console.log('Page changed:', val);
132
+ // },
133
+ // handleCurrentChange(val) {
134
+ // console.log('Current change:', val);
135
+ // },
136
+ // show() {
137
+ // console.log('显示');
138
+
139
+ // }
140
+ // }
207
141
  };
208
142
  </script>
@@ -1,32 +1,48 @@
1
1
  <template>
2
2
  <div>
3
- <el-dropdown trigger="click" @visible-change="visibleChange">
4
- <el-input
5
- :placeholder="inputInfo.inputPlaceholder"
6
- v-model="inputValue"
7
- class="el-dropdown-link"
8
- readonly
9
- :suffix-icon="showDropdown ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"></el-input>
10
- <el-dropdown-menu slot="dropdown" class="mec-input-table">
11
- <div class="search-table" v-if="showSearch">
12
- <el-input
13
- :placeholder="inputInfo.tablePlaceholder"
14
- v-model="tableInput"
15
- @input="tableInputHandel"
16
- ></el-input>
17
- <el-button type="primary" size="medium" @click="search">查询</el-button>
18
- <el-button icon="el-icon-refresh" size="medium" @click="refresh"></el-button>
19
- </div>
20
-
21
- <el-dropdown-item>
22
- <mec-table
23
- :tableData="tableData"
24
- style="width: 100%"
25
- @row-click="handleTableRowClick"
26
- :columns="columns">
27
- </mec-table>
28
- </el-dropdown-item>
29
- </el-dropdown-menu>
3
+ <el-dropdown trigger="click" ref="dropdown" @visible-change="visibleChange">
4
+ <el-input v-model="inputValue" :placeholder="inputInfo.inputPlaceholder" readonly>
5
+ <template slot="suffix">
6
+ <i class="el-input__icon el-icon-arrow-down"></i>
7
+ </template>
8
+ </el-input>
9
+ <el-dropdown-menu slot="dropdown">
10
+ <div class="search-table" v-if="showSearch">
11
+ <el-input
12
+ :placeholder="inputInfo.tablePlaceholder"
13
+ v-model="tableInput"
14
+ ></el-input>
15
+ <el-button type="primary" size="medium" @click="search">查询</el-button>
16
+ <el-button icon="el-icon-refresh" size="medium" @click="refresh"></el-button>
17
+ </div>
18
+ <el-table :data="tableData" style="width: 100%" @row-click="rowClick">
19
+ <!-- <el-table-column
20
+ type="selection"
21
+ :reserve-selection="true"
22
+ width="55"
23
+ v-if="showSelection"
24
+ ></el-table-column> -->
25
+ <el-table-column
26
+ v-for="(item, index) in columns"
27
+ :key="index"
28
+ :prop="item.bind"
29
+ :label="item.label"
30
+ :show-overflow-tooltip="true"
31
+ :width="item.width"
32
+ >
33
+ </el-table-column>
34
+
35
+ </el-table>
36
+ <el-pagination
37
+ @size-change="handleSizeChange"
38
+ @current-change="handleCurrentChange"
39
+ :current-page="page.currentPage"
40
+ :page-sizes="[10, 20, 30, 50]"
41
+ :page-size="page.pageSize"
42
+ layout="total, sizes, prev, pager, next"
43
+ :total="page.total">
44
+ </el-pagination>
45
+ </el-dropdown-menu>
30
46
  </el-dropdown>
31
47
  </div>
32
48
  </template>
@@ -43,12 +59,26 @@ export default {
43
59
  type: Array,
44
60
  default: () => []
45
61
  },
62
+ showSelection: {
63
+ type: Boolean,
64
+ default: false
65
+ },
46
66
  inputInfo: {
47
67
  default: {}
48
68
  },
49
69
  showSearch:{
50
70
  type: Boolean,
51
71
  dafault: true
72
+ },
73
+ page: {
74
+ default: {}
75
+ },
76
+ toggleRow: {
77
+ type: Boolean,
78
+ default: true
79
+ },
80
+ value: {
81
+ default: ''
52
82
  }
53
83
  },
54
84
  data() {
@@ -59,9 +89,11 @@ export default {
59
89
  };
60
90
  },
61
91
  methods: {
62
- handleTableRowClick(row) {
92
+ rowClick(row) {
93
+ if(this.toggleRow) {
94
+ this.$refs.dropdown.hide()
95
+ }
63
96
  this.$emit('row-click', row)
64
- this.showDropdown = false;
65
97
  },
66
98
  visibleChange(val) {
67
99
  this.showDropdown = val
@@ -79,11 +111,18 @@ export default {
79
111
  refresh() {
80
112
  this.tableInput = ''
81
113
  this.$emit('refresh')
114
+ },
115
+ handleSizeChange(val) {
116
+ this.$refs.dropdown.show()
117
+ this.$emit('size-change', val)
118
+ },
119
+ handleCurrentChange(val) {
120
+ this.$emit('current-change', val)
82
121
  }
83
122
 
84
123
  },
85
124
  watch: {
86
- 'inputInfo.inputValue': {
125
+ value: {
87
126
  handler(val) {
88
127
  this.inputValue = val
89
128
  },
@@ -111,4 +150,7 @@ export default {
111
150
  margin-left: 15px;
112
151
  }
113
152
  }
153
+ /deep/ .el-pagination {
154
+ margin-top: 15px;
155
+ }
114
156
  </style>
@@ -0,0 +1,5 @@
1
+ import MecSearchForm from "./MecSearchForm.vue";
2
+
3
+ MecSearchForm.install = Vue => Vue.component(MecSearchForm.name, MecSearchForm); //注册组件
4
+
5
+ export default MecSearchForm;
@@ -0,0 +1,55 @@
1
+ <template>
2
+ <div>
3
+ <el-form ref="form" :model="formModel" :inline="true">
4
+ <template v-for="(item, index) in formGroups">
5
+ <el-form-item
6
+ :key="index"
7
+ :label="item.label ? item.label : null"
8
+ :label-width="item.label?item.labelWidth:'0px'"
9
+ :rules="item.rules"
10
+ :prop="getProp(item,index)"
11
+ >
12
+ <component :is="item['componentName']"
13
+ v-model="item.value"
14
+ v-bind="item.componentProps"
15
+ v-on="item.componentListeners"
16
+ ></component>
17
+ </el-form-item>
18
+
19
+ </template>
20
+ <el-button type="primary" @click="search">查询</el-button>
21
+ </el-form>
22
+ </div>
23
+ </template>
24
+ <script>
25
+ export default {
26
+ name: 'MecSearchForm',
27
+ props: {
28
+ formGroups: {
29
+ type: Array,
30
+ default: () => []
31
+ }
32
+ },
33
+ data() {
34
+ return {
35
+ formModel: this.createFormModel(this.formGroups)
36
+ };
37
+ },
38
+ methods: {
39
+ createFormModel(formGroups) {
40
+ const model = {};
41
+ formGroups.forEach(item => {
42
+ model[item.prop] = item.value;
43
+ });
44
+ return model;
45
+ },
46
+ getProp (item, index) {
47
+ let propName = item.prop ? item.prop : index + ".value";
48
+ return propName;
49
+ },
50
+ search() {
51
+ console.log(this.formGroups)
52
+ }
53
+ }
54
+ }
55
+ </script>
@@ -0,0 +1,5 @@
1
+ import MecSelect from "./MecSelect.vue";
2
+
3
+ MecSelect.install = Vue => Vue.component(MecSelect.name, MecSelect); //注册组件
4
+
5
+ export default MecSelect;
@@ -0,0 +1,92 @@
1
+ <template>
2
+ <el-select
3
+ v-model="selected"
4
+ @clear="clear"
5
+ @change="handleChange"
6
+ :placeholder="placeholder"
7
+ :multiple="multiple || false"
8
+ :clearable="clearable"
9
+ :disabled="disabled"
10
+ :size="size"
11
+ v-bind="$attrs"
12
+ :filterable="filterable"
13
+ >
14
+ <el-option
15
+ v-for="item in options"
16
+ :key="item[props.value]"
17
+ :label="item[props.label]"
18
+ :value="item[props.value]"
19
+ :disabled="item.disabled"
20
+ ></el-option>
21
+ </el-select>
22
+ </template>
23
+
24
+ <script>
25
+ export default {
26
+ name: "MecSelect",
27
+ props: {
28
+ value: {
29
+ default: null,
30
+ required: true,
31
+ },
32
+ options: {
33
+ type: Array,
34
+ required: true,
35
+ default: () => [],
36
+ },
37
+ multiple: {
38
+ default: false,
39
+ },
40
+ props: {
41
+ default() {
42
+ return {
43
+ label: "label",
44
+ value: "value",
45
+ };
46
+ },
47
+ },
48
+ placeholder: {
49
+ type: String,
50
+ default: "请选择",
51
+ },
52
+ clearable: {
53
+ type: Boolean,
54
+ },
55
+ disabled: {
56
+ type: Boolean,
57
+ defalut: false,
58
+ },
59
+ size: String,
60
+ filterable: {
61
+ type: Boolean,
62
+ defalut: false,
63
+ },
64
+ },
65
+ data() {
66
+ return {
67
+ selected: this.value,
68
+ };
69
+ },
70
+ watch: {
71
+ value: {
72
+ handler(val) {
73
+ this.selected = val;
74
+ },
75
+ immediate: true,
76
+ },
77
+ },
78
+ methods: {
79
+ handleChange(val) {
80
+ this.$emit("change", val);
81
+ },
82
+ clear() {
83
+ this.selected = '';
84
+ this.$emit('clear')
85
+ }
86
+ },
87
+ };
88
+ </script>
89
+
90
+ <style scoped>
91
+ /* 你可以在这里添加自定义样式 */
92
+ </style>