tianheng-ui 0.0.26 → 0.0.27
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 +1 -1
- package/lib/tianheng-ui.js +1 -1
- package/lib/tianheng-ui.js.map +1 -1
- package/package.json +1 -1
- package/packages/table/index.vue +53 -0
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,51 @@ export default {
|
|
239
247
|
},
|
240
248
|
getTable() {
|
241
249
|
return this.$refs["th_table"];
|
250
|
+
},
|
251
|
+
handleFormatTime(time, cFormat) {
|
252
|
+
console.log(time, cFormat);
|
253
|
+
if (arguments.length === 0) {
|
254
|
+
return null;
|
255
|
+
}
|
256
|
+
const format = cFormat || "yyyy-MM-dd HH:mm:ss";
|
257
|
+
let date;
|
258
|
+
if (typeof time === "undefined" || time === null || time === "null") {
|
259
|
+
return "";
|
260
|
+
} else if (typeof time === "object") {
|
261
|
+
date = time;
|
262
|
+
} else {
|
263
|
+
if (typeof time === "string" && /^[0-9]+$/.test(time)) {
|
264
|
+
time = parseInt(time);
|
265
|
+
}
|
266
|
+
if (typeof time === "number" && time.toString().length === 10) {
|
267
|
+
time = time * 1000;
|
268
|
+
}
|
269
|
+
date = new Date(time);
|
270
|
+
}
|
271
|
+
const formatObj = {
|
272
|
+
yyyy: date.getFullYear(),
|
273
|
+
MM: date.getMonth() + 1,
|
274
|
+
dd: date.getDate(),
|
275
|
+
HH: date.getHours(),
|
276
|
+
mm: date.getMinutes(),
|
277
|
+
ss: date.getSeconds(),
|
278
|
+
a: date.getDay()
|
279
|
+
};
|
280
|
+
const time_str = format.replace(
|
281
|
+
/(yyyy|MM|dd|HH|mm|ss|a)/g,
|
282
|
+
(result, key) => {
|
283
|
+
let value = formatObj[key];
|
284
|
+
// Note: getDay() returns 0 on Sunday
|
285
|
+
if (key === "a") {
|
286
|
+
return ["日", "一", "二", "三", "四", "五", "六"][value];
|
287
|
+
}
|
288
|
+
if (result.length > 0 && value < 10) {
|
289
|
+
value = "0" + value;
|
290
|
+
}
|
291
|
+
return value || 0;
|
292
|
+
}
|
293
|
+
);
|
294
|
+
return time_str;
|
242
295
|
}
|
243
296
|
}
|
244
297
|
};
|