index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. <template>
  2. <div class="dataVisualize-box">
  3. <div class="card top-box">
  4. <div class="top-title">工作台</div>
  5. <div class="top-content">
  6. <div class="item-center">
  7. <div class="gitee-traffic traffic-box">
  8. <div class="traffic-img">
  9. <img src="./images/add_person.png" alt="" />
  10. </div>
  11. <span class="item-value">{{ auditSums["店铺入驻"] || 0 }}</span>
  12. <span class="traffic-name sle">待审核商铺</span>
  13. </div>
  14. <div class="today-traffic traffic-box">
  15. <div class="traffic-img">
  16. <img src="./images/today.png" alt="" />
  17. </div>
  18. <span class="item-value">{{ auditSums["商家申诉"] || 0 }}</span>
  19. <span class="traffic-name sle">待审核商家申诉</span>
  20. </div>
  21. <div class="yesterday-traffic traffic-box">
  22. <div class="traffic-img">
  23. <img src="./images/book_sum.png" alt="" />
  24. </div>
  25. <span class="item-value">{{ auditSums["套餐"] || 0 }}</span>
  26. <span class="traffic-name sle">待审核套餐</span>
  27. </div>
  28. <div class="gitHub-traffic traffic-box">
  29. <div class="traffic-img">
  30. <img src="./images/add_team.png" alt="" />
  31. </div>
  32. <span class="item-value">{{ auditSums["代金券"] || 0 }}</span>
  33. <span class="traffic-name sle">代金券审核</span>
  34. </div>
  35. <div class="yesterday-traffic traffic-box">
  36. <div class="traffic-img">
  37. <img src="./images/book_sum.png" alt="" />
  38. </div>
  39. <span class="item-value">{{ auditSums["经营许可证"] || 0 }}</span>
  40. <span class="traffic-name sle">待食品许可证审批</span>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="card top-box">
  46. <el-tabs v-model="tabActive" class="demo-tabs">
  47. <el-tab-pane v-for="item in tab" :key="item.name" :label="item.label" :name="item.name" />
  48. </el-tabs>
  49. <div class="card top-box">
  50. <el-table :data="tableData" height="250">
  51. <el-table-column type="index" label="序号" width="80" />
  52. <el-table-column prop="content" label="内容" />
  53. <el-table-column prop="type" label="类型" />
  54. <el-table-column prop="createdTime" label="提交时间" />
  55. <el-table-column prop="status" label="状态" />
  56. <el-table-column label="操作" fixed="right" width="120">
  57. <template #default="scope">
  58. <el-button type="primary" link @click="handleAudit(scope.row)"> 通过 </el-button>
  59. <el-button type="primary" link @click="handleAudit2(scope.row)"> 拒绝 </el-button>
  60. </template>
  61. </el-table-column>
  62. </el-table>
  63. </div>
  64. <!-- 分页组件 -->
  65. <div class="pagination-container">
  66. <el-pagination
  67. v-if="total > 0"
  68. :current-page="currentPage"
  69. :page-size="pageSize"
  70. :total="total"
  71. :page-sizes="[5, 10, 15, 20]"
  72. @current-change="handlePageChange"
  73. @size-change="handleSizeChange"
  74. background
  75. layout="total, sizes, prev, pager, next, jumper"
  76. />
  77. </div>
  78. </div>
  79. <!-- 拒接弹出框 -->
  80. <el-dialog v-model="dialogFormVisible" title="审核拒接" width="500">
  81. <el-form :model="form">
  82. <el-form-item>
  83. <el-input v-model="form.reason" autocomplete="off" style="width: 500px" type="textarea" />
  84. </el-form-item>
  85. </el-form>
  86. <template #footer>
  87. <div class="dialog-footer">
  88. <el-button @click="dialogFormVisible = false"> 取消 </el-button>
  89. <el-button type="primary" @click="handleOk"> 确定 </el-button>
  90. </div>
  91. </template>
  92. </el-dialog>
  93. </div>
  94. </template>
  95. <script setup lang="tsx" name="useProTable">
  96. import { ref, reactive, onMounted, onActivated, watch } from "vue";
  97. import { useRoute, useRouter } from "vue-router";
  98. import { Audit } from "@/api/interface";
  99. import { ElMessage, ElMessageBox } from "element-plus";
  100. import { getAuditList, getAuditSum } from "@/api/modules/audit";
  101. import { approveStoreInfo } from "@/api/modules/groupPackageManagement";
  102. import { consentComplaintFun, rejectClaimFun } from "@/api/modules/storeCommentAppeal";
  103. import { updateStatus } from "@/api/modules/groupPackage";
  104. import { changeStatus } from "@/api/modules/groupPackage";
  105. import { updatefoodLicenceImageStatus } from "@/api/modules/groupPackageManagement";
  106. const dialogFormVisible = ref(false);
  107. const router = useRouter();
  108. const tabActive = ref(1);
  109. const form = ref({
  110. reason: ""
  111. });
  112. // 分页相关响应式数据
  113. const currentPage = ref(1);
  114. const pageSize = ref(10);
  115. const total = ref(0);
  116. const route = useRoute();
  117. const tab = [
  118. { label: "商铺入驻", name: 1, type: "1" },
  119. { label: "审核商家申诉", name: 4, type: "3" },
  120. { label: "审核套餐", name: 5, type: "4" },
  121. { label: "代金券审核", name: 7, type: "6" },
  122. // { label: "审核活动", name: 6, type: "5" }
  123. { label: "食品许可证审批", name: 8, type: "7" }
  124. ];
  125. const tableData = ref<any[]>([]);
  126. const auditSums = ref<{
  127. [key: string]: number;
  128. }>({});
  129. // 封装参数处理函数
  130. const processParams = (params: any) => {
  131. let newParams = JSON.parse(JSON.stringify(params));
  132. delete newParams.createTime;
  133. delete newParams.pageNum;
  134. delete newParams.pageSize;
  135. newParams.status = newParams.status || "";
  136. newParams.type = newParams.type || "";
  137. newParams.page = newParams.page || 1;
  138. newParams.size = newParams.size || 10;
  139. newParams.classBigType = newParams.classBigType || "";
  140. newParams.classTeacher = newParams.classTeacher || "";
  141. newParams.className = newParams.className || "";
  142. return newParams;
  143. };
  144. const getTableList = async (params: any) => {
  145. const newParams = processParams(params);
  146. try {
  147. const res = await getAuditList(newParams);
  148. return res;
  149. } catch (error) {
  150. console.error("getTableList - 获取审核列表失败:", error);
  151. return { records: [], total: 0 };
  152. }
  153. };
  154. // 统一数据加载方法
  155. const loadData = async () => {
  156. try {
  157. // 获取当前标签页的类型
  158. const currentTab = tab.find(item => item.name === tabActive.value);
  159. const type = currentTab ? currentTab.type : "1";
  160. const res = await getTableList({
  161. page: currentPage.value,
  162. size: pageSize.value,
  163. type: type
  164. });
  165. // 检查响应数据格式
  166. if (res.data && res.data.current && res.data.size && res.data.total) {
  167. // 更新分页数据
  168. currentPage.value = res.data.current;
  169. pageSize.value = res.data.size;
  170. total.value = res.data.total;
  171. // 更新表格数据
  172. tableData.value = res.data.records || [];
  173. } else {
  174. console.error("loadData - 响应数据格式不正确:", res);
  175. tableData.value = [];
  176. total.value = 0;
  177. }
  178. } catch (error) {
  179. console.error("loadData - 获取审核列表失败:", error);
  180. tableData.value = [];
  181. total.value = 0;
  182. }
  183. };
  184. // 页码变化处理
  185. const handlePageChange = (newPage: number) => {
  186. currentPage.value = newPage;
  187. loadData();
  188. };
  189. // 每页数量变化处理
  190. const handleSizeChange = (newSize: number) => {
  191. pageSize.value = newSize;
  192. currentPage.value = 1;
  193. loadData();
  194. };
  195. const getTobList = async () => {
  196. try {
  197. // 初始化所有类型为0
  198. auditSums.value = {
  199. 店铺入驻: 0,
  200. 商家申诉: 0,
  201. 套餐: 0,
  202. 代金券: 0,
  203. 食品许可证审批: 0
  204. };
  205. const resp = await getAuditSum({});
  206. // 检查响应数据格式
  207. if (resp.code === 200 && resp.data) {
  208. resp.data.forEach(item => {
  209. const type = item.type;
  210. const typeSum = parseInt(item.typeSum, 10);
  211. auditSums.value[type] = typeSum;
  212. });
  213. } else {
  214. console.error("getTobList - 响应数据格式不正确:", resp);
  215. ElMessage.error("获取审核统计数据失败,响应数据格式不正确");
  216. }
  217. return resp;
  218. } catch (error) {}
  219. };
  220. // 审核通过操作
  221. const handleAudit = (row: any) => {
  222. ElMessageBox.confirm("确定要通过该审核吗?", "审核确认", {
  223. confirmButtonText: "确定",
  224. cancelButtonText: "取消",
  225. type: "warning"
  226. })
  227. .then(() => {
  228. // 同意
  229. // 商铺入驻
  230. if (tabActive.value == 1) {
  231. approveStoreInfo({
  232. id: row.storeInfoId,
  233. approvalStatus: 1
  234. }).then(res => {
  235. if (res.code === 200) {
  236. ElMessage.success("审核通过成功");
  237. loadData();
  238. getTobList();
  239. }
  240. });
  241. } else if (tabActive.value == 4) {
  242. // 审核商家申诉
  243. consentComplaintFun({
  244. id: row.storeCommentAppealId,
  245. appealStatus: "2"
  246. }).then(res => {
  247. if (res.code === 200) {
  248. ElMessage.success("审核通过成功");
  249. loadData();
  250. getTobList();
  251. }
  252. });
  253. } else if (tabActive.value == 5) {
  254. // 审核套餐
  255. updateStatus({
  256. id: row.lifeGroupPackageId,
  257. status: 2,
  258. approvalComments: ""
  259. }).then(res => {
  260. if (res.code === 200) {
  261. ElMessage.success("审核通过成功");
  262. loadData();
  263. getTobList();
  264. }
  265. });
  266. } else if (tabActive.value == 7) {
  267. // 代金券审核
  268. changeStatus({
  269. id: row.couponId,
  270. status: 5,
  271. comment: "",
  272. type: 1
  273. }).then(res => {
  274. if (res.code === 200) {
  275. ElMessage.success("审核通过成功");
  276. loadData();
  277. getTobList();
  278. }
  279. });
  280. } else if (tabActive.value == 8) {
  281. // 许可证审核
  282. updatefoodLicenceImageStatus({
  283. id: row.storeInfoId,
  284. foodLicenceStatus: 1,
  285. foodLicenceReason: ""
  286. }).then(res => {
  287. if (res.code === 200) {
  288. ElMessage.success("审核通过成功");
  289. loadData();
  290. getTobList();
  291. }
  292. });
  293. }
  294. })
  295. .catch(() => {
  296. ElMessage.info("已取消操作");
  297. });
  298. };
  299. const rowValue = ref({});
  300. // 驳回操作
  301. const handleOk = () => {
  302. if (form.value.reason) {
  303. dialogFormVisible.value = false;
  304. if (tabActive.value == 1) {
  305. approveStoreInfo({
  306. id: rowValue.value.storeInfoId,
  307. approvalStatus: 2,
  308. reason: form.value.reason
  309. }).then(res => {
  310. if (res.code === 200) {
  311. handleCs();
  312. loadData();
  313. getTobList();
  314. }
  315. });
  316. } else if (tabActive.value == 4) {
  317. // 审核商家申诉
  318. rejectClaimFun({
  319. id: rowValue.value.storeCommentAppealId,
  320. appealStatus: "1",
  321. logRemark: form.value.reason
  322. }).then(res => {
  323. if (res.code === 200) {
  324. handleCs();
  325. loadData();
  326. getTobList();
  327. }
  328. });
  329. } else if (tabActive.value == 5) {
  330. // 审核套餐
  331. updateStatus({
  332. id: rowValue.value.lifeGroupPackageId,
  333. status: 3,
  334. approvalComments: form.value.reason
  335. }).then(res => {
  336. if (res.code === 200) {
  337. handleCs();
  338. loadData();
  339. getTobList();
  340. }
  341. });
  342. } else if (tabActive.value == 7) {
  343. // 代金券审核
  344. changeStatus({
  345. id: rowValue.value.couponId,
  346. status: 3,
  347. comment: form.value.reason,
  348. type: 1
  349. }).then(res => {
  350. if (res.code === 200) {
  351. handleCs();
  352. loadData();
  353. getTobList();
  354. }
  355. });
  356. } else if (tabActive.value == 8) {
  357. // 许可证审核
  358. updatefoodLicenceImageStatus({
  359. id: rowValue.value.storeInfoId,
  360. foodLicenceStatus: 3,
  361. foodLicenceReason: form.value.reason
  362. }).then(res => {
  363. if (res.code === 200) {
  364. ElMessage.success("审核通过成功");
  365. loadData();
  366. getTobList();
  367. }
  368. });
  369. }
  370. } else {
  371. ElMessage.error("请填写审核拒绝原因!");
  372. }
  373. };
  374. const handleCs = () => {
  375. ElMessage.success("审核拒接成功!");
  376. form.value.reason = "";
  377. };
  378. // 审核拒绝操作
  379. const handleAudit2 = (row: any) => {
  380. rowValue.value = row;
  381. dialogFormVisible.value = true;
  382. };
  383. // 监听 tabActive 变化
  384. watch(tabActive, async (newVal, oldVal) => {
  385. if (newVal !== oldVal) {
  386. // 重置分页状态
  387. currentPage.value = 1;
  388. total.value = 0;
  389. // 加载新数据
  390. getTobList();
  391. await loadData();
  392. }
  393. });
  394. // 页面加载时触发查询
  395. onMounted(async () => {
  396. await loadData();
  397. await getTobList();
  398. });
  399. // 从其他页面返回时触发查询
  400. onActivated(async () => {
  401. await loadData();
  402. });
  403. // 表格配置项
  404. const columns = reactive<ColumnProps<Audit.ResAuditList>[]>([
  405. { prop: "index", label: "序号", type: "index", width: 100 },
  406. { prop: "content", label: "内容", search: { el: "input" } },
  407. { prop: "type", label: "类型" },
  408. { prop: "createdTime", label: "提交时间" },
  409. { prop: "status", label: "状态" },
  410. { prop: "operation", label: "操作", fixed: "right", width: 120 }
  411. ]);
  412. </script>
  413. <style scoped lang="scss">
  414. @import "./index";
  415. .pagination-container {
  416. display: flex;
  417. justify-content: flex-end;
  418. padding: 20px;
  419. }
  420. </style>