Authored by 李奇

时间之类删除统一修改

import Vue from 'vue';
import purview from './purview';
import prodImage from './prod-image';
import time from './time';
Vue.directive('purview', purview);
Vue.directive('prod-img', prodImage);
Vue.directive('time', time);
... ...
import _ from 'lodash';
import moment from 'moment';
export default {
// unix timestamp format
// use example:
// v-time="1495787643"
// v-time="{time: 1495787643}"
// v-time="{time: 1495787643, format: 'moment支持的format格式'}"
bind(el, binding) {
let format;
let unixStamp;
const value = binding.value;
const isNum = _.isFinite(value);
const isObj = _.isPlainObject(value);
const defaultFmt = 'YYYY-MM-DD HH:mm:ss';
if (isNum) {
unixStamp = value;
format = defaultFmt;
} else if (isObj) {
unixStamp = binding.value.time;
format = binding.value.format || defaultFmt;
} else {
unixStamp = 'Invalid value.';
}
el.innerHTML = moment.unix(unixStamp).format(format);
}
};
... ... @@ -24,6 +24,7 @@
</template>
<script>
import _ from 'lodash';
import timeFormat from 'filters/time-format';
import supplierService from 'supplier-service';
export default {
... ... @@ -70,7 +71,7 @@ export default {
width: 155,
render: (h, params) => {
return (
<span v-time={params.row.createTime}></span>
<span>{timeFormat(params.row.createTime)}</span>
);
}
}, {
... ...
... ... @@ -3,6 +3,8 @@
* @author: qi.li <qi.li@yoho.cn>
* @date: 2017/04/13
*/
import timeFormat from 'filters/time-format';
export default function() {
return {
columns: [
... ... @@ -19,7 +21,7 @@ export default function() {
const row = params.row;
return (
<p v-time={{time: row.createTime}}></p>
<p>{timeFormat(row.createTime)}</p>
);
}
},
... ...
... ... @@ -4,6 +4,8 @@
* @date: 04/05/2017
*/
import timeFormat from 'filters/time-format';
export default function() {
return {
filters: {
... ... @@ -56,7 +58,7 @@ export default function() {
align: 'center',
render(h, params) {
return (
<span v-time={params.row.createTime}></span>
<span>{timeFormat(params.row.createTime)}</span>
);
}
},
... ...