2 İşlemeler 66c1b16fdc ... b5e5fd3592

Yazar SHA1 Mesaj Tarih
  xiongxing b5e5fd3592 Merge branch 'master' of http://47.107.245.0:3000/xiongxing/kyj-yanglao-web-new 2 hafta önce
  xiongxing bc6e69317e 优化编辑公告模块无初始数据接口tenantId传1 2 hafta önce

+ 11 - 4
src/views/elderly/elder/notice-customer/index.vue

@@ -109,6 +109,9 @@ const currentTenantId = computed(() => queryParams.tenantIds?.[0])
 /** 是否集团账号:集团账号可切换院区,普通院区账号固定为当前院区 */
 const canSwitchTenant = computed(() => !!userStore.getOrgTenant?.multiple)
 
+/** 内容换行处理:兼容后端存的字面量 \n */
+const normalizeContent = (content?: string) => (content || '').replace(/\\n/g, '\n')
+
 /** 按机构查询须知(返回第一条) */
 const fetchDetail = async () => {
   const list = await getNoticeCustomerList({
@@ -125,8 +128,12 @@ const fetchDetail = async () => {
  */
 const initNotice = async () => {
   try {
-    const defaultList = await getNoticeCustomerList({ type: NOTICE_TYPE })
-    const initContent = defaultList?.[0]?.content
+    const defaultList = await getNoticeCustomerList({ type: NOTICE_TYPE, tenantId: 1 })
+    // 初始数据可能返回多条,用 \n 拼接后展示
+    const initContent = (defaultList || [])
+      .map((item) => normalizeContent(item?.content))
+      .filter((item) => item.trim())
+      .join('\n')
     if (!initContent) {
       return false
     }
@@ -152,7 +159,7 @@ const getDetail = async () => {
     const detail = await fetchDetail()
     if (detail) {
       formData.id = detail.id
-      formData.content = detail.content || ''
+      formData.content = normalizeContent(detail.content)
       return
     }
     // 机构下无数据 -> 自动初始化后再查一次回填
@@ -160,7 +167,7 @@ const getDetail = async () => {
     if (created) {
       const newDetail = await fetchDetail()
       formData.id = newDetail?.id
-      formData.content = newDetail?.content || ''
+      formData.content = normalizeContent(newDetail?.content)
       return
     }
     formData.id = undefined