foodBusinessLicense.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  1. <template>
  2. <div class="card content-box">
  3. <div class="content-section">
  4. <div class="tip-text">食品经营许可证到期时间:{{ expirationTime || "--" }}</div>
  5. <div class="action-buttons">
  6. <el-button type="primary" @click="handleReplace"> 更换 </el-button>
  7. <el-button type="primary" @click="handleViewChangeRecord"> 查看变更记录 </el-button>
  8. </div>
  9. </div>
  10. <div class="license-container" v-if="licenseImage">
  11. <div class="license-display">
  12. <el-image :src="licenseImage" fit="contain" class="license-image" :preview-src-list="[licenseImage]">
  13. <template #error>
  14. <div class="empty-image-box">
  15. <el-icon class="empty-icon">
  16. <Picture />
  17. </el-icon>
  18. </div>
  19. </template>
  20. </el-image>
  21. </div>
  22. </div>
  23. <div v-else class="empty-license">
  24. <el-empty description="暂无食品经营许可证" :image-size="100" />
  25. </div>
  26. <!-- 更换食品经营许可证弹窗 -->
  27. <el-dialog
  28. v-model="replaceDialogVisible"
  29. title="更换食品经营许可证"
  30. width="600px"
  31. :before-close="handleReplaceDialogClose"
  32. :close-on-click-modal="false"
  33. :close-on-press-escape="false"
  34. >
  35. <div class="replace-upload-area" :class="{ 'upload-full': uploadedImageCount >= 1 }">
  36. <div class="upload-tip">只允许上传jpg,jpeg,png格式图片;上传图片不得超过20M</div>
  37. <el-upload
  38. v-model:file-list="fileList"
  39. list-type="picture-card"
  40. :accept="'.jpg,.jpeg,.png'"
  41. :limit="1"
  42. :auto-upload="false"
  43. :disabled="hasUnuploadedImages"
  44. :on-change="handleUploadChange"
  45. :on-exceed="handleUploadExceed"
  46. :on-preview="handlePictureCardPreview"
  47. :before-remove="handleBeforeRemove"
  48. :on-remove="handleRemove"
  49. :show-file-list="true"
  50. >
  51. <template #trigger>
  52. <div v-if="uploadedImageCount < 1" class="upload-trigger-card el-upload--picture-card">
  53. <el-icon>
  54. <Plus />
  55. </el-icon>
  56. <div class="upload-tip">({{ uploadedImageCount }}/1)</div>
  57. </div>
  58. </template>
  59. </el-upload>
  60. </div>
  61. <template #footer>
  62. <div class="dialog-footer">
  63. <el-button @click="handleCancelReplace" :disabled="hasUnuploadedImages"> 取消 </el-button>
  64. <el-button type="primary" @click="handleSubmitReplace" :disabled="hasUnuploadedImages"> 去审核 </el-button>
  65. </div>
  66. </template>
  67. </el-dialog>
  68. <!-- 图片预览 -->
  69. <el-image-viewer
  70. v-if="imageViewerVisible"
  71. :url-list="imageViewerUrlList"
  72. :initial-index="imageViewerInitialIndex"
  73. @close="imageViewerVisible = false"
  74. />
  75. <!-- 变更记录弹窗 -->
  76. <el-dialog v-model="changeRecordDialogVisible" title="变更记录" width="900px" :close-on-click-modal="false">
  77. <el-scrollbar height="400px" class="change-record-scrollbar">
  78. <div v-if="changeRecordList && changeRecordList.length > 0" class="change-record-content">
  79. <div v-for="(item, index) in changeRecordList" :key="index" class="record-group">
  80. <div class="record-date">
  81. {{ item.createdDateFormat }}
  82. </div>
  83. <div class="record-items">
  84. <div class="record-item">
  85. <div class="record-status-badge" :class="getStatusClass(item.licenseExecuteStatus)">
  86. {{ item.licenseExecuteName }}
  87. </div>
  88. <el-image
  89. :src="item.imgUrl"
  90. fit="cover"
  91. class="record-image"
  92. :preview-src-list="changeRecordList.map(record => record.imgUrl)"
  93. :initial-index="index"
  94. >
  95. <template #error>
  96. <div class="image-slot">
  97. <el-icon><Picture /></el-icon>
  98. </div>
  99. </template>
  100. </el-image>
  101. </div>
  102. </div>
  103. <div v-if="item.reasonRefusal" class="rejection-reason">拒绝原因: {{ item.reasonRefusal }}</div>
  104. </div>
  105. </div>
  106. <div v-else class="empty-record">
  107. <el-empty description="暂无变更记录" :image-size="100" />
  108. </div>
  109. </el-scrollbar>
  110. <template #footer>
  111. <div class="dialog-footer">
  112. <el-button type="primary" @click="changeRecordDialogVisible = false"> 关闭 </el-button>
  113. </div>
  114. </template>
  115. </el-dialog>
  116. </div>
  117. </template>
  118. <script setup lang="ts" name="foodBusinessLicense">
  119. import { ref, computed, onMounted } from "vue";
  120. import { ElMessage, ElMessageBox } from "element-plus";
  121. import { Picture, Plus } from "@element-plus/icons-vue";
  122. import type { UploadProps, UploadFile } from "element-plus";
  123. import {
  124. getFoodBusinessLicense,
  125. uploadContractImage,
  126. submitFoodLicenseReview,
  127. getChangeRecords,
  128. getStoreFoodLicenceStatus,
  129. ocrRequestUrl
  130. } from "@/api/modules/licenseManagement";
  131. import { localGet } from "@/utils";
  132. const userInfo = localGet("geeker-user")?.userInfo || {};
  133. // 状态映射对象
  134. const statusMap: Record<number, { name: string; class: string }> = {
  135. 1: { name: "审核通过", class: "status-success" },
  136. 2: { name: "审核中", class: "status-pending" },
  137. 3: { name: "审核拒绝", class: "status-failed" }
  138. };
  139. const id = localGet("createdId");
  140. const licenseImage = ref<string>("");
  141. const expirationTime = ref<string>("");
  142. const replaceDialogVisible = ref(false);
  143. const changeRecordDialogVisible = ref(false);
  144. const fileList = ref<UploadFile[]>([]);
  145. const changeRecordList = ref<any>([]);
  146. // ==================== 图片上传相关变量 ====================
  147. const uploading = ref(false);
  148. const pendingUploadFiles = ref<UploadFile[]>([]);
  149. const imageUrlList = ref<string[]>([]); // 存储图片URL列表
  150. // 图片预览相关
  151. const imageViewerVisible = ref(false);
  152. const imageViewerUrlList = ref<string[]>([]);
  153. const imageViewerInitialIndex = ref(0);
  154. // 计算属性:获取已成功上传的图片数量
  155. const uploadedImageCount = computed(() => {
  156. return fileList.value.filter((file: any) => file.status === "success" && file.url).length;
  157. });
  158. // 计算属性:检查是否有未上传完成的图片
  159. const hasUnuploadedImages = computed(() => {
  160. // 检查是否有正在上传的文件
  161. if (uploading.value || pendingUploadFiles.value.length > 0) {
  162. return true;
  163. }
  164. // 检查文件列表中是否有状态为 "ready"(待上传)或 "uploading"(上传中)的图片
  165. if (fileList.value && fileList.value.length > 0) {
  166. return fileList.value.some((file: any) => {
  167. return file.status === "ready" || file.status === "uploading";
  168. });
  169. }
  170. return false;
  171. });
  172. onMounted(async () => {
  173. await initData();
  174. });
  175. const initData = async () => {
  176. const params = {
  177. id: id
  178. };
  179. const res: any = await getFoodBusinessLicense(params);
  180. if (res.code == 200) {
  181. licenseImage.value = res.data[0]?.imgUrl;
  182. expirationTime.value = res.data[0]?.expirationTime;
  183. }
  184. };
  185. const handleReplace = async () => {
  186. fileList.value = [];
  187. imageUrlList.value = [];
  188. pendingUploadFiles.value = [];
  189. uploading.value = false;
  190. const params = {
  191. id: localGet("createdId")
  192. };
  193. const res: any = await getStoreFoodLicenceStatus(params);
  194. if (res.data.foodLicenceStatus == 2) {
  195. ElMessage.warning("食品经营许可证审核中,请耐心等待");
  196. } else {
  197. replaceDialogVisible.value = true;
  198. }
  199. };
  200. const handleViewChangeRecord = async () => {
  201. try {
  202. const params = {
  203. storeId: localGet("createdId")
  204. };
  205. const res: any = await getChangeRecords(params);
  206. if (res.code === 200) {
  207. changeRecordList.value = res.data;
  208. } else {
  209. // 请求失败时清空数据
  210. changeRecordList.value = [];
  211. }
  212. changeRecordDialogVisible.value = true;
  213. } catch (error) {
  214. ElMessage.error("获取变更记录失败");
  215. // 发生错误时清空数据并显示空状态
  216. changeRecordList.value = [];
  217. changeRecordDialogVisible.value = true;
  218. }
  219. };
  220. /**
  221. * 检查文件是否在排队中(未上传)
  222. * @param file 文件对象
  223. * @returns 是否在排队中
  224. */
  225. const isFilePending = (file: any): boolean => {
  226. // 只检查 ready 状态(排队中),不包括 uploading(正在上传)
  227. if (file.status === "ready") {
  228. return true;
  229. }
  230. // 检查是否在待上传队列中
  231. if (pendingUploadFiles.value.some(item => item.uid === file.uid)) {
  232. return true;
  233. }
  234. return false;
  235. };
  236. /**
  237. * 图片上传 - 删除前确认
  238. * @param uploadFile 要删除的文件对象
  239. * @param uploadFiles 当前文件列表
  240. * @returns Promise<boolean>,true 允许删除,false 阻止删除
  241. */
  242. const handleBeforeRemove = async (uploadFile: any, uploadFiles: any[]): Promise<boolean> => {
  243. // 如果文件在排队中(未上传),禁止删除
  244. if (isFilePending(uploadFile)) {
  245. ElMessage.warning("图片尚未上传,请等待上传完成后再删除");
  246. return false;
  247. }
  248. try {
  249. await ElMessageBox.confirm("确定要删除这张图片吗?", "提示", {
  250. confirmButtonText: "确定",
  251. cancelButtonText: "取消",
  252. type: "warning"
  253. });
  254. // 用户确认删除,返回 true 允许删除
  255. return true;
  256. } catch {
  257. // 用户取消删除,返回 false 阻止删除
  258. return false;
  259. }
  260. };
  261. /**
  262. * 图片上传 - 移除图片回调(删除成功后调用)
  263. * @param uploadFile 已删除的文件对象
  264. * @param uploadFiles 删除后的文件列表
  265. */
  266. const handleRemove: UploadProps["onRemove"] = (uploadFile, uploadFiles) => {
  267. // 从被删除的文件对象中获取 url
  268. const file = uploadFile as any;
  269. const imageUrl = file.url;
  270. if (imageUrl) {
  271. // 从 imageUrl 数组中删除对应的 URL
  272. const urlIndex = imageUrlList.value.indexOf(imageUrl);
  273. if (urlIndex > -1) {
  274. imageUrlList.value.splice(urlIndex, 1);
  275. }
  276. }
  277. if (file.url && file.url.startsWith("blob:")) {
  278. URL.revokeObjectURL(file.url);
  279. }
  280. // 同步文件列表
  281. fileList.value = [...uploadFiles];
  282. // 删除成功后提示
  283. ElMessage.success("图片已删除");
  284. };
  285. /**
  286. * 上传文件超出限制提示
  287. */
  288. const handleUploadExceed: UploadProps["onExceed"] = () => {
  289. ElMessage.warning("最多只能上传1张图片");
  290. };
  291. /**
  292. * el-upload 文件变更(选中或移除)
  293. */
  294. const handleUploadChange: UploadProps["onChange"] = async (uploadFile, uploadFiles) => {
  295. // 检查文件类型,只允许 jpg 和 png
  296. if (uploadFile.raw) {
  297. const fileType = uploadFile.raw.type.toLowerCase();
  298. const fileName = uploadFile.name.toLowerCase();
  299. const validTypes = ["image/jpeg", "image/jpg", "image/png"];
  300. const validExtensions = [".jpg", ".jpeg", ".png"];
  301. // 检查 MIME 类型或文件扩展名
  302. const isValidType = validTypes.includes(fileType) || validExtensions.some(ext => fileName.endsWith(ext));
  303. if (!isValidType) {
  304. // 从文件列表中移除不符合类型的文件
  305. const index = fileList.value.findIndex((f: any) => f.uid === uploadFile.uid);
  306. if (index > -1) {
  307. fileList.value.splice(index, 1);
  308. }
  309. // 从 uploadFiles 中移除
  310. const uploadIndex = uploadFiles.findIndex((f: any) => f.uid === uploadFile.uid);
  311. if (uploadIndex > -1) {
  312. uploadFiles.splice(uploadIndex, 1);
  313. }
  314. // 如果文件有 blob URL,释放它
  315. if (uploadFile.url && uploadFile.url.startsWith("blob:")) {
  316. URL.revokeObjectURL(uploadFile.url);
  317. }
  318. ElMessage.warning("只支持上传 JPG、JPEG 和 PNG 格式的图片");
  319. return;
  320. }
  321. // 检查文件大小,不得超过20M
  322. const maxSize = 20 * 1024 * 1024; // 20MB
  323. if (uploadFile.raw.size > maxSize) {
  324. // 从文件列表中移除超过大小的文件
  325. const index = fileList.value.findIndex((f: any) => f.uid === uploadFile.uid);
  326. if (index > -1) {
  327. fileList.value.splice(index, 1);
  328. }
  329. // 从 uploadFiles 中移除
  330. const uploadIndex = uploadFiles.findIndex((f: any) => f.uid === uploadFile.uid);
  331. if (uploadIndex > -1) {
  332. uploadFiles.splice(uploadIndex, 1);
  333. }
  334. // 如果文件有 blob URL,释放它
  335. if (uploadFile.url && uploadFile.url.startsWith("blob:")) {
  336. URL.revokeObjectURL(uploadFile.url);
  337. }
  338. ElMessage.warning("上传图片不得超过20M");
  339. return;
  340. }
  341. }
  342. // 同步文件列表到表单数据(只添加通过验证的文件)
  343. const existingIndex = fileList.value.findIndex((f: any) => f.uid === uploadFile.uid);
  344. if (existingIndex === -1) {
  345. fileList.value.push(uploadFile);
  346. }
  347. const readyFiles = fileList.value.filter(file => file.status === "ready");
  348. if (readyFiles.length) {
  349. readyFiles.forEach(file => {
  350. if (!pendingUploadFiles.value.some(item => item.uid === file.uid)) {
  351. pendingUploadFiles.value.push(file);
  352. }
  353. });
  354. }
  355. processUploadQueue();
  356. };
  357. /**
  358. * 处理上传队列 - 逐个上传文件
  359. */
  360. const processUploadQueue = async () => {
  361. if (uploading.value || pendingUploadFiles.value.length === 0) {
  362. return;
  363. }
  364. // 每次只取一个文件进行上传
  365. const file = pendingUploadFiles.value.shift();
  366. if (file) {
  367. await uploadSingleFile(file);
  368. // 继续处理队列中的下一个文件
  369. processUploadQueue();
  370. }
  371. };
  372. /**
  373. * 单文件上传图片
  374. * @param file 待上传的文件
  375. */
  376. const uploadSingleFile = async (file: UploadFile) => {
  377. if (!file.raw) {
  378. return;
  379. }
  380. const rawFile = file.raw as File;
  381. const formData = new FormData();
  382. formData.append("file", rawFile);
  383. formData.append("user", "text");
  384. file.status = "uploading";
  385. file.percentage = 0;
  386. uploading.value = true;
  387. try {
  388. // 上传过程中保持进度为 0,避免接口异常时进度条误显示 100%
  389. const result: any = await uploadContractImage(formData);
  390. if (result?.code === 200 && result.data) {
  391. // 处理单个文件的上传结果
  392. let imageUrl = result.data[0];
  393. if (!imageUrl) {
  394. throw new Error("上传成功但未获取到图片URL");
  395. }
  396. file.status = "success";
  397. file.percentage = 100;
  398. // 保存图片URL到文件对象
  399. file.url = imageUrl;
  400. file.response = { url: imageUrl };
  401. // 保存图片URL
  402. if (!Array.isArray(imageUrlList.value)) {
  403. imageUrlList.value = [];
  404. }
  405. if (!imageUrlList.value.includes(imageUrl)) {
  406. imageUrlList.value.push(imageUrl);
  407. }
  408. // 图片上传成功后调用 OCR 接口进行识别校验
  409. try {
  410. const params = {
  411. imageUrls: imageUrl,
  412. ocrType: "FOOD_MANAGE_LICENSE",
  413. storeId: userInfo.storeId,
  414. storeUserId: userInfo.id
  415. };
  416. const res: any = await ocrRequestUrl(params);
  417. if (res.code == 200) {
  418. ElMessage.success("食品经营许可证识别成功");
  419. } else {
  420. // OCR 识别失败:提示并删除当前图片
  421. ElMessage.error(res?.msg || "识别失败,请重试");
  422. // 从文件列表中移除当前文件
  423. const index = fileList.value.findIndex((f: any) => f.uid === file.uid);
  424. if (index > -1) {
  425. fileList.value.splice(index, 1);
  426. }
  427. // 从图片 URL 列表中移除
  428. const urlIndex = imageUrlList.value.indexOf(imageUrl);
  429. if (urlIndex > -1) {
  430. imageUrlList.value.splice(urlIndex, 1);
  431. }
  432. // 如果有 blob URL,释放掉(稳妥处理)
  433. if (file.url && file.url.startsWith("blob:")) {
  434. URL.revokeObjectURL(file.url);
  435. }
  436. }
  437. } catch (error) {
  438. // 调用接口异常时:提示并删除当前图片
  439. const index = fileList.value.findIndex((f: any) => f.uid === file.uid);
  440. if (index > -1) {
  441. fileList.value.splice(index, 1);
  442. }
  443. const urlIndex = imageUrlList.value.indexOf(imageUrl);
  444. if (urlIndex > -1) {
  445. imageUrlList.value.splice(urlIndex, 1);
  446. }
  447. if (file.url && file.url.startsWith("blob:")) {
  448. URL.revokeObjectURL(file.url);
  449. }
  450. }
  451. } else {
  452. throw new Error(result?.msg || "图片上传失败");
  453. }
  454. } catch (error: any) {
  455. file.status = "fail";
  456. // 上传失败时保持进度条为 0
  457. file.percentage = 0;
  458. if (file.url && file.url.startsWith("blob:")) {
  459. URL.revokeObjectURL(file.url);
  460. }
  461. // 从文件列表中移除失败的文件
  462. const index = fileList.value.findIndex((f: any) => f.uid === file.uid);
  463. if (index > -1) {
  464. fileList.value.splice(index, 1);
  465. }
  466. // Error message handled by global upload method, except for specific business logic errors
  467. if (error?.message && error.message.includes("未获取到图片URL")) {
  468. ElMessage.error(error.message);
  469. }
  470. } finally {
  471. uploading.value = false;
  472. // 触发视图更新
  473. fileList.value = [...fileList.value];
  474. }
  475. };
  476. /**
  477. * 图片预览 - 使用 el-image-viewer 预览功能
  478. * @param file 上传文件对象
  479. */
  480. const handlePictureCardPreview = (file: any) => {
  481. // 如果文件在排队中(未上传),禁止预览
  482. if (isFilePending(file)) {
  483. ElMessage.warning("图片尚未上传,请等待上传完成后再预览");
  484. return;
  485. }
  486. // 如果文件正在上传中,允许预览(使用本地预览)
  487. if (file.status === "uploading" && file.url) {
  488. imageViewerUrlList.value = [file.url];
  489. imageViewerInitialIndex.value = 0;
  490. imageViewerVisible.value = true;
  491. return;
  492. }
  493. // 获取所有图片的 URL 列表(只包含已上传成功的图片)
  494. const urlList = fileList.value
  495. .filter((item: any) => item.status === "success" && (item.url || item.response?.data))
  496. .map((item: any) => item.url || item.response?.data);
  497. // 找到当前点击的图片索引
  498. const currentIndex = urlList.findIndex((url: string) => url === (file.url || file.response?.data));
  499. if (currentIndex < 0) {
  500. ElMessage.warning("图片尚未上传完成,无法预览");
  501. return;
  502. }
  503. imageViewerUrlList.value = urlList;
  504. imageViewerInitialIndex.value = currentIndex;
  505. imageViewerVisible.value = true;
  506. };
  507. const handleCancelReplace = async () => {
  508. // 如果有图片正在上传,阻止关闭
  509. if (hasUnuploadedImages.value) {
  510. ElMessage.warning("请等待图片上传完成后再关闭");
  511. return;
  512. }
  513. if (fileList.value.length > 0) {
  514. try {
  515. await ElMessageBox.confirm("确定要取消本次图片上传吗?已上传的图片将不保存", "提示", {
  516. confirmButtonText: "确定",
  517. cancelButtonText: "取消",
  518. type: "warning"
  519. });
  520. // 用户确认取消
  521. fileList.value = [];
  522. imageUrlList.value = [];
  523. pendingUploadFiles.value = [];
  524. uploading.value = false;
  525. replaceDialogVisible.value = false;
  526. } catch {
  527. // 用户取消操作,不做任何处理
  528. }
  529. } else {
  530. replaceDialogVisible.value = false;
  531. }
  532. };
  533. const handleReplaceDialogClose = async (done: () => void) => {
  534. // 如果有图片正在上传,阻止关闭
  535. if (hasUnuploadedImages.value) {
  536. ElMessage.warning("请等待图片上传完成后再关闭");
  537. return; // 不调用 done(),阻止关闭弹窗
  538. }
  539. if (fileList.value.length > 0) {
  540. try {
  541. await ElMessageBox.confirm("确定要取消本次图片上传吗?已上传的图片将不保存", "提示", {
  542. confirmButtonText: "确定",
  543. cancelButtonText: "取消",
  544. type: "warning"
  545. });
  546. // 用户确认取消,清空数据并关闭弹窗
  547. fileList.value = [];
  548. imageUrlList.value = [];
  549. pendingUploadFiles.value = [];
  550. uploading.value = false;
  551. done(); // 调用 done() 允许关闭弹窗
  552. } catch {
  553. // 用户取消操作,不调用 done(),阻止关闭弹窗
  554. }
  555. } else {
  556. // 没有文件,直接关闭
  557. done();
  558. }
  559. };
  560. const handleSubmitReplace = async () => {
  561. // 检查是否有未上传完成的图片
  562. if (hasUnuploadedImages.value) {
  563. ElMessage.warning("请等待图片上传完成后再提交");
  564. return;
  565. }
  566. if (fileList.value.length === 0) {
  567. ElMessage.warning("请先上传图片");
  568. return;
  569. }
  570. const uploadedFiles = fileList.value.filter(file => file.status === "success");
  571. if (uploadedFiles.length === 0) {
  572. ElMessage.warning("请先上传图片");
  573. return;
  574. }
  575. try {
  576. // 只提交单张图片,排序为0
  577. const imageDataWithSort = uploadedFiles.map((file, index) => ({
  578. imgUrl: file.url,
  579. imgSort: index,
  580. storeId: localGet("createdId")
  581. }));
  582. await submitFoodLicenseReview(imageDataWithSort[0]);
  583. ElMessage.success("提交审核成功");
  584. replaceDialogVisible.value = false;
  585. fileList.value = [];
  586. imageUrlList.value = [];
  587. pendingUploadFiles.value = [];
  588. uploading.value = false;
  589. await initData();
  590. } catch (error) {
  591. ElMessage.error("提交审核失败");
  592. }
  593. };
  594. const getStatusClass = (status: string) => {
  595. const statusInfo = statusMap[status];
  596. return statusInfo ? statusInfo.class : "";
  597. };
  598. const getStatusText = (status: string) => {
  599. const map: Record<string, string> = {
  600. pending: "审核中",
  601. success: "审核通过",
  602. failed: "审核拒绝"
  603. };
  604. return map[status] || "未知";
  605. };
  606. </script>
  607. <style lang="scss" scoped>
  608. .page-header {
  609. margin-bottom: 20px;
  610. }
  611. .store-title {
  612. margin: 0;
  613. font-size: 24px;
  614. font-weight: 600;
  615. color: var(--el-text-color-primary);
  616. }
  617. .content-section {
  618. display: flex;
  619. align-items: center;
  620. justify-content: space-between;
  621. width: 100%;
  622. margin-top: 20px;
  623. margin-bottom: 50px;
  624. }
  625. .tip-text {
  626. font-size: 18px;
  627. color: var(--el-text-color-regular);
  628. }
  629. .action-buttons {
  630. display: flex;
  631. flex-shrink: 0;
  632. gap: 10px;
  633. }
  634. .license-container {
  635. padding: 20px;
  636. background-color: var(--el-bg-color-page);
  637. border-radius: 8px;
  638. }
  639. .license-display {
  640. display: flex;
  641. align-items: center;
  642. justify-content: center;
  643. width: 700px;
  644. height: 500px;
  645. }
  646. .license-image {
  647. width: 100%;
  648. height: 100%;
  649. border-radius: 8px;
  650. box-shadow: 0 2px 12px rgb(0 0 0 / 10%);
  651. }
  652. .empty-image-box {
  653. display: flex;
  654. align-items: center;
  655. justify-content: center;
  656. width: 100%;
  657. height: 100%;
  658. background-color: var(--el-fill-color-lighter);
  659. border-radius: 8px;
  660. .empty-icon {
  661. font-size: 64px;
  662. color: var(--el-text-color-placeholder);
  663. }
  664. }
  665. .empty-license {
  666. display: flex;
  667. align-items: center;
  668. justify-content: center;
  669. min-height: 570px;
  670. padding: 40px 20px;
  671. }
  672. .replace-upload-area {
  673. .upload-tip {
  674. margin-bottom: 10px;
  675. }
  676. min-height: 300px;
  677. // padding: 20px;
  678. :deep(.el-upload-list--picture-card .el-upload-list__item:hover .el-upload-list__item-status-label) {
  679. display: inline-flex !important;
  680. opacity: 1 !important;
  681. }
  682. :deep(.el-upload-list__item.is-success:focus .el-upload-list__item-status-label) {
  683. display: inline-flex !important;
  684. opacity: 1 !important;
  685. }
  686. :deep(.el-upload-list--picture-card .el-icon--close-tip) {
  687. display: none !important;
  688. }
  689. &.upload-full {
  690. :deep(.el-upload--picture-card) {
  691. display: none !important;
  692. }
  693. }
  694. }
  695. .dialog-footer {
  696. display: flex;
  697. gap: 10px;
  698. justify-content: center;
  699. }
  700. /* el-upload 图片预览铺满容器 */
  701. :deep(.el-upload-list--picture-card) {
  702. .el-upload-list__item {
  703. overflow: hidden;
  704. .el-upload-list__item-thumbnail {
  705. width: 100%;
  706. height: 100%;
  707. object-fit: fill;
  708. }
  709. }
  710. /* 排队中(未上传)的图片禁用样式 */
  711. .el-upload-list__item[data-status="ready"],
  712. .el-upload-list__item.is-ready {
  713. position: relative;
  714. pointer-events: none;
  715. cursor: not-allowed;
  716. opacity: 0.6;
  717. &::after {
  718. position: absolute;
  719. inset: 0;
  720. z-index: 1;
  721. content: "";
  722. background-color: rgb(0 0 0 / 30%);
  723. }
  724. .el-upload-list__item-actions {
  725. pointer-events: none;
  726. opacity: 0.5;
  727. }
  728. }
  729. }
  730. .upload-trigger-card {
  731. display: flex;
  732. flex-direction: column;
  733. align-items: center;
  734. justify-content: center;
  735. width: 100%;
  736. height: 100%;
  737. font-size: 28px;
  738. color: #8c939d;
  739. .upload-tip {
  740. margin-top: 8px;
  741. font-size: 14px;
  742. color: #8c939d;
  743. }
  744. }
  745. .change-record-scrollbar {
  746. :deep(.el-scrollbar__wrap) {
  747. overflow-x: hidden;
  748. }
  749. }
  750. .change-record-content {
  751. .record-group {
  752. padding: 20px;
  753. margin-bottom: 30px;
  754. background-color: var(--el-fill-color-lighter);
  755. &:last-child {
  756. margin-bottom: 0;
  757. }
  758. .record-date {
  759. margin-bottom: 15px;
  760. font-size: 16px;
  761. font-weight: 500;
  762. color: var(--el-text-color-primary);
  763. }
  764. .record-items {
  765. display: flex;
  766. flex-wrap: wrap;
  767. gap: 15px;
  768. }
  769. .record-item {
  770. position: relative;
  771. width: 150px;
  772. height: 150px;
  773. overflow: hidden;
  774. border-radius: 8px;
  775. .record-status-badge {
  776. position: absolute;
  777. right: 0;
  778. bottom: 0;
  779. left: 0;
  780. z-index: 1;
  781. padding: 4px 8px;
  782. font-size: 12px;
  783. font-weight: 500;
  784. text-align: center;
  785. border-radius: 0 0 8px 8px;
  786. &.status-pending {
  787. color: #e6a23c;
  788. background-color: rgb(253 246 236 / 90%);
  789. border-top: 1px solid #e6a23c;
  790. }
  791. &.status-success {
  792. color: #67c23a;
  793. background-color: rgb(240 249 255 / 90%);
  794. border-top: 1px solid #67c23a;
  795. }
  796. &.status-failed {
  797. color: #f56c6c;
  798. background-color: rgb(254 240 240 / 90%);
  799. border-top: 1px solid #f56c6c;
  800. }
  801. }
  802. .record-image {
  803. width: 100%;
  804. height: 100%;
  805. .image-slot {
  806. display: flex;
  807. align-items: center;
  808. justify-content: center;
  809. width: 100%;
  810. height: 100%;
  811. font-size: 30px;
  812. color: var(--el-text-color-placeholder);
  813. background: var(--el-fill-color-light);
  814. }
  815. }
  816. }
  817. .rejection-reason {
  818. margin-top: 15px;
  819. font-size: 14px;
  820. font-weight: 500;
  821. color: var(--el-text-color-regular);
  822. border-radius: 8px;
  823. }
  824. }
  825. }
  826. .empty-record {
  827. display: flex;
  828. align-items: center;
  829. justify-content: center;
  830. min-height: 300px;
  831. padding: 40px 20px;
  832. }
  833. </style>