gyyg-components 0.2.4 → 0.2.6

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.4",
3
+ "version": "0.2.6",
4
4
  "private": false,
5
5
  "main": "lib/gyyg-components.umd.js",
6
6
  "scripts": {
package/src/App.vue CHANGED
@@ -1,189 +1,75 @@
1
1
  <template>
2
2
  <div id="app">
3
3
  <mec-input-table
4
- :tableData="tableData"
5
- :columns="columns"
6
- :inputInfo="inputInfo"
7
- @search="searchHandel"
8
- @refresh="refreshHandel"
9
- @row-click="rowClick"
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"
10
14
  ></mec-input-table>
11
- <mec-button-group :btnList="btnList"></mec-button-group>
12
- <el-form ref="form" :model="formData" :rules="rules" label-width="100px">
13
- <el-form-item label="数字输入框" prop="numberInput">
14
- <mec-input placeholder="请输入数字" inputType="number" type="number" v-model="formData.numberInput"></mec-input>
15
- </el-form-item>
16
- <el-form-item label="汉字输入框" prop="chineseInput">
17
- <mec-input placeholder="请输入汉字" inputType="chinese" type="text" v-model="formData.chineseInput"></mec-input>
18
- </el-form-item>
19
- <el-form-item label="英文输入框" prop="englishInput">
20
- <mec-input placeholder="请输入英文" inputType="english" type="text" v-model="formData.englishInput"></mec-input>
21
- </el-form-item>
22
- <el-form-item label="自定义正则输入框" prop="regexInput">
23
- <mec-input placeholder="请按正则输入" inputType="regex" type="text" :maxlength="11" v-model="formData.regexInput">
24
- </mec-input>
25
- </el-form-item>
26
- <el-form-item label="正常输入框" prop="input">
27
- <mec-input placeholder="输入" type="text" :clearable="true" v-model="formData.input" @clear="clear">
28
- </mec-input>
29
- </el-form-item>
30
- <el-form-item label="文本域" prop="input">
31
- <mec-input placeholder="输入" type="textarea" v-model="formData.textarea" :autosize="{minRows: 2, maxRows: 4}" :rows="2">
32
- </mec-input>
33
- </el-form-item>
34
- <el-button @click="submitForm">提交</el-button>
35
- </el-form>
36
- <mec-table
37
- :tableData="tableData"
38
- :columns="columns"
39
- :selection="true"
40
- @selection-change="selectionChange"
41
- @row-click="rowClick"
42
- :highlightSelectionRow="true"
43
- ></mec-table>
44
15
  </div>
16
+
45
17
  </template>
46
18
 
47
19
  <script>
48
20
 
49
21
  export default {
50
- name: 'App',
51
22
  data() {
52
- const _this = this;
53
23
  return {
54
- btnList: [
55
- // 按钮列表配置
56
- {
57
- text: '转资审租',
58
- componentType: 'mec-popover-button',
59
- size: 'medium',
60
- type: 'primary',
61
- disabled: false,
62
- id: 'popover',
63
- options: [
64
- {
65
- label: '转谈判组',
66
- value: '1',
67
- },
68
- {
69
- label: '转呈批组',
70
- value: '1',
71
- },
72
- {
73
- label: '转签约组',
74
- value: '1',
75
- },
76
- ],
77
- trigger() {
78
- console.log('按钮点击');
79
- },
80
- callback(row) {
81
- console.log(row);
82
-
83
- }
84
- }
85
- ],
86
- formData: {
87
- numberInput: '',
88
- chineseInput: '',
89
- regexInput: '',
90
- englishInput: '',
91
- input: '',
92
- textarea: ''
24
+ inputInfo: {
25
+ inputPlaceholder: '请输入',
26
+ clearable: true,
27
+ disabled: false,
28
+ tablePlaceholder: '请输入'
93
29
  },
94
- rules: {
95
- numberInput: [
96
- { required: true, message: '数字输入框不能为空', trigger: 'blur' },
97
- ],
98
- chineseInput: [
99
- { required: true, message: '汉字输入框不能为空', trigger: 'blur' },
100
- ],
101
- englishInput: [
102
- { required: true, message: '英文输入框不能为空', trigger: 'blur' },
103
- ],
104
- regexInput: [
105
- { required: true, message: '自定义正则输入框不能为空', trigger: 'blur' },
106
- { validator: this.validateRegex, message: '请按正则输入内容', trigger: 'blur' }
107
- ]
30
+ showSearch: true,
31
+ showSelection: true,
32
+ height: '200',
33
+ page: {
34
+ currentPage: 1,
35
+ total: 100,
36
+ pageSize: 20,
108
37
  },
109
- regexInfo: /^(?:(?:\+|00)86)?1[3-9]\d{9}$/,
110
38
  tableData: [
111
- { name: 'hss', age: 18, dept: '技术部' },
112
- { name: 'hss2', age: 18, dept: '技术部' }
39
+ { name: '数据1', value: 'value1' },
40
+ { name: '数据2', value: 'value2' },
41
+ { name: '数据3', value: 'value3' },
113
42
  ],
114
43
  columns: [
115
44
  {
116
- label: '姓名',
117
- bind: 'name'
45
+ bind: 'name',
46
+ label: '姓名'
118
47
  },
119
48
  {
120
- label: '年龄',
121
- bind: 'age',
122
- },
123
- {
124
- label: '部门',
125
- bind: 'dept'
49
+ label: '编码',
50
+ bind: 'value'
126
51
  }
127
- ],
128
- inputInfo: {
129
- inputPlaceholder: '科室',
130
- tablePlaceholder: '姓名/科室',
131
- inputValue: ''
132
- }
52
+ ]
133
53
  };
134
54
  },
135
55
  methods: {
136
- change(val) {
137
- console.log(val);
56
+ handleRowClick(row) {
57
+ console.log('Row clicked:', row);
138
58
  },
139
- validateRegex(rule, value, callback) {
140
- const reg = this.regexInfo;
141
- if (reg.test(value)) {
142
- callback();
143
- } else {
144
- callback(new Error('请按正则输入内容'));
145
- }
59
+ handlePageSizeChange(val) {
60
+ console.log('Page size changed:', val);
61
+ // 在这里处理 page-size-change 事件
146
62
  },
147
- submitForm() {
148
- this.$refs.form.validate((valid) => {
149
- if (valid) {
150
- console.log('表单验证通过');
151
- } else {
152
- console.log('表单验证失败');
153
- }
154
- });
155
- },
156
- updateArrayById(arr, updateConfigs) {
157
- const newArray = arr.map(item => ({ ...item }));
158
- updateConfigs.forEach(config => {
159
- const index = newArray.findIndex(el => el.id === config.id);
160
- if (index !== -1) {
161
- for (const key in config) {
162
- if (key !== 'id') {
163
- newArray[index][key] = config[key];
164
- }
165
- }
166
- }
167
- });
168
- return newArray;
169
- },
170
- clear() {
171
- console.log('清除操作');
63
+ handlePageChange(val) {
64
+ console.log('Page changed:', val);
172
65
  },
173
- searchHandel(val) {
174
- console.log(val);
66
+ handleCurrentChange(val) {
67
+ console.log('Current change:', val);
175
68
  },
176
- refreshHandel() {
177
- console.log('重置')
178
- },
179
- rowClick(row) {
180
- console.log(row);
181
- this.inputInfo.inputValue = row.name // 赋值操作
182
- },
183
- selectionChange(val) {
184
- console.log(val, 123);
69
+ show() {
70
+ console.log('显示');
71
+
185
72
  }
186
-
187
73
  }
188
74
  };
189
75
  </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">
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,8 +59,23 @@ 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: {}
68
+ },
69
+ showSearch:{
70
+ type: Boolean,
71
+ dafault: true
72
+ },
73
+ page: {
74
+ default: {}
75
+ },
76
+ toggleRow: {
77
+ type: Boolean,
78
+ default: true
48
79
  }
49
80
  },
50
81
  data() {
@@ -55,12 +86,18 @@ export default {
55
86
  };
56
87
  },
57
88
  methods: {
58
- handleTableRowClick(row) {
89
+ rowClick(row) {
90
+ if(this.toggleRow) {
91
+ this.$refs.dropdown.hide()
92
+ }
59
93
  this.$emit('row-click', row)
60
- this.showDropdown = false;
61
94
  },
62
95
  visibleChange(val) {
63
96
  this.showDropdown = val
97
+ if(val) {
98
+ this.$emit('show')
99
+ }
100
+
64
101
  },
65
102
  tableInputHandel(val) {
66
103
  this.$emit('input', val)
@@ -71,6 +108,13 @@ export default {
71
108
  refresh() {
72
109
  this.tableInput = ''
73
110
  this.$emit('refresh')
111
+ },
112
+ handleSizeChange(val) {
113
+ this.$refs.dropdown.show()
114
+ this.$emit('size-change', val)
115
+ },
116
+ handleCurrentChange(val) {
117
+ this.$emit('current-change', val)
74
118
  }
75
119
 
76
120
  },
@@ -103,4 +147,7 @@ export default {
103
147
  margin-left: 15px;
104
148
  }
105
149
  }
150
+ /deep/ .el-pagination {
151
+ margin-top: 15px;
152
+ }
106
153
  </style>