Kxc0822a
2022-04-12 5f989f9ab035126a8272c63542caa1f2d1b02b3a
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
<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" icon="el-icon-plus" @click="onSubmit">添加</el-button>
                        <el-button>批量删除</el-button>
                    </el-form-item>
                </el-form>
                <el-table
                    :data="tableData"
                    size="mini"
                    style="width: 1600px"
                    @cell-mouse-enter="handleCellEnter"
                    @cell-mouse-leave="handleCellLeave"
                    @cell-click="handleCellClick"
                >
                    <el-table-column
                       type="selection"
                       align="center"
                       width="55">
                    </el-table-column>
                    <el-table-column
                        prop="fillingTime"
                        align="center"
                        width="220"
                        label="填报时间">
                        <div class="item" slot-scope="scope">
<!--                            <el-input class="item__input" v-model="scope.row.fillingTime" placeholder="请输入内容"></el-input>-->
                            <el-date-picker
                                class="item__input"
                                v-model="scope.row.fillingTime"
                                type="date"
                                ref="saveDateInput"
                                placeholder="选择日期" clearable>
                            </el-date-picker>
                            <div class="item__txt">{{scope.row.fillingTime}}</div>
                        </div>
                    </el-table-column>
                    <el-table-column
                        prop="filledBy"
                        align="center"
                        width="300"
                        label="填报人">
                        <div class="item" slot-scope="scope">
                            <el-input class="item__input" v-model="scope.row.filledBy" placeholder="请输入内容"></el-input>
                            <div class="item__txt">{{scope.row.filledBy}}</div>
                        </div>
                    </el-table-column>
                    <el-table-column
                        prop="progress"
                        label="整改形象进度"
                        width="300"
                        align="center">
                        <div class="item" slot-scope="scope">
                            <el-input class="item__input" v-model="scope.row.progress" placeholder="请输入内容" clearable></el-input>
                            <div class="item__txt">{{scope.row.progress}}</div>
                        </div>
                    </el-table-column>
                    <el-table-column
                        prop="remarks"
                        label="备注"
                        align="center">
                        <div class="item" slot-scope="scope">
                            <el-input type="textarea" class="item__input" v-model="scope.row.remarks" placeholder="请输入内容" clearable></el-input>
                            <div class="item__txt">{{scope.row.remarks}}</div>
                        </div>
                    </el-table-column>
                    <el-table-column
                        label="操作"
                        align="center"
                        width="200">
                        <template slot-scope="scope">
                            <el-button type="text" size="small">编辑</el-button>
                            <el-button @click="save(scope.row)" type="text" size="small">保存</el-button>
                            <el-button type="text" size="small" style="color: #f56c6c">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
        </div>
 
    </div>
</template>
 
<script>
    import Titlename from "../../components/Titlename/index.vue";
    export default {
        components: {Titlename},
        name: "fillProgress",
        data(){
            return{
                // tableData: [],
                tableData: [{
                    fillingTime: '2016-05-02',
                    progress: '无进度',
                    remarks: '222222222',
                    filledBy:'王小虎'
                }, {
                    fillingTime: '2016-05-02',
                    progress: '无进度',
                    remarks: '222222222',
                    filledBy:'王小虎'
                }],
                // // 需要编辑的属性
                // editProp: ['fillingTime', 'progress', 'remarks'],
                // // 保存进入编辑的cell
                // clickCellMap: {},
                // 需要编辑的属性
                editProp: ['fillingTime', 'progress', 'remarks','filledBy'],
                // 保存进入编辑的cell
                clickCellMap: {}
            }
        },
        methods: {
            /** 鼠标移入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] = []
            },
        }
    }
</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>