zhangyanpeng
2020-05-06 d0be57c51de4ed3bf6e8d9a68242f24a5716e65d
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<template>
    <div>
        <!-- 兼职支付确认 -->
        <el-form label-position="left" label-width="50px" :inline="true" :model="formInline" class="form-inline">
            <el-form-item label="姓名">
                <el-input v-model="formInline.userName" placeholder="姓名"></el-input>
            </el-form-item>
            
            <el-form-item label="日期">
                <el-date-picker
                      v-model="formInline.month"
                      type="month"
                      placeholder="选择月">
                    </el-date-picker>
            </el-form-item>
            <el-form-item >
                <el-button type="primary" @click="query_">查询</el-button>
                <el-button type="info" @click="empty_">重置</el-button>
            </el-form-item>
        </el-form>
        
        <el-table  
                highlight-current-row
                ref="data_table"
                v-loading="loading_table"
                size="small"
                :data="tableData_" 
                :header-cell-style="{'width': '100%', 'text-align': 'center'}" 
                >
                <!-- <el-table-column type="index" width="50"> </el-table-column> -->
            <el-table-column prop="userName" label="姓名" width="120" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="year" label="年份" width="80" align="center" :formatter="getyear_"></el-table-column>
            <el-table-column prop="month" label="月份" width="80" align="center" :formatter="getmonth_"></el-table-column>
            <el-table-column prop="finishCnt" label="已完成模块"  align="center" :formatter="noisnull_"></el-table-column>
            <el-table-column prop="finishMoney" label="已完成金额" align="center" :formatter="noisnull_"></el-table-column>
            <el-table-column prop="unFinishCnt" label="未完成模块"  align="center" :formatter="noisnull_"></el-table-column>
            <el-table-column prop="unFinishMoney" label="未完成金额" align="center" :formatter="noisnull_"></el-table-column>
            <el-table-column prop="payMoney" label="合同支付金额" align="center" :formatter="noisnull_"></el-table-column>
            <el-table-column prop="money" label="支付金额" width="150"  align="center">
                <template v-slot="{row}">
                  <div>
                    <el-input-number size="mini" v-model="row.money" @change="moneyChange(row)"></el-input-number>
                  </div>
                </template>
            </el-table-column>
            <el-table-column label="操作" align="center">
              <template v-slot="{row}">
                <el-row>
                   <el-button type="primary" size="mini" @click="getDetails(row)">详情</el-button>
                </el-row>
              </template>
            </el-table-column>
        </el-table>
        
        <el-dialog title="项目详情" v-if="dialog_1" @close="Cancel1"  width="800px" top="100px" :visible.sync="dialog_1" append-to-body>
            <el-table
                :data="tableData1"
                    v-loading="loading_table1"
                style="width: 100%"
                row-key="id"
                    height="60vh"
                    :header-cell-style="{'width': '100%', 'text-align': 'center'}" 
                >
                <el-table-column prop="name" label="项目名称" show-overflow-tooltip></el-table-column>
                <el-table-column prop="budget" label="金额" width="100"  align="center"></el-table-column>
                <el-table-column prop="startTime" label="开始日期" width="120" show-overflow-tooltip  align="center" :formatter="createTime_"></el-table-column>
                <el-table-column prop="endTime" label="结束日期" width="120" show-overflow-tooltip align="center" :formatter="createTime_"></el-table-column>
                <el-table-column prop="finish" label="是否完成" width="80" align="center" :formatter="finish_"></el-table-column>
              </el-table>
            
        </el-dialog>
    </div>
</template>
 
<script>
    
    export default {
        components: {
        },
        data() {
            return {
                formInline: {
                    month: new Date()
                },
                loading_table: false,
                tableData: [],
                tableData_:[],
                
                dialog_1: false,
                loading_table1: false,
                tableData1: [],
                tableData1_: [],
            }
        },
        mounted() { //组件配置后,页面显示前。用于加载数据
            this.getUserList();
        },
        methods: {
            getUserList(val) {//
                let me = this;
                this.loading_table = true;
                this.tableData =  [];
                let url = "/api/detail/getByParttime";
                let Date_ = new Date();
                if (val) {
                    Date_ = val;
                }
                
                let params = {
                    year: Date_.getFullYear(),
                    month: Date_.getMonth() + 1
                }
                
                this.getUrl(url, params, function(data_) {
                    me.tableData = data_.data.data;
                    me.tableData_ = [...me.tableData];
                    let clientHeight = document.documentElement.clientHeight;
                    let tableHeight_ = clientHeight - 60 - 20 - 65 - 20 - 48;
                    me.$refs.data_table.$el.getElementsByClassName('el-table__body-wrapper')[0].style['height'] = tableHeight_ - 10 + "px";// - header_height
                    me.$refs.data_table.$el.getElementsByClassName('el-table__body-wrapper')[0].style['min-height'] = tableHeight_ - 10 + "px";
                    me.$refs.data_table.$el.getElementsByClassName('el-table__body-wrapper')[0].style['overflow'] = "overlay";
                    me.loading_table = false;
                    
                    if (me.formInline.userName) {
                        let val = me.formInline.userName;
                        me.tableData_ = me.tableData.filter(itm => {
                            return itm.userName.toLowerCase().includes(val.toLowerCase());
                        })
                    }
                });
            },
            
            moneyChange(row) {
                let me = this;
                let url = "/api/detail/dealParttime/" + row.userId;
                let year_ = this.formInline.month.getFullYear();
                let month_ = this.formInline.month.getMonth() + 1;
                
                let params = {
                    year: row.year,
                    month: row.month,
                    money: row.money
                }
                
                this.getUrl(url, params, function(data_) {
                    me.query_();
                }) 
            },
            
            query_() {
                if (this.formInline.userName && !this.formInline.month) {
                    let val = this.formInline.userName;
                    this.tableData_ = this.tableData.filter(itm => {
                        return itm.userName.toLowerCase().includes(val.toLowerCase());
                    })
                }
                else if (this.formInline.month) {
                    this.getUserList(this.formInline.month);
                }
                else {
                    this.tableData_ = this.tableData;
                }
                
            },
            
            empty_() {
                this.formInline = {
                    month: new Date()
                };
                this.query_();
            },
            
            getDetails(row) {
                let me = this;
                //获取项目ListBy负责人
                this.loading_table1 = true;
                let url = "/api/detail/getMoneyByPersion";
                let params = {
                    userId:  row.userId,
                    isParttime: true
                }
                this.getUrl(url, params, function(data_) {
                    let scheme = data_.data.data.scheme ? data_.data.data.scheme : [];
                    let list = data_.data.data.sub ? data_.data.data.sub : [];
                    
                    let parId = "";
                    let obj = {};
                    let result = [];
                    scheme.map(el => {
                        obj[el.id] = el;
                            result.push(el);
                    })
                    for(let i=0, len = list.length; i < len; i++) {
                        let parentId_ = list[i].parentId;
                        //设置显示字段
                    //    list[i].label = list[i].name;
                        if(parentId_ == parId || !parentId_) {
                                obj[list[i].id].children = [];
                                result.push(list[i]);
                                continue;
                        }
                        else if (obj[parentId_]) {
                            if (!obj[parentId_].children) {
                                obj[parentId_].children = [];
                            }
                            obj[parentId_].children.push(list[i]);
                        } 
                    }
                    
                    me.tableData1 = result;
                    
                    me.loading_table1 = false;
                    me.dialog_1 = true;
                });
            },
            
            Cancel1() {
                this.dialog_1 = false;
                
            },
            
            load(tree, treeNode, resolve) {
                let me = this;
                //获取模块List
                let url = "";
                /* this.getUrl(url, params, function(data_) {
                    resolve(data_.data.data);
                }); */
                
            },
            
            createTime_(row, column, cellValue, index) {
                if (cellValue) {
                    return this.$moment(cellValue).format('YYYY-MM-DD');
                }
                return "";
            },
            
            finish_(row, column, cellValue, index) {
                if (cellValue) {
                    return "完成";
                }
                else {
                    return "未完成";
                }
            },
            getyear_(row, column, cellValue, index) {
                let aa = this.formInline.month;
                row.year = aa.getFullYear();
                return aa.getFullYear();
            },
            getmonth_(row, column, cellValue, index) {
                let aa = this.formInline.month;
                row.month = aa.getMonth() + 1;
                return aa.getMonth() + 1;
            },
            
            noisnull_(row, column, cellValue, index) {
                if (cellValue) {
                    return cellValue;
                }
                else {
                    return 0;
                }
            },
            
            getUrl(url, params, callback){
              let me = this;
              this.$axios.get(url,{
                params: params
              }).then(data_ => {
                window.console.log(data_);
                if (callback) {
                  callback(data_);
                }
              })
              .catch(error =>{
                window.console.log(error);
              })
            },
            postUrl(url, params, callback){
              let me = this;
              this.$axios.post(url,params)
              .then(data_ => {
                window.console.log(data_);
                if (callback) {
                  callback(data_);
                }
              })
              .catch(error =>{
                window.console.log(error);
              })
            },
            
        }
    };
</script>
 
<style>
</style>