gyyg-components 0.2.9 → 0.2.11

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.9",
3
+ "version": "0.2.11",
4
4
  "private": false,
5
5
  "main": "lib/gyyg-components.umd.js",
6
6
  "scripts": {
@@ -14,6 +14,8 @@
14
14
  "core-js": "^3.6.5",
15
15
  "element-resize-detector": "^1.2.4",
16
16
  "element-ui": "2.15.6",
17
+ "moment": "^2.30.1",
18
+ "sortablejs": "^1.15.6",
17
19
  "vue": "^2.6.11"
18
20
  },
19
21
  "devDependencies": {
@@ -10,7 +10,6 @@
10
10
  :icon="!btn.rightIcon ? btn.icon: ''"
11
11
  :loading="btn.loading"
12
12
  @click="btnClick(btn)"
13
- :plain="btn.plain || true"
14
13
  >{{ btn.text }}
15
14
  <i v-if="btn.rightIcon" :class="btn.icon + ' el-icon--right'"></i>
16
15
  </el-button>
@@ -50,7 +49,7 @@ export default {
50
49
  align-items: center;
51
50
  flex-wrap: wrap;
52
51
  &>div {
53
- margin-left: 15px;
52
+ margin-left: 5px;
54
53
  margin-bottom: 10px;
55
54
  &:first-child {
56
55
  margin-left: 0;
@@ -12,12 +12,12 @@
12
12
  :start-placeholder="startPlaceholder"
13
13
  :end-placeholder="endPlaceholder"
14
14
  :range-separator="rangeSeparator"
15
- :value-format="valueFormat"
16
15
  style="width: 100%;">
17
16
  </el-date-picker>
18
17
  </div>
19
18
  </template>
20
19
  <script>
20
+ import moment from 'moment';
21
21
  export default {
22
22
  name: 'mec-date-picker',
23
23
  props: {
@@ -60,7 +60,7 @@ export default {
60
60
  },
61
61
  valueFormat: {
62
62
  type: String,
63
- default: 'yyyy-MM-dd'
63
+ default: ''
64
64
  }
65
65
 
66
66
  },
@@ -71,7 +71,9 @@ export default {
71
71
  },
72
72
  methods: {
73
73
  change(val) {
74
- this.$emit('change', val);
74
+ const formattedValue = val ? moment(val).format(this.valueFormat) : '';
75
+ this.$emit('change', formattedValue);
76
+ this.$emit('input', formattedValue);
75
77
  }
76
78
  },
77
79
  watch: {
@@ -83,7 +85,9 @@ export default {
83
85
  },
84
86
  date: {
85
87
  handler(val) {
86
- this.$emit('input', val);
88
+ // 将内部的 Date 对象格式化后传递给父组件
89
+ const formattedValue = val ? moment(val).format(this.valueFormat) : '';
90
+ this.$emit('input', formattedValue);
87
91
  }
88
92
 
89
93
  }
@@ -12,7 +12,11 @@
12
12
  :style="item.style"
13
13
  :key="index"
14
14
  >
15
- <el-form-item v-bind="item" :prop="getProp(item, index)" :rules="item.rules" :class="item.class">
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
+ :style="item.labelWidth ? 'width: calc(100% - ' + labelWidth + ');' : ''">
16
20
  <template slot="label">
17
21
  <span v-if="item.label">
18
22
  {{ item.label }}
@@ -9,7 +9,6 @@
9
9
  placement="bottom-end"
10
10
  @click="clickEvent"
11
11
  @command="changeItem"
12
- :class="dropdownClass"
13
12
  >
14
13
  {{ btnInfo.text}}
15
14
  <el-dropdown-menu slot="dropdown" class="right-arrow">
@@ -27,15 +26,7 @@
27
26
  <script>
28
27
  export default {
29
28
  name: 'MecPopoverButton',
30
- props: ['btnInfo'],
31
- computed: {
32
- dropdownClass() {
33
- if (this.btnInfo.plain === undefined) {
34
- return 'is-plain';
35
- }
36
- return this.btnInfo.plain ? 'is-plain' : '';
37
- }
38
- },
29
+ props: ['btnInfo'],
39
30
  methods: {
40
31
  clickEvent(){
41
32
  if(this.btnInfo.trigger) {
@@ -20,9 +20,9 @@
20
20
  </template>
21
21
  <slot name="custom" :formGroups="formGroups"></slot>
22
22
  <el-form-item>
23
- <el-button type="primary" size="small" plain @click="search">查询</el-button>
24
- <el-button type="primary" v-if="isSeniorBtn" size="small" plain @click="seniorSearch">高级搜索</el-button>
25
- <el-button size="small" plain icon="el-icon-refresh" @click="refresh"></el-button>
23
+ <el-button type="primary" size="small" @click="search">查询</el-button>
24
+ <el-button type="primary" v-if="isSeniorBtn" size="small" @click="seniorSearch" style="margin-left: 5px;">高级搜索</el-button>
25
+ <el-button size="small" icon="el-icon-refresh" @click="refresh" style="margin-left: 5px;"></el-button>
26
26
  </el-form-item>
27
27
  </el-form>
28
28
  </div>
@@ -64,7 +64,8 @@ export default {
64
64
  width: 100%;
65
65
  }
66
66
  /deep/ .el-form--inline .el-form-item {
67
- margin-bottom: 10px;
67
+ margin-bottom: 8px;
68
+ margin-right: 5px;
68
69
  vertical-align: middle;
69
70
  }
70
71
  </style>
@@ -99,9 +99,17 @@ export default {
99
99
  },
100
100
  mounted() {
101
101
  if (!Array.isArray(this.options) && this.options) {
102
- this.options().then(val => {
103
- this.option = val.data || val;
104
- });
102
+ if(this.options instanceof Promise) {
103
+ this.options.then(val => {
104
+ this.option = val.data || val;
105
+ });
106
+ }
107
+ if(typeof this.options == 'function') {
108
+ this.options().then(val => {
109
+ this.option = val.data || val;
110
+ });
111
+ }
112
+
105
113
  } else {
106
114
  this.option = this.options;
107
115
  }
@@ -0,0 +1,6 @@
1
+
2
+ import MecTransferDrag from "./MecTransferDrag.vue";
3
+
4
+ MecTransferDrag.install = Vue => Vue.component(MecTransferDrag.name, MecTransferDrag); //注册组件
5
+
6
+ export default MecTransferDrag;
@@ -0,0 +1,147 @@
1
+ <template>
2
+ <el-transfer
3
+ v-model="rightData"
4
+ :data="data"
5
+ :titles=titles
6
+ :left-default-checked="leftDefaultChecked"
7
+ :right-default-checked="rightDefaultChecked"
8
+ :props="props"
9
+ @change="handelChange"
10
+ :target-order="targetOrder"
11
+ :filterable="filterable"
12
+ :filter-placeholder="filterPlaceholder"
13
+ @filter-method="filterMethod"
14
+ >
15
+ </el-transfer>
16
+ </template>
17
+ </template>
18
+ <script>
19
+ import Sortable from 'sortablejs';
20
+ export default {
21
+ name: 'mec-transfer-drag',
22
+ props: {
23
+ value: {
24
+ type: Array,
25
+ default: () => []
26
+ },
27
+ data: {
28
+ type: Array,
29
+ default: () => []
30
+ },
31
+ titles: {
32
+ type: Array,
33
+ default: () => ['列表 1', '列表 2']
34
+ },
35
+ leftDefaultChecked: {
36
+ type: Array,
37
+ default: () => []
38
+ },
39
+ rightDefaultChecked: {
40
+ type: Array,
41
+ default: () => []
42
+ },
43
+ props: {
44
+ type: Object,
45
+ default: () => {
46
+ return {
47
+ key: 'key',
48
+ label: 'label',
49
+ disabled: 'disabled'
50
+ }
51
+ }
52
+ },
53
+ targetOrder: {
54
+ type: String,
55
+ default: 'original'
56
+ },
57
+ filterable: {
58
+ type: Boolean,
59
+ default: false
60
+ },
61
+ filterPlaceholder: {
62
+ type: String,
63
+ default: '请输入搜索内容'
64
+ },
65
+ isDrag: {
66
+ type: Boolean,
67
+ default: true
68
+ }
69
+ },
70
+ watch: {
71
+ value: {
72
+ handler(val) {
73
+ this.rightData = val;
74
+ },
75
+ immediate: true
76
+ }
77
+ },
78
+ data() {
79
+ return {
80
+ rightData: []
81
+ };
82
+ },
83
+ mounted() {
84
+ this.$nextTick(() => {
85
+ if(!this.isDrag) return
86
+ this.initSortable();
87
+ })
88
+ },
89
+ methods: {
90
+ initSortable() {
91
+ const _this = this;
92
+ console.log(this.props)
93
+ const transferDoms = document.getElementsByClassName('el-transfer-panel__list');
94
+ if (transferDoms && transferDoms.length > 1) {
95
+ // 找到 transferDoms[1] 下所有类名为 el-checkbox__label 的元素
96
+ const checkboxLabels = transferDoms[1].querySelectorAll('.el-checkbox__label');
97
+ // 为每个元素添加类名 drag-item
98
+ checkboxLabels.forEach(label => {
99
+ label.classList.add('drag-item');
100
+ });
101
+
102
+ Sortable.create(transferDoms[1], {
103
+ handle: '.el-transfer-panel__item', // 触发拖动事件的元素
104
+ draggable: '.el-transfer-panel__item', // 拖动触发时,可拖动的区域
105
+ animation: 150,
106
+ sort: true,
107
+ disabled: false,
108
+ onEnd(event) {
109
+ const oldIndex = event.oldIndex;
110
+ const newIndex = event.newIndex;
111
+ // 更新 this.rightData 的顺序
112
+ const movedItem = _this.rightData.splice(oldIndex, 1)[0];
113
+ _this.rightData.splice(newIndex, 0, movedItem);
114
+ // 遍历 this.rightData,根据 props.key 和 props.sort 获取对应的值
115
+ const keyField = _this.props.key || 'key'; // 动态获取 key 字段
116
+ const sortField = _this.props.sort || 'fchSort'; // 动态获取 sort 字段
117
+
118
+ const list = _this.rightData.map((item, index) => {
119
+ return {
120
+ [keyField]: item, // 使用 props.key 的值作为键
121
+ [sortField]: index // 使用 props.sort 的值作为键
122
+ };
123
+ });
124
+ _this.$emit('drag', list,);
125
+ }
126
+ });
127
+ }
128
+ },
129
+ handelChange(leftArr, position, rightArr) {
130
+ this.$emit('change', leftArr, position, rightArr)
131
+ if(!this.isDrag) return
132
+ this.$nextTick(() => {
133
+ this.initSortable()
134
+ })
135
+
136
+ },
137
+ filterMethod() {
138
+ this.$emit('filter-method')
139
+ }
140
+ }
141
+ }
142
+ </script>
143
+ <style lang="less" scoped>
144
+ /deep/.drag-item {
145
+ cursor: move;
146
+ }
147
+ </style>
@@ -1,7 +1,8 @@
1
1
  <template>
2
2
  <div>
3
- <span class="default-text" :style="[statusStyle]"
3
+ <span class="default-text" :style="[statusStyle]" v-if="tableData.columnType == 'text'"
4
4
  :class="tableData.getClass ? tableData.getClass(scope.row) : ''">{{ getText(tableData.bind) }}</span>
5
+ <el-button v-if="tableData.columnType == 'button'" size="mini" plain round :type="tableData.setType(this.scope.row)">{{ getText(tableData.bind) }}</el-button>
5
6
  </div>
6
7
  </template>
7
8
  <script>
@@ -30,13 +31,42 @@ export default {
30
31
 
31
32
 
32
33
  .default-text {
33
- overflow: hidden;
34
- text-overflow: ellipsis;
35
- white-space: nowrap;
36
- background-color: #409EFF;
37
- color: #fff;
38
- padding: 5px 15px;
39
- border-radius: 20px;
40
34
  font-size: 14px;
41
35
  }
36
+ /deep/ .el-button {
37
+ cursor: text;
38
+ &.is-plain:focus, &.is-plain:hover {
39
+ background: #FFF;
40
+ border: 1px solid #DCDFE6;
41
+ color: #606266;
42
+ }
43
+ &--primary {
44
+ &.is-plain:focus, &.is-plain:hover {
45
+ color: #409EFF;
46
+ background: #ecf5ff;
47
+ border-color: #b3d8ff;
48
+ }
49
+ }
50
+ &--warning {
51
+ &.is-plain:focus, &.is-plain:hover {
52
+ color: #E6A23C;
53
+ background: #fdf6ec;
54
+ border-color: #f5dab1;
55
+ }
56
+ }
57
+ &--success {
58
+ &.is-plain:focus, &.is-plain:hover {
59
+ color: #67C23A;
60
+ background: #f0f9eb;
61
+ border-color: #c2e7b0;
62
+ }
63
+ }
64
+ &--danger {
65
+ &.is-plain:focus, &.is-plain:hover {
66
+ color: #F56C6C;
67
+ background: #fef0f0;
68
+ border-color: #fbc4c4;
69
+ }
70
+ }
71
+ }
42
72
  </style>