Commit a54ffcbe authored by renjintao's avatar renjintao

Merge branch 'product' of git.mes123.com:zhouyx/mes-ui into product-rjt

parents f16103cc 3508cd25
<template> <template>
<div class="time-view" v-if="startDate && endDate"> <div class="time-view" v-if="startDate && endDate">
<div>{{ startDate }}</div> <span>{{ startDate }}</span>
<div class="jian-tou"> <span class="jian-tou">{{ jg }} {{ unit }}</span>
<div>{{ jg }} {{ unit }}</div> <span>{{ endDate }}</span>
</div>
<div>{{ endDate }}</div>
</div> </div>
</template> </template>
<script> <script>
import dayjs from "dayjs";
export default { export default {
name: "", name: "",
data() { data() {
return { return {
startDate: null, startDate: null,
endDate: null, endDate: null,
unit: "h", unit: "",
jg: 0, jg: 0,
}; };
}, },
...@@ -48,36 +47,12 @@ export default { ...@@ -48,36 +47,12 @@ export default {
methods: { methods: {
init(v) { init(v) {
if (v) { if (v) {
this.startDate = v[this.start]; var start = dayjs(v[this.start]);
this.endDate = v[this.end]; var end = dayjs(v[this.end]);
this.startDate=start.format("YYYY-MM-DD");
this.endDate=end.format("YYYY-MM-DD");
this.jg=end.diff(start,'day');
} }
this.unit = this.mode;
var date1 = new Date(this.startDate).getTime(); //开始时间,时间戳
var date2 = new Date(this.endDate).getTime(); //结束时间,时间戳
this.jg = date2 - date1;
var result = "";
var minute = 1000 * 60;
var hour = minute * 60;
var day = hour * 24;
var month = day * 30;
if (this.jg < 0) return;
var monthC = this.jg / month;
var weekC = this.jg / (7 * day);
var dayC = this.jg / day;
var hourC = this.jg / hour;
var minC = this.jg / minute;
if (this.unit == "m") {
result = "" + parseInt(monthC);
} else if (this.unit == "w") {
result = "" + parseInt(weekC);
} else if (this.unit == "d") {
result = "" + parseInt(dayC);
} else if (this.unit == "h") {
result = "" + parseInt(hourC);
}
this.jg = result;
}, },
}, },
watch: { watch: {
...@@ -92,21 +67,19 @@ export default { ...@@ -92,21 +67,19 @@ export default {
</script> </script>
<style lang="less"> <style lang="less">
.time-view { .time-view {
// width: 600px; display: inline-block;
display: -webkit-flex;
display: flex;
.jian-tou { .jian-tou {
min-width: 55px; min-width: 55px;
text-align: center; text-align: center;
margin: 5px; padding: 0 5px 2px 5px;
background-image: url("../../assets/imgicon/range.png"); background-image: url("../../assets/imgicon/range.png");
background-size: 100%; background-size: 100%;
background-repeat: no-repeat; background-repeat: no-repeat;
margin-top: 7px; background-position: bottom right;
div { // border-bottom: #eee 2px solid;
margin-top: -13px; size: 12px;
} font-weight: bold;
} }
} }
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment