ManageBasicArchive.vue 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543
  1. <template>
  2. <section class="manage-page">
  3. <p class="breadcrumb">
  4. 数据管理 / <span>企业端 · 资产月度上报</span> / <span>{{ monthlySub === 'current' ? '本月上报清单' : '历史上报记录' }}</span>
  5. </p>
  6. <div class="page-header">
  7. <h2 class="page-title">月度资产上报</h2>
  8. </div>
  9. <div class="sub-tabs">
  10. <BaseButton
  11. text="本月上报清单"
  12. :class="{ 'nav-tab-item--active': monthlySub === 'current' }"
  13. @click="switchArchiveSub('current')"
  14. />
  15. <BaseButton
  16. text="历史上报记录"
  17. :class="{ 'nav-tab-item--active': monthlySub === 'history' }"
  18. @click="switchArchiveSub('history')"
  19. />
  20. </div>
  21. <template v-if="monthlySub === 'current'">
  22. <div class="period-panel">
  23. <div class="status-strip">
  24. <span>本账期 <strong>{{ currentPeriod }}</strong> · 截止 <strong>{{ periodDeadline }}</strong></span>
  25. <span class="status-tag" :class="`status-tag--${statusTagType}`">{{ statusTagLabel }}</span>
  26. </div>
  27. <div class="flow-stepper">
  28. <template v-for="(step, idx) in flowSteps" :key="step.key">
  29. <div
  30. v-if="idx > 0"
  31. class="flow-stepper__line"
  32. :class="{ 'flow-stepper__line--done': visualStepIndex >= idx }"
  33. />
  34. <div class="flow-stepper__node">
  35. <div class="flow-stepper__dot" :class="getDotClass(idx)" />
  36. <span class="flow-stepper__label">{{ step.label }}</span>
  37. </div>
  38. </template>
  39. </div>
  40. <p v-if="reportingPhase === 'pending'" class="period-notice">
  41. 本账期已提交/审核中,清单只读。通过或驳回后可重新编辑。
  42. </p>
  43. <p v-else-if="reportingPhase === 'passed'" class="period-notice">
  44. 本账期已通过审核,可继续编辑并重新提交。
  45. </p>
  46. <p v-else-if="reportingPhase === 'rejected'" class="period-notice period-notice--warn">
  47. 本账期已被驳回,请修改清单后重新提交。
  48. </p>
  49. </div>
  50. <div class="panel">
  51. <div class="panel-toolbar">
  52. <div class="panel-toolbar__left">
  53. <SectionHeader title="本月待上报资产清单" />
  54. </div>
  55. <div class="action-row">
  56. <BaseButton
  57. text="新增上报资产"
  58. variant="warning"
  59. :class="{ 'nav-tab-item--disabled': isReportLocked }"
  60. @click="!isReportLocked && (showPickModal = true)"
  61. />
  62. <BaseButton
  63. text="批量删除"
  64. variant="outline"
  65. :class="{ 'nav-tab-item--disabled': isReportLocked }"
  66. @click="handleBatchDelete"
  67. />
  68. <BaseButton
  69. text="清空清单"
  70. variant="outline"
  71. :class="{ 'nav-tab-item--disabled': isReportLocked }"
  72. @click="handleClearList"
  73. />
  74. <BaseButton
  75. text="数据一键校验"
  76. variant="outline"
  77. :class="{ 'nav-tab-item--disabled': isReportLocked }"
  78. @click="handleValidateAll"
  79. />
  80. <BaseButton
  81. text="提交上报"
  82. variant="primary"
  83. :class="{ 'nav-tab-item--disabled': isReportLocked || submitting }"
  84. @click="handleSubmitReport"
  85. />
  86. </div>
  87. </div>
  88. <div class="data-table">
  89. <div class="data-table__header">
  90. <span style="width: 40px">
  91. <input
  92. v-if="!isReportLocked"
  93. type="checkbox"
  94. :checked="allSelected"
  95. @change="toggleSelectAll"
  96. />
  97. </span>
  98. <span v-for="col in queueColumns" :key="col.key" :style="{ width: col.width }">{{ col.label }}</span>
  99. </div>
  100. <div v-if="queueRows.length === 0" class="data-table__empty">
  101. {{
  102. reportingPhase === 'passed'
  103. ? '本账期已通过审核'
  104. : isReportLocked
  105. ? '清单暂无数据'
  106. : '暂无资产,请点击「新增上报资产」'
  107. }}
  108. </div>
  109. <div v-for="item in queueRows" :key="item.id" class="data-table__row">
  110. <span style="width: 40px">
  111. <input
  112. v-if="!isReportLocked"
  113. v-model="selectedIds"
  114. type="checkbox"
  115. :value="item.id"
  116. />
  117. </span>
  118. <span :style="{ width: queueColumns[0].width }">{{ item.code }}</span>
  119. <span :style="{ width: queueColumns[1].width }">{{ item.group }}</span>
  120. <span :style="{ width: queueColumns[2].width }">{{ item.name }}</span>
  121. <span :style="{ width: queueColumns[3].width }">{{ item.buildArea }}</span>
  122. <span :style="{ width: queueColumns[4].width }">{{ item.rentArea }}</span>
  123. <span :style="{ width: queueColumns[5].width }">{{ item.idleArea }}</span>
  124. <span :style="{ width: queueColumns[6].width }">{{ item.selfArea }}</span>
  125. <span :style="{ width: queueColumns[7].width }">{{ item.lendArea }}</span>
  126. <span :style="{ width: queueColumns[8].width }">{{ item.utilState }}</span>
  127. <span :style="{ width: queueColumns[9].width }">
  128. <template v-if="isReportLocked">
  129. <span class="muted">只读</span>
  130. </template>
  131. <template v-else>
  132. <button type="button" class="link-btn" @click="handleEditItem(item.id)">编辑</button>
  133. <button type="button" class="link-btn" @click="handleRemoveItem(item.id)">移除</button>
  134. </template>
  135. </span>
  136. </div>
  137. </div>
  138. <p class="panel-hint">清单内 <strong>{{ queueRows.length }}</strong> 条 · 已填报 <strong>{{ filledCount }}</strong> 条</p>
  139. </div>
  140. </template>
  141. <template v-else>
  142. <div class="panel">
  143. <div class="filter-bar">
  144. <BaseSelect text="上报年月" :selectedText="histPeriod" :options="periodOptions" @selected="histPeriod = $event" />
  145. <BaseSelect text="上报状态" :selectedText="histStatus" :options="statusOptions" @selected="histStatus = $event" />
  146. <label class="filter-item">
  147. <span>填报人</span>
  148. <input v-model="histReporter" type="text" placeholder="姓名" />
  149. </label>
  150. <BaseButton text="重置" variant="outline" @click="resetHistoryFilters" />
  151. <BaseButton text="导出往期上报报表" variant="outline" @click="handleHistExport" />
  152. </div>
  153. </div>
  154. <div class="panel">
  155. <div class="data-table">
  156. <div class="data-table__header">
  157. <span v-for="col in historyColumns" :key="col.key" :style="{ width: col.width }">{{ col.label }}</span>
  158. </div>
  159. <div v-if="historyLoading" class="data-table__empty">加载中…</div>
  160. <div v-else-if="filteredHistoryRows.length === 0" class="data-table__empty">暂无历史上报记录</div>
  161. <template v-else>
  162. <div v-for="row in filteredHistoryRows" :key="row.id" class="data-table__row">
  163. <span :style="{ width: historyColumns[0].width }">{{ row.period }}</span>
  164. <span :style="{ width: historyColumns[1].width }">{{ row.group }}</span>
  165. <span :style="{ width: historyColumns[2].width }">{{ row.billNo }}</span>
  166. <span :style="{ width: historyColumns[3].width }">{{ row.submittedAt }}</span>
  167. <span :style="{ width: historyColumns[4].width }">{{ row.reporter }}</span>
  168. <span :style="{ width: historyColumns[5].width }">
  169. <span class="status-tag" :class="`status-tag--${row.statusType}`">{{ row.status }}</span>
  170. </span>
  171. <span :style="{ width: historyColumns[6].width }">
  172. <button type="button" class="link-btn" @click="handleHistDetail(row)">查看详情</button>
  173. <button type="button" class="link-btn" @click="handleHistAudit(row)">审批记录</button>
  174. </span>
  175. </div>
  176. </template>
  177. </div>
  178. </div>
  179. </template>
  180. <PickAssetModal
  181. v-model:visible="showPickModal"
  182. :exclude-ids="queueIds"
  183. @confirm="handlePickConfirm"
  184. />
  185. <MonthlyEditModal
  186. v-model:visible="showEditModal"
  187. :asset="editingAsset"
  188. @save="handleEditSave"
  189. />
  190. <HistDetailModal v-model:visible="showHistDetail" :record="histDetailRecord" />
  191. <HistAuditTrailModal v-model:visible="showHistAudit" :record="histAuditRecord" />
  192. </section>
  193. </template>
  194. <script setup>
  195. import { showAlert, showConfirm, showError, showSuccess, showWarning } from '@/utils/message';
  196. import { exportTableExcel } from '@/utils/exportExcel';
  197. import { computed, ref, watch } from 'vue';
  198. import { useRoute, useRouter } from 'vue-router';
  199. import SectionHeader from '@/components/base/SectionHeader.vue';
  200. import BaseSelect from '@/components/base/BaseSelect.vue';
  201. import BaseButton from '@/components/base/BaseButton.vue';
  202. import PickAssetModal from '@/components/manage/asset/PickAssetModal.vue';
  203. import MonthlyEditModal from '@/components/manage/report/MonthlyEditModal.vue';
  204. import HistDetailModal from '@/components/manage/audit/HistDetailModal.vue';
  205. import HistAuditTrailModal from '@/components/manage/audit/HistAuditTrailModal.vue';
  206. import { useEnterpriseStore, REPORT_STATE } from '@/store/enterprise';
  207. import { useNotificationStore } from '@/store/notification';
  208. import { useUserStore } from '@/store/user';
  209. import { parseManageRoute, buildManageRoute } from '@/utils/manageRoutes';
  210. import { resolveManageEnterprise, assetBelongsToManageScope } from '@/utils/manageContext';
  211. import { useFilterStore } from '@/store/filter';
  212. import { resolveUtilState } from '@/utils/resolveUtilState';
  213. import {
  214. buildBillNo,
  215. extractFillMonth,
  216. buildAuditTrail,
  217. normalizeGroupName,
  218. formatDateTime,
  219. getFillTime,
  220. getAuditTime,
  221. getReporter,
  222. extractPeriod,
  223. sumBuildAreaWan,
  224. } from '@/utils/aggregateReportRecords';
  225. import { updateAudit, submitAssetEdit, updateContent } from '@/api/enterpriseList';
  226. import { buildContentPayload, resolveAssetRecord } from '@/utils/assetDetailFields';
  227. import { COLUMN_ID, MODEL_ID } from '@/config';
  228. const enterpriseStore = useEnterpriseStore();
  229. const notificationStore = useNotificationStore();
  230. const userStore = useUserStore();
  231. const filterStore = useFilterStore();
  232. const route = useRoute();
  233. const router = useRouter();
  234. const currentEnterprise = computed(() => resolveManageEnterprise(userStore.userInfo));
  235. const currentManageGroup = computed(() => normalizeGroupName(filterStore.selectManageGroup));
  236. const monthlySub = ref('current');
  237. const pad2 = (n) => String(n).padStart(2, '0');
  238. /** 本账期:当前自然月 */
  239. const currentPeriod = computed(() => {
  240. const now = new Date();
  241. return `${now.getFullYear()}-${pad2(now.getMonth() + 1)}`;
  242. });
  243. /** 截止:次月 1 日 */
  244. const periodDeadline = computed(() => {
  245. const now = new Date();
  246. const month = now.getMonth() + 1;
  247. const nextMonth = month === 12 ? 1 : month + 1;
  248. const nextYear = month === 12 ? now.getFullYear() + 1 : now.getFullYear();
  249. return `${nextYear}-${pad2(nextMonth)}-01`;
  250. });
  251. const showPickModal = ref(false);
  252. const showEditModal = ref(false);
  253. const editingAssetId = ref(null);
  254. const selectedIds = ref([]);
  255. const monthlyQueue = ref([]);
  256. /** 按资产 id 暂存编辑草稿,不反映到清单表格 */
  257. const monthlyDrafts = ref({});
  258. /** 已点击「提交上报」,整页进入审核等待态 */
  259. const reportLocked = ref(false);
  260. const submitting = ref(false);
  261. const savingEdit = ref(false);
  262. const showHistDetail = ref(false);
  263. const histDetailRecord = ref(null);
  264. const showHistAudit = ref(false);
  265. const histAuditRecord = ref(null);
  266. const flowSteps = [
  267. { key: 'unsubmitted', label: '未提交' },
  268. { key: 'draft', label: '草稿已填写' },
  269. { key: 'submitted', label: '已提交' },
  270. { key: 'pending', label: '审核中' },
  271. { key: 'passed', label: '已通过/已驳回' },
  272. ];
  273. const readPersistedQueueIds = () => {
  274. try {
  275. const raw = localStorage.getItem(queueStorageKey.value);
  276. if (!raw) return new Set();
  277. const saved = JSON.parse(raw);
  278. return new Set((saved.itemIds || []).map(String));
  279. } catch {
  280. return new Set();
  281. }
  282. };
  283. const readPersistedQueueMeta = () => {
  284. try {
  285. const raw = localStorage.getItem(queueStorageKey.value);
  286. if (!raw) return null;
  287. return JSON.parse(raw);
  288. } catch {
  289. return null;
  290. }
  291. };
  292. const extractReportMonth = (item) => {
  293. const fillMonth = extractFillMonth(item);
  294. if (fillMonth) return fillMonth;
  295. const time = item?.update_time ?? item?.audit_time;
  296. if (time == null || time === '') return '';
  297. const text = String(time);
  298. if (/^\d{4}-\d{2}/.test(text)) return text.slice(0, 7);
  299. const d = new Date(time);
  300. if (Number.isNaN(d.getTime())) return '';
  301. const pad = (n) => String(n).padStart(2, '0');
  302. return `${d.getFullYear()}-${pad(d.getMonth() + 1)}`;
  303. };
  304. /** 本账期清单/审核状态:仅按青浦集团(c_ssqpjt)归属,与历史上报一致 */
  305. const belongsToMonthlyQueue = (item) => {
  306. if (!item?.id) return false;
  307. return normalizeGroupName(item.c_ssqpjt) === currentManageGroup.value;
  308. };
  309. const matchesReportScope = (item) => {
  310. if (!belongsToMonthlyQueue(item)) return false;
  311. const period = currentPeriod.value;
  312. if (readPersistedQueueIds().has(String(item.id))) return true;
  313. return extractReportMonth(item) === period;
  314. };
  315. const filterByCurrentScope = (list) => list.filter(matchesReportScope);
  316. const pendingPeriodItems = computed(() => filterByCurrentScope(enterpriseStore.pendingList));
  317. const rejectedPeriodItems = computed(() => filterByCurrentScope(enterpriseStore.rejectedList));
  318. const approvedPeriodItems = computed(() => filterByCurrentScope(enterpriseStore.approvedList));
  319. const queueStorageKey = computed(
  320. () => `monthly-queue:${currentPeriod.value}:${currentManageGroup.value}`
  321. );
  322. const sanitizeMonthlyQueue = () => {
  323. monthlyQueue.value = monthlyQueue.value.filter(belongsToMonthlyQueue);
  324. };
  325. const persistQueue = () => {
  326. try {
  327. if (!monthlyQueue.value.length) {
  328. clearQueueStorage();
  329. return;
  330. }
  331. localStorage.setItem(
  332. queueStorageKey.value,
  333. JSON.stringify({
  334. reportLocked: reportLocked.value,
  335. itemIds: monthlyQueue.value.map((item) => item.id),
  336. filledIds: monthlyQueue.value.filter((item) => item._monthlyFilled).map((item) => item.id),
  337. drafts: monthlyDrafts.value,
  338. })
  339. );
  340. } catch (e) {
  341. console.log('清单持久化失败:', e);
  342. }
  343. };
  344. const getPersistedQueueState = () => {
  345. try {
  346. const raw = localStorage.getItem(queueStorageKey.value);
  347. if (!raw) return 'missing';
  348. const saved = JSON.parse(raw);
  349. if (!Array.isArray(saved?.itemIds) || !saved.itemIds.length) return 'empty';
  350. return 'hasItems';
  351. } catch {
  352. return 'missing';
  353. }
  354. };
  355. const buildQueueSources = () => {
  356. const byId = new Map();
  357. [
  358. ...enterpriseStore.pendingList,
  359. ...enterpriseStore.rejectedList,
  360. ...enterpriseStore.approvedList,
  361. ...enterpriseStore.submittedList,
  362. ].forEach((item) => byId.set(String(item.id), item));
  363. return byId;
  364. };
  365. const mapQueueFromItems = (items, filledSet = null) =>
  366. items.map((item) => ({
  367. ...item,
  368. _monthlyFilled: filledSet ? filledSet.has(String(item.id)) : true,
  369. }));
  370. const restoreQueueFromStorage = () => {
  371. try {
  372. const saved = readPersistedQueueMeta();
  373. if (!saved) return 'missing';
  374. if (!Array.isArray(saved?.itemIds) || !saved.itemIds.length) {
  375. monthlyQueue.value = [];
  376. monthlyDrafts.value = saved?.drafts || {};
  377. reportLocked.value = Boolean(saved?.reportLocked);
  378. return 'empty';
  379. }
  380. const filledSet = new Set((saved.filledIds || []).map(String));
  381. const byId = buildQueueSources();
  382. monthlyQueue.value = saved.itemIds
  383. .map((id) => byId.get(String(id)))
  384. .filter(Boolean)
  385. .filter(belongsToMonthlyQueue)
  386. .map((item) => ({
  387. ...item,
  388. _monthlyFilled: filledSet.has(String(item.id)),
  389. }));
  390. monthlyDrafts.value = saved.drafts || {};
  391. reportLocked.value = Boolean(saved.reportLocked);
  392. return monthlyQueue.value.length > 0 ? 'restored' : 'empty';
  393. } catch (e) {
  394. console.log('清单恢复失败:', e);
  395. return 'missing';
  396. }
  397. };
  398. const hydrateQueueFromAuditStates = () => {
  399. const byId = buildQueueSources();
  400. const savedIds = [...readPersistedQueueIds()];
  401. const saved = readPersistedQueueMeta();
  402. if (savedIds.length) {
  403. const restored = savedIds
  404. .map((id) => byId.get(String(id)))
  405. .filter(Boolean)
  406. .filter(belongsToMonthlyQueue);
  407. if (restored.length) {
  408. const filledSet = new Set((saved?.filledIds || []).map(String));
  409. monthlyQueue.value = mapQueueFromItems(restored, filledSet);
  410. monthlyDrafts.value = saved?.drafts || monthlyDrafts.value;
  411. return true;
  412. }
  413. }
  414. const auditItems = [
  415. ...pendingPeriodItems.value,
  416. ...rejectedPeriodItems.value,
  417. ];
  418. const unique = [...new Map(auditItems.map((item) => [String(item.id), item])).values()];
  419. if (!unique.length) return false;
  420. monthlyQueue.value = mapQueueFromItems(unique);
  421. return true;
  422. };
  423. const syncMonthlyQueue = () => {
  424. if (monthlyQueue.value.length) {
  425. mergeQueueFromBackend();
  426. sanitizeMonthlyQueue();
  427. return;
  428. }
  429. const queueState = restoreQueueFromStorage();
  430. if (queueState === 'restored') {
  431. mergeQueueFromBackend();
  432. sanitizeMonthlyQueue();
  433. return;
  434. }
  435. if (hydrateQueueFromAuditStates()) {
  436. mergeQueueFromBackend();
  437. sanitizeMonthlyQueue();
  438. return;
  439. }
  440. if (getPersistedQueueState() === 'missing') {
  441. bootstrapQueueFromBackend();
  442. sanitizeMonthlyQueue();
  443. }
  444. };
  445. const mergeQueueFromBackend = () => {
  446. if (!monthlyQueue.value.length) return;
  447. const byId = buildQueueSources();
  448. monthlyQueue.value = monthlyQueue.value
  449. .map((item) => {
  450. const fresh = byId.get(String(item.id));
  451. if (!fresh) return item;
  452. return {
  453. ...fresh,
  454. _monthlyFilled: item._monthlyFilled,
  455. };
  456. })
  457. .filter(belongsToMonthlyQueue);
  458. };
  459. const bootstrapQueueFromBackend = () => {
  460. if (getPersistedQueueState() !== 'missing') return false;
  461. const byId = new Map();
  462. [...pendingPeriodItems.value, ...rejectedPeriodItems.value].forEach((item) =>
  463. byId.set(String(item.id), item)
  464. );
  465. if (!byId.size) return false;
  466. monthlyQueue.value = [...byId.values()].map((item) => ({
  467. ...item,
  468. _monthlyFilled: true,
  469. }));
  470. return true;
  471. };
  472. const queueAnyPending = computed(() =>
  473. monthlyQueue.value.some((item) =>
  474. pendingPeriodItems.value.some((p) => String(p.id) === String(item.id))
  475. )
  476. );
  477. const queueAnyRejected = computed(() =>
  478. monthlyQueue.value.some((item) =>
  479. rejectedPeriodItems.value.some((r) => String(r.id) === String(item.id))
  480. )
  481. );
  482. const queueAllApproved = computed(
  483. () =>
  484. monthlyQueue.value.length > 0 &&
  485. monthlyQueue.value.every((item) =>
  486. approvedPeriodItems.value.some((a) => String(a.id) === String(item.id))
  487. )
  488. );
  489. /** 本账期存在审核中资产时锁定清单(含本地清单为空但后端有待审数据) */
  490. const isReportLocked = computed(() => {
  491. if (pendingPeriodItems.value.length === 0) return false;
  492. if (monthlyQueue.value.length > 0) return queueAnyPending.value;
  493. return readPersistedQueueIds().size > 0 || pendingPeriodItems.value.length > 0;
  494. });
  495. const reportingPhase = computed(() => {
  496. const hasQueue = monthlyQueue.value.length > 0;
  497. const hasPending = pendingPeriodItems.value.length > 0;
  498. const hasRejected = rejectedPeriodItems.value.length > 0;
  499. const hasApproved = approvedPeriodItems.value.length > 0;
  500. if ((hasQueue && queueAnyPending.value) || (!hasQueue && hasPending)) return 'pending';
  501. if ((hasQueue && queueAnyRejected.value) || (!hasQueue && hasRejected && !hasPending)) {
  502. return 'rejected';
  503. }
  504. if ((hasQueue && queueAllApproved.value) || (!hasQueue && hasApproved && !hasPending && !hasRejected)) {
  505. return 'passed';
  506. }
  507. if (!hasQueue) return 'unsubmitted';
  508. const allFilled = monthlyQueue.value.every(
  509. (item) => item._monthlyFilled || monthlyDrafts.value[String(item.id)]
  510. );
  511. return allFilled ? 'draft' : 'unsubmitted';
  512. });
  513. const syncQueueAuditState = () => {
  514. reportLocked.value = isReportLocked.value;
  515. };
  516. const visualStepIndex = computed(() => {
  517. const map = {
  518. unsubmitted: 0,
  519. draft: 1,
  520. submitted: 2,
  521. pending: 3,
  522. rejected: 4,
  523. passed: 4,
  524. };
  525. return map[reportingPhase.value] ?? 0;
  526. });
  527. const getDotClass = (idx) => {
  528. const current = visualStepIndex.value;
  529. const phase = reportingPhase.value;
  530. if (idx < current) return 'flow-stepper__dot--done';
  531. if (idx === current) {
  532. if (phase === 'rejected') return 'flow-stepper__dot--rejected';
  533. if (phase === 'passed') return 'flow-stepper__dot--passed';
  534. return 'flow-stepper__dot--active';
  535. }
  536. return 'flow-stepper__dot--future';
  537. };
  538. const statusTagLabel = computed(() => {
  539. const labels = {
  540. unsubmitted: '填报中',
  541. draft: '草稿已填写',
  542. submitted: '已提交',
  543. pending: '审核中',
  544. rejected: '已驳回',
  545. passed: '已通过',
  546. };
  547. return labels[reportingPhase.value] || '填报中';
  548. });
  549. const statusTagType = computed(() => {
  550. const types = {
  551. unsubmitted: 'orange',
  552. draft: 'orange',
  553. submitted: 'orange',
  554. pending: 'orange',
  555. rejected: 'red',
  556. passed: 'green',
  557. };
  558. return types[reportingPhase.value] || 'orange';
  559. });
  560. const histPeriod = ref('全部');
  561. const histStatus = ref('全部');
  562. const histReporter = ref('');
  563. const historyLoading = computed(
  564. () =>
  565. enterpriseStore.pendingLoading ||
  566. enterpriseStore.approvedLoading ||
  567. enterpriseStore.rejectedLoading
  568. );
  569. const queueColumns = [
  570. { key: 'code', label: '资产编号', width: '140px' },
  571. { key: 'group', label: '所属集团', width: '120px' },
  572. { key: 'name', label: '资产名称', width: '180px' },
  573. { key: 'buildArea', label: '实际建筑面积(㎡)', width: '160px' },
  574. { key: 'rentArea', label: '出租', width: '80px' },
  575. { key: 'idleArea', label: '闲置', width: '80px' },
  576. { key: 'selfArea', label: '自用', width: '80px' },
  577. { key: 'lendArea', label: '出借', width: '80px' },
  578. { key: 'utilState', label: '利用状态', width: '100px' },
  579. { key: 'action', label: '操作', width: '120px' },
  580. ];
  581. const mapQueueItem = (item) => ({
  582. id: item.id,
  583. code: item.c_bh || '暂无',
  584. group: item.c_ssjt || item.c_ssqpjt || '暂无',
  585. name: item.c_qymc || '暂无',
  586. buildArea: Number(item.c_sjjzmj || 0).toLocaleString('zh-CN'),
  587. rentArea: Number(item.c_czmj || 0).toLocaleString('zh-CN'),
  588. idleArea: Number(item.c_xzmj || 0).toLocaleString('zh-CN'),
  589. selfArea: Number(item.c_zymj || 0).toLocaleString('zh-CN'),
  590. lendArea: Number(item.c_cjmj || 0).toLocaleString('zh-CN'),
  591. utilState: resolveUtilState(item),
  592. filled: Boolean(item._monthlyFilled || monthlyDrafts.value[String(item.id)]),
  593. });
  594. const displayQueue = computed(() => monthlyQueue.value.map(applyDraft));
  595. const queueRows = computed(() => displayQueue.value.map(mapQueueItem));
  596. const queueIds = computed(() => monthlyQueue.value.map((item) => String(item.id)));
  597. const filledCount = computed(() => queueRows.value.filter((item) => item.filled).length);
  598. const allSelected = computed(
  599. () =>
  600. !isReportLocked.value &&
  601. queueRows.value.length > 0 &&
  602. queueRows.value.every((item) => selectedIds.value.includes(item.id))
  603. );
  604. const toggleSelectAll = (event) => {
  605. if (event.target.checked) {
  606. selectedIds.value = queueRows.value.map((item) => item.id);
  607. } else {
  608. selectedIds.value = [];
  609. }
  610. };
  611. const applyDraft = (item) => {
  612. const draft = monthlyDrafts.value[String(item.id)];
  613. return draft ? { ...item, ...draft } : { ...item };
  614. };
  615. const editingAsset = computed(() => {
  616. if (editingAssetId.value == null) return null;
  617. const item = monthlyQueue.value.find((row) => row.id === editingAssetId.value);
  618. return item ? applyDraft(item) : null;
  619. });
  620. const clearDrafts = (ids) => {
  621. const next = { ...monthlyDrafts.value };
  622. ids.forEach((id) => {
  623. delete next[String(id)];
  624. });
  625. monthlyDrafts.value = next;
  626. };
  627. const handlePickConfirm = (pickedItems) => {
  628. if (isReportLocked.value) return;
  629. let added = 0;
  630. pickedItems.forEach((item) => {
  631. const id = String(item.id);
  632. if (!id || !belongsToMonthlyQueue(item)) return;
  633. if (!assetBelongsToManageScope(item)) return;
  634. if (monthlyQueue.value.some((r) => String(r.id) === id)) return;
  635. monthlyQueue.value.push(item);
  636. added++;
  637. });
  638. if (added > 0) {
  639. persistQueue();
  640. showSuccess(`已加入 ${added} 条(已去重)`);
  641. }
  642. };
  643. const handleBatchDelete = async () => {
  644. if (isReportLocked.value) return;
  645. if (!selectedIds.value.length) {
  646. showWarning('请先勾选要删除的资产');
  647. return;
  648. }
  649. const count = selectedIds.value.length;
  650. if (!(await showConfirm(`确认删除选中的 ${count} 条资产?`))) return;
  651. const toDelete = new Set(selectedIds.value.map((id) => String(id)));
  652. monthlyQueue.value = monthlyQueue.value.filter((item) => !toDelete.has(String(item.id)));
  653. clearDrafts([...toDelete]);
  654. selectedIds.value = [];
  655. persistQueue();
  656. };
  657. const handleClearList = async () => {
  658. if (isReportLocked.value) return;
  659. if (!monthlyQueue.value.length) {
  660. showWarning('清单为空');
  661. return;
  662. }
  663. if (!(await showConfirm('确认清空本月待上报清单?'))) return;
  664. monthlyQueue.value = [];
  665. monthlyDrafts.value = {};
  666. selectedIds.value = [];
  667. persistQueue();
  668. };
  669. const handleRemoveItem = async (id) => {
  670. if (isReportLocked.value) return;
  671. const row = queueRows.value.find((item) => item.id === id);
  672. const label = row?.code || '该资产';
  673. if (!(await showConfirm(`确认从清单中移除 ${label}?`))) return;
  674. monthlyQueue.value = monthlyQueue.value.filter((item) => item.id !== id);
  675. clearDrafts([id]);
  676. selectedIds.value = selectedIds.value.filter((selectedId) => selectedId !== id);
  677. persistQueue();
  678. };
  679. const handleEditItem = (id) => {
  680. if (isReportLocked.value) return;
  681. editingAssetId.value = id;
  682. showEditModal.value = true;
  683. };
  684. const buildMonthlyPatch = (item) => ({
  685. c_czmj: item.c_czmj,
  686. c_xzmj: item.c_xzmj,
  687. c_zymj: item.c_zymj,
  688. c_cjmj: item.c_cjmj,
  689. c_fwyt_yt1: item.c_fwyt_yt1,
  690. });
  691. const handleEditSave = async ({ item, isDraft }) => {
  692. const id = String(item.id);
  693. const index = monthlyQueue.value.findIndex((row) => String(row.id) === id);
  694. if (index < 0) return;
  695. if (isDraft) {
  696. monthlyDrafts.value = {
  697. ...monthlyDrafts.value,
  698. [id]: buildMonthlyPatch(item),
  699. };
  700. persistQueue();
  701. return;
  702. }
  703. const original = monthlyQueue.value[index];
  704. const patch = buildMonthlyPatch(item);
  705. savingEdit.value = true;
  706. try {
  707. await updateContent({
  708. content: buildContentPayload(original, patch),
  709. columnId: COLUMN_ID,
  710. modelId: MODEL_ID,
  711. });
  712. monthlyQueue.value[index] = {
  713. ...resolveAssetRecord({ ...original, ...patch }),
  714. _monthlyFilled: true,
  715. };
  716. clearDrafts([id]);
  717. persistQueue();
  718. showSuccess('保存成功');
  719. } catch (e) {
  720. console.log('月度填报保存异常:', e);
  721. showError(e?.message || e?.msg || '保存失败,请稍后重试');
  722. } finally {
  723. savingEdit.value = false;
  724. }
  725. };
  726. const monthlyAreaSum = (item) =>
  727. Number(item.c_czmj || 0) +
  728. Number(item.c_xzmj || 0) +
  729. Number(item.c_zymj || 0) +
  730. Number(item.c_cjmj || 0);
  731. const validateMonthlyItem = (item) => {
  732. if (!item._monthlyFilled) return '未填报';
  733. const buildArea = Number(item.c_sjjzmj || 0);
  734. const sum = monthlyAreaSum(item);
  735. if (Math.abs(sum - buildArea) > 0.01) {
  736. return `四类使用面积之和须等于实际建筑面积(当前合计 ${sum.toFixed(2)}㎡,应为 ${buildArea.toFixed(2)}㎡)`;
  737. }
  738. return '';
  739. };
  740. const formatQueueItemLabel = (item, index) => {
  741. const parts = [
  742. `${index + 1}.`,
  743. item.c_bh ? `编号 ${item.c_bh}` : null,
  744. item.c_qymc || null,
  745. item.c_ssqpjt || item.c_ssjt || null,
  746. ].filter(Boolean);
  747. return parts.join(' · ');
  748. };
  749. const collectQueueErrors = () => {
  750. if (!monthlyQueue.value.length) {
  751. return ['清单为空'];
  752. }
  753. const errs = [];
  754. monthlyQueue.value.forEach((item, index) => {
  755. const err = validateMonthlyItem(item);
  756. if (err) errs.push(`${formatQueueItemLabel(item, index)}:${err}`);
  757. });
  758. return errs;
  759. };
  760. const showValidationErrors = (errs) => {
  761. const preview = errs.slice(0, 5).join('\n');
  762. const more = errs.length > 5 ? `\n… 还有 ${errs.length - 5} 条未通过` : '';
  763. showAlert(`校验未通过(共 ${errs.length} 条)\n${preview}${more}`, 'warning', { duration: 6000 });
  764. };
  765. const validateQueue = () => {
  766. const errs = collectQueueErrors();
  767. if (errs.length) {
  768. showValidationErrors(errs);
  769. return false;
  770. }
  771. return true;
  772. };
  773. const handleValidateAll = () => {
  774. if (isReportLocked.value) return;
  775. if (validateQueue()) {
  776. showSuccess('全部校验通过');
  777. }
  778. };
  779. const getQueueItemAuditState = (item) => {
  780. const id = String(item.id);
  781. if (approvedPeriodItems.value.some((a) => String(a.id) === id)) return REPORT_STATE.APPROVED;
  782. if (rejectedPeriodItems.value.some((r) => String(r.id) === id)) return REPORT_STATE.REJECTED;
  783. if (pendingPeriodItems.value.some((p) => String(p.id) === id)) return REPORT_STATE.PENDING;
  784. return REPORT_STATE.SUBMITTED;
  785. };
  786. const submitQueueItem = async (item, fillTime = Date.now()) => {
  787. const auditState = getQueueItemAuditState(item);
  788. if (auditState === REPORT_STATE.APPROVED || auditState === REPORT_STATE.REJECTED) {
  789. await submitAssetEdit(
  790. item,
  791. { ...buildMonthlyPatch(item), fill_time: fillTime },
  792. { auditorComment: '月度上报修改送审' }
  793. );
  794. return;
  795. }
  796. await updateContent({
  797. content: buildContentPayload(item, { fill_time: fillTime }),
  798. columnId: COLUMN_ID,
  799. modelId: MODEL_ID,
  800. });
  801. await updateAudit({
  802. id: item.id,
  803. columnId: COLUMN_ID,
  804. state: REPORT_STATE.PENDING,
  805. });
  806. };
  807. const handleSubmitReport = async () => {
  808. if (submitting.value || isReportLocked.value) return;
  809. if (!validateQueue()) return;
  810. if (!(await showConfirm('确认提交?提交后进入审核'))) return;
  811. submitting.value = true;
  812. const fillTime = Date.now();
  813. try {
  814. await Promise.all(monthlyQueue.value.map((item) => submitQueueItem(item, fillTime)));
  815. selectedIds.value = [];
  816. await enterpriseStore.refreshReportProgress({ skipSubmitted: true });
  817. await enterpriseStore.refreshStates([REPORT_STATE.SUBMITTED]);
  818. mergeQueueFromBackend();
  819. syncQueueAuditState();
  820. persistQueue();
  821. await notificationStore.syncAfterReportChange();
  822. showSuccess('提交成功,进入审核');
  823. } catch (e) {
  824. console.log('提交上报异常:', e);
  825. showError(e?.message || e?.msg || '提交失败,请稍后重试');
  826. } finally {
  827. submitting.value = false;
  828. }
  829. };
  830. const clearQueueStorage = () => {
  831. try {
  832. localStorage.removeItem(queueStorageKey.value);
  833. } catch (e) {
  834. console.log('清单清除失败:', e);
  835. }
  836. };
  837. /** 本账期审核已通过:清空清单及 localStorage */
  838. const shouldClearQueueAfterApproval = () => {
  839. if (pendingPeriodItems.value.length > 0) return false;
  840. if (rejectedPeriodItems.value.length > 0) return false;
  841. if (monthlyQueue.value.length > 0) {
  842. return queueAllApproved.value;
  843. }
  844. return approvedPeriodItems.value.length > 0 && getPersistedQueueState() !== 'missing';
  845. };
  846. const resetMonthlyQueueAfterApproval = () => {
  847. monthlyQueue.value = [];
  848. monthlyDrafts.value = {};
  849. selectedIds.value = [];
  850. reportLocked.value = false;
  851. clearQueueStorage();
  852. };
  853. const refreshMonthlyQueueState = () => {
  854. syncMonthlyQueue();
  855. if (shouldClearQueueAfterApproval()) {
  856. resetMonthlyQueueAfterApproval();
  857. return;
  858. }
  859. syncQueueAuditState();
  860. persistQueue();
  861. };
  862. watch(
  863. () => parseManageRoute(route).tab,
  864. (tab) => {
  865. if (tab !== 'archive') return;
  866. if (monthlySub.value === 'history') loadHistoryData();
  867. else loadReportingState();
  868. },
  869. { immediate: true },
  870. );
  871. const loadReportingState = async ({ resetQueue = false } = {}) => {
  872. if (resetQueue) {
  873. await enterpriseStore.refreshReportProgress({ skipSubmitted: true });
  874. await enterpriseStore.refreshStates([REPORT_STATE.SUBMITTED]);
  875. } else {
  876. await enterpriseStore.ensureReportProgress({ skipSubmitted: true });
  877. await enterpriseStore.ensureState(REPORT_STATE.SUBMITTED);
  878. }
  879. if (resetQueue) {
  880. monthlyQueue.value = [];
  881. monthlyDrafts.value = {};
  882. selectedIds.value = [];
  883. reportLocked.value = false;
  884. clearQueueStorage();
  885. return;
  886. }
  887. refreshMonthlyQueueState();
  888. };
  889. const mapHistoryRecord = (record, status, statusType, auditStatus) => ({
  890. ...record,
  891. status,
  892. statusType,
  893. auditTrail: buildAuditTrail(record, auditStatus),
  894. });
  895. /** 同一批上报共用 fill_time,归一化后作为批次 key */
  896. const normalizeSubmissionTime = (val) => {
  897. if (val == null || val === '') return '';
  898. const n = Number(val);
  899. if (Number.isFinite(n) && n > 1e11) return String(Math.floor(n));
  900. const d = new Date(val);
  901. return Number.isNaN(d.getTime()) ? String(val).trim() : String(d.getTime());
  902. };
  903. const getSubmissionBatchKey = (item) => {
  904. const fillTime = item?.fill_time;
  905. if (fillTime == null || fillTime === '') return `item-${item.id}`;
  906. return normalizeSubmissionTime(fillTime);
  907. };
  908. /** 按每次批量上报(fill_time)整合,同批多条资产合并为一条历史记录 */
  909. const buildHistoryRecordsFromList = (items, status, statusType, auditStatus) => {
  910. const group = currentManageGroup.value;
  911. const fallbackPeriod = currentPeriod.value;
  912. const map = new Map();
  913. items.forEach((item) => {
  914. if (normalizeGroupName(item.c_ssqpjt) !== group) return;
  915. const period = extractReportMonth(item) || extractPeriod(item, fallbackPeriod);
  916. const qingpuGroup = normalizeGroupName(item.c_ssqpjt);
  917. const fillTime = String(item?.fill_time ?? '');
  918. const auditTime = String(getAuditTime(item) ?? '');
  919. const batchKey = `${period}|${qingpuGroup}|${getSubmissionBatchKey(item)}|${status}`;
  920. if (!map.has(batchKey)) {
  921. map.set(batchKey, {
  922. id: batchKey,
  923. period,
  924. group: item.c_ssjt || qingpuGroup || '暂无',
  925. qingpuGroup,
  926. billNo: buildBillNo(period, qingpuGroup),
  927. submittedAt: formatDateTime(item?.fill_time ?? getFillTime(item)),
  928. reporter: getReporter(item),
  929. items: [],
  930. sortKey: auditTime || fillTime || period,
  931. });
  932. }
  933. const record = map.get(batchKey);
  934. record.items.push(item);
  935. const time = auditTime || fillTime;
  936. if (time >= (record.sortKey || '')) {
  937. record.sortKey = time;
  938. record.submittedAt = formatDateTime(item?.fill_time ?? getFillTime(item));
  939. record.reporter = getReporter(item);
  940. }
  941. });
  942. return [...map.values()]
  943. .sort((a, b) => (b.sortKey || b.period).localeCompare(a.sortKey || a.period))
  944. .map((record) => {
  945. const row = {
  946. ...record,
  947. count: record.items.length,
  948. area: sumBuildAreaWan(record.items),
  949. };
  950. delete row.sortKey;
  951. return mapHistoryRecord(row, status, statusType, auditStatus);
  952. });
  953. };
  954. const historySourceRows = computed(() => {
  955. const pending = buildHistoryRecordsFromList(
  956. enterpriseStore.pendingList,
  957. '审核中',
  958. 'orange',
  959. 'pending'
  960. );
  961. const approved = buildHistoryRecordsFromList(
  962. enterpriseStore.approvedList,
  963. '已通过',
  964. 'green',
  965. 'passed'
  966. );
  967. const rejected = buildHistoryRecordsFromList(
  968. enterpriseStore.rejectedList,
  969. '已驳回',
  970. 'red',
  971. 'rejected'
  972. );
  973. return [...pending, ...approved, ...rejected].sort((a, b) =>
  974. (b.submittedAt || b.period).localeCompare(a.submittedAt || a.period)
  975. );
  976. });
  977. const periodOptions = computed(() => {
  978. const periods = new Set(historySourceRows.value.map((row) => row.period).filter(Boolean));
  979. return [
  980. { text: '全部', value: '全部' },
  981. ...[...periods].sort().reverse().map((p) => ({ text: p, value: p })),
  982. ];
  983. });
  984. const statusOptions = [
  985. { text: '全部', value: '全部' },
  986. { text: '审核中', value: '审核中' },
  987. { text: '已通过', value: '已通过' },
  988. { text: '已驳回', value: '已驳回' },
  989. ];
  990. const historyColumns = [
  991. { key: 'period', label: '上报月份', width: '120px' },
  992. { key: 'group', label: '所属集团', width: '200px' },
  993. { key: 'billNo', label: '上报单据编号', width: '180px' },
  994. { key: 'submittedAt', label: '填报时间', width: '160px' },
  995. { key: 'reporter', label: '填报人', width: '100px' },
  996. { key: 'status', label: '审批状态', width: '120px' },
  997. { key: 'action', label: '操作', width: '180px' },
  998. ];
  999. const HISTORY_EXPORT_COLUMNS = [
  1000. { key: 'period', label: '上报月份' },
  1001. { key: 'group', label: '所属集团' },
  1002. { key: 'billNo', label: '上报单据编号' },
  1003. { key: 'submittedAt', label: '填报时间' },
  1004. { key: 'reporter', label: '填报人' },
  1005. { key: 'status', label: '审批状态' },
  1006. { key: 'count', label: '资产条数' },
  1007. { key: 'area', label: '建筑面积合计(万㎡)' },
  1008. ];
  1009. const filteredHistoryRows = computed(() => {
  1010. const kw = histReporter.value.trim();
  1011. return historySourceRows.value.filter((row) => {
  1012. if (histPeriod.value !== '全部' && row.period !== histPeriod.value) return false;
  1013. if (histStatus.value !== '全部' && row.status !== histStatus.value) return false;
  1014. if (kw && !row.reporter.includes(kw)) return false;
  1015. return true;
  1016. });
  1017. });
  1018. const loadHistoryData = () => enterpriseStore.ensureReportProgress({ skipSubmitted: true });
  1019. const formatReportMonthForExport = (period) => {
  1020. const match = String(period ?? '').match(/^(\d{4})-(\d{2})$/);
  1021. if (!match) return period ?? '';
  1022. return `${match[1]}年${Number(match[2])}月`;
  1023. };
  1024. const handleHistExport = () => {
  1025. const result = exportTableExcel({
  1026. columns: HISTORY_EXPORT_COLUMNS,
  1027. rows: filteredHistoryRows.value.map((row) => ({
  1028. ...row,
  1029. period: formatReportMonthForExport(row.period),
  1030. })),
  1031. filenameBase: '往期上报报表',
  1032. });
  1033. if (!result.ok) {
  1034. showWarning('当前筛选结果为空,无法导出');
  1035. return;
  1036. }
  1037. showSuccess(`已导出 ${result.count} 条记录(${result.filename})`);
  1038. };
  1039. const handleHistDetail = (row) => {
  1040. histDetailRecord.value = row;
  1041. showHistDetail.value = true;
  1042. };
  1043. const handleHistAudit = (row) => {
  1044. histAuditRecord.value = row;
  1045. showHistAudit.value = true;
  1046. };
  1047. const resetHistoryFilters = () => {
  1048. histPeriod.value = '全部';
  1049. histStatus.value = '全部';
  1050. histReporter.value = '';
  1051. if (route.query.period || route.query.status) {
  1052. router.replace(buildManageRoute({ tab: 'archive', sub: 'history' }));
  1053. }
  1054. };
  1055. watch(monthlySub, (tab) => {
  1056. if (parseManageRoute(route).tab !== 'archive') return;
  1057. if (tab === 'history') {
  1058. loadHistoryData();
  1059. } else {
  1060. loadReportingState();
  1061. }
  1062. });
  1063. const applyRouteSubNav = () => {
  1064. const { tab, sub, period, status } = parseManageRoute(route);
  1065. if (tab !== 'archive') return;
  1066. if (sub !== 'history') {
  1067. monthlySub.value = 'current';
  1068. return;
  1069. }
  1070. monthlySub.value = 'history';
  1071. const nextPeriod = period ? String(period) : '全部';
  1072. const nextStatus =
  1073. status && ['审核中', '已通过', '已驳回'].includes(String(status)) ? String(status) : '全部';
  1074. histPeriod.value = nextPeriod;
  1075. histStatus.value = nextStatus;
  1076. loadHistoryData();
  1077. };
  1078. const switchArchiveSub = (sub) => {
  1079. if (sub === monthlySub.value) return;
  1080. router.replace(buildManageRoute({ tab: 'archive', sub }));
  1081. };
  1082. watch(() => route.fullPath, applyRouteSubNav, { immediate: true });
  1083. watch(
  1084. () => [currentManageGroup.value, currentEnterprise.value],
  1085. () => {
  1086. if (monthlySub.value === 'current') {
  1087. loadReportingState({ resetQueue: true });
  1088. }
  1089. }
  1090. );
  1091. watch(
  1092. () => [
  1093. enterpriseStore.pendingList.length,
  1094. enterpriseStore.rejectedList.length,
  1095. enterpriseStore.approvedList.length,
  1096. ],
  1097. () => {
  1098. if (monthlySub.value !== 'current') return;
  1099. refreshMonthlyQueueState();
  1100. }
  1101. );
  1102. </script>
  1103. <style scoped>
  1104. .manage-page {
  1105. width: 100%;
  1106. max-width: var(--content-max-width);
  1107. display: flex;
  1108. flex-direction: column;
  1109. gap: 16px;
  1110. }
  1111. .breadcrumb {
  1112. font-family: var(--font-regular);
  1113. font-size: 13px;
  1114. color: var(--color-text-secondary);
  1115. margin: 0;
  1116. }
  1117. .breadcrumb span {
  1118. color: var(--color-accent);
  1119. font-weight: 500;
  1120. }
  1121. .page-header {
  1122. display: flex;
  1123. align-items: center;
  1124. justify-content: space-between;
  1125. gap: 12px;
  1126. }
  1127. .page-title {
  1128. font-family: var(--font-semibold);
  1129. font-size: 20px;
  1130. font-weight: 600;
  1131. color: var(--color-text-primary);
  1132. margin: 0;
  1133. }
  1134. .sub-tabs {
  1135. display: flex;
  1136. flex-wrap: wrap;
  1137. gap: 16px;
  1138. }
  1139. .period-panel {
  1140. display: flex;
  1141. flex-direction: column;
  1142. gap: 12px;
  1143. padding: 16px 20px;
  1144. border-radius: var(--radius-card);
  1145. background: var(--color-surface);
  1146. border: 1px solid var(--color-accent-border);
  1147. }
  1148. .flow-stepper {
  1149. display: flex;
  1150. align-items: flex-start;
  1151. justify-content: space-between;
  1152. gap: 0;
  1153. padding: 8px 0 4px;
  1154. overflow-x: auto;
  1155. }
  1156. .flow-stepper__node {
  1157. display: flex;
  1158. flex-direction: column;
  1159. align-items: center;
  1160. gap: 8px;
  1161. flex: 0 0 auto;
  1162. min-width: 72px;
  1163. }
  1164. .flow-stepper__dot {
  1165. width: 12px;
  1166. height: 12px;
  1167. border-radius: 50%;
  1168. border: 2px solid rgba(152, 162, 179, 0.5);
  1169. background: var(--color-surface);
  1170. box-sizing: border-box;
  1171. }
  1172. .flow-stepper__dot--done {
  1173. border-color: var(--color-accent);
  1174. background: var(--color-accent);
  1175. }
  1176. .flow-stepper__dot--active {
  1177. border-color: rgba(255, 140, 0, 1);
  1178. background: rgba(255, 140, 0, 1);
  1179. box-shadow: 0 0 0 4px rgba(255, 140, 0, 0.18);
  1180. }
  1181. .flow-stepper__dot--passed {
  1182. border-color: var(--color-success);
  1183. background: var(--color-success);
  1184. }
  1185. .flow-stepper__dot--rejected {
  1186. border-color: var(--color-danger);
  1187. background: var(--color-danger);
  1188. }
  1189. .flow-stepper__dot--future {
  1190. border-color: rgba(152, 162, 179, 0.5);
  1191. background: var(--color-surface);
  1192. }
  1193. .flow-stepper__line {
  1194. flex: 1 1 auto;
  1195. height: 2px;
  1196. min-width: 24px;
  1197. margin-top: 5px;
  1198. background: rgba(152, 162, 179, 0.35);
  1199. }
  1200. .flow-stepper__line--done {
  1201. background: var(--color-accent-strong);
  1202. }
  1203. .flow-stepper__label {
  1204. font-family: var(--font-regular);
  1205. font-size: 12px;
  1206. color: var(--color-text-secondary);
  1207. text-align: center;
  1208. white-space: nowrap;
  1209. }
  1210. .period-notice {
  1211. margin: 0;
  1212. padding: 10px 12px;
  1213. border-radius: var(--radius-sm);
  1214. background: rgba(255, 204, 51, 0.12);
  1215. border: 1px solid rgba(255, 204, 51, 0.35);
  1216. font-family: var(--font-regular);
  1217. font-size: 13px;
  1218. color: rgba(120, 90, 0, 1);
  1219. }
  1220. .period-notice--warn {
  1221. background: rgba(255, 79, 52, 0.08);
  1222. border-color: rgba(255, 79, 52, 0.25);
  1223. color: rgba(180, 50, 30, 1);
  1224. }
  1225. .muted {
  1226. color: rgba(152, 162, 179, 1);
  1227. font-size: 13px;
  1228. }
  1229. .status-strip {
  1230. display: flex;
  1231. flex-wrap: wrap;
  1232. align-items: center;
  1233. gap: 12px;
  1234. padding: 12px 16px;
  1235. border-radius: var(--radius-card);
  1236. background: var(--color-accent-hover);
  1237. border: 1px solid var(--color-accent-border);
  1238. font-family: var(--font-regular);
  1239. font-size: 13px;
  1240. color: var(--color-text-body);
  1241. }
  1242. .panel {
  1243. padding: 20px;
  1244. border-radius: var(--radius-card);
  1245. background: var(--color-surface);
  1246. border: 1px solid var(--color-accent-border);
  1247. display: flex;
  1248. flex-direction: column;
  1249. gap: 12px;
  1250. }
  1251. .panel-toolbar {
  1252. display: flex;
  1253. align-items: flex-start;
  1254. justify-content: space-between;
  1255. flex-wrap: wrap;
  1256. gap: 12px;
  1257. }
  1258. .panel-hint {
  1259. font-family: var(--font-regular);
  1260. font-size: 12px;
  1261. color: var(--color-text-secondary);
  1262. margin: 0;
  1263. }
  1264. .action-row,
  1265. .filter-bar {
  1266. display: flex;
  1267. flex-wrap: wrap;
  1268. align-items: center;
  1269. gap: 12px;
  1270. }
  1271. .filter-item {
  1272. display: flex;
  1273. align-items: center;
  1274. gap: 8px;
  1275. font-family: var(--font-regular);
  1276. font-size: 14px;
  1277. color: var(--color-text-body);
  1278. }
  1279. .filter-item input {
  1280. height: 36px;
  1281. padding: 0 12px;
  1282. border-radius: var(--radius-sm);
  1283. border: 1px solid var(--color-input-border);
  1284. font-family: var(--font-regular);
  1285. font-size: 14px;
  1286. min-width: 140px;
  1287. }
  1288. .data-table {
  1289. display: flex;
  1290. flex-direction: column;
  1291. gap: 4px;
  1292. overflow-x: auto;
  1293. }
  1294. .data-table__header,
  1295. .data-table__row {
  1296. display: flex;
  1297. align-items: center;
  1298. gap: 12px;
  1299. min-height: 42px;
  1300. min-width: max-content;
  1301. }
  1302. .data-table__header {
  1303. background: var(--color-table-head);
  1304. border-radius: 2px;
  1305. font-family: var(--font-medium);
  1306. font-weight: 500;
  1307. font-size: 14px;
  1308. color: var(--color-text-secondary);
  1309. }
  1310. .data-table__row {
  1311. font-family: var(--font-regular);
  1312. font-size: 14px;
  1313. color: var(--color-text-data);
  1314. }
  1315. .data-table__empty {
  1316. padding: 24px;
  1317. text-align: center;
  1318. font-family: var(--font-regular);
  1319. font-size: 14px;
  1320. color: var(--color-text-secondary);
  1321. }
  1322. .data-table__header span,
  1323. .data-table__row span {
  1324. flex-shrink: 0;
  1325. }
  1326. .status-tag {
  1327. display: inline-block;
  1328. padding: 2px 8px;
  1329. border-radius: 4px;
  1330. font-size: 12px;
  1331. }
  1332. .status-tag--orange {
  1333. background: rgba(255, 204, 51, 0.2);
  1334. color: rgba(180, 120, 0, 1);
  1335. }
  1336. .status-tag--green {
  1337. background: rgba(104, 221, 169, 0.25);
  1338. color: var(--color-success);
  1339. }
  1340. .status-tag--red {
  1341. background: rgba(255, 79, 52, 0.12);
  1342. color: var(--color-danger);
  1343. }
  1344. .link-btn {
  1345. border: none;
  1346. background: none;
  1347. color: var(--color-accent);
  1348. cursor: pointer;
  1349. font-family: var(--font-regular);
  1350. font-size: 14px;
  1351. padding: 0;
  1352. margin-right: 8px;
  1353. }
  1354. .link-btn:last-child {
  1355. margin-right: 0;
  1356. }
  1357. :deep(.nav-tab-item--disabled) {
  1358. opacity: 0.6;
  1359. pointer-events: none;
  1360. cursor: not-allowed;
  1361. }
  1362. </style>