| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div> |
| | | <!-- æç´¢åºå --> |
| | | <el-form :model="searchForm" label-width="100px" class="search-form"> |
| | | <el-form-item label="ä¼è®®å®¤åç§°"> |
| | | <el-input v-model="searchForm.name" placeholder="请è¾å
¥ä¼è®®å®¤åç§°" clearable /> |
| | | </el-form-item> |
| | | <el-form-item label="ä½ç½®"> |
| | | <el-input v-model="searchForm.location" placeholder="请è¾å
¥ä½ç½®" clearable /> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" @click="handleSearch">æç´¢</el-button> |
| | | <el-button @click="resetSearch">éç½®</el-button> |
| | | </el-form-item> |
| | | <el-form-item class="search-actions"> |
| | | <el-button @click="handleExport">导åº</el-button> |
| | | <el-button type="primary" @click="handleAdd"> |
| | | <el-icon><Plus /></el-icon> |
| | | æ°å¢ä¼è®®å®¤ |
| | | </el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | |
| | | <!-- ä¼è®®å®¤å表 --> |
| | | <el-card> |
| | | <el-table v-loading="loading" :data="meetingRoomList" border :height="tableHeight"> |
| | | <el-table-column prop="name" label="ä¼è®®å®¤åç§°" align="center" /> |
| | | <el-table-column prop="location" label="ä½ç½®" align="center" /> |
| | | <el-table-column prop="capacity" label="容纳人æ°" align="center" /> |
| | | <el-table-column prop="equipment" label="设å¤é
ç½®" align="center"> |
| | | <template #default="scope"> |
| | | <el-tag v-for="item in scope.row.equipment" :key="item" style="margin-right: 5px; margin-bottom: 5px;"> |
| | | {{ item }} |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="status" label="ç¶æ" align="center" width="100"> |
| | | <template #default="scope"> |
| | | <el-tag :type="scope.row.status === 1 ? 'success' : 'danger'"> |
| | | {{ scope.row.status === 1 ? 'å¯ç¨' : 'ç¦ç¨' }} |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="æä½" align="center" width="200"> |
| | | <template #default="scope"> |
| | | <el-button type="primary" link @click="handleEdit(scope.row)">ç¼è¾</el-button> |
| | | <el-button type="danger" link @click="handleDelete(scope.row)">å é¤</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <!-- å页 --> |
| | | <pagination |
| | | v-show="total > 0" |
| | | :total="total" |
| | | v-model:page="queryParams.current" |
| | | v-model:limit="queryParams.size" |
| | | @pagination="getList" |
| | | /> |
| | | </el-card> |
| | | |
| | | <!-- æ·»å /ç¼è¾å¯¹è¯æ¡ --> |
| | | <el-dialog :title="dialogTitle" v-model="dialogVisible" width="600px" @close="cancel"> |
| | | <el-form ref="meetingRoomFormRef" :model="meetingRoomForm" :rules="rules" label-width="100px"> |
| | | <el-form-item label="ä¼è®®å®¤åç§°" prop="name"> |
| | | <el-input v-model="meetingRoomForm.name" placeholder="请è¾å
¥ä¼è®®å®¤åç§°" /> |
| | | </el-form-item> |
| | | <el-form-item label="ä½ç½®" prop="location"> |
| | | <el-input v-model="meetingRoomForm.location" placeholder="请è¾å
¥ä¼è®®å®¤ä½ç½®" /> |
| | | </el-form-item> |
| | | <el-form-item label="容纳人æ°" prop="capacity"> |
| | | <el-input-number v-model="meetingRoomForm.capacity" :min="1" placeholder="请è¾å
¥å®¹çº³äººæ°" /> |
| | | </el-form-item> |
| | | <el-form-item label="设å¤é
ç½®" prop="equipment"> |
| | | <el-select v-model="meetingRoomForm.equipment" multiple placeholder="è¯·éæ©è®¾å¤é
ç½®" style="width: 100%"> |
| | | <el-option |
| | | v-for="item in equipmentOptions" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="ç¶æ" prop="status"> |
| | | <el-radio-group v-model="meetingRoomForm.status"> |
| | | <el-radio :label="1">å¯ç¨</el-radio> |
| | | <el-radio :label="0">ç¦ç¨</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | <el-form-item label="夿³¨" prop="remark"> |
| | | <el-input v-model="meetingRoomForm.remark" type="textarea" placeholder="请è¾å
¥å¤æ³¨" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | | <el-button type="primary" @click="submitForm">ç¡® å®</el-button> |
| | | <el-button @click="cancel">å æ¶</el-button> |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, reactive, onMounted, getCurrentInstance } from 'vue' |
| | | import { ElMessage, ElMessageBox } from 'element-plus' |
| | | import { Plus } from '@element-plus/icons-vue' |
| | | import Pagination from '@/components/Pagination/index.vue' |
| | | import {getMeetingRoomList,saveRoom,delRoom} from '@/api/collaborativeApproval/meeting.js' |
| | | |
| | | // æ°æ®å表å è½½ç¶æ |
| | | const loading = ref(false) |
| | | |
| | | // æ»æ¡æ° |
| | | const total = ref(0) |
| | | |
| | | // è¡¨æ ¼é«åº¦ï¼æ ¹æ®çªå£é«åº¦èªéåºï¼ |
| | | const tableHeight = ref(window.innerHeight - 380) |
| | | |
| | | // ä¼è®®å®¤åè¡¨æ°æ® |
| | | const meetingRoomList = ref([]) |
| | | |
| | | // æ¥è¯¢åæ° |
| | | const queryParams = reactive({ |
| | | current: 1, |
| | | size: 10 |
| | | }) |
| | | |
| | | // æç´¢è¡¨å |
| | | const searchForm = reactive({ |
| | | name: '', |
| | | location: '' |
| | | }) |
| | | |
| | | // å¯¹è¯æ¡æ é¢ |
| | | const dialogTitle = ref('') |
| | | |
| | | // æ¯å¦æ¾ç¤ºå¯¹è¯æ¡ |
| | | const dialogVisible = ref(false) |
| | | |
| | | // 设å¤é
ç½®é项 |
| | | const equipmentOptions = ref([ |
| | | { value: 'æå½±ä»ª', label: 'æå½±ä»ª' }, |
| | | { value: 'çµè§', label: 'çµè§' }, |
| | | { value: 'é³å', label: 'é³å' }, |
| | | { value: 'çµè¯', label: 'çµè¯' }, |
| | | { value: 'è§é¢ä¼è®®ç³»ç»', label: 'è§é¢ä¼è®®ç³»ç»' }, |
| | | { value: 'ç½æ¿', label: 'ç½æ¿' }, |
| | | { value: 'ååæ¿', label: 'ååæ¿' }, |
| | | { value: 'æ 线ç½ç»', label: 'æ 线ç½ç»' } |
| | | ]) |
| | | |
| | | // è¡¨åæ°æ® |
| | | const meetingRoomForm = reactive({ |
| | | id: undefined, |
| | | name: '', |
| | | location: '', |
| | | capacity: 10, |
| | | equipment: [], |
| | | status: 1, |
| | | remark: '' |
| | | }) |
| | | |
| | | // è¡¨åæ ¡éªè§å |
| | | const rules = { |
| | | name: [{ required: true, message: 'ä¼è®®å®¤åç§°ä¸è½ä¸ºç©º', trigger: 'blur' }], |
| | | location: [{ required: true, message: 'ä½ç½®ä¸è½ä¸ºç©º', trigger: 'blur' }], |
| | | capacity: [{ required: true, message: '容纳人æ°ä¸è½ä¸ºç©º', trigger: 'blur' }] |
| | | } |
| | | |
| | | // 表åå¼ç¨ |
| | | const meetingRoomFormRef = ref(null) |
| | | |
| | | // æ¥è¯¢æ°æ® |
| | | const getList = async () => { |
| | | loading.value = true |
| | | |
| | | let resp = await getMeetingRoomList({...searchForm,...queryParams}) |
| | | meetingRoomList.value = resp.data.records.map(it=>{ |
| | | it.equipment = it.equipment.split(',') |
| | | return it; |
| | | }) |
| | | total.value = resp.data.total |
| | | loading.value = false |
| | | |
| | | } |
| | | |
| | | // æç´¢æé®æä½ |
| | | const handleSearch = () => { |
| | | queryParams.current = 1 |
| | | getList() |
| | | } |
| | | |
| | | // éç½®æç´¢è¡¨å |
| | | const resetSearch = () => { |
| | | Object.assign(searchForm, { |
| | | name: '', |
| | | location: '' |
| | | }) |
| | | handleSearch() |
| | | } |
| | | |
| | | // æ·»å æé®æä½ |
| | | const handleAdd = () => { |
| | | dialogTitle.value = 'æ·»å ä¼è®®å®¤' |
| | | dialogVisible.value = true |
| | | } |
| | | |
| | | // ä¿®æ¹æé®æä½ |
| | | const handleEdit = (row) => { |
| | | dialogTitle.value = 'ä¿®æ¹ä¼è®®å®¤' |
| | | Object.assign(meetingRoomForm, row) |
| | | dialogVisible.value = true |
| | | } |
| | | |
| | | // å é¤æé®æä½ |
| | | const handleDelete = (row) => { |
| | | ElMessageBox.confirm( |
| | | `æ¯å¦ç¡®è®¤å é¤ä¼è®®å®¤ "${row.name}"?`, |
| | | 'è¦å', |
| | | { |
| | | confirmButtonText: 'ç¡®å®', |
| | | cancelButtonText: 'åæ¶', |
| | | type: 'warning' |
| | | } |
| | | ).then(() => { |
| | | // 模æå é¤æä½ |
| | | delRoom(row.id).then(resp=>{ |
| | | ElMessage.success('å 餿å') |
| | | getList() |
| | | }) |
| | | |
| | | }).catch(() => {}) |
| | | } |
| | | |
| | | // åæ¶æé® |
| | | const cancel = () => { |
| | | dialogVisible.value = false |
| | | reset() |
| | | } |
| | | |
| | | // 表åéç½® |
| | | const reset = () => { |
| | | Object.assign(meetingRoomForm, { |
| | | id: undefined, |
| | | name: '', |
| | | location: '', |
| | | capacity: 10, |
| | | equipment: [], |
| | | status: 1, |
| | | remark: '' |
| | | }) |
| | | meetingRoomFormRef.value?.resetFields() |
| | | } |
| | | |
| | | // æäº¤è¡¨å |
| | | const submitForm = () => { |
| | | meetingRoomFormRef.value?.validate((valid) => { |
| | | if (valid) { |
| | | // 模ææäº¤æä½ |
| | | |
| | | let formData = {... meetingRoomForm} |
| | | formData.equipment = formData.equipment.join(',') |
| | | saveRoom(formData).then(resp=>{ |
| | | ElMessage.success('ä¿åæå') |
| | | dialogVisible.value = false |
| | | getList() |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | // å¯¼åº |
| | | const { proxy } = getCurrentInstance() |
| | | const handleExport = () => { |
| | | proxy.download('/meeting/export', { ...searchForm }, 'ä¼è®®å®¤è®¾ç½®.xlsx') |
| | | } |
| | | |
| | | // 页é¢å è½½æ¶è·åæ°æ® |
| | | onMounted(() => { |
| | | getList() |
| | | }) |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .app-container { |
| | | padding: 20px; |
| | | } |
| | | |
| | | .search-form { |
| | | display: flex; |
| | | /* align-items: center; */ |
| | | } |
| | | |
| | | .search-actions { |
| | | margin-left: auto; |
| | | } |
| | | |
| | | .page-header { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | align-items: center; |
| | | margin-bottom: 20px; |
| | | } |
| | | |
| | | .page-header h2 { |
| | | margin: 0; |
| | | color: #303133; |
| | | } |
| | | |
| | | .search-card { |
| | | margin-bottom: 20px; |
| | | } |
| | | |
| | | .dialog-footer { |
| | | text-align: center; |
| | | } |
| | | </style> |