gyyg-components 0.3.18 → 0.3.19

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.3.18",
3
+ "version": "0.3.19",
4
4
  "private": false,
5
5
  "main": "lib/gyyg-components.umd.js",
6
6
  "scripts": {
@@ -1,100 +1,128 @@
1
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)"
16
- :rules="item.rules"
17
- :class="item.class"
18
- :label-width="item.labelWidth">
19
- <template slot="label">
20
- <span v-if="item.label">
21
- <span :style="'color:' + item.labelColor">{{ item.label }}</span>
22
- <el-tooltip v-if="item.tooltip" class="item" effect="dark" :content="item.tooltip" placement="top">
23
- <i class="el-icon-question"></i>
24
- </el-tooltip>
25
- </span>
26
- </template>
27
- <component
28
- :is="item['componentName']"
29
- v-model="item.value"
30
- :value.sync="item.value"
31
- :otherValue.sync="item.otherValue"
32
- :delIdList.sync="item.delIdList"
33
- v-bind="item"
34
- v-on="item.componentListeners"
35
- ></component>
36
- </el-form-item>
37
- </el-col>
38
- </template>
39
- </el-form>
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="
11
+ typeof item.displayWith !== 'function' ||
12
+ item.displayWith(formData, item)
13
+ "
14
+ :span="item.col"
15
+ :style="item.style"
16
+ :key="index"
17
+ >
18
+ <el-form-item
19
+ v-bind="item"
20
+ :prop="getProp(item, index)"
21
+ :rules="item.rules"
22
+ :class="item.class"
23
+ :label-width="item.labelWidth"
24
+ >
25
+ <template slot="label">
26
+ <span v-if="item.label">
27
+ <span :style="'color:' + item.labelColor">{{ item.label }}</span>
28
+ <el-tooltip
29
+ v-if="item.tooltip"
30
+ class="item"
31
+ effect="dark"
32
+ :content="item.tooltip"
33
+ placement="top"
34
+ >
35
+ <i class="el-icon-question"></i>
36
+ </el-tooltip>
37
+ </span>
38
+ </template>
39
+ <component
40
+ :is="item['componentName']"
41
+ v-model="item.value"
42
+ :value.sync="item.value"
43
+ :otherValue.sync="item.otherValue"
44
+ :delIdList.sync="item.delIdList"
45
+ v-bind="item"
46
+ v-on="item.componentListeners"
47
+ ></component>
48
+ </el-form-item>
49
+ </el-col>
50
+ </template>
51
+ </el-form>
40
52
  </template>
41
53
  <script>
42
54
  export default {
43
- name: 'mec-form',
44
- props: {
45
- formData: {
46
- required: true,
47
- },
48
- labelWidth: {
49
- type: String,
50
- default: '150px',
51
- },
52
- labelPosition: {
53
- type: String,
54
- default: 'right',
55
- },
56
- },
57
- data() {
58
- return {
59
- loading: false,
60
- };
61
- },
62
- computed: {},
63
- methods: {
64
- getProp(item, index) {
65
- let propName = item.prop ? item.prop : index + ".value";
66
- return propName;
67
- },
68
- validate() {
69
- return new Promise((resolve, reject) => {
70
- this.$refs.formData.validate(valid => {
71
- if (valid) {
72
- resolve(true);
73
- } else {
74
- resolve(false);
75
- }
76
- });
77
- });
78
- },
79
- clearValidate() {
80
- this.$refs.formData.clearValidate();
81
- },
82
- },
55
+ name: "mec-form",
56
+ props: {
57
+ formData: {
58
+ required: true,
59
+ },
60
+ labelWidth: {
61
+ type: String,
62
+ default: "150px",
63
+ },
64
+ labelPosition: {
65
+ type: String,
66
+ default: "right",
67
+ },
68
+ showErrMsg: {
69
+ type: Boolean,
70
+ default: false,
71
+ },
72
+ },
73
+ data() {
74
+ return {
75
+ loading: false,
76
+ };
77
+ },
78
+ computed: {},
79
+ methods: {
80
+ getProp(item, index) {
81
+ let propName = item.prop ? item.prop : index + ".value";
82
+ return propName;
83
+ },
84
+ validate() {
85
+ return new Promise((resolve) => {
86
+ this.$refs.formData.validate((valid, info) => {
87
+ if (valid) {
88
+ if (this.showErrMsg) {
89
+ resolve({ valid: true, errorMsg: [] });
90
+ } else {
91
+ resolve(true);
92
+ }
93
+ } else {
94
+ let errorMsg = [];
95
+ for (let key in info) {
96
+ console.log(info[key]);
97
+ errorMsg.push(info[key][0].message);
98
+ }
99
+ if (this.showErrMsg) {
100
+ resolve({ valid: false, errorMsg: errorMsg });
101
+ } else {
102
+ resolve(false);
103
+ }
104
+ }
105
+ });
106
+ });
107
+ },
108
+ clearValidate() {
109
+ this.$refs.formData.clearValidate();
110
+ },
111
+ },
83
112
  };
84
113
  </script>
85
114
  <style lang="less" scoped>
86
115
  ::v-deep.el-form::after {
87
- content: "";
88
- display: table;
89
- clear: both;
116
+ content: "";
117
+ display: table;
118
+ clear: both;
90
119
  }
91
120
  ::v-deep.el-form--label-top {
92
- .el-col {
93
- padding-right: 15px;
94
- }
95
- .el-form-item {
96
- margin-bottom: 12px;
97
- }
121
+ .el-col {
122
+ padding-right: 15px;
123
+ }
124
+ .el-form-item {
125
+ margin-bottom: 12px;
126
+ }
98
127
  }
99
-
100
128
  </style>
@@ -150,6 +150,8 @@
150
150
  if (value.split('.').length > 2) {
151
151
  value = value.replace(/\.+$/, '');
152
152
  }
153
+ } else if (this.inputType === 'englishAndNumber') {
154
+ value = value.replace(/[^a-zA-Z0-9\s]/g, '');
153
155
  }
154
156
  this.inputValue = value
155
157
  this.$emit('input', value);
@@ -12,7 +12,15 @@
12
12
  :key="item[props.value]"
13
13
  :value="item[props.value]"
14
14
  :border="border"
15
- >{{ item[props.label] }}</el-radio>
15
+ >{{ item[props.label] }}
16
+ </el-radio>
17
+ <el-input
18
+ v-if="showOther"
19
+ v-model="inputValue"
20
+ :disabled="inputDisabled"
21
+ placeholder="请输入"
22
+ style="display: inline-block; margin-top: 10px;" />
23
+ <!-- @input="inputChange" -->
16
24
  </el-radio-group>
17
25
  </template>
18
26
  <script>
@@ -33,11 +41,25 @@ export default {
33
41
  }
34
42
  },
35
43
  },
44
+ showOther: {
45
+ type: Boolean,
46
+ default: false
47
+ },
48
+ checkText: {
49
+ default() {
50
+ return '其他'
51
+ }
52
+ },
53
+ otherValue: {
54
+ default: ""
55
+ }
36
56
  },
37
57
  data() {
38
58
  return {
39
59
  radio: this.value,
40
- option: []
60
+ option: [],
61
+ inputValue: '',
62
+ inputDisabled: true
41
63
  }
42
64
  },
43
65
  watch: {
@@ -68,18 +90,44 @@ export default {
68
90
  }
69
91
 
70
92
  } else {
71
- this.option = this.options;
93
+ this.option = val;
94
+ }
95
+ let name = this.getNameById(this.value, this.option)
96
+ if(name.includes(this.checkText)) {
97
+ this.inputDisabled = false
98
+ } else {
99
+ this.inputDisabled = true
72
100
  }
73
101
  },
74
102
  deep: true,
75
103
  immediate: true,
76
104
  },
105
+ otherValue: {
106
+ handler(val) {
107
+ this.inputValue = val;
108
+ console.log(val, 'otherValue')
109
+ },
110
+ immediate: true
111
+ }
77
112
  },
78
113
  methods: {
79
114
  handleChange(val) {
80
115
  let info = this.option.filter(item => item[this.props.value] === val)
116
+ let name = this.getNameById(val, this.option)
117
+ if(name.includes(this.checkText)) {
118
+ this.inputDisabled = false
119
+ } else {
120
+ this.inputDisabled = true
121
+ this.inputValue = ''
122
+ }
81
123
  this.$emit('change', val, info.length > 0 ? info[0] : {})
82
124
  },
125
+ // 根据 id 数组获取对应的 name 列表
126
+ getNameById(id, array) {
127
+ console.log(id, array)
128
+ if(!id) return ''
129
+ return array[array.findIndex(item => item[this.props.value] === id)][this.props.label]
130
+ },
83
131
  }
84
132
 
85
133
  }
@@ -47,7 +47,7 @@
47
47
  :width="col.width"
48
48
  :sortable="col.sortable"
49
49
  :show-overflow-tooltip="col.showOverflowTooltip"
50
- :key="index"
50
+ :key="col.id"
51
51
  :fixed="col.fixed"
52
52
  :prop="col.bind"
53
53
  >
@@ -205,7 +205,7 @@ export default {
205
205
  required: false,
206
206
  default: () => {
207
207
  return {
208
- backgroundColor: "#EFF3F8",
208
+ backgroundColor: "#efefef",
209
209
  fontWeight: 'normal',
210
210
  color: '#303133',
211
211
  }
@@ -276,6 +276,7 @@ export default {
276
276
  data() {
277
277
  return {
278
278
  multipleSelection: [],
279
+ column: []
279
280
  }
280
281
  },
281
282
  methods: {
@@ -329,8 +330,8 @@ export default {
329
330
  watch: {
330
331
  columns: {
331
332
  handler: function (val) {
332
-
333
- this.column = val;
333
+ console.log(val);
334
+ this.column = [...val];
334
335
  },
335
336
  immediate: true,
336
337
  deep: true,
@@ -343,7 +344,9 @@ export default {
343
344
  background-color: #fff;
344
345
  height: 100%;
345
346
  }
346
-
347
+ /deep/ .el-table {
348
+ margin-bottom: 10px;
349
+ }
347
350
  .pagination-layout {
348
351
  text-align: right;
349
352
  padding: 0px 10px 5px 0;
@@ -385,4 +388,5 @@ export default {
385
388
  font-size: 15px;
386
389
  color: #F56C6C;
387
390
  }
391
+
388
392
  </style>