<template>
|
<div class='app'>
|
<!--周报录入-->
|
<div class='part1'>
|
<a-button @click='handleReload' style='position: absolute;z-index: 300;right: 40px;top: 45px' type='primary'>
|
刷新
|
</a-button>
|
|
<weekly-list-compent :kpDisabled='false' @submit='submit' :model='model' @onLoadMore='onLoadMore' :loadingMore='loadingMore' @reload='handleReload' :show-load-model='true' />
|
</div>
|
</div>
|
|
</template>
|
|
<script>
|
import { queryLinkList, queryLinkListWbs, queryProList } from '@api/pro'
|
import { querySingleThisWeek } from '@api/week'
|
import { deleteAction, getAction, postAction, putAction } from '@api/manage'
|
import { getWeek } from '@/utils/util'
|
import { ajaxGetDictItems } from '@api/api'
|
import { initDictOptions, filterDictText } from '@/components/dict/JDictSelectUtil'
|
import WeeklyListCompent from '@views/week/modules/WeeklyListCompent'
|
|
export default {
|
name: 'RightJuniorWeekly',
|
components: { WeeklyListCompent },
|
props: {
|
username: {
|
type: String,
|
default: '',
|
required: true
|
}
|
},
|
watch: {
|
username: {
|
deep: true,
|
handler() {
|
this.page = 0
|
this.model.weekList = []
|
this.onLoadMore()
|
console.info(this.username)
|
}
|
}
|
},
|
data() {
|
return {
|
loading: false,
|
loadingMore: false,
|
showLoadingMore: true,
|
queryParam: {
|
year:null,
|
week:null,
|
username:null
|
},
|
|
//填写的周报信息
|
model: {
|
|
weekList: [
|
]
|
|
},
|
page: 0,
|
url: {
|
addBatch: '/wek/record/addBatch',
|
edit: '/wek/record/edit',
|
delete: '/wek/record/delete',
|
add: '/wek/record/add',
|
evaluateEdit: '/wek/evaluate/edit'
|
}
|
|
}
|
},
|
created() {
|
this.page = 0
|
this.onLoadMore()
|
|
},
|
methods: {
|
onLoadMore() {
|
this.loadingMore = true
|
this.getQueryParams()
|
getAction('/wek/record/queryWeeklyListByWeekNo' ,this.queryParam).then((res) => {
|
if (res.success && res.result ) {
|
if (this.page == 0) {
|
this.model.weekList = res.result
|
} else {
|
this.model.weekList = this.model.weekList.concat(res.result)
|
}
|
//有数据才添加页码
|
if (res.result && res.result.length > 0) {
|
this.page++
|
} else {
|
this.$message.warning('无更多数据')
|
}
|
|
this.model.weekLis = this.model.weekList.map(item=>{
|
|
//a-select不显示placehold处理
|
for (let prop in item.wekEvaluate) {
|
if (item.wekEvaluate.hasOwnProperty(prop)) {
|
if(item.wekEvaluate[prop] == null){
|
item.wekEvaluate[prop] = undefined
|
}
|
}
|
}
|
item.wekEvaluate.showEvaluate = true
|
return item
|
})
|
|
|
} else {
|
this.$message.warning(res.message)
|
}
|
this.loadingMore = false
|
this.$nextTick(() => {
|
window.dispatchEvent(new Event('resize'))
|
})
|
})
|
|
},
|
//自动提交
|
submit(item, evaluate) {
|
console.info(item)
|
console.info(evaluate)
|
//add
|
if (item) {
|
postAction(this.url.add, item)
|
.then((res) => {
|
if (res.success) {
|
//重新查询周报列表
|
//that.onLoadMore()
|
} else {
|
this.$message.warning(res.message)
|
}
|
})
|
.finally(() => {
|
|
})
|
}
|
|
if (evaluate) {
|
postAction(this.url.evaluateEdit, evaluate)
|
.then((res) => {
|
if (res.success) {
|
//重新查询周报列表
|
//that.onLoadMore()
|
} else {
|
this.$message.warning(res.message)
|
}
|
})
|
.finally(() => {
|
|
})
|
}
|
|
|
},
|
|
|
/**
|
* 提交周报
|
*/
|
handleOk() {
|
let that = this
|
this.$confirm({
|
title: '提示',
|
content: h => <div>确定提交本周周报吗?</div>,
|
onOk() {
|
console.info(that.model)
|
//add
|
if (!that.model.id) {
|
postAction(that.url.addBatch, that.model)
|
.then((res) => {
|
if (res.success) {
|
that.$message.success(res.message)
|
//重新查询周报列表
|
that.onLoadMore()
|
} else {
|
that.$message.warning(res.message)
|
}
|
})
|
.finally(() => {
|
|
})
|
|
//edit
|
} else {
|
putAction(that.url.edit, that.model)
|
.then((res) => {
|
that.confirmLoading = false
|
if (res.success) {
|
that.$message.success(res.message)
|
} else {
|
that.$message.warning(res.message)
|
}
|
})
|
.finally(() => {
|
that.confirmLoading = false
|
})
|
}
|
|
|
},
|
onCancel() {
|
|
},
|
class: 'test'
|
})
|
},
|
getQueryParams(){
|
this.queryParam.username = this.username
|
//点击查询前一周需计算属于哪年的哪周 TODO 此处查询会查询每一周的数据,例如 page = 1 相当于查询当前周的数据、page = 2 查询上周( this.weekNo - this.page)的数据
|
let y = this.weekNo - this.page
|
if(y > 0){
|
this.queryParam.year = this.yearNo
|
this.queryParam.week = y
|
}else if(y==0){
|
this.queryParam.year = (this.yearNo - 1)
|
this.queryParam.week = 52
|
}else {
|
var t = Math.abs(y)
|
var r = Math.ceil(t/52)
|
this.queryParam.year = (this.yearNo - r)
|
this.queryParam.week = 52 - t%52
|
}
|
console.info(this.queryParam.year)
|
console.info(this.queryParam.week)
|
|
},
|
handleReload() {
|
this.page = 0
|
this.onLoadMore()
|
|
},
|
|
|
},
|
computed: {
|
yearNo(){
|
return getWeek().yearNo
|
},
|
weekNo(){
|
return getWeek().weekNo
|
}
|
}
|
}
|
</script>
|
|
<style lang='less' scoped>
|
.app {
|
width: 100%;
|
height: 100%;
|
background: white;
|
min-height: calc(100vh - 140px);
|
}
|
|
</style>
|