index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774
  1. <template>
  2. <div class="p-2 factory-visit-page">
  3. <!-- 搜索区域 -->
  4. <transition
  5. :enter-active-class="proxy?.animate.searchAnimate.enter"
  6. :leave-active-class="proxy?.animate.searchAnimate.leave"
  7. >
  8. <div v-show="showSearch" class="mb-[10px]">
  9. <el-card shadow="hover">
  10. <el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="auto">
  11. <el-form-item label="访厂ID" prop="visitCode">
  12. <el-input
  13. v-model="queryParams.visitCode"
  14. placeholder="请输入访厂ID"
  15. clearable
  16. style="width: 180px"
  17. @keyup.enter="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="公司名称" prop="companyName">
  21. <el-input
  22. v-model="queryParams.companyName"
  23. placeholder="请输入公司名称"
  24. clearable
  25. style="width: 180px"
  26. @keyup.enter="handleQuery"
  27. />
  28. </el-form-item>
  29. <el-form-item label="状态" prop="status">
  30. <el-select v-model="queryParams.status" placeholder="全部" clearable style="width: 160px">
  31. <el-option
  32. v-for="dict in visit_status_dict"
  33. :key="dict.value"
  34. :label="dict.label"
  35. :value="dict.value"
  36. />
  37. </el-select>
  38. </el-form-item>
  39. <el-form-item label="审核结论" prop="auditResult">
  40. <el-select
  41. v-model="queryParams.auditResult"
  42. placeholder="全部"
  43. clearable
  44. style="width: 160px"
  45. >
  46. <el-option
  47. v-for="dict in visit_audit_result_dict"
  48. :key="dict.value"
  49. :label="dict.label"
  50. :value="dict.value"
  51. />
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item label="访厂日期" prop="dateRange">
  55. <el-date-picker
  56. v-model="dateRange"
  57. value-format="YYYY-MM-DD"
  58. type="daterange"
  59. range-separator="-"
  60. start-placeholder="开始日期"
  61. end-placeholder="结束日期"
  62. style="width: 240px"
  63. />
  64. </el-form-item>
  65. <el-form-item>
  66. <el-button type="primary" icon="Search" @click="handleQuery">查询</el-button>
  67. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  68. </el-form-item>
  69. </el-form>
  70. </el-card>
  71. </div>
  72. </transition>
  73. <!-- 数据表格区域 -->
  74. <el-card shadow="hover">
  75. <template #header>
  76. <el-row :gutter="10" class="mb-2">
  77. <el-col :span="1.5">
  78. <el-button
  79. v-hasPermi="['risk:factoryVisit:add']"
  80. type="primary"
  81. plain
  82. icon="Plus"
  83. @click="handleAdd"
  84. >新增访厂任务</el-button
  85. >
  86. </el-col>
  87. <el-col :span="1.5">
  88. <el-button
  89. v-hasPermi="['risk:factoryVisit:export']"
  90. type="warning"
  91. plain
  92. icon="Download"
  93. @click="handleExport"
  94. >导出</el-button
  95. >
  96. </el-col>
  97. <right-toolbar v-model:show-search="showSearch" @query-table="getList" />
  98. </el-row>
  99. </template>
  100. <el-table v-loading="loading" :data="visitList" border>
  101. <el-table-column label="访厂ID" align="center" prop="visitCode" width="150" />
  102. <el-table-column
  103. label="公司名称"
  104. align="center"
  105. prop="companyName"
  106. :show-overflow-tooltip="true"
  107. />
  108. <el-table-column
  109. label="地址"
  110. align="center"
  111. prop="companyAddress"
  112. width="180"
  113. :show-overflow-tooltip="true"
  114. />
  115. <el-table-column label="访厂日期" align="center" prop="visitDate" width="120">
  116. <template #default="scope">
  117. <span>{{ parseDate(scope.row.visitDate) }}</span>
  118. </template>
  119. </el-table-column>
  120. <el-table-column label="访查实际得分" align="center" prop="totalScore" width="120">
  121. <template #default="scope">
  122. <span v-if="scope.row.totalScore != null">{{ scope.row.totalScore }}</span>
  123. <span v-else>-</span>
  124. </template>
  125. </el-table-column>
  126. <el-table-column label="审核结论" align="center" prop="auditResult" width="100">
  127. <template #default="scope">
  128. <el-tag v-if="scope.row.auditResult" :type="getAuditResultTag(scope.row.auditResult)">{{
  129. scope.row.auditResult
  130. }}</el-tag>
  131. <span v-else>-</span>
  132. </template>
  133. </el-table-column>
  134. <el-table-column label="访查人" align="center" prop="visitorName" width="100" />
  135. <el-table-column
  136. label="审核产品范围"
  137. align="center"
  138. prop="productScope"
  139. width="160"
  140. :show-overflow-tooltip="true"
  141. />
  142. <el-table-column label="审核部门" align="center" prop="auditDept" width="120" />
  143. <el-table-column label="评审人" align="center" prop="reviewerName" width="100" />
  144. <el-table-column label="状态" align="center" prop="status" width="100">
  145. <template #default="scope">
  146. <el-tag :type="getStatusTag(scope.row.status)">{{ scope.row.status }}</el-tag>
  147. </template>
  148. </el-table-column>
  149. <el-table-column
  150. label="操作"
  151. fixed="right"
  152. align="center"
  153. width="240"
  154. class-name="small-padding fixed-width"
  155. >
  156. <template #default="scope">
  157. <el-button
  158. v-hasPermi="['risk:factoryVisit:list']"
  159. link
  160. type="primary"
  161. icon="Document"
  162. @click="handleView(scope.row)"
  163. >查看详情</el-button
  164. >
  165. <el-button
  166. v-if="scope.row.status === '待访厂'"
  167. v-hasPermi="['risk:factoryVisit:report']"
  168. link
  169. type="primary"
  170. icon="EditPen"
  171. @click="handleFillReport(scope.row)"
  172. >填写报告</el-button
  173. >
  174. <el-button
  175. v-if="scope.row.status === '待审核'"
  176. v-hasPermi="['risk:factoryVisit:audit']"
  177. link
  178. type="primary"
  179. icon="CircleCheck"
  180. @click="handleAudit(scope.row)"
  181. >审核</el-button
  182. >
  183. <el-button
  184. v-if="scope.row.status === '待访厂'"
  185. v-hasPermi="['risk:factoryVisit:edit']"
  186. link
  187. type="primary"
  188. icon="Edit"
  189. @click="handleUpdate(scope.row)"
  190. >编辑</el-button
  191. >
  192. <el-button
  193. v-if="scope.row.status === '待访厂'"
  194. v-hasPermi="['risk:factoryVisit:remove']"
  195. link
  196. type="danger"
  197. icon="Delete"
  198. @click="handleDelete(scope.row)"
  199. >删除</el-button
  200. >
  201. </template>
  202. </el-table-column>
  203. </el-table>
  204. <pagination
  205. v-show="total > 0"
  206. v-model:page="queryParams.pageNum"
  207. v-model:limit="queryParams.pageSize"
  208. :total="total"
  209. @pagination="getList"
  210. />
  211. </el-card>
  212. <!-- 新增/编辑对话框 -->
  213. <el-dialog
  214. v-model="dialog.visible"
  215. :title="dialog.title"
  216. width="780px"
  217. append-to-body
  218. @close="closeDialog"
  219. >
  220. <el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
  221. <el-row :gutter="20">
  222. <el-col :span="12">
  223. <el-form-item label="公司名称" prop="companyName">
  224. <el-input v-model="form.companyName" placeholder="请输入被访厂商名称" maxlength="200" />
  225. </el-form-item>
  226. </el-col>
  227. <el-col :span="12">
  228. <el-form-item label="审核部门" prop="auditDept">
  229. <el-input v-model="form.auditDept" placeholder="请输入审核部门" maxlength="100" />
  230. </el-form-item>
  231. </el-col>
  232. </el-row>
  233. <el-row :gutter="20">
  234. <el-col :span="24">
  235. <el-form-item label="厂商地址" prop="companyAddress">
  236. <el-input
  237. v-model="form.companyAddress"
  238. placeholder="请输入厂商地址"
  239. maxlength="500"
  240. />
  241. </el-form-item>
  242. </el-col>
  243. </el-row>
  244. <el-row :gutter="20">
  245. <el-col :span="12">
  246. <el-form-item label="访厂日期" prop="visitDate">
  247. <el-date-picker
  248. v-model="form.visitDate"
  249. type="date"
  250. value-format="YYYY-MM-DD"
  251. placeholder="请选择访厂日期"
  252. style="width: 100%"
  253. />
  254. </el-form-item>
  255. </el-col>
  256. <el-col :span="12">
  257. <el-form-item label="访查人" prop="visitorName">
  258. <el-input
  259. v-model="form.visitorName"
  260. placeholder="请输入访查人"
  261. maxlength="50"
  262. />
  263. </el-form-item>
  264. </el-col>
  265. </el-row>
  266. <el-row :gutter="20">
  267. <el-col :span="12">
  268. <el-form-item label="评审人" prop="reviewerName">
  269. <el-input
  270. v-model="form.reviewerName"
  271. placeholder="请输入评审人"
  272. maxlength="50"
  273. />
  274. </el-form-item>
  275. </el-col>
  276. <el-col :span="12">
  277. <el-form-item label="审核产品范围" prop="productScope">
  278. <el-input
  279. v-model="form.productScope"
  280. placeholder="如:烘焙类、冷链食品等"
  281. maxlength="200"
  282. />
  283. </el-form-item>
  284. </el-col>
  285. </el-row>
  286. <el-form-item label="备注" prop="remark">
  287. <el-input
  288. v-model="form.remark"
  289. type="textarea"
  290. :rows="3"
  291. placeholder="请输入备注"
  292. maxlength="1000"
  293. />
  294. </el-form-item>
  295. </el-form>
  296. <template #footer>
  297. <el-button @click="cancel">取 消</el-button>
  298. <el-button type="primary" :loading="submitLoading" @click="submitForm">确 定</el-button>
  299. </template>
  300. </el-dialog>
  301. <!-- 查看详情对话框 -->
  302. <el-dialog v-model="viewDialog.visible" title="访厂详情" width="900px" append-to-body>
  303. <el-descriptions v-if="viewDialog.data" :column="2" border>
  304. <el-descriptions-item label="访厂ID">{{
  305. viewDialog.data.visitCode
  306. }}</el-descriptions-item>
  307. <el-descriptions-item label="状态">
  308. <el-tag :type="getStatusTag(viewDialog.data.status)">{{ viewDialog.data.status }}</el-tag>
  309. </el-descriptions-item>
  310. <el-descriptions-item label="公司名称">{{
  311. viewDialog.data.companyName
  312. }}</el-descriptions-item>
  313. <el-descriptions-item label="审核部门">{{
  314. viewDialog.data.auditDept || '-'
  315. }}</el-descriptions-item>
  316. <el-descriptions-item label="地址" :span="2">{{
  317. viewDialog.data.companyAddress || '-'
  318. }}</el-descriptions-item>
  319. <el-descriptions-item label="访厂日期">{{
  320. parseDate(viewDialog.data.visitDate)
  321. }}</el-descriptions-item>
  322. <el-descriptions-item label="访查人">{{
  323. viewDialog.data.visitorName || '-'
  324. }}</el-descriptions-item>
  325. <el-descriptions-item label="评审人">{{
  326. viewDialog.data.reviewerName || '-'
  327. }}</el-descriptions-item>
  328. <el-descriptions-item label="审核产品范围">{{
  329. viewDialog.data.productScope || '-'
  330. }}</el-descriptions-item>
  331. <el-descriptions-item label="访查实际得分">{{
  332. viewDialog.data.totalScore ?? '-'
  333. }}</el-descriptions-item>
  334. <el-descriptions-item label="审核结论">
  335. <el-tag
  336. v-if="viewDialog.data.auditResult"
  337. :type="getAuditResultTag(viewDialog.data.auditResult)"
  338. >{{ viewDialog.data.auditResult }}</el-tag
  339. >
  340. <span v-else>-</span>
  341. </el-descriptions-item>
  342. <el-descriptions-item label="审核人">{{
  343. viewDialog.data.auditorName || '-'
  344. }}</el-descriptions-item>
  345. <el-descriptions-item label="审核时间">{{
  346. parseDateTime(viewDialog.data.auditTime)
  347. }}</el-descriptions-item>
  348. <el-descriptions-item label="审核意见" :span="2">{{
  349. viewDialog.data.auditRemark || '-'
  350. }}</el-descriptions-item>
  351. <el-descriptions-item label="备注" :span="2">{{
  352. viewDialog.data.remark || '-'
  353. }}</el-descriptions-item>
  354. </el-descriptions>
  355. <!-- 报告子表(已审核时也可查看) -->
  356. <div v-if="viewDialog.data?.report" class="mt-4">
  357. <el-divider content-position="left">访厂报告</el-divider>
  358. <el-tabs v-model="activeReportTab" type="border-card">
  359. <el-tab-pane label="基础信息" name="basic">
  360. <pre class="report-json">{{
  361. formatJson(viewDialog.data.report.basicEvaluate)
  362. }}</pre>
  363. </el-tab-pane>
  364. <el-tab-pane label="ESG 评分" name="esg">
  365. <pre class="report-json">{{ formatJson(viewDialog.data.report.esgScore) }}</pre>
  366. </el-tab-pane>
  367. <el-tab-pane label="GMP 评分" name="gmp">
  368. <pre class="report-json">{{ formatJson(viewDialog.data.report.gmpScore) }}</pre>
  369. </el-tab-pane>
  370. <el-tab-pane label="ISO14001" name="iso14001">
  371. <pre class="report-json">{{
  372. formatJson(viewDialog.data.report.iso14001Score)
  373. }}</pre>
  374. </el-tab-pane>
  375. <el-tab-pane label="ISO45001" name="iso45001">
  376. <pre class="report-json">{{
  377. formatJson(viewDialog.data.report.iso45001Score)
  378. }}</pre>
  379. </el-tab-pane>
  380. <el-tab-pane label="ISO9001" name="iso9001">
  381. <pre class="report-json">{{
  382. formatJson(viewDialog.data.report.iso9001Score)
  383. }}</pre>
  384. </el-tab-pane>
  385. <el-tab-pane label="致敏原管控" name="allergen">
  386. <pre class="report-json">{{
  387. formatJson(viewDialog.data.report.allergenEvaluate)
  388. }}</pre>
  389. </el-tab-pane>
  390. <el-tab-pane label="问题汇总" name="summary">
  391. <div class="report-summary">{{ viewDialog.data.report.summary || '(空)' }}</div>
  392. </el-tab-pane>
  393. </el-tabs>
  394. </div>
  395. <template #footer>
  396. <el-button @click="viewDialog.visible = false">关 闭</el-button>
  397. </template>
  398. </el-dialog>
  399. <!-- 填写报告弹框 -->
  400. <ReportDialog
  401. v-if="reportDialog.visible"
  402. v-model:visible="reportDialog.visible"
  403. :visit="reportDialog.data"
  404. @success="onReportSuccess"
  405. />
  406. <!-- 审核弹框 -->
  407. <el-dialog
  408. v-model="auditDialog.visible"
  409. title="审核访厂任务"
  410. width="560px"
  411. append-to-body
  412. @close="closeAuditDialog"
  413. >
  414. <el-form ref="auditFormRef" :model="auditForm" :rules="auditRules" label-width="100px">
  415. <el-form-item label="访厂ID">
  416. <span>{{ auditDialog.data?.visitCode }}</span>
  417. </el-form-item>
  418. <el-form-item label="公司名称">
  419. <span>{{ auditDialog.data?.companyName }}</span>
  420. </el-form-item>
  421. <el-form-item label="状态">
  422. <el-tag :type="getStatusTag(auditDialog.data?.status)">{{
  423. auditDialog.data?.status
  424. }}</el-tag>
  425. </el-form-item>
  426. <el-form-item label="访查得分">
  427. <span>{{ auditDialog.data?.totalScore ?? '-' }}</span>
  428. </el-form-item>
  429. <el-form-item label="审核结论" prop="auditResult">
  430. <el-select
  431. v-model="auditForm.auditResult"
  432. placeholder="请选择审核结论"
  433. style="width: 100%"
  434. >
  435. <el-option
  436. v-for="dict in visit_audit_result_dict"
  437. :key="dict.value"
  438. :label="dict.label"
  439. :value="dict.value"
  440. />
  441. </el-select>
  442. </el-form-item>
  443. <el-form-item label="审核意见" prop="auditRemark">
  444. <el-input
  445. v-model="auditForm.auditRemark"
  446. type="textarea"
  447. :rows="4"
  448. placeholder="请输入审核意见"
  449. maxlength="1000"
  450. />
  451. </el-form-item>
  452. </el-form>
  453. <template #footer>
  454. <el-button @click="auditDialog.visible = false">取 消</el-button>
  455. <el-button type="primary" :loading="auditLoading" @click="submitAudit">确 定</el-button>
  456. </template>
  457. </el-dialog>
  458. </div>
  459. </template>
  460. <script setup lang="ts" name="FactoryVisit">
  461. import { ref, reactive, computed, getCurrentInstance, watch } from 'vue';
  462. import { ElMessage, ElMessageBox } from 'element-plus';
  463. import {
  464. listFactoryVisit,
  465. getFactoryVisit,
  466. addFactoryVisit,
  467. updateFactoryVisit,
  468. delFactoryVisit,
  469. exportFactoryVisit,
  470. auditFactoryVisit
  471. } from '@/api/risk/factoryVisit';
  472. import ReportDialog from './components/ReportDialog.vue';
  473. const { proxy } = getCurrentInstance() as any;
  474. // 字典
  475. const { visit_status_dict, visit_audit_result_dict } = proxy.useDict(
  476. 'visit_status',
  477. 'visit_audit_result'
  478. );
  479. const visitList = ref<any[]>([]);
  480. const loading = ref(false);
  481. const submitLoading = ref(false);
  482. const auditLoading = ref(false);
  483. const total = ref(0);
  484. const showSearch = ref(true);
  485. const dateRange = ref<[string, string] | null>(null);
  486. const activeReportTab = ref('basic');
  487. const queryParams = reactive({
  488. pageNum: 1,
  489. pageSize: 10,
  490. visitCode: undefined,
  491. companyName: undefined,
  492. status: undefined,
  493. auditResult: undefined,
  494. params: {}
  495. });
  496. const initialForm = {
  497. id: undefined,
  498. visitCode: undefined,
  499. companyName: undefined,
  500. companyAddress: undefined,
  501. visitDate: undefined,
  502. visitorName: undefined,
  503. auditDept: undefined,
  504. productScope: undefined,
  505. reviewerName: undefined,
  506. remark: undefined
  507. };
  508. const form = reactive({ ...initialForm });
  509. const rules = {
  510. companyName: [{ required: true, message: '公司名称不能为空', trigger: 'blur' }]
  511. };
  512. const dialog = reactive({
  513. visible: false,
  514. title: ''
  515. });
  516. const viewDialog = reactive({
  517. visible: false,
  518. data: null as any
  519. });
  520. const reportDialog = reactive({
  521. visible: false,
  522. data: null as any
  523. });
  524. const auditDialog = reactive({
  525. visible: false,
  526. data: null as any
  527. });
  528. const initialAuditForm = {
  529. id: undefined,
  530. auditResult: undefined,
  531. auditRemark: undefined
  532. };
  533. const auditForm = reactive({ ...initialAuditForm });
  534. const auditRules = {
  535. auditResult: [{ required: true, message: '请选择审核结论', trigger: 'change' }],
  536. auditRemark: [{ required: true, message: '请填写审核意见', trigger: 'blur' }]
  537. };
  538. watch(dateRange, (val) => {
  539. if (val && val.length === 2) {
  540. queryParams.params = { ...(queryParams.params || {}), beginVisitDate: val[0], endVisitDate: val[1] };
  541. } else {
  542. queryParams.params = { ...(queryParams.params || {}) };
  543. delete (queryParams.params as any).beginVisitDate;
  544. delete (queryParams.params as any).endVisitDate;
  545. }
  546. });
  547. // ============ 列表 ============
  548. const getList = async () => {
  549. loading.value = true;
  550. try {
  551. const res: any = await listFactoryVisit(queryParams);
  552. visitList.value = res.rows || [];
  553. total.value = res.total || 0;
  554. } finally {
  555. loading.value = false;
  556. }
  557. };
  558. const handleQuery = () => {
  559. queryParams.pageNum = 1;
  560. getList();
  561. };
  562. const resetQuery = () => {
  563. Object.assign(queryParams, {
  564. pageNum: 1,
  565. pageSize: 10,
  566. visitCode: undefined,
  567. companyName: undefined,
  568. status: undefined,
  569. auditResult: undefined,
  570. params: {}
  571. });
  572. dateRange.value = null;
  573. getList();
  574. };
  575. // ============ 新增/编辑 ============
  576. const handleAdd = () => {
  577. Object.assign(form, initialForm);
  578. dialog.title = '新增访厂任务';
  579. dialog.visible = true;
  580. };
  581. const handleUpdate = async (row: any) => {
  582. Object.assign(form, initialForm);
  583. const res: any = await getFactoryVisit(row.id);
  584. Object.assign(form, res.data || res);
  585. dialog.title = '编辑访厂任务';
  586. dialog.visible = true;
  587. };
  588. const submitForm = async () => {
  589. const formRef = proxy.$refs.formRef;
  590. await formRef.validate();
  591. submitLoading.value = true;
  592. try {
  593. if (form.id) {
  594. await updateFactoryVisit(form);
  595. ElMessage.success('修改成功');
  596. } else {
  597. await addFactoryVisit(form);
  598. ElMessage.success('新增成功');
  599. }
  600. dialog.visible = false;
  601. getList();
  602. } finally {
  603. submitLoading.value = false;
  604. }
  605. };
  606. const cancel = () => {
  607. dialog.visible = false;
  608. Object.assign(form, initialForm);
  609. };
  610. const closeDialog = () => {
  611. Object.assign(form, initialForm);
  612. };
  613. const handleDelete = async (row: any) => {
  614. await ElMessageBox.confirm(`确认删除访厂任务 "${row.visitCode}" ?`, '提示', {
  615. type: 'warning'
  616. });
  617. await delFactoryVisit(row.id);
  618. ElMessage.success('删除成功');
  619. getList();
  620. };
  621. // ============ 查看详情 ============
  622. const handleView = async (row: any) => {
  623. const res: any = await getFactoryVisit(row.id);
  624. viewDialog.data = res.data || res;
  625. viewDialog.visible = true;
  626. };
  627. // ============ 填写报告 ============
  628. const handleFillReport = async (row: any) => {
  629. const res: any = await getFactoryVisit(row.id);
  630. reportDialog.data = res.data || res;
  631. reportDialog.visible = true;
  632. };
  633. const onReportSuccess = () => {
  634. reportDialog.visible = false;
  635. getList();
  636. };
  637. // ============ 审核 ============
  638. const handleAudit = (row: any) => {
  639. Object.assign(auditForm, initialAuditForm);
  640. auditDialog.data = row;
  641. auditDialog.visible = true;
  642. };
  643. const submitAudit = async () => {
  644. const ref: any = proxy.$refs.auditFormRef;
  645. await ref.validate();
  646. auditLoading.value = true;
  647. try {
  648. await auditFactoryVisit({
  649. id: auditDialog.data.id,
  650. auditResult: auditForm.auditResult,
  651. auditRemark: auditForm.auditRemark
  652. });
  653. ElMessage.success('审核成功');
  654. auditDialog.visible = false;
  655. getList();
  656. } finally {
  657. auditLoading.value = false;
  658. }
  659. };
  660. const closeAuditDialog = () => {
  661. Object.assign(auditForm, initialAuditForm);
  662. };
  663. // ============ 导出 ============
  664. const handleExport = async () => {
  665. const res: any = await exportFactoryVisit(queryParams);
  666. proxy.download(res);
  667. };
  668. // ============ 辅助 ============
  669. const getAuditResultTag = (result?: string): 'success' | 'danger' | 'info' => {
  670. if (result === '通过') return 'success';
  671. if (result === '不通过') return 'danger';
  672. if (result === '待定') return 'info';
  673. return 'info';
  674. };
  675. const getStatusTag = (status?: string): 'warning' | 'primary' | 'success' | 'info' => {
  676. if (status === '待访厂') return 'warning';
  677. if (status === '待审核') return 'primary';
  678. if (status === '已审核') return 'success';
  679. return 'info';
  680. };
  681. const parseDate = (d?: string | Date) => {
  682. if (!d) return '-';
  683. const s = typeof d === 'string' ? d : d.toISOString();
  684. return s.substring(0, 10);
  685. };
  686. const parseDateTime = (d?: string | Date) => {
  687. if (!d) return '-';
  688. const s = typeof d === 'string' ? d : d.toISOString();
  689. return s.substring(0, 19).replace('T', ' ');
  690. };
  691. const formatJson = (data: any) => {
  692. if (!data) return '(空)';
  693. try {
  694. return JSON.stringify(data, null, 2);
  695. } catch {
  696. return String(data);
  697. }
  698. };
  699. getList();
  700. </script>
  701. <style scoped lang="scss">
  702. .factory-visit-page {
  703. .report-json {
  704. background: #f5f7fa;
  705. padding: 12px;
  706. border-radius: 4px;
  707. font-size: 13px;
  708. line-height: 1.6;
  709. max-height: 400px;
  710. overflow: auto;
  711. white-space: pre-wrap;
  712. word-break: break-all;
  713. }
  714. .report-summary {
  715. background: #f5f7fa;
  716. padding: 16px;
  717. border-radius: 4px;
  718. line-height: 1.8;
  719. min-height: 100px;
  720. white-space: pre-wrap;
  721. }
  722. }
  723. </style>