zhuguifei
2025-04-28 442928123f63ee497d766f9a7a14f0a6ee067e25
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<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>