gyyg-components 0.2.1 → 0.2.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": "gyyg-components",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "private": false,
5
5
  "main": "lib/gyyg-components.umd.js",
6
6
  "scripts": {
package/src/App.vue CHANGED
@@ -1,46 +1,189 @@
1
1
  <template>
2
2
  <div id="app">
3
- <!-- <gyyg-layout>
4
- <template slot="table">
5
- <gyyg-table :data='data' @selection-change="change" >
6
- <template slot='content'>
7
- <el-table-column type="selection" width="55"> </el-table-column>
8
- <el-table-column prop='a'></el-table-column>
9
- </template>
10
- </gyyg-table>
11
- </template>
12
- </gyyg-layout> -->
3
+ <mec-input-table
4
+ :tableData="tableData"
5
+ :columns="columns"
6
+ :inputInfo="inputInfo"
7
+ @search="searchHandel"
8
+ @refresh="refreshHandel"
9
+ @row-click="rowClick"
10
+ ></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>
13
44
  </div>
14
45
  </template>
15
46
 
16
47
  <script>
48
+
17
49
  export default {
18
50
  name: 'App',
19
- data(){
20
- return{
21
- // text:'',
22
- // data:[
23
- // {
24
- // a:'1322'
25
- // }
26
- // ]
27
- }
51
+ data() {
52
+ const _this = this;
53
+ 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: ''
93
+ },
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
+ ]
108
+ },
109
+ regexInfo: /^(?:(?:\+|00)86)?1[3-9]\d{9}$/,
110
+ tableData: [
111
+ { name: 'hss', age: 18, dept: '技术部' },
112
+ { name: 'hss2', age: 18, dept: '技术部' }
113
+ ],
114
+ columns: [
115
+ {
116
+ label: '姓名',
117
+ bind: 'name'
118
+ },
119
+ {
120
+ label: '年龄',
121
+ bind: 'age',
122
+ },
123
+ {
124
+ label: '部门',
125
+ bind: 'dept'
126
+ }
127
+ ],
128
+ inputInfo: {
129
+ inputPlaceholder: '科室',
130
+ tablePlaceholder: '姓名/科室',
131
+ inputValue: ''
132
+ }
133
+ };
28
134
  },
29
- methods:{
30
- change(val){
31
- console.log(val)
135
+ methods: {
136
+ change(val) {
137
+ console.log(val);
138
+ },
139
+ validateRegex(rule, value, callback) {
140
+ const reg = this.regexInfo;
141
+ if (reg.test(value)) {
142
+ callback();
143
+ } else {
144
+ callback(new Error('请按正则输入内容'));
145
+ }
146
+ },
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('清除操作');
172
+ },
173
+ searchHandel(val) {
174
+ console.log(val);
175
+ },
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);
32
185
  }
33
- }
34
- }
35
- </script>
36
186
 
37
- <style>
38
- #app {
39
- font-family: Avenir, Helvetica, Arial, sans-serif;
40
- -webkit-font-smoothing: antialiased;
41
- -moz-osx-font-smoothing: grayscale;
42
- text-align: center;
43
- color: #2c3e50;
44
- margin-top: 60px;
45
- }
46
- </style>
187
+ }
188
+ };
189
+ </script>
@@ -0,0 +1,5 @@
1
+ import MecButtonGroup from "./MecButtonGroup.vue";
2
+
3
+ MecButtonGroup.install = Vue => Vue.component(MecButtonGroup.name, MecButtonGroup); //注册组件
4
+
5
+ export default MecButtonGroup;
@@ -0,0 +1,59 @@
1
+ <template>
2
+ <div class="btn-group">
3
+ <div v-for="btn in btnList" :key="btn.id">
4
+ <el-button
5
+ v-if="!btn['componentType']"
6
+ v-has-permi="[btn.hasPermi]"
7
+ :disabled="btn.disabled"
8
+ :size="btn.size"
9
+ :type="btn.type"
10
+ :icon="!btn.rightIcon ? btn.icon: ''"
11
+ :loading="btn.loading"
12
+ @click="btnClick(btn)"
13
+ >{{ btn.text }}
14
+ <i v-if="btn.rightIcon" :class="btn.icon + ' el-icon--right'"></i>
15
+ </el-button>
16
+ <div v-else>
17
+ <component
18
+ :is="btn['componentType']"
19
+ :btnInfo="btn"
20
+ ></component>
21
+ </div>
22
+ </div>
23
+
24
+ </div>
25
+ </template>
26
+ <script>
27
+
28
+ export default {
29
+ name: 'MecButtonGroup',
30
+ props: {
31
+ // 按钮组数据
32
+ btnList: {
33
+ required: true,
34
+ },
35
+ },
36
+ methods: {
37
+ // 按钮点击事件
38
+ btnClick(btn) {
39
+
40
+ if(btn.trigger){
41
+ btn.trigger()
42
+ }
43
+ }
44
+ },
45
+ }
46
+ </script>
47
+ <style lang="less" scoped>
48
+ .btn-group {
49
+ display: flex;
50
+ align-items: center;
51
+ flex-wrap: wrap;
52
+ &>div {
53
+ margin-left: 15px;
54
+ margin-bottom: 15px;
55
+ }
56
+ }
57
+ </style>
58
+
59
+
@@ -0,0 +1,5 @@
1
+ import MecInput from "./MecInput.vue";
2
+
3
+ MecInput.install = Vue => Vue.component(MecInput.name, MecInput); //注册组件
4
+
5
+ export default MecInput;
@@ -0,0 +1,127 @@
1
+ <template>
2
+ <el-input
3
+ v-model="inputValue"
4
+ :placeholder="placeholder"
5
+ :type="inputTypeValue"
6
+ :disabled="disabled"
7
+ :readonly="readonly"
8
+ :size="size"
9
+ :maxlength="maxlength"
10
+ :show-word-limit="showWordLimit"
11
+ :clearable="clearable"
12
+ :prefix-icon="prefixIcon"
13
+ :suffix-icon="suffixIcon"
14
+ :rows="rows"
15
+ :autosize="autosize"
16
+ @input="handleInput"
17
+ @clear="clear"
18
+ ></el-input>
19
+ </template>
20
+
21
+ <script>
22
+ export default {
23
+ name: 'MecInput',
24
+ props: {
25
+ // 输入框的占位符
26
+ placeholder: {
27
+ type: String,
28
+ default: ''
29
+ },
30
+ // 输入类型限制,可选值为 'number'(数字)、'chinese'(汉字)、'english'(英文字母)
31
+ inputType: {
32
+ type: String,
33
+ default: 'text'
34
+ },
35
+ // 输入框类型(对应原生input类型),如 'text'、'password'等
36
+ type: {
37
+ type: String,
38
+ default: 'text'
39
+ },
40
+ // 是否禁用
41
+ disabled: {
42
+ type: Boolean,
43
+ default: false
44
+ },
45
+ // 是否只读
46
+ readonly: {
47
+ type: Boolean,
48
+ default: false
49
+ },
50
+ // 尺寸大小,可选值'medium'、'small'、'mini'
51
+ size: {
52
+ type: String,
53
+ default: 'medium'
54
+ },
55
+ // 最大长度
56
+ maxlength: {
57
+ type: [Number, String],
58
+ default: -1
59
+ },
60
+ // 是否显示字数限制提示
61
+ showWordLimit: {
62
+ type: Boolean,
63
+ default: false
64
+ },
65
+ // 是否可清空
66
+ clearable: {
67
+ type: Boolean,
68
+ default: false
69
+ },
70
+ // 前缀图标名称
71
+ prefixIcon: {
72
+ type: String,
73
+ default: ''
74
+ },
75
+ // 后缀图标名称
76
+ suffixIcon: {
77
+ type: String,
78
+ default: ''
79
+ },
80
+ // 文本域行数(当type为'textarea'时有效)
81
+ rows: {
82
+ default: 1
83
+ },
84
+ // 文本域是否自适应大小(当type为'textarea'时有效)
85
+ autosize: {
86
+ default: false
87
+ },
88
+ },
89
+ data() {
90
+ return {
91
+ inputValue: ''
92
+ };
93
+ },
94
+ computed: {
95
+ inputTypeValue() {
96
+ return this.inputType === 'textarea'? 'textarea' : this.type;
97
+ }
98
+ },
99
+ methods: {
100
+ handleInput(val) {
101
+ let value = val;
102
+
103
+ if (this.inputType === 'number') {
104
+ // 只允许输入数字
105
+ value = value.replace(/[^0-9]/g, '');
106
+ } else if (this.inputType === 'chinese') {
107
+ // 只允许输入汉字
108
+ value = value.replace(/[^\u4e00-\u9fa5]/g, '');
109
+ } else if (this.inputType === 'english') {
110
+ // 只允许输入英文
111
+ value = value.replace(/[^a-zA-Z]/g, '');
112
+ }
113
+ this.inputValue = value
114
+
115
+ this.$emit('input', value);
116
+ },
117
+ clear() {
118
+ this.$emit('clear')
119
+ }
120
+ },
121
+ watch: {
122
+ value(newValue) {
123
+ this.inputValue = newValue;
124
+ }
125
+ }
126
+ };
127
+ </script>
@@ -0,0 +1,5 @@
1
+ import MecInputTable from "./MecInputTable.vue";
2
+
3
+ MecInputTable.install = Vue => Vue.component(MecInputTable.name, MecInputTable); //注册组件
4
+
5
+ export default MecInputTable;
@@ -0,0 +1,106 @@
1
+ <template>
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>
30
+ </el-dropdown>
31
+ </div>
32
+ </template>
33
+
34
+ <script>
35
+ export default {
36
+ name: 'MecInputTable',
37
+ props: {
38
+ tableData: {
39
+ type: Array,
40
+ default: () => []
41
+ },
42
+ columns: {
43
+ type: Array,
44
+ default: () => []
45
+ },
46
+ inputInfo: {
47
+ default: {}
48
+ }
49
+ },
50
+ data() {
51
+ return {
52
+ inputValue: '',
53
+ showDropdown: false,
54
+ tableInput: ''
55
+ };
56
+ },
57
+ methods: {
58
+ handleTableRowClick(row) {
59
+ this.$emit('row-click', row)
60
+ this.showDropdown = false;
61
+ },
62
+ visibleChange(val) {
63
+ this.showDropdown = val
64
+ },
65
+ tableInputHandel(val) {
66
+ this.$emit('input', val)
67
+ },
68
+ search() {
69
+ this.$emit('search', this.tableInput)
70
+ },
71
+ refresh() {
72
+ this.tableInput = ''
73
+ this.$emit('refresh')
74
+ }
75
+
76
+ },
77
+ watch: {
78
+ 'inputInfo.inputValue': {
79
+ handler(val) {
80
+ this.inputValue = val
81
+ },
82
+ immediate: true,
83
+ deep: true
84
+ },
85
+ }
86
+ };
87
+ </script>
88
+ <style lang="less" scoped>
89
+ .mec-input-table {
90
+ /deep/ .el-dropdown-menu__item {
91
+ line-height: 0;
92
+ padding: 0;
93
+ }
94
+ }
95
+ .search-table {
96
+ padding: 0 10px;
97
+ display: flex;
98
+ align-items: center;
99
+ /deep/ .el-input {
100
+ width: 150px;
101
+ }
102
+ /deep/ .el-button {
103
+ margin-left: 15px;
104
+ }
105
+ }
106
+ </style>
@@ -0,0 +1,5 @@
1
+ import MecPopoverButton from "./MecPopoverButton.vue";
2
+
3
+ MecPopoverButton.install = Vue => Vue.component(MecPopoverButton.name, MecPopoverButton); //注册组件
4
+
5
+ export default MecPopoverButton;
@@ -0,0 +1,47 @@
1
+ <template>
2
+ <div class="popover-button" v-has-permi="[btnInfo.hasPermi]">
3
+ <el-dropdown
4
+ :size="btnInfo.size"
5
+ split-button
6
+ :type="btnInfo.type"
7
+ :disabled="btnInfo.disabled"
8
+ trigger="click"
9
+ placement="bottom-end"
10
+ @click="clickEvent"
11
+ @command="changeItem"
12
+ >
13
+ {{ btnInfo.text}}
14
+ <el-dropdown-menu slot="dropdown" class="right-arrow">
15
+ <el-dropdown-item
16
+ v-for="item in btnInfo.options"
17
+ :key="item.id"
18
+ :command="item"
19
+ >{{ item.label }}</el-dropdown-item>
20
+ </el-dropdown-menu>
21
+ </el-dropdown>
22
+ </div>
23
+ </template>
24
+ <script>
25
+ export default {
26
+ name: 'MecPopoverButton',
27
+ props: ['btnInfo'],
28
+ methods: {
29
+ clickEvent(){
30
+ if(this.btnInfo.trigger) {
31
+ this.btnInfo.trigger()
32
+ }
33
+ },
34
+ changeItem(value) {
35
+ this.btnInfo.callback(value)
36
+
37
+ }
38
+ }
39
+ }
40
+ </script>
41
+ <style lang="less" scoped>
42
+ .right-arrow {
43
+ /deep/ .popper__arrow {
44
+ left: 65% !important;
45
+ }
46
+ }
47
+ </style>
@@ -17,6 +17,7 @@
17
17
  @select="select"
18
18
  :row-style="selectedRowStyle"
19
19
  :default-expand-all="defaultExpandAll"
20
+ @row-click="rowClickHandel"
20
21
  >
21
22
  <!-- 多选框 -->
22
23
  <el-table-column
@@ -178,6 +179,10 @@ export default {
178
179
  // 是否默认展开所有行
179
180
  defaultExpandAll: {
180
181
  default: false,
182
+ },
183
+ // 是否只选中当前行
184
+ toggleRow: {
185
+ default: false
181
186
  }
182
187
  },
183
188
  data() {
@@ -219,6 +224,14 @@ export default {
219
224
  this.multipleSelection = column
220
225
  this.$emit('selection-change', column);
221
226
  },
227
+ // 行点击触发的事件
228
+ rowClickHandel(column) {
229
+ if(this.toggleRow) {
230
+ this.$refs.table.clearSelection()
231
+ this.$refs.table.toggleRowSelection(column)
232
+ }
233
+ this.$emit('row-click', column)
234
+ }
222
235
 
223
236
  },
224
237
  watch: {
@@ -0,0 +1,29 @@
1
+ /**
2
+ * 操作权限处理
3
+ * Copyright (c) 2019 chuangshi
4
+ */
5
+ import Vue from 'vue'
6
+ let authorities = localStorage.getItem('authorities') || 'aaa,bbb,ccc'
7
+ Vue.directive('hasPermi', {
8
+ inserted(el, binding, vnode) {
9
+ const { value } = binding
10
+ const all_permission = "*:*:*";
11
+ const permissions = authorities.split(',')//用户拥有的权限
12
+ if (value && value instanceof Array && value.length > 0) {
13
+ const permissionFlag = value//
14
+
15
+ const hasPermissions = permissions.some(permission => {
16
+ return all_permission === permission || permissionFlag.includes(permission)
17
+ })
18
+ console.log(hasPermissions,'hasPermissions')
19
+ if (!hasPermissions) {
20
+ console.log(el.parentNode);
21
+
22
+ el.parentNode && el.parentNode.removeChild(el)
23
+ }
24
+ } else {
25
+ throw new Error(`请设置操作权限标签值`)
26
+ }
27
+ }
28
+ })
29
+
package/src/main.js CHANGED
@@ -2,16 +2,8 @@ import Vue from 'vue'
2
2
  import App from './App.vue'
3
3
 
4
4
  Vue.config.productionTip = false
5
- import { Dialog,Button,Pagination,Input,Table,TableColumn,Icon, Switch, Tooltip } from 'element-ui';
6
- Vue.use(Dialog)
7
- Vue.use(Button)
8
- Vue.use(Pagination)
9
- Vue.use(Input)
10
- Vue.use(Table)
11
- Vue.use(TableColumn)
12
- Vue.use(Icon)
13
- Vue.use(Switch)
14
- Vue.use(Tooltip)
5
+ import ElementUI from 'element-ui';
6
+ Vue.use(ElementUI)
15
7
 
16
8
  import zj from '@/index.js'
17
9
  Vue.use(zj)