169 lines
4.9 KiB
Vue
Raw Normal View History

2023-07-27 13:34:39 +08:00
<template>
2023-08-12 16:05:13 +08:00
<div>
<el-card class="!border-none" v-loading="loading" shadow="never">
<el-button v-perms="['flow_type/add']" type="primary" @click="handleAdd">
<template #icon>
<icon name="el-icon-Plus" />
</template>
新增
</el-button>
<div class="mt-4">
<el-calendar v-model="dateValue">
<template #dateCell="{ data }">
<div style="width: 100%; height: 100%; background-color: aquamarine">
<p :class="data.isSelected ? 'is-selected' : ''">
{{ data.day.split('-').slice(1).join('-') }}
<!-- {{ data.isSelected ? '✔️' : '' }} -->
</p>
<div
class="task"
:class="{
fou: item.priority == 4,
tow: item.priority == 2,
the: item.priority == 3
}"
v-if="taskList[data.day]"
@click="handleEdit(item)"
v-for="(item, index) in taskList[data.day]"
:key="index"
>
{{ item.title }}
</div>
</div>
</template>
</el-calendar>
2023-07-27 13:34:39 +08:00
</div>
2023-08-12 16:05:13 +08:00
</el-card>
<edit-popup
v-if="showEdit"
ref="editRef"
:dict-data="dictData"
:dateValue="dateValue"
@success="loadTask"
@close="showEdit = false"
/>
</div>
2023-07-27 13:34:39 +08:00
</template>
2023-08-02 09:09:24 +08:00
2023-07-27 13:34:39 +08:00
<script lang="ts" setup name="task">
2023-08-12 16:05:13 +08:00
import { useDictData } from '@/hooks/useDictOptions'
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'
2023-07-27 13:34:39 +08:00
// import { getRoutePath } from "router";
2023-08-12 16:05:13 +08:00
import EditPopup from './edit.vue'
import { reactive, watch } from 'vue'
const route = useRoute()
2023-07-27 13:34:39 +08:00
2023-08-12 16:05:13 +08:00
const dateValue = ref(new Date())
2023-07-27 13:34:39 +08:00
watch(
2023-08-12 16:05:13 +08:00
() => dateValue,
(newValue, oldValue) => {
initShowDate(timeFormat(newValue.value.getTime()))
},
{ deep: true }
)
2023-07-27 13:34:39 +08:00
2023-08-02 09:09:24 +08:00
const test = (e: any) => {
2023-08-12 16:05:13 +08:00
console.log(e)
}
2023-07-27 13:34:39 +08:00
// 加载
2023-08-12 16:05:13 +08:00
const loading = ref(true)
2023-07-27 13:34:39 +08:00
2023-08-12 16:05:13 +08:00
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
2023-07-27 13:34:39 +08:00
// 是否显示编辑框
2023-08-12 16:05:13 +08:00
const showEdit = ref(false)
2023-07-27 13:34:39 +08:00
// 查询条件
const queryParams = reactive({
2023-08-12 16:05:13 +08:00
start_time: '',
end_time: '',
day: 1,
page_no: 1,
pageSize: 150
})
2023-07-27 13:34:39 +08:00
2023-08-12 16:05:13 +08:00
const taskList = ref<any>([])
2023-07-27 13:34:39 +08:00
// 查询
2023-08-12 16:05:13 +08:00
const start_date = ref('')
const end_date = ref('')
2023-07-27 13:34:39 +08:00
// 计算当前显示的第一天和最后一天
2023-08-12 16:05:13 +08:00
const initShowDate = (dateStr = '') => {
const currentDate = dateStr ? new Date(dateStr) : new Date()
const currentYear = currentDate.getFullYear()
const currentMonth = currentDate.getMonth()
const lastDay = new Date(currentYear, currentMonth + 1, 0).getDay() //获取第一天星期
const startDay = new Date(currentYear, currentMonth, 1).getDay() //获取最后一天星期
// console.log(new Date(currentYear, currentMonth, 1-startDay).getDate());
// console.log(new Date(currentYear, currentMonth + 1, 6-lastDay).getDate());
start_date.value = timeFormat(new Date(currentYear, currentMonth, 1 - startDay).getTime()) //获取第一天时间
end_date.value = timeFormat(new Date(currentYear, currentMonth + 1, 6 - lastDay).getTime()) //获取最后一天时间
if (queryParams.start_time != start_date.value) {
queryParams.start_time = start_date.value
queryParams.end_time = end_date.value
loading.value = true
}
}
initShowDate()
2023-07-27 13:34:39 +08:00
// 获取字典数据
2023-08-12 16:05:13 +08:00
const { dictData } = useDictData('')
2023-07-27 13:34:39 +08:00
// 添加
const handleAdd = async () => {
2023-08-12 16:05:13 +08:00
console.log(2232)
showEdit.value = true
await nextTick()
editRef.value?.open('add')
if (route.query.id) {
console.log(22)
const emits = defineEmits(['scheduling_id'])
emits('scheduling_id', route.query.id)
}
}
2023-07-27 13:34:39 +08:00
// 编辑
const handleEdit = async (data: any) => {
2023-08-12 16:05:13 +08:00
showEdit.value = true
await nextTick()
editRef.value?.open('edit')
editRef.value?.setFormData(data)
}
2023-07-27 13:34:39 +08:00
// 删除
2023-08-03 17:34:37 +08:00
// const handleDelete = async (id: number | any[]) => {
// await feedback.confirm("确定要删除?");
// await apiFlowTypeDelete({ id });
// getLists();
// };
2023-07-27 13:34:39 +08:00
// getLists();
</script>
2023-08-02 09:09:24 +08:00
2023-07-27 13:34:39 +08:00
<style lang="scss">
.is-selected {
2023-08-12 16:05:13 +08:00
color: #1989fa;
2023-07-27 13:34:39 +08:00
}
2023-08-02 09:09:24 +08:00
.el-calendar-table .el-calendar-day {
2023-08-12 16:05:13 +08:00
height: 6.2rem;
2023-07-27 13:34:39 +08:00
}
2023-08-02 09:09:24 +08:00
.task {
2023-08-12 16:05:13 +08:00
font-size: 0.8rem;
color: #f7ba2a;
white-space: nowrap; /* 设置文本不换行 */
overflow: hidden; /* 隐藏溢出的部分 */
text-overflow: ellipsis; /* 在溢出的部分显示省略号 */
2023-07-27 13:34:39 +08:00
}
2023-08-02 09:09:24 +08:00
.the {
2023-08-12 16:05:13 +08:00
color: #ff5100;
2023-07-27 13:34:39 +08:00
}
2023-08-02 09:09:24 +08:00
.tow {
2023-08-12 16:05:13 +08:00
color: #f38200;
2023-07-27 13:34:39 +08:00
}
2023-08-02 09:09:24 +08:00
.fou {
2023-08-12 16:05:13 +08:00
color: red;
2023-07-27 13:34:39 +08:00
}
2023-08-02 09:09:24 +08:00
</style>