餐饮油烟智能监测与监管一体化平台
riku
2026-03-13 e365192a36d6d9432fbd00ea9d577a38f8679707
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
<template>
  <div>
    <el-row class="sub-title" justify="space-between">
      <div>行政处罚记录</div>
      <el-button-group>
        <el-button type="primary" @click="handleAdd">
          <el-icon><Plus /></el-icon>
          <span>新增处罚记录</span>
        </el-button>
        <el-button type="success" @click="dialogImportVisible = true">
          <el-icon><Upload /></el-icon>
          <span>导入记录</span>
        </el-button>
      </el-button-group>
    </el-row>
 
    <!-- 表格展示 -->
    <el-table :data="punishmentList" style="width: 100%">
      <el-table-column prop="name" label="处罚事项" width="180" />
      <el-table-column prop="punishTime" label="处罚时间" width="180" />
      <el-table-column prop="reason" label="处罚理由" />
      <el-table-column prop="result" label="处罚结果" width="180" />
      <el-table-column prop="department" label="处罚部门" width="180" />
      <el-table-column label="操作" width="150" fixed="right">
        <template #default="scope">
          <el-button size="small" @click="handleEdit(scope.row)">修改</el-button>
          <el-button size="small" type="danger" @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
 
    <!-- 空状态 -->
    <div v-if="punishmentList.length === 0" class="empty-state">
      <el-empty description="暂无行政处罚记录" />
    </div>
 
    <!-- 新增/编辑对话框 -->
    <el-dialog v-model="dialogVisible" :title="dialogTitle" width="50%">
      <el-form :model="form" :rules="rules" ref="formRef" label-width="120px">
        <el-form-item label="行政处罚名称" prop="name">
          <el-input v-model="form.name" placeholder="请输入行政处罚名称" />
        </el-form-item>
        <el-form-item label="处罚时间" prop="punishTime">
          <el-date-picker
            v-model="form.punishTime"
            type="date"
            placeholder="请选择处罚时间"
            style="width: 100%"
          />
        </el-form-item>
        <el-form-item label="处罚理由" prop="reason">
          <el-input v-model="form.reason" placeholder="请输入处罚理由" type="textarea" rows="3" />
        </el-form-item>
        <el-form-item label="处罚结果" prop="result">
          <el-input v-model="form.result" placeholder="请输入处罚结果" />
        </el-form-item>
        <el-form-item label="处罚部门" prop="department">
          <el-input v-model="form.department" placeholder="请输入处罚部门" />
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="dialogVisible = false">取消</el-button>
          <el-button type="primary" @click="handleSubmit">确定</el-button>
        </span>
      </template>
    </el-dialog>
 
    <!-- Excel导入对话框 -->
    <el-dialog v-model="dialogImportVisible" title="导入处罚记录" width="50%">
      <el-upload
        class="upload-demo"
        action="#"
        :auto-upload="false"
        :on-change="handleFileChange"
        :show-file-list="false"
        accept=".xlsx,.xls"
      >
        <el-button type="primary">选择Excel文件</el-button>
        <template #tip>
          <div class="el-upload__tip">请上传.xlsx或.xls格式的文件</div>
        </template>
      </el-upload>
      <div v-if="uploadedFile" class="uploaded-file">
        <el-icon><Document /></el-icon>
        <span>{{ uploadedFile.name }}</span>
        <el-button type="text" @click="uploadedFile = null">移除</el-button>
      </div>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="dialogImportVisible = false">取消</el-button>
          <el-button type="primary" @click="handleImport" :loading="importLoading">导入</el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>
 
<script setup>
import { ref, reactive, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Upload, Document } from '@element-plus/icons-vue'
 
// 表单数据
const form = reactive({
  name: '',
  punishTime: '',
  reason: '',
  result: '',
  department: '',
})
 
// 验证规则
const rules = reactive({
  name: [{ required: true, message: '请输入行政处罚名称', trigger: 'blur' }],
  punishTime: [{ required: true, message: '请输入处罚时间', trigger: 'blur' }],
  reason: [{ required: true, message: '请输入处罚理由', trigger: 'blur' }],
  result: [{ required: true, message: '请输入处罚结果', trigger: 'blur' }],
  department: [{ required: true, message: '请输入处罚部门', trigger: 'blur' }],
})
 
// 状态
const dialogVisible = ref(false)
const dialogImportVisible = ref(false)
const dialogTitle = ref('新增行政处罚')
const formRef = ref(null)
const punishmentList = ref([])
const currentRow = ref(null)
const uploadedFile = ref(null)
const importLoading = ref(false)
 
// 模拟数据
onMounted(() => {
  // 这里可以从API获取数据
  // 暂时使用模拟数据
  punishmentList.value = [
    {
      id: 1,
      name: '违规排放废气',
      punishTime: '2026-01-15',
      reason: '未按规定处理废气,超标排放',
      result: '罚款5000元',
      department: '环保局',
    },
    {
      id: 2,
      name: '未安装油烟净化设备',
      punishTime: '2026-02-20',
      reason: '餐厅未安装油烟净化设备',
      result: '责令限期整改',
      department: '环保局',
    },
  ]
})
 
// 新增
function handleAdd() {
  form.name = ''
  form.punishTime = ''
  form.reason = ''
  form.result = ''
  form.department = ''
  dialogTitle.value = '新增行政处罚'
  currentRow.value = null
  dialogVisible.value = true
}
 
// 编辑
function handleEdit(row) {
  currentRow.value = row
  form.name = row.name
  form.punishTime = row.punishTime
  form.reason = row.reason
  form.result = row.result
  form.department = row.department
  dialogTitle.value = '修改行政处罚'
  dialogVisible.value = true
}
 
// 删除
function handleDelete(row) {
  ElMessageBox.confirm('确定要删除这条记录吗?', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning',
  })
    .then(() => {
      const index = punishmentList.value.findIndex((item) => item.id === row.id)
      if (index !== -1) {
        punishmentList.value.splice(index, 1)
        ElMessage.success('删除成功')
      }
    })
    .catch(() => {
      // 取消删除
    })
}
 
// 提交
function handleSubmit() {
  formRef.value.validate((valid) => {
    if (valid) {
      if (currentRow.value) {
        // 修改
        const index = punishmentList.value.findIndex((item) => item.id === currentRow.value.id)
        if (index !== -1) {
          punishmentList.value[index] = {
            ...currentRow.value,
            ...form,
          }
          ElMessage.success('修改成功')
        }
      } else {
        // 新增
        const newItem = {
          id: Date.now(),
          ...form,
        }
        punishmentList.value.push(newItem)
        ElMessage.success('新增成功')
      }
      dialogVisible.value = false
    }
  })
}
 
// 处理文件选择
function handleFileChange(file) {
  uploadedFile.value = file.raw
}
 
// 处理Excel导入
function handleImport() {
  if (!uploadedFile.value) {
    ElMessage.warning('请选择要导入的Excel文件')
    return
  }
 
  importLoading.value = true
 
  // 这里可以添加实际的Excel解析和导入逻辑
  // 暂时模拟导入过程
  setTimeout(() => {
    // 模拟导入数据
    const importedData = [
      {
        id: Date.now() + 1,
        name: '未按规定排放污水',
        punishTime: '2026-03-05',
        reason: '未按规定处理污水,超标排放',
        result: '罚款8000元',
        department: '环保局',
      },
      {
        id: Date.now() + 2,
        name: '违规倾倒固废',
        punishTime: '2026-03-12',
        reason: '违规倾倒固体废物',
        result: '罚款10000元',
        department: '环保局',
      },
    ]
 
    // 添加到列表
    punishmentList.value.push(...importedData)
 
    ElMessage.success('导入成功,共导入2条记录')
    dialogImportVisible.value = false
    uploadedFile.value = null
    importLoading.value = false
  }, 1500)
}
</script>
 
<style scoped>
.empty-state {
  padding: 40px 0;
  text-align: center;
}
.sub-title {
  margin-bottom: 20px;
}
.uploaded-file {
  margin-top: 20px;
  padding: 10px;
  border: 1px solid #e4e7ed;
  border-radius: 4px;
  display: flex;
  align-items: center;
}
.uploaded-file span {
  margin-left: 10px;
  flex: 1;
}
.uploaded-file .el-button {
  margin-left: 10px;
}
</style>