tianheng-ui 0.0.26 → 0.0.29
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/lib/index.js +3 -2
- package/lib/tianheng-ui.js +1 -1
- package/lib/tianheng-ui.js.map +1 -1
- package/package.json +1 -1
- package/packages/table/action.vue +0 -4
- package/packages/table/index.vue +52 -0
- package/packages/table/tools.js +8 -0
- package/packages/table/tools.vue +21 -71
package/package.json
CHANGED
package/packages/table/index.vue
CHANGED
@@ -57,6 +57,14 @@
|
|
57
57
|
:scope="scope"
|
58
58
|
:option="item"
|
59
59
|
/>
|
60
|
+
<div v-else-if="item.format">
|
61
|
+
{{
|
62
|
+
handleFormatTime(
|
63
|
+
scope.row[item.alias || item.prop],
|
64
|
+
item.format
|
65
|
+
)
|
66
|
+
}}
|
67
|
+
</div>
|
60
68
|
<div v-else-if="item.alias">{{ scope.row[item.alias] }}</div>
|
61
69
|
<div v-else>{{ scope.row[item.prop] }}</div>
|
62
70
|
</template>
|
@@ -239,6 +247,50 @@ export default {
|
|
239
247
|
},
|
240
248
|
getTable() {
|
241
249
|
return this.$refs["th_table"];
|
250
|
+
},
|
251
|
+
handleFormatTime(time, cFormat) {
|
252
|
+
if (arguments.length === 0) {
|
253
|
+
return null;
|
254
|
+
}
|
255
|
+
const format = cFormat || "yyyy-MM-dd HH:mm:ss";
|
256
|
+
let date;
|
257
|
+
if (typeof time === "undefined" || time === null || time === "null") {
|
258
|
+
return "";
|
259
|
+
} else if (typeof time === "object") {
|
260
|
+
date = time;
|
261
|
+
} else {
|
262
|
+
if (typeof time === "string" && /^[0-9]+$/.test(time)) {
|
263
|
+
time = parseInt(time);
|
264
|
+
}
|
265
|
+
if (typeof time === "number" && time.toString().length === 10) {
|
266
|
+
time = time * 1000;
|
267
|
+
}
|
268
|
+
date = new Date(time);
|
269
|
+
}
|
270
|
+
const formatObj = {
|
271
|
+
yyyy: date.getFullYear(),
|
272
|
+
MM: date.getMonth() + 1,
|
273
|
+
dd: date.getDate(),
|
274
|
+
HH: date.getHours(),
|
275
|
+
mm: date.getMinutes(),
|
276
|
+
ss: date.getSeconds(),
|
277
|
+
a: date.getDay()
|
278
|
+
};
|
279
|
+
const time_str = format.replace(
|
280
|
+
/(yyyy|MM|dd|HH|mm|ss|a)/g,
|
281
|
+
(result, key) => {
|
282
|
+
let value = formatObj[key];
|
283
|
+
// Note: getDay() returns 0 on Sunday
|
284
|
+
if (key === "a") {
|
285
|
+
return ["日", "一", "二", "三", "四", "五", "六"][value];
|
286
|
+
}
|
287
|
+
if (result.length > 0 && value < 10) {
|
288
|
+
value = "0" + value;
|
289
|
+
}
|
290
|
+
return value || 0;
|
291
|
+
}
|
292
|
+
);
|
293
|
+
return time_str;
|
242
294
|
}
|
243
295
|
}
|
244
296
|
};
|
package/packages/table/tools.vue
CHANGED
@@ -1,54 +1,22 @@
|
|
1
1
|
<template>
|
2
|
-
<div class="
|
3
|
-
<
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
<el-button
|
15
|
-
v-if="item.act_type === 'refresh'"
|
16
|
-
:key="index"
|
17
|
-
:style="{ color: item.btn_color }"
|
18
|
-
:type="item.btn_type"
|
19
|
-
:icon="item.btn_icon"
|
20
|
-
:disabled="item.btn_disabled"
|
21
|
-
@click="doRefresh(item)"
|
22
|
-
>{{ item.btn_name }}</el-button
|
23
|
-
>
|
24
|
-
<el-button
|
25
|
-
v-if="item.act_type === 'export'"
|
26
|
-
:key="index"
|
27
|
-
:style="{ color: item.btn_color }"
|
28
|
-
:type="item.btn_type"
|
29
|
-
:icon="item.btn_icon"
|
30
|
-
:disabled="item.btn_disabled"
|
31
|
-
@click="doExport(item)"
|
32
|
-
>{{ item.btn_name }}</el-button
|
33
|
-
>
|
34
|
-
<el-button
|
35
|
-
v-if="item.act_type === 'batch'"
|
36
|
-
:key="index"
|
37
|
-
:style="{ color: item.btn_color }"
|
38
|
-
:type="item.btn_type"
|
39
|
-
:icon="item.btn_icon"
|
40
|
-
:disabled="item.btn_disabled || selectionDisabled"
|
41
|
-
:loading="loadingDel"
|
42
|
-
@click="doBatch(item)"
|
43
|
-
>{{ item.btn_name }}</el-button
|
44
|
-
>
|
45
|
-
</template>
|
2
|
+
<div class="th-tools">
|
3
|
+
<el-button
|
4
|
+
v-for="(item, index) in options"
|
5
|
+
:key="index"
|
6
|
+
:style="item.style"
|
7
|
+
:type="item.type"
|
8
|
+
:icon="item.icon"
|
9
|
+
:disabled="item.disabled || disabled[item.act]"
|
10
|
+
:loading="item.loading"
|
11
|
+
@click="handleClick(item)"
|
12
|
+
>{{ item.name }}</el-button
|
13
|
+
>
|
46
14
|
</div>
|
47
15
|
</template>
|
48
16
|
|
49
17
|
<script>
|
50
18
|
export default {
|
51
|
-
name: "
|
19
|
+
name: "ThTools",
|
52
20
|
props: {
|
53
21
|
options: {
|
54
22
|
type: Array,
|
@@ -56,44 +24,26 @@ export default {
|
|
56
24
|
return [];
|
57
25
|
}
|
58
26
|
},
|
59
|
-
|
60
|
-
type:
|
27
|
+
disabled: {
|
28
|
+
type: Object,
|
61
29
|
default: () => {
|
62
|
-
return
|
30
|
+
return {};
|
63
31
|
}
|
64
32
|
}
|
65
33
|
},
|
66
34
|
data() {
|
67
|
-
return {
|
68
|
-
loadingDel: false
|
69
|
-
};
|
35
|
+
return {};
|
70
36
|
},
|
71
37
|
methods: {
|
72
|
-
|
73
|
-
this.$emit("on-
|
74
|
-
},
|
75
|
-
doAdd(item) {
|
76
|
-
this.$emit("on-add", item);
|
77
|
-
},
|
78
|
-
doRefresh(item) {
|
79
|
-
this.$emit("on-refresh", item);
|
80
|
-
},
|
81
|
-
doExport(item) {
|
82
|
-
this.$emit("on-export", item);
|
83
|
-
},
|
84
|
-
doBatch(item) {
|
85
|
-
this.loadingDel = true;
|
86
|
-
const callback = bool => {
|
87
|
-
this.loadingDel = false;
|
88
|
-
};
|
89
|
-
this.$emit("on-batch", item, callback);
|
38
|
+
handleClick(item) {
|
39
|
+
this.$emit("on-click", item);
|
90
40
|
}
|
91
41
|
}
|
92
42
|
};
|
93
43
|
</script>
|
94
44
|
|
95
|
-
<style lang="less">
|
96
|
-
.
|
45
|
+
<style lang="less" scoped>
|
46
|
+
.th-tools {
|
97
47
|
margin-bottom: 10px;
|
98
48
|
}
|
99
49
|
</style>
|