gyyg-components 0.2.16 → 0.2.18

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.16",
3
+ "version": "0.2.18",
4
4
  "private": false,
5
5
  "main": "lib/gyyg-components.umd.js",
6
6
  "scripts": {
@@ -1,9 +1,21 @@
1
1
  <template>
2
- <div>{{ value }}</div>
2
+ <div :class="textType == 'littleTitle' ? 'title' : ''">{{ value }}</div>
3
3
  </template>
4
4
  <script>
5
5
  export default {
6
6
  name: 'mec-defaultText',
7
- props:['value']
7
+ props:['value', 'textType']
8
8
  }
9
- </script>
9
+ </script>
10
+ <style lang="less" scoped>
11
+ .title {
12
+ padding-left: 10px;
13
+ height: 30px;
14
+ line-height: 30px;
15
+ background: #efefef;
16
+ margin-bottom: 10px;
17
+ font-weight: bold;
18
+ font-size: 14px;
19
+ width: 100%;
20
+ }
21
+ </style>
@@ -0,0 +1,5 @@
1
+ import MECDescriptions from "./MECDescriptions.vue";
2
+
3
+ MECDescriptions.install = Vue => Vue.component(MECDescriptions.name, MECDescriptions); //注册组件
4
+
5
+ export default MECDescriptions;
@@ -0,0 +1,99 @@
1
+ <template>
2
+ <div>
3
+ <el-descriptions :column="column" :title="title" :extra="extra" :direction="direction" :border="border">
4
+ <template #title>
5
+ <div class="title">{{ title }}</div>
6
+ <div class="top-content">
7
+ <slot name="topContent"></slot>
8
+
9
+ </div>
10
+ </template>
11
+
12
+ <el-descriptions-item v-for="(item, index) in detailsData" :key="index" :label="item.label" :span="item.span || 1">
13
+ <div v-if="item.type === 'img'">
14
+ <el-image
15
+ v-for="(url, index) in item.value"
16
+ :key="index"
17
+ style="width: 100px; height: 100px; margin-right: 10px;"
18
+ :src="url"
19
+ :preview-src-list="item.value">
20
+ </el-image>
21
+ </div>
22
+ <div v-else-if="item.type === 'voice'">
23
+ <audio controls="controls" style="width: 240px; height: 40px;" v-for="item in item.value" :key="item.id">
24
+ <source :src="item" type="audio/mp3">
25
+ </audio>
26
+ </div>
27
+ <span v-else>{{ item.value }}</span>
28
+ </el-descriptions-item>
29
+ </el-descriptions>
30
+ </div>
31
+ </template>
32
+ <script>
33
+ export default {
34
+ name: 'mec-descriptions',
35
+ props: {
36
+ // 详细信息
37
+ detailsData: {
38
+ type: Array,
39
+ default: () => {
40
+ return [];
41
+ }
42
+ },
43
+ // 列数
44
+ column: {
45
+ type: Number,
46
+ default: 3
47
+ },
48
+ // 标题
49
+ title: {
50
+ type: String,
51
+ default: ''
52
+ },
53
+ // 右边的文本
54
+ extra: {
55
+ type: String,
56
+ default: ''
57
+ },
58
+ // 是否显示冒号
59
+ colon: {
60
+ type: Boolean,
61
+ default: true
62
+ },
63
+ direction: {
64
+ type: String,
65
+ default: 'horizontal'
66
+ },
67
+ border: {
68
+ type: Boolean,
69
+ default: false
70
+ }
71
+ },
72
+ }
73
+ </script>
74
+ <style lang="less" scoped>
75
+ /deep/ .el-descriptions__header {
76
+ display: block;
77
+ }
78
+ .title {
79
+ padding-left: 10px;
80
+ height: 30px;
81
+ line-height: 30px;
82
+ background: #efefef;
83
+ margin-bottom: 10px;
84
+ font-weight: bold;
85
+ color: #606266;
86
+ font-size: 14px;
87
+ }
88
+ .top-content {
89
+ color: #606266;
90
+ font-size: 14px;
91
+ font-weight: normal;
92
+ }
93
+ /deep/ .el-descriptions-item__label {
94
+ white-space: nowrap;
95
+ }
96
+ /deep/ .el-descriptions__body .el-descriptions__table .el-descriptions-item__cell {
97
+ white-space: pre-wrap;
98
+ }
99
+ </style>
@@ -6,31 +6,34 @@
6
6
  v-model="checkAll"
7
7
  @change="handleCheckAllChange">全选</el-checkbox>
8
8
  <div style="margin: 15px 0;" v-if="isCheckAll" ></div>
9
- <el-checkbox-group v-model="checkbox" @change="handleCheckedCitiesChange">
10
- <el-checkbox v-for="(item, index) in options"
9
+ <el-checkbox-group v-model="checkbox" @change="handleCheckedCitiesChange" :disabled="disabled">
10
+ <el-checkbox v-for="(item, index) in option"
11
11
  :label="item[props.value]"
12
12
  :disabled="item.disabled"
13
- :key="index">{{ item[props.label] }}</el-checkbox>
13
+ :key="index"
14
+ >{{ item[props.label] }}</el-checkbox>
15
+ <el-input
16
+ v-if="showOther"
17
+ v-model="inputValue"
18
+ :disabled="inputDisabled"
19
+ placeholder="请输入其他"
20
+ @input="inputChange"
21
+ style="display: inline-block; margin-left: 10px;" />
14
22
  </el-checkbox-group>
23
+
15
24
  </div>
16
25
  </template>
17
26
  <script>
18
- const cityOptions = ['上海', '北京', '广州', '深圳'];
19
27
  export default {
20
28
  name: 'mec-checkbox',
21
29
  props: {
22
30
  value: {},
23
- options: {
24
- type: Array,
25
- default() {
26
- return [];
27
- }
28
- },
31
+ options: {},
29
32
  props: {
30
33
  default() {
31
34
  return {
32
- label: 'label',
33
- value: 'value'
35
+ label: 'name',
36
+ value: 'id'
34
37
  }
35
38
  }
36
39
  },
@@ -39,12 +42,35 @@ export default {
39
42
  return false;
40
43
  }
41
44
  },
45
+ showOther: {
46
+ default() {
47
+ return false;
48
+ }
49
+ },
50
+ otherValue: {
51
+ default() {
52
+ return '';
53
+ }
54
+ },
55
+ checkText: {
56
+ default() {
57
+ return '其他'
58
+ }
59
+ },
60
+ disabled: {
61
+ default() {
62
+ return false;
63
+ }
64
+ }
42
65
  },
43
66
  data() {
44
67
  return {
45
68
  checkAll: false,
46
69
  checkbox: [],
47
- isIndeterminate: true
70
+ isIndeterminate: true,
71
+ option: [],
72
+ inputValue: '',
73
+ inputDisabled: true
48
74
  };
49
75
  },
50
76
  watch: {
@@ -54,10 +80,42 @@ export default {
54
80
  },
55
81
  immediate: true
56
82
  },
83
+ options: {
84
+ handler: function (val) {
85
+ //判断options是否为promise
86
+ if (typeof val !== 'function' && val && !val.then) {
87
+ this.option = this.options;
88
+ }
89
+ },
90
+ deep: true,
91
+ immediate: true,
92
+ },
93
+ otherValue: {
94
+ handler(val) {
95
+ this.inputValue = val;
96
+ }
97
+ }
98
+ },
99
+ mounted() {
100
+ if (!Array.isArray(this.options) && this.options) {
101
+ if(this.options instanceof Promise) {
102
+ this.options.then(val => {
103
+ this.option = val.data || val;
104
+ });
105
+ }
106
+ if(typeof this.options == 'function') {
107
+ this.options().then(val => {
108
+ this.option = val.data || val;
109
+ });
110
+ }
111
+
112
+ } else {
113
+ this.option = this.options;
114
+ }
57
115
  },
58
116
  computed: {
59
117
  checkboxAll () {
60
- return this.options.map(item => {
118
+ return this.option.map(item => {
61
119
  return item[this.props.value]
62
120
  })
63
121
  }
@@ -72,8 +130,23 @@ export default {
72
130
  this.checkAll = checkedCount === this.checkboxAll.length;
73
131
  this.isIndeterminate = checkedCount > 0 && checkedCount < this.checkboxAll.length;
74
132
  this.$emit('input', value)
75
- console.log(value)
76
- }
133
+ this.$emit('update:value', value)
134
+ let nameList = this.getNameListByIds(value, this.option)
135
+ this.inputDisabled = nameList.filter(item => {
136
+ return item.includes(this.checkText)
137
+ }).length == 0
138
+ },
139
+ // 根据 id 数组获取对应的 name 列表
140
+ getNameListByIds(ids, array) {
141
+ return ids.map(id => {
142
+ const reason = array.find(item => item[this.props.value] === id);
143
+ return reason ? reason[this.props.label] : '';
144
+ }).filter(name => name); // 过滤掉空值
145
+ },
146
+ // 其他输入框输入
147
+ inputChange(val) {
148
+ this.$emit('update:otherValue', val)
149
+ },
77
150
  }
78
151
  };
79
152
  </script>
@@ -84,6 +84,7 @@ export default {
84
84
  date: {
85
85
  handler(val) {
86
86
  this.$emit('input', val);
87
+ this.$emit('update:value', val)
87
88
  }
88
89
 
89
90
  }
@@ -81,6 +81,10 @@ export default {
81
81
  type: Boolean,
82
82
  default: true,
83
83
  },
84
+ dialogClass: {
85
+ type: String,
86
+ default: ""
87
+ }
84
88
  },
85
89
  data() {
86
90
  return {
@@ -90,18 +94,7 @@ export default {
90
94
  },
91
95
  computed: {
92
96
  customClass() {
93
- let className = "";
94
- switch (this.type) {
95
- case "form":
96
- className = "base-dialog-form";
97
- break;
98
- case "table":
99
- className = "base-dialog-table";
100
- break;
101
- case "fullscreen":
102
- className = "base-dialog-fullscreen";
103
- break;
104
- }
97
+ let className = this.dialogClass;
105
98
  return className;
106
99
  },
107
100
  },
@@ -169,7 +162,6 @@ export default {
169
162
  }
170
163
 
171
164
  .el-dialog__footer {
172
- box-sizing: border-box;
173
165
  padding: 10px 20px;
174
166
  border: none;
175
167
  background-color: #efefef;
@@ -222,4 +214,9 @@ export default {
222
214
  }
223
215
  }
224
216
  }
217
+ .shan-maintenance-dialog {
218
+ /deep/ .el-dialog {
219
+ height: 90%;
220
+ }
221
+ }
225
222
  </style>
@@ -15,8 +15,7 @@
15
15
  <el-form-item v-bind="item" :prop="getProp(item, index)"
16
16
  :rules="item.rules"
17
17
  :class="item.class"
18
- :label-width="item.labelWidth"
19
- :style="item.labelWidth ? 'width: calc(100% - ' + labelWidth + ');' : ''">
18
+ :label-width="item.labelWidth">
20
19
  <template slot="label">
21
20
  <span v-if="item.label">
22
21
  {{ item.label }}
@@ -28,6 +27,8 @@
28
27
  <component
29
28
  :is="item['componentName']"
30
29
  v-model="item.value"
30
+ :value.sync="item.value"
31
+ :otherValue.sync="item.otherValue"
31
32
  v-bind="item"
32
33
  v-on="item.componentListeners"
33
34
  ></component>
@@ -73,7 +74,10 @@ export default {
73
74
  }
74
75
  });
75
76
  });
76
- }
77
+ },
78
+ clearValidate() {
79
+ this.$refs.formData.clearValidate();
80
+ },
77
81
  },
78
82
  };
79
83
  </script>
@@ -83,4 +87,5 @@ export default {
83
87
  display: table;
84
88
  clear: both;
85
89
  }
90
+
86
91
  </style>
@@ -16,6 +16,8 @@
16
16
  @input="handleInput"
17
17
  @clear="clear"
18
18
  @keyup.enter.native="handleEnter"
19
+ v-feeInput="isFeeInput"
20
+ @blur="handleBlur"
19
21
  >
20
22
  <div slot="prepend" v-if="prependText" @click="btnClick" :style="disabled ? 'cursor: not-allowed' : 'cursor: pointer'">{{ prependText }}</div>
21
23
  <div slot="append" v-if="appendText" @click="btnClick" :style="disabled ? 'cursor: not-allowed' : 'cursor: pointer'">{{ appendText }}</div>
@@ -24,8 +26,13 @@
24
26
  </template>
25
27
 
26
28
  <script>
29
+ import feeInput from "@/directive/mec-feeInput/index"
27
30
  export default {
28
31
  name: 'mec-input',
32
+ directives: {
33
+ feeInput
34
+ },
35
+
29
36
  props: {
30
37
  value: {
31
38
  default: ''
@@ -87,11 +94,14 @@
87
94
  },
88
95
  // 文本域行数(当type为'textarea'时有效)
89
96
  rows: {
90
- default: 1
97
+ default: 2
91
98
  },
92
99
  // 文本域是否自适应大小(当type为'textarea'时有效)
93
100
  autosize: {
94
- default: false
101
+ type: [Boolean, Object],
102
+ default: () => {
103
+ return { minRows: 2 }
104
+ }
95
105
  },
96
106
  prependText: {
97
107
  type: String,
@@ -104,7 +114,12 @@
104
114
  appendIcon: {
105
115
  type: String,
106
116
  default: ''
107
- }
117
+ },
118
+ isFeeInput: {
119
+ type: Boolean,
120
+ default: false
121
+ },
122
+
108
123
  },
109
124
  data() {
110
125
  return {
@@ -138,6 +153,7 @@
138
153
  }
139
154
  this.inputValue = value
140
155
  this.$emit('input', value);
156
+ this.$emit('update:value', value)
141
157
  },
142
158
  clear() {
143
159
  this.$emit('clear')
@@ -147,6 +163,9 @@
147
163
  },
148
164
  handleEnter() {
149
165
  this.$emit('enter')
166
+ },
167
+ handleBlur() {
168
+ this.$emit('blur', this.inputValue)
150
169
  }
151
170
  },
152
171
  watch: {
@@ -104,6 +104,7 @@ export default {
104
104
  },
105
105
  tableInputHandel(val) {
106
106
  this.$emit('input', val)
107
+ this.$emit('update:value', val)
107
108
  },
108
109
  search() {
109
110
  this.$emit('search', this.tableInput)
@@ -49,6 +49,7 @@ export default {
49
49
  radio: {
50
50
  handler(val) {
51
51
  this.$emit('input', val)
52
+ this.$emit('update:value', val)
52
53
  },
53
54
  }
54
55
  },
@@ -40,8 +40,8 @@ export default {
40
40
  props: {
41
41
  default() {
42
42
  return {
43
- label: "label",
44
- value: "value",
43
+ label: "name",
44
+ value: "id",
45
45
  };
46
46
  },
47
47
  },
@@ -90,6 +90,7 @@ export default {
90
90
  handleChange(val) {
91
91
  this.selected = val;
92
92
  this.$emit("input", this.selected);
93
+ this.$emit('update:value', val)
93
94
  this.$emit("change", val);
94
95
  },
95
96
  clear() {
@@ -259,6 +259,7 @@ export default {
259
259
  <style lang="less" scoped>
260
260
  .table-container {
261
261
  background-color: #fff;
262
+ height: 100%;
262
263
  }
263
264
  .pagination-layout {
264
265
  text-align: right;
@@ -53,6 +53,7 @@ export default {
53
53
  activeName:{
54
54
  handler(val) {
55
55
  this.$emit('input', val);
56
+ this.$emit('update:value', val)
56
57
  }
57
58
  }
58
59
  },
@@ -1,9 +1,12 @@
1
1
  // input金额指令(数字,且保留两位小数,blur自动增加.00)
2
2
  import Vue from 'vue'
3
3
 
4
- Vue.directive('feeInput', {
4
+ export default {
5
5
  bind(el, binding, vnode) {
6
+ if (!binding.value) return; // 绑定值为false时不执行后续逻辑
6
7
  const input = el.getElementsByTagName('input')[0]
8
+ console.log(input)
9
+ if(!input) return
7
10
  input.addEventListener('compositionstart', () => {
8
11
  vnode.inputLocking = true
9
12
  })
@@ -45,4 +48,4 @@ Vue.directive('feeInput', {
45
48
  }
46
49
  })
47
50
  }
48
- })
51
+ }
@@ -0,0 +1,13 @@
1
+ import feeInput from "./feeInput";
2
+
3
+ const install = function (Vue) {
4
+ Vue.directive("el-feeInput", feeInput);
5
+ };
6
+
7
+ if (window.Vue) {
8
+ window["el-feeInput"] = feeInput;
9
+ Vue.use(install); // eslint-disable-line
10
+ }
11
+
12
+ feeInput.install = install;
13
+ export default feeInput;
package/src/index.js CHANGED
@@ -24,10 +24,11 @@ const install = function (Vue) {
24
24
  Vue.component(component.name, component);
25
25
  }
26
26
  });
27
+
27
28
  requireDirective.keys().forEach((directiveFileName) => {
28
29
  const moduleName = directiveFileName.replace(/^\.\/(.*)\.\w+$/, "$1");
29
- const directiveConfig = requireDirective(directiveFileName);
30
- Vue.directive(moduleName, directiveConfig.default);
30
+ const directiveConfig = requireDirective(directiveFileName).default; // 获取指令配
31
+ Vue.directive(moduleName, directiveConfig); // 注册指令
31
32
  });
32
33
  };
33
34