| | |
| | | import { Search } from "@element-plus/icons-vue"; |
| | | import dayjs from "dayjs"; |
| | | import { ElMessageBox } from "element-plus"; |
| | | import { computed, reactive, ref, watch } from "vue"; |
| | | import { computed, onMounted, reactive, ref, watch } from "vue"; |
| | | import { |
| | | NEWS_TYPE_OPTIONS, |
| | | PUBLISH_STATUS_OPTIONS, |
| | |
| | | DEPT_OPTIONS, |
| | | createEmptyForm, |
| | | loadStoredNews, |
| | | saveStoredNews, |
| | | getUnreadEmployees, |
| | | readRate, |
| | | nextNewsNo, |
| | |
| | | } from "./enterpriseNewsUtils.js"; |
| | | |
| | | export function useEnterpriseNews() { |
| | | const stored = loadStoredNews(); |
| | | const allRows = ref(stored?.length ? stored : []); |
| | | const allRows = ref([]); |
| | | |
| | | const searchForm = reactive({ |
| | | keyword: "", |
| | |
| | | }, |
| | | ]); |
| | | |
| | | function persist() { |
| | | saveStoredNews(allRows.value); |
| | | } |
| | | onMounted(() => { |
| | | loadStoredNews(); |
| | | }); |
| | | |
| | | function handleQuery() { |
| | | tableLoading.value = true; |
| | |
| | | if (!hit.readRecords?.length) { |
| | | hit.readRecords = []; |
| | | } |
| | | persist(); |
| | | return true; |
| | | } catch { |
| | | return false; |
| | |
| | | } |
| | | allRows.value[idx] = { ...prev, ...payload }; |
| | | } |
| | | persist(); |
| | | formDialog.visible = false; |
| | | return { ok: true }; |
| | | } |
| | |
| | | if (hit) { |
| | | hit.publishStatus = "archived"; |
| | | hit.updateTime = dayjs().format("YYYY-MM-DD HH:mm:ss"); |
| | | persist(); |
| | | } |
| | | } |
| | | |
| | |
| | | }); |
| | | hit.readRecords = records; |
| | | hit.updateTime = now; |
| | | persist(); |
| | | unreadDialog.visible = false; |
| | | return { ok: true, count: selectedIds.length }; |
| | | } |
| | |
| | | } else { |
| | | hit.likes.push({ userId, name: userName, time: dayjs().format("YYYY-MM-DD HH:mm:ss") }); |
| | | } |
| | | persist(); |
| | | if (detailRow.value?.id === row.id) { |
| | | detailRow.value = { ...hit }; |
| | | } |
| | |
| | | content: text, |
| | | time: dayjs().format("YYYY-MM-DD HH:mm:ss"), |
| | | }); |
| | | persist(); |
| | | if (detailRow.value?.id === row.id) { |
| | | detailRow.value = { ...hit }; |
| | | } |