From 03c275439949875a857538df89a41696642c42b3 Mon Sep 17 00:00:00 2001
From: zhangwei <1504152376@qq.com>
Date: 星期一, 01 九月 2025 17:15:39 +0800
Subject: [PATCH] '首页公告与详情'

---
 src/views/system/dept/uploadform.vue |  148 ++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 128 insertions(+), 20 deletions(-)

diff --git a/src/views/system/dept/uploadform.vue b/src/views/system/dept/uploadform.vue
index 4dddd4f..a41733e 100644
--- a/src/views/system/dept/uploadform.vue
+++ b/src/views/system/dept/uploadform.vue
@@ -19,19 +19,46 @@
 const props = withDefaults(defineProps<TenderProps>(), {
   formInline: () => ({
     id: "", // 涓婚敭Id锛堝繀濉級
+    tenderId: "",
+    higherDeptOptions: [],
     projectName: "",
     toubiaoStartDate: "", // 鎶曟爣鎶ュ悕寮�濮嬫椂闂达紙蹇呭~锛屾牸寮忥細yyyy-MM-dd HH:mm:ss锛�
     toubiaoEndDate: "", // 鎶曟爣鎶ュ悕缁撴潫鏃堕棿锛堝繀濉紝鏍煎紡锛歽yyy-MM-dd HH:mm:ss锛�
     kaibiaoDate: "", // 寮�鏍囨椂闂达紙蹇呭~锛屾牸寮忥細yyyy-MM-dd HH:mm:ss锛�
     zhaobiaowenjian: "", // 鎷涙爣鏂囦欢锛堝繀濉紝闀垮害1-512瀛楃锛�
+    zhaobiaowenjianName: "",
     biangengwenjian: "",
+    biangengwenjianName: "",
     fujian: "", // 闄勪欢锛堝彲閫夛紝鏈�澶ч暱搴�512瀛楃锛屽彲涓虹┖锛�
+    fujianName: "", // 闄勪欢锛堝彲閫夛紝鏈�澶ч暱搴�512瀛楃锛屽彲涓虹┖锛�
     kaibiaodidian: "" // 寮�鏍囧湴鐐癸紙蹇呭~锛岄暱搴�1-250瀛楃锛�
   }),
-  isChange: null
+  isChange: null,
+  changeDetail: null
 });
-
-const gonggaoRules = reactive({
+interface FormInlineType {
+  // 椤圭洰鏍囬
+  projectName: string | null | undefined;
+  // 鎶曟爣鎶ュ悕寮�濮嬫椂闂达紙閫氬父涓篒SO鏃ユ湡瀛楃涓叉牸寮忥級
+  toubiaoStartDate: string | null | undefined;
+  // 鎶曟爣鎶ュ悕缁撴潫鏃堕棿
+  toubiaoEndDate: string | null | undefined;
+  // 寮�鏍囨椂闂�
+  kaibiaoDate: string | null | undefined;
+  // 鎷涙爣鏂囦欢锛堝彲鑳芥槸鏂囦欢璺緞銆両D鎴栨枃浠跺璞★級
+  zhaobiaowenjian: string | null | undefined;
+  // 鎷涙爣鏂囦欢鍚嶏紙鍙兘鏄枃浠惰矾寰勩�両D鎴栨枃浠跺璞★級
+  zhaobiaowenjianName?: string | null | undefined;
+  // 鍙樻洿鏂囦欢
+  biangengwenjian: string | null | undefined;
+  // 鍙樻洿鏂囦欢
+  biangengwenjianName?: string | null | undefined;
+  // 闄勪欢锛堟枃鏈弿杩版垨璺緞锛�
+  fujian: string | null | undefined;
+  // 寮�鏍囧湴鐐�
+  kaibiaodidian: string | null | undefined;
+}
+const gonggaoRules = reactive<FormRules<FormInlineType>>({
   projectName: [{ required: true, message: "璇疯緭鍏ユ爣棰�", trigger: "change" }],
   toubiaoStartDate: [
     { required: true, message: "璇烽�夋嫨鎶曟爣鎶ュ悕寮�濮嬫椂闂�", trigger: "change" }
@@ -93,6 +120,7 @@
 const newFormInline = ref(props.formInline);
 const validateForm = reactive({
   fileList: [],
+  fileListFile: [],
   date: ""
 });
 const upload = ref<UploadInstance>();
@@ -136,20 +164,16 @@
   fetchCredentials(file);
   // upload.value!.submit();
 };
-// state.formDataNew = {
-//   policy: res.result.policy, //琛ㄥ崟鍩�
-//   "x-oss-signature-version": res.result.x_oss_signature_version, //鎸囧畾绛惧悕鐨勭増鏈拰绠楁硶
-//   "x-oss-credential": res.result.x_oss_credential, //鎸囨槑娲剧敓瀵嗛挜鐨勫弬鏁伴泦
-//   "x-oss-date": res.result.x_oss_date, //璇锋眰鐨勬椂闂�
-//   "x-oss-signature": res.result.signature, //绛惧悕璁よ瘉鎻忚堪淇℃伅
-//   "x-oss-security-token": res.result.security_token, //瀹夊叏浠ょ墝
-//   success_action_status: "200" //涓婁紶鎴愬姛鍚庡搷搴旂姸鎬佺爜
-// };
-const fetchCredentials = async file => {
+const handleChangeFile = async file => {
+  if (file.status !== "ready") return;
+  // const isLt10M = file.size / 1024 / 1024 < 10;
+  // fetchCredentials(file);
   // 杩欓噷搴旇皟鐢ㄤ綘鑷繁鐨勫悗绔帴鍙h幏鍙栦复鏃跺嚟璇�
   let res = await getUploadToken();
   if (res.code == 200) {
     let keyVal = generateTimestampWithRandom(res.result.DirPath, file.name);
+    let upUrl = res.result.url;
+    let upPath = res.result.DirPath;
     let formData = new FormData();
     formData.append("policy", res.result.policy);
     formData.append(
@@ -166,17 +190,60 @@
     formData.append("key", keyVal); // 鏂囦欢鍚�
     formData.append("file", file.raw); // file 蹇呴』涓烘渶鍚庝竴涓〃鍗曞煙
     uploadFileAli(formData, res.result.url).then(res => {
-      let path = res.result.url + "/" + res.result.DirPath + keyVal;
-      console.log(path);
-
+      let path = `${upUrl}${keyVal}`;
+      newFormInline.value.fujian += newFormInline.value.fujian
+        ? `,${path}`
+        : path;
+      newFormInline.value.fujianName += newFormInline.value.fujianName
+        ? `,${file.name}`
+        : file.name;
+    });
+  }
+};
+// state.formDataNew = {
+//   policy: res.result.policy, //琛ㄥ崟鍩�
+//   "x-oss-signature-version": res.result.x_oss_signature_version, //鎸囧畾绛惧悕鐨勭増鏈拰绠楁硶
+//   "x-oss-credential": res.result.x_oss_credential, //鎸囨槑娲剧敓瀵嗛挜鐨勫弬鏁伴泦
+//   "x-oss-date": res.result.x_oss_date, //璇锋眰鐨勬椂闂�
+//   "x-oss-signature": res.result.signature, //绛惧悕璁よ瘉鎻忚堪淇℃伅
+//   "x-oss-security-token": res.result.security_token, //瀹夊叏浠ょ墝
+//   success_action_status: "200" //涓婁紶鎴愬姛鍚庡搷搴旂姸鎬佺爜
+// };
+const fetchCredentials = async file => {
+  // 杩欓噷搴旇皟鐢ㄤ綘鑷繁鐨勫悗绔帴鍙h幏鍙栦复鏃跺嚟璇�
+  let res = await getUploadToken();
+  if (res.code == 200) {
+    let keyVal = generateTimestampWithRandom(res.result.DirPath, file.name);
+    let upUrl = res.result.url;
+    let upPath = res.result.DirPath;
+    let formData = new FormData();
+    formData.append("policy", res.result.policy);
+    formData.append(
+      "x-oss-signature-version",
+      res.result.x_oss_signature_version
+    );
+    formData.append("x-oss-credential", res.result.x_oss_credential);
+    formData.append("x-oss-date", res.result.x_oss_date);
+    // formData.append("Signature", res.result.signature);
+    formData.append("x-oss-signature", res.result.signature);
+    formData.append("x-oss-security-token", res.result.security_token);
+    // formData.append("x-oss-content-type", "application/pdf");
+    formData.append("success_action_status", "200");
+    formData.append("key", keyVal); // 鏂囦欢鍚�
+    formData.append("file", file.raw); // file 蹇呴』涓烘渶鍚庝竴涓〃鍗曞煙
+    uploadFileAli(formData, res.result.url).then(res => {
+      let path = `${upUrl}${keyVal}`;
       if (props.isChange) {
         newFormInline.value.biangengwenjian = path;
+        newFormInline.value.biangengwenjianName = file.name;
       } else {
         newFormInline.value.zhaobiaowenjian = path;
+        newFormInline.value.zhaobiaowenjianName = file.name;
       }
     });
   }
 };
+const defaultTime = new Date(2000, 1, 1, 9, 30, 0);
 const beforeAvatarUpload: UploadProps["beforeUpload"] = rawFile => {
   isLoading.value = true;
   if (rawFile.type !== "application/pdf") {
@@ -201,7 +268,16 @@
   upload.value!.handleStart(file);
 };
 defineExpose({ getRef });
-onMounted(async () => {});
+onMounted(async () => {
+  if (props.formInline.biangengwenjianName) {
+    validateForm.fileList = [
+      {
+        name: props.formInline.biangengwenjianName,
+        url: props.formInline.biangengwenjian
+      }
+    ];
+  }
+});
 </script>
 
 <template>
@@ -209,10 +285,21 @@
     ref="ruleFormRef"
     :model="newFormInline"
     :rules="gonggaoRules"
-    label-width="140px"
+    :label-width="props.changeDetail ? '50px' : '140px'"
   >
-    <el-row :gutter="30">
-      <div v-if="props.isChange">
+    <el-row v-if="props.changeDetail" :gutter="10">
+      <re-col :value="24" :xs="24" :sm="24">
+        <el-form-item label="鏍囬" prop="projectName">
+          <el-input
+            v-model="newFormInline.projectName"
+            clearable
+            placeholder="璇疯緭鍏ユ爣棰�"
+          />
+        </el-form-item>
+      </re-col>
+    </el-row>
+    <el-row v-else :gutter="30">
+      <div v-if="props.isChange" style="width: 100%">
         <re-col :value="24" :xs="24" :sm="24">
           <el-form-item label="鏍囬" prop="projectName">
             <el-input
@@ -253,6 +340,7 @@
             v-model="newFormInline.toubiaoStartDate"
             type="datetime"
             clearable
+            :default-time="defaultTime"
             placeholder="璇烽�夋嫨鎶曟爣鎶ュ悕寮�濮嬫椂闂�"
             value-format="YYYY-MM-DD HH:mm:ss"
           />
@@ -264,6 +352,7 @@
             v-model="newFormInline.toubiaoEndDate"
             type="datetime"
             clearable
+            :default-time="defaultTime"
             placeholder="璇烽�夋嫨鎶曟爣鎶ュ悕缁撴潫鏃堕棿"
             value-format="YYYY-MM-DD HH:mm:ss"
           />
@@ -275,6 +364,7 @@
             v-model="newFormInline.kaibiaoDate"
             type="datetime"
             clearable
+            :default-time="defaultTime"
             placeholder="璇烽�夋嫨寮�鏍囨椂闂�"
             value-format="YYYY-MM-DD HH:mm:ss"
           />
@@ -301,6 +391,23 @@
           </el-upload>
         </el-form-item>
       </re-col>
+      <re-col v-if="!props.isChange" :value="24" :xs="24" :sm="24">
+        <el-form-item label="闄勪欢" prop="">
+          <el-upload
+            ref="upload"
+            v-model:file-list="validateForm.fileListFile"
+            multiple
+            :on-exceed="handleExceed"
+            :auto-upload="false"
+            :on-success="handleAvatarSuccess"
+            :before-upload="beforeAvatarUpload"
+            :headers="state.headers"
+            @change="handleChangeFile"
+          >
+            <el-button type="primary">鐐瑰嚮涓婁紶</el-button>
+          </el-upload>
+        </el-form-item>
+      </re-col>
       <re-col :value="24" :xs="24" :sm="24">
         <el-form-item label="寮�鏍囧湴鐐�" prop="kaibiaodidian">
           <el-input
@@ -319,6 +426,7 @@
 .el-date-editor.el-input__wrapper {
   width: 100%;
 }
+
 .upload__tip {
   width: 100%;
 }

--
Gitblit v1.9.1