gyyg-components 0.2.1 → 0.2.2

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.2",
4
4
  "private": false,
5
5
  "main": "lib/gyyg-components.umd.js",
6
6
  "scripts": {
package/src/App.vue CHANGED
@@ -1,46 +1,149 @@
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>
13
36
  </div>
14
37
  </template>
15
38
 
16
39
  <script>
40
+
17
41
  export default {
18
42
  name: 'App',
19
- data(){
20
- return{
21
- // text:'',
22
- // data:[
23
- // {
24
- // a:'1322'
25
- // }
26
- // ]
27
- }
43
+ data() {
44
+ const _this = this;
45
+ return {
46
+ btnList: [
47
+ // 按钮列表配置
48
+ ],
49
+ formData: {
50
+ numberInput: '',
51
+ chineseInput: '',
52
+ regexInput: '',
53
+ englishInput: '',
54
+ input: '',
55
+ textarea: ''
56
+ },
57
+ rules: {
58
+ numberInput: [
59
+ { required: true, message: '数字输入框不能为空', trigger: 'blur' },
60
+ ],
61
+ chineseInput: [
62
+ { required: true, message: '汉字输入框不能为空', trigger: 'blur' },
63
+ ],
64
+ englishInput: [
65
+ { required: true, message: '英文输入框不能为空', trigger: 'blur' },
66
+ ],
67
+ regexInput: [
68
+ { required: true, message: '自定义正则输入框不能为空', trigger: 'blur' },
69
+ { validator: this.validateRegex, message: '请按正则输入内容', trigger: 'blur' }
70
+ ]
71
+ },
72
+ regexInfo: /^(?:(?:\+|00)86)?1[3-9]\d{9}$/,
73
+ tableData: [
74
+ { name: 'hss', age: 18, dept: '技术部' },
75
+ { name: 'hss2', age: 18, dept: '技术部' }
76
+ ],
77
+ columns: [
78
+ {
79
+ label: '姓名',
80
+ bind: 'name'
81
+ },
82
+ {
83
+ label: '年龄',
84
+ bind: 'age',
85
+ },
86
+ {
87
+ label: '部门',
88
+ bind: 'dept'
89
+ }
90
+ ],
91
+ inputInfo: {
92
+ inputPlaceholder: '科室',
93
+ tablePlaceholder: '姓名/科室',
94
+ inputValue: ''
95
+ }
96
+ };
28
97
  },
29
- methods:{
30
- change(val){
31
- console.log(val)
98
+ methods: {
99
+ change(val) {
100
+ console.log(val);
101
+ },
102
+ validateRegex(rule, value, callback) {
103
+ const reg = this.regexInfo;
104
+ if (reg.test(value)) {
105
+ callback();
106
+ } else {
107
+ callback(new Error('请按正则输入内容'));
108
+ }
109
+ },
110
+ submitForm() {
111
+ this.$refs.form.validate((valid) => {
112
+ if (valid) {
113
+ console.log('表单验证通过');
114
+ } else {
115
+ console.log('表单验证失败');
116
+ }
117
+ });
118
+ },
119
+ updateArrayById(arr, updateConfigs) {
120
+ const newArray = arr.map(item => ({ ...item }));
121
+ updateConfigs.forEach(config => {
122
+ const index = newArray.findIndex(el => el.id === config.id);
123
+ if (index !== -1) {
124
+ for (const key in config) {
125
+ if (key !== 'id') {
126
+ newArray[index][key] = config[key];
127
+ }
128
+ }
129
+ }
130
+ });
131
+ return newArray;
132
+ },
133
+ clear() {
134
+ console.log('清除操作');
135
+ },
136
+ searchHandel(val) {
137
+ console.log(val);
138
+ },
139
+ refreshHandel() {
140
+ console.log('重置')
141
+ },
142
+ rowClick(row) {
143
+ console.log(row);
144
+ this.inputInfo.inputValue = row.name // 赋值操作
32
145
  }
33
- }
34
- }
35
- </script>
36
146
 
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>
147
+ }
148
+ };
149
+ </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,132 @@
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'(英文字母)、'regex'(自定义正则)
31
+ inputType: {
32
+ type: String,
33
+ default: 'text'
34
+ },
35
+ // 当inputType为'regex'时,传入的正则表达式字符串
36
+ regex: {
37
+ type: String,
38
+ default: ''
39
+ },
40
+ // 输入框类型(对应原生input类型),如 'text'、'password'等
41
+ type: {
42
+ type: String,
43
+ default: 'text'
44
+ },
45
+ // 是否禁用
46
+ disabled: {
47
+ type: Boolean,
48
+ default: false
49
+ },
50
+ // 是否只读
51
+ readonly: {
52
+ type: Boolean,
53
+ default: false
54
+ },
55
+ // 尺寸大小,可选值'medium'、'small'、'mini'
56
+ size: {
57
+ type: String,
58
+ default: 'medium'
59
+ },
60
+ // 最大长度
61
+ maxlength: {
62
+ type: [Number, String],
63
+ default: -1
64
+ },
65
+ // 是否显示字数限制提示
66
+ showWordLimit: {
67
+ type: Boolean,
68
+ default: false
69
+ },
70
+ // 是否可清空
71
+ clearable: {
72
+ type: Boolean,
73
+ default: false
74
+ },
75
+ // 前缀图标名称
76
+ prefixIcon: {
77
+ type: String,
78
+ default: ''
79
+ },
80
+ // 后缀图标名称
81
+ suffixIcon: {
82
+ type: String,
83
+ default: ''
84
+ },
85
+ // 文本域行数(当type为'textarea'时有效)
86
+ rows: {
87
+ default: 1
88
+ },
89
+ // 文本域是否自适应大小(当type为'textarea'时有效)
90
+ autosize: {
91
+ default: false
92
+ },
93
+ },
94
+ data() {
95
+ return {
96
+ inputValue: ''
97
+ };
98
+ },
99
+ computed: {
100
+ inputTypeValue() {
101
+ return this.inputType === 'textarea'? 'textarea' : this.type;
102
+ }
103
+ },
104
+ methods: {
105
+ handleInput(val) {
106
+ let value = val;
107
+
108
+ if (this.inputType === 'number') {
109
+ // 只允许输入数字
110
+ value = value.replace(/[^0-9]/g, '');
111
+ } else if (this.inputType === 'chinese') {
112
+ // 只允许输入汉字
113
+ value = value.replace(/[^\u4e00-\u9fa5]/g, '');
114
+ } else if (this.inputType === 'english') {
115
+ // 只允许输入英文
116
+ value = value.replace(/[^a-zA-Z]/g, '');
117
+ }
118
+ this.inputValue = value
119
+
120
+ this.$emit('input', value);
121
+ },
122
+ clear() {
123
+ this.$emit('clear')
124
+ }
125
+ },
126
+ watch: {
127
+ value(newValue) {
128
+ this.inputValue = newValue;
129
+ }
130
+ }
131
+ };
132
+ </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
@@ -219,6 +220,10 @@ export default {
219
220
  this.multipleSelection = column
220
221
  this.$emit('selection-change', column);
221
222
  },
223
+ // 行点击触发的事件
224
+ rowClickHandel(column) {
225
+ this.$emit('row-click', column)
226
+ }
222
227
 
223
228
  },
224
229
  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)