Bladeren bron

修改伙伴商问题

hurx 3 dagen geleden
bovenliggende
commit
6cab197fd2
2 gewijzigde bestanden met toevoegingen van 51 en 78 verwijderingen
  1. 7 1
      src/views/partner/qualification/index.vue
  2. 44 77
      src/views/report/order/index.vue

+ 7 - 1
src/views/partner/qualification/index.vue

@@ -56,7 +56,13 @@
 <script setup lang="ts" name="PartnerQualification">
 import { ref, onMounted } from 'vue';
 import { ElMessage, ElMessageBox } from 'element-plus';
-import { getCurrentPartnerInfo, getPartnerQualificationList, addPartnerQualification, updatePartnerQualification, deletePartnerQualification } from '@/api/partner';
+import {
+  getCurrentPartnerInfo,
+  getPartnerQualificationList,
+  addPartnerQualification,
+  updatePartnerQualification,
+  deletePartnerQualification
+} from '@/api/partner';
 
 const qualificationList = ref([]);
 const loading = ref(false);

+ 44 - 77
src/views/report/order/index.vue

@@ -103,8 +103,8 @@
             <div style="display: flex; flex-wrap: wrap; gap: 4px; justify-content: center">
               <el-button link type="primary" @click="handleUpdate(scope.row)">编辑</el-button>
               <el-button link type="success" @click="handleSubmit(scope.row)">提交</el-button>
-              <el-button link type="danger" @click="handleReject(scope.row)">驳回</el-button>
-              <el-button link type="primary" @click="handleConfirm(scope.row)">确认</el-button>
+              <!-- <el-button link type="danger" @click="handleReject(scope.row)">驳回</el-button> -->
+              <!-- <el-button link type="primary" @click="handleConfirm(scope.row)">确认</el-button> -->
               <el-button link type="info" @click="handleViewAttachment(scope.row)">查看附件</el-button>
             </div>
           </template>
@@ -168,19 +168,7 @@
         <el-row :gutter="20">
           <el-col :span="24">
             <el-form-item label="发票附件" prop="invoiceAttachment">
-              <el-upload
-                class="upload-demo"
-                :action="uploadAction"
-                :headers="uploadHeaders"
-                :on-success="handleUploadSuccess"
-                :on-error="handleUploadError"
-                :file-list="fileList"
-                :limit="5"
-                :on-exceed="handleExceed"
-              >
-                <el-button size="small" type="primary">合同上传</el-button>
-              </el-upload>
-              <div style="color: #999; font-size: 12px; margin-top: 4px">支持jpg/png/pdf/xlsx等文件,最多5个</div>
+              <FileUpload v-model="form.invoiceAttachment" :file-size="5" :file-type="['jpg', 'jpeg', 'png', 'xlsx', 'xls', 'doc', 'docx', 'pdf']" />
             </el-form-item>
           </el-col>
         </el-row>
@@ -370,22 +358,22 @@
     <!-- 附件查看抽屉 -->
     <el-drawer v-model="attachmentDrawer.visible" title="查看附件" direction="rtl" size="50%" :close-on-click-modal="true">
       <el-table :data="attachmentDrawer.attachments" border style="width: 100%">
-        <el-table-column label="附件名称" prop="name" width="150" />
-        <el-table-column label="附件预览" align="center" width="200">
+        <el-table-column label="附件名称" prop="name" />
+        <el-table-column label="附件预览" align="center">
           <template #default="scope">
             <el-image
-              v-if="scope.row.url.match(/\.(jpg|jpeg|png|gif|webp)$/i)"
+              v-if="isImageFile(scope.row.url)"
               :src="scope.row.url"
               style="width: 100px; height: 100px"
               fit="cover"
               :preview-src-list="attachmentDrawer.attachments.map((a: any) => a.url)"
             />
-            <span v-else>不支持预览</span>
+            <span v-else>{{ getFileTypeLabel(scope.row.url) }}</span>
           </template>
         </el-table-column>
         <el-table-column label="操作" align="center" width="150">
           <template #default="scope">
-            <el-button link type="primary" @click="window.open(scope.row.url, '_blank')">下载</el-button>
+            <el-button link type="primary" @click="downloadFile(scope.row.url)">下载</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -395,7 +383,7 @@
 </template>
 
 <script setup name="OrderReport" lang="ts">
-import { getCurrentInstance, reactive, ref, toRefs, computed } from 'vue';
+import { getCurrentInstance, reactive, ref, toRefs } from 'vue';
 import {
   listPartnerPrepared,
   getPartnerPrepared,
@@ -410,8 +398,9 @@ import {
 } from '@/api/partner/prepared';
 import { getCurrentPartnerInfo } from '@/api/partner';
 import { PartnerPreparedVO, PartnerPreparedForm, PartnerPreparedQuery } from '@/api/partner/prepared/types';
+import { listByIds } from '@/api/system/oss';
 import { ComponentInternalInstance } from 'vue';
-import { getToken } from '@/utils/auth';
+import FileUpload from '@/components/FileUpload/index.vue';
 
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 
@@ -430,15 +419,8 @@ const single = ref(true);
 const multiple = ref(true);
 const total = ref(0);
 const expandedRows = ref<string[]>([]);
-const fileList = ref<any[]>([]);
 const partnerId = ref(0);
 
-// 文件上传配置
-const uploadAction = computed(() => import.meta.env.VITE_APP_BASE_API + '/resource/oss/upload?clientid=' + import.meta.env.VITE_APP_CLIENT_ID);
-const uploadHeaders = computed(() => ({
-  Authorization: 'Bearer ' + getToken()
-}));
-
 /** 获取字典标签 */
 function getDictLabel(dictList: any[], value: any) {
   if (!dictList || !value) return '';
@@ -520,7 +502,11 @@ const data = reactive({
     dealStatus: undefined
   } as PartnerPreparedQuery,
   rules: {
-    customerName: [{ required: true, message: '客户名称不能为空', trigger: 'blur' }]
+    customerName: [{ required: true, message: '客户名称不能为空', trigger: 'blur' }],
+    phone: [
+      { required: true, message: '下单手机号不能为空', trigger: 'blur' },
+      { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号', trigger: 'blur' }
+    ]
   },
   dialog: {
     visible: false,
@@ -630,17 +616,6 @@ function handleUpdate(row?: any) {
     // 使用 Object.assign 更新 form.value,而不是直接替换
     Object.assign(form.value, res.data);
 
-    // 加载已有附件到文件列表
-    if (res.data.invoiceAttachment) {
-      const urls = res.data.invoiceAttachment.split(',');
-      fileList.value = urls.map((url: string, index: number) => ({
-        name: `附件${index + 1}`,
-        url: url
-      }));
-    } else {
-      fileList.value = [];
-    }
-
     dialog.value.visible = true;
     dialog.value.title = '修改订单报备';
     // 加载产品明细
@@ -821,53 +796,45 @@ function handleReject(row: any) {
     .catch(() => {});
 }
 
-function handleViewAttachment(row: any) {
-  if (row.invoiceAttachment) {
-    // 解析附件URL列表
-    const urls = row.invoiceAttachment.split(',').filter(Boolean);
-    attachmentDrawer.value.attachments = urls.map((url: string, index: number) => ({
+async function handleViewAttachment(row: any) {
+  if (!row.invoiceAttachment) {
+    proxy?.$modal.msgWarning('该订单暂无附件');
+    return;
+  }
+  const ids = row.invoiceAttachment.split(',').filter(Boolean);
+  // 判断是 ossId 还是 URL(兼容旧数据)
+  const isUrl = ids[0].startsWith('http://') || ids[0].startsWith('https://');
+  if (isUrl) {
+    attachmentDrawer.value.attachments = ids.map((url: string, index: number) => ({
       name: `附件${index + 1}`,
       url: url.trim()
     }));
-    attachmentDrawer.value.visible = true;
   } else {
-    proxy?.$modal.msgWarning('该订单暂无附件');
+    try {
+      const res = await listByIds(row.invoiceAttachment);
+      attachmentDrawer.value.attachments = (res.data || []).map((item: any) => ({
+        name: item.originalName || item.fileName || '',
+        url: item.url || ''
+      }));
+    } catch {
+      proxy?.$modal.msgError('获取附件信息失败');
+      return;
+    }
   }
+  attachmentDrawer.value.visible = true;
 }
 
-/** 文件上传成功 */
-function handleUploadSuccess(response: any, file: any, fileListParam: any[]) {
-  console.log('上传成功回调 - response:', response);
-  console.log('上传成功回调 - file:', file);
-  console.log('上传成功回调 - fileListParam:', fileListParam);
-
-  if (response.code === 200) {
-    // 更新 fileList
-    fileList.value = fileListParam;
-    // 收集所有已上传成功的文件URL
-    const urls = fileListParam
-      .filter((f: any) => f.response?.code === 200 || f.url)
-      .map((f: any) => f.response?.data?.url || f.url)
-      .filter(Boolean);
-
-    console.log('提取的URLs:', urls);
-    form.value.invoiceAttachment = urls.join(',');
-    console.log('保存到表单的附件:', form.value.invoiceAttachment);
-
-    proxy?.$modal.msgSuccess('文件上传成功');
-  } else {
-    proxy?.$modal.msgError(response.msg || '文件上传失败');
-  }
+function isImageFile(url: string) {
+  return /\.(jpg|jpeg|png|gif|webp)(\?|$)/i.test(url);
 }
 
-/** 文件上传失败 */
-function handleUploadError() {
-  proxy?.$modal.msgError('文件上传失败,请重试');
+function getFileTypeLabel(url: string) {
+  const ext = url.match(/\.(\w+)(\?|$)/i);
+  return ext ? ext[1].toUpperCase() + ' 文件' : '不支持预览';
 }
 
-/** 文件数量超出限制 */
-function handleExceed() {
-  proxy?.$modal.msgWarning('最多只能上传5个文件');
+function downloadFile(url: string) {
+  window.open(url, '_blank');
 }
 
 function handleAddProduct() {