马宇豪
2025-03-04 1b9fea7d4af68d8f933b2dc42bf6084b9646f64c
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
<template>
    <div>
        <el-dialog v-model="dialogVisible" title="选择事故名称" width="900px" draggable :fullscreen="full" @close="handleClose">
            <el-button @click="toggleFullscreen" size="small" class="pot" :icon="FullScreen"></el-button>
            <el-row>
                <el-col :span="18">
                    <el-row>
                        <el-form ref="ruleFormRef" :model="ruleForm" :inline="true" status-icon>
                            <!--<el-form-item>-->
                            <!--<el-input size="default" v-model="listQuery.searchParams.id" placeholder="id"  style="min-width: 215px;"/>-->
                            <!--</el-form-item>-->
                            <el-form-item>
                                <el-input size="default" v-model="listQuery.searchParams.accidentName" placeholder="事故名称" style="min-width: 215px" />
                            </el-form-item>
                            <!--<el-form-item>-->
                            <!--<el-input size="default" v-model="listQuery.searchParams.deptName" placeholder="事故部门"  style="min-width: 215px;"/>-->
                            <!--</el-form-item>-->
                            <!--<el-form-item>-->
                            <!--<el-input size="default" v-model="listQuery.searchParams.occurrencePlace" placeholder="发生地点"  style="min-width: 215px;"/>-->
                            <!--</el-form-item>-->
                            <!--<el-form-item>-->
                            <!--<el-input size="default" v-model="listQuery.searchParams.occurrenceTime" placeholder="发生时间"  style="min-width: 215px;"/>-->
                            <!--</el-form-item>-->
                            <el-form-item>
                                <el-button size="default" type="primary" @click="listApi">查询</el-button>
                                <el-button size="default" @click="submitReset">重置</el-button>
                                <el-button size="default" :icon="Delete" @click="handleClose">清除选择</el-button>
                            </el-form-item>
                        </el-form>
                    </el-row>
                    <!--<el-table :data="tableData" style="width: 100%;margin-top:20px">-->
                    <!--<el-table-column type="selection" width="55" />-->
                    <!--<el-table-column align="center" prop="date" label="id" />-->
                    <!--<el-table-column align="center" prop="name" label="事故名称"/>-->
                    <!--<el-table-column align="center" prop="date" label="事故部门" />-->
                    <!--<el-table-column align="center" prop="name" label="发生地点"/>-->
                    <!--<el-table-column align="center" prop="name" label="发生时间"/>-->
                    <!--</el-table>-->
                    <!--<div class="pages">-->
                    <!--<el-pagination-->
                    <!--v-model:currentPage="currentPage4"-->
                    <!--v-model:page-size="pageSize4"-->
                    <!--:page-sizes="[100, 200, 300, 400]"-->
                    <!--:small="small"-->
                    <!--:disabled="disabled"-->
                    <!--:background="background"-->
                    <!--layout="total, sizes, prev, pager, next, jumper"-->
                    <!--:total="400"-->
                    <!--@size-change="handleSizeChange"-->
                    <!--@current-change="handleCurrentChange"-->
                    <!--/>-->
                    <!--</div>-->
                    <el-table :data="tableData" style="width: 100%" ref="multipleTableRef">
                        <el-table-column align="center">
                            <template #default="scope">
                                <el-radio-group v-model="radio1">
                                    <el-radio :label="scope.row.id" size="large" @click="checkedItem(scope.row)">{{ null }}</el-radio>
                                </el-radio-group>
                            </template>
                        </el-table-column>
                        <!--<el-table-column prop="id" label="id" show-overflow-tooltip></el-table-column>-->
                        <el-table-column prop="accidentName" label="事故名称" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="deptName" label="事故部门" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="occurrencePlace" label="发生地点" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="occurrenceTime" label="发生时间" show-overflow-tooltip></el-table-column>
                    </el-table>
                    <div class="pages">
                        <el-pagination
                            v-model:currentPage="pageIndex"
                            v-model:page-size="pageSize"
                            :page-sizes="[10, 20, 30]"
                            :pager-count="5"
                            layout="total, sizes, prev, pager, next, jumper"
                            :total="total"
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                        />
                    </div>
                </el-col>
                <el-col :span="6">
                    <el-tag v-for="tag in dynamicTags" :key="tag" class="mx-1" style="margin: 5px" closable :disable-transitions="false" @close="handleClose()">
                        {{ tag.accidentName }}
                    </el-tag>
                </el-col>
            </el-row>
            <template #footer>
                <span class="dialog-footer">
                    <el-button @click="closeDialog()" size="default">关闭</el-button>
                    <el-button type="primary" @click="submitForm" size="default">确定</el-button>
                </span>
            </template>
        </el-dialog>
    </div>
</template>
<script lang="ts">
import { defineComponent, reactive, ref } from 'vue';
import { Delete, FullScreen } from '@element-plus/icons-vue';
import {
    // ElTable,
    ElMessage,
} from 'element-plus';
import { accidentManagementSystemApi } from '/@/api/workInjuryDeclaration';
export default defineComponent({
    setup(props, { emit }) {
        const dialogVisible = ref<boolean>(false);
        const openDailog = () => {
            dialogVisible.value = true;
            listApi();
        };
        // 搜索条件
        const ruleForm = reactive({
            pass: '',
        });
        // 定义表格数据
        const tableData = ref([]);
        // 列表参数
        const listQuery = reactive({
            pageIndex: 1,
            pageSize: 10,
            searchParams: {
                accidentName: '',
            },
        });
        //单选按钮
        const radio1 = ref('');
        // 分页
        const pageIndex = ref();
        const pageSize = ref();
        const total = ref();
        // 分页改变
        const handleSizeChange = (val: number) => {
            listQuery.pageSize = val;
        };
        // 分页未改变
        const handleCurrentChange = (val: number) => {
            listQuery.pageIndex = val;
        };
        const checkedItem = (row: object) => {
            dynamicTags.value = [row];
        };
        // 重置
        const submitReset = () => {
            listQuery.searchParams = {};
            listApi();
        };
        const submitForm = () => {
            emit('selectItem', dynamicTags.value);
            dialogVisible.value = false;
            radio1.value=''
        };
        //查询list数据
        const listApi = async () => {
            let res = await accidentManagementSystemApi().accidentList(listQuery);
            if (res.data.code == 200) {
                tableData.value = res.data.data;
                pageIndex.value = res.data.pageIndex;
                pageSize.value = res.data.pageSize;
                total.value = res.data.total;
            } else {
                ElMessage.error(res.data.msg);
            }
        };
        // 右方点击添加后显示标签
        const dynamicTags = ref([]);
        const closeDialog=()=>{
            dialogVisible.value = false
            handleClose()
        };
        const handleClose = () => {
            dynamicTags.value = [];
            radio1.value = '';
        };
        //全屏
        const full = ref(false);
        const toggleFullscreen = () => {
            if (full.value == false) {
                full.value = true;
            } else {
                full.value = false;
            }
        };
        return {
            dialogVisible,
            openDailog,
            ruleForm,
            tableData,
            handleSizeChange,
            handleCurrentChange,
            dynamicTags,
            handleClose,
            Delete,
            toggleFullscreen,
            FullScreen,
            full,
            pageIndex,
            pageSize,
            total,
            listApi,
            listQuery,
            radio1,
            checkedItem,
            submitReset,
            submitForm,
            closeDialog
        };
    },
});
</script>
<style scoped>
.el-form--inline .el-form-item {
    margin-bottom: 18px !important;
    margin-right: 12px;
}
/*分页*/
.pages {
    margin-top: 15px;
}
::v-deep .el-pagination .el-pager li {
    margin: 0 5px;
    background-color: #f4f4f5;
    color: #606266;
    min-width: 30px;
    border-radius: 2px;
}
::v-deep .el-pagination .el-pager li.is-active {
    background-color: #409eff;
    color: #fff;
}
::v-deep .el-pagination .btn-prev {
    margin: 0 5px;
    background-color: #f4f4f5;
    color: #606266;
    min-width: 30px;
    border-radius: 2px;
}
::v-deep .el-pagination button:disabled {
    color: #c0c4cc;
}
::v-deep .el-pagination .btn-next {
    margin: 0 5px;
    background-color: #f4f4f5;
    color: #606266;
    min-width: 30px;
    border-radius: 2px;
}
</style>