lyfO_o
2022-07-12 c562fa2e66f4972ae23fa57ef7412da6e18991ed
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
<template>
    <div class="app-container">
        <div>
            <Titlename title="进度列表页面"></Titlename>
            <div class="whole">
                <el-form ref="form" :model="form" label-width="100px">
                    <el-form-item style="text-align: right;">
                        <el-button class="btn" type="primary" size="small" icon="el-icon-plus" @click="addProgress" v-if="type!=1">添加</el-button>
                        <el-button size="small" @click="deleteBatch" v-if="type!=1">批量删除</el-button>
                    </el-form-item>
                </el-form>
                <el-table
                    type="selection"
                    :data="tableData"
                    style="width: 1600px"
                    @selection-change="changeBox"
                    border
                >
                    <el-table-column
                       type="selection"
                       align="center"
                       v-if="type!=1"
                       width="55">
                    </el-table-column>
                    <el-table-column
                        prop="FillinTime"
                        align="center"
                        width="220"
                        label="填报时间">
 
                    </el-table-column>
                    <el-table-column
                        prop="FillinPople"
                        align="center"
                        width="300"
                        label="填报人">
 
                    </el-table-column>
                    <el-table-column
                        prop="RectProgrees"
                        label="整改形象进度"
                        width="300"
                        align="center">
                    </el-table-column>
                    <el-table-column
                        prop="Remark"
                        label="备注"
                        align="center">
                    </el-table-column>
                    <el-table-column
                        v-if="type!=1"
                        label="操作"
                        align="center"
                        width="200">
                        <template slot-scope="scope">
                            <el-button type="text" size="small" @click="updateClick(scope.row)" v-if="type!=1">编辑</el-button>
                           <!-- <el-button @click="save(scope.row)" type="text" size="small">保存</el-button>-->
                            <el-button type="text" size="small" style="color: #f56c6c" @click="deleteClick(scope.row)" v-if="type!=1">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <div style="text-align: right">
                    <el-pagination
                        v-show="recordTotal > 0"
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page="currentPage"
                        :page-sizes="[10, 20, 30, 50]"
                        :page-size="pageSize"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="recordTotal"
                    >
                    </el-pagination>
                </div>
            </div>
        </div>
 
        <el-button @click="returnIndex">返回</el-button>
        <el-dialog
            :title="title"
            :visible.sync="dialogVisible"
            :close-on-click-modal="false"
            width="40%">
            <el-form ref="form" :rules="rules" :model="form" label-width="100px">
                <el-row>
                    <el-col :span="9">
                        <el-form-item label="填报时间" prop="FillinTime">
                            <el-date-picker
                                v-model="form.FillinTime"
                                type="date"
                                value-format="yyyy-MM-dd"
                                placeholder="选择日期"
                                style="width: 100%"
                            >
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="9" :offset="4">
                        <el-form-item label="填报人" prop="FillinPople">
                            <el-input v-model="form.FillinPople"  class="multiline"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="9">
                        <el-form-item label="进度" prop="RectProgrees">
                            <el-input v-model="form.RectProgrees" type="textarea" :rows="3"  class="multiline"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
 
                <el-row>
                    <el-col :span="9">
                        <el-form-item label="备注" prop="Remark ">
                            <el-input v-model="form.Remark " type="textarea" :rows="3"  class="multiline"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="22">
                        <el-form-item style="text-align: center">
                            <el-button type="primary" class="btns" @click="submitProgress('form')"
                            >保存</el-button
                            >
                            <el-button @click="dialogVisible=false">关闭</el-button>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </el-dialog>
 
    </div>
</template>
 
<script>
    import Titlename from "../../components/Titlename/index.vue";
    import {saveProcess,viewProcess,deleteProcess} from '@/api/sgyhpczl/majorHidden.js'
    import { deepClone } from '@/utils'
    export default {
        components: {Titlename},
        name: "fillProgress",
        data(){
            return{
                selectedList:[],
                rules:{
                    FillinTime: [{ required: true, message: '不能为空', trigger: 'blur' },],
                    FillinPople: [{ required: true, message: '不能为空', trigger: 'blur' },],
                    RectProgrees: [{ required: true, message: '不能为空', trigger: 'blur' },],
                },
                form:{},
                title:'新增',
                dialogVisible:false,
                id:'',
                type:'',
                listQuery:{
                    page:1,
                    limit:10,
                    form:{
                        id:''
                    },
                },
                recordTotal: 0,
                tableData: [],
                currentPage: 1,
                pageSize: 10,
                editProp: ['fillingTime', 'progress', 'remarks','filledBy'],
                clickCellMap: {}
            }
        },
        mounted() {
            this.id = this.$route.query.id;
            this.listQuery.form.id = this.$route.query.id;
            this.type = this.$route.query.type;
            this.getPageList()
        },
        methods: {
            deleteBatch(){
                if(this.selectedList==null ||this.selectedList.length==0 ){
                    this.$message({type:'warning', message:'至少选中一条数据', duration:3000})
                    return
                }
                var ids=this.selectedList.map((obj) => {
                    return obj.id
                }).join(",")
                this.$confirm('确认删除吗','提示', {
                    confirmButtonText: '确认',
                    cancelButtonText: '取消',
                    type: 'warning'
                })
                    .then(()=>{
                        deleteProcess(ids).then(() => {
                            this.getPageList()
                            this.$notify({
                                title: "成功",
                                message: "删除成功",
                                type: "success",
                                duration: 2000,
                            });
                        });
                    })
                    .catch(error =>{
                    });
            },
            changeBox(val){
                this.selectedList = []
                val.forEach((item) => {
                    this.selectedList.push(item)
                })
            },
            deleteClick(row){
                this.$confirm('确认删除吗','提示', {
                    confirmButtonText: '确认',
                    cancelButtonText: '取消',
                    type: 'warning'
                })
                    .then(()=>{
                        deleteProcess(row.id).then(() => {
                            this.getPageList()
                            this.$notify({
                                title: "成功",
                                message: "删除成功",
                                type: "success",
                                duration: 2000,
                            });
                        });
                    })
                    .catch(error =>{
                    });
            },
            updateClick(row){
                this.form=deepClone(row)
                this.title='编辑'
                this.dialogVisible=true
            },
            addProgress(){
                this.form={
                    yh_id:this.id
                }
                this.title='新增'
                this.dialogVisible=true
            },
            submitProgress(formName){
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        if(this.title=='新增'){
                            saveProcess(this.form).then(res=>{
                                if(res.data.ok==1){
                                    this.getPageList()
                                    this.dialogVisible=false
                                    this.$message({type:'success', message:'新增成功', duration:3000})
                                }else {
                                    this.$message({type:'error', message:res.data.msg, duration:3000})
                                }
                            })
                        }else {
                            saveProcess(this.form).then(res=>{
                                if(res.data.ok==1){
                                    this.getPageList()
                                    this.dialogVisible=false
                                    this.$message({type:'success', message:'编辑成功', duration:3000})
                                }else {
                                    this.$message({type:'error', message:res.data.msg, duration:3000})
                                }
                            })
                        }
                        this.dialogVisible=false
 
                    } else {
                        return false;
                    }
                });
            },
            getPageList(){
                this.listQuery.page=1
                viewProcess(this.listQuery).then(res=>{
                    if (res.data.ok==1) {
                        this.tableData = res.data.data.items
                        this.recordTotal=res.data.data.total
                    }else{
                        this.$message({type:'error', message:res.data.msg, duration:3000})
                    }
                })
            },
            handleSizeChange(val){
                this.listQuery.limit = val
                this.getPageListForPagination();
            },
            handleCurrentChange(val){
                this.listQuery.page = val
                this.getPageListForPagination();
            },
            getPageListForPagination(){
                viewProcess(this.listQuery).then(res=>{
                    if (res.data.ok==1) {
                        this.tableData = res.data.data.items
                        this.recordTotal=res.data.data.total
                    }else{
                        this.$message({type:'error', message:res.data.msg, duration:3000})
                    }
                })
            },
            /** 鼠标移入cell */
            handleCellEnter (row, column, cell, event) {
                const property = column.property
                if (property === 'date' || property === 'name' || property === 'food') {
                    cell.querySelector('.item__txt').classList.add('item__txt--hover')
                }
            },
            /** 鼠标移出cell */
            handleCellLeave (row, column, cell, event) {
                const property = column.property
                if (this.editProp.includes(property)) {
                    cell.querySelector('.item__txt').classList.remove('item__txt--hover')
                }
            },
            /** 点击cell */
            handleCellClick (row, column, cell, event) {
                const property = column.property
                if (this.editProp.includes(property)) {
                    // 保存cell
                    this.saveCellClick(row, cell)
                    cell.querySelector('.item__txt').style.display = 'none'
                    cell.querySelector('.item__input').style.display = 'block'
                    cell.querySelector('input').focus()
                }
            },
            /** 取消编辑状态 */
            cancelEditable (cell) {
                cell.querySelector('.item__txt').style.display = 'block'
                cell.querySelector('.item__input').style.display = 'none'
            },
            /** 保存进入编辑的cell */
            saveCellClick (row, cell) {
                const id = row.id
                if (this.clickCellMap[id] !== undefined) {
                    if (!this.clickCellMap[id].includes(cell)) {
                        this.clickCellMap[id].push(cell)
                    }
                } else {
                    this.clickCellMap[id] = [cell]
                }
            },
            /** 保存数据 */
            save (row) {
                const id = row.id
                // 取消本行所有cell的编辑状态
                this.clickCellMap[id].forEach(cell => {
                    this.cancelEditable(cell)
                })
                this.clickCellMap[id] = []
            },
            returnIndex(){
                this.$router.push({
                    path:"/accidentHidden/accidentHidden/majorHidden"
                })
            },
        }
    }
</script>
 
<style scoped>
    .app-container {
        padding: 20px;
        height: 850px;
        overflow-y: auto;
    }
    .btn {
        background-color: #034ea2;
        border: 1px solid #034ea2;
    }
    .item .item__input{
        display: none;
        font-size: 14px;
    }
    .item .item__input .el-input__inner{
        height: 24px!important;
    }
    /*/deep/ .el-input__inner{*/
    /*    width: 200px;*/
    /*}*/
    /*/deep/ .el-textarea__inner{*/
    /*    width: 200px;*/
    /*}*/
    .item .item__input .el-input__suffix i{
        font-size: 14px !important;
        line-height: 26px !important;
    }
    .item .item__txt{
        box-sizing: border-box;
        border: 1px solid transparent;
        width: 100%;
        line-height: 24px;
        font-size: 14px;
        padding: 0 8px;
    }
 
</style>