@tripup-company/element-ui-extended 0.0.103 → 0.0.104

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": "@tripup-company/element-ui-extended",
3
- "version": "0.0.103",
3
+ "version": "0.0.104",
4
4
  "main": "./dist/element-ui-extended.umd.js",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve && tsc --emitDeclarationOnly",
@@ -32,10 +32,11 @@
32
32
  @reset:filter="handleResetTopFilter"
33
33
  />
34
34
  </slot>
35
- <slot name="table" v-bind="{ fields, data }">
35
+ <slot name="table" v-bind="{ fields, data, rowClassName }">
36
36
  <generic-table
37
37
  :fields="fields"
38
38
  :data="data"
39
+ :row-class-name="rowClassName"
39
40
  @sort:change="handleChangeSort"
40
41
  />
41
42
  </slot>
@@ -114,6 +115,10 @@ export default {
114
115
  default: () => [],
115
116
  type: Array,
116
117
  },
118
+ rowClassName: {
119
+ type: [String, Function],
120
+ default: null,
121
+ },
117
122
  topFilter: {
118
123
  default() {
119
124
  return {};
@@ -1,22 +1,27 @@
1
1
  <template>
2
2
  <div>
3
- <el-table :data="data" border @sort-change="sortChange">
3
+ <el-table
4
+ :data="data"
5
+ border
6
+ :row-class-name="rowClassName"
7
+ @sort-change="sortChange"
8
+ >
4
9
  <template v-for="field in fields">
5
10
  <template v-if="field.callback">
6
11
  <el-table-column
7
- :key="field.prop"
8
- v-slot="context"
9
- :prop="field.prop"
10
- :label="field.label"
11
- :width="field.width ? field.width : null"
12
- :sortable="field.sortable ? field.sortable : null"
12
+ :key="field.prop"
13
+ v-slot="context"
14
+ :prop="field.prop"
15
+ :label="field.label"
16
+ :width="field.width ? field.width : null"
17
+ :sortable="field.sortable ? field.sortable : null"
13
18
  >
14
19
  <el-link v-if="field.href" :href="customHref(field, context)">
15
20
  {{ customLinkLabel(field, context) }}
16
21
  </el-link>
17
22
  <el-link
18
- v-else
19
- @click.prevent="
23
+ v-else
24
+ @click.prevent="
20
25
  field.callback(field.prop, context.$index, context.row)
21
26
  "
22
27
  >
@@ -26,11 +31,11 @@
26
31
  </template>
27
32
  <template v-else-if="field.type && field.type === 'template'">
28
33
  <el-table-column
29
- :key="field.prop"
30
- :prop="field.prop"
31
- :label="field.label"
32
- :width="field.width ? field.width : null"
33
- :sortable="field.sortable ? field.sortable : null"
34
+ :key="field.prop"
35
+ :prop="field.prop"
36
+ :label="field.label"
37
+ :width="field.width ? field.width : null"
38
+ :sortable="field.sortable ? field.sortable : null"
34
39
  >
35
40
  <template slot-scope="scope">
36
41
  <span v-html="field.formatter(scope)"></span>
@@ -39,27 +44,27 @@
39
44
  </template>
40
45
  <template v-else-if="field.type && field.type === 'component'">
41
46
  <el-table-column
42
- :key="field.prop"
43
- :prop="field.prop"
44
- :label="field.label"
45
- :width="field.width ? field.width : null"
46
- :sortable="field.sortable ? field.sortable : null"
47
+ :key="field.prop"
48
+ :prop="field.prop"
49
+ :label="field.label"
50
+ :width="field.width ? field.width : null"
51
+ :sortable="field.sortable ? field.sortable : null"
47
52
  >
48
53
  <template slot-scope="scope">
49
- <component :is="field.name" v-bind="field.params(scope)"/>
54
+ <component :is="field.name" v-bind="field.params(scope)" />
50
55
  </template>
51
56
  </el-table-column>
52
57
  </template>
53
58
  <template v-else>
54
59
  <el-table-column
55
- :formatter="
60
+ :formatter="
56
61
  typeof field.formatter === 'function' ? field.formatter : null
57
62
  "
58
- :key="field.prop"
59
- :prop="field.prop"
60
- :label="field.label"
61
- :width="field.width ? field.width : null"
62
- :sortable="field.sortable ? field.sortable : null"
63
+ :key="field.prop"
64
+ :prop="field.prop"
65
+ :label="field.label"
66
+ :width="field.width ? field.width : null"
67
+ :sortable="field.sortable ? field.sortable : null"
63
68
  />
64
69
  </template>
65
70
  </template>
@@ -81,8 +86,13 @@ export default {
81
86
  default: () => [],
82
87
  type: Array,
83
88
  },
89
+ rowClassName: {
90
+ type: [String, Function],
91
+ default: null,
92
+ },
84
93
  },
85
94
  data: function () {
95
+ console.log(this.rowClassName);
86
96
  return {
87
97
  loading: false,
88
98
  };
@@ -94,15 +104,15 @@ export default {
94
104
  },
95
105
  customHref(field, context) {
96
106
  return field.href
97
- ? typeof field.href === "function"
98
- ? field.href(field.prop, context.$index, context.row)
99
- : field.href
100
- : "#";
107
+ ? typeof field.href === "function"
108
+ ? field.href(field.prop, context.$index, context.row)
109
+ : field.href
110
+ : "#";
101
111
  },
102
112
  customLinkLabel(field, context) {
103
113
  return typeof field.formatter === "function"
104
- ? field.formatter(context.row)
105
- : context.row[field.prop];
114
+ ? field.formatter(context.row)
115
+ : context.row[field.prop];
106
116
  },
107
117
  },
108
118
  };