|
@@ -6,9 +6,15 @@
|
|
|
div{
|
|
|
text-align: center;
|
|
|
margin: 5px;
|
|
|
- /deep/ .el-input{
|
|
|
+ label,/deep/ .el-input,/deep/ .el-textarea{
|
|
|
display: inline-block;
|
|
|
- width: 370px;
|
|
|
+ vertical-align: middle;
|
|
|
+ }
|
|
|
+ /deep/ .el-input{
|
|
|
+ width: 200px;
|
|
|
+ }
|
|
|
+ /deep/ .el-textarea{
|
|
|
+ width: 600px;
|
|
|
}
|
|
|
}
|
|
|
.add-bt{
|
|
@@ -16,6 +22,10 @@
|
|
|
font-size: 18px;
|
|
|
float: right;
|
|
|
}
|
|
|
+ .del-bt{
|
|
|
+ cursor: pointer;
|
|
|
+ font-size: 15px;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|
|
|
<template>
|
|
@@ -36,15 +46,20 @@
|
|
|
</el-calendar>
|
|
|
<el-dialog
|
|
|
class="dialog-style"
|
|
|
- title="修改计划"
|
|
|
+ title="编辑计划"
|
|
|
:visible.sync="visibleChange"
|
|
|
- width="500px">
|
|
|
+ width="1000px">
|
|
|
<div v-for="(item, index) in dayPlan" :key="index">
|
|
|
<label>计划:</label>
|
|
|
- <el-input placeholder="" v-model="item.name"></el-input>
|
|
|
+ <el-input placeholder="" v-model="item.name" :disabled="!ableEdit"></el-input>
|
|
|
+
|
|
|
+ <label>内容:</label>
|
|
|
+ <el-input type="textarea" autosize placeholder="" v-model="item.content" :disabled="!ableEdit"></el-input>
|
|
|
+
|
|
|
+ <i class="el-icon-remove-outline del-bt" @click="deletePlan(item,index)" v-if="ableEdit"></i>
|
|
|
</div>
|
|
|
- <i class="el-icon-circle-plus-outline add-bt" @click="addDayPlan()"></i>
|
|
|
- <span slot="footer" class="dialog-footer">
|
|
|
+ <i class="el-icon-circle-plus-outline add-bt" @click="addDayPlan()" v-if="ableEdit"></i>
|
|
|
+ <span slot="footer" class="dialog-footer" v-if="ableEdit">
|
|
|
<el-button @click="visibleChange = false">取 消</el-button>
|
|
|
<el-button type="primary" @click="editTask">确 定</el-button>
|
|
|
</span>
|
|
@@ -62,7 +77,8 @@ export default {
|
|
|
return {
|
|
|
searchMonth: new Date(),
|
|
|
params:{
|
|
|
- startTime: ''
|
|
|
+ startTime: '',
|
|
|
+ userId: this.$store.state.checkUser.id
|
|
|
},
|
|
|
visibleChange: false,
|
|
|
planList: {},
|
|
@@ -73,11 +89,22 @@ export default {
|
|
|
this.getMonthPlan();
|
|
|
},
|
|
|
watch: {
|
|
|
- searchMonth(val) {
|
|
|
- this.params.startTime = val.getTime();
|
|
|
+ searchMonth(val,old) {
|
|
|
+ if(val.getMonth() != old.getMonth()){
|
|
|
+ this.params.startTime = val.getTime();
|
|
|
+ this.getMonthPlan();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ '$store.state.checkUser.id'(val){
|
|
|
+ this.params.userId = val;
|
|
|
this.getMonthPlan();
|
|
|
}
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ ableEdit() {
|
|
|
+ return this.$store.state.loginUser.id == this.$store.state.checkUser.id;
|
|
|
+ },
|
|
|
+ },
|
|
|
methods: {
|
|
|
getMonthPlan(){
|
|
|
getMonthPlan(this.params).then((data) => {
|
|
@@ -89,6 +116,31 @@ export default {
|
|
|
},
|
|
|
editTask(){
|
|
|
this.visibleChange = false;
|
|
|
+ this.dayPlan.forEach(item => {
|
|
|
+ if(item.id){
|
|
|
+ let temp = {
|
|
|
+ "id": item.id,
|
|
|
+ "name": item.name,
|
|
|
+ "content": item.content,
|
|
|
+ "status": item.status,
|
|
|
+ "startTime": this.searchMonth.getTime(),
|
|
|
+ }
|
|
|
+ updatePlan(temp).then((data) => {
|
|
|
+ if(!data.result){
|
|
|
+ this.$message(data.message);
|
|
|
+ }
|
|
|
+ this.getMonthPlan();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ addPlan(item).then((data) => {
|
|
|
+ if(!data.result){
|
|
|
+ this.$message(data.message);
|
|
|
+ }
|
|
|
+ this.getMonthPlan();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
chooseDay(data){
|
|
|
if(new Date(data.day).getMonth() != this.searchMonth.getMonth()){
|
|
@@ -102,11 +154,29 @@ export default {
|
|
|
this.dayPlan.push({
|
|
|
"name": "",
|
|
|
"content": "",
|
|
|
- "year": "",
|
|
|
+ "year": this.searchMonth.getFullYear(),
|
|
|
"userId": "",
|
|
|
- "startTime": "",
|
|
|
+ "startTime": this.searchMonth.getTime(),
|
|
|
})
|
|
|
},
|
|
|
+ deletePlan(item,index){
|
|
|
+ if(item.id){
|
|
|
+ let temp = {
|
|
|
+ id:item.id
|
|
|
+ }
|
|
|
+ deletePlan(temp).then((data) => {
|
|
|
+ if(!data.result){
|
|
|
+ this.$message(data.message);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ this.dayPlan.splice(index,1);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ this.dayPlan.splice(index,1);
|
|
|
+ }
|
|
|
+ },
|
|
|
getDayNum(day){
|
|
|
return ~~day.split('-')[2];
|
|
|
}
|