mirror of https://gitee.com/godoos/godoos.git
19 changed files with 429 additions and 194 deletions
@ -0,0 +1,78 @@ |
|||||
|
<template> |
||||
|
<el-form :model="form" label-width="auto" style="max-width: 560px;margin-top:20px;padding: 20px;"> |
||||
|
<el-form-item label="任务名称"> |
||||
|
<el-input v-model="form.name" /> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="任务跨度"> |
||||
|
<el-select v-model="form.duration"> |
||||
|
<el-option label="按天" value="1" /> |
||||
|
<el-option label="按周" value="7" /> |
||||
|
<el-option label="按月" value="30" /> |
||||
|
<el-option label="按季" value="90" /> |
||||
|
<el-option label="按年" value="365" /> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="任务模板"> |
||||
|
<el-input v-model="form.tpl" /> |
||||
|
</el-form-item> |
||||
|
<el-form-item label="选择人员"> |
||||
|
<el-select v-model="form.users" filterable multiple clearable collapse-tags placeholder="选择人员" |
||||
|
popper-class="custom-header" :max-collapse-tags="1" value-key="id" style="width: 240px" @change="checkUsers"> |
||||
|
<template #header> |
||||
|
<el-checkbox v-model="checkAll" @change="handleCheckAll"> |
||||
|
全选 |
||||
|
</el-checkbox> |
||||
|
</template> |
||||
|
<el-option v-for="item in userList" :key="item.id" :label="item.nickname" :value="item.id" /> |
||||
|
</el-select></el-form-item> |
||||
|
<el-form-item label="任务描述"> |
||||
|
<el-input v-model="form.desc" type="textarea" /> |
||||
|
</el-form-item> |
||||
|
<div class="btn-group"> |
||||
|
<el-button type="primary" @click="onSubmit">创建任务</el-button> |
||||
|
</div> |
||||
|
</el-form> |
||||
|
</template> |
||||
|
|
||||
|
<script lang="ts" setup> |
||||
|
import { ref } from 'vue'; |
||||
|
import { useSystem } from '@/system'; |
||||
|
const sys = useSystem() |
||||
|
const userInfo: any = sys.getConfig('userInfo') |
||||
|
const userList = ref(userInfo.user_auths) |
||||
|
const checkAll = ref(false) |
||||
|
const form: any = ref({ |
||||
|
name: '', |
||||
|
duration: '1', |
||||
|
tpl: '', |
||||
|
after: '1', |
||||
|
users: [], |
||||
|
desc: '', |
||||
|
}) |
||||
|
|
||||
|
const handleCheckAll = (val: any) => { |
||||
|
if (val) { |
||||
|
form.value.users = userList.value.map((d: any) => d.value) |
||||
|
} else { |
||||
|
form.value.users.value = [] |
||||
|
} |
||||
|
} |
||||
|
const checkUsers = (val: any) => { |
||||
|
const res:any = [] |
||||
|
val.forEach((item: any) => { |
||||
|
if(item){ |
||||
|
res.push(item) |
||||
|
} |
||||
|
}) |
||||
|
form.value.users = res |
||||
|
} |
||||
|
const onSubmit = () => { |
||||
|
console.log('submit!') |
||||
|
} |
||||
|
</script> |
||||
|
<style scoped> |
||||
|
.btn-group{ |
||||
|
display: flex; |
||||
|
justify-content: center; |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,45 @@ |
|||||
|
<template> |
||||
|
<el-dialog v-model="store.showNews" :title="store.newsDetail.title" show-close="true" width="600"> |
||||
|
<div class="new-content"> |
||||
|
<div class="news-detail" v-html="store.newsDetail.content"></div> |
||||
|
<p class="new-time"><strong>发布时间:</strong> {{ store.newsDetail.showtime }}</p> |
||||
|
</div> |
||||
|
</el-dialog> |
||||
|
</template> |
||||
|
<script setup lang="ts"> |
||||
|
import { useNotifyStore } from '@/stores/notify'; |
||||
|
const store:any = useNotifyStore() |
||||
|
</script> |
||||
|
<style lang="scss" scoped> |
||||
|
|
||||
|
.new-content { |
||||
|
padding: 20px; |
||||
|
background-color: #F5F5F5; |
||||
|
border: 1px solid #E5E5E5; |
||||
|
border-radius: 4px; |
||||
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); |
||||
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; |
||||
|
|
||||
|
.new-time { |
||||
|
margin-bottom: 10px; |
||||
|
font-size: 14px; |
||||
|
color: #666; |
||||
|
|
||||
|
strong { |
||||
|
font-weight: bold; |
||||
|
color: #333; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.news-detail { |
||||
|
font-size: 16px; |
||||
|
line-height: 1.5; |
||||
|
color: #333; |
||||
|
white-space: pre-wrap; |
||||
|
} |
||||
|
.news-detail:deep(img){ |
||||
|
max-width: 90%; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
</style> |
@ -1,40 +1,97 @@ |
|||||
import { defineStore } from "pinia"; |
import { defineStore } from "pinia"; |
||||
import { ref } from "vue"; |
import { ref } from "vue"; |
||||
import { getSystemConfig,fetchGet } from "@/system/config"; |
import { getSystemConfig, fetchGet } from "@/system/config"; |
||||
|
import { useUpgradeStore } from "./upgrade"; |
||||
export const useNotifyStore = defineStore('notifyStore', () => { |
export const useNotifyStore = defineStore('notifyStore', () => { |
||||
const config = getSystemConfig(); |
const config = getSystemConfig(); |
||||
const notifyList:any = ref([]); |
const upgradeStore = useUpgradeStore() |
||||
|
const notifyList: any = ref([]); |
||||
|
const readList: any = ref([]) |
||||
|
const showNews = ref(false) |
||||
|
const newsDetail = ref({}) |
||||
const page = ref({ |
const page = ref({ |
||||
current: 1, |
current: 1, |
||||
size: 10, |
size: 10, |
||||
total: 0, |
total: 0, |
||||
pages: 0, |
pages: 0, |
||||
}) |
}) |
||||
async function getList(){ |
async function getList() { |
||||
if(config.userType == 'person'){ |
if (config.userType == 'person') { |
||||
return |
return |
||||
} |
} |
||||
const complition = await fetchGet(config.userInfo.url + '/news/list?page=' + page.value.current + '&limit='+ page.value.size) |
const complition = await fetchGet(config.userInfo.url + '/news/list?page=' + page.value.current + '&limit=' + page.value.size) |
||||
if(!complition.ok){ |
if (!complition.ok) { |
||||
return; |
return; |
||||
} |
} |
||||
const data = await complition.json(); |
const data = await complition.json(); |
||||
if(data.success){ |
if (data.success) { |
||||
page.value.total = data.data.total; |
page.value.total = data.data.total; |
||||
notifyList.value = data.data.list; |
notifyList.value = data.data.list; |
||||
page.value.pages = Math.ceil(page.value.total / page.value.size) |
page.value.pages = Math.ceil(page.value.total / page.value.size) |
||||
} |
checkNotify() |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
const checkNotify = ()=> { |
||||
|
const list = notifyList.value.filter((item: any) => { |
||||
|
return readList.value.indexOf(item.id) < 0 |
||||
|
}) |
||||
|
if(list.length < 1)return; |
||||
|
const centerList = list.filter((item: any) => { |
||||
|
return item.position == 'center' |
||||
|
}) |
||||
|
const bottomList = list.filter((item: any) => { |
||||
|
return item.position == 'bottom' |
||||
|
}) |
||||
|
if(centerList.length > 0){ |
||||
|
upgradeStore.hasAd = true |
||||
|
upgradeStore.adList = [...centerList, ...upgradeStore.adList] |
||||
|
} |
||||
|
if(bottomList.length > 0){ |
||||
|
upgradeStore.hasNotice = true |
||||
|
upgradeStore.noticeList = [...bottomList, ...upgradeStore.noticeList] |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
const addRead = (id: number) => { |
||||
|
if (readList.value.indexOf(id) < 0) { |
||||
|
readList.value.push(id) |
||||
|
} |
||||
} |
} |
||||
const pageClick = async (pageNum: any) => { |
const pageClick = async (pageNum: any) => { |
||||
//console.log(pageNum)
|
//console.log(pageNum)
|
||||
page.value.current = pageNum |
page.value.current = pageNum |
||||
await getList() |
await getList() |
||||
} |
} |
||||
|
const viewContent = (item :any) =>{ |
||||
|
const timestamp = item.add_time * 1000; // 将 10 位时间戳转换为 13 位
|
||||
|
const date = new Date(timestamp); |
||||
|
item.showtime = date.toLocaleString(); |
||||
|
newsDetail.value = item |
||||
|
addRead(item.id) |
||||
|
showNews.value = true |
||||
|
} |
||||
return { |
return { |
||||
notifyList, |
notifyList, |
||||
|
showNews, |
||||
|
newsDetail, |
||||
getList, |
getList, |
||||
|
addRead, |
||||
page, |
page, |
||||
pageClick |
pageClick, |
||||
|
readList, |
||||
|
viewContent |
||||
|
} |
||||
|
}, { |
||||
|
persist: { |
||||
|
enabled: true, |
||||
|
strategies: [ |
||||
|
{ |
||||
|
storage: localStorage, |
||||
|
paths: [ |
||||
|
"readList", |
||||
|
] |
||||
|
}, // name 字段用localstorage存储
|
||||
|
], |
||||
} |
} |
||||
}) |
}) |
Loading…
Reference in new issue