Browse Source

完善节假日同步接口,主界面逻辑完善,导出excel功能同步

厅长信箱
21819 2 years ago
parent
commit
70b8dee2b0
  1. 63
      src/components/HolidayList.vue
  2. 24
      src/components/ManageMail.vue
  3. 7
      src/layout/Index.vue

63
src/components/HolidayList.vue

@ -7,25 +7,28 @@
<el-button type="primary" @click="searchHoliday">查询节假日</el-button>
<el-button type="primary" @click="refreshHoliday">同步节假日</el-button>
</el-form>
<el-row>
<el-col v-for="(item, index) in defaultCals " :key="item.cal" :span="7"
style="margin-right: 10px;margin-left: 50px;">
<el-card shadow="hover" style="margin-bottom: 20px;">
<el-calendar v-model="item.cal" class="holiday" style="pointer-events:none">
<!-- <el-calendar v-model="item.cal" class="holiday"> -->
<template #date-cell="{ data }">
<div class="holiday-cell" v-show="data.type === 'current-month'" :id="index + '-' + data.day"
:class="{ 'is-holiday': ifHoliday(data.day) }, { 'is-adjust': ifAdjustDay(data.day) }">
{{ data.day.split('-')[2] }}
<span class="holiday-text">{{ ifHoliday(data.day) ? '休' : '' }}</span>
<span class="adjust-text">{{ ifAdjustDay(data.day) ? '班' : '' }}</span>
<span class="content-text">{{ dayContent(data.day) }}</span>
</div>
</template>
</el-calendar>
</el-card>
</el-col>
</el-row>
<el-scrollbar class="scrollbar-container">
<el-row>
<el-col v-for="(item, index) in defaultCals " :key="item.cal" :span="7"
style="margin-right: 10px;margin-left: 50px;">
<el-card shadow="hover" style="margin-bottom: 20px;">
<el-calendar v-model="item.cal" class="holiday" style="pointer-events:none">
<!-- <el-calendar v-model="item.cal" class="holiday"> -->
<template #date-cell="{ data }">
<div class="holiday-cell" v-show="data.type === 'current-month'"
:id="index + '-' + data.day"
:class="{ 'is-holiday': ifHoliday(data.day) }, { 'is-adjust': ifAdjustDay(data.day) }">
{{ data.day.split('-')[2] }}
<span class="holiday-text">{{ ifHoliday(data.day) ? '休' : '' }}</span>
<span class="adjust-text">{{ ifAdjustDay(data.day) ? '班' : '' }}</span>
<span class="content-text">{{ dayContent(data.day) }}</span>
</div>
</template>
</el-calendar>
</el-card>
</el-col>
</el-row>
</el-scrollbar>
</div>
</template>
@ -42,7 +45,7 @@ const dayType = ref({
type: ''
});
const getDateData = (date) => {
const getDateData = () => {
axios.get('/api/outer/holiday/show-holiday').then(res => {
dayType.value = res.data;
loading.value = false;
@ -89,17 +92,17 @@ const searchHoliday = () => {
const refreshHoliday = () => {
loading.value = true;
let nowYear = new Date().getFullYear();
console.log(currenYear.value + '==' + nowYear);
if (currenYear.value === String(nowYear)) {
getDateData();
axios.post('/api/outer/holiday/refresh-holiday', { year: currenYear.value }, { headers: { 'Content-Type': 'application/json' } }).then(res => {
// console.log(res.data);
dayType.value = res.data.holidayList;
setTimeout(() => {
loading.value = false;
}, 1000);
} else {
ElMessage.info('其他年份尚未拥有数据')
loading.value = false;
}
ElMessage.success('同步成功')
}).catch(err => {
ElMessage.error('同步失败')
console.log(err);
});
};
const ifHoliday = (day) => {
@ -211,6 +214,10 @@ const dayContent = (day) => {
-5px -5px 10px #ffdcdc;
}
.scrollbar-container {
height: calc(100vh - 150px);
}
/* .is-today {
border-radius: 5px;
background: linear-gradient(145deg, #d9a2a2, #ffc1c1);

24
src/components/ManageMail.vue

@ -220,7 +220,29 @@ const reset = () => {
}
const out = () => {
console.log('导出信件')
const requestData = {
formData: form.value,
pageData: pageData.value
}
const data = JSON.stringify(requestData)
console.log(data)
axios.post('api/mailbox/exportexcel', data, { headers: { 'Content-Type': 'application/json' }, responseType: 'blob' }).then(function (res) {
var blob = new Blob([res.data], { type: 'application/octet-stream;charset=UTF-8' })
var contentDisposition = res.headers['content-disposition']
var patt = new RegExp('filename=([^;]+\\.[^\\.;]+);*')
var result = patt.exec(contentDisposition)
var filename = result[1]
var downloadElement = document.createElement('a')
var href = window.URL.createObjectURL(blob) //
var reg = /^["](.*)["]$/g
downloadElement.style.display = 'none'
downloadElement.href = href
downloadElement.download = decodeURI(filename.replace(reg, '$1')) //
document.body.appendChild(downloadElement)
downloadElement.click() //
document.body.removeChild(downloadElement) //
window.URL.revokeObjectURL(href)
}).catch(function (error) { console.log(error) })
}
</script>

7
src/layout/Index.vue

@ -13,7 +13,7 @@
<nav>
<a class="flex v-center center wrap pointer" @click="router.push('/')">
<el-icon><HomeFilled /></el-icon>
<span>信件管理</span>
<span>首页</span>
</a>
<a class="flex v-center center wrap pointer" @click="router.push('/holiday')">
<el-icon><Platform /></el-icon>
@ -27,11 +27,6 @@
<el-icon><User /></el-icon>
<span>人员管理</span>
</a>
<a class="flex v-center center wrap pointer" @click="router.push('/')">
<el-icon><Setting /></el-icon>
<span>系统管理</span>
</a>
</nav>
</aside>
<main style="width: 100%;"><router-view /></main>

Loading…
Cancel
Save