tangning vor 2 Monaten
Ursprung
Commit
8550fbf53d

+ 1 - 1
src/store/case.ts

@@ -70,7 +70,7 @@ export type AllSaveFile = {
 export const setCaseSharePWD = (params: { caseId: number; randCode: string }) =>
   axios.post(setCasePsw, params);
 
-export const getCaseSharePWD = async (params: { caseId: number }) =>
+export const getCaseSharePWD = async (params: { caseId: number, password: string }) =>
   (await axios.get<string>(getCasePsw, { params })).data;
 
 export const getCaseInfo = async (caseId: number) =>

+ 14 - 2
src/view/case/newShare.vue

@@ -38,7 +38,7 @@
     <!-- 公开分享内容:复用 share.vue -->
     <div v-if="viewScope === 'public'" class="public-share">
       <p class="share-title">分享</p>
-      <ShareForm :caseId="caseId" :projectName="projectName" ref="shareRef" />
+      <ShareForm v-model:shareAuthCode="shareAuthCode" :caseId="caseId" :projectName="projectName" ref="shareRef" />
       <div class="share-actions">
         <el-button type="primary" @click="copyPublicShare">复制链接和密码</el-button>
       </div>
@@ -69,6 +69,7 @@ const orgSharePerm = ref<"none" | "read" | "edit">("none");
 // 查看权限
 const viewScope = ref<"login" | "public">("login");
 const shareRef = ref<InstanceType<typeof ShareForm> | null>(null);
+const shareAuthCode = ref<string>("");
 
 // 仅复制公开分享的链接与密码(由子组件进行校验与保存)
 const copyPublicShare = async () => {
@@ -81,7 +82,12 @@ const copyPublicShare = async () => {
     }
   await (shareRef.value as any)?.submit();
 };
-
+function generateFourDigitString() {
+  // 生成 0 ~ 9999 的随机整数
+  const num = Math.floor(Math.random() * 10000);
+  // 补前导零,确保长度为 4
+  return num.toString().padStart(4, '0');
+}
 // 确认提交:仅触发接口调用与保存设置
 const handleConfirm = async (showTips = false) => {
   if (orgSharePerm.value != 'none' && !selectedParentId.value) {
@@ -104,7 +110,11 @@ const handleConfirm = async (showTips = false) => {
     caseId: props.caseId,
     shareAuth: shareAuthVal,
     mapShow: mapShowVal,
+    shareAuthCode:shareAuthVal ? shareAuthCode.value : 0,
   });
+  if(shareAuthVal){
+    await (shareRef.value as any)?.submit(true);
+  }
   if(!showTips){
     ElMessage.success("设置已保存");
   }
@@ -113,6 +123,7 @@ const handleConfirm = async (showTips = false) => {
 
 defineExpose<QuiskExpose>({
   async submit() {
+  
     return await handleConfirm();
   },
 });
@@ -129,6 +140,7 @@ onMounted(async () => {
     const raw = res?.data ?? null;
     const item = Array.isArray(raw) ? raw[0] : raw;
     if (item) {
+      shareAuthCode.value = item.shareAuthCode || generateFourDigitString();
       if (item.deptId != null) {
         selectedParentId.value = String(item.deptId || "");
       }

+ 26 - 9
src/view/case/share.vue

@@ -22,7 +22,7 @@
 </template>
 <script setup lang="ts">
 import { appConstant } from "@/app";
-import { computed, onMounted, ref } from "vue";
+import { computed, onMounted, ref, watch, toRefs } from "vue";
 import { EPSW } from "@/constant/REG";
 import { ElMessage } from "element-plus";
 import { copyText } from "@/util";
@@ -31,10 +31,16 @@ import { Fire, getFire } from "@/app/fire/store/fire";
 import { getCaseSharePWD, setCaseSharePWD } from "@/store/case";
 import { QuiskExpose } from "@/helper/mount";
 
-const props = defineProps<{ caseId: number, projectName?: string }>();
-const randCode = ref("");
+const emit = defineEmits(['update:shareAuthCode']);
+const props = defineProps<{ caseId: number, shareAuthCode?: string, projectName?: string }>();
+const randCode = ref(props.shareAuthCode || '');
 const oldRandCode = ref("");
 const appId = import.meta.env.VITE_APP_APP || 'fire'
+console.log(props, 'shareAuthCode');
+// 监听 props 变化,同步到子组件内部
+watch(() => props.shareAuthCode, (newVal) => {
+  randCode.value = newVal || '';
+});
 const shareLink = computed(() => {
   const base = location.origin;
   const p = md5(randCode.value || "");
@@ -50,13 +56,22 @@ const filterPSW = (val: string) => {
     return;
   } else if (EPSW.REG.test(val.substr(val.length - 1))) {
     randCode.value = val;
+    emit('update:shareAuthCode', val);
   } else {
     ElMessage.error(EPSW.tip);
   }
 };
-
+function generateFourDigitString() {
+  // 生成 0 ~ 9999 的随机整数
+  const num = Math.floor(Math.random() * 10000);
+  // 补前导零,确保长度为 4
+  return num.toString().padStart(4, '0');
+}
+function updateShare() {
+    getCaseSharePWD({ caseId: props.caseId, password: randCode.value })
+  }
 defineExpose<QuiskExpose>({
-  async submit() {
+  async submit(save = false) {
     if (!randCode.value || randCode.value.length !== 4) {
       ElMessage.error("请输入四位数的密码!");
       throw "请输入四位数的密码!";
@@ -67,17 +82,19 @@ defineExpose<QuiskExpose>({
         randCode: randCode.value,
       });
     }
-    const result = `${appId=='appId'?'案件名称':'起火对象'}:${props.projectName || ''} 链接:${shareLink.value} 密码:${randCode.value}`;
+    const result = `${appId=='criminal'?'案件名称':'起火对象'}:${props.projectName || ''} 链接:${shareLink.value} 密码:${randCode.value}`;
     copyText(result);
     ElMessage.success("链接复制成功");
+    // if(save) updateShare()
     return result;
-  },
+  }
 });
 
 onMounted(async () => {
   try {
-    const code = await getCaseSharePWD({ caseId: props.caseId });
-    oldRandCode.value = randCode.value = code || "";
+    // const code = await getCaseSharePWD({ caseId: props.caseId });
+    // let code = generateFourDigitString();
+    // oldRandCode.value = randCode.value = code || "";
   } catch (e) {
     // 忽略错误,保持手动输入密码
   }

+ 0 - 2
src/view/newFireCase/newFireDetails/components/scene.vue

@@ -380,9 +380,7 @@ const onSelectionChange = (rows: Scene[]) => {
   // 先放入全局已选中的集合(跨页保持)
   (selectedRows.value || []).forEach((r: any) => map.set(rowKey(r), r));
   // 当前页导入的行强制选中
-  console.log(selectedRows.value, 'rows4', importedKeySet.value)
   (tableData.value || []).forEach((r: any) => {
-    console.log(isRowImported(r), 'rows2', importedKeySet.value)
     if (isRowImported(r)) {
       map.set(rowKey(r), r);
     }

+ 1 - 0
src/view/newFireCase/newFireDetails/components/siteInspection.vue

@@ -1238,6 +1238,7 @@ const openEditOverlay = (type: 'inquest' | 'extraction', item) => {
     try {
       const key = `inquestPreset:${caseId.value!}`;
       const currentItem = inquestData.value || {};
+      console.log(currentItem, 'openEditOverlay')
       sessionStorage.setItem(key, JSON.stringify(currentItem));
       query.presetKey = String(caseId.value!);
       if (currentItem && currentItem.id !== undefined) {