xiangpei
2025-06-06 31d78dd4e988cfce8f0a16678f2041849cc0dce3
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
<template>
    <div>
        <div class="search-bar">
            <div>
                <label>会议主题</label>
                <el-input type="text" v-model="searchParams.topic" size="small" />
            </div>
            <div>
                <label>主持人</label>
                <el-input type="text" v-model="searchParams.host"  size="small"/>
            </div>
            <div>
                <label>会议地址</label>
                <el-input type="text" v-model="searchParams.place"  size="small" />
            </div>
            <div>
                <label>参会人员</label>
                <el-input type="text" v-model="searchParams.peoplelist" size="small" />
            </div>
            <div>
                <el-button type="primary" @click="search" size="mini" icon="el-icon-search">搜索</el-button>
                <el-button type="default" @click="reset" size="mini" icon="el-icon-refresh">重置</el-button>
            </div>
        </div>
        <table-template
            :data="tableData"
            :total="total"
            selection
            @selection-change="handleSelectionChange"
            @page-change="handlePageChange"
        >
            <template #toolbar>
                <el-button type="primary" @click="dialogVisible = true" plain icon="el-icon-plus" size="mini">添加</el-button>
                <el-button type="danger" :disabled="currentSelection.length === 0" @click="handleDelelteMultiple" plain icon="el-icon-delete" size="mini">删除</el-button>
            </template>
            <template #columns>
                <el-table-column
                    prop="topic"
                    label="会议主题">
                </el-table-column>
                <el-table-column
                    prop="host"
                    label="主持人">
                </el-table-column>
                <el-table-column
                    prop="place"
                    label="会议地址">
 
                </el-table-column>
                <el-table-column
                    prop="peoplelist"
                    label="参会人员">
                </el-table-column>
                <el-table-column
                    prop="startTime"
                    label="开始时间">
                </el-table-column>
                <el-table-column
                    prop="endTime"
                    label="结束时间">
                </el-table-column>
                <el-table-column
                    prop="operation"
                    label="操作">
                    <template slot-scope="scope">
                        <el-button
                        size="mini"
                        type="text"
                        icon="el-icon-delete"
                        @click="handleDelete(scope.$index, scope.row)">删除</el-button>
                    </template>
                </el-table-column>
            </template>
        </table-template>
        <el-dialog :visible.sync="dialogVisible" width="600px">
            <el-form ref="form" :model="form" label-width="110px">
                <el-form-item label="会议主题">
                    <el-input v-model="form.topic"></el-input>
                </el-form-item>
                <el-form-item label="主持人">
                    <el-input v-model="form.host" disabled></el-input>
                </el-form-item>
                <el-form-item label="会议地址">
                    <el-input v-model="form.place"></el-input>
                </el-form-item>
                <el-form-item label="参会人员">
                    <el-select v-model="form.peoplelist" multiple>
                        <el-option
                            v-for="(user, i) in userList" 
                            :key="i"
                            :label="user.userName"
                            :value="user.userName"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="开始时间">
                    <el-date-picker type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期" v-model="form.startTime" style="width: 100%;"></el-date-picker>
                </el-form-item>
                <el-form-item label="结束时间">
                    <el-date-picker type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期" v-model="form.endTime" style="width: 100%;"></el-date-picker>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="handleAdd">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>
 
<script>
import TableTemplate from "@/components/TableTemplate";
import {getMeetingList, addMeeting, deleteMeeting, exportMeeting} from "./api/meeting";
import {listUser} from "@/api/system/user.js"
export default {
    name: "leaveApply",
    components: {
        TableTemplate
    },
    data() {
        return {
            responseData: {},
            dialogVisible: false,
            form: {
                topic: "",
                host: this.$store.state.user.name,
                place: "",
                peoplelist: [],
                startTime: "",
                endTime: ""
            },
            searchParams: {
                pageNum: 1,
                pageSize: 10,
                topic: "",
                host: "",
                place: "",
                peoplelist: "",
            },
            currentSelection: [],
            userList: []
        };
    },
    computed: {
        tableData() {
            return this.responseData.rows || []
        },
        total() {
            return this.responseData.total || 0
        },
        selectionIds() {
            return this.currentSelection.map(item => item.id)
        }
    },
    mounted() {
        this.getMeetingListAndRender(this.searchParams);
        listUser().then(res => {
            console.log("获取用户", res);
            this.userList = res.rows;
        });
    },
    methods: {
        getMeetingListAndRender(params) {
            const {pageNum = 1, pageSize = 10, topic, host, place, peoplelist} = params;
            getMeetingList({
                pageNum,
                pageSize,
                topic,
                host,
                place,
                peoplelist,
                isAsc: "asc"
            }).then(res => {
                this.responseData = res;
            });
        },
        handleAdd() {
            console.log("填写的form值是", this.form);
            const params = Object.assign({}, this.form, {
                peoplelist: this.form.peoplelist.join()
            });
            addMeeting(params).then(res => {
                this.dialogVisible = false;
                this.$message.success("添加成功");
                this.getMeetingListAndRender(this.searchParams);
            });
        },
        handleDelete(index, row) {
            this.$confirm('确定删除吗?', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                const {id} = row;
                this.deleteByIdsAndRender(id)
            });
        },
        handleDelelteMultiple() {
            this.$confirm(`确定删除选中的${this.currentSelection.length}条数据吗?`, {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                const ids = this.selectionIds.join(",");
                this.deleteByIdsAndRender(ids)
            });
        },
        handleExport() {
            this.$confirm('确定导出所有数据吗?', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                exportMeeting(this.searchParams)
            });
        },
        search() {
            this.getMeetingListAndRender(this.searchParams);
        },
        reset() {
            this.searchParams.topic = "";
            this.searchParams.host = "";
            this.searchParams.place = "";
            this.searchParams.peoplelist = "";
            this.getMeetingListAndRender(this.searchParams);
        },
        deleteByIdsAndRender(ids) {
            deleteMeeting({
                ids
            }).then(() => {
                this.$message.error("删除成功!")
                this.getMeetingListAndRender(this.searchParams);
            })
        },
        handleSelectionChange(selection) {
            this.currentSelection = selection;
        },
        handlePageChange({pageNum, pageSize}) {
            this.searchParams.pageNum = pageNum;
            this.searchParams.pageSize = pageSize;
            this.getMeetingListAndRender(this.searchParams);
        }
    }
};
</script>
 
<style scoped>
.search-bar label {
    font-size: 14px;
    color: #606266;
    margin-right: 8px;
}
.search-bar {
    display: flex;
    margin-top: 8px;
    margin-left: 8px;
}
.search-bar .el-input {
    display: inline-block;
    width: 200px;
    margin-right: 10px;
}
</style>