Prechádzať zdrojové kódy

feat(zfhtgl): 添加入账日期功能并优化权限验证- 在租金户塘管理页面添加入账日期字段,要求用户填写
- 优化权限验证逻辑,使用 URL 参数进行验证
-调整用户信息存储结构,直接使用 res.data 而非 res.data.data
- 修复部分可能导致错误的代码问题,如使用 ?? 进行空值合并

nahida 8 mesiacov pred
rodič
commit
7172924359
2 zmenil súbory, kde vykonal 42 pridanie a 18 odobranie
  1. 24 15
      src/stores/permissionStore.ts
  2. 18 3
      src/views/zfgl/zfhtgl.vue

+ 24 - 15
src/stores/permissionStore.ts

@@ -4,34 +4,43 @@ import { ElMessage } from 'element-plus'
 
 interface PermissionReponse extends BaseResponse {
   data: {
-    success: boolean
-    code: number
-    data: {
-      personName: string
-      deptName: string
-      deptId: string
-      errorCode: number
-      personCode: string
-      userName: string
-      isBusinessAtt: boolean
-      message: string
-    }
+    personName: string
+    deptName: string
+    deptId: string
+    errorCode: number
+    personCode: string
+    userName: string
+    isBusinessAtt: boolean
     message: string
   }
 }
 
 export const usePermissionStore = defineStore('permission', () => {
+  const search = window.location.search // 获取"?appToken=xxx&appId=xxx"
+  const params = new URLSearchParams(search)
   const getUserPermission = async () => {
-    const res = await clientPost<null, PermissionReponse>('/userPermissions/queryUserPermissions')
+    if (!params.get('appId') || !params.get('appToken')) {
+      return
+    }
+    const res = await clientPost<null, PermissionReponse>(
+      '/userPermissions/queryUserPermissions',
+      null,
+      {
+        params: {
+          appId: params.get('appId'),
+          appToken: params.get('appToken'),
+        },
+      },
+    )
     if (res.code !== 200) {
       ElMessage.error(res.msg)
       return
     }
-    if (res.data.code !== 200) {
+    if (res.data.errorCode !== 2000) {
       ElMessage.error(res.data.message)
       return
     }
-    localStorage.setItem('userInfo', JSON.stringify(res.data.data))
+    localStorage.setItem('userInfo', JSON.stringify(res.data))
     return res.data
   }
 

+ 18 - 3
src/views/zfgl/zfhtgl.vue

@@ -73,6 +73,7 @@ interface ReceiptDto {
   wyf: number // 物业费
   sf: number // 水费
   paymentReason: string // 付款事由
+  rzrq: string //入账日期
   operator: string
 }
 
@@ -165,7 +166,8 @@ const receiptForm = reactive<ReceiptDto>({
   wyf: 0,
   sf: 0,
   paymentReason: '房屋租赁费用',
-  operator: userInfo.value.personName,
+  rzrq: '',
+  operator: userInfo.value?.personName,
 })
 
 // 退据相关
@@ -652,6 +654,10 @@ const generateReceipt = async () => {
     ElMessage.warning('总金额必须大于0')
     return
   }
+  if (!receiptForm.rzrq) {
+    ElMessage.warning('请填写入账日期')
+    return
+  }
 
   try {
     await ElMessageBox.confirm(
@@ -1042,7 +1048,7 @@ onMounted(() => {
                   size="small"
                   text
                   :icon="Receipt"
-                  :disabled="!userInfo.isBusinessAtt"
+                  :disabled="!userInfo?.isBusinessAtt"
                   @click="openReceiptDialog(row.id, row.contractNumber)"
                 >
                   获取收据
@@ -1054,7 +1060,7 @@ onMounted(() => {
                   size="small"
                   text
                   :icon="RotateCcw"
-                  :disabled="!userInfo.isBusinessAtt"
+                  :disabled="!userInfo?.isBusinessAtt"
                   @click="openReturnReceiptDialog(row.id, row.contractNumber)"
                 >
                   获取退据
@@ -1319,6 +1325,15 @@ onMounted(() => {
                 @change="handleAmountChange"
               />
             </ElFormItem>
+            <ElFormItem label="入账日期" required>
+              <ElDatePicker
+                v-model="receiptForm.rzrq"
+                type="date"
+                value-format="YYYY-MM-DD"
+                placeholder="请选择入账日期"
+                style="width: 100%"
+              />
+            </ElFormItem>
           </div>
 
           <ElFormItem label="总金额(元)">