Commit 35b44e81 authored by 仇晓婷's avatar 仇晓婷

封装时间,优化项目管理

parent 44a9a077
<template> <template>
<div class="time-view">{{ date }}</div> <div class="time-view" v-if="timeValue.startDate && timeValue.endDate">
<span>{{ timeValue.startDate }}</span
>&nbsp; <span class="line">————</span>&nbsp;
<!-- {{ date }} -->
<span>{{ timeValue.endDate }}</span>
<div class="jian-tou"></div>
<div class="day-time">{{ date }}</div>
</div>
</template> </template>
<script> <script>
export default { export default {
...@@ -8,14 +15,18 @@ export default { ...@@ -8,14 +15,18 @@ export default {
return {}; return {};
}, },
props: { props: {
// model: {
// prop: "value",
// event: "on-change",
// },
timeValue: { timeValue: {
type: [String, Object], type: [String, Object],
default: "", default: "",
}, },
// mode: { work: {
// type: [String, Object], type: [String, Number], //传入的work为0,转换为小时,1为天,2为周,3为月
// default: "", default: 0,
// }, },
}, },
computed: { computed: {
date() { date() {
...@@ -24,33 +35,42 @@ export default { ...@@ -24,33 +35,42 @@ export default {
var date3 = 0; var date3 = 0;
date3 = date2 - date1; date3 = date2 - date1;
var timeSpanStr; // var timeSpanStr;
if (date3 <= 1000 * 60 * 1) { // if (date3 <= 1000 * 60 * 1) {
timeSpanStr = "刚刚"; // timeSpanStr = "刚刚";
} else if (1000 * 60 * 1 < date3 && date3 <= 1000 * 60 * 60) { // } else if (1000 * 60 * 1 < date3 && date3 <= 1000 * 60 * 60) {
timeSpanStr = Math.round(date3 / (1000 * 60)) + "分钟"; // timeSpanStr = Math.round(date3 / (1000 * 60)) + "分钟";
} else if (1000 * 60 * 60 * 1 < date3 && date3 <= 1000 * 60 * 60 * 24) { // } else if (1000 * 60 * 60 * 1 < date3 && date3 <= 1000 * 60 * 60 * 24) {
timeSpanStr = Math.round(date3 / (1000 * 60 * 60)) + "小时"; // timeSpanStr = Math.round(date3 / (1000 * 60 * 60)) + "小时";
} else if ( // } else if (
1000 * 60 * 60 * 24 < // 1000 * 60 * 60 * 24 <
date3 // date3
// && date3 <= 1000 * 60 * 60 * 24 * 30 // // && date3 <= 1000 * 60 * 60 * 24 * 30
) { // ) {
timeSpanStr = Math.round(date3 / (1000 * 60 * 60 * 24)) + "天"; // timeSpanStr = Math.round(date3 / (1000 * 60 * 60 * 24)) + "天";
} // }
return timeSpanStr; // return timeSpanStr;
// var result = ""; var result = "";
// var minute = 1000 * 60; var minute = 1000 * 60;
// var hour = minute * 60; var hour = minute * 60;
// var day = hour * 24; var day = hour * 24;
// var month = day * 30; var month = day * 30;
// if (date3 < 0) return; if (date3 < 0) return;
// var monthC = date3 / month; var monthC = date3 / month;
// var weekC = date3 / (7 * day); var weekC = date3 / (7 * day);
// var dayC = date3 / day; var dayC = date3 / day;
// var hourC = date3 / hour; var hourC = date3 / hour;
// var minC = date3 / minute; var minC = date3 / minute;
if (this.work == 3) {
result = "" + parseInt(monthC) + "月";
} else if (this.work == 2) {
result = "" + parseInt(weekC) + "周";
} else if (this.work == 1) {
result = "" + parseInt(dayC) + "天";
} else if (this.work == 0) {
result = "" + parseInt(hourC) + "小时";
}
// if (monthC >= 1) { // if (monthC >= 1) {
// result = "" + parseInt(monthC) + "月"; // result = "" + parseInt(monthC) + "月";
// } else if (weekC >= 1) { // } else if (weekC >= 1) {
...@@ -59,12 +79,14 @@ export default { ...@@ -59,12 +79,14 @@ export default {
// result = "" + parseInt(dayC) + "天"; // result = "" + parseInt(dayC) + "天";
// } else if (hourC >= 1) { // } else if (hourC >= 1) {
// result = "" + parseInt(hourC) + "小时"; // result = "" + parseInt(hourC) + "小时";
// } else if (minC >= 1) { // }
// else if (minC >= 1) {
// result = "" + parseInt(minC) + "分钟"; // result = "" + parseInt(minC) + "分钟";
// } else {
// result = "刚刚";
// } // }
// return result; else {
result = "0";
}
return result;
}, },
}, },
mounted() {}, mounted() {},
...@@ -73,4 +95,26 @@ export default { ...@@ -73,4 +95,26 @@ export default {
}; };
</script> </script>
<style lang="less"> <style lang="less">
.time-view {
width: 300px;
position: relative;
.day-time {
position: absolute;
bottom: 11px;
left: 83px;
}
.line {
font-size: 18px;
}
.jian-tou {
position: absolute;
bottom: 9px;
left: 144px;
width: 7px;
height: 7px;
border-top: 2px solid #666;
border-right: 2px solid #666;
transform: rotate(45deg);
}
}
</style> </style>
<template> <template>
<Form ref="form" :model="entity" :rules="rules" :label-width="90"> <Form ref="form" :model="entity" :rules="rules" :label-width="100">
<Row> <Row>
<Col span="8" class="projct-img"> <Col span="8" class="projct-img">
<FormItem :label="l('picture')" prop="picture"> <FormItem :label="l('picture')" prop="picture">
...@@ -72,29 +72,28 @@ ...@@ -72,29 +72,28 @@
><FormItem :label="l('state')" prop="state"> ><FormItem :label="l('state')" prop="state">
<Dictionary <Dictionary
code="project.main.state" code="project.main.state"
type="radio"
v-model="entity.state" v-model="entity.state"
></Dictionary> </FormItem ></Dictionary> </FormItem
></Col> ></Col>
<Col :span="12" <Col :span="12">
><FormItem :label="l('startDate')" prop="startDate"> <FormItem label="开始结束时间" prop="date">
<DatePicker <DatePicker
type="date" type="datetimerange"
v-model="entity.startDate" format="yyyy-MM-dd"
v-model="date"
placeholder="请选择时间范围"
@on-change="changeFormat"
style="width: 300px"
></DatePicker> </FormItem ></DatePicker> </FormItem
></Col> ></Col>
<Col :span="12" <!-- <TimeDifference :timeValue="timeValue" :wrok="1"></TimeDifference> -->
><FormItem :label="l('endDate')" prop="endDate">
<DatePicker
type="date"
v-model="entity.endDate"
></DatePicker> </FormItem
></Col>
<!-- <TimeDifference :timeValue="timeValue"></TimeDifference> -->
<Col :span="12" <Col :span="12"
><FormItem :label="l('type')" prop="type"> ><FormItem :label="l('type')" prop="type">
<Dictionary <Dictionary
code="project.main.type" code="project.main.type"
v-model="entity.type" v-model="entity.type"
type="radio"
></Dictionary> </FormItem ></Dictionary> </FormItem
></Col> ></Col>
<!-- <!--
...@@ -144,6 +143,7 @@ export default { ...@@ -144,6 +143,7 @@ export default {
}, },
imgName: "", imgName: "",
avatorPath: "", avatorPath: "",
date: [],
entity: { entity: {
// creationTime: null, // creationTime: null,
creatorUserId: this.$store.state.userInfo.userId, creatorUserId: this.$store.state.userInfo.userId,
...@@ -154,11 +154,12 @@ export default { ...@@ -154,11 +154,12 @@ export default {
// deleterUserId: null, // deleterUserId: null,
title: "", title: "",
note: "", note: "",
state: null, state: 1,
type: null, type: 0,
picture: "", picture: "",
attachment: "", attachment: "",
phase: null, phase: null,
startDate: "", startDate: "",
endDate: "", endDate: "",
businessUnits: "", businessUnits: "",
...@@ -187,6 +188,10 @@ export default { ...@@ -187,6 +188,10 @@ export default {
this.parms.eid = this.$u.guid(); this.parms.eid = this.$u.guid();
}, },
methods: { methods: {
changeFormat(val) {
this.entity.startDate = val[0];
this.entity.endDate = val[1];
},
imgUrl() { imgUrl() {
window.open(this.avatorPath, "_blank"); window.open(this.avatorPath, "_blank");
}, },
......
<template> <template>
<Form ref="form" :model="entity" :rules="rules" :label-width="90"> <Form ref="form" :model="entity" :rules="rules" :label-width="100">
<Row> <Row>
<Col span="8" class="projct-img"> <Col span="8" class="projct-img">
<FormItem :label="l('picture')" prop="picture"> <FormItem :label="l('picture')" prop="picture">
...@@ -30,10 +30,21 @@ ...@@ -30,10 +30,21 @@
<Dictionary <Dictionary
code="project.main.state" code="project.main.state"
v-model="entity.state" v-model="entity.state"
type="radio"
></Dictionary> </FormItem ></Dictionary> </FormItem
></Col> ></Col>
<Col :span="12">
<Col :span="12" <FormItem label="开始结束时间" prop="date">
<DatePicker
type="datetimerange"
format="yyyy-MM-dd"
v-model="date"
placeholder="请选择时间范围"
@on-change="changeFormat"
style="width: 300px"
></DatePicker> </FormItem
></Col>
<!-- <Col :span="12"
><FormItem :label="l('startDate')" prop="startDate"> ><FormItem :label="l('startDate')" prop="startDate">
<DatePicker <DatePicker
type="date" type="date"
...@@ -46,12 +57,13 @@ ...@@ -46,12 +57,13 @@
type="date" type="date"
v-model="entity.endDate" v-model="entity.endDate"
></DatePicker> </FormItem ></DatePicker> </FormItem
></Col> ></Col> -->
<Col :span="12" <Col :span="12"
><FormItem :label="l('type')" prop="type"> ><FormItem :label="l('type')" prop="type">
<Dictionary <Dictionary
code="project.main.type" code="project.main.type"
v-model="entity.type" v-model="entity.type"
type="radio"
></Dictionary> </FormItem ></Dictionary> </FormItem
></Col> ></Col>
<Col :span="24"> <Col :span="24">
...@@ -96,7 +108,11 @@ export default { ...@@ -96,7 +108,11 @@ export default {
return { return {
imgName: "", imgName: "",
avatorPath: "", avatorPath: "",
entity: {}, entity: {
state: 1,
type: 0,
},
date: [],
rules: { rules: {
title: [{ required: true, message: "必填", trigger: "blur" }], title: [{ required: true, message: "必填", trigger: "blur" }],
}, },
...@@ -116,6 +132,11 @@ export default { ...@@ -116,6 +132,11 @@ export default {
this.$refs.refmovieFile1.inputShow = false; this.$refs.refmovieFile1.inputShow = false;
}, },
methods: { methods: {
changeFormat(val) {
// console.log(val)
this.entity.startDate = val[0];
this.entity.endDate = val[1];
},
imgUrl() { imgUrl() {
window.open(this.avatorPath, "_blank"); window.open(this.avatorPath, "_blank");
}, },
...@@ -123,14 +144,21 @@ export default { ...@@ -123,14 +144,21 @@ export default {
Api.get({ id: v }).then((r) => { Api.get({ id: v }).then((r) => {
this.entity = r.result; this.entity = r.result;
this.avatorPath = fileUrlDown + r.result.picture; this.avatorPath = fileUrlDown + r.result.picture;
this.imgName = r.result.picture; if (r.result.picture) {
this.imgName = r.result.picture;
}
if (r.result.attachment && r.result.attachment != "") { if (r.result.attachment && r.result.attachment != "") {
this.parms.eid = r.result.attachment; this.parms.eid = r.result.attachment;
} else { } else {
this.parms.eid = this.$u.guid(); this.parms.eid = this.$u.guid();
} }
this.entity.attachment = this.parms.eid; this.entity.attachment = this.parms.eid;
// this.entity.creatorUserId = r.result.creatorUserId; // let data0 = r.result.startDate.slice(0, 10);
// let data1 = r.result.endDate.slice(0, 10);
// this.date[0] = JSON.parse(data0);
// this.date[1] = JSON.parse(data1);
// console.log(this.date);
// console.log(typeof this.date[1]);
}); });
}, },
handleSubmit() { handleSubmit() {
......
...@@ -214,6 +214,16 @@ export default { ...@@ -214,6 +214,16 @@ export default {
align: "left", align: "left",
easy: true, easy: true,
high: true, high: true,
render: (h, params) => {
return h(
"op",
{
attrs: { oprate: "detail" },
on: { click: () => this.view(params.row.id) },
},
params.row.title
);
},
}, },
{ {
key: "state", key: "state",
...@@ -322,14 +332,14 @@ export default { ...@@ -322,14 +332,14 @@ export default {
align: "center", align: "center",
render: (h, params) => { render: (h, params) => {
return h("div", { class: "action" }, [ return h("div", { class: "action" }, [
h( // h(
"op", // "op",
{ // {
attrs: { oprate: "detail" }, // attrs: { oprate: "detail" },
on: { click: () => this.view(params.row.id) }, // on: { click: () => this.view(params.row.id) },
}, // },
"查看" // "查看"
), // ),
//h('op', { attrs: { oprate: 'copy' }, on: { click: () => this.copy(params.row.id) } }, '克隆'), //h('op', { attrs: { oprate: 'copy' }, on: { click: () => this.copy(params.row.id) } }, '克隆'),
h( h(
"op", "op",
...@@ -424,10 +434,13 @@ export default { ...@@ -424,10 +434,13 @@ export default {
} }
}, },
viewFiles(row) { viewFiles(row) {
console.log(row); // console.log(row.attachment);
this.parms.eid = row.attachment; if (row.attachment) {
this.parms.eid = row.attachment;
this.modal1 = true; this.modal1 = true;
} else {
this.$Message.error("暂没上传附件");
}
}, },
ok() { ok() {
this.$refs.grid.load(); this.$refs.grid.load();
......
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