bob
2020-08-13 801770456ae3750a44e0989b0025a98ccbad24e6
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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
<template>
    <!-- 已完成的不修改需将 finish1 改成 finish -->
    <div>
        <div align="left">
            <div class="btn-line">
                <!-- <el-button type="primary" @click="addProject">新建项目</el-button> -->
                <el-button type="primary" v-if="editShow" @click="editProject">编辑项目</el-button>
                <el-button type="primary" @click="showDetail">查看详情</el-button>
                <el-button type="primary" @click="download">导出timeline</el-button>
 
            </div>
            <div style="width: 0px; height: 0px;">
                <iframe ref="frame_export" style="width: 0px; height: 0px; border: 0px;"></iframe>
            </div>
            <el-form label-width="80px" :inline="true" :label-position="labelPosition" :model="formInline" class="form-inline">
                <el-form-item label="项目名称">
                    <el-input v-model="formInline.name" placeholder="项目名称"></el-input>
                </el-form-item>
                
                <el-form-item label="研究类型分类" label-width="100px">
                    <el-select v-model="formInline.type" placeholder="研究类型分类">
                        <el-option
                            v-for="(item,k) in options_type"
                            :key="k"
                            :label="item"
                            :value="item"
                        ></el-option>
                    </el-select>
                </el-form-item>
                
            
                <el-form-item label="项目状态">
                    <el-select v-model="formInline.status" placeholder="项目状态">
                        <el-option label="未开始" value="edit"></el-option>
                        <el-option label="进行中" value="working"></el-option>
                        <el-option label="已延期" value="delay"></el-option>
                        <el-option label="已结束" value="finish"></el-option>
                    </el-select>
                </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>
            <div class="btn-line">
                
 
            </div>
        </div>
 
        <el-table  highlight-current-row
                ref="data_table"
                @current-change="tableChange"
                @sort-change="sortChange"
                v-loading="loading_table"
                size="small"
                :data="tableData" 
                :header-cell-style="{'width': '100%', 'text-align': 'center'}" 
                :row-class-name="tableRowClassName">
                <el-table-column type="index" width="50"> </el-table-column>
            <el-table-column prop="code" label="项目号" width="130" sortable="custom">
            </el-table-column>
            <el-table-column prop="name" label="项目名称" width="120" sortable="custom" show-overflow-tooltip>
            </el-table-column>
            <el-table-column prop="status" label="当前状态" width="100" sortable="custom" align="center" :formatter="status_">
            </el-table-column>
            <el-table-column prop="totalCnt" label="服务项目数" width="120"  align="center">
            </el-table-column>
            <el-table-column prop="finishCnt" label="已完成项目" width="120"  align="center">
            </el-table-column>
            <el-table-column prop="delayCnt" label="延期项目" width="100"  align="center">
            </el-table-column>
            <el-table-column prop="startTime" label="开始时间" width="100" sortable="custom" align="center" :formatter="dateFormat_">
            </el-table-column>
            <el-table-column prop="endTime" label="结束时间" width="100" sortable="custom" align="center" :formatter="dateFormat_" >
            </el-table-column>
            <el-table-column prop="desc" label="项目描述" show-overflow-tooltip></el-table-column>
            <el-table-column label="操作" align="center" width="300">
              <template v-slot="{row}">
                <el-row>
                  <el-tooltip class="item" effect="dark" content="预览" placement="top">
                    <el-button :disabled="!row.attachment" type="primary" icon=" el-icon-view" circle @click="viewHT(row)"></el-button>
                  </el-tooltip>
                  <el-tooltip class="item" effect="dark" content="上传报价合同" placement="top">
                    <el-button type="success" icon="el-icon-upload2" circle @click="uploadHT(row)"></el-button>
                  </el-tooltip>
                </el-row>
              </template>
            </el-table-column>
            
        </el-table>
        <div style="text-align: right; background-color: #fff;">
            <el-pagination 
                @current-change="handleCurrentChange"
                background :current-page="pagenum" :page-sizes="[15]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper"
             :total="total">
            </el-pagination>
        </div>
        
        <el-dialog v-if="dialog_1"  @close="Cancel"  width="70%" top="50px" :visible.sync="dialog_1" append-to-body>
          <newProject @closeNewProject="closeNewProject" v-bind:rowData="rowData" ref="newProject_"></newProject>
        </el-dialog>
        <el-dialog v-if="dialog_2" @close="Cancel2"  width="70%" top="50px" :visible.sync="dialog_2" append-to-body>
          <prodetail @closeNewProject="closeDetail" v-bind:rowData="detailData" ref="newProject2_"></prodetail>
        </el-dialog>
        
        <el-dialog custom-class="z_master_dialog" title="文件上传" v-if="dialog_upload" :visible.sync="dialog_upload" width="500px" append-to-body>
          <div style="width: 100%; padding-top: 24px; height: 300px; text-align: center;">
            <el-upload
              :show-file-list='true'
              class="upload-demo"
              ref="upload"
              :action="upload_url"
              :headers= "upload_headers"
              :data="upload_data"
              :on-preview="handlePreview"
              :on-success="uploadSuccess"
              :on-remove="handleRemove"
              :before-upload="beforeAvatarUpload"
              :auto-upload="false">
              <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
              <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button>
              <div slot="tip" class="el-upload__tip">只能上传PDF文件</div>
            </el-upload>
        
          </div>
        </el-dialog>
        
        <el-dialog v-if="dialog_pdf" :visible.sync="dialog_pdf" top="10px" width="80%">
            <div style="height: 500px; width: 100%; overflow: overlay;">
                <pdf :src="pdfUrl" :page="currentPage" 
                @num-pages="pageCount=$event" 
                @page-loaded="currentPage=$event"
                @loaded="loadPdfHandler"
                ref="wrapper" class="pdf"></pdf>
            </div>
            
            <div style="">
                <el-button size="small"  @click="changePdfPage(0)">上一页</el-button>
                <el-button size="small"  @click="changePdfPage(1)">下一页</el-button>
            </div>
            
        </el-dialog>
        
    </div>
</template>
 
<script>
    import newProject from '../components/popup/newProject.vue'
    import prodetail from '../components/popup/prodetail.vue'
    import pdf from 'vue-pdf'
    export default {
        
        components: {
          newProject,
          prodetail,
            
            pdf
        },
        data() {
            return {
                editShow: true,
                upload_url: "",
                upload_type: "",
                upload_headers: {},
                upload_data: {},
                
                pdfUrl: "",
                currentPage: 1,
                pageCount: 0,
                
                loading_table: false,
                query: "",
                rowData:undefined,
                detailData:undefined,
                dialog_1: false,
                dialog_2: false,
                dialog_upload: false,
                dialog_pdf: false,
                pagenum: 1,
                pagesize: 15,
                total: 0,
                selected: undefined,
                labelPosition: "left",
                tableData: [],
                userId:"",
                assign:null,
                formInline: {},
                options_type:[
                    "Health technology assessment (HTA)",
                    "Clinical practice guideline (CPG)",
                    "Evidence mapping",
                    "Overview of review",
                    "Scoping review",
                    "Rapid review",
                    "Systematic review",
                    "Rapid review",
                    "Randomised controlled trial (RCT)",
                    "Other"
                ],
                
                orderBy: "",
            }
        },
        mounted() { //组件配置后,页面显示前。用于加载数据
            //this.userId = localStorage.getItem('userId');
            //this.assign = localStorage.getItem('assign');
            
            this.userId = this.$cookies.get('userId');
            this.assign = this.$cookies.get('assign');
            
            this.getData();
        },
        methods: {
            sortChange(column, prop, order) {
                this.orderBy = "";
                if (column.prop && column.order) {
                    this.orderBy = this.toLine(column.prop);
                    if (column.order == "descending") {
                        this.orderBy += " desc";
                    }
                }
                
                this.query_();
            },
            
            // 下划线转换驼峰
            toHump(name) {
                return name.replace(/\_(\w)/g, function(all, letter){
                    return letter.toUpperCase();
                });
            },
            // 驼峰转换下划线
            toLine(name) {
              return name.replace(/([A-Z])/g,"_$1").toLowerCase();
            },
            
            download() {
                if (!this.selected) {
                    this.$message({message:'请选择下载条目', type: 'warning'});
                    return;
                }
                
                if(!this.selected.id || this.selected.status == "edit"){
                    this.$message({message:'【未开始】状态不能下载', type: 'warning'});
                    return;
                }
                this.$refs.frame_export.src = "/api/api/file/timeline/" + this.selected.id;
            },
            viewHT(row) {
                this.pdfUrl = "/api/api/file/downloadPath?path=" + row.attachment;
                this.dialog_pdf = true;
                /* let url = "/api/file/downloadPath";
                let params = {
                    path: row.attachment
                };
                this.$axios.get(url, {
                        params
                    }).then(data_ => {
                        
                    }).catch(error => {
                        
                    }) */
            },
            loadPdfHandler (e) {
                this.currentPage = 1 // 加载的时候先加载第一页
            },
            changePdfPage(val) {
                    if(val === 0 && this.currentPage > 1) {
                            this.currentPage--;
                    }
                    if(val === 1 && this.currentPage < this.pageCount) {
                            this.currentPage++;
                    }
            },
            
            uploadHT(row) {
                /* this.upload_data = {
                  id: row.id
                }; */
                this.upload_url = "/api/api/file/schemeUpload/" + row.id;
                this.dialog_upload = true;
            },
            submitUpload() {
              this.$refs.upload.submit();
            },
            beforeAvatarUpload(file) {
              let FileName = file.name;
              let index1=FileName.lastIndexOf(".");
              let index2=FileName.length;
              let suffix=FileName.substring(index1, index2);//后缀名
              const isSQL = suffix === '.pdf';
            
              if (!isSQL) {
                this.$message.error('只能上传.pdf文件');
              }
              return isSQL;
            },
            handleRemove(file, fileList) {
              window.console.log(file, fileList);
            },
            handlePreview(file) {
              window.console.log(file);
            },
            uploadSuccess() {
                this.dialog_upload = false;
                this.query_();
            },
            
            Cancel() {
                this.dialog_1 = false;
                this.query_();
            },
            Cancel2() {
                this.dialog_2 = false;
                this.closeDetail();
            },
            closeDetail() {
                this.detailData = undefined;
            },
            showDetail() {
                if(!this.selected){
                    this.$message({message:'请选中一条未启动的项目', type: 'warning'});
                    return;
                }
                this.dialog_2 = true;
            },
            tableChange(val) {
                if (!val) {
                    val = {};
                }
                this.selected = val;
                this.detailData = val;
            //    this.editShow = true;
                 if (this.selected.userId == this.userId) {
                    this.editShow = true;
                }else {
                    this.editShow = false;
                }
                
            },
            handleCurrentChange(pageno) {
                this.pagenum = pageno;
                this.query_();
            },
            empty_() {
                this.formInline = {};
                this.query_();
            },
            query_() {
                this.getData(this.formInline);
            },
            getData(query) {
                this.loading_table = true;
                let pageno = this.pagenum;
                let url = "/api/scheme/page/" + pageno;
                
                let params =  {
                    pageSize: this.pagesize
                };
                if(this.assign == "true") {
                    params.userId = this.userId;
                }
                
                if (query && query.name) {
                    params.name = query.name;
                }
                if (query && query.status) {
                    params.status = query.status;
                }
                if (query && query.type) {
                    params.type = query.type;
                }
                
                if(this.orderBy) {
                    params.orderBy = this.orderBy;
                }
                
                this.$axios.get(url, {
                        params
                    })
                    .then(data_ => {
                        window.console.log(data_);
                        let clientHeight = document.documentElement.clientHeight;
                        let tableHeight_ = clientHeight - 60 - 20 - 60 - 62 - 48 - 48 - 20;
                        this.$refs.data_table.$el.getElementsByClassName('el-table__body-wrapper')[0].style['height'] = tableHeight_ - 10 + "px";// - header_height
                        this.$refs.data_table.$el.getElementsByClassName('el-table__body-wrapper')[0].style['min-height'] = tableHeight_ - 10 + "px";
                        this.$refs.data_table.$el.getElementsByClassName('el-table__body-wrapper')[0].style['overflow'] = "overlay";
                        
                        this.tableData = data_.data.data.datas.records; //给tableData赋值
                        this.total = data_.data.data.datas.total;
                        this.loading_table = false;
                    }).catch(error => {
                //        console.log(error);
                    })
            },
            tableRowClassName(row, rowIndex) {
                if (row.finish) {
                    return 'success-row';
                } else if(row.delay){
                    return 'warning-row';
                }
                return '';
            },
            onSubmit() {
                query_();
            },
            dateFormat_(row, colum, val ,index) {
                return this.$moment(val).format('YYYY-MM-DD');
            
            },
            status_(row, colum, val ,index) {
                if(val == "working") {
                    return "进行中";
                }else if(val == "edit") {
                    return "未开始";
                }else if(val == "delay") {
                    return "已延期";
                }else if(val == "finish") {
                    return "已结束";
                }
            },
            finishFotmat(row, colum, val ,index) {
                if(val) {
                    return "已结束";
                }else {
                    return "进行中";
                }
            },
            addProject() {
                this.dialog_1 = true;
                this.rowData = {};
            },
            editProject() {
                //已完成的不修改需将 finish1 改成 finish
            //    if(!this.selected || this.selected.status == "finish"){
                if(!this.selected || this.selected.status == "finish1"){
                    this.$message({message:'请选中一条未完成的项目', type: 'warning'});
                }else {
                    this.rowData = {
                        id:this.selected.id,
                        desc:this.selected.desc,
                        name: this.selected.name,
                        beginDate: this.selected.beginDate,
                        endDate: this.selected.endDate,
                        objective:this.selected.reseachType,
                        items:[this.$moment(this.selected.startTime).format('YYYY-MM-DD'),this.$moment(this.selected.endTime).format('YYYY-MM-DD')]
                    }
                    this.dialog_1 = true;
                }
                
                
            },
            closeNewProject() {
                this.dialog_1 = false;
                this.query_();
            },
            
        }
    }
</script>
 
<style>
    .btn-line {
        margin-bottom: 20px;
    }
    .el-table .warning-row {
        background: oldlace;
      }
    
      .el-table .success-row {
        background: #f0f9eb;
      }
</style>