Showing
5 changed files
with
8 additions
and
35 deletions
1 | import Vue from 'vue'; | 1 | import Vue from 'vue'; |
2 | import purview from './purview'; | 2 | import purview from './purview'; |
3 | import prodImage from './prod-image'; | 3 | import prodImage from './prod-image'; |
4 | -import time from './time'; | ||
5 | 4 | ||
6 | Vue.directive('purview', purview); | 5 | Vue.directive('purview', purview); |
7 | Vue.directive('prod-img', prodImage); | 6 | Vue.directive('prod-img', prodImage); |
8 | -Vue.directive('time', time); |
app/directives/time.js
deleted
100644 → 0
1 | -import _ from 'lodash'; | ||
2 | -import moment from 'moment'; | ||
3 | - | ||
4 | -export default { | ||
5 | - // unix timestamp format | ||
6 | - // use example: | ||
7 | - // v-time="1495787643" | ||
8 | - // v-time="{time: 1495787643}" | ||
9 | - // v-time="{time: 1495787643, format: 'moment支持的format格式'}" | ||
10 | - bind(el, binding) { | ||
11 | - let format; | ||
12 | - let unixStamp; | ||
13 | - const value = binding.value; | ||
14 | - const isNum = _.isFinite(value); | ||
15 | - const isObj = _.isPlainObject(value); | ||
16 | - const defaultFmt = 'YYYY-MM-DD HH:mm:ss'; | ||
17 | - | ||
18 | - if (isNum) { | ||
19 | - unixStamp = value; | ||
20 | - format = defaultFmt; | ||
21 | - } else if (isObj) { | ||
22 | - unixStamp = binding.value.time; | ||
23 | - format = binding.value.format || defaultFmt; | ||
24 | - } else { | ||
25 | - unixStamp = 'Invalid value.'; | ||
26 | - } | ||
27 | - | ||
28 | - el.innerHTML = moment.unix(unixStamp).format(format); | ||
29 | - } | ||
30 | -}; |
@@ -24,6 +24,7 @@ | @@ -24,6 +24,7 @@ | ||
24 | </template> | 24 | </template> |
25 | <script> | 25 | <script> |
26 | import _ from 'lodash'; | 26 | import _ from 'lodash'; |
27 | +import timeFormat from 'filters/time-format'; | ||
27 | import supplierService from 'supplier-service'; | 28 | import supplierService from 'supplier-service'; |
28 | 29 | ||
29 | export default { | 30 | export default { |
@@ -70,7 +71,7 @@ export default { | @@ -70,7 +71,7 @@ export default { | ||
70 | width: 155, | 71 | width: 155, |
71 | render: (h, params) => { | 72 | render: (h, params) => { |
72 | return ( | 73 | return ( |
73 | - <span v-time={params.row.createTime}></span> | 74 | + <span>{timeFormat(params.row.createTime)}</span> |
74 | ); | 75 | ); |
75 | } | 76 | } |
76 | }, { | 77 | }, { |
@@ -3,6 +3,8 @@ | @@ -3,6 +3,8 @@ | ||
3 | * @author: qi.li <qi.li@yoho.cn> | 3 | * @author: qi.li <qi.li@yoho.cn> |
4 | * @date: 2017/04/13 | 4 | * @date: 2017/04/13 |
5 | */ | 5 | */ |
6 | +import timeFormat from 'filters/time-format'; | ||
7 | + | ||
6 | export default function() { | 8 | export default function() { |
7 | return { | 9 | return { |
8 | columns: [ | 10 | columns: [ |
@@ -19,7 +21,7 @@ export default function() { | @@ -19,7 +21,7 @@ export default function() { | ||
19 | const row = params.row; | 21 | const row = params.row; |
20 | 22 | ||
21 | return ( | 23 | return ( |
22 | - <p v-time={{time: row.createTime}}></p> | 24 | + <p>{timeFormat(row.createTime)}</p> |
23 | ); | 25 | ); |
24 | } | 26 | } |
25 | }, | 27 | }, |
@@ -4,6 +4,8 @@ | @@ -4,6 +4,8 @@ | ||
4 | * @date: 04/05/2017 | 4 | * @date: 04/05/2017 |
5 | */ | 5 | */ |
6 | 6 | ||
7 | +import timeFormat from 'filters/time-format'; | ||
8 | + | ||
7 | export default function() { | 9 | export default function() { |
8 | return { | 10 | return { |
9 | filters: { | 11 | filters: { |
@@ -56,7 +58,7 @@ export default function() { | @@ -56,7 +58,7 @@ export default function() { | ||
56 | align: 'center', | 58 | align: 'center', |
57 | render(h, params) { | 59 | render(h, params) { |
58 | return ( | 60 | return ( |
59 | - <span v-time={params.row.createTime}></span> | 61 | + <span>{timeFormat(params.row.createTime)}</span> |
60 | ); | 62 | ); |
61 | } | 63 | } |
62 | }, | 64 | }, |
-
Please register or login to post a comment