Compare commits
1131 Commits
master
..
b7d4d325e0
| Author | SHA1 | Date | |
|---|---|---|---|
| b7d4d325e0 | |||
| 82a782550e | |||
| d1b56918fa | |||
| 441917bfce | |||
| 037a689316 | |||
| db7cd22ed1 | |||
| 9962d9797e | |||
| 47459e2089 | |||
| e6021593ea | |||
| 540d6588e6 | |||
| 2a9110ec32 | |||
| 51fb77ec25 | |||
| 30d31fb318 | |||
| bb52574767 | |||
| cd055f8ccd | |||
| c2915036d6 | |||
| 8dc03df95b | |||
| bb74c9a192 | |||
| 32985c78f3 | |||
| 8e684b92dd | |||
| d54dbf72c9 | |||
| 94a0c287e0 | |||
| 47b2758fe8 | |||
| dd45ffe34c | |||
| 48ee76d60d | |||
| 5af4e1c23e | |||
| b9768aac5e | |||
| 08e78ebe55 | |||
| 6fe67b648f | |||
| 96e93944d9 | |||
| 0cf20527a4 | |||
| 83cb3ff84e | |||
| 9a487ae9a7 | |||
| 02441565a0 | |||
| b3f7b81b9c | |||
| 11d1951c7f | |||
| ffd8c718dd | |||
| 45fdd8a294 | |||
| 5fad0ae027 | |||
| 3f599547e6 | |||
| 7c1c13526e | |||
| 15222be2b5 | |||
| 3cc5a64609 | |||
| 197643a8fa | |||
| ba581ed095 | |||
| 630bfc3eee | |||
| b12acf7793 | |||
| 4ac8f8b472 | |||
| 7b6f62f1bc | |||
| f2906e8d6f | |||
| d9e3f34d37 | |||
| e248b6e43a | |||
| abcfa5bef7 | |||
| 83e38d4278 | |||
| 50d0d110a2 | |||
| c086d402a7 | |||
| 30b8c910e8 | |||
| c5982dd900 | |||
| 0bd4843b8e | |||
| e8f0dead9e | |||
| b575059726 | |||
| 6d6cfcb6ff | |||
| 4994142a67 | |||
| e6cf4c2461 | |||
| d2301db292 | |||
| f6c44d1b92 | |||
| 23e749c973 | |||
| 5f8c469b8e | |||
| 678605e9fb | |||
| 056abcd473 | |||
| e820811d98 | |||
| cd6beef388 | |||
| d3f5a371e3 | |||
| f00fdcd42a | |||
| 970affec95 | |||
| 4a9ddcab64 | |||
| 3ef7cefe07 | |||
| b0c461d347 | |||
| f324c6bd3d | |||
| 35ecceacb4 | |||
| c5c103b287 | |||
| 35bed42b73 | |||
| 66082af52a | |||
| c200fa4f32 | |||
| e81aa9e02e | |||
| 4276a90236 | |||
| 7adef149d8 | |||
| e793f3b72d | |||
| fc4eff2f01 | |||
| 2691472a5e | |||
| 4742a2e3b5 | |||
| 26e062d32c | |||
| 898fae4cb3 | |||
| 8034d916bc | |||
| 191e5f9102 | |||
| 1da4511dd9 | |||
| 4c88964473 | |||
| 6bd935dc6b | |||
| b7029835d8 | |||
| ab787ceff7 | |||
| 3dd39bba44 | |||
| 648935e757 | |||
| 6d9b4a13ee | |||
| 3b5adff2e3 | |||
| 6e2e4bf8e7 | |||
| c3dc2a3f2f | |||
| 0315a3a93d | |||
| 8add3ceaa4 | |||
| 5e5658b00d | |||
| 9ac4eda054 | |||
| c381527528 | |||
| efada31764 | |||
| d30e8f3e8f | |||
| 596933eea2 | |||
| a2bfb08122 | |||
| d3bbb1a296 | |||
| c915847d92 | |||
| 553aca34f7 | |||
| 207f48f7d8 | |||
| 0387dc4918 | |||
| 603822a6c1 | |||
| a8d08c4d39 | |||
| 1848a34a27 | |||
| 2f4bb834cf | |||
| 32ef9a2ebb | |||
| 1692fa4a69 | |||
| 63339b401c | |||
| 359f3ce1c9 | |||
| 6329695fc2 | |||
| 1d99423da5 | |||
| ad5c7c02f9 | |||
| af49cbda64 | |||
| 5e4a2a9d11 | |||
| a7cdb0031a | |||
| a6b18b78e6 | |||
| 6bd44e6884 | |||
| 8120ba48f6 | |||
| eebdb7af2d | |||
| cabbb4be0b | |||
| 6a0eb8cf63 | |||
| 0248c8737d | |||
| 4c6884223d | |||
| d745271685 | |||
| 3902acafb9 | |||
| 85f565bd82 | |||
| 178ff96be4 | |||
| 88f2ec8bb0 | |||
| f765b3ce67 | |||
| 8b4955d9b5 | |||
| 07fda4cf22 | |||
| 41cb4ce174 | |||
| e0ec2d864e | |||
| cea7662fc3 | |||
| 4e86506f3e | |||
| f7ad99deda | |||
| 8b0bf3d563 | |||
| 39f43469c2 | |||
| 4aa9b587ba | |||
| 3ba84de784 | |||
| 50ba594ad1 | |||
| c924ffa16d | |||
| 79ee16a374 | |||
| b4657a50fb | |||
| fe429c7a05 | |||
| cd9c5effb7 | |||
| 916d13c3ce | |||
| 9422ad529c | |||
| 79878c8532 | |||
| be486699fd | |||
| bf9ede7049 | |||
| 3a5b2f5101 | |||
| 125a9ff8d6 | |||
| de03a41734 | |||
| 67390c54a9 | |||
| 9e675d63a3 | |||
| 3a68489ee6 | |||
| 9684a184e1 | |||
| 0bf6026083 | |||
| 02a0a6cbf1 | |||
| 26f472413e | |||
| 0ff9024fe4 | |||
| c7708ca57c | |||
| a36a60f151 | |||
| e45ab1da9e | |||
| 05d19626a1 | |||
| cf750a26d4 | |||
| 656dc7ce2f | |||
| 37d3dc8a4c | |||
| 74691acdf9 | |||
| 46f1d27478 | |||
| ea9b263af3 | |||
| 95af9667f6 | |||
| 1e8e173236 | |||
| d3b7ea85eb | |||
| 4e7eb49e0d | |||
| 21e56d40e2 | |||
| 5e274878fe | |||
| 9a20b38bbd | |||
| 9aceedb2e2 | |||
| 23cb828162 | |||
| 3fc8746218 | |||
| b134db134e | |||
| e88bf5322b | |||
| e461ceec2c | |||
| 3056608e04 | |||
| 4cdc7205e9 | |||
| 6701c12178 | |||
| ee73d7d683 | |||
| 6dcdbec63d | |||
| 84cc592517 | |||
| 51b88e4331 | |||
| 16c17c5481 | |||
| f2d3b08e2f | |||
| e3cb97fb49 | |||
| d23fde1757 | |||
| 9b8423bb9b | |||
| f41d8b127f | |||
| cea4db2c45 | |||
| b791fa94e7 | |||
| 320600584c | |||
| ef19a5c00c | |||
| 8668a6e439 | |||
| 4dd9ca7a22 | |||
| 89c06b58c3 | |||
| a6bc6b80b3 | |||
| 423931eb1d | |||
| c4262bd704 | |||
| 94954648d2 | |||
| 21e4bfc221 | |||
| 883625a072 | |||
| 5708025baa | |||
| 3917d678d8 | |||
| 68f6ffe84e | |||
| e063aedb8f | |||
| 5eb3e865b2 | |||
| 91f429f1a0 | |||
| 095a79de94 | |||
| b60bf7bc13 | |||
| 154ec6e301 | |||
| 1d98315877 | |||
| 4731c9a23c | |||
| d8950e93da | |||
| df8255c41e | |||
| 103cb28a1f | |||
| 467c72efb4 | |||
| 818eed0cb5 | |||
| 1acb93ff1c | |||
| 9b21e1f22e | |||
| 479cc449d6 | |||
| b5a1a51403 | |||
| 61b2d7152d | |||
| c919780875 | |||
| 69f6965c93 | |||
| 40463772c5 | |||
| 137af44ae8 | |||
| cb1490ccc2 | |||
| 88d3bfb8b2 | |||
| 77d049990c | |||
| a1e466030b | |||
| d2ef1ce4d8 | |||
| 64f9ac54cf | |||
| a816bfa899 | |||
| cb8e092cc6 | |||
| 841430cd6c | |||
| 602c2118d3 | |||
| a877488f8f | |||
| bf0cecef88 | |||
| 25ebd667f1 | |||
| 085f352320 | |||
| 6368ee376f | |||
| 29641e20a7 | |||
| 0a1e778ef6 | |||
| 7fa9b5ccf3 | |||
| 813ab5db7b | |||
| 58ea911d66 | |||
| 9293cd0976 | |||
| 6ccd5ce1af | |||
| 42722d0cc6 | |||
| bef09cb5b5 | |||
| 9060464afd | |||
| be6a17d4bd | |||
| 72a8f75dc5 | |||
| 119095a57b | |||
| 8c6088bdc9 | |||
| 93033e94db | |||
| 7ccabf859f | |||
| 3828c90b4c | |||
| a46c35f01d | |||
| c1d6ce6d20 | |||
| d9b1b980ca | |||
| 43c7c03aee | |||
| ad6658e490 | |||
| a9b4a56986 | |||
| 5058baffe0 | |||
| 9d25f13fe9 | |||
| 4c78c64569 | |||
| 62bf4f005d | |||
| 43463e12ca | |||
| 27afc4470a | |||
| ce27161bbb | |||
| abc8ed72d4 | |||
| 23037c669d | |||
| fb420c2988 | |||
| 09b3d9f013 | |||
| 53b4cb52f3 | |||
| 8e5fc00945 | |||
| eb526fef5d | |||
| aeb226a0e6 | |||
| 50a6cf12e7 | |||
| 45a8161bb2 | |||
| aaa943a86d | |||
| ffb16bea9a | |||
| 5d9019a40d | |||
| 916f179fca | |||
| 47d1c6bf80 | |||
| 2077f871f8 | |||
| 0fcee02189 | |||
| fba8e35118 | |||
| 311df66231 | |||
| 0e8c5c7223 | |||
| 2f71b4be3c | |||
| 1063e5188c | |||
| dad9cda4ac | |||
| 1ae4bb2a36 | |||
| a8c5d357e6 | |||
| 289f4488f9 | |||
| 40224d8e56 | |||
| d760838e71 | |||
| 60fa5a818b | |||
| 837fc9bcc0 | |||
| aad11c71bb | |||
| 4fd4d68460 | |||
| 836ea6ecc7 | |||
| 18a48e80b4 | |||
| 5b94eb1af6 | |||
| 0524489ac2 | |||
| 37d021500a | |||
| a7b184fbd7 | |||
| 1a0159b7fc | |||
| 877a690635 | |||
| 2957c575e6 | |||
| 115df85063 | |||
| 8b07321fbb | |||
| 2d0d836d9a | |||
| 7c8374424d | |||
| 46622d9f42 | |||
| d3154a48b8 | |||
| 7ae595c91a | |||
| 9f73af5911 | |||
| 1cfdcb5fb3 | |||
| bd4b2a579e | |||
| ba12e04d1e | |||
| 7ffae78919 | |||
| d397c88c3c | |||
| 83b935c11b | |||
| 13e7a4c602 | |||
| c3f160afa5 | |||
| f4f7268045 | |||
| 50e70c43ab | |||
| f1fa5f7adf | |||
| ab7255a55b | |||
| 02e0dc20b8 | |||
| 8e828c1204 | |||
| 26edb9e6ed | |||
| 4a0e464308 | |||
| af68b20f87 | |||
| 7065dbb53e | |||
| 6f0357e41c | |||
| ec7d56d566 | |||
| 445c139bce | |||
| 1924e273e9 | |||
| be332a47ab | |||
| 01e8c608e7 | |||
| d4b4e1e165 | |||
| fe3b8624bf | |||
| 3ee281a433 | |||
| 736760aa31 | |||
| 8cbc86f6fa | |||
| 6bd3e76048 | |||
| 4735a18390 | |||
| c282327a0b | |||
| dacdab7adb | |||
| f0f9ba29f0 | |||
| 0b83c9a3c1 | |||
| db0c1c1fdc | |||
| 92bd114e71 | |||
| e69d82e7b1 | |||
| 5c0f535aca | |||
| d3b499b596 | |||
| d6086ec7b0 | |||
| 9d172ac170 | |||
| 2304e634ee | |||
| 68b743f18b | |||
| 63b7cd82a6 | |||
| c1922d9e26 | |||
| 541e397ca6 | |||
| f5d4410063 | |||
| 5c63604b5b | |||
| 1b27a3f1ca | |||
| d6b223ba25 | |||
| b6cf693e05 | |||
| 187c123071 | |||
| 402c3e2cb3 | |||
| 7f7090f433 | |||
| bcd5879a08 | |||
| 5688870788 | |||
| 36463f2119 | |||
| 75d553f99a | |||
| b468750d00 | |||
| 4179e0de23 | |||
| 7967f454ec | |||
| 7b73a2cf6e | |||
| 03f5b827e2 | |||
| e365fc84f8 | |||
| 17cfd6902b | |||
| 0ec4fb3534 | |||
| 0863614e66 | |||
| a2c60d319f | |||
| 39fb23bd16 | |||
| 5fa59680f2 | |||
| 620ee15a48 | |||
| 05da03c5ba | |||
| 02cff8ea63 | |||
| 2a2d23e0dc | |||
| 19121f6239 | |||
| e248b2b935 | |||
| c1f03d64d1 | |||
| ec23c0d77c | |||
| 5ee99f9441 | |||
| 05bda8915a | |||
| 8241cd704e | |||
| 3420c72c1d | |||
| 64e4c19531 | |||
| bc5d5b3d2e | |||
| e5909c9977 | |||
| 1474f69c73 | |||
| 11dba90780 | |||
| 92a7a2c478 | |||
| d0db577a9c | |||
| 672b9f9b46 | |||
| 417a2bf831 | |||
| 152ea6eec0 | |||
| 664047dbe0 | |||
| 1aea4674e3 | |||
| 69eb825d29 | |||
| 162ed7e406 | |||
| 8ca5b1d53b | |||
| f2736729fa | |||
| bde9e75eed | |||
| 34f614ea32 | |||
| 7a43ed6c43 | |||
| 0e4d680aef | |||
| 035ec9ac79 | |||
| 9712bdf538 | |||
| 5305d6dbc2 | |||
| 9998571770 | |||
| 9144bce33f | |||
| d773748ae9 | |||
| d64ef5284a | |||
| 87a6d20f88 | |||
| 57f75b8bc3 | |||
| 3b34ec3bef | |||
| f0e12b9b1b | |||
| ffc3963345 | |||
| dd569edc66 | |||
| 383ec544e1 | |||
| dc90ead263 | |||
| eced873779 | |||
| 0945882458 | |||
| 6c674f0f1d | |||
| 5e5056b99d | |||
| 9e58d28a99 | |||
| 89d5eda057 | |||
| b7a403dc22 | |||
| 4fb33bda1c | |||
| 2493019c27 | |||
| 58cfcfdf35 | |||
| a982da0262 | |||
| c8d14a5b1b | |||
| 44fc43912f | |||
| cf83752338 | |||
| c60ad48be5 | |||
| 29ddf5c780 | |||
| 5e71e1bb3d | |||
| ecc62f095b | |||
| 28f61eb70d | |||
| ef4ea8d24b | |||
| 79b3efd365 | |||
| 56afee0386 | |||
| c8250e5320 | |||
| 793bd4f9c8 | |||
| 445b7780c5 | |||
| 29625f703c | |||
| 5f4fcad2ef | |||
| 55517f996b | |||
| f18d488cea | |||
| ac2b15d72f | |||
| fa5a59e5cd | |||
| 759f0b15d8 | |||
| e2607ab723 | |||
| 0cc7380205 | |||
| 969c5a2a67 | |||
| 5314fa7745 | |||
| a9bc9ff52e | |||
| 6bf87aff13 | |||
| 9af7a5170a | |||
| 50518b5420 | |||
| d33316f093 | |||
| 93943bb51a | |||
| 89fff86333 | |||
| 01e00f4b98 | |||
| 9e8ecb57e5 | |||
| 745e3fe2c4 | |||
| e16aa63974 | |||
| dd0a32e89a | |||
| 3e45aa2a91 | |||
| ab55b20edd | |||
| 9e224929fb | |||
| 37eabcbb2e | |||
| 71606e9fe5 | |||
| 3fe8d5d05c | |||
| e896e0bef4 | |||
| f177a15105 | |||
| eaf457c6c0 | |||
| 21c92afa7a | |||
| 8f119198fd | |||
| 79e3513056 | |||
| 71b482df6d | |||
| be02833b11 | |||
| 173ea3b074 | |||
| f8dad27957 | |||
| b27a686998 | |||
| d7104d35da | |||
| b93d338eac | |||
| fdbf681292 | |||
| a98efb00f7 | |||
| a4ca9d5a19 | |||
| 22422bc9d2 | |||
| 9349f8ff33 | |||
| 980e6e91e0 | |||
| 35de13f7f1 | |||
| 1e1f533a24 | |||
| 432b2c52b2 | |||
| 9f58350b4a | |||
| 6e227aa377 | |||
| f63ab837f5 | |||
| d1870f1382 | |||
| c8cd851b2f | |||
| 14a41e64f1 | |||
| 7f4737c800 | |||
| 26f4bb3f25 | |||
| 0408c9752e | |||
| 483374744a | |||
| 19ddfb9c5a | |||
| 0f09cbec74 | |||
| 97ed407c32 | |||
| 4a75f7b96b | |||
| c7fb126761 | |||
| a4607b41fd | |||
| a75d8d38bf | |||
| 07ecaf355e | |||
| 7c3e5f399a | |||
| d705fd7a25 | |||
| fc7dfaaa5c | |||
| 4143fb5fbf | |||
| f725c358a1 | |||
| 8ea662dd5a | |||
| 830a7ccbef | |||
| 60bcd390a7 | |||
| b44a1a2cda | |||
| ee6541ae25 | |||
| e49466ffd3 | |||
| 8fd574c472 | |||
| dceb76c30c | |||
| 922b6ee9f7 | |||
| 779e5006d9 | |||
| 0f52c80e86 | |||
| 4d84d362cf | |||
| 6593b8f007 | |||
| 2fb56632c9 | |||
| e79f1015cb | |||
| 38e94e1f53 | |||
| 6e9a9f7347 | |||
| c08869f109 | |||
| a707e754f8 | |||
| 1b491d972a | |||
| cc41b5d81b | |||
| b03aaab493 | |||
| 5999b10643 | |||
| 2bcb8955a5 | |||
| 9accebd2b4 | |||
| 85c8c66c4d | |||
| 77bd83743b | |||
| eb158e76f0 | |||
| bd3af46cf8 | |||
| 72998b7d22 | |||
| 6804b2dea6 | |||
| bf38a1b9a0 | |||
| cc2722c104 | |||
| bb2f200d76 | |||
| 79961170c3 | |||
| 6600bfaa99 | |||
| abb262668c | |||
| 2da93414a5 | |||
| 6a470d1b39 | |||
| 58e91589df | |||
| 62bf1fb206 | |||
| 25d5a5a5e3 | |||
| b3f16433fc | |||
| 5caca86ad1 | |||
| 5f062df3cc | |||
| e60bd8567a | |||
| a52e39ad80 | |||
| 83b93eb39b | |||
| c19f59bb9e | |||
| 9bf25765dd | |||
| 0ce664d2b9 | |||
| c517711169 | |||
| 143ad3f6da | |||
| ba17e34b84 | |||
| 42bbf4904e | |||
| 2b613a8e5a | |||
| 4c70ca4101 | |||
| f1d1fe5c78 | |||
| 39e52858d1 | |||
| 678ba57347 | |||
| 04f45bebec | |||
| e9ba3689ba | |||
| 6a4a115260 | |||
| ba163aa4bd | |||
| 5105ca95c5 | |||
| adf0a5ff73 | |||
| ec9811c8a5 | |||
| f190896ea7 | |||
| baa43d80ba | |||
| c07e26a400 | |||
| 6f32ed86e4 | |||
| f48407ec7e | |||
| 9de4603484 | |||
| fb090bf80d | |||
| 5749a421cb | |||
| 54260551ee | |||
| 2de58b7afc | |||
| 45b23b559c | |||
| 2819fb3c6c | |||
| f15d2e1c22 | |||
| e2d6875ef9 | |||
| e377814c48 | |||
| 9b1978aec8 | |||
| 4e9c5d242e | |||
| ca32cde4fe | |||
| f8e4360482 | |||
| 9c9b8a6078 | |||
| a9cee8e9a1 | |||
| 8d91e599ab | |||
| dff38a04c7 | |||
| 8e9c79fc0e | |||
| 7b3feb4b1a | |||
| 305b897f2a | |||
| 9ec43e8922 | |||
| 7147fc464c | |||
| 8ea1577924 | |||
| 567cb1ab67 | |||
| 44abcdd4ef | |||
| 5bbf601480 | |||
| c0447c908e | |||
| adcfa28af3 | |||
| 15269c6ed9 | |||
| e7828dc926 | |||
| 5776217c2c | |||
| 91f760f789 | |||
| e8cedbcb50 | |||
| 97ae8a7c51 | |||
| ae95b294ec | |||
| 9ebb1a4012 | |||
| 48284be214 | |||
| 7f46b9f768 | |||
| a29d6e6ce4 | |||
| 687bc18510 | |||
| 1127e9c8bb | |||
| 68ebd387be | |||
| 5919ae12e9 | |||
| ed2900361c | |||
| d4ebe1926d | |||
| 98c45486fa | |||
| c609ffb279 | |||
| b92d3e688d | |||
| 751f4b89fd | |||
| 0d99baea04 | |||
| 61f8c86b02 | |||
| 7110d1086b | |||
| d23485029d | |||
| 639e8b989e | |||
| a0a232f504 | |||
| 173287e3d6 | |||
| f168e23dde | |||
| fec89b6b7b | |||
| 3f8326afc4 | |||
| 33d0f02c55 | |||
| 2ce37f0a1a | |||
| 7f44ca6383 | |||
| 6875abaa1a | |||
| b806ab9384 | |||
| 6b76333159 | |||
| 9a8fab2ce4 | |||
| 36bed2bdc6 | |||
| a9a72c7bdf | |||
| 95e314cef4 | |||
| 6f6d7be344 | |||
| 93ccb27b40 | |||
| f2546fc152 | |||
| 2f89f795f6 | |||
| add8b057d5 | |||
| 11e19ef4f1 | |||
| 790267560a | |||
| 0e4a1c1c35 | |||
| 76d9558851 | |||
| 2cd5e07248 | |||
| 5f7457a07b | |||
| cb4e10c87f | |||
| 76a51ac290 | |||
| 199345fd11 | |||
| 6e3b43d591 | |||
| ec28216984 | |||
| 24ea02f150 | |||
| f1db31f813 | |||
| 7f49ef596e | |||
| 23eddde770 | |||
| 0092092dbd | |||
| 8ea4d2f502 | |||
| 6594e1f5d7 | |||
| 4e4af7911a | |||
| f816fed4f5 | |||
| 7eccbc016a | |||
| a9cbd18246 | |||
| 70d724382d | |||
| 4a11fd612e | |||
| 6d488515ca | |||
| 064e13c132 | |||
| 81da7a182e | |||
| 3d5fd42bfa | |||
| 29b6353d7e | |||
| 9b5873bb84 | |||
| 77ae8b2823 | |||
| 07e99a5fa8 | |||
| 92858acb4d | |||
| e1217c9c85 | |||
| 795dd1084c | |||
| 423666ef99 | |||
| 0e3dbe450f | |||
| f517b7585f | |||
| dc69b002db | |||
| fb10077557 | |||
| d1ea8feb6f | |||
| 4030897d49 | |||
| e201b13301 | |||
| cbe0ec8bb2 | |||
| 4d91146256 | |||
| 59ee3c8154 | |||
| 3d085c1605 | |||
| d64ba3a827 | |||
| 1ccf4f74ef | |||
| 17a3292c78 | |||
| 99c0b7dd75 | |||
| 3b051bbafe | |||
| 68b7d9a4a4 | |||
| db6e8f0ce8 | |||
| 16bec1c0fa | |||
| 026aa4e0c3 | |||
| 9f8bdecc9e | |||
| 8c84ff3394 | |||
| 2039acdfe6 | |||
| 322905607a | |||
| 79596a970c | |||
| ea0a319c27 | |||
| d643ae156a | |||
| 75f23d4568 | |||
| 18db20099a | |||
| 7b238522ed | |||
| c287fe01a8 | |||
| 7b81b7aa01 | |||
| 427a8cb79f | |||
| 5f519f9cd5 | |||
| 338493ecaa | |||
| c8fb93ff29 | |||
| a11f44664f | |||
| 9ba7181212 | |||
| 5acf3c79ed | |||
| 205b0b71b4 | |||
| bc8870f957 | |||
| a659132469 | |||
| 8712df2645 | |||
| 5a750be066 | |||
| 159d52194c | |||
| b00ea71c1b | |||
| 7a7f1dfa21 | |||
| 5b1ccad40e | |||
| 38216a1885 | |||
| f7e26ee266 | |||
| 28e7fce11c | |||
| a821d306ac | |||
| 18db4f80bb | |||
| db1f7f2238 | |||
| 4775748447 | |||
| 9048bbb7f8 | |||
| 7c3c9e53a0 | |||
| 4ddb8b47b0 | |||
| 8ab36b1aaf | |||
| f1b7a7aae8 | |||
| bca1335dc6 | |||
| ba48bbc6af | |||
| cbde22ec79 | |||
| 69784b8d32 | |||
| 8543dad514 | |||
| 8a9126e626 | |||
| d8ca8de537 | |||
| aab4ce942c | |||
| 0ecf5cd45a | |||
| 021b0c618b | |||
| f44110fae5 | |||
| ac19637ad6 | |||
| 8672668c33 | |||
| 17236265c6 | |||
| c9efdf8b0e | |||
| c3d43aa26a | |||
| b0462df3c1 | |||
| 967eedcad7 | |||
| 98e0e54309 | |||
| eeb27e21ed | |||
| c85e5b278f | |||
| 8ab647c419 | |||
| 95ccb00d25 | |||
| ee9cf5f8c6 | |||
| e98a1a1207 | |||
| ea37d82d73 | |||
| 9835831415 | |||
| 080625567b | |||
| 266c0f17c1 | |||
| 225d13fb6e | |||
| 2ed1250604 | |||
| ca4a2cd07a | |||
| 73ac9187a6 | |||
| 7503e3fa8b | |||
| 532438faba | |||
| a1376b51b0 | |||
| 1e087c1aae | |||
| 2e2de02476 | |||
| aeb4e1710c | |||
| b4b80cb572 | |||
| 70e902e7ea | |||
| 14cebf22c3 | |||
| 73d25fcbcb | |||
| 01ecde45c5 | |||
| a2ebfc0b81 | |||
| 1dc2cac19a | |||
| 14db1e0cb1 | |||
| 01f4dbb83a | |||
| 0d63d6d75a | |||
| fe692fcd1d | |||
| 79b177b345 | |||
| 18b0c2d211 | |||
| e4e01c1686 | |||
| 648e7d2f14 | |||
| 0d78d63437 | |||
| 289b1c67ce | |||
| 5c990e651e | |||
| 52095eb992 | |||
| a4e4745921 | |||
| a2d0bd3c1c | |||
| b9275bc174 | |||
| 683a3934fc | |||
| e5d0b2d9ab | |||
| b0514c3e9a | |||
| d618a5abf0 | |||
| 8be12ca9bc | |||
| 5ca46b0a57 | |||
| afeeb8327c | |||
| a7d8f8be6c | |||
| 4d2da94692 | |||
| 8cd1a4e2b1 | |||
| b746812e23 | |||
| 3fbbf87c10 | |||
| b0e97f21a4 | |||
| a00ff1804c | |||
| c3810fdb7b | |||
| 203937335d | |||
| b16c63225f | |||
| 710b953120 | |||
| 45a45dc0fe | |||
| 3ca569ed1e | |||
| c315bb350c | |||
| 111f30d150 | |||
| 6d398b66bc | |||
| f46c231323 | |||
| 934919c699 | |||
| 12d84a22e4 | |||
| 9d4810eace | |||
| dc457aff9e | |||
| 3ce66a59ee | |||
| 578847d596 | |||
| 147b324658 | |||
| 6416c14f20 | |||
| e47c87f3a3 | |||
| add6e6aeb5 | |||
| 1ecce13814 | |||
| 7968cef8c3 | |||
| 7c2b154c20 | |||
| 34148b5d8a | |||
| 7ba916f00c | |||
| 79e408333d | |||
| af4f4a9ed4 | |||
| 74a7cd22b0 | |||
| aece8123c3 | |||
| e1cca219b8 | |||
| 70658041a5 | |||
| 4419c5bacd | |||
| 668226a99d | |||
| 4eec0dd5a4 | |||
| b315d11c28 | |||
| 8e60f50616 | |||
| 72faf0433a | |||
| f85e3be40e | |||
| 3616d64735 | |||
| 7f9116f12a | |||
| 01bae23df5 | |||
| 11f0d2c745 | |||
| b073bbe97d | |||
| 955a6439a0 | |||
| c6ecfb5b77 | |||
| 172917ac41 | |||
| ad2bfcd2f5 | |||
| a5f6898d06 | |||
| 83bd5839d0 | |||
| 83bc90ecf2 | |||
| 6ea3a960e7 | |||
| cbfc29e953 | |||
| fd2013b448 | |||
| b66465aa6a | |||
| a684fde472 | |||
| fbd1a4dbea | |||
| 824fa7b76c | |||
| be8a8492a9 | |||
| b429721070 | |||
| b352eea21d | |||
| 73d1dff21d | |||
| 51bf0aaa8c | |||
| d7d1021ec3 | |||
| 28a752265c | |||
| 735234f7bc | |||
| 1d9d138423 | |||
| 8c5edc6ad6 | |||
| e09ce6d13b | |||
| ee6fb5d33a | |||
| 46e55fa623 | |||
| cd2b437be5 | |||
| a92d1af4f2 | |||
| a504e7a13b | |||
| 1be28f10e9 | |||
| 325687d532 | |||
| 9c16c9c589 | |||
| 9760d1171c | |||
| 8711b205cf | |||
| d42ed57119 | |||
| e316adca1f | |||
| 18208f691c | |||
| 0457fbfac0 | |||
| c06a4d0e06 | |||
| 58df800685 | |||
| f21934e55b | |||
| 7c198f7d6f | |||
| 515135c120 | |||
| ec4d1b2567 | |||
| 42bdd59c71 | |||
| 4ff4d8cfdc | |||
| 8be85fd332 | |||
| e4bf104ae2 | |||
| b96b136fa3 | |||
| 5105bf7049 | |||
| 02ddfc7a76 | |||
| 08997e9e20 | |||
| 8defef904f | |||
| 9146d17625 | |||
| 13c3a04a48 | |||
| 1aca3d6152 | |||
| 60a6494260 | |||
| 052bb31aea | |||
| 995e2ee65a | |||
| 225b525ba1 | |||
| 7f83bceba1 | |||
| e1543416e3 | |||
| 1eb622d33f | |||
| 0b57aea5f6 | |||
| 5d8ee8fe79 | |||
| a04c2f9a19 | |||
| 6f1b8e46f5 | |||
| c352c34501 | |||
| f9b2d2da25 | |||
| 5c9671df44 | |||
| 26a920a1cc | |||
| 8a8d3c5cd9 | |||
| e695fd5184 | |||
| d272afae1c | |||
| 0caf62c3d2 | |||
| 03e697f5d3 | |||
| 326f78705d | |||
| c502afb588 | |||
| afa8e44909 | |||
| 3fada5d198 | |||
| 72fdb1841c | |||
| c0fdea6570 | |||
| 34bc980eea | |||
| 0391cb223f | |||
| 2dab555ca5 | |||
| b25111e4b4 | |||
| d537924aa9 | |||
| 2f2db4986e | |||
| dc6ecc1edf | |||
| 6f970b3783 | |||
| 95d5c82474 | |||
| 87507708ce | |||
| f6e83352d7 | |||
| c6ae7ca170 | |||
| 46f46039ea | |||
| 6894f9cc57 | |||
| 8c4a6cd12a | |||
| 524d8763ce | |||
| 236b73755c | |||
| 1e845a1510 | |||
| 0341838d19 | |||
| b04b05e4da | |||
| d691e53886 | |||
| ea35273597 | |||
| 72c8167472 | |||
| dabb278170 | |||
| 9b1138c83e | |||
| 7b12cebb45 | |||
| dc5e23892f | |||
| 9d75d673f8 | |||
| 4f8cbc3e38 | |||
| 8d97f5318c | |||
| 3ffbb2b004 | |||
| 34ed15a9bd | |||
| 110f407ae2 | |||
| 4b6295dd44 | |||
| 8db9f3a408 | |||
| 01116d5607 | |||
| 2ae720ae09 | |||
| 07904a29aa | |||
| f87c37528b | |||
| 8d683a791d | |||
| 71b09a89de | |||
| ef0e0df0ac | |||
| d5764f3b50 | |||
| ac07416352 | |||
| 4e5ed76cb6 | |||
| 025ca6d4fd | |||
| ecc8b6ce6c | |||
| 951a353881 | |||
| 9ad6e037dc | |||
| eb04caccf1 | |||
| 4a58b366b6 | |||
| cd84def61d | |||
| bbc833f2c9 | |||
| d8098b0378 | |||
| 325c2f7c82 | |||
| 62d30ec190 | |||
| 728eea4b83 | |||
| d0d3c6ee67 | |||
| e53eaf738e | |||
| 21b6b5b270 | |||
| ad2bb0a6ea | |||
| 365050b890 | |||
| 7589b4e418 | |||
| 73392a9b83 | |||
| b400b494ad | |||
| c47c03fde4 | |||
| 9a59dac6d0 | |||
| 86fd9475e4 | |||
| 03a85d5523 | |||
| 2d0d1d3461 | |||
| ccaec4a984 | |||
| 169ba7edb6 | |||
| 0327d1cc51 | |||
| e02ddab599 | |||
| 336338cff5 | |||
| acff31e652 | |||
| ad304a6880 | |||
| cb34788e53 | |||
| 13b0ffb5d8 | |||
| c9947c4ac8 | |||
| afffb7aad2 | |||
| 9720453ac4 | |||
| 1ff6d5220e | |||
| 46d91fd8ca | |||
| a24db2f73c | |||
| ca9537f862 | |||
| 94ae7e68ff | |||
| 94e1930538 | |||
| 5bbe5a3077 | |||
| 8cead01270 | |||
| 99fc14b9f9 | |||
| d3671206e1 | |||
| 0a8202788b | |||
| 855f1affd9 | |||
| 5a294e5c85 | |||
| df606a1087 | |||
| ece3552b89 | |||
| 4df3945131 | |||
| 6eb0f33421 | |||
| 25ce9f74b8 | |||
| 0f1f471590 | |||
| d9487b6885 | |||
| 9845ab8f2a | |||
| 6fa130386a | |||
| 53df8b9971 | |||
| d6625762cf | |||
| cb3b9e9cfe | |||
| 3d39236b13 | |||
| 9e57fa5762 | |||
| 9c6232bc85 | |||
| d3c7938627 | |||
| 06256946fa | |||
| 2042d386e2 | |||
| 7176754564 | |||
| a20222192e | |||
| a5c2681e88 | |||
| 5e2f750359 | |||
| 27602890ab | |||
| dfe0d652ce | |||
| 24076adf98 | |||
| 15a78abc1b |
@@ -1,12 +0,0 @@
|
||||
# 仓库内文本 blob 全部是 LF(2026-09-28 取证:git grep -P '\r' 在 HEAD 上 0 命中),
|
||||
# 但开发机 core.autocrlf=true 会在检出时改写为 CRLF。快照类测试拿 Files.readString 读
|
||||
# golden 后与代码里 append('\n') 生成的字符串逐字节比对,检出形态一变就整片红。
|
||||
# 这里把"断言会读到的文本"钉成 LF,checkout 时不再被 autocrlf 转换。
|
||||
# 只列扩展名、不写 `* text`:避免 git 去归一化 jar/png/zip 等二进制产物。
|
||||
*.txt text eol=lf
|
||||
*.md text eol=lf
|
||||
*.sql text eol=lf
|
||||
*.yml text eol=lf
|
||||
*.yaml text eol=lf
|
||||
*.json text eol=lf
|
||||
*.sh text eol=lf
|
||||
@@ -43,40 +43,6 @@ jobs:
|
||||
- name: Type check (vue-tsc)
|
||||
working-directory: frontend-vue
|
||||
run: npm run build
|
||||
- name: Frontend contract tests (npm test → node --test)
|
||||
- name: Frontend contract tests (node --test)
|
||||
working-directory: frontend-vue
|
||||
run: npm test
|
||||
|
||||
admin-frontend-test:
|
||||
# 2026-10-08 加:后管此前是 0 CI 覆盖(本 workflow 只有 backend-java 与 frontend-vue 两个 job,
|
||||
# `.gitea` 下 grep admin-frontend-vue 命中 0)⇒ 1,7xx 例契约/棘轮用例与 vue-tsc 只能手跑。
|
||||
# 本机实跑过的:npm install(112 包 3m34s,再 72 包 2m35s)→ vue-tsc --noEmit 退出 0(49.7s)
|
||||
# → node --test tests/*.test.ts 1,764 例全绿 → vitest run 挂载例 7 例全绿 → npm ci 复现通过。
|
||||
# 没跑的那半:`npm run build` 的后半 `vite build` 本机没执行——它会重写 dist/,
|
||||
# 而 dist/ 正是 scripts/_deploy_admin_vue.py 的发布输入,脏树上构建会把别人未提交的改动带进产物。
|
||||
#
|
||||
# ⚠ 前提未证实,别把这个 job 当成"CI 会跑":Gitea 26.4.5 的匿名接口
|
||||
# /api/v1/repos/super/crawler-plugin/actions/tasks 只列得出 3 次 run,最后一个停在
|
||||
# 2026-08-11T14:50(三次 status 全为 failure);此后 origin/master 又推进了 1,131 笔
|
||||
# (含 2026-10-08 12:14:57 那次 push,仓库 updated_at 也是这一刻)却没有产生任何新 run。
|
||||
# ⇒ 只能证到"这条 workflow 历史上真被 runner 执行过",证不到"现在还在执行"。
|
||||
# 要让它真兜住这一面,先恢复 runner / 确认 Actions 未被关停。
|
||||
runs-on: ubuntu-latest
|
||||
container: node:24-alpine
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Install dependencies
|
||||
working-directory: admin-frontend-vue
|
||||
run: npm ci
|
||||
- name: Type check + build (vue-tsc --noEmit && vite build)
|
||||
working-directory: admin-frontend-vue
|
||||
run: npm run build
|
||||
- name: Admin contract & ratchet tests (node --test, 不是 vitest)
|
||||
working-directory: admin-frontend-vue
|
||||
run: node --test tests/*.test.ts
|
||||
- name: Admin component mount tests (vitest + @vue/test-utils + jsdom)
|
||||
working-directory: admin-frontend-vue
|
||||
run: npm run test:mount
|
||||
|
||||
|
||||
+3
-57
@@ -14,8 +14,6 @@ backend-java/target/
|
||||
backend-java/data/
|
||||
backend-java/*.log
|
||||
backend-java/logs/
|
||||
# 会话级诊断脚本残渣(2026-11-03 瘦身审计 BD-8:_diag_keyword_sync.py 有误提交风险)
|
||||
backend-java/tmp/
|
||||
backend-java/src/main/resources/application-local.yml
|
||||
backend-java/.idea/
|
||||
backend-java/*.iml
|
||||
@@ -114,10 +112,10 @@ OPS_REDIS_MYSQL_OPTIMIZATION_NOTES.md
|
||||
*ts.%
|
||||
.omc
|
||||
|
||||
# ===== 规划文档 =====
|
||||
# docs/plans/ 与 backend-java/docs/plans/ 已从「本地不入库」改为入库(2026-10-04 用户拍定):
|
||||
# 实施计划要跨会话留存,被 gitignore 的文件在干净 worktree 出包时不存在,护栏用例也读不到。
|
||||
# ===== 本地规划文档(不入库)=====
|
||||
docs/plans/
|
||||
docs/*plan*.md
|
||||
backend-java/docs/plans/
|
||||
backend-java/docs/*plan*.md
|
||||
backend-java/docs/specs/
|
||||
backend-java/docs/*audit*.md
|
||||
@@ -135,55 +133,3 @@ scripts/test_task_*.py
|
||||
scripts/*_scan.py
|
||||
scripts/*_migration.py
|
||||
data/logs/
|
||||
|
||||
# ===== 本地临时目录(出包 worktree / 验证日志,不入库)=====
|
||||
/tmp/
|
||||
|
||||
# 生产库转储永不再入库(本体只留 backend-java/data/,那里已被忽略)
|
||||
backend-java/src/main/resources/db/aiimage.sql
|
||||
|
||||
# ===== 文档与参考资料不入库(2026-11-19 用户拍板:docs/reference 及非源码内容不提交,只留本地;
|
||||
# 取代上面「规划文档入库」的 2026-10-04 口径——当前实测本仓 0 支 docs/md 跟踪件)=====
|
||||
/docs/
|
||||
/reference/
|
||||
|
||||
# 打包前由 scripts/_git_stamp.py write 生成,随 jar 进 BOOT-INF/classes/;
|
||||
# 入库会变成"孤儿构建产物"(10-07 那笔 target/classes 里的 V148 就是这个形状造成的宕机)
|
||||
backend-java/src/main/resources/git.properties
|
||||
|
||||
# ===== 2026-10-15 瘦身审计 P0-6:补仓根日志与压缩包(§2 那 10 支历史大对象就从这个口子进来的)
|
||||
*.log
|
||||
/*.log
|
||||
*.zip
|
||||
app/update/
|
||||
app/user_data/
|
||||
target/
|
||||
*.pid
|
||||
|
||||
# ===== 2026-10-18 重构蓝图 Phase 1:只堵未来的口子(审计报告 §4.1(b))=====
|
||||
# 本仓此前 0 支构建产物入库(实测 git ls-files -i -c --exclude-standard=0),下面每条都是
|
||||
# "今天没踩到、将来会踩到"的产物面;纯新增忽略,不改任何现存规则的行为。
|
||||
# 注意:gitignore 的行内 # 不是注释(会被当模式的一部分),所以说明一律单起一行。
|
||||
# node_modules:原只写了 frontend-vue/node_modules/,admin 靠子文件兜 ⇒ 提为通用
|
||||
node_modules/
|
||||
.vite/
|
||||
**/.vite/
|
||||
playwright-report/
|
||||
blob-report/
|
||||
test-results/
|
||||
surefire-reports/
|
||||
failsafe-reports/
|
||||
# Java 编译产物此前没人挡(原只有 *$py.class)
|
||||
*.class
|
||||
*.tsbuildinfo
|
||||
*.pyd
|
||||
# Windows 原生扩展与打包残留;本仓 0 支跟踪件用这些后缀(亲测 git ls-files 计数为 0)
|
||||
*.dll
|
||||
# 关键:*.log 匹配不到 aiimage-backend.log.2026-10-11.0 这类轮转名
|
||||
*.log.*
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
desktop.ini
|
||||
# ⚠ 报告另建议把遗留的 lib//parts//var/ 收窄成 /build/、/dist/ 式根锚定前缀,本轮不做:
|
||||
# 实测盘上有 53 个 lib、87 个 dist、19 个 bin 目录,收窄等于把今天被挡住的产物一次性放成 ?? 噪声,
|
||||
# 与 Phase 1「零行为变更」的定性冲突;而它们造成的实害今天是 0(ls-files -i -c 亲测)。单独拍板。
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
import { expect, test } from '@playwright/test'
|
||||
|
||||
const brandPath = '/admin-vue/asin-center/invalid'
|
||||
|
||||
test('品牌数据库:单行筛选控件等高、底边对齐,窄屏可以换行', async ({ page }) => {
|
||||
await page.goto(brandPath)
|
||||
const filters = page.locator('.invalid-filter-row')
|
||||
await expect(filters.getByRole('button', { name: '查询' })).toBeVisible()
|
||||
const controls = [
|
||||
filters.getByPlaceholder('输入 ASIN'),
|
||||
filters.getByPlaceholder('输入品牌'),
|
||||
filters.locator('.el-select__wrapper'),
|
||||
filters.getByRole('button', { name: '查询' }),
|
||||
]
|
||||
const boxes = await Promise.all(controls.map((control) => control.evaluate((el) => {
|
||||
const { height, bottom } = el.getBoundingClientRect()
|
||||
return { height, bottom }
|
||||
})))
|
||||
expect(boxes.map((box) => box.height)).toEqual([34, 34, 34, 34])
|
||||
expect(Math.max(...boxes.map((box) => box.bottom)) - Math.min(...boxes.map((box) => box.bottom))).toBeLessThan(1)
|
||||
|
||||
const batchDelete = page.getByRole('button', { name: '批量删除(0)' })
|
||||
await expect(batchDelete).toBeDisabled()
|
||||
const batchBox = await batchDelete.boundingBox()
|
||||
const tableBox = await page.locator('.invalid-asin-table-scroll').boundingBox()
|
||||
expect(batchBox?.height).toBe(34)
|
||||
expect(tableBox!.y - batchBox!.y - batchBox!.height).toBeGreaterThanOrEqual(8)
|
||||
|
||||
await page.setViewportSize({ width: 680, height: 900 })
|
||||
await expect.poll(async () => filters.evaluate((row) => {
|
||||
const first = row.firstElementChild!.getBoundingClientRect()
|
||||
const last = row.lastElementChild!.getBoundingClientRect()
|
||||
return last.top >= first.bottom && last.right <= row.getBoundingClientRect().right + 1
|
||||
})).toBe(true)
|
||||
})
|
||||
|
||||
test('品牌数据库:键盘搜索分组、查询和新增仍可用', async ({ page }) => {
|
||||
await page.goto(brandPath)
|
||||
const filters = page.locator('.invalid-filter-row')
|
||||
await filters.getByPlaceholder('输入品牌').press('Tab')
|
||||
const group = filters.getByRole('combobox')
|
||||
await expect(group).toBeFocused()
|
||||
await group.fill('测试')
|
||||
await expect(page.getByRole('option', { name: '测试分组' })).toBeVisible()
|
||||
await expect(page.getByRole('option', { name: '其他分组' })).not.toBeVisible()
|
||||
await page.getByRole('option', { name: '测试分组' }).click()
|
||||
await filters.getByPlaceholder('输入 ASIN').fill('B0INVALID1')
|
||||
const queried = page.waitForRequest((req) => new URL(req.url()).pathname === '/api/admin/invalid-asin-data' && req.url().includes('group_id=1'))
|
||||
await filters.getByRole('button', { name: '查询' }).click()
|
||||
const params = new URL((await queried).url()).searchParams
|
||||
expect(params.get('data_value')).toBe('B0INVALID1')
|
||||
expect(params.get('page')).toBe('1')
|
||||
await page.getByRole('button', { name: '新增', exact: true }).click()
|
||||
const dialog = page.getByRole('dialog')
|
||||
await expect(dialog.getByRole('button', { name: '保存' })).toBeVisible()
|
||||
await dialog.getByRole('button', { name: '取消' }).click()
|
||||
await expect(dialog).not.toBeVisible()
|
||||
})
|
||||
@@ -1,159 +0,0 @@
|
||||
import { expect, test, type Locator } from '@playwright/test'
|
||||
|
||||
// 独立的可见菜单清单;不从运行时路由反推夹具,以免漏注册时测试仍然全绿。
|
||||
const shared = [
|
||||
['admin_users', '用户管理', 'account/users', '.form-row'],
|
||||
['admin_columns', '菜单管理', 'account/menus', '.form-row'],
|
||||
['admin_group_manage', '数据权限分组', 'account/groups', '.form-row'],
|
||||
['admin_companies', '公司管理', 'account/companies', '.form-row'],
|
||||
] as const
|
||||
const amazon = [
|
||||
...shared,
|
||||
['admin_user_secrets', '密钥管理', 'account/user-secrets', '.form-row'],
|
||||
['admin_user_secret_usage', '密钥用量统计', 'account/user-secret-usage', '.form-row'],
|
||||
['admin_shop_data_duplicate_check', '店铺撞款监控', 'shop-center/duplicate-check', '.filter-row'],
|
||||
['admin_brand_gating', '品牌Gating库', 'shop-center/brand-gating', '.g-filters'],
|
||||
['admin_keyword_usage', '关键词使用记录', 'shop-center/keyword-usage', '.kw-filters'],
|
||||
['admin_shop_keys', '店铺密钥管理', 'shop-center/keys', '.form-row'],
|
||||
['admin_shop_manage', '店铺管理', 'shop-center/shops', '.form-row'],
|
||||
['admin_history', '生成记录', 'records/history', '.form-row'],
|
||||
['admin_version', '软件版本管理', 'records/software-version', '.admin-header-controls'],
|
||||
['admin_tutorial', '教程管理', 'records/tutorial', '.admin-header-controls'],
|
||||
['admin_workbench_client_package', '数富AI工作台客户端包管理', 'records/workbench-client-package', '.admin-header-controls'],
|
||||
['admin_device_logs', '日志管理', 'records/device-logs', '.form-row'],
|
||||
['admin_task_center', '客户端任务管理', 'task-center/board', '.form-row'],
|
||||
['digital_human_version', '数字人版本管理', 'records/digital-human-version', '.admin-header-controls'],
|
||||
['admin_image_video_tasks', '视频任务记录', 'records/image-video-tasks', '.form-row'],
|
||||
['admin_shop_data_crawl_tasks', '店铺数据记录', 'shop-center/data-tasks', '.form-row'],
|
||||
['admin_dedupe_total_data', '数据去重总数据', 'asin-center/registry', '.dedupe-filter-row'],
|
||||
['admin_invalid_asin_data', '品牌数据库', 'asin-center/invalid', '.form-row'],
|
||||
['admin_query_asin', '查询ASIN', 'asin-center/query', '.form-row'],
|
||||
['admin_product_categories', '商品类目', 'asin-center/categories', '.admin-header-controls'],
|
||||
['admin_skip_price_asin', '最低价ASIN', 'asin-center/skip-price', '.form-row'],
|
||||
['admin_appearance_patent_clean_items', '外观专利数据库', 'patent-center/clean-items', '.clean-filter-row'],
|
||||
] as const
|
||||
const jdDatabase = ['admin_jd_database', '京东数据库', 'jd-center/database', '.jd-filter-row'] as const
|
||||
const jd = [...shared, jdDatabase]
|
||||
const allMenus = [...amazon, jdDatabase].map(([key, name, path]) => ({ key, name, route: `/${path}` }))
|
||||
|
||||
const emptyPage = { items: [], total: 0 }
|
||||
const fixtures: Record<string, unknown> = {
|
||||
'/api/admin/appearance-patent-clean-items': emptyPage,
|
||||
'/api/admin/brand-gating': emptyPage,
|
||||
'/api/admin/brand-gating/stats': { total: 0 },
|
||||
'/api/admin/companies': { items: [{ id: 1, name: '测试公司' }], total: 1 },
|
||||
'/api/admin/device-logs/files': emptyPage,
|
||||
'/api/admin/history': emptyPage,
|
||||
'/api/admin/image-video-tasks': emptyPage,
|
||||
'/api/admin/jd-product-groups': { items: [{ id: 1, name: '测试分类' }] },
|
||||
'/api/admin/jd-product-groups/scope': {
|
||||
platformSuperAdmin: true, defaultGroupId: 1,
|
||||
groups: [{ id: 1, name: '测试分组', label: '测试分组', editable: true }, { id: 2, name: '其他分组', label: '其他分组', editable: true }],
|
||||
},
|
||||
'/api/admin/jd-products': emptyPage,
|
||||
'/api/admin/jd-products/categories': [],
|
||||
'/api/admin/keyword-usage': emptyPage,
|
||||
'/api/admin/keyword-usage/deletes': emptyPage,
|
||||
'/api/admin/keyword-usage/overview': {},
|
||||
'/api/admin/shop-data-crawl-tasks': emptyPage,
|
||||
'/api/admin/shop-keys': emptyPage,
|
||||
'/api/admin/shop-manages': emptyPage,
|
||||
'/api/admin/shop-manages/groups': [{ id: 1, group_name: '测试分组' }],
|
||||
'/api/admin/task-center/overview': { runningTasks: 0, todayFinishedTasks: 0, stuckTasks: 0 },
|
||||
'/api/admin/task-center/shop-options': { items: ['测试店铺'] },
|
||||
'/api/admin/task-center/tasks': emptyPage,
|
||||
'/api/admin/task-center/variant-tasks': emptyPage,
|
||||
'/api/admin/user-secret-usage': emptyPage,
|
||||
'/api/admin/versions': emptyPage,
|
||||
'/api/admin/workbench-client/packages': emptyPage,
|
||||
'/api/digital-human/versions': emptyPage,
|
||||
}
|
||||
|
||||
// 这些接口在 mock-admin-server 里已经有专门的响应,不吃通用兜底。
|
||||
const serverFixtures = new Set([
|
||||
'/api/admin/current-user', '/api/admin/notifications/summary', '/api/admin/users',
|
||||
'/api/admin/permission-menus', '/api/admin/user-secrets', '/api/admin/user-secrets/balances',
|
||||
'/api/admin/shop-data-crawl/duplicate-check-console', '/api/admin/shop-data-crawl/duplicate-check-ledger',
|
||||
'/api/admin/tutorials', '/api/admin/invalid-asin-data', '/api/admin/invalid-asin-data/groups',
|
||||
'/api/admin/dedupe-total-data', '/api/admin/query-asins', '/api/admin/product-categories/children',
|
||||
'/api/admin/skip-price-asins',
|
||||
])
|
||||
|
||||
async function controlDeviations(row: Locator) {
|
||||
await expect(row).toBeVisible()
|
||||
return row.evaluate((el) => {
|
||||
const selector = 'input[type="text"], input[type="number"], input[type="date"], input[type="datetime-local"], select, .el-select__wrapper:not(.is-multiple), button:not(.btn-sm), .admin-header-controls > .btn'
|
||||
const controls = Array.from(el.querySelectorAll<HTMLElement>(selector)).flatMap((control) => {
|
||||
if (control.matches('.el-select__input, .el-input__inner') || control.closest('[role="listbox"], .cat-panel')) return []
|
||||
const box = control.getBoundingClientRect()
|
||||
if (!box.width || !box.height) return []
|
||||
const name = control.getAttribute('placeholder') || control.textContent?.trim() || control.className
|
||||
return [{ name, box }]
|
||||
})
|
||||
if (!controls.length) return ['没有测到可见控件']
|
||||
const failures = controls.filter(({ box }) => Math.abs(box.height - 34) >= 1)
|
||||
.map(({ name, box }) => `${name}: ${box.height}px`)
|
||||
for (const [index, { name, box }] of controls.entries()) {
|
||||
for (const other of controls.slice(index + 1)) {
|
||||
const overlapY = Math.min(box.bottom, other.box.bottom) - Math.max(box.top, other.box.top)
|
||||
if (overlapY < 17) continue
|
||||
if (Math.abs(box.bottom - other.box.bottom) >= 1) failures.push(`${name} / ${other.name} 底边未对齐`)
|
||||
}
|
||||
}
|
||||
return failures
|
||||
})
|
||||
}
|
||||
|
||||
for (const [platform, menus] of [['亚马逊', amazon], ['京东', jd]] as const) {
|
||||
test(`${platform}:逐个点击侧栏菜单,检查筛选区外框`, async ({ page, baseURL }) => {
|
||||
test.setTimeout(120_000)
|
||||
const pageErrors: string[] = []
|
||||
const missingFixtures = new Set<string>()
|
||||
page.on('pageerror', (error) => pageErrors.push(error.message))
|
||||
await page.route('**/*', async (route) => {
|
||||
const url = new URL(route.request().url())
|
||||
if (url.origin !== baseURL) return route.abort()
|
||||
if (url.pathname === '/api/admin/current-user/menus') {
|
||||
return route.fulfill({ json: { success: true, data: { items: allMenus } } })
|
||||
}
|
||||
if (Object.hasOwn(fixtures, url.pathname)) {
|
||||
return route.fulfill({ json: { success: true, data: fixtures[url.pathname] } })
|
||||
}
|
||||
if (url.pathname.startsWith('/api/') && !serverFixtures.has(url.pathname)) {
|
||||
missingFixtures.add(url.pathname)
|
||||
return route.abort()
|
||||
}
|
||||
return route.continue()
|
||||
})
|
||||
await page.goto('/admin-vue/')
|
||||
await page.getByRole('tab', { name: platform }).click()
|
||||
const sidebar = page.locator('.admin-menu')
|
||||
await expect(sidebar.getByRole('menuitem')).toHaveCount(menus.length)
|
||||
const deviations: string[] = []
|
||||
for (const [, name, path, selector] of menus) {
|
||||
await test.step(name, async () => {
|
||||
await sidebar.getByRole('menuitem', { name, exact: true }).click()
|
||||
await expect(page).toHaveURL(new RegExp(`/admin-vue/${path}$`))
|
||||
await expect(page.locator('.admin-topbar h1')).toHaveText(name)
|
||||
const content = page.locator('#admin-content')
|
||||
await expect(content.locator('.load-failure-bar:visible, .page-error:visible')).toHaveCount(0)
|
||||
const record = async (label: string, row: Locator) => {
|
||||
const mismatches = await controlDeviations(row)
|
||||
if (mismatches.length) deviations.push(`${name}${label}:${mismatches.join('、')}`)
|
||||
}
|
||||
await record('', content.locator(`${selector}:visible`).first())
|
||||
if (path === 'asin-center/registry') {
|
||||
await record('日期导出', content.locator('.dedupe-filter-date-row'))
|
||||
}
|
||||
if (path === 'task-center/board') {
|
||||
await content.getByRole('button', { name: /^变体采集/ }).click()
|
||||
await expect(content.getByRole('heading', { name: '变体采集(麦象批量任务)' })).toBeVisible()
|
||||
await record('变体采集', content.locator('.form-row:visible'))
|
||||
}
|
||||
})
|
||||
}
|
||||
expect.soft(pageErrors).toEqual([])
|
||||
expect.soft([...missingFixtures], '逐菜单验收不能使用未登记的空响应').toEqual([])
|
||||
expect(deviations).toEqual([])
|
||||
})
|
||||
}
|
||||
@@ -32,9 +32,7 @@ test('test_dup_console_render_ledger_tab_normal_variant_input', async ({ page })
|
||||
await expect(page.locator('.dup-head h2')).toHaveText('店铺数据撞款监控')
|
||||
await page.getByRole('button', { name: /全部ASIN台账/ }).click()
|
||||
await expect(page.locator('table.ledger tbody tr').first()).toBeVisible({ timeout: 15000 })
|
||||
// 台账 tab 下页面同时有「店铺上架分布」分页器(常显,见 tests/align-dup-console.test.ts)与台账分页器,
|
||||
// 全页 .old-pagination 会命中 2 个元素触发 strict mode;限定到台账表格(.table-wrap)紧邻的分页器。
|
||||
await expect(page.locator('.table-wrap + .old-pagination')).toBeVisible()
|
||||
await expect(page.locator('.old-pagination')).toBeVisible()
|
||||
expect(errors).toEqual([])
|
||||
await page.locator('.table-wrap').screenshot({ path: 'test-results/dup-console-admin-ledger.jpg' })
|
||||
})
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
import { expect, test, type Page } from '@playwright/test'
|
||||
|
||||
// 后台管理列表「创建时间 + 更新时间」两列验收(2026-09-19 需求):
|
||||
// 8 个实体管理列表统一展示创建/更新时间,数据取自各列表 VO。
|
||||
// mock 夹具统一给 createdAt=2026-03-01 09:15:00、updatedAt=2026-09-18 16:42:30,
|
||||
// 页面统一经 formatDateTime 归一为「YYYY-MM-DD HH:mm:ss」。
|
||||
|
||||
const CREATED = '2026-03-01 09:15:00'
|
||||
const UPDATED = '2026-09-18 16:42:30'
|
||||
|
||||
const PAGES: Array<{ title: string; path: string; heading: string }> = [
|
||||
{ title: '用户管理', path: '/admin-vue/account/users', heading: '用户列表' },
|
||||
{ title: '菜单管理', path: '/admin-vue/account/menus', heading: '菜单' },
|
||||
{ title: '密钥管理', path: '/admin-vue/account/user-secrets', heading: '用户密钥列表' },
|
||||
{ title: '品牌数据库', path: '/admin-vue/asin-center/invalid', heading: '品牌数据列表' },
|
||||
{ title: '数据去重总数据', path: '/admin-vue/asin-center/registry', heading: '数据去重总数据' },
|
||||
{ title: '查询ASIN', path: '/admin-vue/asin-center/query', heading: '查询' },
|
||||
{ title: '最低价ASIN', path: '/admin-vue/asin-center/skip-price', heading: '最低价' },
|
||||
{ title: '商品类目', path: '/admin-vue/asin-center/categories', heading: '商品类目' },
|
||||
]
|
||||
|
||||
async function openPage(page: Page, path: string) {
|
||||
await page.goto(path)
|
||||
await expect(page.locator('.panel-box table tbody tr').first()).toBeVisible({ timeout: 15000 })
|
||||
}
|
||||
|
||||
for (const spec of PAGES) {
|
||||
test(`${spec.title}:表格展示创建时间与更新时间`, async ({ page }) => {
|
||||
const errors: string[] = []
|
||||
page.on('pageerror', (error) => errors.push(error.message))
|
||||
|
||||
await openPage(page, spec.path)
|
||||
|
||||
const table = page.locator('.panel-box table').first()
|
||||
// 表头出现两列
|
||||
await expect(table.locator('thead')).toContainText('创建时间')
|
||||
await expect(table.locator('thead')).toContainText('更新时间')
|
||||
// 数据行渲染出真实时间值(非空、非占位符)
|
||||
await expect(table.locator('tbody')).toContainText(CREATED)
|
||||
await expect(table.locator('tbody')).toContainText(UPDATED)
|
||||
|
||||
expect(errors).toEqual([])
|
||||
})
|
||||
}
|
||||
@@ -1,280 +0,0 @@
|
||||
import { expect, test, type Page } from '@playwright/test'
|
||||
|
||||
// 站内通知铃铛面板验收:聚合视图(场景 × 自然日 × 事件主体用户)、展开明细、
|
||||
// 关键字/年月日区间搜索、按组分页、红点按组数。
|
||||
// 依赖 scripts/mock-admin-server.mjs 的通知夹具:14 行折成 10 组、2 组未读、3 行未读。
|
||||
// 夹具的 id 与 createdAt 同为插入时单调(与真库一致),场景显式写在夹具里而不是从 id 推。
|
||||
|
||||
// 夹具会被"标记已读"改写,而 mock 服务在 reuseExistingServer 下跨轮存活 ⇒ 每条用例前重置,
|
||||
// 否则第二遍跑会带着上一遍的已读态,绝对计数断言全漂。
|
||||
test.beforeEach(async ({ request }) => {
|
||||
await request.post('/api/admin/notifications/__reset')
|
||||
})
|
||||
|
||||
async function clearDateFilter(page: Page) {
|
||||
const picker = page.locator('.bell-panel .bell-date-picker')
|
||||
await picker.hover()
|
||||
await picker.locator('.el-range__close-icon').click()
|
||||
await expect(page.locator('.bell-page-total')).toHaveText('共 10 组 · 明细 14 条')
|
||||
}
|
||||
|
||||
async function openBell(page: Page) {
|
||||
await page.goto('/admin-vue/')
|
||||
await expect(page.locator('.admin-topbar h1')).toHaveText('用户管理')
|
||||
await page.locator('.admin-notification-bell .bell-trigger').click()
|
||||
await expect(page.locator('.bell-panel')).toBeVisible()
|
||||
// 面板默认按「当天」过滤,夹具是 09-10~09-13:先清空日期才能拿到全量
|
||||
await clearDateFilter(page)
|
||||
await expect(page.locator('.bell-group').first()).toBeVisible()
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开日历并等入场动画落定。
|
||||
*
|
||||
* 两件事必须先做对,否则读数全是假的:
|
||||
* ① 弹层节点是常驻的(Element 用 v-show),未打开时它也在 DOM 里、rect 全 0,
|
||||
* 所以 `toBeAttached()` 不能当「已打开」的判据;
|
||||
* ② 打开瞬间 el-zoom-in-top 把弹层 scaleY 压到 0,格子坐标整体贴到面板顶部,
|
||||
* 此时做命中测试会把「动画中」读成「被面板遮挡」。
|
||||
*/
|
||||
async function openCalendar(page: Page) {
|
||||
await page.locator('.bell-panel .bell-date-picker').click()
|
||||
const popper = page.locator('.bell-date-popper')
|
||||
await expect(popper).toBeVisible()
|
||||
await page.waitForFunction(() => {
|
||||
const pop = document.querySelector('.bell-date-popper')
|
||||
if (!pop) return false
|
||||
const style = getComputedStyle(pop)
|
||||
return style.transform === 'none' && style.opacity === '1' && pop.getBoundingClientRect().height > 0
|
||||
})
|
||||
return popper
|
||||
}
|
||||
|
||||
test('test_notification_panel_groups_and_pagination', async ({ page }) => {
|
||||
await openBell(page)
|
||||
|
||||
const panel = page.locator('.bell-panel')
|
||||
const nextPage = panel.getByRole('button', { name: '下一页' })
|
||||
|
||||
// 一页 6 组:09-13 的 4 组 + 09-12 的 2 组 ⇒ 日期头 2 个(同一天可以多组)
|
||||
await expect(page.locator('.bell-group')).toHaveCount(6)
|
||||
await expect(page.locator('.bell-day-head')).toHaveCount(2)
|
||||
await expect(page.locator('.bell-day-head').first()).toHaveText(/^(今天|昨天|\d{4}年\d{1,2}月\d{1,2}日)$/)
|
||||
await expect(page.locator('.bell-page-info')).toHaveText('1 / 2')
|
||||
await expect(page.locator('.bell-page-total')).toHaveText('共 10 组 · 明细 14 条')
|
||||
// 聚合行必须把"折叠前几条、其中几条没读"写在行上
|
||||
await expect(page.locator('.bell-group-count').first()).toHaveText('1 条 · 1 未读')
|
||||
|
||||
const page2Request = page.waitForRequest(
|
||||
(request) => request.url().includes('/api/admin/notifications/groups?') && request.url().includes('page=2'),
|
||||
)
|
||||
await nextPage.click()
|
||||
await page2Request
|
||||
|
||||
await expect(page.locator('.bell-group')).toHaveCount(4)
|
||||
await expect(page.locator('.bell-page-info')).toHaveText('2 / 2')
|
||||
await expect(nextPage).toBeDisabled()
|
||||
})
|
||||
|
||||
test('test_notification_panel_search_by_keyword', async ({ page }) => {
|
||||
await openBell(page)
|
||||
|
||||
const keywordRequest = page.waitForRequest((request) =>
|
||||
decodeURIComponent(request.url()).includes('keyword=余额不足'),
|
||||
)
|
||||
await page.locator('.bell-search-input').fill('余额不足')
|
||||
await keywordRequest
|
||||
|
||||
// 关键字命中标题/内容:夹具里 5 条含「余额不足」,且分属 5 个不同的组
|
||||
await expect(page.locator('.bell-group')).toHaveCount(5)
|
||||
await expect(page.locator('.bell-page-total')).toHaveText('共 5 组 · 明细 5 条')
|
||||
await expect(page.locator('.bell-search-reset')).toBeVisible()
|
||||
|
||||
await page.locator('.bell-search-reset').click()
|
||||
// 重置回到面板的默认视图:清空关键字、日期恢复「当天」(当天不是清空日期)
|
||||
await expect(page.locator('.bell-search-input')).toHaveValue('')
|
||||
await expect(page.locator('.bell-search-reset')).toBeHidden()
|
||||
await expect(page.locator('.bell-empty')).toHaveText('暂无通知')
|
||||
})
|
||||
|
||||
/** 红点按**组数**亮:3 条未读落在 2 个组里,徽标就是 2 而不是 3。 */
|
||||
test('test_notification_panel_badge_counts_groups_not_rows', async ({ page }) => {
|
||||
await page.goto('/admin-vue/')
|
||||
await expect(page.locator('.admin-notification-bell .bell-badge')).toHaveText('2')
|
||||
})
|
||||
|
||||
test('test_notification_panel_expand_group_loads_that_group_only', async ({ page }) => {
|
||||
await openBell(page)
|
||||
|
||||
const groups = page.locator('.bell-group')
|
||||
await expect(groups).toHaveCount(6)
|
||||
|
||||
const firstDetailRequest = page.waitForRequest((request) => {
|
||||
const url = new URL(request.url())
|
||||
return (
|
||||
url.pathname.endsWith('/api/admin/notifications') &&
|
||||
url.searchParams.get('scene') === 'secret_balance' &&
|
||||
url.searchParams.get('day') === '2026-09-13' &&
|
||||
url.searchParams.get('subjectUserId') === '1196'
|
||||
)
|
||||
})
|
||||
await groups.first().click()
|
||||
await firstDetailRequest
|
||||
await expect(page.locator('.bell-item--detail')).toHaveCount(1)
|
||||
await expect(page.locator('.bell-group--open')).toHaveCount(1)
|
||||
|
||||
// 换一组展开:上一组的明细必须收掉,不能两组明细叠在一起
|
||||
const secondDetailRequest = page.waitForRequest((request) => {
|
||||
const url = new URL(request.url())
|
||||
return (
|
||||
url.pathname.endsWith('/api/admin/notifications') &&
|
||||
url.searchParams.get('scene') === 'task_failed' &&
|
||||
url.searchParams.get('subjectUserId') === '1196'
|
||||
)
|
||||
})
|
||||
await groups.nth(1).click()
|
||||
await secondDetailRequest
|
||||
await expect(page.locator('.bell-item--detail')).toHaveCount(2)
|
||||
await expect(page.locator('.bell-group--open')).toHaveCount(1)
|
||||
|
||||
// 再点一次收起
|
||||
await groups.nth(1).click()
|
||||
await expect(page.locator('.bell-item--detail')).toHaveCount(0)
|
||||
})
|
||||
|
||||
test('test_notification_panel_date_popper_not_covered_by_panel', async ({ page }) => {
|
||||
await openBell(page)
|
||||
await openCalendar(page)
|
||||
|
||||
// 日历与通知面板同为挂在 body 上的浮层:逐格做命中测试,最上层必须还是日历自己。
|
||||
// 通知面板 z-index 3200 高于 Element 默认弹层段(自 2000 递增)时,日历整块被压在
|
||||
// 面板底下,用户看到的就是「日期点不动」——这里必须判红而不是靠肉眼发现。
|
||||
const covered = await page.evaluate(() => {
|
||||
const pop = document.querySelector('.bell-date-popper') as HTMLElement
|
||||
const panel = document.querySelector('.bell-panel') as HTMLElement
|
||||
const blocked: string[] = []
|
||||
for (const cell of Array.from(pop.querySelectorAll<HTMLTableCellElement>('td.available'))) {
|
||||
const rect = cell.getBoundingClientRect()
|
||||
if (rect.bottom > window.innerHeight || rect.right > window.innerWidth) continue
|
||||
const hit = document.elementFromPoint(rect.left + rect.width / 2, rect.top + rect.height / 2)
|
||||
if (!hit || !pop.contains(hit)) blocked.push(String(hit?.className ?? hit?.tagName ?? 'null'))
|
||||
}
|
||||
return { blocked, popperZ: getComputedStyle(pop).zIndex, panelZ: getComputedStyle(panel).zIndex }
|
||||
})
|
||||
expect(covered.blocked, `日历被通知面板遮挡(popper=${covered.popperZ},panel=${covered.panelZ})`).toEqual([])
|
||||
})
|
||||
|
||||
/** 把左栏翻到 2026 年 9 月,返回按日取格的点击器(夹具:09-10 四条、09-12 四条、09-13 六条)。 */
|
||||
async function openRangeOnSeptember(page: Page) {
|
||||
const popper = await openCalendar(page)
|
||||
await popper.locator('.el-picker-panel__icon-btn.arrow-left').click()
|
||||
const leftPanel = popper.locator('.el-date-range-picker__content').first()
|
||||
const day = (text: string) =>
|
||||
leftPanel.locator('td.available .el-date-table-cell__text', { hasText: new RegExp(`^${text}$`) })
|
||||
await expect(day('10')).toBeVisible()
|
||||
return day
|
||||
}
|
||||
|
||||
test('test_notification_panel_search_by_day_range', async ({ page }) => {
|
||||
await openBell(page)
|
||||
const day = await openRangeOnSeptember(page)
|
||||
|
||||
// 09-10 四条折成 3 组(两个用户 × 两个场景组合)
|
||||
const rangeRequest = page.waitForRequest(
|
||||
(request) =>
|
||||
request.url().includes('startDate=2026-09-10') && request.url().includes('endDate=2026-09-12'),
|
||||
)
|
||||
await day('10').click()
|
||||
await day('12').click()
|
||||
await rangeRequest
|
||||
|
||||
await expect(page.locator('.bell-page-total')).toHaveText('共 6 组 · 明细 8 条')
|
||||
await expect(page.locator('.bell-day-head')).toHaveCount(2)
|
||||
await expect(page.locator('.bell-empty')).toHaveCount(0)
|
||||
// 选完区间后面板必须还开着:日历挂在 body 上,不能被「点击外部关闭」当成面板外
|
||||
await expect(page.locator('.bell-panel')).toBeVisible()
|
||||
})
|
||||
|
||||
test('test_notification_panel_day_range_picked_backwards', async ({ page }) => {
|
||||
await openBell(page)
|
||||
const day = await openRangeOnSeptember(page)
|
||||
|
||||
// 先点 13 再点 10:控件自己保证起 ≤ 止,落到 09-10 ~ 09-13(全量 14 条 / 10 组)
|
||||
const swappedRequest = page.waitForRequest(
|
||||
(request) =>
|
||||
request.url().includes('startDate=2026-09-10') && request.url().includes('endDate=2026-09-13'),
|
||||
)
|
||||
await day('13').click()
|
||||
await day('10').click()
|
||||
await swappedRequest
|
||||
await expect(page.locator('.bell-page-total')).toHaveText('共 10 组 · 明细 14 条')
|
||||
})
|
||||
|
||||
test('test_notification_panel_not_covered_by_page_content', async ({ page }) => {
|
||||
await openBell(page)
|
||||
|
||||
// 回归:面板挂在顶栏内时曾被页面 el-select 压住(提 z-index 无效),现改为 Teleport 到 body。
|
||||
// 这里在面板内取多点做命中测试,最上层元素必须属于面板自身。
|
||||
const covered = await page.evaluate(() => {
|
||||
const panel = document.querySelector('.bell-panel') as HTMLElement
|
||||
const rect = panel.getBoundingClientRect()
|
||||
const points: Array<[number, number]> = [
|
||||
[rect.left + 30, rect.top + 130],
|
||||
[rect.left + rect.width / 2, rect.top + rect.height / 2],
|
||||
[rect.right - 30, rect.bottom - 60],
|
||||
]
|
||||
return points
|
||||
.map(([x, y]) => document.elementsFromPoint(x, y)[0])
|
||||
.filter((el) => !!el && el !== panel && !panel.contains(el))
|
||||
.map((el) => `${el!.tagName}.${String((el as HTMLElement).className).slice(0, 40)}`)
|
||||
})
|
||||
expect(covered, '面板被页面元素遮挡').toEqual([])
|
||||
})
|
||||
|
||||
test('test_notification_panel_reference_screenshot', async ({ page }) => {
|
||||
await openBell(page)
|
||||
|
||||
const tops = await page
|
||||
.locator('.bell-group')
|
||||
.evaluateAll((els) => els.map((el) => el.getBoundingClientRect().top))
|
||||
for (let i = 1; i < tops.length; i += 1) {
|
||||
expect(tops[i], `第 ${i + 1} 组应排在第 ${i} 组下方`).toBeGreaterThan(tops[i - 1])
|
||||
}
|
||||
|
||||
await page.locator('.bell-panel').screenshot({
|
||||
path: 'test-results/notification-panel-admin-groups.jpg',
|
||||
animations: 'disabled',
|
||||
})
|
||||
await page.locator('.bell-group').first().click()
|
||||
await expect(page.locator('.bell-item--detail')).toHaveCount(1)
|
||||
await page.locator('.bell-panel').screenshot({
|
||||
path: 'test-results/notification-panel-admin-expanded.jpg',
|
||||
animations: 'disabled',
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* 已读只能进明细逐条点(口径见设计):组内未读清零,红点才掉一格。
|
||||
*/
|
||||
test('test_notification_panel_mark_read_from_detail_drops_group_last', async ({ page }) => {
|
||||
await openBell(page)
|
||||
|
||||
const group = page.locator('.bell-group').nth(1)
|
||||
await expect(group.locator('.bell-group-count')).toHaveText('2 条 · 2 未读')
|
||||
await group.click()
|
||||
await expect(page.locator('.bell-item--detail')).toHaveCount(2)
|
||||
// 每次点的都必须是「还红着」的那条:已读行点了不做事(onItemClick 直接 return),
|
||||
// 拿 .first() 连点两次会第二次点到刚读过的那条,看着像"没扣数"。
|
||||
const unread = page.locator('.bell-item--detail.bell-item--unread')
|
||||
|
||||
await unread.first().click()
|
||||
await expect(unread).toHaveCount(1)
|
||||
await expect(group.locator('.bell-group-count')).toHaveText('2 条 · 1 未读')
|
||||
// 还剩一条未读 ⇒ 这一组仍计为一个未读组,红点不动
|
||||
await expect(page.locator('.admin-notification-bell .bell-badge')).toHaveText('2')
|
||||
|
||||
await unread.first().click()
|
||||
await expect(unread).toHaveCount(0)
|
||||
await expect(group.locator('.bell-group-count')).toHaveText('2 条')
|
||||
await expect(page.locator('.admin-notification-bell .bell-badge')).toHaveText('1')
|
||||
})
|
||||
@@ -1,79 +0,0 @@
|
||||
import { expect, test, type Page } from '@playwright/test'
|
||||
|
||||
// 教程管理页验收(module 记录与版本):列表新增「版本号」列 + 上传时间列,
|
||||
// 默认按上传时间降序;版本号/上传时间表头可点击切换升降序;空版本历史行沉底。
|
||||
// 依赖 scripts/mock-admin-server.mjs 的教程包夹具(4 条,其中 1 条无版本号、1 条 09-01 历史行)。
|
||||
|
||||
async function openTutorial(page: Page) {
|
||||
await page.goto('/admin-vue/records/tutorial')
|
||||
await expect(page.locator('.admin-topbar h1')).toHaveText('教程管理')
|
||||
await expect(page.locator('.panel-box tbody tr').first()).toBeVisible()
|
||||
}
|
||||
|
||||
const versionTexts = (page: Page) =>
|
||||
page.locator('.panel-box tbody tr td:nth-child(3)').allTextContents()
|
||||
|
||||
const fileTexts = (page: Page) =>
|
||||
page.locator('.panel-box tbody tr td:nth-child(2) .file-name').allTextContents()
|
||||
|
||||
test('test_tutorial_list_default_desc_by_upload_time', async ({ page }) => {
|
||||
await openTutorial(page)
|
||||
|
||||
// 表头:版本号、上传时间(均带排序标记)
|
||||
await expect(page.locator('.sort-version')).toHaveText(/版本号/)
|
||||
await expect(page.locator('.sort-time')).toHaveText(/上传时间/)
|
||||
// 默认排序状态:上传时间降序(▼),版本号未激活(▲▼)
|
||||
await expect(page.locator('.sort-time .sort-mark')).toHaveText('▼')
|
||||
await expect(page.locator('.sort-version .sort-mark')).toHaveText('▲▼')
|
||||
|
||||
// 默认按上传时间降序:09-14 → 09-12 → 09-10 → 09-01;空版本行沉底
|
||||
expect(await versionTexts(page)).toEqual(['v3.10.0', 'v3.2.0', 'v3.1.0', '—'])
|
||||
expect(await fileTexts(page)).toEqual([
|
||||
'数富AI-教学客户端-v4.zip',
|
||||
'数富AI-教学客户端-v3.zip',
|
||||
'数富AI-教学客户端-v2.zip',
|
||||
'数富AI-教学客户端.zip',
|
||||
])
|
||||
// 当前生效 = 最新上传(夹具里 09-14 那条),不随列表排序变化
|
||||
await expect(page.locator('.tag-active')).toHaveCount(1)
|
||||
await expect(page.locator('.tag-active').locator('xpath=..')).toHaveText(/数富AI-教学客户端-v4\.zip/)
|
||||
})
|
||||
|
||||
test('test_tutorial_sort_toggle_by_version_and_time', async ({ page }) => {
|
||||
await openTutorial(page)
|
||||
|
||||
// 点「版本号」:首次为降序(v3.10.0 按自然序大于 v3.2.0),空版本行仍在末尾
|
||||
await page.locator('.sort-version').click()
|
||||
await expect(page.locator('.sort-version .sort-mark')).toHaveText('▼')
|
||||
expect(await versionTexts(page)).toEqual(['v3.10.0', 'v3.2.0', 'v3.1.0', '—'])
|
||||
|
||||
// 再点一次切升序
|
||||
await page.locator('.sort-version').click()
|
||||
await expect(page.locator('.sort-version .sort-mark')).toHaveText('▲')
|
||||
expect(await versionTexts(page)).toEqual(['v3.1.0', 'v3.2.0', 'v3.10.0', '—'])
|
||||
|
||||
// 点回「上传时间」:切换字段时回到降序默认
|
||||
await page.locator('.sort-time').click()
|
||||
await expect(page.locator('.sort-time .sort-mark')).toHaveText('▼')
|
||||
await expect(page.locator('.sort-version .sort-mark')).toHaveText('▲▼')
|
||||
expect(await fileTexts(page)).toEqual([
|
||||
'数富AI-教学客户端-v4.zip',
|
||||
'数富AI-教学客户端-v3.zip',
|
||||
'数富AI-教学客户端-v2.zip',
|
||||
'数富AI-教学客户端.zip',
|
||||
])
|
||||
})
|
||||
|
||||
test('test_tutorial_upload_dialog_has_version_field', async ({ page }) => {
|
||||
await openTutorial(page)
|
||||
|
||||
await page.getByRole('button', { name: '上传教程包' }).click()
|
||||
const dialog = page.locator('.el-dialog')
|
||||
await expect(dialog).toBeVisible()
|
||||
await expect(dialog.locator('.el-form-item').first()).toContainText('版本号')
|
||||
await expect(dialog.locator('input').first()).toHaveAttribute('maxlength', '64')
|
||||
|
||||
// 不选文件直接提交:提示仍以 zip 为必填(版本号可空)
|
||||
await dialog.getByRole('button', { name: '上传教程包' }).click()
|
||||
await expect(dialog.locator('.el-alert')).toContainText('请选择 zip 压缩包')
|
||||
})
|
||||
Generated
-1024
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,6 @@
|
||||
"build": "vue-tsc --noEmit && vite build",
|
||||
"preview": "vite preview",
|
||||
"test": "node --test tests/*.test.ts",
|
||||
"test:mount": "vitest run",
|
||||
"test:live": "node --test tests/live/*.test.ts",
|
||||
"test:browser": "playwright test"
|
||||
},
|
||||
@@ -23,11 +22,8 @@
|
||||
"@playwright/test": "^1.63.0",
|
||||
"@types/node": "^26.4.1",
|
||||
"@vitejs/plugin-vue": "^6.0.1",
|
||||
"@vue/test-utils": "^2.5.1",
|
||||
"jsdom": "^30.1.2",
|
||||
"typescript": "^5.9.2",
|
||||
"vite": "^7.3.1",
|
||||
"vitest": "^5.0.3",
|
||||
"vue-tsc": "^3.0.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
import { defineConfig } from '@playwright/test'
|
||||
|
||||
/**
|
||||
* 浏览器验收:起 mock admin API(18100) + vite dev(E2E_PORT,默认 5174, /api 代理到 mock)。
|
||||
* 浏览器验收:起 mock admin API(18100) + vite dev(5174, /api 代理到 mock)。
|
||||
* 本地用已安装的 MS Edge(channel: msedge)运行,无需下载 Chromium。
|
||||
*
|
||||
* 端口必须可改:5174 被别的项目占用时 vite 会顺延到别的端口,而 reuseExistingServer
|
||||
* 会让 playwright 直接连上那个「不是本站」的服务,整份验收测的是别人的页面。
|
||||
*/
|
||||
const PORT = Number(process.env.E2E_PORT || 5174)
|
||||
const MOCK_PORT = Number(process.env.MOCK_PORT || 18100)
|
||||
|
||||
export default defineConfig({
|
||||
testDir: './e2e',
|
||||
timeout: 45_000,
|
||||
@@ -19,7 +13,7 @@ export default defineConfig({
|
||||
retries: 0,
|
||||
reporter: [['list']],
|
||||
use: {
|
||||
baseURL: `http://127.0.0.1:${PORT}`,
|
||||
baseURL: 'http://127.0.0.1:5174',
|
||||
channel: 'msedge',
|
||||
headless: true,
|
||||
viewport: { width: 1440, height: 900 },
|
||||
@@ -28,14 +22,13 @@ export default defineConfig({
|
||||
webServer: [
|
||||
{
|
||||
command: 'node scripts/mock-admin-server.mjs',
|
||||
port: MOCK_PORT,
|
||||
reuseExistingServer: false,
|
||||
port: 18100,
|
||||
reuseExistingServer: true,
|
||||
},
|
||||
{
|
||||
command: `npm run dev -- --host 127.0.0.1 --port ${PORT} --strictPort`,
|
||||
env: { VITE_API_TARGET: `http://127.0.0.1:${MOCK_PORT}` },
|
||||
port: PORT,
|
||||
reuseExistingServer: false,
|
||||
command: 'set VITE_API_TARGET=http://127.0.0.1:18100&& npm run dev',
|
||||
port: 5174,
|
||||
reuseExistingServer: true,
|
||||
timeout: 120_000,
|
||||
},
|
||||
],
|
||||
|
||||
@@ -142,167 +142,6 @@ function json(res, payload, status = 200) {
|
||||
res.end(body)
|
||||
}
|
||||
|
||||
/* ===================== 教程包夹具(教程管理页:版本号列 + 上传时间排序验收用) ===================== */
|
||||
// 故意乱序给出,且含一条无版本号的历史行:页面默认应按上传时间降序、空版本行沉底。
|
||||
const TUTORIAL_PACKAGES = [
|
||||
{ id: 3, file_name: '数富AI-教学客户端-v3.zip', version: 'v3.2.0', object_key: 'tutorial/20260912090000-数富AI-教学客户端-v3.zip', file_size: 1048576, file_url: 'https://oss.aishufu.top/client/tutorial/t3.zip', created_at: '2026-09-12 09:00' },
|
||||
{ id: 1, file_name: '数富AI-教学客户端.zip', version: '', object_key: 'tutorial/数富AI-教学客户端.zip', file_size: 0, file_url: 'https://oss.aishufu.top/client/tutorial/legacy.zip', created_at: '2026-09-01 08:00' },
|
||||
{ id: 4, file_name: '数富AI-教学客户端-v4.zip', version: 'v3.10.0', object_key: 'tutorial/20260914103000-数富AI-教学客户端-v4.zip', file_size: 2097152, file_url: 'https://oss.aishufu.top/client/tutorial/t4.zip', created_at: '2026-09-14 10:30' },
|
||||
{ id: 2, file_name: '数富AI-教学客户端-v2.zip', version: 'v3.1.0', object_key: 'tutorial/20260910120000-数富AI-教学客户端-v2.zip', file_size: 524288, file_url: 'https://oss.aishufu.top/client/tutorial/t2.zip', created_at: '2026-09-10 12:00' },
|
||||
]
|
||||
|
||||
/* ===================== 站内通知夹具(铃铛面板:搜索/按天分组/分页验收用) ===================== */
|
||||
/**
|
||||
* 通知夹具。两条约定不能破:
|
||||
* ① id 与 createdAt 同为插入时单调(09-10 最早 ⇒ id 最小)——与真库一致;倒挂会让
|
||||
* "按 id 倒序即按天倒序"这种隐藏假设在 mock 里成立、上线就翻车。
|
||||
* ② 场景显式给,不从 id 取模推——否则换一批 id,「余额不足」命中数与聚合组数一起漂,
|
||||
* 用例断言就成了跟着夹具跑的活字。
|
||||
* 共 14 行、5 行密钥告警;按 场景×自然日×主体用户 折成 10 组,其中 2 组未读、3 行未读。
|
||||
*/
|
||||
const NOTIFICATIONS = [
|
||||
['2026-09-10', 18, 1, true, 'task_failed'],
|
||||
['2026-09-10', 18, 2, true, 'task_failed'],
|
||||
['2026-09-10', 18, 3, true, 'secret_balance'],
|
||||
['2026-09-10', 18, 4, true, 'task_failed'],
|
||||
['2026-09-12', 20, 1, true, 'secret_balance'],
|
||||
['2026-09-12', 20, 2, true, 'task_failed'],
|
||||
['2026-09-12', 20, 3, true, 'task_failed'],
|
||||
['2026-09-12', 20, 4, true, 'secret_balance'],
|
||||
['2026-09-13', 22, 1, true, 'task_failed'],
|
||||
['2026-09-13', 22, 2, true, 'task_failed'],
|
||||
['2026-09-13', 22, 3, true, 'secret_balance'],
|
||||
['2026-09-13', 22, 4, false, 'task_failed'],
|
||||
['2026-09-13', 22, 5, false, 'task_failed'],
|
||||
['2026-09-13', 22, 6, false, 'secret_balance'],
|
||||
].map(([day, hour, seq, read, scene], index) => notif(index + 1, day, hour, seq, read, scene))
|
||||
|
||||
const NOTIFICATION_SEED = structuredClone(NOTIFICATIONS)
|
||||
|
||||
function notif(id, day, hour, seq, read, scene) {
|
||||
const minutes = String(seq * 7).padStart(2, '0')
|
||||
const secret = scene === 'secret_balance'
|
||||
return {
|
||||
id,
|
||||
scene,
|
||||
level: secret ? 'error' : 'warning',
|
||||
title: secret ? `用户密钥异常:测试用户${seq}` : `跟价任务失败`,
|
||||
content: secret
|
||||
? `用户 测试用户${seq}(uid=${1100 + seq})的代理设置对应服务商余额不足`
|
||||
: `用户 测试用户${seq} 有 ${seq} 个跟价任务失败`,
|
||||
// 事件主体用户:与后端 V158 那列同义,聚合分组键的第三维。seq>3 归 1196、其余归 1160,
|
||||
// 让"同一天两个用户"在夹具里真的存在(否则聚合视图测不到按用户拆组这一维)。
|
||||
subjectUserId: seq > 3 ? 1196 : 1160,
|
||||
read,
|
||||
readAt: read ? `${day} ${hour}:${minutes}:00` : null,
|
||||
createdAt: `${day} ${hour}:${minutes}:00`,
|
||||
}
|
||||
}
|
||||
|
||||
/** 与后端 groups 出口同形的聚合:场景 × 自然日 × 主体用户。 */
|
||||
function groupRows(rows) {
|
||||
const byKey = new Map()
|
||||
for (const item of [...rows].sort((a, b) => b.id - a.id)) {
|
||||
const day = item.createdAt.slice(0, 10)
|
||||
const key = `${item.scene}|${day}|${item.subjectUserId ?? 'none'}`
|
||||
let group = byKey.get(key)
|
||||
if (!group) {
|
||||
group = {
|
||||
latestId: item.id,
|
||||
scene: item.scene,
|
||||
category: item.scene === 'secret_balance' ? 'config_error' : 'task_error',
|
||||
day,
|
||||
subjectUserId: item.subjectUserId ?? null,
|
||||
rowCount: 0,
|
||||
unreadCount: 0,
|
||||
level: item.level,
|
||||
title: item.title,
|
||||
content: item.content,
|
||||
createdAt: item.createdAt,
|
||||
}
|
||||
byKey.set(key, group)
|
||||
}
|
||||
group.rowCount += 1
|
||||
if (!item.read) group.unreadCount += 1
|
||||
if (item.level === 'error') group.level = 'error'
|
||||
}
|
||||
return [...byKey.values()]
|
||||
}
|
||||
|
||||
/** 通知列表:关键字匹配标题/内容,日期按年月日区间(与 Java 侧同语义)。 */
|
||||
/** 列表与聚合共用的筛选:关键字 / 日期区间 / 展开某一组(场景 + 自然日 + 主体用户)。 */
|
||||
function filteredRows(searchParams) {
|
||||
const keyword = (searchParams.get('keyword') || '').trim()
|
||||
const startDate = searchParams.get('startDate') || ''
|
||||
const endDate = searchParams.get('endDate') || ''
|
||||
const scene = searchParams.get('scene') || ''
|
||||
const day = searchParams.get('day') || ''
|
||||
const subjectUserId = searchParams.get('subjectUserId')
|
||||
const subjectUnlabelled = searchParams.get('subjectUnlabelled') === 'true'
|
||||
let rows = NOTIFICATIONS
|
||||
if (keyword) {
|
||||
rows = rows.filter((item) => `${item.title}${item.content}`.includes(keyword))
|
||||
}
|
||||
if (startDate) {
|
||||
rows = rows.filter((item) => item.createdAt.slice(0, 10) >= startDate)
|
||||
}
|
||||
if (endDate) {
|
||||
rows = rows.filter((item) => item.createdAt.slice(0, 10) <= endDate)
|
||||
}
|
||||
if (scene) {
|
||||
rows = rows.filter((item) => item.scene === scene)
|
||||
}
|
||||
if (day) {
|
||||
rows = rows.filter((item) => item.createdAt.slice(0, 10) === day)
|
||||
}
|
||||
if (subjectUserId) {
|
||||
rows = rows.filter((item) => String(item.subjectUserId) === String(subjectUserId))
|
||||
} else if (subjectUnlabelled) {
|
||||
rows = rows.filter((item) => item.subjectUserId === null || item.subjectUserId === undefined)
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
function readPaging(searchParams) {
|
||||
const page = Math.max(1, Number(searchParams.get('page') || 1))
|
||||
const pageSize = Math.min(100, Math.max(1, Number(searchParams.get('pageSize') || 20)))
|
||||
return { page, pageSize, start: (page - 1) * pageSize }
|
||||
}
|
||||
|
||||
function notificationPage(searchParams) {
|
||||
const rows = filteredRows(searchParams)
|
||||
const { page, pageSize, start } = readPaging(searchParams)
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
items: rows.slice(start, start + pageSize),
|
||||
total: rows.length,
|
||||
page,
|
||||
pageSize,
|
||||
unreadCount: rows.filter((item) => !item.read).length,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/** 聚合出口:分页按组切,total=组数、rowCount=折叠前的明细条数,两个都给前端。 */
|
||||
function notificationGroupsPage(searchParams) {
|
||||
const rows = filteredRows(searchParams)
|
||||
const groups = groupRows(rows)
|
||||
const { page, pageSize, start } = readPaging(searchParams)
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
groups: groups.slice(start, start + pageSize),
|
||||
total: groups.length,
|
||||
rowCount: rows.length,
|
||||
page,
|
||||
pageSize,
|
||||
unreadGroupCount: groups.filter((group) => group.unreadCount > 0).length,
|
||||
unreadCount: rows.filter((item) => !item.read).length,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const server = createServer((req, res) => {
|
||||
const url = (req.url || '').split('?')[0]
|
||||
const method = req.method || 'GET'
|
||||
@@ -321,212 +160,13 @@ const server = createServer((req, res) => {
|
||||
return json(res, {
|
||||
success: true,
|
||||
data: {
|
||||
items: [{ id: 1, username: 'admin', role: 'super_admin', creatorUsername: 'system', created_at: '2026-03-01 09:15:00', updated_at: '2026-09-18 16:42:30' }],
|
||||
items: [{ id: 1, username: 'admin', role: 'super_admin', creatorUsername: 'system', createdAt: '2026-01-01 00:00:00' }],
|
||||
total: 1,
|
||||
},
|
||||
})
|
||||
}
|
||||
if (url === '/api/admin/permission-menus') {
|
||||
// 菜单管理列表:一条根节点,带创建/更新时间(验收时间列)。
|
||||
return json(res, {
|
||||
success: true,
|
||||
data: [
|
||||
{
|
||||
id: 1,
|
||||
name: '用户管理',
|
||||
column_key: 'admin_users',
|
||||
parent_id: null,
|
||||
menu_type: 'admin',
|
||||
route_path: 'account/users',
|
||||
sort_order: 10,
|
||||
created_at: '2026-03-01T09:15:00',
|
||||
updated_at: '2026-09-18T16:42:30',
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
if (url === '/api/admin/invalid-asin-data/groups') {
|
||||
return json(res, { success: true, data: [{ id: 1, group_name: '测试分组' }, { id: 2, group_name: '其他分组' }] })
|
||||
}
|
||||
if (url === '/api/admin/invalid-asin-data') {
|
||||
return json(res, {
|
||||
success: true,
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
id: 1,
|
||||
dataValue: 'B0INVALID1',
|
||||
brand: '测试品牌',
|
||||
groupId: 1,
|
||||
groupName: '测试分组',
|
||||
recordSource: 'MANUAL',
|
||||
createdAt: '2026-03-01 09:15:00',
|
||||
updatedAt: '2026-09-18 16:42:30',
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
})
|
||||
}
|
||||
if (url === '/api/admin/dedupe-total-data') {
|
||||
return json(res, {
|
||||
success: true,
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
id: 1,
|
||||
dataValue: 'B0DEDUPE01',
|
||||
country: 'DE',
|
||||
groupId: 1,
|
||||
groupName: '测试分组',
|
||||
uploaderUserId: 1,
|
||||
username: 'admin',
|
||||
createdAt: '2026-03-01 09:15:00',
|
||||
updatedAt: '2026-09-18 16:42:30',
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
})
|
||||
}
|
||||
if (url === '/api/admin/query-asins') {
|
||||
return json(res, {
|
||||
success: true,
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
id: 1,
|
||||
groupId: 1,
|
||||
groupName: '测试分组',
|
||||
shopName: '测试店铺',
|
||||
asinDe: 'B0QUERY001',
|
||||
asinUk: '',
|
||||
asinFr: '',
|
||||
asinIt: '',
|
||||
asinEs: '',
|
||||
createdAt: '2026-03-01 09:15:00',
|
||||
updatedAt: '2026-09-18 16:42:30',
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
})
|
||||
}
|
||||
if (url === '/api/admin/skip-price-asins') {
|
||||
return json(res, {
|
||||
success: true,
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
id: 1,
|
||||
groupId: 1,
|
||||
groupName: '测试分组',
|
||||
shopName: '测试店铺',
|
||||
asinDe: 'B0SKIP0001',
|
||||
minimumPriceDe: 9.99,
|
||||
asinUk: '',
|
||||
minimumPriceUk: null,
|
||||
asinFr: '',
|
||||
minimumPriceFr: null,
|
||||
asinIt: '',
|
||||
minimumPriceIt: null,
|
||||
asinEs: '',
|
||||
minimumPriceEs: null,
|
||||
createdAt: '2026-03-01 09:15:00',
|
||||
updatedAt: '2026-09-18 16:42:30',
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
})
|
||||
}
|
||||
if (url === '/api/admin/product-categories/children') {
|
||||
return json(res, {
|
||||
success: true,
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
id: 1,
|
||||
parentId: null,
|
||||
name: '护肤品',
|
||||
categoryKey: 'skincare',
|
||||
sortOrder: 10,
|
||||
description: '测试备注',
|
||||
isBuiltin: true,
|
||||
childCount: 0,
|
||||
level: 0,
|
||||
path: '护肤品',
|
||||
createdAt: '2026-03-01 09:15:00',
|
||||
updatedAt: '2026-09-18 16:42:30',
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
hasMore: false,
|
||||
},
|
||||
})
|
||||
}
|
||||
if (url === '/api/admin/user-secrets') {
|
||||
const emptyModule = { moduleKey: '', moduleLabel: '', masked: '', full: '', exists: false, checkStatus: 'unknown', checkCode: '', checkMessage: '', checkLatencyMs: null, checkedAt: null, updatedAt: null }
|
||||
return json(res, {
|
||||
success: true,
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
userId: 1,
|
||||
username: 'admin',
|
||||
groups: [],
|
||||
leaderUsername: '',
|
||||
similarAsin: { ...emptyModule, moduleKey: 'similar-asin', moduleLabel: '货源查询密钥' },
|
||||
appearancePatent: { ...emptyModule, moduleKey: 'appearance-patent', moduleLabel: '外观专利密钥' },
|
||||
proxy: { ...emptyModule, moduleKey: 'proxy', moduleLabel: '代理设置' },
|
||||
status: 'unknown',
|
||||
statusMessage: '',
|
||||
createdAt: '2026-03-01 09:15:00',
|
||||
updatedAt: '2026-09-18 16:42:30',
|
||||
},
|
||||
],
|
||||
total: 1,
|
||||
page: 1,
|
||||
pageSize: 15,
|
||||
groupOptions: [],
|
||||
},
|
||||
})
|
||||
}
|
||||
if (url === '/api/admin/user-secrets/balances') {
|
||||
// 余额侧写夹具(POST):两把密钥同渠道 ⇒ 界面折叠成一行;代理给「你的套餐」形状
|
||||
const llmCell = (moduleKey, moduleLabel, over = {}) => ({
|
||||
moduleKey, moduleLabel,
|
||||
channel: 'longtaitou', channelLabel: '龙抬头',
|
||||
available: true, balance: '88.888882', availableBalance: '85.288882', frozen: '3.6',
|
||||
unit: 'CREDIT', message: null, checkedAt: '2026-11-05T10:30:00', ...over,
|
||||
})
|
||||
return json(res, {
|
||||
success: true,
|
||||
data: {
|
||||
items: [
|
||||
{
|
||||
userId: 1,
|
||||
llm: [
|
||||
llmCell('appearance-patent', '外观专利密钥'),
|
||||
llmCell('similar-asin', '货源查询密钥'),
|
||||
],
|
||||
proxy: { available: true, surplus: '1234', balance: '56', scope: 'user', message: null },
|
||||
},
|
||||
],
|
||||
deniedUserIds: [],
|
||||
timedOutUserIds: [],
|
||||
},
|
||||
})
|
||||
return json(res, { success: true, data: { items: [] } })
|
||||
}
|
||||
if (url === '/api/admin/shop-manage-groups') {
|
||||
return json(res, { success: true, data: { items: [] } })
|
||||
@@ -540,56 +180,10 @@ const server = createServer((req, res) => {
|
||||
data: { pending: false, scanned_at: '2026-09-05 08:30:00', items: ALL_ROWS, total: ALL_ROWS.length, page: 1, page_size: 20 },
|
||||
})
|
||||
}
|
||||
// 已读标记会改内存里的夹具(不是幂等只读口)⇒ 用例之间要靠下面这条重置口隔离,
|
||||
// 否则同一份 mock 服务被 reuseExistingServer 复用时,第二次跑就会带着上一次的已读态。
|
||||
if (method === 'POST' && url === '/api/admin/notifications/__reset') {
|
||||
NOTIFICATIONS.splice(0, NOTIFICATIONS.length, ...structuredClone(NOTIFICATION_SEED))
|
||||
return json(res, { success: true, data: NOTIFICATIONS.length })
|
||||
}
|
||||
if (method === 'POST' && /^\/api\/admin\/notifications\/\d+\/read$/.test(url)) {
|
||||
const id = Number(url.split('/')[3])
|
||||
const item = NOTIFICATIONS.find((row) => row.id === id)
|
||||
if (item && !item.read) {
|
||||
item.read = true
|
||||
item.readAt = `${item.createdAt.slice(0, 10)} 23:59:59`
|
||||
}
|
||||
return json(res, { success: true, data: true })
|
||||
}
|
||||
if (method === 'POST' && url === '/api/admin/notifications/read-all') {
|
||||
for (const item of NOTIFICATIONS) {
|
||||
if (!item.read) {
|
||||
item.read = true
|
||||
item.readAt = `${item.createdAt.slice(0, 10)} 23:59:59`
|
||||
}
|
||||
}
|
||||
return json(res, { success: true, data: NOTIFICATIONS.length })
|
||||
}
|
||||
if (url === '/api/admin/notifications/summary') {
|
||||
const groups = groupRows(NOTIFICATIONS)
|
||||
return json(res, {
|
||||
success: true,
|
||||
data: {
|
||||
unreadCount: NOTIFICATIONS.filter((item) => !item.read).length,
|
||||
unreadGroupCount: groups.filter((group) => group.unreadCount > 0).length,
|
||||
latestId: NOTIFICATIONS.reduce((max, item) => Math.max(max, item.id), 0),
|
||||
},
|
||||
})
|
||||
}
|
||||
if (url === '/api/admin/notifications/groups') {
|
||||
return json(res, notificationGroupsPage(new URL(req.url || '/', 'http://127.0.0.1').searchParams))
|
||||
}
|
||||
if (url === '/api/admin/notifications') {
|
||||
return json(res, notificationPage(new URL(req.url || '/', 'http://127.0.0.1').searchParams))
|
||||
}
|
||||
if (url === '/api/admin/tutorials') {
|
||||
// 与 Java 侧同契约:created_at 降序返回(页面"当前生效"取第一条)。
|
||||
const items = [...TUTORIAL_PACKAGES].sort((a, b) => (a.created_at < b.created_at ? 1 : -1))
|
||||
return json(res, { success: true, data: { items } })
|
||||
}
|
||||
if (url.startsWith('/api/')) {
|
||||
return json(res, { success: true, data: { items: [], total: 0 } })
|
||||
}
|
||||
return json(res, { success: true }, 200)
|
||||
})
|
||||
|
||||
server.listen(PORT, '127.0.0.1', () => console.log(`mock admin api listening on ${PORT}`))
|
||||
server.listen(PORT, () => console.log(`mock admin api listening on ${PORT}`))
|
||||
|
||||
@@ -1,17 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { RouterView } from 'vue-router'
|
||||
import zhCn from 'element-plus/es/locale/lang/zh-cn'
|
||||
import { useGlobalErrorReporting } from '@/shared/api/error-report'
|
||||
|
||||
// 浏览器级错误兜底接线(S1-F2/AC-16):脚本级崩溃与没人接的 Promise 都进同一条上报路,
|
||||
// 卸载出口由该 composable 的 onBeforeUnmount 摘掉——根组件不卸载时它就是应用级单例。
|
||||
useGlobalErrorReporting()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 摘掉整包 use(ElementPlus, { locale }) 后,全局配置只能走 config-provider:
|
||||
日期控件(周/月/年份)、分页组件(上一页/下一页)靠它显示中文。 -->
|
||||
<el-config-provider :locale="zhCn">
|
||||
<RouterView />
|
||||
</el-config-provider>
|
||||
<RouterView />
|
||||
</template>
|
||||
|
||||
@@ -1,211 +0,0 @@
|
||||
import { http, unwrap } from '@/api/http'
|
||||
|
||||
/**
|
||||
* 大档分片阈值与片大小(AC-11):后管这一侧只有这一个出口,阈值由片大小派生。
|
||||
*
|
||||
* ⚠ 同族的 8MB 数还另有两处:用户端上传出口一处、桌面客户端分片入口一处。两边是各自
|
||||
* 独立的构建根(各自的 `@` 别名与 tsconfig include),客户端是 Python 打包物 ⇒
|
||||
* 没有共享包就合不成同一个字面量(P3-5 的边界,已登记)。
|
||||
*/
|
||||
export const CHUNK_UPLOAD_PART_SIZE = 8 * 1024 * 1024
|
||||
export const CHUNK_UPLOAD_THRESHOLD = CHUNK_UPLOAD_PART_SIZE
|
||||
|
||||
/** 每片重试次数(不含首次):单片 502/超时不该让 512MB 从 0 再来。 */
|
||||
const PART_RETRY_LIMIT = 2
|
||||
|
||||
/**
|
||||
* 逐片超时(P2-8):预算只看**这一片**有多大——60s 保底 + 每 MB 30s(8MB 片=300s)。
|
||||
* 过去按整包体积算(120s + MB×15s),512MB 包里的一个 8MB 片能拿到 128 分钟,
|
||||
* 慢链路真卡死时没人知道,进度条还会一直爬。
|
||||
*/
|
||||
export function partTimeoutOf(partBytes: number): number {
|
||||
return 60_000 + Math.ceil(partBytes / (1024 * 1024)) * 30_000
|
||||
}
|
||||
|
||||
/** 会话登记/查询只发元数据,固定预算即可;失败要快快回来,别陪整包一起放大。 */
|
||||
const REQUEST_TIMEOUT_MS = 60_000
|
||||
/** 只有拼装这一步真随整包体积走:服务端要读全部分片、复算 sha256。 */
|
||||
const COMPLETE_TIMEOUT_MS = 600_000
|
||||
|
||||
function partUrl(uploadId: string, index: number): string {
|
||||
return `/api/files/chunk/${encodeURIComponent(uploadId)}/part/${index}`
|
||||
}
|
||||
|
||||
/** 分片会话跨尝试/刷新续用:同一文件身份复用 upload_id,服务端没回收就从已达片号继续(P2-7)。 */
|
||||
interface StoredChunkSession {
|
||||
uploadId: string;
|
||||
size: number;
|
||||
lastModified: number;
|
||||
}
|
||||
|
||||
const CHUNK_SESSION_PREFIX = 'shufu:admin:chunk:'
|
||||
|
||||
function lastModifiedOf(file: Blob): number {
|
||||
const value = (file as File).lastModified
|
||||
return typeof value === 'number' && Number.isFinite(value) ? value : 0
|
||||
}
|
||||
|
||||
/** 会话键:文件名+体积+修改时间,三者同一条上传才算同一个件。 */
|
||||
export function chunkSessionKeyOf(fileName: string, file: Blob): string {
|
||||
return `${CHUNK_SESSION_PREFIX}${fileName}:${file.size}:${lastModifiedOf(file)}`
|
||||
}
|
||||
|
||||
function readStoredSession(key: string, file: Blob): string {
|
||||
if (typeof localStorage === 'undefined') return ''
|
||||
try {
|
||||
const raw = localStorage.getItem(key)
|
||||
if (!raw) return ''
|
||||
const parsed = JSON.parse(raw) as StoredChunkSession
|
||||
return parsed.size === file.size && parsed.lastModified === lastModifiedOf(file) ? parsed.uploadId : ''
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
function writeStoredSession(key: string, file: Blob, uploadId: string): void {
|
||||
if (typeof localStorage === 'undefined') return
|
||||
try {
|
||||
localStorage.setItem(key, JSON.stringify({
|
||||
uploadId, size: file.size, lastModified: lastModifiedOf(file),
|
||||
} satisfies StoredChunkSession))
|
||||
} catch {
|
||||
// 存储不可用(隐私模式/配额满)只影响跨刷新续传,不影响本次上传
|
||||
}
|
||||
}
|
||||
|
||||
function clearStoredSession(key: string): void {
|
||||
if (typeof localStorage === 'undefined') return
|
||||
try {
|
||||
localStorage.removeItem(key)
|
||||
} catch {
|
||||
// 同上:清不掉只会让下次多问一次 status
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务端对「这个会话还在不在」的三种答复:还在(附带已到片号)/确实没了/问不出来。
|
||||
* 第三态是 P2-7 与 P1-11 的共同判据——过去它被当成"没会话",瞬态抖动=整包作废。
|
||||
*/
|
||||
type ProbeOutcome
|
||||
= { state: 'ok'; parts: number[] }
|
||||
| { state: 'gone' }
|
||||
| { state: 'transient' }
|
||||
|
||||
/** 后端回收会话的原文案(ChunkedUploadService.readMeta);BusinessException 不带 code ⇒ HTTP 200 出。 */
|
||||
function messageSaysSessionGone(text: unknown): boolean {
|
||||
const message = typeof text === 'string' ? text : ''
|
||||
return ['不存在', '过期'].some((marker) => message.includes(marker))
|
||||
}
|
||||
|
||||
function classifyProbe(response: unknown): ProbeOutcome {
|
||||
const status = Number((response as { status?: unknown } | null | undefined)?.status)
|
||||
if (status === 404) return { state: 'gone' }
|
||||
if (status >= 500 || status === 408 || status === 429) return { state: 'transient' }
|
||||
const body = (response as { data?: unknown } | null | undefined)?.data
|
||||
if (body && typeof body === 'object' && (body as { success?: unknown }).success === false) {
|
||||
return messageSaysSessionGone((body as { message?: unknown }).message)
|
||||
? { state: 'gone' }
|
||||
: { state: 'transient' }
|
||||
}
|
||||
const core = (unwrap<Record<string, unknown>>(body) ?? {}) as Record<string, unknown>
|
||||
const arrived = core.uploaded_parts
|
||||
return { state: 'ok', parts: Array.isArray(arrived) ? arrived.map((value) => Number(value)) : [] }
|
||||
}
|
||||
|
||||
/**
|
||||
* 探测已达片号(P2-7/与用户端 upload.ts 同一口径)。
|
||||
* validateStatus 恒真:状态码要自己判——真 404/5xx 一旦被拦截器折成 Error 就分不出原因了;
|
||||
* 能走到 catch 的就只剩网络层失败与超时,铁定瞬态。
|
||||
*/
|
||||
async function probeUploadedParts(uploadId: string): Promise<ProbeOutcome> {
|
||||
try {
|
||||
const response = await http.get(
|
||||
`/api/files/chunk/${encodeURIComponent(uploadId)}`,
|
||||
{ validateStatus: () => true },
|
||||
)
|
||||
return classifyProbe(response)
|
||||
} catch (error) {
|
||||
const status = (error as { response?: { status?: unknown } } | null | undefined)?.response?.status
|
||||
if (status === 404) return { state: 'gone' }
|
||||
if (messageSaysSessionGone((error as { message?: unknown } | null | undefined)?.message)) {
|
||||
return { state: 'gone' }
|
||||
}
|
||||
return { state: 'transient' }
|
||||
}
|
||||
}
|
||||
|
||||
/** 后管大档上传(版本包/教程包共用):会话续用 → GET 已达片号 → 逐片 POST → complete。 */
|
||||
export async function uploadFileInChunks(
|
||||
file: Blob,
|
||||
fileName: string,
|
||||
onProgress?: (percent: number) => void,
|
||||
): Promise<Record<string, unknown>> {
|
||||
const totalParts = Math.max(1, Math.ceil(file.size / CHUNK_UPLOAD_PART_SIZE))
|
||||
const sessionKey = chunkSessionKeyOf(fileName, file)
|
||||
let uploadId = readStoredSession(sessionKey, file)
|
||||
const arrived = new Set<number>()
|
||||
if (uploadId) {
|
||||
const probed = await probeUploadedParts(uploadId)
|
||||
if (probed.state === 'gone') {
|
||||
// 服务端确实说会话没了(404/「不存在或已过期」):清掉重开,否则这个件每次都在同一个死会话上失败。
|
||||
clearStoredSession(sessionKey)
|
||||
uploadId = ''
|
||||
} else if (probed.state === 'ok') {
|
||||
probed.parts.forEach((index) => arrived.add(index))
|
||||
}
|
||||
// transient:片号未知但会话还在 ⇒ 照原会话逐片重传(后端同片覆盖,幂等),不重开 init。
|
||||
}
|
||||
if (!uploadId) {
|
||||
const initResponse = await http.post('/api/files/chunk/init', null, {
|
||||
params: { fileName, totalParts, totalBytes: file.size },
|
||||
timeout: REQUEST_TIMEOUT_MS,
|
||||
})
|
||||
const init = (unwrap(initResponse.data) ?? {}) as Record<string, unknown>
|
||||
uploadId = String(init.upload_id ?? '')
|
||||
if (!uploadId) {
|
||||
throw new Error('后端未返回分片会话,请重试')
|
||||
}
|
||||
writeStoredSession(sessionKey, file, uploadId)
|
||||
}
|
||||
|
||||
for (let index = 0; index < totalParts; index += 1) {
|
||||
if (arrived.has(index)) {
|
||||
continue
|
||||
}
|
||||
const blob = file.slice(index * CHUNK_UPLOAD_PART_SIZE,
|
||||
Math.min(file.size, (index + 1) * CHUNK_UPLOAD_PART_SIZE))
|
||||
let lastError: unknown = null
|
||||
for (let attempt = 0; attempt <= PART_RETRY_LIMIT; attempt += 1) {
|
||||
const form = new FormData()
|
||||
form.append('file', blob, `part-${index}`)
|
||||
try {
|
||||
const partResponse = await http.post(partUrl(uploadId, index), form, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
timeout: partTimeoutOf(blob.size),
|
||||
onUploadProgress: (event) => {
|
||||
if (!onProgress) return
|
||||
const perPart = Math.round(((index + (event.loaded || 0) / Math.max(blob.size, 1)) / totalParts) * 100)
|
||||
onProgress(Math.min(perPart, 99))
|
||||
},
|
||||
})
|
||||
unwrap(partResponse.data)
|
||||
arrived.add(index)
|
||||
lastError = null
|
||||
break
|
||||
} catch (error) {
|
||||
lastError = error
|
||||
}
|
||||
}
|
||||
if (lastError) {
|
||||
// 不 DELETE(P2-7):会话连同已达片号留在服务端(后端 24h 过期回收兜底),
|
||||
// 下一次点开同一个文件就从断点接着传——这才是"续传"两个字的本义。
|
||||
throw lastError instanceof Error ? lastError : new Error('分片上传失败')
|
||||
}
|
||||
}
|
||||
|
||||
const completeResponse = await http.post(
|
||||
`/api/files/chunk/${encodeURIComponent(uploadId)}/complete`, null, { timeout: COMPLETE_TIMEOUT_MS })
|
||||
clearStoredSession(sessionKey)
|
||||
if (onProgress) onProgress(100)
|
||||
return (unwrap(completeResponse.data) ?? {}) as Record<string, unknown>
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/** 公司目录 DTO(设计文档 §2.3):纯逻辑,无框架依赖。 */
|
||||
|
||||
/** company.company_name 是 varchar(128),前端同步限长,免得撞库上 1406。 */
|
||||
export const COMPANY_NAME_MAX_LENGTH = 128
|
||||
|
||||
/** company.status:1=启用 0=停用(与 V143 列注释同口径)。 */
|
||||
export const COMPANY_STATUS_ACTIVE = 1
|
||||
export const COMPANY_STATUS_DISABLED = 0
|
||||
|
||||
/** 前端公司项(camelCase,与 Java CompanyVo 的 snake_case 线上字段对应)。 */
|
||||
export interface CompanyItem {
|
||||
id: number
|
||||
companyName: string
|
||||
status: number
|
||||
remark: string | null
|
||||
createdAt: string | null
|
||||
updatedAt: string | null
|
||||
/** 所属平台(V206):'amazon'|'jd';后端恒带值(列 NOT NULL DEFAULT 'amazon'),旧负载缺省不渲染。 */
|
||||
platform?: string
|
||||
/**
|
||||
* 在册账号数(2026-11-23):仅列表回包带(create/update 不带)。
|
||||
* 非零 ⇒ 该公司不能删(用户拍板「有账号不能删」),勾选框与删除按钮据此置灰。
|
||||
* 缺省(旧负载/测试桩)按 0 读——那是"看起来可删",后端删除时仍有权威校验兜底。
|
||||
*/
|
||||
userCount?: number
|
||||
}
|
||||
|
||||
/** 新建/改名的表单草稿。 */
|
||||
export interface CompanyDraft {
|
||||
companyName: string
|
||||
status?: number
|
||||
remark?: string | null
|
||||
/** 所属平台(V206):新建必带(页面从平台 tab 取),编辑显式下发,缺省后端不动。 */
|
||||
platform?: string
|
||||
}
|
||||
|
||||
export function text(value: unknown): string {
|
||||
return typeof value === 'string' ? value : ''
|
||||
}
|
||||
|
||||
export function trimmedOrNull(value: unknown): string | null {
|
||||
const raw = text(value).trim()
|
||||
return raw || null
|
||||
}
|
||||
|
||||
/** 校验草稿,返回错误文案;合法返回空串。 */
|
||||
export function validateCompanyDraft(draft: CompanyDraft): string {
|
||||
const name = text(draft.companyName).trim()
|
||||
if (!name) return '公司名称不能为空'
|
||||
if (name.length > COMPANY_NAME_MAX_LENGTH) {
|
||||
return `公司名称长度不能超过 ${COMPANY_NAME_MAX_LENGTH} 个字符`
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
/** 草稿 → POST/PUT 请求体(Java 侧 CompanySaveRequest 是 camelCase,与 AdminUserCreateRequest 同口径)。 */
|
||||
export function toCompanyPayload(draft: CompanyDraft): Record<string, unknown> {
|
||||
const payload: Record<string, unknown> = { companyName: text(draft.companyName).trim() }
|
||||
if (typeof draft.status === 'number') payload.status = draft.status
|
||||
payload.remark = trimmedOrNull(draft.remark)
|
||||
if (draft.platform) payload.platform = draft.platform
|
||||
return payload
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/** 公司目录响应解析:Java CompanyVo(snake_case) → 前端 CompanyItem(camelCase)。 */
|
||||
import { unwrap } from './envelope.ts'
|
||||
import {
|
||||
COMPANY_STATUS_ACTIVE,
|
||||
COMPANY_STATUS_DISABLED,
|
||||
text,
|
||||
trimmedOrNull,
|
||||
type CompanyItem,
|
||||
} from './companies-dto.ts'
|
||||
|
||||
function numberOrNull(value: unknown): number | null {
|
||||
return typeof value === 'number' && Number.isFinite(value) ? Math.floor(value) : null
|
||||
}
|
||||
|
||||
/** 单条映射;无 id 视为无效行(列表中直接丢弃,避免编辑时打到 /companies/undefined)。 */
|
||||
export function toCompanyItem(raw: unknown): CompanyItem | null {
|
||||
if (!raw || typeof raw !== 'object') return null
|
||||
const r = raw as Record<string, unknown>
|
||||
const id = numberOrNull(r.id)
|
||||
if (id === null) return null
|
||||
const item: CompanyItem = {
|
||||
id,
|
||||
companyName: text(r.company_name),
|
||||
// status 列 NOT NULL,取不到就是链路异常;未知一律按停用,不把异常状态当启用。
|
||||
status: r.status === COMPANY_STATUS_ACTIVE ? COMPANY_STATUS_ACTIVE : COMPANY_STATUS_DISABLED,
|
||||
remark: trimmedOrNull(r.remark),
|
||||
createdAt: trimmedOrNull(r.created_at),
|
||||
updatedAt: trimmedOrNull(r.updated_at),
|
||||
}
|
||||
// platform 后端恒带(列 NOT NULL);旧负载/测试桩缺省就不渲染该键,字段形状与 users-model 一致。
|
||||
const platform = text(r.platform)
|
||||
if (platform) item.platform = platform
|
||||
// user_count 仅公司目录列表下发(create/update 不带);非负整数才认,缺省不渲染(按 0 读)。
|
||||
const userCount = numberOrNull(r.user_count)
|
||||
if (userCount !== null && userCount >= 0) item.userCount = userCount
|
||||
return item
|
||||
}
|
||||
|
||||
/** 解析 GET /api/admin/companies:接受 data 为数组或 {items:[...]},success=false 抛后端文案。 */
|
||||
export function parseCompanyList(payload: unknown): CompanyItem[] {
|
||||
const core = unwrap<unknown>(payload)
|
||||
if (!core || typeof core !== 'object') return []
|
||||
const candidate = Array.isArray(core) ? core : (core as { items?: unknown }).items
|
||||
if (!Array.isArray(candidate)) return []
|
||||
return candidate
|
||||
.map((raw) => toCompanyItem(raw))
|
||||
.filter((item): item is CompanyItem => item !== null)
|
||||
}
|
||||
|
||||
/** 解析 POST/PUT 回包(data 为 CompanyVo)。 */
|
||||
export function parseCompany(payload: unknown): CompanyItem | null {
|
||||
const core = unwrap<unknown>(payload)
|
||||
if (!core || typeof core !== 'object' || Array.isArray(core)) return null
|
||||
return toCompanyItem(core)
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
import { http } from './http'
|
||||
import { parseCompany, parseCompanyList } from './companies-model'
|
||||
import { toCompanyPayload, type CompanyDraft, type CompanyItem } from './companies-dto'
|
||||
|
||||
/** 公司目录(设计文档 §2.3)。GET 的可见范围由后端收窄:超管全部、公司内 admin 只自己公司。 */
|
||||
|
||||
export async function fetchCompanies(platform?: string): Promise<CompanyItem[]> {
|
||||
const { data } = await http.get('/api/admin/companies', {
|
||||
params: platform ? { platform } : {},
|
||||
})
|
||||
return parseCompanyList(data)
|
||||
}
|
||||
|
||||
export async function createCompany(draft: CompanyDraft): Promise<CompanyItem | null> {
|
||||
const { data } = await http.post('/api/admin/companies', toCompanyPayload(draft))
|
||||
return parseCompany(data)
|
||||
}
|
||||
|
||||
/** 改名 / 启停(删除走独立出口 deleteCompany,与用户管理同形)。 */
|
||||
export async function updateCompany(id: number, draft: CompanyDraft): Promise<CompanyItem | null> {
|
||||
const { data } = await http.put(`/api/admin/companies/${id}`, toCompanyPayload(draft))
|
||||
return parseCompany(data)
|
||||
}
|
||||
|
||||
/** 删除公司:DELETE /api/admin/companies/{id},success=false 由 unwrap 抛后端 message。 */
|
||||
export async function deleteCompany(id: number): Promise<void> {
|
||||
await http.delete<unknown>(`/api/admin/companies/${id}`)
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
import { http } from './http'
|
||||
import { unwrap } from './envelope'
|
||||
|
||||
/** 日志文件行(桌面客户端 / 麦象采集机上报)。 */
|
||||
export interface DeviceLogFileRow {
|
||||
id: number
|
||||
source: string
|
||||
deviceId: string
|
||||
deviceName: string | null
|
||||
username: string | null
|
||||
uid: number | null
|
||||
fileName: string
|
||||
logDate: string
|
||||
uploadedBytes: number
|
||||
partCount: number
|
||||
lastUploadAt: string | null
|
||||
createdAt: string | null
|
||||
}
|
||||
|
||||
export interface DeviceLogPage {
|
||||
items: DeviceLogFileRow[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
/** 云端日志保留天数(页面提示用)。 */
|
||||
retentionDays: number
|
||||
}
|
||||
|
||||
export interface DeviceLogContent {
|
||||
fileId: number
|
||||
fileName: string
|
||||
content: string
|
||||
totalBytes: number
|
||||
shownBytes: number
|
||||
truncated: boolean
|
||||
}
|
||||
|
||||
export interface DeviceLogDevice {
|
||||
source: string
|
||||
deviceId: string
|
||||
deviceName: string | null
|
||||
lastUploadAt: string | null
|
||||
}
|
||||
|
||||
export interface DeviceLogOverride {
|
||||
id: number
|
||||
source: string
|
||||
deviceId: string
|
||||
deviceName: string | null
|
||||
mode: string
|
||||
updatedAt: string | null
|
||||
}
|
||||
|
||||
export interface DeviceLogConfigData {
|
||||
globalMode: string
|
||||
overrides: DeviceLogOverride[]
|
||||
}
|
||||
|
||||
export interface DeviceLogQuery {
|
||||
source?: string
|
||||
/** 指定用户(users.id);不传=全部上报者,含 uid 为空的采集机与未登录客户端。 */
|
||||
uid?: number
|
||||
startDate?: string
|
||||
endDate?: string
|
||||
page: number
|
||||
pageSize: number
|
||||
/** 超管选中的公司 tab;null/undefined=不发这个参数,后端按「不筛」出全量(非超管恒不发)。 */
|
||||
companyId?: number | null
|
||||
}
|
||||
|
||||
/** 分页查询日志文件列表:GET /api/admin/device-logs/files */
|
||||
export async function fetchDeviceLogFiles(params: DeviceLogQuery): Promise<DeviceLogPage> {
|
||||
const query: Record<string, string | number> = { page: params.page, pageSize: params.pageSize }
|
||||
if (params.source) query.source = params.source
|
||||
if (params.uid) query.uid = params.uid
|
||||
if (params.startDate) query.startDate = params.startDate
|
||||
if (params.endDate) query.endDate = params.endDate
|
||||
// 公司值由页面组件(companyTab.requestCompanyId)传进来,本模块不读 Pinia store。
|
||||
// query 是这里逐字段点名的白名单构造 ⇒ 右半边只许取原始 params。
|
||||
if (params.companyId != null) query.company_id = params.companyId
|
||||
const { data } = await http.get('/api/admin/device-logs/files', { params: query })
|
||||
return unwrap<DeviceLogPage>(data)
|
||||
}
|
||||
|
||||
/** 查看日志尾部内容:GET /api/admin/device-logs/content */
|
||||
export async function fetchDeviceLogContent(fileId: number, maxBytes?: number): Promise<DeviceLogContent> {
|
||||
const query: Record<string, number> = { fileId }
|
||||
if (maxBytes) query.maxBytes = maxBytes
|
||||
const { data } = await http.get('/api/admin/device-logs/content', { params: query })
|
||||
return unwrap<DeviceLogContent>(data)
|
||||
}
|
||||
|
||||
/** 完整日志下载地址(同域 cookie 鉴权,直接给 a[href] 或 window.open 用)。 */
|
||||
export function deviceLogDownloadUrl(fileId: number): string {
|
||||
return `/api/admin/device-logs/download?fileId=${fileId}`
|
||||
}
|
||||
|
||||
/** 删除日志文件(片段与元数据,不可恢复):DELETE /api/admin/device-logs/{id} */
|
||||
export async function deleteDeviceLogFile(id: number): Promise<void> {
|
||||
const { data } = await http.delete(`/api/admin/device-logs/${id}`)
|
||||
unwrap<unknown>(data)
|
||||
}
|
||||
|
||||
/** 采集配置(全局默认 + 终端覆盖):GET /api/admin/device-logs/config */
|
||||
export async function fetchDeviceLogConfig(keyword?: string): Promise<DeviceLogConfigData> {
|
||||
const { data } = await http.get('/api/admin/device-logs/config', {
|
||||
params: keyword ? { keyword } : undefined,
|
||||
})
|
||||
return unwrap<DeviceLogConfigData>(data)
|
||||
}
|
||||
|
||||
/** 最近上报过的终端(覆盖选择用):GET /api/admin/device-logs/devices */
|
||||
export async function fetchDeviceLogDevices(): Promise<DeviceLogDevice[]> {
|
||||
const { data } = await http.get('/api/admin/device-logs/devices')
|
||||
return unwrap<DeviceLogDevice[]>(data)
|
||||
}
|
||||
|
||||
/** 设置全局采集模式:PUT /api/admin/device-logs/config/global */
|
||||
export async function updateDeviceLogGlobalMode(mode: string): Promise<void> {
|
||||
const { data } = await http.put('/api/admin/device-logs/config/global', undefined, { params: { mode } })
|
||||
unwrap<unknown>(data)
|
||||
}
|
||||
|
||||
/** 设置/更新终端覆盖:PUT /api/admin/device-logs/config/device */
|
||||
export async function updateDeviceLogOverride(
|
||||
source: string,
|
||||
deviceId: string,
|
||||
deviceName: string | null,
|
||||
mode: string,
|
||||
): Promise<void> {
|
||||
const { data } = await http.put('/api/admin/device-logs/config/device', undefined, {
|
||||
params: { source, deviceId, deviceName: deviceName || undefined, mode },
|
||||
})
|
||||
unwrap<unknown>(data)
|
||||
}
|
||||
|
||||
/** 删除终端覆盖(回落到全局默认):DELETE /api/admin/device-logs/config/device/{id} */
|
||||
export async function deleteDeviceLogOverride(id: number): Promise<void> {
|
||||
const { data } = await http.delete(`/api/admin/device-logs/config/device/${id}`)
|
||||
unwrap<unknown>(data)
|
||||
}
|
||||
@@ -1,14 +1,12 @@
|
||||
/** API 响应解包与错误归一化(任务 22):纯函数,无框架依赖(只借 config/app 的 base 常量)。 */
|
||||
import { userNotice } from './user-notice.ts'
|
||||
import { joinAdminPath } from '../config/app.ts'
|
||||
/** API 响应解包与错误归一化(任务 22):纯函数,无框架依赖。 */
|
||||
|
||||
export const REQUEST_FALLBACK_MESSAGE = '网络异常,请稍后重试'
|
||||
|
||||
function textOf(value: Record<string, unknown>): string {
|
||||
const message = value.message
|
||||
const error = value.error
|
||||
if (typeof message === 'string' && message.trim()) return userNotice(message)
|
||||
if (typeof error === 'string' && error.trim()) return userNotice(error)
|
||||
if (typeof message === 'string' && message.trim()) return message.trim()
|
||||
if (typeof error === 'string' && error.trim()) return error.trim()
|
||||
return ''
|
||||
}
|
||||
|
||||
@@ -32,12 +30,12 @@ export function unwrap<T>(payload: unknown): T {
|
||||
|
||||
/** 从任意负载取错误文案;缺省回退。 */
|
||||
export function errorTextOf(payload: unknown): string {
|
||||
if (payload instanceof Error) return userNotice(payload.message, REQUEST_FALLBACK_MESSAGE)
|
||||
if (payload instanceof Error) return payload.message.trim() || REQUEST_FALLBACK_MESSAGE
|
||||
if (payload && typeof payload === 'object') {
|
||||
const text = textOf(payload as Record<string, unknown>)
|
||||
if (text) return text
|
||||
}
|
||||
if (typeof payload === 'string' && payload.trim()) return payload
|
||||
if (typeof payload === 'string' && payload.trim()) return payload.trim()
|
||||
return REQUEST_FALLBACK_MESSAGE
|
||||
}
|
||||
|
||||
@@ -48,20 +46,6 @@ export function isUnauthorized(payload: unknown): boolean {
|
||||
return [record.status, record.statusCode, record.code].some((v) => v === 401)
|
||||
}
|
||||
|
||||
/** 负载/状态码是否 403(已登录但无后台权限)。 */
|
||||
export function isForbidden(payload: unknown): boolean {
|
||||
const record = payload as { status?: unknown; statusCode?: unknown; code?: unknown } | null
|
||||
if (!record || typeof record !== 'object') return false
|
||||
return [record.status, record.statusCode, record.code].some((v) => v === 403)
|
||||
}
|
||||
|
||||
/** 单设备登录:账号已在其他设备登录(4011,与后端 DeviceSessionPolicy.CODE_KICKED 对齐)。 */
|
||||
export function isKicked(payload: unknown): boolean {
|
||||
const record = payload as { code?: unknown } | null
|
||||
if (!record || typeof record !== 'object') return false
|
||||
return record.code === 4011
|
||||
}
|
||||
|
||||
/** Axios 错误(带 response)或普通 Error 统一取可展示文案。 */
|
||||
export function requestErrorMessage(error: unknown): string {
|
||||
const response = (error as { response?: { data?: unknown; status?: number } })?.response
|
||||
@@ -80,22 +64,11 @@ export function loginRedirectTarget(location: { pathname: string; search: string
|
||||
/** 登录页统一入口;401 一律跳此路径。 */
|
||||
export const LOGIN_PATH = '/login'
|
||||
|
||||
/**
|
||||
* 浏览器地址栏里的登录页形态。
|
||||
*
|
||||
* <p>LOGIN_PATH 是路由内的相对路径(axios 的 url 也用它比较),而 `window.location.pathname`
|
||||
* 带 History base,生产实际值是 `/admin-vue/login`。少这一条,"已经在登录页就别再跳"
|
||||
* 的守卫在真机上一次都没生效过:2026-10-06 那次登录失败,拦截器把整页重刷成
|
||||
* `/admin-vue/login?redirect=…`,连刚填的用户名和错误原因一起没了。</p>
|
||||
*/
|
||||
export const LOGIN_LOCATION_PATH = joinAdminPath('login')
|
||||
|
||||
/** 当前 pathname 是否处于登录页(去掉可能携带的查询串后比较)。 */
|
||||
export function isLoginLocation(pathname: string): boolean {
|
||||
if (typeof pathname !== 'string') return false
|
||||
const queryAt = pathname.indexOf('?')
|
||||
const path = queryAt >= 0 ? pathname.slice(0, queryAt) : pathname
|
||||
return path === LOGIN_PATH || path === LOGIN_LOCATION_PATH || path === `${LOGIN_LOCATION_PATH}/`
|
||||
return (queryAt >= 0 ? pathname.slice(0, queryAt) : pathname) === LOGIN_PATH
|
||||
}
|
||||
|
||||
/** 把请求 URL(相对或绝对)规整为相对路径,便于与登录入口比较。 */
|
||||
@@ -106,24 +79,6 @@ export function requestRelativePath(url: string): string {
|
||||
return match ? match[1] : noQuery
|
||||
}
|
||||
|
||||
/**
|
||||
* 会话引导端点:只有这里的 403 才等于"这个账号进不了后台"(比如拿客户端 token 打开后台),
|
||||
* 除了去登录页没有别的出路。
|
||||
*
|
||||
* <p>其余端点的 403 是"已经登录、但缺这个模块的权限",和身份无关。把它按未登录整页跳走,
|
||||
* 等于把权限缺口伪装成登录故障:2026-10-04 那次"登录闪退"报的其实是
|
||||
* GET /api/admin/companies 的 403,代价是当前页连人带未提交的表单一起没了。</p>
|
||||
*/
|
||||
export const SESSION_BOOTSTRAP_PATHS: readonly string[] = [
|
||||
'/api/admin/current-user',
|
||||
'/api/admin/current-user/menus',
|
||||
]
|
||||
|
||||
/** 403 是否应执行"跳 /login":仅当失败的请求本身是会话引导端点。 */
|
||||
export function shouldRedirectForbidden(requestUrl: string | undefined): boolean {
|
||||
return SESSION_BOOTSTRAP_PATHS.includes(requestRelativePath(requestUrl || ''))
|
||||
}
|
||||
|
||||
/** 401 失败请求本身是否指向登录/认证端点(登录提交失败不应再被踢回登录页)。 */
|
||||
export function isAuthEndpointRequest(url: string | undefined): boolean {
|
||||
return requestRelativePath(url || '') === LOGIN_PATH
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
import axios from 'axios'
|
||||
import {
|
||||
isForbidden,
|
||||
isKicked,
|
||||
isLoginLocation,
|
||||
isUnauthorized,
|
||||
loginRedirectTarget,
|
||||
shouldRedirectForbidden,
|
||||
shouldRedirectUnauthorized,
|
||||
} from './envelope'
|
||||
import { isUnauthorized, loginRedirectTarget, shouldRedirectUnauthorized } from './envelope'
|
||||
|
||||
export { unwrap } from './envelope'
|
||||
|
||||
@@ -17,56 +9,23 @@ export const http = axios.create({
|
||||
timeout: 30_000,
|
||||
})
|
||||
|
||||
/** 会话失效成因(后端 X-Auth-Reason 头):disabled=已停用、deleted=已删除;其余 401 无成因。 */
|
||||
function authReasonOf(headers: unknown): string {
|
||||
const value = (headers as Record<string, unknown> | undefined)?.['x-auth-reason']
|
||||
return value === 'disabled' || value === 'deleted' ? value : ''
|
||||
}
|
||||
|
||||
function redirectToLogin(requestUrl?: string, reason = ''): void {
|
||||
function redirectToLogin(requestUrl?: string): void {
|
||||
if (typeof window === 'undefined') return
|
||||
// 已在登录页或失败请求即登录端点时不再跳转,避免登录页循环与吞掉登录失败反馈。
|
||||
if (!shouldRedirectUnauthorized(window.location.pathname, requestUrl)) return
|
||||
const target = loginRedirectTarget(window.location)
|
||||
// 成因随 query 带给登录页点名(停用/删除),登录页据此显示对应提示
|
||||
window.location.assign('/admin-vue/login?redirect=' + target + (reason ? `&auth=${reason}` : ''))
|
||||
}
|
||||
|
||||
/** 403 只在会话引导端点上才当"进不了后台"处理;其余端点的 403 交给页面自己把原因说出来。 */
|
||||
function redirectToLoginOnForbidden(requestUrl?: string): void {
|
||||
if (!shouldRedirectForbidden(requestUrl)) return
|
||||
redirectToLogin(requestUrl)
|
||||
}
|
||||
|
||||
/** 单设备登录:被新设备顶下线,整页回登录页(整页 reload 顺带重置会话 store,避免守卫弹回)。 */
|
||||
function redirectToLoginKicked(): void {
|
||||
if (typeof window === 'undefined') return
|
||||
if (isLoginLocation(window.location.pathname)) return
|
||||
window.location.assign('/admin-vue/login?kicked=1')
|
||||
window.location.assign('/admin-vue/login?redirect=' + target)
|
||||
}
|
||||
|
||||
http.interceptors.response.use(
|
||||
(response) => {
|
||||
// Java 未登录以 HTTP 200 + body.code=401 返回,需统一按未登录处理;
|
||||
// 403(已登录但无后台权限)只在会话引导端点上按"进不了后台"跳登录页,
|
||||
// 业务端点的 403 留给页面自己报错——整页跳走会把权限缺口说成登录坏了。
|
||||
// 4011(账号已在其他设备登录)单独提示,不按普通 401 处理。
|
||||
if (isKicked(response.data)) {
|
||||
redirectToLoginKicked()
|
||||
} else if (isUnauthorized(response.data)) {
|
||||
redirectToLogin(response.config?.url, authReasonOf(response.headers))
|
||||
} else if (isForbidden(response.data)) {
|
||||
redirectToLoginOnForbidden(response.config?.url)
|
||||
}
|
||||
// Java 未登录以 HTTP 200 + body.code=401 返回,需统一按未登录处理。
|
||||
if (isUnauthorized(response.data)) redirectToLogin(response.config?.url)
|
||||
return response
|
||||
},
|
||||
(error) => {
|
||||
if (isKicked(error?.response?.data)) {
|
||||
redirectToLoginKicked()
|
||||
} else if (error?.response?.status === 401 || isUnauthorized(error?.response?.data)) {
|
||||
redirectToLogin(error?.config?.url, authReasonOf(error?.response?.headers))
|
||||
} else if (error?.response?.status === 403 || isForbidden(error?.response?.data)) {
|
||||
redirectToLoginOnForbidden(error?.config?.url)
|
||||
if (error?.response?.status === 401 || isUnauthorized(error?.response?.data)) {
|
||||
redirectToLogin(error?.config?.url)
|
||||
}
|
||||
return Promise.reject(error)
|
||||
},
|
||||
|
||||
@@ -1,160 +0,0 @@
|
||||
import { http } from './http'
|
||||
import { unwrap } from './envelope'
|
||||
|
||||
/** 业务严重度:紧急 / 高危 / 中危 / 低危(后端按 scene + level 推导)。 */
|
||||
export type AdminNotificationSeverity = 'urgent' | 'high' | 'medium' | 'low'
|
||||
|
||||
export type AdminNotificationSortMode = 'severity' | 'time'
|
||||
|
||||
export const ADMIN_NOTIFICATION_SEVERITY_LABELS: Readonly<Record<AdminNotificationSeverity, string>> = {
|
||||
urgent: '紧急',
|
||||
high: '高危',
|
||||
medium: '中危',
|
||||
low: '低危',
|
||||
}
|
||||
|
||||
/** 通知里的结构化定位锚点(当前只有 task_failed 使用:桶内每个失败任务一项)。 */
|
||||
export interface AdminNotificationRef {
|
||||
taskId: number | null
|
||||
/** 任务号;品牌任务为 #<id>。任务详情接口按它查。 */
|
||||
taskNo: string
|
||||
moduleType?: string | null
|
||||
reason?: string | null
|
||||
updatedAt?: string | null
|
||||
deviceId?: string | null
|
||||
}
|
||||
|
||||
/** 单条通知(后台铃铛)。 */
|
||||
export interface AdminNotificationItem {
|
||||
id: number
|
||||
scene: string
|
||||
level: string
|
||||
/** 业务严重度;旧后端不返回时前端按 level 兜底。 */
|
||||
severity?: string
|
||||
title: string
|
||||
content: string
|
||||
/** 可点的定位锚点;旧后端/历史行没有这一列时为空。 */
|
||||
refs?: AdminNotificationRef[] | null
|
||||
read: boolean
|
||||
readAt: string | null
|
||||
createdAt: string | null
|
||||
}
|
||||
|
||||
export interface AdminNotificationPage {
|
||||
items: AdminNotificationItem[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
unreadCount: number
|
||||
}
|
||||
|
||||
export interface AdminNotificationSummary {
|
||||
unreadCount: number
|
||||
/** 有未读的聚合组数;徽标用它。unreadCount 仍是"条数",给老明细视图与对账用。 */
|
||||
unreadGroupCount?: number
|
||||
latestId: number
|
||||
}
|
||||
|
||||
/** 聚合组:一个「场景 × 自然日 × 事件主体用户」折成的一行。 */
|
||||
export interface AdminNotificationGroup {
|
||||
latestId: number
|
||||
scene: string
|
||||
category: string
|
||||
day: string
|
||||
subjectUserId: number | null
|
||||
rowCount: number
|
||||
unreadCount: number
|
||||
level: string
|
||||
/** 组内最高严重度。 */
|
||||
severity?: string
|
||||
title: string
|
||||
content: string
|
||||
createdAt: string | null
|
||||
}
|
||||
|
||||
export interface AdminNotificationGroupPage {
|
||||
groups: AdminNotificationGroup[]
|
||||
/** 组数(分页分母)。 */
|
||||
total: number
|
||||
/** 折叠前的明细条数——必须与 total 同屏,否则「共 12 条」会被读成只有 12 条通知。 */
|
||||
rowCount: number
|
||||
page: number
|
||||
pageSize: number
|
||||
unreadGroupCount: number
|
||||
unreadCount: number
|
||||
}
|
||||
|
||||
/** 铃铛轮询:未读数 + 最新通知 id。 */
|
||||
export async function fetchNotificationSummary(): Promise<AdminNotificationSummary> {
|
||||
const { data } = await http.get('/api/admin/notifications/summary')
|
||||
return unwrap<AdminNotificationSummary>(data)
|
||||
}
|
||||
|
||||
/** 列表查询参数:关键字匹配标题/内容;startDate/endDate 为年月日闭区间(yyyy-MM-dd)。 */
|
||||
export interface AdminNotificationListParams {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
onlyUnread?: boolean
|
||||
keyword?: string
|
||||
startDate?: string
|
||||
endDate?: string
|
||||
/** 排序:severity(默认)或 time;默认值不下发。 */
|
||||
sort?: AdminNotificationSortMode
|
||||
/** 展开聚合组:三个条件取自该组自己返回的值,原样回传。 */
|
||||
scene?: string
|
||||
day?: string
|
||||
subjectUserId?: number | null
|
||||
/** true 表示展开「未区分用户」那一组(subject_user_id 为空的存量行)。 */
|
||||
subjectUnlabelled?: boolean
|
||||
}
|
||||
|
||||
/** 聚合列表(铃铛默认视图)。分页按组切。 */
|
||||
export async function fetchNotificationGroups(
|
||||
params: AdminNotificationListParams = {},
|
||||
): Promise<AdminNotificationGroupPage> {
|
||||
const keyword = (params.keyword ?? '').trim()
|
||||
const { data } = await http.get('/api/admin/notifications/groups', {
|
||||
params: {
|
||||
page: params.page ?? 1,
|
||||
pageSize: params.pageSize ?? 20,
|
||||
onlyUnread: params.onlyUnread ? 'true' : 'false',
|
||||
keyword: keyword || undefined,
|
||||
startDate: params.startDate || undefined,
|
||||
endDate: params.endDate || undefined,
|
||||
sort: params.sort === 'time' ? 'time' : undefined,
|
||||
},
|
||||
})
|
||||
return unwrap<AdminNotificationGroupPage>(data)
|
||||
}
|
||||
|
||||
export async function fetchNotificationList(
|
||||
params: AdminNotificationListParams = {},
|
||||
): Promise<AdminNotificationPage> {
|
||||
const keyword = (params.keyword ?? '').trim()
|
||||
const { data } = await http.get('/api/admin/notifications', {
|
||||
params: {
|
||||
page: params.page ?? 1,
|
||||
pageSize: params.pageSize ?? 20,
|
||||
onlyUnread: params.onlyUnread ? 'true' : 'false',
|
||||
keyword: keyword || undefined,
|
||||
startDate: params.startDate || undefined,
|
||||
endDate: params.endDate || undefined,
|
||||
sort: params.sort === 'time' ? 'time' : undefined,
|
||||
scene: params.scene || undefined,
|
||||
day: params.day || undefined,
|
||||
subjectUserId: params.subjectUserId ?? undefined,
|
||||
subjectUnlabelled: params.subjectUnlabelled ? 'true' : undefined,
|
||||
},
|
||||
})
|
||||
return unwrap<AdminNotificationPage>(data)
|
||||
}
|
||||
|
||||
export async function markNotificationRead(id: number): Promise<boolean> {
|
||||
const { data } = await http.post(`/api/admin/notifications/${id}/read`)
|
||||
return unwrap<boolean>(data)
|
||||
}
|
||||
|
||||
export async function markAllNotificationsRead(): Promise<number> {
|
||||
const { data } = await http.post('/api/admin/notifications/read-all')
|
||||
return unwrap<number>(data)
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
import { http } from './http'
|
||||
import { unwrap } from './envelope'
|
||||
|
||||
/** 客户端任务管理(后台看板):按账号 × 店铺 × 业务统一查看客户端任务,全部只读。 */
|
||||
|
||||
/** 查询参数(由页面侧 buildTaskQuery / buildVariantQuery 产出,空白项不下传)。 */
|
||||
type QueryParams = Record<string, string | number>
|
||||
|
||||
export interface TaskCenterOverview {
|
||||
shopTotal: number
|
||||
shopRunning: number
|
||||
runningTasks: number
|
||||
todayFinishedTasks: number
|
||||
stuckTasks: number
|
||||
}
|
||||
|
||||
export interface TaskCenterTaskRow {
|
||||
id: number
|
||||
taskNo: string
|
||||
moduleType: string
|
||||
moduleLabel: string
|
||||
status: string
|
||||
userId: number | null
|
||||
username: string | null
|
||||
deviceId: string | null
|
||||
deviceName: string | null
|
||||
webDevice: boolean
|
||||
shopName: string | null
|
||||
shopCount: number
|
||||
/** 目标站点国家码(后端从 request_json 归一,多国家用 / 连);该模块不写国家时为 null。 */
|
||||
country: string | null
|
||||
createdAt: string | null
|
||||
finishedAt: string | null
|
||||
lastReportAt: string | null
|
||||
progressTotal: number
|
||||
progressSuccess: number
|
||||
progressFailed: number
|
||||
currentScope: string | null
|
||||
message: string | null
|
||||
stuck: boolean
|
||||
}
|
||||
|
||||
export interface TaskCenterTaskPage {
|
||||
items: TaskCenterTaskRow[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
export interface TaskCenterShopStat {
|
||||
scopeKey: string
|
||||
total: number
|
||||
success: number
|
||||
failed: number
|
||||
}
|
||||
|
||||
export interface TaskCenterTaskDetail extends TaskCenterTaskRow {
|
||||
shops: TaskCenterShopStat[]
|
||||
errorMessage: string | null
|
||||
}
|
||||
|
||||
export interface TaskCenterVariantTaskRow {
|
||||
taskId: string
|
||||
uid: string | null
|
||||
username: string | null
|
||||
status: number | null
|
||||
statusLabel: string | null
|
||||
resMes: string | null
|
||||
taskData: string | null
|
||||
createTime: string | null
|
||||
updateTime: string | null
|
||||
}
|
||||
|
||||
export interface TaskCenterVariantPage {
|
||||
items: TaskCenterVariantTaskRow[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
/**
|
||||
* 汇总卡:GET /api/admin/task-center/overview
|
||||
* companyId = 公司 tab 选中的公司(超管专用,页面只从 companyTab.requestCompanyId 取);
|
||||
* null/undefined 由这里自己丢掉——不发给后端 = 按会话口径看全部,不是「筛成空」。
|
||||
*/
|
||||
export async function fetchTaskCenterOverview(companyId?: number | null): Promise<TaskCenterOverview> {
|
||||
const query: QueryParams = {}
|
||||
if (companyId != null) query.company_id = companyId
|
||||
const { data } = await http.get('/api/admin/task-center/overview', { params: query })
|
||||
return unwrap<TaskCenterOverview>(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺筛选候选(店铺库内的店铺名,精确匹配):GET /api/admin/task-center/shop-options
|
||||
* 下拉候选必须跟列表同宽:少了这一支,切 tab 后能选到别家的店铺名(选了又筛不出东西)。
|
||||
*/
|
||||
export async function fetchTaskCenterShopOptions(companyId?: number | null): Promise<string[]> {
|
||||
const query: QueryParams = {}
|
||||
if (companyId != null) query.company_id = companyId
|
||||
const { data } = await http.get('/api/admin/task-center/shop-options', { params: query })
|
||||
return unwrap<string[]>(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务分页列表:GET /api/admin/task-center/tasks
|
||||
* params 由 buildTaskQuery 构造(含 company_id,见 task-center-model.ts)。
|
||||
*/
|
||||
export async function fetchTaskCenterTasks(params: QueryParams): Promise<TaskCenterTaskPage> {
|
||||
const { data } = await http.get('/api/admin/task-center/tasks', { params })
|
||||
return unwrap<TaskCenterTaskPage>(data)
|
||||
}
|
||||
|
||||
/** 任务详情(品牌任务 taskNo 形如 brand-1):GET /api/admin/task-center/tasks/detail
|
||||
* 任务不存在或不在可见范围时后端返回 success + data:null,这里归一为 null 供页面提示(unwrap 对 null data 会回传信封)。 */
|
||||
export async function fetchTaskCenterTaskDetail(
|
||||
taskNo: string,
|
||||
companyId?: number | null,
|
||||
): Promise<TaskCenterTaskDetail | null> {
|
||||
const query: QueryParams = { taskNo }
|
||||
if (companyId != null) query.company_id = companyId
|
||||
const { data } = await http.get('/api/admin/task-center/tasks/detail', { params: query })
|
||||
const envelope = data as { data?: unknown } | null
|
||||
if (envelope && typeof envelope === 'object' && 'data' in envelope && envelope.data == null) return null
|
||||
return unwrap<TaskCenterTaskDetail>(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 变体采集(代理麦象 console,取当前可见用户集合):GET /api/admin/task-center/variant-tasks
|
||||
* params 由 buildVariantQuery 构造(含 company_id,见 task-center-model.ts)。
|
||||
*/
|
||||
export async function fetchTaskCenterVariantTasks(params: QueryParams): Promise<TaskCenterVariantPage> {
|
||||
const { data } = await http.get('/api/admin/task-center/variant-tasks', { params })
|
||||
return unwrap<TaskCenterVariantPage>(data)
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/**
|
||||
* 后台提示语把关(2026-10-09):只把中文给用户看。
|
||||
*
|
||||
* Java 侧仍有出口把底层异常原文写进 message/errorMessage,后台同学看到
|
||||
* `Invalid export date range` 这类句子既看不懂也没法转述给用户。这里统一换成中文兜底句,
|
||||
* 原文进 console 供对着日志核对。
|
||||
*/
|
||||
|
||||
const CJK = /[\u3400-\u4dbf\u4e00-\u9fff]/
|
||||
|
||||
export const NOTICE_FALLBACK = '操作未能完成,请稍后重试'
|
||||
|
||||
export function userNotice(text?: string | null, fallback: string = NOTICE_FALLBACK): string {
|
||||
const raw = typeof text === 'string' ? text.trim() : ''
|
||||
if (!raw) {
|
||||
return fallback
|
||||
}
|
||||
if (!CJK.test(raw)) {
|
||||
console.warn('[user-notice] 提示语原文不是中文,已换成中文兜底句,原文:', raw)
|
||||
return fallback
|
||||
}
|
||||
// 中文主干 + 英文尾巴(后端把底层异常原文拼在冒号后):留主干,尾巴只进 console
|
||||
const at = Math.max(raw.lastIndexOf(':'), raw.lastIndexOf(':'))
|
||||
if (at > 0 && !CJK.test(raw.slice(at + 1))) {
|
||||
const head = raw.slice(0, at).trim()
|
||||
if (CJK.test(head)) {
|
||||
console.warn('[user-notice] 提示语尾巴是英文,已隐去,原文:', raw)
|
||||
return head
|
||||
}
|
||||
}
|
||||
return raw
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
import { http } from './http'
|
||||
import { unwrap } from './envelope'
|
||||
|
||||
/** 单用户一行:三类密钥调用次数 + 合计(口径=真实对外请求次数)。 */
|
||||
export interface AdminUserSecretUsageRow {
|
||||
userId: number
|
||||
username: string
|
||||
groups: string[]
|
||||
similarAsinCount: number
|
||||
appearancePatentCount: number
|
||||
proxyCount: number
|
||||
totalCount: number
|
||||
}
|
||||
|
||||
export interface AdminUserSecretUsagePage {
|
||||
items: AdminUserSecretUsageRow[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
/** 所选范围内(不分页)三类总次数。 */
|
||||
totalCalls: number
|
||||
similarAsinCalls: number
|
||||
appearancePatentCalls: number
|
||||
proxyCalls: number
|
||||
groupOptions?: Array<{ id: number; groupName: string }>
|
||||
}
|
||||
|
||||
export interface UserSecretUsageQuery {
|
||||
startDate?: string
|
||||
endDate?: string
|
||||
keyword?: string
|
||||
/** 按数据权限分组筛选(仅超管生效);后端参数为 snake_case。 */
|
||||
groupId?: number
|
||||
/** 公司 tab 的当前口径;不传 = 后端按操作者自己的公司(批次 1 里非超管只有这一家)。 */
|
||||
companyId?: number | null
|
||||
/** 平台 tab(amazon/jd):按 users.platform 过滤(2026-11-22 京东侧新增);不传 = 旧行为不筛。 */
|
||||
platform?: string
|
||||
page: number
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
/** 分页查询密钥用量:GET /api/admin/user-secret-usage(group_id 必须 snake_case)。 */
|
||||
export async function fetchUserSecretUsage(params: UserSecretUsageQuery): Promise<AdminUserSecretUsagePage> {
|
||||
const query: Record<string, string | number> = { page: params.page, pageSize: params.pageSize }
|
||||
if (params.startDate) query.startDate = params.startDate
|
||||
if (params.endDate) query.endDate = params.endDate
|
||||
if (params.keyword) query.keyword = params.keyword
|
||||
if (params.groupId) query.group_id = params.groupId
|
||||
// 用 `!= null` 而不是上面几行的 truthy 写法:这一项类型是 `number | null`(null = 没选公司)。
|
||||
// 后端把 company_id<=0 归一成「没选公司」(DataReadScope.readScope 第一行),0 与缺失等价,按类型判即可。
|
||||
if (params.companyId != null) query.company_id = params.companyId
|
||||
// 平台值(2026-11-22)同 companyId 形状:白名单构造不收,只认原始入参。
|
||||
if (params.platform) query.platform = params.platform
|
||||
const { data } = await http.get('/api/admin/user-secret-usage', { params: query })
|
||||
return unwrap<AdminUserSecretUsagePage>(data)
|
||||
}
|
||||
@@ -5,24 +5,8 @@ import { unwrap } from './envelope'
|
||||
export interface AdminUserSecretModule {
|
||||
moduleKey: string
|
||||
moduleLabel: string
|
||||
/**
|
||||
* 货源:按模块分域,后端 `UserSecretModule.channelOrDefault` 已归一——
|
||||
* LLM 行为渠道(longtaitou/t8star),代理行为供应商(qingguo/jikip)。
|
||||
* ⚠ 界面不得用一张合表渲染这两域(代理行贴出「龙抬头」就是这么来的),
|
||||
* 走 `user-secret-model.ts` 的 `moduleSourceLabel`。
|
||||
*/
|
||||
channel?: string | null
|
||||
/** 脱敏值:代理列为 `scheme://host`,不含提取链接里的 key/pwd。 */
|
||||
masked: string
|
||||
/**
|
||||
* 完整明文值:后台侧**恒为空**(2026-11-02 `SecretMasking.maskProxy` 收口,代理链接里带着账密)。
|
||||
* 字段保留只为接口兼容;界面**不得**读它、更不得拿它做"masked 空就回落原文"的兜底,
|
||||
* 也不许有任何复制/导出整条链接的旁路。
|
||||
*/
|
||||
full: string
|
||||
exists: boolean
|
||||
/** 是否由后台代填并锁定:锁定时客户端不可修改或清空。 */
|
||||
locked: boolean
|
||||
checkStatus: string
|
||||
checkCode: string
|
||||
checkMessage: string
|
||||
@@ -35,17 +19,11 @@ export interface AdminUserSecretModule {
|
||||
export interface AdminUserSecretRow {
|
||||
userId: number
|
||||
username: string
|
||||
/** 所属数据权限分组名(可能多个)。 */
|
||||
groups: string[]
|
||||
/** 所属主管(创建人)用户名;无分组时的兜底展示。 */
|
||||
leaderUsername: string
|
||||
similarAsin: AdminUserSecretModule
|
||||
appearancePatent: AdminUserSecretModule
|
||||
proxy: AdminUserSecretModule
|
||||
status: string
|
||||
statusMessage: string
|
||||
/** 首次配置时间(三模块中最早);从未配置为 null。 */
|
||||
createdAt: string | null
|
||||
updatedAt: string | null
|
||||
}
|
||||
|
||||
@@ -54,111 +32,24 @@ export interface AdminUserSecretPage {
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
/** 分组筛选项(超管=全部;主管=自己带的分组)。 */
|
||||
groupOptions?: GroupOption[]
|
||||
}
|
||||
|
||||
export interface GroupOption {
|
||||
id: number
|
||||
groupName: string
|
||||
}
|
||||
|
||||
/**
|
||||
* LLM 一格的余额(**人民币口径**,后端取龙抬头 `credits` 块)。
|
||||
* 与 `AdminProxyBalanceCell` 是两套语义:这里的 `balance` 是钱、单位 CREDIT(=⚡=人民币),
|
||||
* 代理那边的 `surplus` 是「次」。界面不得用一张函数渲染两域(同 `channel` 那张表的教训)。
|
||||
*/
|
||||
export interface AdminLlmBalanceCell {
|
||||
moduleKey: string
|
||||
moduleLabel: string
|
||||
channel: string
|
||||
channelLabel: string
|
||||
available: boolean
|
||||
/** 上游原样小数串(未取整);available=false 时为 null。 */
|
||||
balance: string | null
|
||||
availableBalance: string | null
|
||||
frozen: string | null
|
||||
/** 恒为 CREDIT;不是这个值就按「认不出口径」处理,不猜。 */
|
||||
unit: string | null
|
||||
message: string | null
|
||||
checkedAt: string | null
|
||||
}
|
||||
|
||||
/** 代理余量一格:jikip 套餐口径(`surplus`=IP 次数、`scope`=谁的池子)。青果为 scope=none。 */
|
||||
export interface AdminProxyBalanceCell {
|
||||
available: boolean
|
||||
surplus: string | null
|
||||
balance: string | null
|
||||
/** user=该用户自己的套餐;platform=平台池子(不是这个用户的钱);none=查不了。 */
|
||||
scope: string | null
|
||||
message: string | null
|
||||
low?: boolean
|
||||
lowReason?: string | null
|
||||
}
|
||||
|
||||
export interface AdminUserSecretBalanceItem {
|
||||
userId: number
|
||||
llm: AdminLlmBalanceCell[]
|
||||
proxy: AdminProxyBalanceCell
|
||||
}
|
||||
|
||||
export interface AdminUserSecretBalances {
|
||||
items: AdminUserSecretBalanceItem[]
|
||||
/** 被数据权限剔出、本次没查的用户(不静默少给数)。 */
|
||||
deniedUserIds?: number[]
|
||||
/** 超出整请求时间预算、这轮没取到数的用户。 */
|
||||
timedOutUserIds?: number[]
|
||||
}
|
||||
|
||||
export interface UserSecretQuery {
|
||||
keyword?: string
|
||||
checkStatus?: string
|
||||
/** 按数据权限分组筛选(仅超管生效);后端参数为 snake_case。 */
|
||||
groupId?: number
|
||||
/** 公司 tab 的当前口径;不传 = 后端按操作者自己的公司(批次 1 里非超管只有这一家)。 */
|
||||
companyId?: number | null
|
||||
/** 平台 tab(amazon/jd):按 users.platform 过滤(2026-11-22 京东侧新增);不传 = 旧行为不筛。 */
|
||||
platform?: string
|
||||
page: number
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
/** 分页查询用户密钥(一行一用户):GET /api/admin/user-secrets(筛选参数必须 snake_case,camel 会被后端静默忽略)。 */
|
||||
/** 分页查询用户密钥(一行一用户):GET /api/admin/user-secrets */
|
||||
export async function fetchUserSecretList(params: UserSecretQuery): Promise<AdminUserSecretPage> {
|
||||
const query: Record<string, string | number> = { page: params.page, pageSize: params.pageSize }
|
||||
if (params.keyword) query.keyword = params.keyword
|
||||
if (params.checkStatus) query.checkStatus = params.checkStatus
|
||||
if (params.groupId) query.group_id = params.groupId
|
||||
// 用 `!= null` 而不是上面几行的 truthy 写法:这一项类型是 `number | null`(null = 没选公司)。
|
||||
// 后端把 company_id<=0 归一成「没选公司」(DataReadScope.readScope 第一行),0 与缺失等价,按类型判即可。
|
||||
if (params.companyId != null) query.company_id = params.companyId
|
||||
// 平台值(2026-11-22)同 companyId 形状:白名单构造不收,只认原始入参。
|
||||
if (params.platform) query.platform = params.platform
|
||||
const { data } = await http.get('/api/admin/user-secrets', { params: query })
|
||||
const { data } = await http.get('/api/admin/user-secrets', { params })
|
||||
return unwrap<AdminUserSecretPage>(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新本页用户的余额侧写:POST /api/admin/user-secrets/balances。
|
||||
*
|
||||
* 实时打上游、不落库,所以服务端带三条护栏(单次 ≤20 个用户、固定并发、整请求 10s 预算),
|
||||
* 客户端的超时必须**长于**服务端预算,否则服务端还在取数、这边先报错,
|
||||
* 界面就会把「查得慢」显示成「查不到」(与铁律 10「前端超时不得短于服务端预算」同形)。
|
||||
*/
|
||||
export async function fetchAdminSecretBalances(
|
||||
userIds: number[],
|
||||
companyId?: number | null,
|
||||
): Promise<AdminUserSecretBalances> {
|
||||
const body: Record<string, unknown> = { userIds }
|
||||
if (companyId != null) body.company_id = companyId
|
||||
const { data } = await http.post('/api/admin/user-secrets/balances', body, { timeout: 30_000 })
|
||||
return unwrap<AdminUserSecretBalances>(data)
|
||||
}
|
||||
|
||||
/** 立即检测该用户全部已配置项:POST /api/admin/user-secrets/{userId}/check
|
||||
* 逐模块检测(每项最多「首查 + 传输层失败重试一次」,最坏约 31s/项),故放宽超时到 180s。 */
|
||||
/** 立即检测该用户全部已配置项:POST /api/admin/user-secrets/{userId}/check */
|
||||
export async function checkUserSecret(userId: number) {
|
||||
const { data } = await http.post(`/api/admin/user-secrets/${userId}/check`, undefined, { timeout: 180_000 })
|
||||
const { data } = await http.post(`/api/admin/user-secrets/${userId}/check`)
|
||||
return unwrap<
|
||||
Array<{
|
||||
moduleKey: string
|
||||
@@ -177,28 +68,3 @@ export async function deleteUserSecret(userId: number): Promise<void> {
|
||||
const { data } = await http.delete(`/api/admin/user-secrets/${userId}`)
|
||||
unwrap<unknown>(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 代填并锁定该用户某模块配置(当前仅代理):PUT /api/admin/user-secrets/{userId}/modules/{moduleKey}
|
||||
* `value` 是**一次性写载荷**(代理为现拼的提取链接,带着 key/pwd):调用方不得把它渲染回界面、
|
||||
* 不得打进日志;`channel` 是同一单的货源(代理=供应商 key),后端据此选解析分支——
|
||||
* 不给则由后端按链接域名识别,识别不出回落默认供应商,会静默换执行方,所以本面一律显式带上。
|
||||
*/
|
||||
export async function saveUserSecretModule(
|
||||
userId: number,
|
||||
moduleKey: string,
|
||||
value: string,
|
||||
channel?: string,
|
||||
): Promise<AdminUserSecretModule> {
|
||||
const { data } = await http.put(`/api/admin/user-secrets/${userId}/modules/${moduleKey}`, {
|
||||
value,
|
||||
...(channel ? { channel } : {}),
|
||||
})
|
||||
return unwrap<AdminUserSecretModule>(data)
|
||||
}
|
||||
|
||||
/** 清空该用户某模块配置并解除锁定:DELETE /api/admin/user-secrets/{userId}/modules/{moduleKey} */
|
||||
export async function clearUserSecretModule(userId: number, moduleKey: string): Promise<void> {
|
||||
const { data } = await http.delete(`/api/admin/user-secrets/${userId}/modules/${moduleKey}`)
|
||||
unwrap<unknown>(data)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/** 用户管理列表/分页 DTO(任务 41):纯逻辑,无框架依赖,与 Java AdminUserController 对齐。 */
|
||||
import type { AdminUser } from '../types/admin'
|
||||
import type { PlatformTabId } from '../config/platform-scope.ts'
|
||||
|
||||
export const USER_PAGE_DEFAULT_SIZE = 10
|
||||
export const USER_PAGE_MIN_PAGE = 1
|
||||
@@ -16,11 +15,6 @@ export interface UserListParams {
|
||||
adminId?: number | null
|
||||
/** 角色过滤(''=全部)。 */
|
||||
role?: string
|
||||
/** 公司 tab 的当前公司;由页面从 store 传入,**不住在 UserFilterState 里**
|
||||
* (normalizeUserPageParams 白名单构造会把它丢掉,取值口只认 fetchUserList 的原始入参)。 */
|
||||
companyId?: number | null
|
||||
/** 平台 tab 的当前平台(V206);同 companyId 形状:白名单构造不收,从原始入参读。 */
|
||||
platform?: PlatformTabId
|
||||
}
|
||||
|
||||
/** 序列化到 GET /api/admin/users 的查询参数(Java snake_case)。 */
|
||||
@@ -32,8 +26,6 @@ export interface UserListQuery {
|
||||
created_by_id?: number
|
||||
admin_id?: number
|
||||
role?: string
|
||||
company_id?: number
|
||||
platform?: string
|
||||
}
|
||||
|
||||
/** 用户列表项即 AdminUser(与 Java AdminUserItemVo 字段对齐)。 */
|
||||
|
||||
@@ -18,23 +18,13 @@ export function toAdminUserItem(raw: unknown): AdminUser | null {
|
||||
const id = numberOrNull(r.id)
|
||||
if (id === null) return null
|
||||
const item: AdminUser = { id, username: text(r.username), role: text(r.role) }
|
||||
const quota = numberOrNull(r.jd_publish_quota)
|
||||
if (quota !== null) item.jdPublishQuota = quota
|
||||
const platform = text(r.platform)
|
||||
if (platform) item.platform = platform
|
||||
if (typeof r.is_admin === 'boolean') item.isAdmin = r.is_admin
|
||||
const createdById = numberOrNull(r.created_by_id)
|
||||
if (createdById !== null) item.createdById = createdById
|
||||
const createdAt = text(r.created_at)
|
||||
if (createdAt) item.createdAt = createdAt
|
||||
const updatedAt = text(r.updated_at)
|
||||
if (updatedAt) item.updatedAt = updatedAt
|
||||
const creator = text(r.creator_username)
|
||||
if (creator) item.creatorUsername = creator
|
||||
const expiresAt = text(r.expires_at)
|
||||
if (expiresAt) item.expiresAt = expiresAt
|
||||
const disabledAt = text(r.disabled_at)
|
||||
if (disabledAt) item.disabledAt = disabledAt
|
||||
const abbr = text(r.pinyin_abbr)
|
||||
if (abbr) item.pinyinAbbr = abbr
|
||||
return item
|
||||
|
||||
@@ -11,13 +11,7 @@ import {
|
||||
/** 分页查询用户列表:归一化参数 → GET /api/admin/users → 解析 Java 分页负载。 */
|
||||
export async function fetchUserList(params: Partial<UserListParams> = {}): Promise<UserPageResult> {
|
||||
const normalized = normalizeUserPageParams(params)
|
||||
const query = toUserListQuery(normalized)
|
||||
// normalizeUserPageParams 是白名单构造(只点名 page/pageSize/keyword/createdById/adminId/role),
|
||||
// 公司值必须从原始 params 读:写成 normalized.companyId 会 TS 绿、运行时恒 undefined。
|
||||
if (params.companyId != null) query.company_id = params.companyId
|
||||
// 平台值(V206)同 companyId 形状:白名单构造不收,只认原始入参。
|
||||
if (params.platform) query.platform = params.platform
|
||||
const { data } = await http.get('/api/admin/users', { params: query })
|
||||
const { data } = await http.get('/api/admin/users', { params: toUserListQuery(normalized) })
|
||||
return parseUserPage(data)
|
||||
}
|
||||
|
||||
@@ -26,12 +20,3 @@ export async function deleteUser(uid: number): Promise<void> {
|
||||
const { data } = await http.delete<unknown>(`/api/admin/user/${uid}`)
|
||||
unwrap<unknown>(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 停用/解除停用:PUT /api/admin/user/{uid} 只带 disabled 开关(V155)。
|
||||
* 停用是硬停点:该账号已发令牌在下一次请求就被拒(401),客户端与后台会被强制退出到登录页。
|
||||
*/
|
||||
export async function setUserDisabled(uid: number, disabled: boolean): Promise<void> {
|
||||
const { data } = await http.put<unknown>(`/api/admin/user/${uid}`, { disabled })
|
||||
unwrap<unknown>(data)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
import { openAdminConfirm } from './admin-confirm'
|
||||
|
||||
/**
|
||||
* AdminConfirm 共享确认组件(module 13 task 245):renderless 单例承载。
|
||||
* 使用:<AdminConfirm ref="confirmRef" />,需确认时 await confirmRef.open({...})。
|
||||
*/
|
||||
export default defineComponent({
|
||||
name: 'AdminConfirm',
|
||||
setup(_props, { expose }) {
|
||||
expose({ open: openAdminConfirm })
|
||||
return () => null
|
||||
},
|
||||
})
|
||||
</script>
|
||||
@@ -1,52 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
defineProps<{
|
||||
batch: {
|
||||
verb: string
|
||||
count: number
|
||||
disabled: boolean
|
||||
progress: string
|
||||
result: { failures: ReadonlyArray<{ id: number | string; label: string; reason: string }> } | null
|
||||
submit: () => Promise<void>
|
||||
clearSelection: () => void
|
||||
}
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="batch-delete-actions">
|
||||
<button class="btn btn-danger batch-delete-button" type="button" :disabled="batch.disabled || !batch.count" @click="batch.submit">
|
||||
{{ batch.progress ? `正在${batch.verb} ${batch.progress}` : `批量${batch.verb}(${batch.count})` }}
|
||||
</button>
|
||||
<button v-if="batch.count" class="btn btn-sm batch-clear-button" type="button" :disabled="batch.disabled" @click="batch.clearSelection">清除勾选</button>
|
||||
<details v-if="batch.result?.failures.length" class="batch-delete-failures">
|
||||
<summary>查看失败原因({{ batch.result.failures.length }} 条)</summary>
|
||||
<ul>
|
||||
<li v-for="failure in batch.result.failures" :key="failure.id">{{ failure.label }}:{{ failure.reason }}</li>
|
||||
</ul>
|
||||
</details>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 2026-11-23 用户口径「批量删除放上去,最大化利用空间」:不再独占一行,由各页放进筛选/工具行,
|
||||
margin-left:auto 在 flex 行内右对齐(落点=查询按钮右侧留白)。 */
|
||||
.batch-delete-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
|
||||
.batch-delete-actions button {
|
||||
min-height: 34px;
|
||||
padding: 5px 12px;
|
||||
border: 1px solid var(--admin-border);
|
||||
border-radius: 9px;
|
||||
background: #fff;
|
||||
color: var(--admin-text);
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
/* 主按钮沿用 34px:全局 main.css 已把 panel 内 .btn(查询)压到 34px,同高才不会一高一矮。 */
|
||||
.batch-delete-actions .batch-delete-button { color: #fff; background: #b35f6a; border-color: #b35f6a; }
|
||||
.batch-delete-button:hover:not(:disabled) { background: #a34f5b; }
|
||||
.batch-clear-button:hover:not(:disabled) { background: #edf5fb; }
|
||||
.batch-delete-actions button:focus-visible { outline: 2px solid var(--admin-primary); outline-offset: 2px; }
|
||||
.batch-delete-actions button:disabled { cursor: not-allowed; opacity: 0.55; }
|
||||
.batch-delete-failures { max-width: 520px; color: #9f3845; overflow-wrap: anywhere; }
|
||||
.batch-delete-failures ul { max-height: 180px; overflow: auto; margin: 4px 0; padding-left: 20px; }
|
||||
</style>
|
||||
@@ -1,20 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
defineProps<{
|
||||
label: string
|
||||
checked: boolean
|
||||
disabled: boolean
|
||||
partial?: boolean
|
||||
}>()
|
||||
|
||||
defineEmits<{ change: [] }>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<input class="batch-delete-checkbox" type="checkbox" :aria-label="label" :title="label"
|
||||
:checked="checked" :disabled="disabled" :indeterminate="partial ?? false" @change.stop="$emit('change')" @click.stop />
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.batch-delete-checkbox { width: 15px; height: 15px; vertical-align: middle; cursor: pointer; accent-color: #b33a2e; }
|
||||
.batch-delete-checkbox:disabled { cursor: not-allowed; }
|
||||
</style>
|
||||
@@ -1,7 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { copyFeedback, isCopySupported } from './copy-model'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
|
||||
const props = defineProps<{ text: string }>()
|
||||
|
||||
@@ -14,7 +13,7 @@ async function handleCopy(): Promise<void> {
|
||||
await navigator.clipboard.writeText(props.text)
|
||||
ElMessage.success(copyFeedback(props.text))
|
||||
} catch {
|
||||
showAdminFeedback(copyFeedback(''), 'error')
|
||||
ElMessage.error(copyFeedback(''))
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { dialogTitleOf, drawerLayoutSpec } from './modal-model'
|
||||
|
||||
/**
|
||||
* DrawerShell 右侧抽屉容器(module 13 task 248):封装 el-drawer,统一 admin 尺寸
|
||||
* 与关闭语义(遮罩/Esc),标题透传默认头部、footer 槽承接底部按钮,构成头/体/脚三段。
|
||||
*/
|
||||
const props = withDefaults(
|
||||
defineProps<{ modelValue: boolean; title?: string; subtitle?: string; width?: string | number }>(),
|
||||
{ title: '', subtitle: '', width: drawerLayoutSpec().width },
|
||||
)
|
||||
const emit = defineEmits<{ (e: 'update:modelValue', value: boolean): void }>()
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (v: boolean) => emit('update:modelValue', v),
|
||||
})
|
||||
const spec = computed(() => drawerLayoutSpec())
|
||||
const head = computed(() => dialogTitleOf({ title: props.title, subtitle: props.subtitle }))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-drawer
|
||||
v-model="visible"
|
||||
:size="width"
|
||||
:title="head.title"
|
||||
:close-on-click-modal="spec.maskClosable"
|
||||
:close-on-press-escape="spec.escClosable"
|
||||
class="admin-drawer-shell"
|
||||
>
|
||||
<p v-if="head.subtitle" class="admin-drawer-subtitle">{{ head.subtitle }}</p>
|
||||
<slot />
|
||||
<template #footer>
|
||||
<slot name="footer" />
|
||||
</template>
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.admin-drawer-subtitle { margin: 0 0 12px; color: var(--admin-muted); font-size: 13px; }
|
||||
</style>
|
||||
@@ -1,164 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 到期续费提醒(V146,2026-10-05 需求):
|
||||
* 「管理员快过期的时候(仅剩 5 天不到开始)要在数富后台界面上有个弹窗去提醒,
|
||||
* 只能缩小但是不能关闭,直到续费超过 5 天才消失。」
|
||||
*
|
||||
* - 数据源:/api/admin/current-user 的 expiresAt/daysToExpire(session store 的 user 上);
|
||||
* 只反映账号自身 expires_at,不级联——续费是账号自己的事。
|
||||
* - 触发:0 ≤ daysToExpire < 5(剩余不足 5 天)。刷新/重新登录后按最新值判定,
|
||||
* 续费到 ≥5 天自动消失,无需手动关。
|
||||
* - 只能缩小不能关闭:无关闭按钮;缩小态是右下角常驻浮标,点开即恢复。
|
||||
* - 缩小状态按「用户 + 到期值」记 localStorage:续费(到期值变化)后重置为展开。
|
||||
*/
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
|
||||
const props = defineProps<{
|
||||
/** 展示阈值(天):daysToExpire < EXPIRY_NOTICE_DAYS 时展示。需求口径 = 5(不足 5 天)。 */
|
||||
threshold?: number
|
||||
}>()
|
||||
|
||||
const THRESHOLD = props.threshold ?? 5
|
||||
|
||||
const session = useAdminSessionStore()
|
||||
const user = computed(() => session.user)
|
||||
const daysToExpire = computed<number | null>(() => {
|
||||
const value = user.value?.daysToExpire
|
||||
return typeof value === 'number' && Number.isFinite(value) ? value : null
|
||||
})
|
||||
const visible = computed(() => daysToExpire.value !== null && daysToExpire.value < THRESHOLD)
|
||||
const expiresAt = computed(() => (user.value?.expiresAt || '').trim())
|
||||
|
||||
const minimized = ref(false)
|
||||
const minimizedKey = computed(() =>
|
||||
user.value ? `admin-expiry-notice-min:${user.value.id}:${expiresAt.value}` : '',
|
||||
)
|
||||
watch(
|
||||
minimizedKey,
|
||||
(key) => {
|
||||
minimized.value = key ? localStorage.getItem(key) === '1' : false
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
function minimize(): void {
|
||||
minimized.value = true
|
||||
if (minimizedKey.value) {
|
||||
try {
|
||||
localStorage.setItem(minimizedKey.value, '1')
|
||||
} catch {
|
||||
/* localStorage 不可用时仅本次会话生效 */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function restore(): void {
|
||||
minimized.value = false
|
||||
if (minimizedKey.value) {
|
||||
try {
|
||||
localStorage.removeItem(minimizedKey.value)
|
||||
} catch {
|
||||
/* 同上 */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const daysText = computed(() => {
|
||||
const days = daysToExpire.value
|
||||
if (days === null) return ''
|
||||
return days <= 0 ? '不足 1 天' : `还剩 ${days} 天`
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<template v-if="visible">
|
||||
<div
|
||||
v-if="!minimized"
|
||||
class="expiry-notice"
|
||||
role="alert"
|
||||
aria-live="assertive"
|
||||
>
|
||||
<div class="expiry-notice-body">
|
||||
<strong>服务即将到期</strong>
|
||||
<span>
|
||||
您的账号{{ expiresAt ? `(${expiresAt})` : '' }}即将到期,{{ daysText }}。
|
||||
到期后账号将无法登录,名下账号与正在执行的任务也会一并停止,请联系管理员续费。
|
||||
</span>
|
||||
</div>
|
||||
<button
|
||||
class="expiry-notice-min"
|
||||
type="button"
|
||||
title="收起(不可关闭,续费前会一直提醒)"
|
||||
@click="minimize"
|
||||
>
|
||||
收起
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
v-else
|
||||
class="expiry-notice-chip"
|
||||
type="button"
|
||||
:title="`服务即将到期:${daysText},点击展开`"
|
||||
@click="restore"
|
||||
>
|
||||
⏰ {{ daysText }}
|
||||
</button>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.expiry-notice {
|
||||
position: fixed;
|
||||
right: 24px;
|
||||
bottom: 24px;
|
||||
z-index: 3000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
max-width: 420px;
|
||||
padding: 14px 16px;
|
||||
border: 1px solid #e4b363;
|
||||
border-radius: 12px;
|
||||
background: #fffaf0;
|
||||
color: #7a4d0b;
|
||||
box-shadow: 0 12px 32px -18px rgba(122, 77, 11, 0.55);
|
||||
}
|
||||
.expiry-notice-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
font-size: 13px;
|
||||
line-height: 1.55;
|
||||
}
|
||||
.expiry-notice-body strong {
|
||||
font-size: 14px;
|
||||
}
|
||||
.expiry-notice-min {
|
||||
flex-shrink: 0;
|
||||
padding: 6px 12px;
|
||||
border: 1px solid #e4b363;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
color: #7a4d0b;
|
||||
font-size: 12.5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.expiry-notice-min:hover {
|
||||
background: #fdf3dd;
|
||||
}
|
||||
.expiry-notice-chip {
|
||||
position: fixed;
|
||||
right: 24px;
|
||||
bottom: 24px;
|
||||
z-index: 3000;
|
||||
padding: 8px 14px;
|
||||
border: 1px solid #e4b363;
|
||||
border-radius: 999px;
|
||||
background: #fffaf0;
|
||||
color: #7a4d0b;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 8px 20px -12px rgba(122, 77, 11, 0.5);
|
||||
}
|
||||
</style>
|
||||
@@ -1,53 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
/** 列表加载失败条(四面9分口径 · 后管「模板内失败态只有 4/24 页」)。
|
||||
* 两件事一起做:把失败原因留在页面上(不是一闪而过的 toast),并给出一个真能重跑的出口。
|
||||
* 重试动作由父页面传回自己的取数函数,本组件不自己发请求、也不放占位按钮。 */
|
||||
import { LOAD_FAILURE_RETRY_LABEL } from './load-failure-model'
|
||||
|
||||
defineProps<{ message: string }>()
|
||||
defineEmits<{ (event: 'retry'): void }>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="load-failure-bar" role="alert">
|
||||
<span class="load-failure-bar-text">{{ message }}</span>
|
||||
<button class="load-failure-bar-retry" type="button" @click="$emit('retry')">{{ LOAD_FAILURE_RETRY_LABEL }}</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 自带样式:各页的 .btn 是 scoped 的,套不到子组件内部的元素上。 */
|
||||
.load-failure-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin: 0 0 14px;
|
||||
padding: 10px 14px;
|
||||
border: 1px solid #e0bfc4;
|
||||
border-radius: 10px;
|
||||
background: #fdf3f4;
|
||||
color: #8f4650;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.load-failure-bar-text {
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.load-failure-bar-retry {
|
||||
flex: none;
|
||||
min-height: 32px;
|
||||
padding: 5px 14px;
|
||||
border: 1px solid #b35f6a;
|
||||
border-radius: 8px;
|
||||
background: linear-gradient(135deg, #c06d77, #b35f6a);
|
||||
color: #ffffff;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.load-failure-bar-retry:hover {
|
||||
background: linear-gradient(135deg, #cb7c84, #b96570);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,81 @@
|
||||
<script setup lang="ts">
|
||||
import { onBeforeUnmount, ref, watch } from 'vue'
|
||||
import { secretPlaceholder } from '@/pages/shop/secret-mask'
|
||||
|
||||
/**
|
||||
* MaskReveal 掩码揭示(module 13 task 247):默认以店铺 secret-mask 掩码占位展示,
|
||||
* 点击切换时向父组件发 reveal 事件取明文(以 value prop 回填);短时后自动收回。
|
||||
*/
|
||||
const props = withDefaults(defineProps<{ value?: string; revealMs?: number }>(), {
|
||||
value: '',
|
||||
revealMs: 5000,
|
||||
})
|
||||
const emit = defineEmits<{ (e: 'reveal'): void }>()
|
||||
|
||||
const revealed = ref(false)
|
||||
let timer: ReturnType<typeof setTimeout> | null = null
|
||||
|
||||
function clearTimer(): void {
|
||||
if (timer) {
|
||||
clearTimeout(timer)
|
||||
timer = null
|
||||
}
|
||||
}
|
||||
|
||||
function show(): void {
|
||||
revealed.value = true
|
||||
emit('reveal')
|
||||
clearTimer()
|
||||
timer = setTimeout(() => {
|
||||
revealed.value = false
|
||||
}, props.revealMs)
|
||||
}
|
||||
|
||||
function hide(): void {
|
||||
clearTimer()
|
||||
revealed.value = false
|
||||
}
|
||||
|
||||
function toggle(): void {
|
||||
if (revealed.value) hide()
|
||||
else show()
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.value,
|
||||
(v) => {
|
||||
if (!v) revealed.value = false
|
||||
},
|
||||
)
|
||||
|
||||
onBeforeUnmount(clearTimer)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span class="mask-reveal">
|
||||
<span class="mask-reveal-text">{{ revealed && value ? value : secretPlaceholder() }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="mask-reveal-toggle"
|
||||
:aria-label="revealed ? '隐藏' : '显示'"
|
||||
@click="toggle"
|
||||
>
|
||||
{{ revealed ? '隐藏' : '显示' }}
|
||||
</button>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.mask-reveal { display: inline-flex; align-items: center; gap: 6px; }
|
||||
.mask-reveal-text { font-variant-numeric: tabular-nums; }
|
||||
.mask-reveal-toggle {
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
color: #5b6f83;
|
||||
font-size: 12px;
|
||||
padding: 1px 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.mask-reveal-toggle:hover { color: #2f5d8b; border-color: #95b1cb; background: #edf5fb; }
|
||||
</style>
|
||||
@@ -0,0 +1,42 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { dialogTitleOf, modalLayoutSpec } from './modal-model'
|
||||
|
||||
/**
|
||||
* ModalShell 居中模态容器(module 13 task 248):封装 el-dialog,统一 admin 尺寸/圆角
|
||||
* 与关闭语义,标题透传给 Element 默认头部;body 用默认槽、操作区走 footer 槽。
|
||||
*/
|
||||
const props = withDefaults(
|
||||
defineProps<{ modelValue: boolean; title?: string; subtitle?: string; width?: string | number }>(),
|
||||
{ title: '', subtitle: '', width: modalLayoutSpec().width },
|
||||
)
|
||||
const emit = defineEmits<{ (e: 'update:modelValue', value: boolean): void }>()
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (v: boolean) => emit('update:modelValue', v),
|
||||
})
|
||||
const spec = computed(() => modalLayoutSpec())
|
||||
const head = computed(() => dialogTitleOf({ title: props.title, subtitle: props.subtitle }))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:width="width"
|
||||
:title="head.title"
|
||||
:close-on-click-modal="spec.maskClosable"
|
||||
:close-on-press-escape="spec.escClosable"
|
||||
class="admin-modal-shell"
|
||||
>
|
||||
<p v-if="head.subtitle" class="admin-modal-subtitle">{{ head.subtitle }}</p>
|
||||
<slot />
|
||||
<template #footer>
|
||||
<slot name="footer" />
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.admin-modal-subtitle { margin: 0 0 12px; color: var(--admin-muted); font-size: 13px; }
|
||||
</style>
|
||||
@@ -1,781 +0,0 @@
|
||||
<template>
|
||||
<div ref="rootRef" class="admin-notification-bell">
|
||||
<button
|
||||
type="button"
|
||||
class="bell-trigger"
|
||||
:class="{ 'bell-trigger--active': panelOpen }"
|
||||
:title="unreadCount > 0 ? `通知(${unreadCount} 条未读)` : '通知'"
|
||||
aria-label="通知"
|
||||
@click="togglePanel"
|
||||
>
|
||||
<svg
|
||||
class="bell-icon"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path d="M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9" />
|
||||
<path d="M13.73 21a2 2 0 0 1-3.46 0" />
|
||||
</svg>
|
||||
<span v-if="badgeText" class="bell-badge">{{ badgeText }}</span>
|
||||
</button>
|
||||
|
||||
<!-- 面板挂到 body 上(fixed 定位):顶栏内绝对定位时会被列表页 el-select 等页面内容压住,提 z-index 无效 -->
|
||||
<Teleport to="body">
|
||||
<div
|
||||
v-if="panelOpen"
|
||||
ref="panelRef"
|
||||
class="bell-panel"
|
||||
:style="panelStyle"
|
||||
role="dialog"
|
||||
aria-label="通知列表"
|
||||
>
|
||||
<div class="bell-panel-head">
|
||||
<span class="bell-panel-title">通知</span>
|
||||
<button
|
||||
v-if="unreadCount > 0"
|
||||
type="button"
|
||||
class="bell-read-all"
|
||||
:disabled="markingAll"
|
||||
@click="readAll"
|
||||
>
|
||||
{{ markingAll ? '处理中...' : '全部已读' }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="bell-search">
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
class="bell-search-input"
|
||||
placeholder="搜索标题或内容"
|
||||
aria-label="搜索通知"
|
||||
@input="onKeywordInput"
|
||||
/>
|
||||
<div class="bell-search-days">
|
||||
<el-date-picker
|
||||
:model-value="dateRangeValue"
|
||||
type="daterange"
|
||||
value-format="YYYY-MM-DD"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
range-separator="至"
|
||||
size="small"
|
||||
class="bell-date-picker"
|
||||
popper-class="bell-date-popper"
|
||||
:clearable="true"
|
||||
@update:model-value="onDateRangeChange"
|
||||
@change="reload"
|
||||
/>
|
||||
<button v-if="hasFilter" type="button" class="bell-search-reset" @click="resetFilters">
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
<div class="bell-sort-chips" role="group" aria-label="通知排序">
|
||||
<span class="bell-sort-label">排序</span>
|
||||
<button
|
||||
type="button"
|
||||
class="bell-sort-chip"
|
||||
:class="{ 'is-active': sortMode === 'severity' }"
|
||||
@click="setSortMode('severity')"
|
||||
>
|
||||
严重度
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="bell-sort-chip"
|
||||
:class="{ 'is-active': sortMode === 'time' }"
|
||||
@click="setSortMode('time')"
|
||||
>
|
||||
时间
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="loading && !groups.length" class="bell-empty">正在加载...</div>
|
||||
<div v-else-if="loadError && !groups.length" class="bell-empty bell-empty--error">{{ loadError }}</div>
|
||||
<div v-else-if="!groups.length" class="bell-empty">{{ hasFilter ? '没有符合条件的通知' : '暂无通知' }}</div>
|
||||
<ul v-else class="bell-list">
|
||||
<template v-for="(group, index) in groups" :key="notificationGroupKey(group)">
|
||||
<!-- 严重度排序会跨天交错,日期头只在时间排序下有意义 -->
|
||||
<li v-if="sortMode === 'time' && startsNewDay(index)" class="bell-day-head">{{ formatDayLabel(group.day) }}</li>
|
||||
<li
|
||||
class="bell-group"
|
||||
:class="[`bell-item--${group.level || 'warning'}`, { 'bell-group--open': isExpanded(group) }]"
|
||||
@click="toggleGroup(group)"
|
||||
>
|
||||
<div class="bell-item-head">
|
||||
<span class="bell-severity-tag" :class="`bell-severity-tag--${itemSeverity(group)}`">
|
||||
{{ severityLabel(group) }}
|
||||
</span>
|
||||
<span class="bell-item-title">{{ group.title }}</span>
|
||||
<span class="bell-item-time">{{ formatTime(group.createdAt) }}</span>
|
||||
</div>
|
||||
<div class="bell-item-content">{{ group.content }}</div>
|
||||
<div class="bell-group-foot">
|
||||
<span class="bell-group-count">{{ formatGroupCounts(group.rowCount, group.unreadCount) }}</span>
|
||||
<span class="bell-group-toggle">{{ isExpanded(group) ? '收起明细' : '展开明细' }}</span>
|
||||
</div>
|
||||
</li>
|
||||
<!-- 已读只能进明细逐条点:聚合行上的点击只做展开,避免"看一眼顺手把没看过的全标成已读" -->
|
||||
<template v-if="isExpanded(group)">
|
||||
<li v-if="detailLoading" class="bell-empty bell-empty--detail">正在加载明细...</li>
|
||||
<li v-else-if="!details.length" class="bell-empty bell-empty--detail">这一组里没有通知</li>
|
||||
<li
|
||||
v-for="item in details"
|
||||
:key="item.id"
|
||||
class="bell-item bell-item--detail"
|
||||
:class="{ 'bell-item--unread': !item.read }"
|
||||
@click="onItemClick(item)"
|
||||
>
|
||||
<div class="bell-item-head">
|
||||
<span class="bell-severity-tag" :class="`bell-severity-tag--${itemSeverity(item)}`">
|
||||
{{ severityLabel(item) }}
|
||||
</span>
|
||||
<span class="bell-item-title">{{ item.title }}</span>
|
||||
<span class="bell-item-time">{{ formatTime(item.createdAt) }}</span>
|
||||
</div>
|
||||
<div class="bell-item-content">{{ item.content }}</div>
|
||||
<div v-if="item.refs && item.refs.length" class="bell-ref-list">
|
||||
<button
|
||||
v-for="ref in item.refs"
|
||||
:key="`${item.id}-${ref.taskNo}`"
|
||||
type="button"
|
||||
class="bell-ref-link"
|
||||
:title="ref.reason || `查看任务 ${ref.taskNo}`"
|
||||
@click.stop="openTaskRef(item, ref)"
|
||||
>
|
||||
{{ ref.taskNo }}<span v-if="ref.reason" class="bell-ref-reason">:{{ ref.reason }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
<li v-if="!detailLoading && detailTotal > details.length" class="bell-detail-more">
|
||||
另有 {{ detailTotal - details.length }} 条未列出,可缩小日期范围后查看
|
||||
</li>
|
||||
</template>
|
||||
</template>
|
||||
</ul>
|
||||
|
||||
<div class="bell-panel-foot">
|
||||
<button
|
||||
type="button"
|
||||
class="bell-page-btn"
|
||||
:disabled="page <= 1 || loading"
|
||||
@click="goPage(page - 1)"
|
||||
>
|
||||
上一页
|
||||
</button>
|
||||
<span class="bell-page-info">{{ page }} / {{ totalPages }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="bell-page-btn"
|
||||
:disabled="page >= totalPages || loading"
|
||||
@click="goPage(page + 1)"
|
||||
>
|
||||
下一页
|
||||
</button>
|
||||
<span class="bell-page-total">共 {{ total }} 组 · 明细 {{ rowCount }} 条</span>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import type { AdminNotificationItem, AdminNotificationRef } from '@/api/notifications'
|
||||
import {
|
||||
NOTIFICATION_POLL_INTERVAL_MS,
|
||||
formatDayLabel,
|
||||
formatGroupCounts,
|
||||
formatNotificationTime,
|
||||
notificationGroupKey,
|
||||
taskCenterRouteForRef,
|
||||
} from '@/layout/notification-bell-model'
|
||||
import { todayDateInput } from '@/utils/datetime'
|
||||
import {
|
||||
itemLevel,
|
||||
itemSeverity,
|
||||
severityLabel,
|
||||
startsNewDay as groupStartsNewDay,
|
||||
useNotificationBellPanel,
|
||||
} from '@/layout/notification-bell-panel'
|
||||
|
||||
const session = useAdminSessionStore()
|
||||
const router = useRouter()
|
||||
|
||||
/**
|
||||
* 面板的数据流(聚合组、明细、两个计数、防抖与取数)整块在 notification-bell-panel.ts。
|
||||
* 那一层是真函数,`npm test` 能直接跑判据;组件只留 DOM 相关的一半:
|
||||
* 面板开合、fixed 定位、外部点击关闭、60s 轮询定时器。
|
||||
*/
|
||||
const {
|
||||
badgeText,
|
||||
dateRangeValue,
|
||||
detailLoading,
|
||||
detailTotal,
|
||||
details,
|
||||
goPage,
|
||||
groups,
|
||||
hasFilter,
|
||||
isExpanded,
|
||||
keyword,
|
||||
loadError,
|
||||
loading,
|
||||
markingAll,
|
||||
onItemClick,
|
||||
onDateRangeChange,
|
||||
onKeywordInput,
|
||||
page,
|
||||
readAll,
|
||||
refreshSummary,
|
||||
reload,
|
||||
resetFilters,
|
||||
rowCount,
|
||||
setSortMode,
|
||||
sortMode,
|
||||
toggleGroup,
|
||||
total,
|
||||
totalPages,
|
||||
unreadCount,
|
||||
} = useNotificationBellPanel({ uid: () => session.user?.id ?? 0, today: () => todayDateInput() })
|
||||
|
||||
/** 点锚点:先按原逻辑标已读,再跳任务中心(路由带 taskNo,页面进来自动开详情抽屉)。 */
|
||||
function openTaskRef(item: AdminNotificationItem, ref: AdminNotificationRef): void {
|
||||
const target = taskCenterRouteForRef(ref)
|
||||
if (!target) {
|
||||
return
|
||||
}
|
||||
void onItemClick(item)
|
||||
void router.push(target)
|
||||
}
|
||||
|
||||
const rootRef = ref<HTMLElement | null>(null)
|
||||
const panelRef = ref<HTMLElement | null>(null)
|
||||
const panelStyle = ref<Record<string, string>>({})
|
||||
const panelOpen = ref(false)
|
||||
|
||||
/** 模板里仍是 startsNewDay(index):组序列在面板层,这里只补一次取值。 */
|
||||
function startsNewDay(index: number): boolean {
|
||||
return groupStartsNewDay(groups.value, index)
|
||||
}
|
||||
|
||||
function formatTime(value: string | null) {
|
||||
return formatNotificationTime(value)
|
||||
}
|
||||
|
||||
/** 面板挂到 body 后用 fixed 定位,位置按触发器实时算(右对齐在铃铛下方)。 */
|
||||
function syncPanelPosition() {
|
||||
const trigger = rootRef.value
|
||||
if (!trigger) return
|
||||
const rect = trigger.getBoundingClientRect()
|
||||
panelStyle.value = {
|
||||
top: `${Math.round(rect.bottom + 10)}px`,
|
||||
right: `${Math.max(8, Math.round(window.innerWidth - rect.right))}px`,
|
||||
}
|
||||
}
|
||||
|
||||
function togglePanel() {
|
||||
panelOpen.value = !panelOpen.value
|
||||
if (panelOpen.value) {
|
||||
syncPanelPosition()
|
||||
reload()
|
||||
}
|
||||
}
|
||||
|
||||
/** 点击组件外部关闭面板(面板已 Teleport 到 body,需连同面板自身一起判断)。 */
|
||||
function onDocumentMouseDown(event: MouseEvent) {
|
||||
if (!panelOpen.value) return
|
||||
const target = event.target
|
||||
if (!(target instanceof Node)) return
|
||||
if (rootRef.value?.contains(target) || panelRef.value?.contains(target)) return
|
||||
panelOpen.value = false
|
||||
}
|
||||
|
||||
/** 窗口尺寸变化时重新对齐面板。 */
|
||||
function onWindowResize() {
|
||||
if (panelOpen.value) {
|
||||
syncPanelPosition()
|
||||
}
|
||||
}
|
||||
|
||||
/** 页面回到前台时立即刷新一次未读数。 */
|
||||
function onVisibilityChange() {
|
||||
if (typeof document !== 'undefined' && document.visibilityState === 'visible') {
|
||||
refreshSummary()
|
||||
}
|
||||
}
|
||||
|
||||
let pollTimer: number | null = null
|
||||
|
||||
onMounted(() => {
|
||||
document.addEventListener('mousedown', onDocumentMouseDown)
|
||||
document.addEventListener('visibilitychange', onVisibilityChange)
|
||||
window.addEventListener('resize', onWindowResize)
|
||||
refreshSummary()
|
||||
pollTimer = window.setInterval(() => {
|
||||
if (typeof document !== 'undefined' && document.visibilityState !== 'visible') {
|
||||
return
|
||||
}
|
||||
refreshSummary()
|
||||
}, NOTIFICATION_POLL_INTERVAL_MS)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
document.removeEventListener('mousedown', onDocumentMouseDown)
|
||||
document.removeEventListener('visibilitychange', onVisibilityChange)
|
||||
window.removeEventListener('resize', onWindowResize)
|
||||
if (pollTimer != null) {
|
||||
window.clearInterval(pollTimer)
|
||||
pollTimer = null
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.admin-notification-bell {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.bell-trigger {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
padding: 0;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 9px;
|
||||
background: transparent;
|
||||
color: var(--admin-muted, #5b6f83);
|
||||
cursor: pointer;
|
||||
transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
|
||||
}
|
||||
|
||||
.bell-trigger:hover,
|
||||
.bell-trigger--active {
|
||||
background: #edf5fb;
|
||||
border-color: #cbd9e6;
|
||||
color: var(--admin-primary-strong, #2f5d8b);
|
||||
}
|
||||
|
||||
.bell-icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.bell-badge {
|
||||
position: absolute;
|
||||
top: 1px;
|
||||
right: 0;
|
||||
min-width: 16px;
|
||||
height: 16px;
|
||||
padding: 0 4px;
|
||||
box-sizing: border-box;
|
||||
border-radius: 999px;
|
||||
background: #d64545;
|
||||
color: #ffffff;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
line-height: 16px;
|
||||
text-align: center;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.bell-panel {
|
||||
position: fixed;
|
||||
z-index: 3200;
|
||||
width: 380px;
|
||||
max-width: calc(100vw - 32px);
|
||||
max-height: 520px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border: 1px solid var(--admin-border, #d8e3ee);
|
||||
border-radius: 12px;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 18px 48px rgba(39, 67, 94, 0.22);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.bell-panel-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12px 14px;
|
||||
border-bottom: 1px solid #edf1f5;
|
||||
}
|
||||
|
||||
.bell-panel-title {
|
||||
color: var(--admin-text, #24384d);
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.bell-read-all {
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--admin-primary-strong, #2f5d8b);
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.bell-read-all:disabled {
|
||||
opacity: 0.55;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.bell-empty {
|
||||
padding: 36px 0;
|
||||
color: #8a99a8;
|
||||
font-size: 13px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.bell-empty--error {
|
||||
color: #b23c3c;
|
||||
}
|
||||
|
||||
.bell-list {
|
||||
flex: 1;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.bell-item {
|
||||
padding: 11px 14px;
|
||||
border-bottom: 1px solid #f0f3f7;
|
||||
cursor: pointer;
|
||||
transition: background 0.12s ease;
|
||||
}
|
||||
|
||||
.bell-item:hover {
|
||||
background: #f7f9fc;
|
||||
}
|
||||
|
||||
/* ---- 聚合行(默认视图的一级)与明细行(展开后的二级)---- */
|
||||
.bell-group {
|
||||
padding: 11px 14px 8px;
|
||||
border-bottom: 1px solid #f0f3f7;
|
||||
cursor: pointer;
|
||||
transition: background 0.12s ease;
|
||||
}
|
||||
|
||||
.bell-group:hover {
|
||||
background: #f7f9fc;
|
||||
}
|
||||
|
||||
.bell-group--open {
|
||||
background: #f4f8fd;
|
||||
}
|
||||
|
||||
.bell-group-foot {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.bell-group-count {
|
||||
color: #7c8b9a;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.bell-group-toggle {
|
||||
color: var(--admin-primary-strong, #2f5d8b);
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
/* 明细缩进 + 左侧一道竖线,让"这是上面那一组里的东西"看得出来,而不是又一批同级通知 */
|
||||
.bell-item--detail {
|
||||
padding-left: 26px;
|
||||
background: #fcfdfe;
|
||||
border-bottom-color: #f5f8fb;
|
||||
}
|
||||
|
||||
.bell-item--detail::before {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
width: 2px;
|
||||
height: 26px;
|
||||
margin: 0 0 -8px -14px;
|
||||
border-radius: 2px;
|
||||
background: #dce7f2;
|
||||
}
|
||||
|
||||
.bell-empty--detail {
|
||||
padding: 14px 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.bell-detail-more {
|
||||
padding: 8px 14px;
|
||||
color: #8a99a8;
|
||||
font-size: 11px;
|
||||
text-align: center;
|
||||
background: #fcfdfe;
|
||||
}
|
||||
|
||||
.bell-item--unread {
|
||||
background: #f2f6ff;
|
||||
}
|
||||
|
||||
.bell-item--unread .bell-item-title::before {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
margin-right: 7px;
|
||||
border-radius: 50%;
|
||||
background: #d64545;
|
||||
vertical-align: 1px;
|
||||
}
|
||||
|
||||
.bell-item-head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.bell-item-title {
|
||||
flex: 1;
|
||||
color: var(--admin-text, #24384d);
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.bell-severity-tag {
|
||||
flex-shrink: 0;
|
||||
padding: 1px 6px;
|
||||
border: 1px solid currentColor;
|
||||
border-radius: 999px;
|
||||
font-size: 10.5px;
|
||||
font-weight: 600;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.bell-severity-tag--urgent {
|
||||
background: #fdecec;
|
||||
color: #c92a2a;
|
||||
}
|
||||
|
||||
.bell-severity-tag--high {
|
||||
background: #fdf3e2;
|
||||
color: #b26a12;
|
||||
}
|
||||
|
||||
.bell-severity-tag--medium {
|
||||
background: #eaf2fb;
|
||||
color: #2f6fb3;
|
||||
}
|
||||
|
||||
.bell-severity-tag--low {
|
||||
background: #f1f4f7;
|
||||
color: #6b7c8e;
|
||||
}
|
||||
|
||||
.bell-item--error .bell-item-title {
|
||||
color: #b23c3c;
|
||||
}
|
||||
|
||||
.bell-item--warning .bell-item-title {
|
||||
color: #a8793e;
|
||||
}
|
||||
|
||||
.bell-item--info .bell-item-title {
|
||||
color: var(--admin-primary-strong, #2f5d8b);
|
||||
}
|
||||
|
||||
.bell-item-time {
|
||||
flex-shrink: 0;
|
||||
color: #9aa6b3;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.bell-item-content {
|
||||
margin-top: 4px;
|
||||
color: #667085;
|
||||
font-size: 12px;
|
||||
line-height: 1.55;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* 定位锚点:任务号可点,直达任务详情。压低视觉权重,不与正文抢注意力。 */
|
||||
.bell-ref-list { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
|
||||
.bell-ref-link { padding: 0; border: none; background: none; color: var(--admin-primary, #2f5d8b); font-family: inherit; font-size: 12px; line-height: 1.5; text-align: left; word-break: break-all; cursor: pointer; }
|
||||
.bell-ref-link:hover { text-decoration: underline; }
|
||||
.bell-ref-reason { color: #8a94a6; }
|
||||
|
||||
.bell-search {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid #edf1f5;
|
||||
background: #fafcfe;
|
||||
}
|
||||
|
||||
.bell-search-input,
|
||||
.bell-date-input {
|
||||
height: 28px;
|
||||
padding: 0 8px;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #d8e3ee;
|
||||
border-radius: 6px;
|
||||
background: #ffffff;
|
||||
color: var(--admin-text, #24384d);
|
||||
font-size: 12px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.bell-search-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.bell-search-input:focus,
|
||||
.bell-date-input:focus {
|
||||
border-color: var(--admin-primary-strong, #2f5d8b);
|
||||
}
|
||||
|
||||
.bell-search-days {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.bell-date-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.bell-date-sep {
|
||||
color: #8a99a8;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.bell-search-reset {
|
||||
flex-shrink: 0;
|
||||
padding: 0 8px;
|
||||
height: 28px;
|
||||
border: 1px solid #d8e3ee;
|
||||
border-radius: 6px;
|
||||
background: #ffffff;
|
||||
color: var(--admin-primary-strong, #2f5d8b);
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.bell-search-reset:hover {
|
||||
background: #edf5fb;
|
||||
}
|
||||
|
||||
.bell-sort-chips {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.bell-sort-label {
|
||||
color: #8a99a8;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.bell-sort-chip {
|
||||
height: 24px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid #d8e3ee;
|
||||
border-radius: 12px;
|
||||
background: #ffffff;
|
||||
color: #667085;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
|
||||
}
|
||||
|
||||
.bell-sort-chip:hover {
|
||||
border-color: var(--admin-primary-strong, #2f5d8b);
|
||||
color: var(--admin-primary-strong, #2f5d8b);
|
||||
}
|
||||
|
||||
.bell-sort-chip.is-active {
|
||||
border-color: var(--admin-primary-strong, #2f5d8b);
|
||||
background: #edf5fb;
|
||||
color: var(--admin-primary-strong, #2f5d8b);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.bell-day-head {
|
||||
padding: 6px 14px;
|
||||
background: #f4f7fa;
|
||||
color: #7c8b9a;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.bell-panel-foot {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
padding: 7px 12px;
|
||||
border-top: 1px solid #edf1f5;
|
||||
}
|
||||
|
||||
.bell-page-btn {
|
||||
padding: 3px 10px;
|
||||
border: 1px solid #d8e3ee;
|
||||
border-radius: 6px;
|
||||
background: #ffffff;
|
||||
color: var(--admin-primary-strong, #2f5d8b);
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.bell-page-btn:hover:not(:disabled) {
|
||||
background: #edf5fb;
|
||||
}
|
||||
|
||||
.bell-page-btn:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.bell-page-info {
|
||||
color: var(--admin-text, #24384d);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.bell-page-total {
|
||||
color: #9aa6b3;
|
||||
font-size: 11px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
/* 日期选择面板与通知面板同为 body 级浮层,须压在通知面板(3200)之上:
|
||||
Element 弹层只自 2000 起递增,不抬就会被面板挡住,表现为「日期点不动」。 */
|
||||
.bell-date-popper {
|
||||
z-index: 3300 !important;
|
||||
}
|
||||
</style>
|
||||
@@ -2,11 +2,6 @@
|
||||
/** 旧版风格分页(像素复刻 admin.html .pagination)+ 每页条数下拉(10/20/50/100)。
|
||||
* props: total / page / pageSize / sizes(默认 10/20/50/100) / showTotal(默认 true) / jump(默认 true)。 */
|
||||
import { computed, ref } from 'vue'
|
||||
// 每页条数下拉 2026-11-17 用户口径「和亚马逊不统一」:原生 <select> 的弹层是浏览器直角
|
||||
// 原生物,全站分页条都有这一处 ⇒ 换 el-select(EP 圆角面板)。组件内局部导入,不与全局
|
||||
// 注册表耦合:任何挂载测试单独 mount 本组件都能正确渲染(不依赖外部 app.use)。
|
||||
// 样式已在 plugins/element.ts 里按组件全局引过,这里不重复引。
|
||||
import { ElOption, ElSelect } from 'element-plus'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -39,7 +34,8 @@ function goJump() {
|
||||
go(Math.min(Math.max(n, 1), totalPages.value))
|
||||
}
|
||||
|
||||
function onSizeChange(value: number) {
|
||||
function onSizeChange(event: Event) {
|
||||
const value = Number((event.target as HTMLSelectElement).value)
|
||||
if (Number.isFinite(value) && value > 0) emit('size-change', value)
|
||||
}
|
||||
</script>
|
||||
@@ -47,16 +43,9 @@ function onSizeChange(value: number) {
|
||||
<template>
|
||||
<div class="old-pagination">
|
||||
<span v-if="showTotal" class="page-total">共 {{ total }} 条</span>
|
||||
<!-- el-select 出厂宽度 100%(--el-select-width),进 flex 行会横涨 ⇒ 类里钉位宽。 -->
|
||||
<el-select
|
||||
class="page-size-select"
|
||||
:model-value="pageSize"
|
||||
size="small"
|
||||
aria-label="每页条数"
|
||||
@change="onSizeChange"
|
||||
>
|
||||
<el-option v-for="size in sizes" :key="size" :value="size" :label="`${size}条/页`" />
|
||||
</el-select>
|
||||
<select class="page-size-select" :value="pageSize" @change="onSizeChange">
|
||||
<option v-for="size in sizes" :key="size" :value="size">{{ size }}条/页</option>
|
||||
</select>
|
||||
<button type="button" :disabled="page <= 1" @click="go(page - 1)">上一页</button>
|
||||
<span class="page-cur">第 {{ page }} / {{ totalPages }} 页</span>
|
||||
<button type="button" :disabled="page >= totalPages" @click="go(page + 1)">下一页</button>
|
||||
@@ -103,22 +92,15 @@ function onSizeChange(value: number) {
|
||||
.page-total {
|
||||
margin-right: 4px;
|
||||
}
|
||||
/* 每页条数下拉:与原分页条同尺寸(30px 高、8px 圆角、#cbd9e6 描边、#f8fbfd 浅底)。
|
||||
外形走 .el-select__wrapper(EP 的结构类,scoped 需 :deep 穿透)。 */
|
||||
.page-size-select {
|
||||
width: 104px;
|
||||
}
|
||||
.page-size-select :deep(.el-select__wrapper) {
|
||||
min-height: 30px;
|
||||
padding: 3px 8px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 8px;
|
||||
background: #f8fbfd;
|
||||
box-shadow: 0 0 0 1px #cbd9e6 inset;
|
||||
color: #24384d;
|
||||
font-size: 13px;
|
||||
line-height: 22px;
|
||||
}
|
||||
.page-size-select :deep(.el-select__wrapper:hover) {
|
||||
box-shadow: 0 0 0 1px #9fb7cd inset;
|
||||
font-family: inherit;
|
||||
}
|
||||
.page-jump {
|
||||
display: inline-flex;
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { pillToneStyle, type PillTone } from './status-pill-model'
|
||||
|
||||
const props = withDefaults(defineProps<{ text: string; tone?: PillTone }>(), { tone: 'info' })
|
||||
const style = computed(() => pillToneStyle(props.tone))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span class="status-pill" :style="{ color: style.text, background: style.bg }">{{ text }}</span>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.status-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 62px;
|
||||
padding: 2px 10px;
|
||||
border-radius: 999px;
|
||||
font-size: 12px;
|
||||
line-height: 1.7;
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
@@ -2,7 +2,7 @@
|
||||
* 二次确认模型(module 13 task 245):文案/按钮键规则对齐 admin-interactions.js ——
|
||||
* 优先显式 message,否则由行名拼接「确认删除“X”吗?此操作可能影响已有数据。」;
|
||||
* danger(删除/清空/删除导入类)默认标题「删除前确认」、确认键「确认删除」。
|
||||
* 纯逻辑、无 UI 依赖,便于单测;打开入口见 admin-confirm.ts。
|
||||
* 纯逻辑、无 UI 依赖,便于单测;打开入口见 admin-confirm.ts / AdminConfirm.vue。
|
||||
*/
|
||||
export const ADMIN_CONFIRM = {
|
||||
dangerTitle: '删除前确认',
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
/**
|
||||
* 列表加载失败态模型(四面9分口径 · 后管「模板内失败态只有 4/24 页」):
|
||||
* 把「请求失败了」归一成一条可读中文,配 LoadFailureBar.vue 的那个真能重跑的按钮用。
|
||||
*
|
||||
* 纯逻辑、不依赖 Vue 也不依赖 Element,`node --test` 直接 import 跑行为断言。
|
||||
* 文案把关复用 api/user-notice:后端把底层异常原文拼进 message 时,界面只留中文主干。
|
||||
*/
|
||||
import { userNotice } from '../api/user-notice.ts'
|
||||
|
||||
/** 失败条上那个按钮的字样:必须是「重试」而不是一句「知道了」——撤入口同时得是出口。 */
|
||||
export const LOAD_FAILURE_RETRY_LABEL = '重试'
|
||||
|
||||
/** 网络层失败(请求没到服务器就断了)给用户的中文提示。2026-11-21 线上实录:用户代理
|
||||
* 链路抖动成批掐断 TLS 连接(当天全服 29 条「连接未完成即断」记录全部来自该用户的两个
|
||||
* 出口 IP),axios 拿到英文 "Network Error" 按 userNotice 口径被滤空 ⇒ 界面只剩页面
|
||||
* 兜底文案,用户看不出是网络问题、更不知道该重试还是该找人。这里显式补一句。 */
|
||||
export const NETWORK_FAILURE_DETAIL = '网络连接中断,请检查网络后重试'
|
||||
|
||||
/** axios 错误且没有 response = 网络层失败(连接被掐断/超时/DNS),服务端根本没回话。
|
||||
* 只认 axios 形状(code 为网络错误码,或带 config+isAxiosError 标记);普通 Error 没有
|
||||
* response 不算(走原有 message 解析)。 */
|
||||
function isNetworkLevelError(error: unknown): boolean {
|
||||
if (!error || typeof error !== 'object') return false
|
||||
const record = error as Record<string, unknown>
|
||||
if (record.response !== undefined) return false
|
||||
const code = typeof record.code === 'string' ? record.code : ''
|
||||
if (code === 'ECONNABORTED' || code === 'ERR_NETWORK' || code === 'ETIMEDOUT' || code === 'ECONNRESET') {
|
||||
return true
|
||||
}
|
||||
return record.isAxiosError === true && record.config !== undefined
|
||||
}
|
||||
|
||||
/** 从 axios 错误 / Error / 字符串里取后端给的原因;取不到、或原文不是中文时返回空串。
|
||||
* 例外:axios 网络层失败(无 response)不算「取不到原因」,给中文网络提示。 */
|
||||
export function failureDetail(error: unknown): string {
|
||||
const data = (error as { response?: { data?: unknown } } | undefined)?.response?.data
|
||||
if (data && typeof data === 'object') {
|
||||
const record = data as Record<string, unknown>
|
||||
for (const key of ['message', 'error', 'msg']) {
|
||||
const value = record[key]
|
||||
if (typeof value === 'string' && value.trim()) return userNotice(value, '')
|
||||
}
|
||||
}
|
||||
if (isNetworkLevelError(error)) return NETWORK_FAILURE_DETAIL
|
||||
if (error instanceof Error && error.message.trim()) return userNotice(error.message, '')
|
||||
if (typeof error === 'string' && error.trim()) return userNotice(error, '')
|
||||
return ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 后端按范围拒掉的句子(`无权操作该总数据`、`缺少归属公司…`)补一句人话:
|
||||
* 这类失败不是页面坏了,重试一百次也是同一个结果,得把出路说清楚。
|
||||
*/
|
||||
export const SCOPE_REFUSAL_NOTE = '这一行不在你当前可操作的分组/公司范围内,需要由平台超级管理员处理'
|
||||
const SCOPE_REFUSAL = /无权|缺少归属公司/
|
||||
|
||||
/** 命中范围拒绝时返回补充说明,否则空串。 */
|
||||
export function scopeRefusalNote(detail: string): string {
|
||||
return SCOPE_REFUSAL.test(detail || '') ? SCOPE_REFUSAL_NOTE : ''
|
||||
}
|
||||
|
||||
/** 「本页兜底文案:后端原因」;没有可读原因时只留兜底文案,不拼出「加载失败:」这种半截句。 */
|
||||
export function loadFailureMessage(error: unknown, fallback: string): string {
|
||||
const head = (fallback || '').trim()
|
||||
const detail = failureDetail(error)
|
||||
if (!detail) return head
|
||||
const note = scopeRefusalNote(detail)
|
||||
const reason = note ? `${detail}(${note})` : detail
|
||||
if (!head || head.includes(detail)) return head || reason
|
||||
return `${head}:${reason}`
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 模态/抽屉布局模型(module 13 task 248):统一两种承载容器的尺寸与关闭语义,
|
||||
* 对齐 admin.html —— 居中 modal width min(920px,100vw-48)、radius14;右侧 drawer
|
||||
* width min(460px,100%);遮罩点击与 Esc 均关闭。页面接入统一尺寸与头/脚槽。
|
||||
*/
|
||||
export const ADMIN_MODAL_WIDTH = 'min(920px, 100vw - 48px)'
|
||||
export const ADMIN_DRAWER_WIDTH = 'min(460px, 100%)'
|
||||
export const ADMIN_MODAL_RADIUS = 14
|
||||
|
||||
export interface AdminContainerSpec {
|
||||
width: string
|
||||
radius?: number
|
||||
maskClosable: boolean
|
||||
escClosable: boolean
|
||||
}
|
||||
|
||||
export function modalLayoutSpec(): AdminContainerSpec {
|
||||
return { width: ADMIN_MODAL_WIDTH, radius: ADMIN_MODAL_RADIUS, maskClosable: true, escClosable: true }
|
||||
}
|
||||
|
||||
export function drawerLayoutSpec(): AdminContainerSpec {
|
||||
return { width: ADMIN_DRAWER_WIDTH, maskClosable: true, escClosable: true }
|
||||
}
|
||||
|
||||
/** 页面头标题归一:空/空白标题兜底「操作」,副标题去空白后无则省略。 */
|
||||
export function dialogTitleOf(opts: { title?: string; subtitle?: string }): { title: string; subtitle?: string } {
|
||||
const title = opts.title?.trim()
|
||||
const subtitle = opts.subtitle?.trim()
|
||||
return { title: title || '操作', ...(subtitle ? { subtitle } : {}) }
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* 状态药丸配色/分类模型(module 13 task 247):统一 admin.html 的三态语义色
|
||||
* (success 绿 / danger 红 / warning 琥珀 / info 蓝 / primary 深蓝),供视频任务、
|
||||
* 店铺数据任务、数字人版本等页面复用;未知文本回落 info。
|
||||
*/
|
||||
export type PillTone = 'success' | 'danger' | 'warning' | 'info' | 'primary'
|
||||
|
||||
export interface PillToneStyle {
|
||||
text: string
|
||||
bg: string
|
||||
}
|
||||
|
||||
export const PILL_TONES: Record<PillTone, PillToneStyle> = {
|
||||
success: { text: '#4e806d', bg: '#e6f6ec' },
|
||||
danger: { text: '#b35f6a', bg: '#fdecec' },
|
||||
warning: { text: '#a8793e', bg: '#fdf0dc' },
|
||||
info: { text: '#4f78a5', bg: '#e7f0f8' },
|
||||
primary: { text: '#2f5d8b', bg: '#e6f0f8' },
|
||||
}
|
||||
|
||||
/** 取某 tone 的配色;未知 tone 回退 info(不抛错)。 */
|
||||
export function pillToneStyle(tone: PillTone): PillToneStyle {
|
||||
return PILL_TONES[tone] ?? PILL_TONES.info
|
||||
}
|
||||
|
||||
const SUCCESS_PATTERN = /success|succeed|已发布|发布|成功|正常|可用/
|
||||
const DANGER_PATTERN = /fail|error|已废弃|失败|不可用|异常/
|
||||
const WARNING_PATTERN = /running|pending|waiting|进行|处理中|草稿|待执行|待/
|
||||
|
||||
/** 由状态文本(中英文)归类语义 tone。 */
|
||||
export function statusTone(raw: string): PillTone {
|
||||
const s = (raw || '').toLowerCase()
|
||||
if (SUCCESS_PATTERN.test(s)) return 'success'
|
||||
if (DANGER_PATTERN.test(s)) return 'danger'
|
||||
if (WARNING_PATTERN.test(s)) return 'warning'
|
||||
return 'info'
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/** 公司口径的唯一清单(设计文档 §8)。
|
||||
* 单独成文件而不是塞进 routes.ts:routes.ts 被 menu-route-map.ts import,
|
||||
* 而护栏用例要从这里反过来读注册表,放在一起会成环。 */
|
||||
|
||||
/** 角色内在闸门:只有超管可见可读写,与 user_column_permission 无关。 */
|
||||
export const SUPER_ADMIN_ONLY_MENU_KEYS: readonly string[] = ['admin_companies']
|
||||
|
||||
export interface CompanyScopedPage {
|
||||
/** 与 routes.ts 的 menuKey 逐字一致。 */
|
||||
menuKey: string
|
||||
/** 相对 admin-frontend-vue 的 api/取数模块路径;护栏逐文件断言它真的带了 company_id。 */
|
||||
apiFiles: string[]
|
||||
/** 页面组件路径;护栏断言它 watch 了 tab.activeId(否则切 tab 不重取数,tab 是装饰品)。 */
|
||||
pageFiles: string[]
|
||||
}
|
||||
|
||||
/** 参与公司 tab 的页(spec §3 归属普查:批次 1 = 9 个 A 类页里除去依赖二期 V145 的去重库)。
|
||||
* 后续批次往里加行时,同一笔提交必须带上对应 api 文件的 company_id,否则新用例红。 */
|
||||
export const COMPANY_SCOPED_PAGES: readonly CompanyScopedPage[] = [
|
||||
{ menuKey: 'admin_task_center', apiFiles: ['src/api/task-center.ts', 'src/pages/task-center/task-center-model.ts'], pageFiles: ['src/pages/task-center/TaskCenterBoardPage.vue'] },
|
||||
{ menuKey: 'admin_image_video_tasks', apiFiles: ['src/pages/tasks/image-video-api.ts'], pageFiles: ['src/pages/tasks/ImageVideoTasksPage.vue'] },
|
||||
{ menuKey: 'admin_user_secret_usage', apiFiles: ['src/api/user-secret-usage.ts'], pageFiles: ['src/pages/account/UserSecretUsagePage.vue'] },
|
||||
{ menuKey: 'admin_user_secrets', apiFiles: ['src/api/user-secrets.ts'], pageFiles: ['src/pages/account/UserSecretsPage.vue'] },
|
||||
{ menuKey: 'admin_history', apiFiles: ['src/pages/records/history-api.ts'], pageFiles: ['src/pages/records/RecordsHistoryPage.vue'] },
|
||||
{ menuKey: 'admin_device_logs', apiFiles: ['src/api/device-logs.ts'], pageFiles: ['src/pages/records/DeviceLogsPage.vue'] },
|
||||
{ menuKey: 'admin_group_manage', apiFiles: ['src/pages/account/shop-group-api.ts'], pageFiles: ['src/pages/account/GroupsPage.vue'] },
|
||||
{ menuKey: 'admin_shop_manage', apiFiles: ['src/pages/shop/shop-manage-api.ts'], pageFiles: ['src/pages/shop/ShopManagePage.vue'] },
|
||||
// 批次 2(控制方 2026-10-05 点名「切 tab 数据还一样」那五页):读门已在后端接上(V145 补归属 / V147 加列),
|
||||
// 这一批把前端接线补齐。apiFiles 只列**真的把 company_id 拼进请求**的模块:
|
||||
// 各页的 *-filter.ts 与 asin-filter.ts 只带 camel 的 companyId 字段(类型 + 白名单构造都不点名它),
|
||||
// 列进来会让正向判据去盯一个本来就不该出现 snake_case 的文件。
|
||||
// 【这两页已于 2026-10-06 退出注册表】admin_invalid_asin_data(品牌数据库)与 admin_product_categories
|
||||
// (商品类目)按控制方定案退回**全平台共享**,摘的不只是 tab:后端读写两侧的 company_id 谓词一起删
|
||||
// (V151 退唯一键)。反向钉在 tests/company-tab-wiring.test.ts——把它们再加回来必须先推翻那条定案。
|
||||
// dedupe-import-api.ts 是 10-09 补进来的:导入/删除导入这两支写侧出口原先不发 company_id,
|
||||
// 超管在别家 tab 点「新增导入」,数据落进了超管自己那一家(group_id 却是别家的组)=归属分裂。
|
||||
{ menuKey: 'admin_dedupe_total_data', apiFiles: ['src/pages/asin/dedupe-total-api.ts', 'src/pages/asin/dedupe-total-export.ts', 'src/pages/asin/dedupe-import-api.ts'], pageFiles: ['src/pages/asin/DedupeRegistryPage.vue'] },
|
||||
{ menuKey: 'admin_query_asin', apiFiles: ['src/pages/asin/query-asin-api.ts', 'src/pages/asin/query-asin-export.ts'], pageFiles: ['src/pages/asin/QueryAsinPage.vue'] },
|
||||
{ menuKey: 'admin_skip_price_asin', apiFiles: ['src/pages/asin/skip-price-api.ts', 'src/pages/asin/skip-price-export.ts'], pageFiles: ['src/pages/asin/SkipPricePage.vue'] },
|
||||
// 批次 3(控制方 2026-10-05 点名「店铺撞款监控 店铺数据也要做隔离」)。这两页的可见集不是按 company_id 列筛的,
|
||||
// 而是「本公司账号名下的店铺」:后端由 DataReadScope 把公司 → 成员账号 → biz_shop_manage.created_by_id 逐级推导,
|
||||
// 前端只负责把 activeId 当 company_id 送下去。
|
||||
{ menuKey: 'admin_shop_data_duplicate_check', apiFiles: ['src/pages/tasks/duplicate-console-api.ts'], pageFiles: ['src/pages/tasks/DuplicateCheckPage.vue'] },
|
||||
// 关键词使用记录(2026-10-25):只读留痕按行 company_id 收窄;超管切 tab 重取,非超管后端强制本公司。
|
||||
{ menuKey: 'admin_keyword_usage', apiFiles: ['src/pages/tasks/keyword-usage-api.ts'], pageFiles: ['src/pages/tasks/KeywordUsagePage.vue'] },
|
||||
{ menuKey: 'admin_shop_data_crawl_tasks', apiFiles: ['src/pages/tasks/shop-data-api.ts'], pageFiles: ['src/pages/tasks/ShopDataTasksPage.vue'] },
|
||||
// 批次 4(控制方 2026-10-05 点名「菜单权限和用户管理也要区分公司 tab 的数据」)。
|
||||
// 这一页的后端早就认 company_id(AdminUserService 只在**站点超管**身上用它筛,公司超管恒锁本公司),
|
||||
// 断的是前端:users-dto 的 UserListQuery 里连这个字段都没有 ⇒ 三家 tab 看到的是同一份全量列表。
|
||||
{ menuKey: 'admin_users', apiFiles: ['src/api/users.ts', 'src/pages/account/user-menu-auth-api.ts'], pageFiles: ['src/pages/account/UsersPage.vue'] },
|
||||
// 批次 5(控制方 2026-10-06 点名「店铺密钥管理的数据按照公司区分」)。biz_shop_key 原先零归属列,
|
||||
// 拿到这一页菜单的任意管理员读的是同一池全平台紫鸟令牌,而列表 VO 把令牌原文整列下发(悬停即得全文)。
|
||||
// V150 加 company_id;后端读门是 readCompanyIdOrOwn ⇒ 非超管连 company_id 都不带也一律锁本公司,
|
||||
// 这一页的 tab 只对超管改变行数(非超管恒锁本公司,与其余页同形)。
|
||||
{ menuKey: 'admin_shop_keys', apiFiles: ['src/pages/shop/shop-key-api.ts'], pageFiles: ['src/pages/shop/ShopKeysPage.vue'] },
|
||||
// 批次 6(控制方 2026-10-06 点名「菜单权限也加字段来区分」,并选了「每家公司一套菜单树」那一档)。
|
||||
// V149 给 columns 加 company_id 并把 52 行复制成每家一套 ⇒ 同一 column_key 在别家有另一份 id:
|
||||
// 不带 company_id 时后端只给操作者本公司那一棵(2026-10-06 生产实测),超管切看别家必须显式带;
|
||||
// 而一旦漏带又去勾别家的项,提交的 id 属于另一棵树,后端按本公司菜单集校验就会撞
|
||||
// 「无效的菜单权限项」。写侧(编辑/删除/重排)不带参数——归属由那一行的 id 与操作者公司共同判定,
|
||||
// 跨公司写后端 403(见 docs/ops/menu-company-tree-design-2026-10-06.md §5)。
|
||||
{ menuKey: 'admin_columns', apiFiles: ['src/pages/account/menu-manage-api.ts'], pageFiles: ['src/pages/account/MenusPage.vue'] },
|
||||
// 外观专利无侵权数据(2026-11-10 v1.3):出表成功自动同步的只读明细,归属物化在行 company_id 列
|
||||
// (V189,同店铺密钥形状)⇒ 后端正门 readCompanyIdOrOwn(超管显式传才收窄,非超管强制本公司)。
|
||||
{ menuKey: 'admin_appearance_patent_clean_items', apiFiles: ['src/pages/patent/appearance-patent-clean-api.ts'], pageFiles: ['src/pages/patent/AppearancePatentCleanItemsPage.vue'] },
|
||||
// 京东数据库(2026-11-14 v1.4)已于 2026-11-16 退出注册表(用户定案「删除掉公司 tab,参考品牌
|
||||
// 数据库」=品牌库 2026-10-06 先例同形):数据全平台公共(行 company_id 只剩"哪家公司客户端
|
||||
// 同步的"来源标记),摘的不只是 tab——页面/api 的 company_id 发送口与后端读侧 company_id 谓词
|
||||
// (superAdminScopedCompanyId)同窗一起摘。反向钉在 tests/company-tab-wiring.test.ts 的
|
||||
// 「公司维度不得回流」清单里,再加回来必须先推翻这条定案。
|
||||
]
|
||||
@@ -1,83 +0,0 @@
|
||||
/** 平台 tab 口径的唯一清单(2026-11-16 用户定案「亚马逊/京东不混一起」)。
|
||||
* 仿 company-scope.ts 的形状:单独成文件而不是塞进 routes.ts——护栏用例要从这里
|
||||
* 反读清单与注册表对撞,放在一起会成环。 */
|
||||
|
||||
export type PlatformTabId = 'amazon' | 'jd'
|
||||
|
||||
export interface PlatformTabDef {
|
||||
id: PlatformTabId
|
||||
label: string
|
||||
}
|
||||
|
||||
/** 侧边栏顶部平台 tab 的固定顺序:亚马逊在前(存量主体),京东在后。 */
|
||||
export const PLATFORM_TABS: readonly PlatformTabDef[] = [
|
||||
{ id: 'amazon', label: '亚马逊' },
|
||||
{ id: 'jd', label: '京东' },
|
||||
]
|
||||
|
||||
/** 京东侧独占菜单的 menuKey 唯一清单(与 routes.ts 的 menuKey 逐字一致,用例钉住)。
|
||||
* 2026-11-17 晚:分类管理子菜单(admin_jd_category_manage,V204)随「京东分类管理并到
|
||||
* 京东数据库分类编辑里」用户口径整体下线(页/路由/菜单行 V208 删),key 从清单摘除。
|
||||
* 后续京东新页面上线把 key 加进这里即可,清单外的 key(含店铺管理/生成记录等
|
||||
* 存量页)一律归亚马逊或双侧清单。
|
||||
* ⚠ 本清单只收后台(admin)侧 key——护栏用例要求每条都在 routes.ts 登记 menuKey;
|
||||
* 桌面端(app)京东菜单走 {@link JD_APP_MENU_KEYS}(无 admin 路由,不进侧边栏)。 */
|
||||
export const JD_MENU_KEYS: readonly string[] = [
|
||||
'admin_jd_database',
|
||||
]
|
||||
|
||||
/** 桌面端(app)京东菜单的 column_key 清单(V209,2026-11-17 用户口径「前台的京东少了」):
|
||||
* 组行 jd_tools(京东工具台)+两工具子行 jd-collect(京东店铺数据采集)/jd-publish(京东商品上架),
|
||||
* 与用户端 permissionKeys 逐字一致。app 菜单不进后管侧边栏与 routes.ts 路由表,故与
|
||||
* {@link JD_MENU_KEYS} 分列——判定出口 {@link platformsOfMenuKey} 两份同认。
|
||||
* 后续用户端京东新工具上线把 column_key 加进这里即可。 */
|
||||
export const JD_APP_MENU_KEYS: readonly string[] = [
|
||||
'jd_tools',
|
||||
'jd-collect',
|
||||
'jd-publish',
|
||||
]
|
||||
|
||||
/** 双侧共用账号管理页面:用户、分组、公司与菜单权限配置。
|
||||
* 密钥管理/密钥用量统计(admin_user_secrets/admin_user_secret_usage)按 2026-11-22 用户拍板
|
||||
* 扩回双侧(「后台京东 tab 下也要加密钥管理和密钥统计量」);页面数据按当前平台 tab 过滤
|
||||
* (platform 查询参数,后端 AdminUserSecretQuery.platform),菜单归属与数据隔离是两层。 */
|
||||
export const BOTH_PLATFORM_MENU_KEYS: readonly string[] = [
|
||||
'admin_users',
|
||||
'admin_group_manage',
|
||||
'admin_companies',
|
||||
'admin_columns',
|
||||
'admin_user_secrets',
|
||||
'admin_user_secret_usage',
|
||||
]
|
||||
|
||||
/** menuKey → 平台归属清单(唯一判定出口):京东独占(后台或桌面端清单)→ ['jd'];
|
||||
* 双侧清单 → ['amazon','jd'];其余(未知 key 在内)默认亚马逊。 */
|
||||
export function platformsOfMenuKey(key: string): PlatformTabId[] {
|
||||
if (JD_MENU_KEYS.includes(key) || JD_APP_MENU_KEYS.includes(key)) return ['jd']
|
||||
if (BOTH_PLATFORM_MENU_KEYS.includes(key)) return ['amazon', 'jd']
|
||||
return ['amazon']
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用「按平台过滤菜单树」(唯一算法出口,2026-11-17 用户口径「授权树也按平台收」):
|
||||
* 叶子按 {@link platformsOfMenuKey} 是否包含当前平台留下;分组节点自身的 key 不参与
|
||||
* 平台判定,按「有存活的子项」决定去留——否则京东侧「账号与权限」这类混合分组会被整组误剪。
|
||||
* 两个消费方必须同形:侧边栏(platform-menu-filter.ts)与账号弹窗的授权树
|
||||
* (UserMenuAuthTree.vue),改判定规则只改这一处。
|
||||
*/
|
||||
export function filterMenuTreeNodesByPlatform<T extends { key?: string; children?: T[] }>(
|
||||
nodes: readonly T[] | null | undefined,
|
||||
platform: PlatformTabId,
|
||||
): T[] {
|
||||
const filtered: T[] = []
|
||||
for (const node of nodes || []) {
|
||||
const children = filterMenuTreeNodesByPlatform(node.children, platform)
|
||||
if (children.length > 0) {
|
||||
filtered.push({ ...node, children })
|
||||
continue
|
||||
}
|
||||
if ((node.children || []).length > 0) continue
|
||||
if (platformsOfMenuKey(node.key || '').includes(platform)) filtered.push({ ...node })
|
||||
}
|
||||
return filtered
|
||||
}
|
||||
@@ -1,27 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, ref, watch } from 'vue'
|
||||
import { computed, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { joinAdminPath } from '@/config/app'
|
||||
import { pageTitleOf, topbarUserOf } from '@/layout/topbar-model'
|
||||
import { allGroupKeys, toSidebarEntries } from '@/layout/menu-mapper'
|
||||
import { filterMenuTreeByPlatform, allowedPlatformsForUser } from '@/layout/platform-menu-filter'
|
||||
import { PLATFORM_TABS, platformsOfMenuKey } from '@/config/platform-scope'
|
||||
import { usePlatformTabStore } from '@/stores/platform-tab'
|
||||
import { firstVisiblePath } from '@/router/helpers'
|
||||
import { groupKeysForActive, toSidebarEntries } from '@/layout/menu-mapper'
|
||||
import {
|
||||
EMPTY_MENU_DESCRIPTION,
|
||||
EMPTY_MENU_TITLE,
|
||||
shouldShowEmptyMenu,
|
||||
} from '@/layout/empty-state'
|
||||
import GlobalErrorContainer from '@/layout/GlobalErrorContainer.vue'
|
||||
import NotificationBell from '@/components/NotificationBell.vue'
|
||||
import ExpiryNotice from '@/components/ExpiryNotice.vue'
|
||||
import OperationGuide from '@/layout/OperationGuide.vue'
|
||||
import CompanyTabs from '@/layout/CompanyTabs.vue'
|
||||
import { crumbsForActiveRoute, resolveDocumentTitle, updateDocumentTitle } from '@/layout/title-breadcrumb'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import {
|
||||
LOGOUT_CONFIRM_CANCEL,
|
||||
LOGOUT_CONFIRM_MESSAGE,
|
||||
@@ -35,33 +27,8 @@ const router = useRouter()
|
||||
const session = useAdminSessionStore()
|
||||
|
||||
const activePath = computed(() => route.path)
|
||||
const platformTab = usePlatformTabStore()
|
||||
// 平台 tab(亚马逊/京东,2026-11-16「不混」定案)只做显示分组:准入仍是 session.menuTree
|
||||
// (后端按权限裁剪)+路由守卫,这里只把当前用户已被授权的菜单按平台分侧展示。
|
||||
const menuEntries = computed(() =>
|
||||
toSidebarEntries(filterMenuTreeByPlatform(session.menuTree, platformTab.active)),
|
||||
)
|
||||
// 平台锁定(2026-11-18 用户口径「隔离下除站点超管外,京东用户只看京东菜单、亚马逊看不了」):
|
||||
// tab 可见性 = 站点超管随菜单树分布;其余用户锁 users.platform 那一侧(后端下发树已按平台
|
||||
// 裁剪,这里再把 tab 收敛到本人平台,单侧时 tab 条整个隐藏)。
|
||||
const allowedTabIds = computed(() => allowedPlatformsForUser(session.menuTree, session.user))
|
||||
const visibleTabDefs = computed(() => PLATFORM_TABS.filter((tab) => allowedTabIds.value.includes(tab.id)))
|
||||
const showPlatformTabs = computed(() => allowedTabIds.value.length > 1)
|
||||
// 父菜单默认全展开(2026-11-17 用户口径「父菜单不要默认折叠」)。el-menu 的 default-openeds
|
||||
// 只在挂载时读一次,平台 tab 切换/菜单树刷新导致 entries 变化后新分组不会自动展开,
|
||||
// 这里在 entries 变更渲染完成后按当下值命令式补开;用户手动收起的组在 entries 不变期间
|
||||
// 保持收起(watch 不重触发)。读当下 computed 而非触发时快照:快速连切 tab 时不补开已
|
||||
// 离开渲染树的旧分组(el-menu 的 open 对未注册 index 会抛)。
|
||||
const menuRef = ref<{ open: (index: string) => void } | null>(null)
|
||||
const openedKeys = computed(() => allGroupKeys(menuEntries.value))
|
||||
watch(openedKeys, async () => {
|
||||
await nextTick()
|
||||
const menu = menuRef.value
|
||||
if (!menu) return
|
||||
for (const key of openedKeys.value) {
|
||||
menu.open(key)
|
||||
}
|
||||
}, { immediate: true })
|
||||
const menuEntries = computed(() => toSidebarEntries(session.menuTree))
|
||||
const openedKeys = computed(() => groupKeysForActive(menuEntries.value, route.path))
|
||||
const emptyMenu = computed(() => shouldShowEmptyMenu(menuEntries.value.length > 0, session.loading, session.initialized))
|
||||
const pageTitle = computed(() => pageTitleOf(route.meta.title))
|
||||
const userVm = computed(() => topbarUserOf(session.user))
|
||||
@@ -74,52 +41,6 @@ watch(
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
// 直达 URL/面包屑跳到另一平台的页面时,tab 指示自动跟过去(与侧边栏保持一致)。
|
||||
// 双侧清单里的页面(账号域三页)两个 tab 都算归属:当前 tab 已含它就不动。
|
||||
// 跟随目标只在允许集(allowedTabIds)里找:被平台锁定的侧不会成为落点。
|
||||
watch(
|
||||
() => route.meta.menuKey as string | undefined,
|
||||
(menuKey) => {
|
||||
if (!menuKey) return
|
||||
const owners = platformsOfMenuKey(menuKey)
|
||||
if (owners.includes(platformTab.active)) return
|
||||
const target = owners.find((platform) => allowedTabIds.value.includes(platform))
|
||||
if (target && target !== platformTab.active) {
|
||||
platformTab.setActive(target)
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
// 平台锁定的归位(2026-11-18):会话就位/菜单树刷新后允许集收敛时,把残留的另一侧 tab
|
||||
// (超管在同一浏览器切过,localStorage 落的值)归位本人平台;当前页若在被禁侧一并跳回
|
||||
// 该侧第一可见页。切 tab 的跳转复用下面 platformTab.active 的 watch(active 被 syncToAllowed
|
||||
// 改写后同链路生效)。
|
||||
watch(
|
||||
allowedTabIds,
|
||||
(allowed) => {
|
||||
if (!session.user) return
|
||||
platformTab.syncToAllowed(allowed)
|
||||
const menuKey = route.meta.menuKey as string | undefined
|
||||
if (!menuKey || platformsOfMenuKey(menuKey).includes(platformTab.active)) return
|
||||
const first = firstVisiblePath(filterMenuTreeByPlatform(session.menuTree, platformTab.active))
|
||||
if (first) void router.replace(first)
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
// 切到另一侧 tab 时当前页多半不在那边:跳到该侧第一个可见页;该侧为空(tab 不可见)则不动。
|
||||
// 双侧清单里的页面(账号域三页)切 tab 不跳转——页面自己按当前平台过滤数据。
|
||||
watch(
|
||||
() => platformTab.active,
|
||||
(tab) => {
|
||||
const menuKey = route.meta.menuKey as string | undefined
|
||||
if (!menuKey || platformsOfMenuKey(menuKey).includes(tab)) return
|
||||
const first = firstVisiblePath(filterMenuTreeByPlatform(session.menuTree, tab))
|
||||
if (first) void router.replace(first)
|
||||
},
|
||||
)
|
||||
|
||||
async function signOut() {
|
||||
try {
|
||||
await runLogout({
|
||||
@@ -135,7 +56,7 @@ async function signOut() {
|
||||
signOut: () => session.signOut(),
|
||||
})
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '退出登录失败', 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '退出登录失败')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -152,21 +73,8 @@ async function signOut() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<nav v-if="showPlatformTabs" class="admin-platform-tabs" role="tablist" aria-label="按平台切换菜单">
|
||||
<button
|
||||
v-for="tab in visibleTabDefs"
|
||||
:key="tab.id"
|
||||
type="button"
|
||||
role="tab"
|
||||
class="admin-platform-tab"
|
||||
:class="{ 'is-active': tab.id === platformTab.active }"
|
||||
:aria-selected="tab.id === platformTab.active"
|
||||
@click="platformTab.setActive(tab.id)"
|
||||
>{{ tab.label }}</button>
|
||||
</nav>
|
||||
|
||||
<el-scrollbar class="admin-menu-scroll">
|
||||
<el-menu ref="menuRef" :default-active="activePath" :default-openeds="openedKeys" router class="admin-menu">
|
||||
<el-menu :default-active="activePath" :default-openeds="openedKeys" router class="admin-menu">
|
||||
<template v-for="entry in menuEntries" :key="entry.key">
|
||||
<el-sub-menu v-if="entry.kind === 'group'" :index="entry.key">
|
||||
<template #title>
|
||||
@@ -192,7 +100,6 @@ async function signOut() {
|
||||
<h1>{{ pageTitle }}</h1>
|
||||
</div>
|
||||
<div class="admin-user">
|
||||
<NotificationBell />
|
||||
<div class="admin-user-meta">
|
||||
<strong>{{ userVm.username }}</strong>
|
||||
</div>
|
||||
@@ -204,7 +111,6 @@ async function signOut() {
|
||||
<el-breadcrumb v-if="breadcrumbs.length > 1" class="admin-breadcrumb" separator="/">
|
||||
<el-breadcrumb-item v-for="crumb in breadcrumbs" :key="crumb.key">{{ crumb.name }}</el-breadcrumb-item>
|
||||
</el-breadcrumb>
|
||||
<CompanyTabs />
|
||||
<OperationGuide />
|
||||
<GlobalErrorContainer />
|
||||
<el-alert v-if="session.error" :title="session.error" type="error" show-icon :closable="false" />
|
||||
@@ -217,7 +123,6 @@ async function signOut() {
|
||||
<RouterView v-else />
|
||||
</main>
|
||||
</section>
|
||||
<ExpiryNotice />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
/** 页面上方的公司 tab(spec §4、§9.3):只有超管看得到,而且只画在**注册表里真的按公司取数的那些页**上——
|
||||
* 选中哪家由哪一枚 tab 带 is-active 表达,这里不再挂第二处"这家是谁"的文案(§12 第 5 条把页头提示条算未批的界面暴露),
|
||||
* 提示条只讲这一页怎么办,不讲 tab(2026-10-14 公司观感那句已从引导文案撤掉,见 operation-guides 文件头)。 */
|
||||
import { computed, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { COMPANY_STATUS_ACTIVE } from '@/api/companies-dto'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { usePlatformTabStore } from '@/stores/platform-tab'
|
||||
import { companyTabAppliesTo, companyTabInitFailureMessage } from '@/layout/company-tab-model'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
|
||||
const route = useRoute()
|
||||
const tab = useCompanyTabStore()
|
||||
const session = useAdminSessionStore()
|
||||
const platformTab = usePlatformTabStore()
|
||||
const tabs = computed(() => tab.companies.filter((c) => c.status === COMPANY_STATUS_ACTIVE))
|
||||
const show = computed(() => tab.visibleForOperator && companyTabAppliesTo(route.meta.menuKey))
|
||||
|
||||
function ensureLoaded() {
|
||||
// 2026-10-05 修复轮 1:改前这里是 `void tab.initialize()`,store 里也只有 try/finally ⇒
|
||||
// GET /companies 抛错时异常变成 unhandled rejection(全仓 src 无 errorHandler/unhandledrejection 兜底),
|
||||
// 现场只剩"tab 条没画出来",Task 13 人工清单第一项无从判断是权限问题还是接口挂了。
|
||||
// 取不到目录 ⇒ fail-closed 不画 tab 条:store 不翻转 loaded,visibleForOperator 仍为 false,观感与改前一致。
|
||||
// store 照 admin-session.ts:37-39 的口径 catch 出 error 之后仍然 rethrow,所以这一侧必须 .catch 接住。
|
||||
// 模板里仍不长出任何新的常驻文字/提示条/图标(§12 第 5 条未批的暴露),但失败不许只剩 console.warn:
|
||||
// 文案由 company-tab-model 出,可见出口统一走 admin-feedback-ui 的 showAdminFeedback(一次性提示)。
|
||||
tab.initialize().catch((error: unknown) => {
|
||||
console.warn('[company-tab] 公司目录没取到,tab 条不渲染', error)
|
||||
showAdminFeedback(companyTabInitFailureMessage(error), 'warning')
|
||||
})
|
||||
}
|
||||
|
||||
watch(() => session.isSuperAdmin, (v) => {
|
||||
if (!v) return
|
||||
ensureLoaded()
|
||||
}, { immediate: true })
|
||||
|
||||
// 平台 tab 切换=公司目录换一份(V206 平台分侧;2026-11-17 用户口径「亚马逊侧别再挂京东-团队,
|
||||
// 京东侧同理」):store 按 loadedPlatform 对撞早退,切了台必然重拉。非超管目录恒空不发请求,
|
||||
// 这里同样按超管闸早退。
|
||||
watch(() => platformTab.active, () => {
|
||||
if (!session.isSuperAdmin) return
|
||||
ensureLoaded()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="show" class="company-tabs" role="tablist" aria-label="按公司查看数据">
|
||||
<button
|
||||
v-for="item in tabs"
|
||||
:key="item.id"
|
||||
type="button"
|
||||
role="tab"
|
||||
class="company-tab"
|
||||
:class="{ 'is-active': item.id === tab.activeId }"
|
||||
:aria-selected="item.id === tab.activeId"
|
||||
@click="tab.setActiveId(item.id)"
|
||||
>{{ item.companyName }}</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 只给上面那几枚 tab 上样式:tab 条本身不产出任何文字节点,公司名一律来自 item.companyName。 */
|
||||
.company-tabs {
|
||||
display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px;
|
||||
margin: 0 0 14px; padding: 0 2px;
|
||||
border-bottom: 1px solid var(--admin-border);
|
||||
}
|
||||
.company-tab {
|
||||
padding: 6px 16px;
|
||||
border: 1px solid transparent; border-bottom: 0;
|
||||
border-radius: 10px 10px 0 0;
|
||||
background: none; cursor: pointer;
|
||||
font: inherit; font-size: 13px; line-height: 1.7;
|
||||
color: var(--admin-sidebar-text);
|
||||
}
|
||||
.company-tab:hover { color: var(--admin-primary-strong); background: var(--admin-primary-soft); }
|
||||
.company-tab.is-active {
|
||||
border-color: var(--admin-border);
|
||||
background: #fff;
|
||||
color: var(--admin-primary-strong); font-weight: 650;
|
||||
box-shadow: inset 0 -2px 0 var(--admin-primary);
|
||||
}
|
||||
</style>
|
||||
@@ -1,8 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
/** 当前页面操作提示条:对齐旧版 admin-interactions.js 的 adminOperationGuide。每页文案逐条登记在
|
||||
* OPERATION_GUIDES 里,条数**不在这里数**(写死一个页数就会过期:公司 tab 那批把 group-manage 从
|
||||
* 通用 fallback 改成自带文案时,上一版注释里的数字就已经是错的了)——分母由 align-operation-guide
|
||||
* 那组用例按路由注册表钉着。
|
||||
/** 当前页面操作提示条:对齐旧版 admin-interactions.js 的 adminOperationGuide(14 页有独立文案,余用通用 fallback)。
|
||||
* 挂在 AdminLayout 内容区顶部,随 route.meta.menuKey 切换文案;折叠态存 localStorage。 */
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/** 公司 tab 的三支纯函数(store 与护栏用例共用,不依赖 pinia / 组件)。
|
||||
* import 用相对路径 + 显式 `.ts`:本文件被 tests 以 `node --test` 直接 import,而测试侧没有
|
||||
* vite 的 `@` 别名解析器,写成 `@/api/...` 会 ERR_MODULE_NOT_FOUND(护栏因此读源码而非常规 import,
|
||||
* 见 tests/company-tab-wiring.test.ts 用 readSource 的原因)。 */
|
||||
import { COMPANY_STATUS_ACTIVE, type CompanyItem } from '../api/companies-dto.ts'
|
||||
import { COMPANY_SCOPED_PAGES } from '../config/company-scope.ts'
|
||||
|
||||
/** 参与公司隔离的页(注册表那份 menuKey 的集合形态)。判据**只有这一份来源**:
|
||||
* 另立一张"哪些页不画 tab"的黑名单,下一个新页会默认长出一条点了没反应的 tab(2026-10-06 的成因)。 */
|
||||
const SCOPED_MENU_KEYS: ReadonlySet<string> = new Set(COMPANY_SCOPED_PAGES.map((page) => page.menuKey))
|
||||
|
||||
/**
|
||||
* 这一页切了公司**有没有用**。与 store 的 `visibleForOperator` 是两个正交问题,不是同一问的两把尺子:
|
||||
* 那一条答「目录取到了吗、这名下有几家可切」,这一条答「当前这页吃不吃公司维度」。
|
||||
* 壳层把 tab 挂在所有页上时,公司管理页头顶就压着一排点了不重取数的 tab(控制方 2026-10-06 点名)。
|
||||
*/
|
||||
export function companyTabAppliesTo(menuKey: unknown): boolean {
|
||||
return typeof menuKey === 'string' && SCOPED_MENU_KEYS.has(menuKey)
|
||||
}
|
||||
|
||||
/** 超管的读范围公司。非超管恒 null——它的公司是固定的,下传一个常数只会让人以为这页在按公司筛。 */
|
||||
export function companyIdForRequest(isSuperAdmin: boolean, activeId: number | null): number | null {
|
||||
return isSuperAdmin ? activeId : null
|
||||
}
|
||||
|
||||
/**
|
||||
* 公司目录没取到时的可见文案(四面9分口径 §2 后管「错误静默」)。
|
||||
*
|
||||
* <p>改前 CompanyTabs.vue 的 `.catch` 只 console.warn,现场只剩「tab 条没画出来」,
|
||||
* 判断不了是权限问题还是接口挂了。文案住在这里(不引组件、不引 element-plus),
|
||||
* 可见出口由组件用 admin-feedback-ui 的 showAdminFeedback 承接;tab 条模板本身仍不产出
|
||||
* 任何文字节点(§12 第 5 条那处未批的页头暴露没被绕过——这是一次性提示,不是常驻文案)。</p>
|
||||
*/
|
||||
export function companyTabInitFailureMessage(error: unknown): string {
|
||||
const base = '公司目录没取到,公司切换条暂不可用'
|
||||
const reason = error instanceof Error ? error.message.trim() : String(error ?? '').trim()
|
||||
return reason ? `${base}:${reason}` : base
|
||||
}
|
||||
|
||||
/** 「默认选中第一家」= id 最小的启用公司(spec §4 口径:不是超管自己所属公司,也不是返回顺序首条)。 */
|
||||
export function firstSelectableCompanyId(companies: readonly CompanyItem[]): number | null {
|
||||
const active = companies.filter((c) => c.status === COMPANY_STATUS_ACTIVE && c.id > 0)
|
||||
if (!active.length) return null
|
||||
return active.reduce((min, c) => (c.id < min ? c.id : min), active[0].id)
|
||||
}
|
||||
@@ -34,11 +34,11 @@ export function toSidebarEntries(nodes: AdminMenuNode[] | null | undefined): Sid
|
||||
return entries
|
||||
}
|
||||
|
||||
/** 计算需默认展开的分组 key:父菜单默认全展开(2026-11-17 用户口径「父菜单不要默认折叠」)。 */
|
||||
export function allGroupKeys(entries: SidebarEntry[]): string[] {
|
||||
/** 计算需默认展开的分组 key:分组下含当前激活路由子项时返回该分组 key。 */
|
||||
export function groupKeysForActive(entries: SidebarEntry[], activeRoute: string): string[] {
|
||||
const keys: string[] = []
|
||||
for (const entry of entries) {
|
||||
if (entry.kind === 'group') {
|
||||
if (entry.kind === 'group' && entry.children.some((child) => child.route === activeRoute)) {
|
||||
keys.push(entry.key)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,222 +0,0 @@
|
||||
/**
|
||||
* 后台铃铛通知纯逻辑:未读徽标文案、新通知判定、「已提醒过」去重记录、时间展示。
|
||||
* 轮询调度与渲染在 NotificationBell.vue;这里只放可单测的纯函数与存储读写。
|
||||
*/
|
||||
|
||||
/** 未读轮询间隔(60 秒)。 */
|
||||
export const NOTIFICATION_POLL_INTERVAL_MS = 60_000
|
||||
|
||||
const NOTIFIED_KEY_PREFIX = 'admin-notification:last-notified-id'
|
||||
|
||||
/** 未读徽标文案:0 或非法值显示空串,>99 显示 99+。 */
|
||||
export function formatUnreadBadge(count: number | null | undefined): string {
|
||||
const value = Number(count ?? 0)
|
||||
if (!Number.isFinite(value) || value <= 0) {
|
||||
return ''
|
||||
}
|
||||
return value > 99 ? '99+' : String(Math.floor(value))
|
||||
}
|
||||
|
||||
/** 是否出现新通知:latestId 大于上次已提醒过的 id。 */
|
||||
export function hasNewNotification(
|
||||
latestId: number | null | undefined,
|
||||
lastNotifiedId: number | null | undefined,
|
||||
): boolean {
|
||||
const latest = Number(latestId ?? 0)
|
||||
const notified = Number(lastNotifiedId ?? 0)
|
||||
if (!Number.isFinite(latest) || latest <= 0) {
|
||||
return false
|
||||
}
|
||||
return latest > (Number.isFinite(notified) && notified > 0 ? notified : 0)
|
||||
}
|
||||
|
||||
function storageKey(uid: string | number | null | undefined): string {
|
||||
const normalized = uid === null || uid === undefined || String(uid).trim() === '' ? '0' : String(uid)
|
||||
return `${NOTIFIED_KEY_PREFIX}:${normalized}`
|
||||
}
|
||||
|
||||
/** 读取当前管理员「已提醒过的最大通知 id」。 */
|
||||
export function readLastNotifiedId(uid: string | number | null | undefined): number {
|
||||
try {
|
||||
const raw = window.localStorage.getItem(storageKey(uid))
|
||||
const value = Number(raw ?? 0)
|
||||
return Number.isFinite(value) && value > 0 ? value : 0
|
||||
} catch {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
export function writeLastNotifiedId(uid: string | number | null | undefined, id: number): void {
|
||||
try {
|
||||
if (Number.isFinite(id) && id > 0) {
|
||||
window.localStorage.setItem(storageKey(uid), String(Math.floor(id)))
|
||||
}
|
||||
} catch {
|
||||
/* 存储不可用时静默忽略(退化为每次都提醒,不影响功能) */
|
||||
}
|
||||
}
|
||||
|
||||
/** 通知所属日期键(本地时区 yyyy-MM-dd);时间缺失/非法返回空串。 */
|
||||
export function notificationDayKey(value: string | null | undefined): string {
|
||||
if (!value) {
|
||||
return ''
|
||||
}
|
||||
const date = new Date(value)
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
return ''
|
||||
}
|
||||
const pad = (input: number) => String(input).padStart(2, '0')
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`
|
||||
}
|
||||
|
||||
/** 日期组头文案:今天 / 昨天 / 2026年9月11日;空键兜底「未知时间」。 */
|
||||
export function formatDayLabel(day: string, now: Date = new Date()): string {
|
||||
if (!day) {
|
||||
return '未知时间'
|
||||
}
|
||||
if (day === notificationDayKey(now.toISOString())) {
|
||||
return '今天'
|
||||
}
|
||||
const yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1)
|
||||
if (day === notificationDayKey(yesterday.toISOString())) {
|
||||
return '昨天'
|
||||
}
|
||||
const [year, month, date] = day.split('-').map((part) => Number(part))
|
||||
if (!Number.isFinite(year) || !Number.isFinite(month) || !Number.isFinite(date)) {
|
||||
return day
|
||||
}
|
||||
return `${year}年${month}月${date}日`
|
||||
}
|
||||
|
||||
/** 通知时间展示:今天只显示 HH:mm;昨天显示「昨天 HH:mm」;更早显示 MM-DD HH:mm。 */
|
||||
export function formatNotificationTime(
|
||||
value: string | null | undefined,
|
||||
now: Date = new Date(),
|
||||
): string {
|
||||
if (!value) {
|
||||
return ''
|
||||
}
|
||||
const date = new Date(value)
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
return ''
|
||||
}
|
||||
const pad = (input: number) => String(input).padStart(2, '0')
|
||||
const hourMinute = `${pad(date.getHours())}:${pad(date.getMinutes())}`
|
||||
const sameDay =
|
||||
date.getFullYear() === now.getFullYear() &&
|
||||
date.getMonth() === now.getMonth() &&
|
||||
date.getDate() === now.getDate()
|
||||
if (sameDay) {
|
||||
return hourMinute
|
||||
}
|
||||
const yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1)
|
||||
const isYesterday =
|
||||
date.getFullYear() === yesterday.getFullYear() &&
|
||||
date.getMonth() === yesterday.getMonth() &&
|
||||
date.getDate() === yesterday.getDate()
|
||||
if (isYesterday) {
|
||||
return `昨天 ${hourMinute}`
|
||||
}
|
||||
return `${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${hourMinute}`
|
||||
}
|
||||
|
||||
/**
|
||||
* 聚合组的稳定键:场景 × 自然日 × 事件主体用户,与后端的分组键逐字对应。
|
||||
* 主体为空(存量未标注那一组)要参与拼键,否则两组不同主体的组会撞成同一个 key,
|
||||
* 展开态就会串台——点开 A 组、展开的却是 B 组。
|
||||
*/
|
||||
export function notificationGroupKey(group: {
|
||||
scene?: string | null
|
||||
day?: string | null
|
||||
subjectUserId?: number | string | null
|
||||
}): string {
|
||||
const subject =
|
||||
group.subjectUserId === null || group.subjectUserId === undefined ? 'none' : String(group.subjectUserId)
|
||||
return `${group.scene ?? ''}|${group.day ?? ''}|${subject}`
|
||||
}
|
||||
|
||||
/** 组行上的计数徽语:折叠前有几条、其中几条没读。只报一个数就会被读成"一共就这些通知"。 */
|
||||
export function formatGroupCounts(rowCount: number | null | undefined, unreadCount: number | null | undefined): string {
|
||||
const total = Number(rowCount ?? 0)
|
||||
const unread = Number(unreadCount ?? 0)
|
||||
return unread > 0 ? `${total} 条 · ${unread} 未读` : `${total} 条`
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败反馈的文案与「同场故障只提示一次」的闸门(四面9分口径 §2 后管「错误静默」)。
|
||||
*
|
||||
* <p>改前 NotificationBell.vue 的两处 catch 只 console.warn:未读数接口挂了红点静默消失、
|
||||
* 点通知标已读失败界面纹丝不动,使用者无从判断是"没有通知"还是"接口没通"(全仓 src 无
|
||||
* errorHandler/unhandledrejection 兜底)。文案在这里出、可见出口由组件注入
|
||||
* ({@code showAdminFeedback}),模型层不引 element-plus ⇒ 这一族判据能用 node --test 直接跑真函数,
|
||||
* 不必退化成读源码的钉子。</p>
|
||||
*/
|
||||
export type BellFeedbackKind = 'success' | 'error' | 'warning'
|
||||
|
||||
/** 可见提示的出口:组件把 admin-feedback-ui 的 showAdminFeedback 递进来。 */
|
||||
export type BellFeedbackSink = (message: string, kind: BellFeedbackKind) => void
|
||||
|
||||
function failureReason(error: unknown): string {
|
||||
if (error instanceof Error) {
|
||||
return error.message.trim()
|
||||
}
|
||||
return String(error ?? '').trim()
|
||||
}
|
||||
|
||||
/** 未读数刷新失败的提示文案:带上原因,便于区分"接口挂了"与"没权限"。 */
|
||||
export function summaryFailureMessage(error: unknown): string {
|
||||
const reason = failureReason(error)
|
||||
return reason ? `通知未读数刷新失败:${reason}` : '通知未读数刷新失败'
|
||||
}
|
||||
|
||||
/** 标记已读失败的提示文案:点了必须有回应,失败也要有回应。 */
|
||||
export function markReadFailureMessage(error: unknown): string {
|
||||
const reason = failureReason(error)
|
||||
return reason ? `这条通知没能标记为已读:${reason}` : '这条通知没能标记为已读'
|
||||
}
|
||||
|
||||
/**
|
||||
* 轮询失败的提示闸门:一轮 60s,同一场故障只提示一次,成功一轮后重新武装。
|
||||
* 不设闸等于把「静默失败」换成「每分钟打扰一次」,两个都是错的口径。
|
||||
*/
|
||||
export function createSummaryFailureAlerter(feedback: BellFeedbackSink): {
|
||||
reportFailure(error: unknown): void
|
||||
reportSuccess(): void
|
||||
isArmed(): boolean
|
||||
} {
|
||||
let alerted = false
|
||||
return {
|
||||
reportFailure(error: unknown): void {
|
||||
if (alerted) {
|
||||
return
|
||||
}
|
||||
alerted = true
|
||||
feedback(summaryFailureMessage(error), 'warning')
|
||||
},
|
||||
reportSuccess(): void {
|
||||
alerted = false
|
||||
},
|
||||
isArmed(): boolean {
|
||||
return alerted
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/** 通知锚点的最小形状(与 AdminNotificationRef 对齐);不 import api 类型,保持本模块可被 node --test 直接跑。 */
|
||||
export interface NotificationTaskRef {
|
||||
taskNo?: string | null
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务锚点 → 任务中心深链。taskNo 是任务详情接口的唯一入参,空值不给链接
|
||||
* (宁可只显示文本,也不跳到一个必然查不到的任务上)。
|
||||
*/
|
||||
export function taskCenterRouteForRef(
|
||||
ref: NotificationTaskRef | null | undefined,
|
||||
): { path: string; query: { taskNo: string } } | null {
|
||||
const taskNo = String(ref?.taskNo ?? '').trim()
|
||||
if (!taskNo) {
|
||||
return null
|
||||
}
|
||||
return { path: '/task-center/board', query: { taskNo } }
|
||||
}
|
||||
@@ -1,420 +0,0 @@
|
||||
/**
|
||||
* 铃铛面板的状态机(10-13 通知聚合改造从 NotificationBell.vue 拆出)。
|
||||
*
|
||||
* 为什么单独一层:聚合两级(组行 ⇄ 明细行)带来 14 个 ref 与一整条数据流,
|
||||
* 全塞进 SFC 后组件 877 行,撞上可读棘轮 800 行上限。拆出来同时解决另一件事——
|
||||
* 组件在本面只能用 readSource 钉形状(`npm test` 那把尺子),而这一层是真函数,
|
||||
* 能被 node --test 直接跑:红点按组数、组内没读完不许掉、下钻三维、换页清展开态
|
||||
* 这些判据从此判的是行为,不是源码里有没有那行字。
|
||||
*
|
||||
* 组件只留 DOM 相关的那一半:面板开合、fixed 定位、外部点击关闭、60s 轮询定时器。
|
||||
*/
|
||||
import { computed, onUnmounted, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
import {
|
||||
ADMIN_NOTIFICATION_SEVERITY_LABELS,
|
||||
fetchNotificationGroups,
|
||||
fetchNotificationList,
|
||||
fetchNotificationSummary,
|
||||
markAllNotificationsRead,
|
||||
markNotificationRead,
|
||||
type AdminNotificationGroup,
|
||||
type AdminNotificationItem,
|
||||
type AdminNotificationSeverity,
|
||||
type AdminNotificationSortMode,
|
||||
} from '@/api/notifications'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import {
|
||||
createSummaryFailureAlerter,
|
||||
formatUnreadBadge,
|
||||
hasNewNotification,
|
||||
markReadFailureMessage,
|
||||
notificationGroupKey,
|
||||
readLastNotifiedId,
|
||||
writeLastNotifiedId,
|
||||
} from '@/layout/notification-bell-model'
|
||||
|
||||
/** 聚合行比单条高(多一行计数与展开入口),一页 6 组刚好是面板的高度量级。 */
|
||||
export const PANEL_PAGE_SIZE = 6
|
||||
/** 展开一组时列出的明细上限:一组最多可能有几百条,全塞进 DOM 会把面板撑到不可滚动。 */
|
||||
export const PANEL_DETAIL_LIMIT = 50
|
||||
|
||||
/** 关键字输入的防抖:每敲一个字都打一次接口没必要。 */
|
||||
const KEYWORD_DEBOUNCE_MS = 300
|
||||
|
||||
type Uid = number | string
|
||||
|
||||
export interface NotificationPanelOptions {
|
||||
/** 当前管理员 id:已提醒水位按人存,不能按机器存。 */
|
||||
uid: () => Uid
|
||||
/** 「今天」由组件供给:日期控件长在组件上,
|
||||
* 「凡渲染日期筛选的页必须自己接默认值」那把尺子(date-filter-default-today)只走 .vue,
|
||||
* 初值搬进这一层就等于从尺子的视野里消失。 */
|
||||
today: () => string
|
||||
}
|
||||
|
||||
/** 起止日期倒挂时自动交换,避免用户只看到「没有符合条件的通知」不知原因。 */
|
||||
export function normalizedDayRange(startDate: string, endDate: string): { startDate?: string; endDate?: string } {
|
||||
let start = startDate
|
||||
let end = endDate
|
||||
if (start && end && start > end) {
|
||||
const swapped = start
|
||||
start = end
|
||||
end = swapped
|
||||
}
|
||||
return { startDate: start || undefined, endDate: end || undefined }
|
||||
}
|
||||
|
||||
/** 下钻条件:三维缺一维就会把别的主体的行混进这一组的明细(同场景同一天有好几组)。 */
|
||||
export function detailQueryFor(
|
||||
group: AdminNotificationGroup,
|
||||
sort: AdminNotificationSortMode = 'severity',
|
||||
) {
|
||||
return {
|
||||
page: 1,
|
||||
pageSize: PANEL_DETAIL_LIMIT,
|
||||
sort,
|
||||
scene: group.scene,
|
||||
day: group.day,
|
||||
subjectUserId: group.subjectUserId,
|
||||
subjectUnlabelled: group.subjectUserId === null || group.subjectUserId === undefined,
|
||||
}
|
||||
}
|
||||
|
||||
/** 读完一条后重算两个计数:组内未读清零,红点(按组数)才掉那一格。 */
|
||||
export function applyMarkReadToCounts(
|
||||
groups: AdminNotificationGroup[],
|
||||
expandedKey: string,
|
||||
unreadCount: number,
|
||||
unreadGroupCount: number,
|
||||
): { unreadCount: number; unreadGroupCount: number } {
|
||||
const owner = groups.find((group) => notificationGroupKey(group) === expandedKey)
|
||||
if (owner && owner.unreadCount > 0) {
|
||||
owner.unreadCount -= 1
|
||||
if (owner.unreadCount === 0) {
|
||||
return { unreadCount: Math.max(0, unreadCount - 1), unreadGroupCount: Math.max(0, unreadGroupCount - 1) }
|
||||
}
|
||||
}
|
||||
return { unreadCount: Math.max(0, unreadCount - 1), unreadGroupCount }
|
||||
}
|
||||
|
||||
/** 聚合页返回:组数与明细条数两个数都要留,只给一个就会被读成「一共就这些通知」。 */
|
||||
export function applyGroupsPage(result: Awaited<ReturnType<typeof fetchNotificationGroups>>, fallback: {
|
||||
unreadCount: number
|
||||
unreadGroupCount: number
|
||||
}) {
|
||||
const list = Array.isArray(result?.groups) ? result.groups : []
|
||||
return {
|
||||
groups: list,
|
||||
total: Number(result?.total ?? list.length),
|
||||
rowCount: Number(result?.rowCount ?? list.length),
|
||||
unreadCount: Number(result?.unreadCount ?? fallback.unreadCount),
|
||||
unreadGroupCount: Number(result?.unreadGroupCount ?? fallback.unreadGroupCount),
|
||||
}
|
||||
}
|
||||
|
||||
/** 无筛选的首页就是最新数据,顺带把「已提醒过的最大 id」推上去;有筛选时最新 id 不代表真实最新。 */
|
||||
export function latestIdWorthRecording(list: AdminNotificationGroup[]): number {
|
||||
if (!list.length) return 0
|
||||
const latest = Number(list[0].latestId)
|
||||
return latest > 0 ? latest : 0
|
||||
}
|
||||
|
||||
/** 日期头只在"与上一组不是同一天"时出现:同一天可能有多个组(多个用户/多个场景)。 */
|
||||
export function startsNewDay(groups: AdminNotificationGroup[], index: number): boolean {
|
||||
if (index === 0) return true
|
||||
return groups[index - 1]?.day !== groups[index]?.day
|
||||
}
|
||||
|
||||
/** 级别:聚合行与明细行共用同一条规则,否则同一件事在两处颜色不一样。 */
|
||||
export function itemLevel(item: { level: string }): 'error' | 'warning' | 'info' {
|
||||
return item.level === 'error' || item.level === 'info' ? item.level : 'warning'
|
||||
}
|
||||
|
||||
/** 严重度兜底:新后端直接给 severity;旧后端没这列时按 level 推,绝不让标签空白。 */
|
||||
export function itemSeverity(item: {
|
||||
severity?: string | null
|
||||
level?: string | null
|
||||
}): AdminNotificationSeverity {
|
||||
const value = item.severity
|
||||
if (value === 'urgent' || value === 'high' || value === 'medium' || value === 'low') {
|
||||
return value
|
||||
}
|
||||
if (item.level === 'error') return 'urgent'
|
||||
if (item.level === 'info') return 'low'
|
||||
return 'high'
|
||||
}
|
||||
|
||||
export function severityLabel(item: { severity?: string | null; level?: string | null }): string {
|
||||
return ADMIN_NOTIFICATION_SEVERITY_LABELS[itemSeverity(item)]
|
||||
}
|
||||
|
||||
export function useNotificationBellPanel(options: NotificationPanelOptions) {
|
||||
const uid = options.uid
|
||||
const today = options.today
|
||||
|
||||
const unreadCount = ref(0)
|
||||
const unreadGroupCount = ref(0)
|
||||
const groups = ref<AdminNotificationGroup[]>([])
|
||||
const total = ref(0)
|
||||
const rowCount = ref(0)
|
||||
const page = ref(1)
|
||||
const loading = ref(false)
|
||||
const markingAll = ref(false)
|
||||
const loadError = ref('')
|
||||
const keyword = ref('')
|
||||
const startDate = ref(today())
|
||||
const endDate = ref(today())
|
||||
/** 默认按严重度;可切「按时间」。 */
|
||||
const sortMode = ref<AdminNotificationSortMode>('severity')
|
||||
const expandedKey = ref('')
|
||||
const details = ref<AdminNotificationItem[]>([])
|
||||
const detailTotal = ref(0)
|
||||
const detailLoading = ref(false)
|
||||
|
||||
/** 徽标按**组数**亮:同类事件一天刷几十条不该把红点做成计数器;后端没给这个字段时退回条数。 */
|
||||
const badgeText = computed(() => formatUnreadBadge(unreadGroupCount.value || unreadCount.value))
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / PANEL_PAGE_SIZE)))
|
||||
/** 日期恒为「当天」是默认视图、不算主动筛选:若计入,「无筛选才记录已提醒 id」的分支会永久失效。 */
|
||||
const hasFilter = computed(() => Boolean(keyword.value.trim()))
|
||||
/** el-date-picker 的绑定桥:内部仍用 startDate/endDate 两个 ref,模板 v-model 走这一层。 */
|
||||
const dateRangeValue = computed<[string, string] | null>(() =>
|
||||
startDate.value && endDate.value ? [startDate.value, endDate.value] : null,
|
||||
)
|
||||
|
||||
const summaryFailures = createSummaryFailureAlerter((message, kind) => showAdminFeedback(message, kind))
|
||||
|
||||
function onDateRangeChange(value: [string, string] | null) {
|
||||
const start = value?.[0]
|
||||
const end = value?.[1]
|
||||
startDate.value = start ? String(start) : ''
|
||||
endDate.value = end ? String(end) : ''
|
||||
}
|
||||
|
||||
function collapse() {
|
||||
expandedKey.value = ''
|
||||
details.value = []
|
||||
detailTotal.value = 0
|
||||
detailLoading.value = false
|
||||
}
|
||||
|
||||
function isExpanded(group: AdminNotificationGroup): boolean {
|
||||
return expandedKey.value === notificationGroupKey(group)
|
||||
}
|
||||
|
||||
async function refreshSummary() {
|
||||
try {
|
||||
const summary = await fetchNotificationSummary()
|
||||
summaryFailures.reportSuccess()
|
||||
unreadCount.value = Number(summary?.unreadCount ?? 0)
|
||||
unreadGroupCount.value = Number(summary?.unreadGroupCount ?? 0)
|
||||
const latestId = Number(summary?.latestId ?? 0)
|
||||
if (hasNewNotification(latestId, readLastNotifiedId(uid()))) {
|
||||
ElMessage.warning('收到新的告警通知,请点击右上角铃铛查看')
|
||||
writeLastNotifiedId(uid(), latestId)
|
||||
console.log('[admin-notification] 检测到新通知 latestId=', latestId)
|
||||
}
|
||||
} catch (error) {
|
||||
// 接口失败时红点不亮(与改前一致),但要让用户知道「没数」不等于「没通知」:
|
||||
// 同一场故障只提示一次,成功一轮后重新武装(见 createSummaryFailureAlerter)。
|
||||
console.warn('[admin-notification] 未读数刷新失败(静默降级):', error)
|
||||
summaryFailures.reportFailure(error)
|
||||
}
|
||||
}
|
||||
|
||||
async function loadPage(targetPage: number) {
|
||||
if (loading.value) return
|
||||
loading.value = true
|
||||
try {
|
||||
const result = await fetchNotificationGroups({
|
||||
page: targetPage,
|
||||
pageSize: PANEL_PAGE_SIZE,
|
||||
keyword: keyword.value,
|
||||
sort: sortMode.value,
|
||||
...normalizedDayRange(startDate.value, endDate.value),
|
||||
})
|
||||
const applied = applyGroupsPage(result, {
|
||||
unreadCount: unreadCount.value,
|
||||
unreadGroupCount: unreadGroupCount.value,
|
||||
})
|
||||
groups.value = applied.groups
|
||||
total.value = applied.total
|
||||
rowCount.value = applied.rowCount
|
||||
unreadCount.value = applied.unreadCount
|
||||
unreadGroupCount.value = applied.unreadGroupCount
|
||||
page.value = targetPage
|
||||
loadError.value = ''
|
||||
// 换页/重查后展开态必须清掉:旧组的明细列表与新页的组对不上,会串台
|
||||
collapse()
|
||||
if (targetPage <= 1 && !hasFilter.value) {
|
||||
const latest = latestIdWorthRecording(applied.groups)
|
||||
if (latest > 0) {
|
||||
writeLastNotifiedId(uid(), Math.max(readLastNotifiedId(uid()), latest))
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
// 列表加载失败在面板内提示,不弹全局消息打扰用户
|
||||
console.warn('[admin-notification] 通知列表加载失败:', error)
|
||||
loadError.value = error instanceof Error ? error.message : '通知加载失败'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleGroup(group: AdminNotificationGroup) {
|
||||
if (isExpanded(group)) {
|
||||
collapse()
|
||||
return
|
||||
}
|
||||
collapse()
|
||||
const key = notificationGroupKey(group)
|
||||
expandedKey.value = key
|
||||
detailLoading.value = true
|
||||
try {
|
||||
const result = await fetchNotificationList(detailQueryFor(group, sortMode.value))
|
||||
// 请求期间用户可能已经收起了另一组:晚到的结果不能盖掉当前展开的那组
|
||||
if (expandedKey.value !== key) return
|
||||
details.value = Array.isArray(result?.items) ? result.items : []
|
||||
detailTotal.value = Number(result?.total ?? details.value.length)
|
||||
} catch (error) {
|
||||
if (expandedKey.value !== key) return
|
||||
details.value = []
|
||||
detailTotal.value = 0
|
||||
showAdminFeedback(error instanceof Error ? error.message : '明细加载失败', 'error')
|
||||
} finally {
|
||||
if (expandedKey.value === key) {
|
||||
detailLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function goPage(targetPage: number) {
|
||||
const safe = Math.min(Math.max(1, targetPage), totalPages.value)
|
||||
if (safe === page.value || loading.value) return
|
||||
void loadPage(safe)
|
||||
}
|
||||
|
||||
/** 搜索/日期变化后回到第一页重新查询。 */
|
||||
function reload() {
|
||||
void loadPage(1)
|
||||
}
|
||||
|
||||
function resetFilters() {
|
||||
keyword.value = ''
|
||||
startDate.value = today()
|
||||
endDate.value = today()
|
||||
void loadPage(1)
|
||||
}
|
||||
|
||||
/** 排序切换:同一档不重复请求;切换后回到第一页并收起明细。 */
|
||||
function setSortMode(value: AdminNotificationSortMode) {
|
||||
if (sortMode.value === value) {
|
||||
return
|
||||
}
|
||||
sortMode.value = value
|
||||
void loadPage(1)
|
||||
}
|
||||
|
||||
async function onItemClick(item: AdminNotificationItem) {
|
||||
if (item.read) return
|
||||
try {
|
||||
await markNotificationRead(item.id)
|
||||
item.read = true
|
||||
const next = applyMarkReadToCounts(
|
||||
groups.value,
|
||||
expandedKey.value,
|
||||
unreadCount.value,
|
||||
unreadGroupCount.value,
|
||||
)
|
||||
unreadCount.value = next.unreadCount
|
||||
unreadGroupCount.value = next.unreadGroupCount
|
||||
} catch (error) {
|
||||
// 改前只 console.warn:点了通知没反应,用户只能反复点。失败必须可见(统一出口)。
|
||||
console.warn('[admin-notification] 标记已读失败:', error)
|
||||
showAdminFeedback(markReadFailureMessage(error), 'error')
|
||||
}
|
||||
}
|
||||
|
||||
async function readAll() {
|
||||
if (markingAll.value || unreadCount.value === 0) return
|
||||
markingAll.value = true
|
||||
try {
|
||||
await markAllNotificationsRead()
|
||||
for (const group of groups.value) {
|
||||
group.unreadCount = 0
|
||||
}
|
||||
for (const item of details.value) {
|
||||
item.read = true
|
||||
}
|
||||
unreadCount.value = 0
|
||||
unreadGroupCount.value = 0
|
||||
} catch (error) {
|
||||
console.warn('[admin-notification] 全部已读失败:', error)
|
||||
showAdminFeedback(error instanceof Error ? error.message : '操作失败', 'error')
|
||||
} finally {
|
||||
markingAll.value = false
|
||||
}
|
||||
}
|
||||
|
||||
let searchTimer: ReturnType<typeof setTimeout> | null = null
|
||||
|
||||
onUnmounted(dispose)
|
||||
|
||||
function onKeywordInput() {
|
||||
if (searchTimer != null) {
|
||||
clearTimeout(searchTimer)
|
||||
}
|
||||
searchTimer = setTimeout(() => {
|
||||
searchTimer = null
|
||||
void loadPage(1)
|
||||
}, KEYWORD_DEBOUNCE_MS)
|
||||
}
|
||||
|
||||
/** 防抖里那次没发出去的请求不许在面板关掉后落地:钩子挂在 composable 自己身上,
|
||||
* "有 setTimeout 的文件必须也有卸载钩子"这条配对判据因此由构造成立,不靠调用方记得清。 */
|
||||
function dispose() {
|
||||
if (searchTimer != null) {
|
||||
clearTimeout(searchTimer)
|
||||
searchTimer = null
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
unreadCount,
|
||||
unreadGroupCount,
|
||||
groups,
|
||||
total,
|
||||
rowCount,
|
||||
page,
|
||||
loading,
|
||||
markingAll,
|
||||
loadError,
|
||||
keyword,
|
||||
startDate,
|
||||
endDate,
|
||||
expandedKey,
|
||||
details,
|
||||
detailTotal,
|
||||
detailLoading,
|
||||
badgeText,
|
||||
totalPages,
|
||||
hasFilter,
|
||||
sortMode,
|
||||
setSortMode,
|
||||
dateRangeValue,
|
||||
onDateRangeChange,
|
||||
refreshSummary,
|
||||
loadPage,
|
||||
isExpanded,
|
||||
toggleGroup,
|
||||
goPage,
|
||||
reload,
|
||||
onKeywordInput,
|
||||
resetFilters,
|
||||
onItemClick,
|
||||
readAll,
|
||||
}
|
||||
}
|
||||
|
||||
export type NotificationPanel = ReturnType<typeof useNotificationBellPanel>
|
||||
@@ -1,10 +1,6 @@
|
||||
/**
|
||||
* 每菜单页的操作提示(guides)文案,对齐旧版 backend/static/admin-interactions.js 的 guides 表原文
|
||||
* (duplicate-check 为例外页不展示)。key = 路由 meta.menuKey。
|
||||
* 2026-10-14 控制方定案:提示条按 menuKey 取、不分支角色,谁能进这一页谁就看得到,
|
||||
* 于是"超级管理员可用上方公司 tab 切换公司""本页全平台共享,不按公司区分"这类只描述超管观感的句子
|
||||
* 会摊到普通账号脸上 —— 整批撤掉,文案回到旧版原文。tab 本身与它的接线没动。
|
||||
* 反向守门:tests/align-operation-guide.test.ts 钉这几句不得回流。
|
||||
* (除 group-manage / duplicate-check 用通用 fallback)。key = 路由 meta.menuKey。
|
||||
*/
|
||||
export interface OperationGuideData {
|
||||
text: string
|
||||
@@ -28,18 +24,11 @@ export const OPERATION_GUIDES: Record<string, OperationGuideData> = {
|
||||
text: '菜单会影响后台和软件端的可见范围。先填写名称并选择对应页面,再设置上级菜单;顺序直接拖动列表左侧手柄调整。',
|
||||
steps: ['新增或调整菜单', '设置层级', '拖动排序'],
|
||||
},
|
||||
admin_group_manage: {
|
||||
text: '数据权限分组决定"哪些账号能看到哪些店铺",分组按负责人和归属账号聚拢。',
|
||||
steps: ['选择分组', '维护负责人与归属账号', '核对店铺可见范围'],
|
||||
},
|
||||
admin_group_manage: OPERATION_GUIDE_FALLBACK,
|
||||
admin_user_secrets: {
|
||||
text: '用户密钥按账号绑定,列表只展示脱敏值。可对单条立即检测连通性;清空后该用户需要重新配置密钥。',
|
||||
steps: ['筛选用户或状态', '立即检测连通性', '必要时清空'],
|
||||
},
|
||||
admin_companies: {
|
||||
text: '公司决定账号归属:新建普通账号/管理员自动落在操作者自己所在的公司,页面上不出现公司选项——要给别的公司建号,请用那个公司自己的管理员登录。唯一例外是「公司超级管理员」:由站点超管开设、需在建号弹窗中显式选择所属公司。公司只做启用/停用,不提供删除。',
|
||||
steps: ['查看公司列表', '新建公司', '改名或启停'],
|
||||
},
|
||||
admin_dedupe_total_data: {
|
||||
text: '支持按关键词、用户、分组和国家筛选;导入前先确认所选分组,导出会按日期范围生成文件。',
|
||||
steps: ['选择分组', '筛选或导入', '核对并导出'],
|
||||
@@ -72,14 +61,6 @@ export const OPERATION_GUIDES: Record<string, OperationGuideData> = {
|
||||
text: '店铺数据任务按状态和时间筛选。批量操作前请核对已选任务。',
|
||||
steps: ['筛选任务', '检查状态', '执行批量操作'],
|
||||
},
|
||||
admin_brand_gating: {
|
||||
text: '维护不符合规则的品牌(品牌Gating / 类目Gating)。新增后可用下方筛选快速回查;云端 Gating 库与前端排查软件同步同一份数据,命中后会自动拦截。',
|
||||
steps: ['新增或批量导入', '筛选回查', '按需解除或删除'],
|
||||
},
|
||||
admin_keyword_usage: {
|
||||
text: '本页记录所有关键词操作,只读、不可删除、永久留痕可追溯;与桌面端互通:桌面复制、添加、删除关键词会自动写入本页,两端同源。',
|
||||
steps: ['选择公司与筛选条件', '切换使用/删除记录', '核对操作人与时间'],
|
||||
},
|
||||
// admin_shop_data_duplicate_check(店铺撞款监控)为例外页:不展示全局提示条,不参与对齐。
|
||||
admin_image_video_tasks: {
|
||||
text: '可先使用筛选缩小任务范围,再查看任务状态、结果和权限范围。',
|
||||
@@ -93,40 +74,10 @@ export const OPERATION_GUIDES: Record<string, OperationGuideData> = {
|
||||
text: '上传版本后请核对版本号和下载链接,再通知用户更新。',
|
||||
steps: ['上传压缩包', '检查版本记录', '维护历史版本'],
|
||||
},
|
||||
admin_tutorial: {
|
||||
text: '上传新的教程压缩包后即刻生效:工具台首页「立即下载教程」以下载最新上传的包为准。确认旧包不再需要后再删除。',
|
||||
steps: ['上传教程压缩包', '到工具台核对下载', '清理历史包'],
|
||||
},
|
||||
admin_workbench_client_package: {
|
||||
text: '上传新的工作台客户端 ZIP 包后即刻生效;服务端会复算 sha256 供客户端校验。确认旧包不再需要后再删除。',
|
||||
steps: ['填写版本号并上传 ZIP', '核对版本与 sha256', '清理历史包'],
|
||||
},
|
||||
digital_human_version: {
|
||||
text: '数字人版本需先上传草稿,再发布并标记最新版本。',
|
||||
steps: ['上传草稿', '确认更新日志', '发布或设为最新'],
|
||||
},
|
||||
admin_device_logs: {
|
||||
text: '桌面客户端与麦象采集机上报的日志按来源、日期和关键字筛选;可查看日志尾部、下载完整文件或删除云端记录,云端日志按保留期自动清理。',
|
||||
steps: ['选择来源与日期', '查看或下载日志', '必要时删除'],
|
||||
},
|
||||
admin_user_secret_usage: {
|
||||
text: '按日期范围统计各用户的密钥调用次数(货源查询与外观专利按 LLM 请求次数、代理按提取次数),用于评估用户资源损耗。',
|
||||
steps: ['选择日期范围', '筛选用户或分组', '核对各模块次数'],
|
||||
},
|
||||
admin_task_center: {
|
||||
text: '按账号、业务、状态、店铺和创建时间筛出客户端任务,点任务查看明细与分组结果;顶部汇总卡给当前在跑与疑似卡住的总量。',
|
||||
steps: ['按条件筛任务', '查看任务明细', '核对汇总卡'],
|
||||
},
|
||||
admin_appearance_patent_clean_items: {
|
||||
text: '本页只读:出表成功后「结论=无侵权」的明细自动同步到这里,按分公司隔离分页展示;支持任务号/ASIN/国家/同步日期筛选,下载原表请到任务中心取结果文件。',
|
||||
steps: ['筛选记录', '核对结论明细', '到任务中心下载原表'],
|
||||
},
|
||||
admin_jd_database: {
|
||||
// 2026-11-17 分类管理子菜单并入本页(用户口径「京东分类管理并到京东数据库分类编辑里」,
|
||||
// 原 admin_jd_category_manage 条目随之摘除):分类建/改名/删在工具栏「分类管理」。
|
||||
text: '本页只读:客户端采集的京东店铺商品自动同步到这里(同店铺同商品只保留最新一次),按分公司隔离分页展示;点行查看全部属性与图片;分类的新建/改名/删除在工具栏「分类管理」,给商品归类先勾选再「批量编辑分类」。',
|
||||
steps: ['筛选商品记录', '查看属性与图片明细', '用「分类管理」维护分类并批量归类'],
|
||||
},
|
||||
}
|
||||
|
||||
/** 全部有独立/兜底提示的后台业务菜单 key。 */
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
import type { AdminMenuNode, AdminUser } from '../types/admin'
|
||||
import { isSuperAdminRole } from '../types/admin.ts'
|
||||
import { PLATFORM_TABS, filterMenuTreeNodesByPlatform } from '../config/platform-scope.ts'
|
||||
import type { PlatformTabId } from '../config/platform-scope.ts'
|
||||
import { firstVisiblePath } from '../router/helpers.ts'
|
||||
|
||||
/**
|
||||
* 按平台 tab 过滤后端菜单树(2026-11-16「亚马逊/京东不混」):**只做显示分组,不做鉴权**——
|
||||
* 准入仍由 session.menuTree(后端按权限裁剪)与路由守卫负责,这里只是把当前用户已被授权的
|
||||
* 菜单按平台分到两个 tab 下展示。
|
||||
* 规则与算法在 {@link filterMenuTreeNodesByPlatform}(2026-11-17 起唯一出口,账号弹窗授权树
|
||||
* 同用一份);本壳只钉侧边栏专属的两条:节点的 key/name/route/children 形状原样透传(浅拷贝
|
||||
* 不改写),toSidebarEntries、groupKeysForActive 与面包屑都不受影响。
|
||||
*/
|
||||
export function filterMenuTreeByPlatform(
|
||||
nodes: AdminMenuNode[] | null | undefined,
|
||||
platform: PlatformTabId,
|
||||
): AdminMenuNode[] {
|
||||
return filterMenuTreeNodesByPlatform(nodes, platform)
|
||||
}
|
||||
|
||||
/** 当前用户在哪些平台下至少有一个可点页面(tab 显示依据);顺序固定随 PLATFORM_TABS。
|
||||
* 「可点」沿用 firstVisiblePath 这一把尺子(有 route 即可点),不另写第二处判定。 */
|
||||
export function visiblePlatformsFor(nodes: AdminMenuNode[] | null | undefined): PlatformTabId[] {
|
||||
return PLATFORM_TABS
|
||||
.filter((tab) => firstVisiblePath(filterMenuTreeByPlatform(nodes, tab.id)) !== '')
|
||||
.map((tab) => tab.id)
|
||||
}
|
||||
|
||||
/** 登录用户可用的平台 tab(2026-11-18 用户口径「隔离下除站点超管外,京东用户只看京东菜单、
|
||||
* 亚马逊看不了」):站点超管不限侧、沿用菜单树分布;其余用户锁 users.platform 那一侧
|
||||
* (未知/缺省按亚马逊存量口径,与后端 AdminMenuPlatformScope.normalize 同形),与「菜单树
|
||||
* 该侧有可点页面」求交——交集空则仍回落单侧(管理角色必有双侧账号域页,交集实际非空;
|
||||
* 宁可锁死自己平台也不放开被禁侧)。会话未就位(user 为空)时按可见分布,锁定的收窄
|
||||
* 由 AdminLayout 的 watch 在 user 就位后再做。 */
|
||||
export function allowedPlatformsForUser(
|
||||
nodes: AdminMenuNode[] | null | undefined,
|
||||
user: Pick<AdminUser, 'role' | 'platform'> | null | undefined,
|
||||
): PlatformTabId[] {
|
||||
const visible = visiblePlatformsFor(nodes)
|
||||
if (!user || isSuperAdminRole(user.role)) return visible
|
||||
const own: PlatformTabId = user.platform === 'jd' ? 'jd' : 'amazon'
|
||||
const allowed = visible.filter((id) => id === own)
|
||||
return allowed.length > 0 ? allowed : [own]
|
||||
}
|
||||
@@ -19,9 +19,5 @@ export interface TopbarUserViewModel {
|
||||
/** 顶部栏用户模型:用户信息或未登录空态统一为可渲染视图模型。 */
|
||||
export function topbarUserOf(user: AdminUser | null | undefined): TopbarUserViewModel {
|
||||
if (!user) return { username: '当前用户', role: '', hasUser: false }
|
||||
return {
|
||||
username: user.username || '当前用户',
|
||||
role: roleLabel(user.role) || user.role || '',
|
||||
hasUser: true,
|
||||
}
|
||||
return { username: user.username || '当前用户', role: roleLabel(user.role) || user.role || '', hasUser: true }
|
||||
}
|
||||
|
||||
@@ -1,36 +1,11 @@
|
||||
import { createApp } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import { installElement } from '@/plugins/element'
|
||||
import { reportClientError } from '@/shared/api/error-report'
|
||||
import ElementPlus from 'element-plus'
|
||||
import zhCn from 'element-plus/es/locale/lang/zh-cn'
|
||||
import 'element-plus/dist/index.css'
|
||||
import '@/styles/main.css'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
|
||||
// 全局错误兜底(S1-F2/AC-16):渲染期异常、未捕获 Promise、脚本级崩溃三类都必须
|
||||
// 可见 + 上报,否则线上白屏只剩浏览器 console,运维永远没有现场。
|
||||
// 出口分两处,各按自己的时机生效:
|
||||
// - Vue 渲染/生命周期异常:挂在这里的 app.config.errorHandler(必须早于 mount,
|
||||
// 首屏就崩也不漏);
|
||||
// - window error 与 unhandledrejection:由 App.vue setup 调 useGlobalErrorReporting()
|
||||
// 接线,卸载出口在 onBeforeUnmount 里摘监听与提示定时器(只定义不接线等于没接)。
|
||||
// 上报本体(内存环 + 脱敏 + sendBeacon)在 @/shared/api/error-report。
|
||||
function installGlobalError(app: ReturnType<typeof createApp>): void {
|
||||
app.config.errorHandler = (error, _instance, info) => {
|
||||
reportClientError({
|
||||
kind: 'vue-render',
|
||||
message: error instanceof Error ? error.message : String(error),
|
||||
stack: error instanceof Error ? error.stack ?? '' : String(error),
|
||||
route: router.currentRoute.value.fullPath,
|
||||
ts: Date.now(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Element Plus 改为按需注册(见 src/plugins/element.ts);全局中文语言包改由
|
||||
// App.vue 的 <el-config-provider :locale="zhCn"> 提供,不要再在这里 use(ElementPlus)。
|
||||
const app = createApp(App)
|
||||
app.use(createPinia())
|
||||
app.use(router)
|
||||
installElement(app)
|
||||
installGlobalError(app)
|
||||
app.mount('#app')
|
||||
// 全局中文语言包:日期控件(周/月/年份)、分页组件(上一页/下一页)等均显示中文。
|
||||
createApp(App).use(createPinia()).use(router).use(ElementPlus, { locale: zhCn }).mount('#app')
|
||||
|
||||
@@ -1,357 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
/** 公司管理(设计文档 §2.3):列表 + 新建 + 改名/启停 + 删除/批量删除(2026-11-23,名下有账号不能删)。
|
||||
* 可见范围由后端收窄(超管全部、公司内 admin 只自己公司);写操作仅超管,这里隐藏入口只是配合,
|
||||
* 真正的把关在 CompanyController,页面不得当作权限边界。 */
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
import { useRowSelection } from '@/utils/use-row-selection'
|
||||
import { deleteCompany, fetchCompanies } from '@/api/companies'
|
||||
import { COMPANY_STATUS_ACTIVE, type CompanyItem } from '@/api/companies-dto'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { refreshCompanyDirectory } from '@/stores/company-tab'
|
||||
import { usePlatformTabStore } from '@/stores/platform-tab'
|
||||
import BatchDeleteActions from '@/components/BatchDeleteActions.vue'
|
||||
import BatchDeleteCheckbox from '@/components/BatchDeleteCheckbox.vue'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import CompanyEditorDialog from './CompanyEditorDialog.vue'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||||
|
||||
const session = useAdminSessionStore()
|
||||
// 平台 tab(V206):公司列表按当前平台过滤,新建默认落当前平台。
|
||||
const platformTab = usePlatformTabStore()
|
||||
const loading = ref(false)
|
||||
const loadFailure = ref('')
|
||||
const rows = ref<CompanyItem[]>([])
|
||||
const editorVisible = ref(false)
|
||||
const editingCompany = ref<CompanyItem | null>(null)
|
||||
const filterKeyword = ref('')
|
||||
|
||||
const canManage = computed(() => session.isSuperAdmin)
|
||||
const filteredRows = computed(() => {
|
||||
const kw = filterKeyword.value.trim().toLowerCase()
|
||||
if (!kw) return rows.value
|
||||
return rows.value.filter((c) => (c.companyName || '').toLowerCase().includes(kw))
|
||||
})
|
||||
const page = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const pagedRows = computed(() => filteredRows.value.slice((page.value - 1) * pageSize.value, page.value * pageSize.value))
|
||||
|
||||
function changePage(p: number) { page.value = p }
|
||||
function changeSize(size: number) { pageSize.value = size; page.value = 1 }
|
||||
|
||||
async function loadCompanies() {
|
||||
loading.value = true
|
||||
loadFailure.value = ''
|
||||
try {
|
||||
rows.value = await fetchCompanies(platformTab.active)
|
||||
} catch (error) {
|
||||
loadFailure.value = error instanceof Error ? error.message : '公司列表加载失败'
|
||||
showAdminFeedback(loadFailure.value, 'error')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function openCreate() {
|
||||
editingCompany.value = null
|
||||
editorVisible.value = true
|
||||
}
|
||||
|
||||
function openEdit(company: CompanyItem) {
|
||||
editingCompany.value = company
|
||||
editorVisible.value = true
|
||||
}
|
||||
|
||||
/** 删除前置闸(勾选框置灰与删除按钮共用同一份理由;后端删除时还有权威校验兜底)。 */
|
||||
function deleteBlockReasonOf(company: CompanyItem): string | undefined {
|
||||
if (!canManage.value) return '只有超级管理员可以删除公司'
|
||||
const userCount = company.userCount ?? 0
|
||||
if (userCount > 0) return `该公司名下还有 ${userCount} 个账号,请先删除或转移后再删除公司`
|
||||
return undefined
|
||||
}
|
||||
|
||||
async function reloadCompaniesAndDirectory() {
|
||||
await loadCompanies()
|
||||
refreshCompanyDirectory().catch((error: unknown) => {
|
||||
console.warn('[company-tab] 公司变动后目录重拉失败', error)
|
||||
})
|
||||
}
|
||||
|
||||
const batch = useRowSelection({
|
||||
pageRows: () => pagedRows.value,
|
||||
rowId: (row) => row.id,
|
||||
rowLabel: (row) => row.companyName || `公司 ${row.id}`,
|
||||
deleteOne: (id) => deleteCompany(id),
|
||||
refresh: reloadCompaniesAndDirectory,
|
||||
blocked: () => loading.value || !!loadFailure.value,
|
||||
scope: () => [platformTab.active],
|
||||
precheck: (row) => deleteBlockReasonOf(row),
|
||||
})
|
||||
|
||||
async function removeCompany(company: CompanyItem) {
|
||||
if (batch.busy) return
|
||||
const reason = deleteBlockReasonOf(company)
|
||||
if (reason) {
|
||||
showAdminFeedback(reason, 'error')
|
||||
return
|
||||
}
|
||||
// 对齐分组管理:统一确认出口,删除不做级联(账号与业务数据留在各自页面处理)。
|
||||
if (!(await openAdminConfirm({ message: `确定删除公司“${company.companyName || company.id}”吗?删除后不可恢复。`, danger: true }))) return
|
||||
try {
|
||||
await deleteCompany(company.id)
|
||||
batch.removeFromSelection(company.id)
|
||||
ElMessage.success('删除成功')
|
||||
await reloadCompaniesAndDirectory()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
||||
}
|
||||
}
|
||||
|
||||
// 保存成功后:本页列表照常重拉,共享公司目录(tab 条)强制重拉一份。
|
||||
// 本页不参与公司隔离(控制方 2026-10-06「公司管理不要有 tab」)⇒ 走 store 的具名出口
|
||||
// refreshCompanyDirectory,而不是自己持一份 company-tab store(后者形状与「给这页上了 tab」
|
||||
// 分不开,company-config-entry-super-only 的 pageFiles 分母会当场红)。
|
||||
// 重拉失败不弹新提示(§12 第 5 条未批的界面暴露):tab 条保留旧名单,下一次切平台 tab / 重进页面会再试。
|
||||
async function onCompaniesSaved() {
|
||||
await reloadCompaniesAndDirectory()
|
||||
}
|
||||
|
||||
// 切平台 tab(V206)= 重新取数:公司归属按平台分列,两 tab 各看各的公司。
|
||||
watch(() => platformTab.active, () => {
|
||||
page.value = 1
|
||||
void loadCompanies()
|
||||
})
|
||||
|
||||
onMounted(loadCompanies)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="companies-view">
|
||||
<section class="panel-box">
|
||||
<div class="companies-head">
|
||||
<h3>公司列表</h3>
|
||||
<button v-if="canManage" class="btn" type="button" @click="openCreate">新建公司</button>
|
||||
</div>
|
||||
|
||||
<div class="form-row companies-filter-row">
|
||||
<div class="form-group" style="min-width: 200px">
|
||||
<label>公司名称</label>
|
||||
<input v-model="filterKeyword" type="text" placeholder="输入公司名称" />
|
||||
</div>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="loadCompanies" />
|
||||
<div class="table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="batch-delete-cell" scope="col">
|
||||
<BatchDeleteCheckbox label="全选当前页可删除公司" :checked="batch.pageAll" :partial="batch.pageSome"
|
||||
:disabled="batch.disabled || batch.pageEmpty" @change="batch.togglePage" />
|
||||
</th>
|
||||
<th style="width: 58px">序号</th>
|
||||
<th>公司名称</th>
|
||||
<th style="width: 90px">状态</th>
|
||||
<th style="width: 24%">备注</th>
|
||||
<th style="width: 160px">创建时间</th>
|
||||
<th style="width: 160px">修改时间</th>
|
||||
<th style="width: 140px">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-if="filteredRows.length">
|
||||
<tr v-for="(company, index) in pagedRows" :key="company.id" :class="{ 'batch-selected': batch.isSelected(company) }">
|
||||
<td class="batch-delete-cell">
|
||||
<BatchDeleteCheckbox :label="batch.reason(company) || `选择 ${batch.label(company)}`" :checked="batch.isSelected(company)"
|
||||
:disabled="batch.disabled || !!batch.reason(company)" @change="batch.toggle(company)" />
|
||||
</td>
|
||||
<td>{{ index + 1 }}</td>
|
||||
<td>{{ company.companyName || '-' }}</td>
|
||||
<td>
|
||||
<span :class="company.status === COMPANY_STATUS_ACTIVE ? 'state-on' : 'state-off'">
|
||||
{{ company.status === COMPANY_STATUS_ACTIVE ? '启用' : '停用' }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ company.remark || '-' }}</td>
|
||||
<td>{{ formatDateTime(company.createdAt) }}</td>
|
||||
<td>{{ formatDateTime(company.updatedAt || company.createdAt) }}</td>
|
||||
<td class="ops-cell">
|
||||
<template v-if="canManage">
|
||||
<button class="btn btn-sm" type="button" @click="openEdit(company)">编辑</button>
|
||||
<button class="btn btn-sm btn-danger" type="button" :disabled="batch.busy || !!deleteBlockReasonOf(company)"
|
||||
:title="deleteBlockReasonOf(company) || undefined" @click="removeCompany(company)">删除</button>
|
||||
</template>
|
||||
<span v-else class="cell-none">-</span>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-else-if="loading">
|
||||
<td colspan="8" class="empty-tip">加载中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td colspan="8" class="empty-tip">{{ filterKeyword.trim() ? '暂无匹配公司' : '暂无公司' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<OldPagination
|
||||
v-if="filteredRows.length > 0"
|
||||
:total="filteredRows.length"
|
||||
:page="page"
|
||||
:page-size="pageSize"
|
||||
@change="changePage"
|
||||
@size-change="changeSize"
|
||||
/>
|
||||
</section>
|
||||
|
||||
<CompanyEditorDialog v-model="editorVisible" :company="editingCompany" :platform="platformTab.active" @saved="onCompaniesSaved" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.companies-view {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 18px;
|
||||
color: #24384d;
|
||||
}
|
||||
.panel-box {
|
||||
width: 100%;
|
||||
padding: 20px 22px 24px;
|
||||
border: 1px solid #d8e3ee;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(145deg, #ffffff, #f9fbfd);
|
||||
box-shadow: 0 1px 2px rgba(39, 67, 94, 0.04), 0 14px 30px -24px rgba(39, 67, 94, 0.28);
|
||||
}
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 650;
|
||||
}
|
||||
.companies-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.companies-filter-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
gap: 14px 18px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.companies-filter-row .form-group {
|
||||
flex: 1 1 200px;
|
||||
}
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 7px;
|
||||
}
|
||||
.form-group label {
|
||||
color: #5b6f83;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input {
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 9px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13.5px;
|
||||
font-family: inherit;
|
||||
outline: none;
|
||||
}
|
||||
.form-group input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
}
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 42px;
|
||||
padding: 9px 18px;
|
||||
border: 1px solid #4f78a5;
|
||||
border-radius: 9px;
|
||||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
||||
color: #ffffff;
|
||||
font-family: inherit;
|
||||
font-size: 13.5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.btn:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #7094ba, #5d83ac);
|
||||
}
|
||||
.btn-sm {
|
||||
min-height: 36px;
|
||||
padding: 7px 12px;
|
||||
font-size: 12.5px;
|
||||
}
|
||||
.table-scroll {
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
border: 1px solid #dbe5ee;
|
||||
border-radius: 10px;
|
||||
background: #ffffff;
|
||||
}
|
||||
.table-scroll table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
table-layout: fixed;
|
||||
}
|
||||
.table-scroll th,
|
||||
.table-scroll td {
|
||||
padding: 10px 12px;
|
||||
text-align: left;
|
||||
font-size: 13.5px;
|
||||
line-height: 1.5;
|
||||
border-bottom: 1px solid #e0e8ef;
|
||||
vertical-align: middle;
|
||||
word-break: break-word;
|
||||
}
|
||||
.table-scroll th {
|
||||
background: #edf4fa;
|
||||
color: #4e6479;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.table-scroll tbody tr:hover td {
|
||||
background: #f1f7fb;
|
||||
}
|
||||
.table-scroll tbody tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.state-on {
|
||||
color: #2e7d5b;
|
||||
}
|
||||
.state-off {
|
||||
color: #b35f6a;
|
||||
}
|
||||
.ops-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
white-space: nowrap;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.cell-none {
|
||||
color: #8293a5;
|
||||
}
|
||||
.empty-tip {
|
||||
padding: 44px 24px;
|
||||
text-align: center;
|
||||
color: #8293a5;
|
||||
font-size: 13.5px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,97 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import type { PlatformTabId } from '@/config/platform-scope'
|
||||
import { createCompany, updateCompany } from '@/api/companies'
|
||||
import {
|
||||
COMPANY_NAME_MAX_LENGTH,
|
||||
COMPANY_STATUS_ACTIVE,
|
||||
COMPANY_STATUS_DISABLED,
|
||||
validateCompanyDraft,
|
||||
type CompanyDraft,
|
||||
type CompanyItem,
|
||||
} from '@/api/companies-dto'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { actionableErrorText } from '@/components/admin-feedback'
|
||||
|
||||
/** 新建/编辑公司(改名 + 启停 + 备注);写操作仅超管可用,权限由后端把关。
|
||||
* 所属平台不设手选(2026-11-17 用户口径「有京东就不需要亚马逊了,亚马逊那边也是」):
|
||||
* 平台跟随当前平台 tab——新建取当前 tab(props.platform),编辑保持行值原样下发。 */
|
||||
const props = defineProps<{ modelValue: boolean; company: CompanyItem | null; platform?: PlatformTabId }>()
|
||||
const emit = defineEmits<{ (e: 'update:modelValue', v: boolean): void; (e: 'saved'): void }>()
|
||||
|
||||
const form = ref<CompanyDraft>({ companyName: '', status: COMPANY_STATUS_ACTIVE, remark: '', platform: 'amazon' })
|
||||
const errorText = ref('')
|
||||
const busy = ref(false)
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(open) => {
|
||||
if (!open) return
|
||||
form.value = props.company
|
||||
? {
|
||||
companyName: props.company.companyName,
|
||||
status: props.company.status,
|
||||
remark: props.company.remark || '',
|
||||
platform: props.company.platform === 'jd' ? 'jd' : 'amazon',
|
||||
}
|
||||
: { companyName: '', status: COMPANY_STATUS_ACTIVE, remark: '', platform: props.platform ?? 'amazon' }
|
||||
errorText.value = ''
|
||||
},
|
||||
)
|
||||
|
||||
function close() {
|
||||
emit('update:modelValue', false)
|
||||
}
|
||||
|
||||
async function save() {
|
||||
errorText.value = validateCompanyDraft(form.value)
|
||||
if (errorText.value) return
|
||||
busy.value = true
|
||||
try {
|
||||
if (props.company) await updateCompany(props.company.id, form.value)
|
||||
else await createCompany(form.value)
|
||||
showAdminFeedback(props.company ? '公司已更新' : '公司已创建', 'success')
|
||||
emit('saved')
|
||||
close()
|
||||
} catch (error) {
|
||||
errorText.value = actionableErrorText(error)
|
||||
showAdminFeedback(errorText.value, 'error')
|
||||
} finally {
|
||||
busy.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-dialog
|
||||
:model-value="modelValue"
|
||||
:title="company ? '编辑公司' : '新建公司'"
|
||||
width="520px"
|
||||
:close-on-click-modal="false"
|
||||
destroy-on-close
|
||||
@update:model-value="(v: boolean) => emit('update:modelValue', v)"
|
||||
>
|
||||
<el-form label-position="top" @submit.prevent>
|
||||
<el-form-item label="公司名称" :error="errorText || undefined">
|
||||
<el-input
|
||||
v-model="form.companyName"
|
||||
:maxlength="COMPANY_NAME_MAX_LENGTH"
|
||||
placeholder="请输入公司名称(全平台唯一)"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="form.status" style="width: 100%">
|
||||
<el-option :value="COMPANY_STATUS_ACTIVE" label="启用" />
|
||||
<el-option :value="COMPANY_STATUS_DISABLED" label="停用" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="form.remark" type="textarea" :rows="2" placeholder="可留空" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="close">取消</el-button>
|
||||
<el-button type="primary" :loading="busy" @click="save">保存</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@@ -1,13 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import type { PlatformTabId } from '@/config/platform-scope'
|
||||
import { reactive, ref, watch } from 'vue'
|
||||
import { submitCreateUser } from './user-create-adapter'
|
||||
import {
|
||||
createEmptyCreateUserForm,
|
||||
defaultRoleChoice,
|
||||
mayCarryOwnExpiry,
|
||||
resolveRoleChoices,
|
||||
type CreatableUserRole,
|
||||
type CreateUserForm,
|
||||
type CreateUserFormErrors,
|
||||
validateCreateUserForm,
|
||||
@@ -19,18 +14,8 @@ import UserMenuAuthTree from './UserMenuAuthTree.vue'
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
operatorSuper?: boolean
|
||||
/** 操作者角色(company_super_admin 也能建管理员/普通账号)。 */
|
||||
operatorRole?: string | null
|
||||
/** 所属管理员候选(列表响应 admins;仅超管创建普通账号时展示,已按当前公司 tab 收窄)。 */
|
||||
/** 所属管理员候选(列表响应 admins;仅超管创建普通账号时展示)。 */
|
||||
adminOptions?: Array<{ id: number; username: string }>
|
||||
/** 公司候选(站点超管创建公司超级管理员时必选)。 */
|
||||
companyOptions?: Array<{ id: number; companyName: string }>
|
||||
/** 操作者自己那家公司(会话 current-user.companyId)。 */
|
||||
operatorCompanyId?: number | null
|
||||
/** 当前公司 tab:这次建号落在哪家,就决定能建哪些角色。 */
|
||||
activeCompanyId?: number | null
|
||||
/** 当前平台 tab(V206):新号落当前平台(跟随所在 tab,弹窗不再手选——2026-11-17 用户口径)。 */
|
||||
platform?: PlatformTabId
|
||||
}>()
|
||||
const emit = defineEmits<{ (e: 'update:modelValue', v: boolean): void; (e: 'created'): void }>()
|
||||
|
||||
@@ -38,29 +23,11 @@ const form = reactive<CreateUserForm>(createEmptyCreateUserForm())
|
||||
const errors = reactive<CreateUserFormErrors>({})
|
||||
const busy = ref(false)
|
||||
|
||||
/** 角色下拉:站点超管可选公司超管/管理员/普通账号;公司超管只可选管理员/普通账号;
|
||||
* 管理员不显示角色选择(后端强制 normal)。 */
|
||||
const ROLE_LABELS: Record<CreatableUserRole, string> = {
|
||||
company_super_admin: '公司超级管理员',
|
||||
admin: '管理员',
|
||||
normal: '普通账号',
|
||||
}
|
||||
const canChooseRole = computed(() => props.operatorSuper || props.operatorRole === 'company_super_admin')
|
||||
/** 可选角色集合的唯一来源是 user-create-model 那个纯函数(后端有同一口径的一条 403)。 */
|
||||
const allowedRoles = computed<CreatableUserRole[]>(() =>
|
||||
resolveRoleChoices(props.operatorSuper === true, props.operatorCompanyId, props.activeCompanyId),
|
||||
)
|
||||
const roleChoices = computed(() => allowedRoles.value.map((value) => ({ value, label: ROLE_LABELS[value] })))
|
||||
/** 只有管理员/公司超管有「自己的到期时间」;普通账号跟随上级级联,不给它入口。 */
|
||||
const expiryEditable = computed(() => mayCarryOwnExpiry(form.role))
|
||||
|
||||
// 公司 tab 收窄了可选角色时,把残留的旧选择收敛回合法项(并清掉上一家的所属管理员):
|
||||
// 留着它,用户看到的是一个已经不给选的选项,提交会被后端 403 打回。
|
||||
watch(allowedRoles, (roles) => {
|
||||
if (roles.includes(form.role)) return
|
||||
form.role = defaultRoleChoice(roles)
|
||||
form.createdBy = null
|
||||
})
|
||||
/** 角色下拉(对齐 admin.html:普通账号/管理员;超管才显示可改)。 */
|
||||
const ROLE_CHOICES: Array<{ value: 'admin' | 'normal'; label: string }> = [
|
||||
{ value: 'normal', label: '普通账号' },
|
||||
{ value: 'admin', label: '管理员' },
|
||||
]
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
@@ -68,17 +35,11 @@ watch(
|
||||
if (!open) return
|
||||
form.username = ''
|
||||
form.password = ''
|
||||
form.role = defaultRoleChoice(allowedRoles.value)
|
||||
form.role = 'normal'
|
||||
form.columnIds = []
|
||||
form.createdBy = null
|
||||
form.expiresAt = ''
|
||||
// 预填当前 tab:跨公司时角色本来就只剩公司超管,而那一例必须带公司
|
||||
form.companyId = props.activeCompanyId ?? null
|
||||
// 预填当前平台 tab(V206):京东侧建的号默认归京东,亚马逊侧默认亚马逊。
|
||||
form.platform = props.platform ?? 'amazon'
|
||||
errors.username = undefined
|
||||
errors.password = undefined
|
||||
errors.companyId = undefined
|
||||
},
|
||||
)
|
||||
|
||||
@@ -131,29 +92,9 @@ async function create(): Promise<void> {
|
||||
@input="errors.password = undefined"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="canChooseRole" label="角色">
|
||||
<el-form-item v-if="operatorSuper" label="角色">
|
||||
<el-select filterable v-model="form.role" style="width: 200px">
|
||||
<el-option v-for="opt in roleChoices" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="operatorSuper && form.role === 'company_super_admin'"
|
||||
label="所属公司"
|
||||
:error="errors.companyId"
|
||||
>
|
||||
<el-select
|
||||
v-model="form.companyId"
|
||||
filterable
|
||||
placeholder="请选择公司(必选)"
|
||||
style="width: 240px"
|
||||
@change="errors.companyId = undefined"
|
||||
>
|
||||
<el-option
|
||||
v-for="company in props.companyOptions || []"
|
||||
:key="company.id"
|
||||
:label="company.companyName"
|
||||
:value="company.id"
|
||||
/>
|
||||
<el-option v-for="opt in ROLE_CHOICES" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="operatorSuper && form.role === 'normal'" label="所属管理员">
|
||||
@@ -166,21 +107,9 @@ async function create(): Promise<void> {
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="expiryEditable" label="到期时间(留空 = 永不过期;到期后该账号及其名下账号将停用)">
|
||||
<el-date-picker
|
||||
v-model="form.expiresAt"
|
||||
type="datetime"
|
||||
placeholder="选择到期时间"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
format="YYYY-MM-DD HH:mm"
|
||||
style="width: 240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="菜单权限(勾选上级菜单会继承全部子菜单)">
|
||||
<div class="auth-tree-box">
|
||||
<!-- 授权树按账号平台收(2026-11-17 用户口径):京东 tab 只给京东侧菜单。
|
||||
平台不再手选(跟随当前 tab),树收窄的判定出口不变。 -->
|
||||
<UserMenuAuthTree v-model:checked="form.columnIds" :company-id="form.companyId" :platform="form.platform" />
|
||||
<UserMenuAuthTree v-model:checked="form.columnIds" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import { reactive, ref, watch } from 'vue'
|
||||
import type { AdminUser } from '@/types/admin'
|
||||
import type { PlatformTabId } from '@/config/platform-scope'
|
||||
import { mayCarryOwnExpiry } from './user-create-model'
|
||||
import { fillEditUserForm, validateEditUserForm, type EditUserForm, type EditUserFormErrors } from './user-edit-model'
|
||||
import { submitEditUser } from './user-edit-adapter'
|
||||
import { loadUserMenuAuth } from './user-menu-auth-api'
|
||||
@@ -10,28 +8,13 @@ import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { actionableErrorText } from '@/components/admin-feedback'
|
||||
import UserMenuAuthTree from './UserMenuAuthTree.vue'
|
||||
|
||||
/** companyId 由 UsersPage 把 companyTab.requestCompanyId 透传进来(本页的用户列表本来就由它筛 ⇒ 目标账号的公司
|
||||
* 就是 tab 选中的那家);弹窗自己不读 store,公司 tab 的取值口只留在页面组件那一处。
|
||||
* platform(V206)同理由页面透传:决定上架上限是否参与校验/下发(仅京东侧)。 */
|
||||
const props = defineProps<{ modelValue: boolean; user: AdminUser | null; operatorSuper?: boolean; companyId?: number | null; platform?: PlatformTabId }>()
|
||||
const props = defineProps<{ modelValue: boolean; user: AdminUser | null; operatorSuper?: boolean }>()
|
||||
const emit = defineEmits<{ (e: 'update:modelValue', v: boolean): void; (e: 'updated'): void }>()
|
||||
|
||||
const form = reactive<EditUserForm>({ uid: 0, username: '', password: '', role: 'normal', columnIds: [], originalRole: '', expiresAt: '', jdPublishQuota: 5000, platform: 'amazon' })
|
||||
const form = reactive<EditUserForm>({ uid: 0, username: '', password: '', role: 'normal', columnIds: [], originalRole: '' })
|
||||
const errors = reactive<EditUserFormErrors>({})
|
||||
const busy = ref(false)
|
||||
const loadingAuth = ref(false)
|
||||
/** 授权是否已成功加载:未就绪时保存会把空 columnIds 提交为“清空授权”,必须拦住。 */
|
||||
const authReady = ref(false)
|
||||
/** 公司超管目标:角色单选隐藏(请求体也不带 role),只允许改密码/到期时间/菜单。 */
|
||||
const targetIsCompanySuperAdmin = computed(() => (props.user?.role || '').trim().toLowerCase() === 'company_super_admin')
|
||||
/** 上架上限只属京东口径(用户 2026-11-17:「只要在京东这边用户编辑里加就行,不需要在亚马逊那边」):
|
||||
* 亚马逊侧隐藏该项,且校验与下发都不带 quota——字段留后端不动。 */
|
||||
const includeQuota = computed(() => props.platform === 'jd')
|
||||
/** 公司超管目标的角色单选是隐藏的(改完仍是 company_super_admin),到期时间照旧可改;
|
||||
* 管理员改成普通账号时这一项消失,保存按「清空」下发(见 user-edit-model 的 roleAfter)。 */
|
||||
const expiryEditable = computed(() =>
|
||||
mayCarryOwnExpiry(targetIsCompanySuperAdmin.value ? 'company_super_admin' : form.role),
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
@@ -44,12 +27,7 @@ watch(
|
||||
form.role = base.role
|
||||
form.columnIds = []
|
||||
form.originalRole = base.originalRole
|
||||
form.expiresAt = base.expiresAt
|
||||
form.jdPublishQuota = base.jdPublishQuota
|
||||
form.platform = base.platform
|
||||
errors.jdPublishQuota = undefined
|
||||
errors.password = undefined
|
||||
authReady.value = false
|
||||
void refreshAuth()
|
||||
},
|
||||
)
|
||||
@@ -58,12 +36,9 @@ async function refreshAuth(): Promise<void> {
|
||||
if (!props.user) return
|
||||
loadingAuth.value = true
|
||||
try {
|
||||
const { checkedIds } = await loadUserMenuAuth(props.user.id, props.companyId)
|
||||
const { checkedIds } = await loadUserMenuAuth(props.user.id)
|
||||
form.columnIds = checkedIds
|
||||
authReady.value = true
|
||||
} catch (error) {
|
||||
// 加载失败保持 authReady=false:保存按钮禁用,避免以空数组整树清空该用户授权。
|
||||
authReady.value = false
|
||||
showAdminFeedback(actionableErrorText(error), 'error')
|
||||
} finally {
|
||||
loadingAuth.value = false
|
||||
@@ -75,16 +50,12 @@ function close(): void {
|
||||
}
|
||||
|
||||
async function save(): Promise<void> {
|
||||
if (!authReady.value) {
|
||||
showAdminFeedback('菜单权限尚未加载完成,请稍后重试', 'error')
|
||||
return
|
||||
}
|
||||
const { valid, errors: errs } = validateEditUserForm(form, { includeQuota: includeQuota.value })
|
||||
const { valid, errors: errs } = validateEditUserForm(form)
|
||||
Object.assign(errors, errs)
|
||||
if (!valid) return
|
||||
busy.value = true
|
||||
try {
|
||||
await submitEditUser(form, { includeQuota: includeQuota.value })
|
||||
await submitEditUser(form)
|
||||
showAdminFeedback('更新成功', 'success')
|
||||
emit('updated')
|
||||
close()
|
||||
@@ -119,46 +90,25 @@ async function save(): Promise<void> {
|
||||
@input="errors.password = undefined"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="operatorSuper && !targetIsCompanySuperAdmin" label="角色">
|
||||
<el-form-item v-if="operatorSuper" label="角色">
|
||||
<el-radio-group v-model="form.role">
|
||||
<el-radio-button value="normal">普通账号</el-radio-button>
|
||||
<el-radio-button value="admin">管理员</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="targetIsCompanySuperAdmin" label="角色">
|
||||
<el-input model-value="公司超级管理员" readonly />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="expiryEditable" label="到期时间(清空 = 永不过期;到期后该账号及其名下账号将停用)">
|
||||
<el-date-picker
|
||||
v-model="form.expiresAt"
|
||||
type="datetime"
|
||||
placeholder="选择到期时间"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
format="YYYY-MM-DD HH:mm"
|
||||
style="width: 240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="includeQuota && (targetIsCompanySuperAdmin || form.role === 'admin')" label="京东上架额度(0 表示不限)" :error="errors.jdPublishQuota">
|
||||
<el-input-number v-model="form.jdPublishQuota" :min="0" :max="2147483647" :precision="0" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="props.user && props.user.creatorUsername" label="所属管理员">
|
||||
<el-input :model-value="props.user.creatorUsername" readonly />
|
||||
</el-form-item>
|
||||
<el-form-item label="菜单权限(勾选上级菜单会继承全部子菜单)">
|
||||
<div class="auth-tree-box">
|
||||
<!-- 授权树按账号平台收(2026-11-17 用户口径):京东档账号不再整树混发亚马逊菜单。
|
||||
平台不再手选(跟随当前平台 tab,编辑取行值),树收窄的判定出口不变。 -->
|
||||
<UserMenuAuthTree v-model:checked="form.columnIds" :company-id="props.companyId" :platform="form.platform" />
|
||||
<UserMenuAuthTree v-model:checked="form.columnIds" />
|
||||
<div v-if="loadingAuth" class="auth-loading">菜单权限加载中…</div>
|
||||
<div v-else-if="!authReady" class="auth-loading auth-loading-error">
|
||||
菜单权限加载失败,保存已禁用;请关闭后重试
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="close">取消</el-button>
|
||||
<el-button type="primary" :loading="busy" :disabled="!authReady" @click="save">保存</el-button>
|
||||
<el-button type="primary" :loading="busy" @click="save">保存</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@@ -176,7 +126,4 @@ async function save(): Promise<void> {
|
||||
font-size: 12px;
|
||||
color: var(--admin-muted);
|
||||
}
|
||||
.auth-loading-error {
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import type { AdminUser } from '@/types/admin'
|
||||
import type { PlatformTabId } from '@/config/platform-scope'
|
||||
import {
|
||||
eligibleGroupLeaders,
|
||||
eligibleGroupMembers,
|
||||
groupMemberCandidateHint,
|
||||
validateShopGroupForm,
|
||||
@@ -15,42 +13,24 @@ import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { actionableErrorText } from '@/components/admin-feedback'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
|
||||
const props = defineProps<{ modelValue: boolean; group: ShopGroupItem | null; operatorSuper?: boolean; platform?: PlatformTabId }>()
|
||||
const props = defineProps<{ modelValue: boolean; group: ShopGroupItem | null; operatorSuper?: boolean }>()
|
||||
const emit = defineEmits<{ (e: 'update:modelValue', v: boolean): void; (e: 'saved'): void }>()
|
||||
|
||||
const session = useAdminSessionStore()
|
||||
const groupName = ref('')
|
||||
/** 所属平台(V206):不设手选(2026-11-17 用户口径「有京东就不需要亚马逊了,亚马逊那边也是」)——
|
||||
* 新建取当前平台 tab(props.platform),编辑保持分组原值,值仍随保存下发。 */
|
||||
const groupPlatform = ref<PlatformTabId>('amazon')
|
||||
const memberIds = ref<number[]>([])
|
||||
const errorText = ref('')
|
||||
const busy = ref(false)
|
||||
const users = ref<AdminUser[]>([])
|
||||
|
||||
/**
|
||||
* 组长:新建默认当前登录用户,站点超管可下拉改选(2026-11-18 用户口径,后端 validateLeaderOperator
|
||||
* 对站点超管放行任意 createdById、只要求组长与操作者同公司);编辑=分组原组长(后端更新载荷不收
|
||||
* 组长,不可改);非站点超管新建时后端强制组长=操作者本人,同样只读展示。
|
||||
*/
|
||||
const leaderUserId = ref<number | null>(null)
|
||||
/** 只有「新建 + 站点超管」出组长下拉;其余场景只读回显。 */
|
||||
const canPickLeader = computed(() => !props.group && !!props.operatorSuper)
|
||||
const operatorRole = computed<string>(() => session.user?.role || '')
|
||||
|
||||
const leaderUsername = computed<string>(() => {
|
||||
const picked = leaderUserId.value != null
|
||||
? users.value.find((u) => u.id === leaderUserId.value)
|
||||
: null
|
||||
if (picked) return picked.username
|
||||
if (props.group) return props.group.leaderUsername || ''
|
||||
return session.user?.username || '当前登录用户'
|
||||
})
|
||||
|
||||
/** 组长候选:与组员同池(本公司账号),排除公司超管;站点超管仅保留操作者本人。 */
|
||||
const leaderCandidates = computed(() =>
|
||||
eligibleGroupLeaders(users.value, operatorRole.value, session.user?.id ?? null),
|
||||
/** 组长:新建=当前登录用户;编辑=分组原组长(不可改,只读展示)。 */
|
||||
const leaderUserId = computed<number | null>(() =>
|
||||
props.group ? (props.group.leaderUserId ?? null) : (session.user?.id ?? null),
|
||||
)
|
||||
const leaderUsername = computed<string>(() =>
|
||||
props.group ? (props.group.leaderUsername || '') : (session.user?.username || '当前登录用户'),
|
||||
)
|
||||
const operatorRole = computed<string>(() => session.user?.role || '')
|
||||
|
||||
/** 组员候选:按组长归属过滤(超管全量、非超管仅本组长创建的普通账号)。 */
|
||||
const memberCandidates = computed(() =>
|
||||
@@ -68,31 +48,14 @@ watch(
|
||||
if (props.group) {
|
||||
groupName.value = props.group.name
|
||||
memberIds.value = props.group.memberUserIds ?? []
|
||||
groupPlatform.value = props.group.platform === 'jd' ? 'jd' : 'amazon'
|
||||
// 编辑保持原值口径:历史行可能没有 leaderUserId(旧负载),回落 null 而不是当前登录人,
|
||||
// 否则组员候选过滤会跟着悄悄变。
|
||||
leaderUserId.value = props.group.leaderUserId ?? null
|
||||
} else {
|
||||
groupPlatform.value = props.platform ?? 'amazon'
|
||||
leaderUserId.value = session.user?.id ?? null
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
// 组长改选后,若该人已被选为组员要立刻摘掉——后端「组长不能作为组员重复加入分组」会打回。
|
||||
watch(leaderUserId, (id) => {
|
||||
if (id == null) return
|
||||
memberIds.value = memberIds.value.filter((v) => v !== id)
|
||||
})
|
||||
|
||||
async function loadCandidates(): Promise<void> {
|
||||
try {
|
||||
// 对齐 admin.js loadUserOptions:page=1&page_size=999 全量拉取,避免归属过滤漏人。
|
||||
// company_id 必带:不带时后端对站点超管返回全平台账号,别家公司的人就会出现在本公司分组的候选里。
|
||||
// 取操作者自己那家,不是公司 tab——组长候选与组员候选同池,后端要求组长与操作者同公司
|
||||
// (ensureLeaderSharesOperatorCompany),按 tab 取人会在超管停在别家 tab 时列出保存必被
|
||||
// 打回的人("只能添加组长本公司的账号")。
|
||||
const page = await fetchUserList({ page: 1, pageSize: 999, companyId: session.user?.companyId ?? null })
|
||||
const page = await fetchUserList({ page: 1, pageSize: 999 })
|
||||
users.value = page.items
|
||||
} catch (error) {
|
||||
showAdminFeedback(actionableErrorText(error), 'error')
|
||||
@@ -110,16 +73,16 @@ async function save(): Promise<void> {
|
||||
busy.value = true
|
||||
try {
|
||||
if (props.group) {
|
||||
await updateShopGroup(props.group.id, groupName.value, memberIds.value, groupPlatform.value)
|
||||
await updateShopGroup(props.group.id, groupName.value, memberIds.value)
|
||||
showAdminFeedback('更新成功', 'success')
|
||||
} else {
|
||||
// 组长默认当前登录用户;站点超管可改选本公司其他账号(createdById=所选组长)。
|
||||
const leaderId = leaderUserId.value ?? 0
|
||||
if (!leaderId) {
|
||||
showAdminFeedback('无法获取组长账号,请重新登录', 'error')
|
||||
// 对齐 admin:组长恒为当前登录用户,提交 createdBy=当前用户 id。
|
||||
const operatorId = session.user?.id ?? 0
|
||||
if (!operatorId) {
|
||||
showAdminFeedback('无法获取当前登录用户,请重新登录', 'error')
|
||||
return
|
||||
}
|
||||
await createShopGroup(groupName.value, memberIds.value, leaderId, groupPlatform.value)
|
||||
await createShopGroup(groupName.value, memberIds.value, operatorId)
|
||||
showAdminFeedback('创建成功', 'success')
|
||||
}
|
||||
emit('saved')
|
||||
@@ -148,16 +111,7 @@ onMounted(loadCandidates)
|
||||
<el-input v-model="groupName" placeholder="请输入分组名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="组长">
|
||||
<el-select
|
||||
v-if="canPickLeader"
|
||||
v-model="leaderUserId"
|
||||
filterable
|
||||
placeholder="选择组长(默认当前登录用户)"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option v-for="u in leaderCandidates" :key="u.id" :label="u.username" :value="u.id" />
|
||||
</el-select>
|
||||
<el-input v-else :model-value="leaderUsername" readonly placeholder="当前登录用户" />
|
||||
<el-input :model-value="leaderUsername" readonly placeholder="当前登录用户" />
|
||||
</el-form-item>
|
||||
<el-form-item label="组员">
|
||||
<el-select
|
||||
|
||||
@@ -1,30 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import BatchDeleteActions from '@/components/BatchDeleteActions.vue'
|
||||
import BatchDeleteCheckbox from '@/components/BatchDeleteCheckbox.vue'
|
||||
import { useRowSelection } from '@/utils/use-row-selection'
|
||||
import { createLatestRequestGate } from '@/utils/latest-request'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
/** 分组管理页 · 像素复刻旧版 admin.html panel-group-manage(自绘:顶部数据权限分组摘要 chips + 分组列表表格 + 新建分组;全量无分页同旧版)。
|
||||
* script 逻辑沿用现有 Vue 实现;编辑器保留现有组件。 */
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { usePlatformTabStore } from '@/stores/platform-tab'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
import { deleteShopGroup, fetchShopGroups } from './shop-group-api'
|
||||
import type { ShopGroupItem } from './shop-group-model'
|
||||
import GroupEditorDialog from './GroupEditorDialog.vue'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||||
|
||||
const session = useAdminSessionStore()
|
||||
const companyTab = useCompanyTabStore()
|
||||
// 平台 tab(V206):分组列表按当前平台过滤,新建默认落当前平台。
|
||||
const platformTab = usePlatformTabStore()
|
||||
const loading = ref(false)
|
||||
const loadFailure = ref('')
|
||||
const rows = ref<ShopGroupItem[]>([])
|
||||
const editorVisible = ref(false)
|
||||
const editingGroup = ref<ShopGroupItem | null>(null)
|
||||
@@ -55,34 +43,17 @@ function canEditOf(group: ShopGroupItem): boolean {
|
||||
return currentUserId.value != null && group.leaderUserId != null && currentUserId.value === group.leaderUserId
|
||||
}
|
||||
|
||||
const batchListGate = createLatestRequestGate()
|
||||
|
||||
async function loadGroups() {
|
||||
const token = batchListGate.begin()
|
||||
loading.value = true
|
||||
loadFailure.value = ''
|
||||
try {
|
||||
const items = await fetchShopGroups(companyTab.requestCompanyId, platformTab.active)
|
||||
if (!batchListGate.isCurrent(token)) return
|
||||
rows.value = items
|
||||
rows.value = await fetchShopGroups()
|
||||
} catch (error) {
|
||||
if (!batchListGate.isCurrent(token)) return
|
||||
loadFailure.value = error instanceof Error ? error.message : '数据权限分组加载失败'
|
||||
showAdminFeedback(loadFailure.value, 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '数据权限分组加载失败')
|
||||
} finally {
|
||||
if (batchListGate.isCurrent(token)) loading.value = false
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 切公司 = 重新取数(G1 的 pageFiles 断言盯着这一条)。
|
||||
watch(() => companyTab.activeId, () => void loadGroups())
|
||||
|
||||
// 切平台 tab(V206)= 重新取数:分组归属按平台分列,两 tab 各看各的分组。
|
||||
watch(() => platformTab.active, () => {
|
||||
page.value = 1
|
||||
void loadGroups()
|
||||
})
|
||||
|
||||
function openCreate() {
|
||||
editingGroup.value = null
|
||||
editorVisible.value = true
|
||||
@@ -94,28 +65,15 @@ function openEdit(group: ShopGroupItem) {
|
||||
editorVisible.value = true
|
||||
}
|
||||
|
||||
const batch = useRowSelection({
|
||||
pageRows: () => pagedGroups.value,
|
||||
rowId: (row) => row.id,
|
||||
rowLabel: (row) => row.name,
|
||||
deleteOne: (id) => deleteShopGroup(id),
|
||||
refresh: loadGroups,
|
||||
blocked: () => loading.value || !!loadFailure.value,
|
||||
scope: () => [companyTab.activeId, platformTab.active, currentUserId.value],
|
||||
precheck: (row) => canEditOf(row) ? undefined : '无权删除此分组',
|
||||
})
|
||||
|
||||
async function removeGroup(group: ShopGroupItem) {
|
||||
if (batch.busy) return
|
||||
const ok = await openAdminConfirm({ message: `确定删除分组“${group.name}”吗?`, danger: true })
|
||||
if (!ok) return
|
||||
try {
|
||||
await deleteShopGroup(group.id)
|
||||
batch.removeFromSelection(group.id)
|
||||
ElMessage.success('删除成功')
|
||||
await loadGroups()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,18 +97,12 @@ onMounted(loadGroups)
|
||||
<label>组长</label>
|
||||
<input v-model="filterLeader" type="text" placeholder="输入组长用户名" />
|
||||
</div>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="loadGroups" />
|
||||
<div class="table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="batch-delete-cell" scope="col">
|
||||
<BatchDeleteCheckbox label="全选当前页可删除记录" :checked="batch.pageAll" :partial="batch.pageSome"
|
||||
:disabled="batch.disabled || batch.pageEmpty" @change="batch.togglePage" />
|
||||
</th>
|
||||
<th style="width: 58px">序号</th>
|
||||
<th style="width: 16%">分组名称</th>
|
||||
<th style="width: 12%">组长</th>
|
||||
@@ -163,11 +115,7 @@ onMounted(loadGroups)
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-if="filteredRows.length">
|
||||
<tr v-for="(group, index) in pagedGroups" :key="group.id" :class="{ 'batch-selected': batch.isSelected(group) }">
|
||||
<td class="batch-delete-cell">
|
||||
<BatchDeleteCheckbox :label="batch.reason(group) || `选择 ${batch.label(group)}`" :checked="batch.isSelected(group)"
|
||||
:disabled="batch.disabled || !!batch.reason(group)" @change="batch.toggle(group)" />
|
||||
</td>
|
||||
<tr v-for="(group, index) in pagedGroups" :key="group.id">
|
||||
<td>{{ index + 1 }}</td>
|
||||
<td>{{ group.name }}</td>
|
||||
<td>{{ group.leaderUsername || '-' }}</td>
|
||||
@@ -183,17 +131,17 @@ onMounted(loadGroups)
|
||||
<td class="ops-cell">
|
||||
<template v-if="canEditOf(group)">
|
||||
<button class="btn btn-sm" type="button" @click="openEdit(group)">编辑</button>
|
||||
<button class="btn btn-sm btn-danger" type="button" :disabled="batch.busy" @click="removeGroup(group)">删除</button>
|
||||
<button class="btn btn-sm btn-danger" type="button" @click="removeGroup(group)">删除</button>
|
||||
</template>
|
||||
<span v-else class="member-none">-</span>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-else-if="loading">
|
||||
<td colspan="9" class="empty-tip">加载中...</td>
|
||||
<td colspan="8" class="empty-tip">加载中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td colspan="9" class="empty-tip">{{ filterKeyword || filterLeader ? '暂无匹配分组' : '暂无分组' }}</td>
|
||||
<td colspan="8" class="empty-tip">{{ filterKeyword || filterLeader ? '暂无匹配分组' : '暂无分组' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -205,7 +153,6 @@ onMounted(loadGroups)
|
||||
v-model="editorVisible"
|
||||
:group="editingGroup"
|
||||
:operator-super="isSuperAdmin"
|
||||
:platform="platformTab.active"
|
||||
@saved="loadGroups"
|
||||
/>
|
||||
</div>
|
||||
@@ -260,7 +207,8 @@ h3 {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input {
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
@@ -274,10 +222,12 @@ h3 {
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover {
|
||||
.form-group input:hover,
|
||||
.form-group select:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus {
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
@@ -400,7 +350,6 @@ h3 {
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
white-space: nowrap;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
|
||||
@@ -1,21 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import BatchDeleteActions from '@/components/BatchDeleteActions.vue'
|
||||
import BatchDeleteCheckbox from '@/components/BatchDeleteCheckbox.vue'
|
||||
import { useRowSelection } from '@/utils/use-row-selection'
|
||||
import { createLatestRequestGate } from '@/utils/latest-request'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
/** 菜单权限配置页 · 像素复刻旧版 admin.html panel-columns(自绘:面板头+新增菜单、拖拽手柄 ⠿、树形缩进+└、旧式表格、全量无分页同旧版)。
|
||||
* script 逻辑沿用现有 Vue 实现(拖拽分组/落点/重排保存、弹窗表单)。 */
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { usePlatformTabStore } from '@/stores/platform-tab'
|
||||
import { filterMenuTreeNodesByPlatform } from '@/config/platform-scope'
|
||||
import { createMenu, deleteMenu, loadMenuManageTree, reorderMenus, updateMenu } from './menu-manage-api'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||||
import {
|
||||
MENU_TYPE_OPTIONS,
|
||||
createMenuForm,
|
||||
@@ -37,22 +27,9 @@ import {
|
||||
interface MenuRow extends MenuManageNode {
|
||||
depth: number
|
||||
}
|
||||
interface PlatformMenuNode extends MenuManageNode {
|
||||
key: string
|
||||
children?: PlatformMenuNode[]
|
||||
}
|
||||
|
||||
const companyTab = useCompanyTabStore()
|
||||
const loading = ref(false)
|
||||
const loadFailure = ref('')
|
||||
const rows = ref<MenuManageNode[]>([])
|
||||
const platformTab = usePlatformTabStore()
|
||||
// 菜单字典保留全树;显示与父级候选先分平台,再展平分页,避免京东项被亚马逊菜单挤到后页。
|
||||
const visibleMenuTree = computed(() => {
|
||||
const withKeys = (nodes: MenuManageNode[]): PlatformMenuNode[] =>
|
||||
nodes.map((node) => ({ ...node, key: node.columnKey, children: withKeys(node.children || []) }))
|
||||
return filterMenuTreeNodesByPlatform(withKeys(rows.value), platformTab.active)
|
||||
})
|
||||
/** 筛选:菜单名称/类型(用户要求账户域子菜单补筛选条件)。 */
|
||||
const filterName = ref('')
|
||||
const filterType = ref('')
|
||||
@@ -80,14 +57,14 @@ const menuRows = computed<MenuRow[]>(() => {
|
||||
if (node.children?.length) walk(node.children, depth + 1)
|
||||
}
|
||||
}
|
||||
walk(visibleMenuTree.value, 0)
|
||||
walk(rows.value, 0)
|
||||
return out
|
||||
})
|
||||
const createVisible = ref(false)
|
||||
const saving = ref(false)
|
||||
const editingNode = ref<MenuManageNode | null>(null)
|
||||
const menuForm = reactive<MenuManageForm>(createMenuForm(null, 0))
|
||||
const parentOptions = computed(() => menuParentCandidates(visibleMenuTree.value, menuForm.menuType))
|
||||
const parentOptions = computed(() => menuParentCandidates(rows.value, menuForm.menuType))
|
||||
const dialogTitle = computed(() => (editingNode.value ? '编辑菜单' : '新增菜单'))
|
||||
/** 节点 id -> 名称,供「上级菜单」列展示。 */
|
||||
const nameById = computed(() => {
|
||||
@@ -104,22 +81,14 @@ function parentNameOf(node: MenuManageNode): string {
|
||||
return nameById.value.get(node.parentId) ?? `#${node.parentId}`
|
||||
}
|
||||
|
||||
const batchListGate = createLatestRequestGate()
|
||||
|
||||
async function loadMenus() {
|
||||
const token = batchListGate.begin()
|
||||
loading.value = true
|
||||
loadFailure.value = ''
|
||||
try {
|
||||
const items = await loadMenuManageTree(companyTab.requestCompanyId)
|
||||
if (!batchListGate.isCurrent(token)) return
|
||||
rows.value = items
|
||||
rows.value = await loadMenuManageTree()
|
||||
} catch (error) {
|
||||
if (!batchListGate.isCurrent(token)) return
|
||||
loadFailure.value = error instanceof Error ? error.message : '菜单列表加载失败'
|
||||
showAdminFeedback(loadFailure.value, 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '菜单列表加载失败')
|
||||
} finally {
|
||||
if (batchListGate.isCurrent(token)) loading.value = false
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +106,7 @@ function openEdit(node: MenuManageNode) {
|
||||
|
||||
/** 菜单类型切换时:当前父菜单不属于新类型则重置为根。 */
|
||||
function onMenuTypeChange(): void {
|
||||
const candidates = menuParentCandidates(visibleMenuTree.value, menuForm.menuType)
|
||||
const candidates = menuParentCandidates(rows.value, menuForm.menuType)
|
||||
if (menuForm.parentId != null && !candidates.some((node) => node.id === menuForm.parentId)) {
|
||||
menuForm.parentId = null
|
||||
}
|
||||
@@ -183,7 +152,7 @@ async function onDrop(event: DragEvent, target: MenuManageNode): Promise<void> {
|
||||
ElMessage.success('排序已保存')
|
||||
await loadMenus()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '排序保存失败', 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '排序保存失败')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,54 +175,35 @@ async function saveMenu() {
|
||||
await updateMenu(editingNode.value.id, menuForm)
|
||||
ElMessage.success('保存成功')
|
||||
} else {
|
||||
await createMenu(menuForm, companyTab.requestCompanyId)
|
||||
await createMenu(menuForm)
|
||||
ElMessage.success('创建成功')
|
||||
}
|
||||
createVisible.value = false
|
||||
await loadMenus()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '保存失败', 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '保存失败')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const batch = useRowSelection({
|
||||
pageRows: () => pagedMenuRows.value,
|
||||
rowId: (row) => row.id,
|
||||
rowLabel: (row) => row.name,
|
||||
deleteOne: (id) => deleteMenu(id),
|
||||
refresh: loadMenus,
|
||||
blocked: () => loading.value || !!loadFailure.value || saving.value,
|
||||
scope: () => [companyTab.activeId, platformTab.active],
|
||||
precheck: (row) => menuDeleteReason(row),
|
||||
})
|
||||
|
||||
async function removeMenu(node: MenuManageNode) {
|
||||
if (batch.busy) return
|
||||
const reason = menuDeleteReason(node)
|
||||
if (reason) {
|
||||
ElMessage.warning(reason)
|
||||
return
|
||||
}
|
||||
// 对齐旧版:原生 confirm。
|
||||
if (!(await openAdminConfirm({ message: `确定删除菜单“${node.name}”吗?`, danger: true }))) return
|
||||
if (!window.confirm(`确定删除菜单“${node.name}”吗?`)) return
|
||||
try {
|
||||
await deleteMenu(node.id)
|
||||
batch.removeFromSelection(node.id)
|
||||
ElMessage.success('删除成功')
|
||||
await loadMenus()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||
}
|
||||
}
|
||||
|
||||
/** 切公司:菜单名称/类型是客户端筛选(在 filteredMenuRows 上筛,不进请求),留着上一家填的值
|
||||
* 就是拿别家的字符串去筛新一家那一套树 ⇒ 首屏「暂无匹配菜单」而输入框里还显示着它;页码回 1
|
||||
* 是因为新一家的行数不同。末尾的 void loadMenus() 才是本页唯一的数据出口。 */
|
||||
watch(() => platformTab.active, () => { filterName.value = ''; filterType.value = ''; page.value = 1; createVisible.value = false })
|
||||
watch(() => companyTab.activeId, () => { filterName.value = ''; filterType.value = ''; page.value = 1; void loadMenus() })
|
||||
|
||||
onMounted(loadMenus)
|
||||
</script>
|
||||
|
||||
@@ -273,35 +223,24 @@ onMounted(loadMenus)
|
||||
</div>
|
||||
<div class="form-group" style="min-width: 160px">
|
||||
<label>菜单类型</label>
|
||||
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 的弹层是浏览器直角原生物
|
||||
⇒ 换 el-select(admin-filter 同壳 42px/9px 圆角,弹层是 EP 圆角面板)。
|
||||
「全部」保留为空值首行=空串不按类型筛(与旧原生下拉同语义);model 是空串时
|
||||
EP 不显示 label 而走 placeholder,所以 placeholder 同文案,观感与改前一致。 -->
|
||||
<el-select v-model="filterType" class="admin-filter" placeholder="全部" aria-label="筛选菜单类型">
|
||||
<el-option label="全部" value="" />
|
||||
<el-option label="后台" value="admin" />
|
||||
<el-option label="软件" value="app" />
|
||||
</el-select>
|
||||
<select v-model="filterType">
|
||||
<option value="">全部</option>
|
||||
<option value="admin">后台</option>
|
||||
<option value="app">软件</option>
|
||||
</select>
|
||||
</div>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="loadMenus" />
|
||||
<div class="table-scroll columns-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="batch-delete-cell" scope="col">
|
||||
<BatchDeleteCheckbox label="全选当前页可删除记录" :checked="batch.pageAll" :partial="batch.pageSome"
|
||||
:disabled="batch.disabled || batch.pageEmpty" @change="batch.togglePage" />
|
||||
</th>
|
||||
<th class="column-drag-cell"><span class="visually-hidden">排序</span></th>
|
||||
<th style="width: 60px">ID</th>
|
||||
<th style="width: 200px">菜单名称</th>
|
||||
<th style="width: 100px">菜单类型</th>
|
||||
<th style="width: 120px">上级菜单</th>
|
||||
<th style="width: 170px">创建时间</th>
|
||||
<th style="width: 170px">更新时间</th>
|
||||
<th style="width: 170px">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -310,14 +249,10 @@ onMounted(loadMenus)
|
||||
<tr
|
||||
v-for="row in pagedMenuRows"
|
||||
:key="row.id"
|
||||
:class="{ 'batch-selected': batch.isSelected(row), 'is-column-dragging': dragState?.id === row.id }"
|
||||
:class="{ 'is-column-dragging': dragState?.id === row.id }"
|
||||
@dragover="onDragOver($event, row)"
|
||||
@drop="onDrop($event, row)"
|
||||
>
|
||||
<td class="batch-delete-cell">
|
||||
<BatchDeleteCheckbox :label="batch.reason(row) || `选择 ${batch.label(row)}`" :checked="batch.isSelected(row)"
|
||||
:disabled="batch.disabled || !!batch.reason(row)" @change="batch.toggle(row)" />
|
||||
</td>
|
||||
<td class="column-drag-cell">
|
||||
<span
|
||||
class="column-drag-handle"
|
||||
@@ -336,13 +271,12 @@ onMounted(loadMenus)
|
||||
<td><span class="menu-type-text">{{ menuTypeLabel(row.menuType) }}</span></td>
|
||||
<td>{{ parentNameOf(row) }}</td>
|
||||
<td>{{ formatDateTime(row.createdAt) }}</td>
|
||||
<td>{{ formatDateTime(row.updatedAt) }}</td>
|
||||
<td class="ops-cell">
|
||||
<button class="btn btn-sm" type="button" @click="openEdit(row)">编辑</button>
|
||||
<button
|
||||
class="btn btn-sm btn-danger"
|
||||
type="button"
|
||||
:disabled="batch.busy || menuDeleteReason(row) !== undefined"
|
||||
:disabled="menuDeleteReason(row) !== undefined"
|
||||
:title="menuDeleteReason(row) || undefined"
|
||||
@click="removeMenu(row)"
|
||||
>
|
||||
@@ -352,10 +286,10 @@ onMounted(loadMenus)
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-else-if="loading">
|
||||
<td colspan="9" class="empty-tip">加载中...</td>
|
||||
<td colspan="7" class="empty-tip">加载中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td colspan="9" class="empty-tip">{{ filterName || filterType ? '暂无匹配菜单' : '暂无菜单,请先在上方新增' }}</td>
|
||||
<td colspan="7" class="empty-tip">{{ filterName || filterType ? '暂无匹配菜单' : '暂无菜单,请先在上方新增' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -448,7 +382,8 @@ h3 {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input {
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
@@ -462,10 +397,12 @@ h3 {
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover {
|
||||
.form-group input:hover,
|
||||
.form-group select:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus {
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
@@ -592,7 +529,6 @@ tr.is-column-dragging td {
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
white-space: nowrap;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
|
||||
@@ -1,248 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { saveUserSecretModule } from '@/api/user-secrets'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { actionableErrorText } from '@/components/admin-feedback'
|
||||
import {
|
||||
PROXY_MODULE_KEY,
|
||||
buildProxyEntryPayload,
|
||||
emptyProxyEntryDraft,
|
||||
validateProxyEntry,
|
||||
type ProxyEntryDraft,
|
||||
} from './user-secret-model.ts'
|
||||
|
||||
/**
|
||||
* 后台代填/改代理(2026-11-02 脱敏后重做的交互)。
|
||||
*
|
||||
* 旧交互是 `window.prompt` 预填 `row.proxy.full` 整条提取链接——后端把这条读路套上
|
||||
* `SecretMasking.maskProxy` 之后 `full` 恒空,预填必然是空的,照旧保存等于把空串顶上去、
|
||||
* 或让管理员去别处翻原文。现在收**账密**、链接在本机现拼现发:
|
||||
* - 青果:填 Authkey + Authpwd,`composeQingguoLink` 拼(青果产品页没有可复制的链接);
|
||||
* - 极客:填极客自己的提取链接(它有可复制的链接)。
|
||||
* 拼好的链接是一次性写载荷,只进 PUT 请求体:不回显、不回填、不进 tooltip、不给复制/导出旁路;
|
||||
* 保存成功即清空输入位,重开必然要从头再填(这是脱敏的应然后果,界面直接把它说出来)。
|
||||
*/
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
userId: number | null
|
||||
username: string
|
||||
/** 后端已登记的供应商(只是预选中的单选框,不是凭据)。 */
|
||||
provider?: string | null
|
||||
locked?: boolean
|
||||
}>()
|
||||
const emit = defineEmits<{ (e: 'update:modelValue', v: boolean): void; (e: 'saved'): void }>()
|
||||
|
||||
const draft = reactive<ProxyEntryDraft>(emptyProxyEntryDraft())
|
||||
const errorText = ref('')
|
||||
const busy = ref(false)
|
||||
|
||||
function resetDraft() {
|
||||
Object.assign(draft, emptyProxyEntryDraft(props.provider))
|
||||
errorText.value = ''
|
||||
}
|
||||
|
||||
// 开与关都重刷:关的时候把已经打进内存的账密/链接抹掉,不留到下一次。
|
||||
watch(() => props.modelValue, resetDraft)
|
||||
|
||||
function close() {
|
||||
emit('update:modelValue', false)
|
||||
}
|
||||
|
||||
async function save() {
|
||||
if (props.userId == null) return
|
||||
errorText.value = validateProxyEntry(draft)
|
||||
if (errorText.value) return
|
||||
const payload = buildProxyEntryPayload(draft)
|
||||
if (!payload) {
|
||||
errorText.value = '代理配置不完整,请重新填写'
|
||||
return
|
||||
}
|
||||
busy.value = true
|
||||
try {
|
||||
await saveUserSecretModule(props.userId, PROXY_MODULE_KEY, payload.value, payload.channel)
|
||||
showAdminFeedback(props.locked ? '已更新锁定代理' : '已代填并锁定代理', 'success')
|
||||
emit('saved')
|
||||
close()
|
||||
} catch (error) {
|
||||
// 文案以接口返回的 message 为准,前端不解释后端状态码
|
||||
errorText.value = actionableErrorText(error)
|
||||
showAdminFeedback(errorText.value, 'error')
|
||||
} finally {
|
||||
busy.value = false
|
||||
Object.assign(draft, { authkey: '', authpwd: '', link: '' })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="modelValue" class="modal-mask" @click.self="close">
|
||||
<div class="modal" role="dialog" aria-modal="true" aria-labelledby="proxy-entry-title">
|
||||
<h3 id="proxy-entry-title">{{ locked ? '改代理' : '代填代理' }}</h3>
|
||||
<p class="modal-note">
|
||||
为「{{ username || '该用户' }}」写入代理。出于凭据保护,后台不再下发已存的提取链接原文,
|
||||
这里每次都重新填写;保存后界面只显示脱敏后的地址(不含 key/pwd)。
|
||||
</p>
|
||||
|
||||
<div class="form-group">
|
||||
<label>代理供应商</label>
|
||||
<div class="radio-row">
|
||||
<label class="radio-item">
|
||||
<input v-model="draft.provider" type="radio" value="qingguo" />
|
||||
<span>青果</span>
|
||||
</label>
|
||||
<label class="radio-item">
|
||||
<input v-model="draft.provider" type="radio" value="jikip" />
|
||||
<span>极客</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template v-if="draft.provider === 'qingguo'">
|
||||
<div class="form-group">
|
||||
<label>Authkey</label>
|
||||
<input v-model="draft.authkey" type="text" autocomplete="off" placeholder="青果产品页的 Authkey" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Authpwd</label>
|
||||
<input v-model="draft.authpwd" type="password" autocomplete="new-password" placeholder="青果产品页的 Authpwd" />
|
||||
<span class="field-hint">青果只填 Authkey 会被判鉴权拒绝,两把都要填。</span>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="form-group">
|
||||
<label>极客提取链接</label>
|
||||
<input
|
||||
v-model="draft.link"
|
||||
type="password"
|
||||
autocomplete="new-password"
|
||||
placeholder="https://api.jikip.com/ip-get?..."
|
||||
/>
|
||||
<span class="field-hint">极客有可复制的提取链接,整条粘贴进来即可。</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<p v-if="errorText" class="modal-error">{{ errorText }}</p>
|
||||
<div class="modal-actions">
|
||||
<button class="btn" type="button" :disabled="busy" @click="save">
|
||||
{{ busy ? '保存中…' : '保存' }}
|
||||
</button>
|
||||
<button class="btn btn-ghost" type="button" :disabled="busy" @click="close">取消</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 与密钥列表页同一视觉语言(本页不用 el-* 标签:新增 el-* 要同步改按需注册表)。 */
|
||||
.modal-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 3000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40px 20px;
|
||||
background: rgba(45, 66, 86, 0.36);
|
||||
backdrop-filter: blur(6px);
|
||||
}
|
||||
.modal {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: min(520px, 100%);
|
||||
max-height: 84vh;
|
||||
padding: 22px 24px;
|
||||
border: 1px solid #c7d7e5;
|
||||
border-radius: 14px;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 22px 60px rgba(39, 67, 94, 0.2);
|
||||
overflow-y: auto;
|
||||
color: #24384d;
|
||||
font-family: inherit;
|
||||
}
|
||||
.modal h3 {
|
||||
margin: 0 0 10px;
|
||||
font-size: 15px;
|
||||
font-weight: 650;
|
||||
}
|
||||
.modal-note {
|
||||
margin: 0 0 14px;
|
||||
color: #5b6f83;
|
||||
font-size: 12.5px;
|
||||
line-height: 1.65;
|
||||
}
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 7px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.form-group label {
|
||||
color: #5b6f83;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input[type='text'],
|
||||
.form-group input[type='password'] {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 9px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13.5px;
|
||||
font-family: inherit;
|
||||
outline: none;
|
||||
}
|
||||
.radio-row {
|
||||
display: flex;
|
||||
gap: 18px;
|
||||
}
|
||||
.radio-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 13.5px;
|
||||
font-weight: 500;
|
||||
color: #24384d;
|
||||
}
|
||||
.field-hint {
|
||||
color: #7d8fa1;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.modal-error {
|
||||
margin: 0 0 10px;
|
||||
color: #b04a5a;
|
||||
font-size: 12.5px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.modal-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 42px;
|
||||
padding: 9px 18px;
|
||||
border: 1px solid #4f78a5;
|
||||
border-radius: 9px;
|
||||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
||||
color: #ffffff;
|
||||
font-family: inherit;
|
||||
font-size: 13.5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.btn:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.55;
|
||||
}
|
||||
.btn-ghost {
|
||||
background: #ffffff;
|
||||
border-color: #c7d7e5;
|
||||
color: #4f78a5;
|
||||
}
|
||||
</style>
|
||||
@@ -1,12 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onMounted, ref, watch } from 'vue'
|
||||
import { filterMenuTreeNodesByPlatform } from '../../config/platform-scope.ts'
|
||||
import type { PlatformTabId } from '../../config/platform-scope.ts'
|
||||
import type { MenuOptionNode } from './user-menu-auth'
|
||||
import { compactDirectGrantIds, pruneCheckedIdsToTree } from './user-menu-auth'
|
||||
import { compactDirectGrantIds } from './user-menu-auth'
|
||||
import { fetchGrantableMenus } from './user-menu-auth-api'
|
||||
|
||||
const props = defineProps<{ checked?: number[]; companyId?: number | null; platform?: PlatformTabId }>()
|
||||
const props = defineProps<{ checked?: number[] }>()
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:checked', ids: number[]): void
|
||||
(e: 'load', ok: boolean): void
|
||||
@@ -19,16 +17,9 @@ const appTree = ref<{ setCheckedKeys(keys: unknown[]): void; getCheckedKeys(): u
|
||||
const data = ref<MenuOptionNode[]>([])
|
||||
const loaded = ref(false)
|
||||
|
||||
/**
|
||||
* 按平台过滤后的可见树(2026-11-17 用户口径「授权树也按平台收,选京东就去掉亚马逊的」):
|
||||
* 平台缺省按亚马逊(历史调用形状)。过滤算法与侧边栏同源(platform-scope 唯一出口),
|
||||
* 叶子按 menuKey 判定——京东侧=「京东数据库+双侧账号域三件+桌面端京东工具台三件」。
|
||||
*/
|
||||
const visibleData = computed(() => filterMenuTreeNodesByPlatform(data.value, props.platform ?? 'amazon'))
|
||||
|
||||
/** 两种一级分类…(与 API menuType 分区一致):后台(admin) / 桌面端(app)。 */
|
||||
const adminNodes = computed(() => visibleData.value.filter((node) => node.type === 'admin'))
|
||||
const appNodes = computed(() => visibleData.value.filter((node) => node.type === 'app'))
|
||||
const adminNodes = computed(() => data.value.filter((node) => node.type === 'admin'))
|
||||
const appNodes = computed(() => data.value.filter((node) => node.type === 'app'))
|
||||
|
||||
function applyChecked(): void {
|
||||
const ids = Array.isArray(props.checked) ? props.checked.filter((id) => typeof id === 'number' && id > 0) : []
|
||||
@@ -44,41 +35,25 @@ function onCheck(): void {
|
||||
const ids = [...collect(adminTree.value), ...collect(appTree.value)]
|
||||
// 父子联动模式(未启用严格勾选)下勾选父菜单会自动全选全部子菜单;
|
||||
// 提交前压缩为最小直接授权集:父级已勾选时后代不再重复提交(后端按“父级授权
|
||||
// 展开全部后代”判断权限,与旧 admin.html 勾父清后代语义一致),
|
||||
// 并剔除置灰的祖先分组(派生勾选,操作者无权授予)。
|
||||
// 压缩按「可见树」算:另一侧菜单不在树上,其历史勾选天然进不来。
|
||||
emit('update:checked', compactDirectGrantIds(ids, visibleData.value))
|
||||
// 展开全部后代”判断权限,与旧 admin.html 勾父清后代语义一致)。
|
||||
emit('update:checked', compactDirectGrantIds(ids, data.value))
|
||||
}
|
||||
|
||||
async function load(): Promise<void> {
|
||||
try {
|
||||
data.value = await fetchGrantableMenus(props.companyId)
|
||||
data.value = await fetchGrantableMenus()
|
||||
loaded.value = true
|
||||
emit('load', true)
|
||||
// el-tree 的 store 通过异步 watch 同步 props.data,setCheckedKeys 必须等树
|
||||
// 渲染完成后再应用已勾选 id,否则作用在空 store 上导致已授权不回显。
|
||||
await nextTick()
|
||||
applyChecked()
|
||||
// 首屏就把勾选集收敛进可见树:编辑一个混档账号(既有亚马逊又有京东授权)时,
|
||||
// 打开弹窗那一刻就该按当前平台剪掉另一侧,而不是等用户点一下树才剪。
|
||||
pruneChecked()
|
||||
} catch {
|
||||
loaded.value = false
|
||||
emit('load', false)
|
||||
}
|
||||
}
|
||||
|
||||
/** 平台切换/首屏后把勾选集收敛进可见树:被过滤掉的另一侧勾选不再随表单提交,
|
||||
* 否则「京东档账号保存后仍带亚马逊授权」会把平台分侧静默架空。集合没变就不发
|
||||
* update 事件(避免与父级 v-model 循环互刷)。 */
|
||||
function pruneChecked(): void {
|
||||
const pruned = pruneCheckedIdsToTree(props.checked, visibleData.value)
|
||||
const current = Array.isArray(props.checked) ? props.checked : []
|
||||
if (pruned.length !== current.length || pruned.some((id, index) => id !== current[index])) {
|
||||
emit('update:checked', pruned)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
watch(
|
||||
() => props.checked,
|
||||
@@ -86,22 +61,6 @@ watch(
|
||||
if (loaded.value) applyChecked()
|
||||
},
|
||||
)
|
||||
/** 平台翻档:可见树整棵换,勾选集同步收敛到新树并回显(被剪掉的勾选以 emit 形式
|
||||
* 落回表单,父级拿到的是纯当前平台的授权集)。 */
|
||||
watch(
|
||||
() => props.platform,
|
||||
() => {
|
||||
if (!loaded.value) return
|
||||
pruneChecked()
|
||||
void nextTick().then(applyChecked)
|
||||
},
|
||||
)
|
||||
/** 公司换了要整棵重取:勾选集里存的是 column id,别家同名菜单是另一份 id(V149 每公司一套树),
|
||||
* 拿别家的树勾出来的 id 提交会被后端判「无效的菜单权限项」,而已授权项也因为 id 不在这棵树上勾不上。 */
|
||||
watch(
|
||||
() => props.companyId,
|
||||
() => { void load() },
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -118,7 +77,7 @@ watch(
|
||||
node-key="id"
|
||||
show-checkbox
|
||||
default-expand-all
|
||||
:props="{ label: 'name', children: 'children', disabled: 'disabled' }"
|
||||
:props="{ label: 'name', children: 'children' }"
|
||||
@check="onCheck"
|
||||
/>
|
||||
</div>
|
||||
@@ -130,7 +89,7 @@ watch(
|
||||
node-key="id"
|
||||
show-checkbox
|
||||
default-expand-all
|
||||
:props="{ label: 'name', children: 'children', disabled: 'disabled' }"
|
||||
:props="{ label: 'name', children: 'children' }"
|
||||
@check="onCheck"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,428 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { orderedPair, todayDateInput } from '@/utils/datetime'
|
||||
import {
|
||||
fetchUserSecretUsage,
|
||||
type AdminUserSecretUsageRow,
|
||||
} from '@/api/user-secret-usage'
|
||||
import type { GroupOption } from '@/api/user-secrets'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { usePlatformTabStore } from '@/stores/platform-tab'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||||
|
||||
const session = useAdminSessionStore()
|
||||
const companyTab = useCompanyTabStore()
|
||||
const platformTab = usePlatformTabStore()
|
||||
/** 仅超管需要分组维度:非超管数据由后端裁剪到本人分组,分组筛选/列一律不展示。 */
|
||||
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
||||
|
||||
const loading = ref(false)
|
||||
const loadFailure = ref('')
|
||||
const rows = ref<AdminUserSecretUsageRow[]>([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(15)
|
||||
const keyword = ref('')
|
||||
const startDate = ref(todayDateInput())
|
||||
const endDate = ref(todayDateInput())
|
||||
/** min/max 挡不住手输,落值后把倒挂的起止交换回来。 */
|
||||
function clampDatePair(): void {
|
||||
const [s, e] = orderedPair(startDate.value, endDate.value)
|
||||
startDate.value = s
|
||||
endDate.value = e
|
||||
}
|
||||
|
||||
const groupFilter = ref<number | null>(null)
|
||||
const groupOptions = ref<GroupOption[]>([])
|
||||
|
||||
/** 所选范围内三类总次数(后端按筛选条件统计,不分页)。 */
|
||||
const summary = ref({ totalCalls: 0, similarAsinCalls: 0, appearancePatentCalls: 0, proxyCalls: 0 })
|
||||
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||
|
||||
function formatCount(value: number | undefined) {
|
||||
const num = Number(value || 0)
|
||||
return num.toLocaleString('zh-CN')
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
loadFailure.value = ''
|
||||
try {
|
||||
const result = await fetchUserSecretUsage({
|
||||
startDate: startDate.value || undefined,
|
||||
endDate: endDate.value || undefined,
|
||||
keyword: keyword.value.trim() || undefined,
|
||||
groupId: groupFilter.value || undefined,
|
||||
companyId: companyTab.requestCompanyId,
|
||||
// 平台 tab(2026-11-22)与公司同形状:由上方 tab 决定而不是用户填的筛选项,每次现取。
|
||||
platform: platformTab.active,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
})
|
||||
rows.value = result?.items || []
|
||||
total.value = Number(result?.total || 0)
|
||||
groupOptions.value = result?.groupOptions || []
|
||||
summary.value = {
|
||||
totalCalls: Number(result?.totalCalls || 0),
|
||||
similarAsinCalls: Number(result?.similarAsinCalls || 0),
|
||||
appearancePatentCalls: Number(result?.appearancePatentCalls || 0),
|
||||
proxyCalls: Number(result?.proxyCalls || 0),
|
||||
}
|
||||
} catch (error) {
|
||||
loadFailure.value = error instanceof Error ? error.message : '加载失败'
|
||||
showAdminFeedback(loadFailure.value, 'error')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 切公司 = 重新取数。不重取的页 = tab 在那页上是假的(G1 的 pageFiles 断言盯着这条)。
|
||||
watch(() => companyTab.activeId, () => void load())
|
||||
|
||||
// 切平台 tab(2026-11-22 密钥两页进京东侧)= 同 UsersPage 的重取数:汇总卡/列表都按平台过滤,
|
||||
// 关键字/翻页跨平台无意义,一并清掉。
|
||||
watch(() => platformTab.active, () => {
|
||||
keyword.value = ''
|
||||
page.value = 1
|
||||
void load()
|
||||
})
|
||||
|
||||
function search() {
|
||||
page.value = 1
|
||||
load()
|
||||
}
|
||||
|
||||
function reset() {
|
||||
keyword.value = ''
|
||||
startDate.value = todayDateInput()
|
||||
endDate.value = todayDateInput()
|
||||
groupFilter.value = null
|
||||
page.value = 1
|
||||
load()
|
||||
}
|
||||
|
||||
function changePage(next: number) {
|
||||
if (next < 1 || next > totalPages.value) return
|
||||
page.value = next
|
||||
load()
|
||||
}
|
||||
|
||||
function changeSize(size: number) {
|
||||
pageSize.value = size
|
||||
page.value = 1
|
||||
load()
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="secret-usage-view">
|
||||
<section class="panel-box">
|
||||
<div class="usage-head">
|
||||
<h3>密钥用量统计</h3>
|
||||
<span class="usage-note">口径:真实对外请求次数(LLM 每次请求、代理每次成功提取)</span>
|
||||
</div>
|
||||
|
||||
<div class="summary-row">
|
||||
<div class="summary-card">
|
||||
<div class="summary-label">总调用次数</div>
|
||||
<div class="summary-value">{{ formatCount(summary.totalCalls) }}</div>
|
||||
</div>
|
||||
<div class="summary-card">
|
||||
<div class="summary-label">货源查询密钥</div>
|
||||
<div class="summary-value">{{ formatCount(summary.similarAsinCalls) }}</div>
|
||||
</div>
|
||||
<div class="summary-card">
|
||||
<div class="summary-label">外观专利密钥</div>
|
||||
<div class="summary-value">{{ formatCount(summary.appearancePatentCalls) }}</div>
|
||||
</div>
|
||||
<div class="summary-card">
|
||||
<div class="summary-label">代理提取</div>
|
||||
<div class="summary-value">{{ formatCount(summary.proxyCalls) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row usage-filter-row">
|
||||
<div class="form-group" style="min-width: 160px">
|
||||
<label>开始日期</label>
|
||||
<input v-model="startDate" type="date" :max="endDate" @change="clampDatePair" />
|
||||
</div>
|
||||
<div class="form-group" style="min-width: 160px">
|
||||
<label>结束日期</label>
|
||||
<input v-model="endDate" type="date" :min="startDate" @change="clampDatePair" />
|
||||
</div>
|
||||
<div class="form-group" style="min-width: 200px">
|
||||
<label>用户名</label>
|
||||
<input v-model="keyword" type="text" placeholder="模糊搜索用户名" @keyup.enter="search" />
|
||||
</div>
|
||||
<div class="form-group" v-if="isSuperAdmin && groupOptions.length" style="min-width: 170px">
|
||||
<label>分组</label>
|
||||
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 的弹层是浏览器直角原生物
|
||||
⇒ 换 el-select(admin-filter 同壳 42px/9px 圆角,弹层是 EP 圆角面板),组多时可搜。
|
||||
「全部分组」的值仍是 null(下游 groupId 照旧 `|| undefined`),空档时由
|
||||
placeholder 显示同一句文案。 -->
|
||||
<el-select v-model="groupFilter" class="admin-filter" filterable placeholder="全部分组" aria-label="筛选分组">
|
||||
<el-option label="全部分组" :value="null" />
|
||||
<el-option v-for="group in groupOptions" :key="group.id" :label="group.groupName" :value="group.id" />
|
||||
</el-select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label> </label>
|
||||
<div class="filter-actions">
|
||||
<button class="btn" type="button" @click="search">查询</button>
|
||||
<button class="btn btn-ghost" type="button" @click="reset">重置</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<div class="usage-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 58px">序号</th>
|
||||
<th style="width: 220px">用户</th>
|
||||
<th v-if="isSuperAdmin" style="width: 130px">分组</th>
|
||||
<th style="width: 170px">货源查询密钥</th>
|
||||
<th style="width: 170px">外观专利密钥</th>
|
||||
<th style="width: 150px">代理提取</th>
|
||||
<th style="width: 130px">合计</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-if="rows.length">
|
||||
<tr v-for="(row, index) in rows" :key="row.userId">
|
||||
<td>{{ (page - 1) * pageSize + index + 1 }}</td>
|
||||
<td>
|
||||
<span class="user-name">{{ row.username || `UID ${row.userId}` }}</span>
|
||||
</td>
|
||||
<td v-if="isSuperAdmin">
|
||||
<span class="group-name">{{ row.groups?.length ? row.groups.join('、') : '—' }}</span>
|
||||
</td>
|
||||
<td><span class="count-value">{{ formatCount(row.similarAsinCount) }}</span></td>
|
||||
<td><span class="count-value">{{ formatCount(row.appearancePatentCount) }}</span></td>
|
||||
<td><span class="count-value">{{ formatCount(row.proxyCount) }}</span></td>
|
||||
<td><span class="count-value count-total">{{ formatCount(row.totalCount) }}</span></td>
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-else-if="loading">
|
||||
<td :colspan="isSuperAdmin ? 7 : 6" class="empty-tip">加载中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td :colspan="isSuperAdmin ? 7 : 6" class="empty-tip">
|
||||
{{ keyword || groupFilter ? '暂无匹配记录' : '暂无用量记录' }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<OldPagination :total="total" :page="page" :page-size="pageSize" @change="changePage" @size-change="changeSize" />
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 与密钥管理页保持同一视觉语言(像素复刻后台面板风格)。 */
|
||||
.secret-usage-view {
|
||||
font-family: inherit;
|
||||
color: #24384d;
|
||||
}
|
||||
.panel-box {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 20px 22px 24px;
|
||||
border: 1px solid #d8e3ee;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(145deg, #ffffff, #f9fbfd);
|
||||
box-shadow: 0 1px 2px rgba(39, 67, 94, 0.04), 0 14px 30px -24px rgba(39, 67, 94, 0.28);
|
||||
}
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 650;
|
||||
color: #24384d;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
.usage-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.usage-note {
|
||||
color: #7d8fa2;
|
||||
font-size: 12px;
|
||||
}
|
||||
.summary-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.summary-card {
|
||||
flex: 1 1 160px;
|
||||
min-width: 150px;
|
||||
padding: 12px 16px;
|
||||
border: 1px solid #dbe5ee;
|
||||
border-radius: 10px;
|
||||
background: #f7fafd;
|
||||
}
|
||||
.summary-label {
|
||||
color: #5b6f83;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.summary-value {
|
||||
margin-top: 6px;
|
||||
color: #2f5d8b;
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.usage-filter-row {
|
||||
margin: 0 0 16px;
|
||||
}
|
||||
.form-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
gap: 14px 18px;
|
||||
}
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 7px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.form-group label {
|
||||
color: #5b6f83;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 9px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13.5px;
|
||||
font-family: inherit;
|
||||
color-scheme: light;
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
}
|
||||
.filter-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
min-height: 42px;
|
||||
padding: 9px 18px;
|
||||
border: 1px solid #4f78a5;
|
||||
border-radius: 9px;
|
||||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
||||
color: #ffffff;
|
||||
font-family: inherit;
|
||||
font-size: 13.5px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 8px 18px -14px rgba(79, 120, 165, 0.72);
|
||||
transition: background 160ms ease, box-shadow 160ms ease, transform 120ms ease;
|
||||
}
|
||||
.btn:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #7094ba, #5d83ac);
|
||||
}
|
||||
.btn-ghost {
|
||||
background: #ffffff;
|
||||
border-color: #c7d7e5;
|
||||
color: #4f78a5;
|
||||
box-shadow: none;
|
||||
}
|
||||
.btn-ghost:hover:not(:disabled) {
|
||||
background: #edf5fb;
|
||||
border-color: #95b1cb;
|
||||
color: #2f5d8b;
|
||||
}
|
||||
.usage-table-scroll {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
overflow-x: auto;
|
||||
border: 1px solid #dbe5ee;
|
||||
border-radius: 10px;
|
||||
background: #ffffff;
|
||||
}
|
||||
.usage-table-scroll table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
table-layout: fixed;
|
||||
min-width: 1020px;
|
||||
}
|
||||
.usage-table-scroll th,
|
||||
.usage-table-scroll td {
|
||||
padding: 10px 12px;
|
||||
text-align: left;
|
||||
font-size: 13.5px;
|
||||
line-height: 1.5;
|
||||
border-bottom: 1px solid #e0e8ef;
|
||||
vertical-align: middle;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.usage-table-scroll th {
|
||||
background: #edf4fa;
|
||||
color: #4e6479;
|
||||
border-bottom-color: #d5e1eb;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.4px;
|
||||
}
|
||||
.usage-table-scroll tbody tr:hover td {
|
||||
background: #f1f7fb;
|
||||
}
|
||||
.usage-table-scroll tbody tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.user-name {
|
||||
color: #24384d;
|
||||
font-weight: 600;
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.group-name {
|
||||
color: #5b6f83;
|
||||
font-size: 12.5px;
|
||||
}
|
||||
.count-value {
|
||||
color: #2f5d8b;
|
||||
font-variant-numeric: tabular-nums;
|
||||
font-size: 13.5px;
|
||||
}
|
||||
.count-total {
|
||||
font-weight: 700;
|
||||
}
|
||||
.empty-tip {
|
||||
color: #8293a5;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
@@ -1,274 +0,0 @@
|
||||
/* 像素复刻旧版 admin.html 面板风格(与店铺密钥页同一视觉语言)。 */
|
||||
.user-secrets-view {
|
||||
font-family: inherit;
|
||||
color: #24384d;
|
||||
}
|
||||
.panel-box {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 20px 22px 24px;
|
||||
border: 1px solid #d8e3ee;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(145deg, #ffffff, #f9fbfd);
|
||||
box-shadow: 0 1px 2px rgba(39, 67, 94, 0.04), 0 14px 30px -24px rgba(39, 67, 94, 0.28);
|
||||
}
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 650;
|
||||
color: #24384d;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
.secrets-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.secrets-filter-row {
|
||||
margin: 0 0 16px;
|
||||
}
|
||||
.form-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
gap: 14px 18px;
|
||||
}
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 7px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.form-group label {
|
||||
color: #5b6f83;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 9px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13.5px;
|
||||
font-family: inherit;
|
||||
color-scheme: light;
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
}
|
||||
.filter-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
min-height: 42px;
|
||||
padding: 9px 18px;
|
||||
border: 1px solid #4f78a5;
|
||||
border-radius: 9px;
|
||||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
||||
color: #ffffff;
|
||||
font-family: inherit;
|
||||
font-size: 13.5px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 8px 18px -14px rgba(79, 120, 165, 0.72);
|
||||
transition: background 160ms ease, box-shadow 160ms ease, transform 120ms ease;
|
||||
}
|
||||
.btn:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #7094ba, #5d83ac);
|
||||
box-shadow: 0 11px 22px -14px rgba(79, 120, 165, 0.8);
|
||||
}
|
||||
.btn:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.55;
|
||||
}
|
||||
.btn-danger {
|
||||
background: linear-gradient(135deg, #c06d77, #b35f6a);
|
||||
border-color: #b35f6a;
|
||||
}
|
||||
.btn-danger:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #cb7c84, #b96570);
|
||||
}
|
||||
.btn-ghost {
|
||||
background: #ffffff;
|
||||
border-color: #c7d7e5;
|
||||
color: #4f78a5;
|
||||
box-shadow: none;
|
||||
}
|
||||
.btn-ghost:hover:not(:disabled) {
|
||||
background: #edf5fb;
|
||||
border-color: #95b1cb;
|
||||
color: #2f5d8b;
|
||||
}
|
||||
.btn-sm {
|
||||
min-height: 36px;
|
||||
padding: 7px 12px;
|
||||
}
|
||||
.secrets-table-scroll {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
overflow-x: auto;
|
||||
border: 1px solid #dbe5ee;
|
||||
border-radius: 10px;
|
||||
background: #ffffff;
|
||||
}
|
||||
.secrets-table-scroll table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
table-layout: fixed;
|
||||
min-width: 1440px;
|
||||
}
|
||||
.secrets-table-scroll th,
|
||||
.secrets-table-scroll td {
|
||||
padding: 10px 12px;
|
||||
text-align: left;
|
||||
font-size: 13.5px;
|
||||
line-height: 1.5;
|
||||
border-bottom: 1px solid #e0e8ef;
|
||||
vertical-align: middle;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.secrets-table-scroll th {
|
||||
background: #edf4fa;
|
||||
color: #4e6479;
|
||||
border-bottom-color: #d5e1eb;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.4px;
|
||||
}
|
||||
.secrets-table-scroll tbody tr:hover td {
|
||||
background: #f1f7fb;
|
||||
}
|
||||
.secrets-table-scroll tbody tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.user-name {
|
||||
color: #24384d;
|
||||
font-weight: 600;
|
||||
/* 用户名(含中文)可完整换行展示,不截断 */
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.creator-name {
|
||||
color: #5b6f83;
|
||||
font-size: 12.5px;
|
||||
}
|
||||
.module-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
/* 代理列:脱敏地址独占一行,状态药丸另起一行(列宽按最长药丸文案留的,不按整条链接) */
|
||||
.module-cell--stack {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 6px;
|
||||
}
|
||||
.module-cell .mono-mask {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
/* 代理列只显示后端脱敏后的 scheme://host(短串,单行足够)。
|
||||
这里**不许**再出现"允许折行展示完整明文 + user-select:all"那套样式:
|
||||
它等于给整条带 key/pwd 的链接做了一键全选复制的旁路(2026-11-02 脱敏收口时一并拆掉)。 */
|
||||
.mono-mask {
|
||||
font-family: Consolas, "Cascadia Mono", monospace;
|
||||
font-size: 12.5px;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
.empty-value {
|
||||
color: #a7b4c1;
|
||||
}
|
||||
/* 余额列:数字按等宽数位对齐(两行叠着看差值才不用竖着对),超长进 title。 */
|
||||
.balance-line {
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-variant-numeric: tabular-nums;
|
||||
font-size: 12.5px;
|
||||
color: #2f4256;
|
||||
}
|
||||
.ops-cell {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.empty-tip {
|
||||
color: #8293a5;
|
||||
text-align: center;
|
||||
}
|
||||
.wh-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 2px 10px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid;
|
||||
font-size: 12px;
|
||||
line-height: 1.7;
|
||||
cursor: help;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.wh-pill.is-source {
|
||||
background: #eef2fb;
|
||||
border-color: #ccd8f2;
|
||||
color: #3d5a99;
|
||||
font-weight: 600;
|
||||
}
|
||||
.wh-pill.is-allowed {
|
||||
background: #e8f6ee;
|
||||
border-color: #b9e0c9;
|
||||
color: #2f7d52;
|
||||
}
|
||||
.wh-pill.is-blocked {
|
||||
background: #fdecef;
|
||||
border-color: #f2c4cd;
|
||||
color: #b04a5a;
|
||||
}
|
||||
.wh-pill.is-warn {
|
||||
background: #fdf6e3;
|
||||
border-color: #f0dfae;
|
||||
color: #8f6d1e;
|
||||
}
|
||||
/* 「等一会再点」这一族(无可用通道/限流/超时/网络/上游):既不红(密钥没坏)
|
||||
也不黄(不是欠费)更不是灰(不是查不出),独立一档青色——三种处置一眼分开。 */
|
||||
.wh-pill.is-retry {
|
||||
background: #e6f2f7;
|
||||
border-color: #b6d8e6;
|
||||
color: #2b6b86;
|
||||
}
|
||||
.wh-pill.is-unknown {
|
||||
background: #f0f3f6;
|
||||
border-color: #d6dee6;
|
||||
color: #6b7d8f;
|
||||
}
|
||||
.wh-pill.is-locked {
|
||||
background: #f0ecfb;
|
||||
border-color: #d5caf0;
|
||||
color: #5b4a96;
|
||||
}
|
||||
.module-cell-pills {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
@@ -1,73 +1,25 @@
|
||||
<script setup lang="ts">
|
||||
import BatchDeleteActions from '@/components/BatchDeleteActions.vue'
|
||||
import BatchDeleteCheckbox from '@/components/BatchDeleteCheckbox.vue'
|
||||
import { useRowSelection } from '@/utils/use-row-selection'
|
||||
import { createLatestRequestGate } from '@/utils/latest-request'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import ProxyEntryDialog from './ProxyEntryDialog.vue'
|
||||
import {
|
||||
checkUserSecret,
|
||||
clearUserSecretModule,
|
||||
deleteUserSecret,
|
||||
fetchAdminSecretBalances,
|
||||
fetchUserSecretList,
|
||||
type AdminUserSecretBalanceItem,
|
||||
type AdminUserSecretModule,
|
||||
type AdminUserSecretRow,
|
||||
type GroupOption,
|
||||
} from '@/api/user-secrets'
|
||||
import {
|
||||
PROXY_MODULE_KEY,
|
||||
llmBalanceLines,
|
||||
llmSourceLabel,
|
||||
moduleStatusBand,
|
||||
proxyBalanceLine,
|
||||
proxyDisplayText,
|
||||
proxySourceLabel,
|
||||
rowDetailLines,
|
||||
rowStatusBand,
|
||||
} from './user-secret-model.ts'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { usePlatformTabStore } from '@/stores/platform-tab'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||||
|
||||
const session = useAdminSessionStore()
|
||||
const companyTab = useCompanyTabStore()
|
||||
const platformTab = usePlatformTabStore()
|
||||
/** 仅超管需要分组维度:非超管数据由后端裁剪到本人分组,分组筛选/列一律不展示。 */
|
||||
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
||||
|
||||
const loading = ref(false)
|
||||
const loadFailure = ref('')
|
||||
const rows = ref<AdminUserSecretRow[]>([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(15)
|
||||
const keyword = ref('')
|
||||
const statusFilter = ref('')
|
||||
const groupFilter = ref<number | null>(null)
|
||||
/** 分组下拉(超管=全部;主管=自己带的分组,由列表接口带回)。 */
|
||||
const groupOptions = ref<GroupOption[]>([])
|
||||
/** 正在检测的行 userId,用于按钮 loading 态。 */
|
||||
const checkingId = ref<number | null>(null)
|
||||
/** 正在解锁代理的行 userId,避免重复点击(代填在弹窗里自己管 busy)。 */
|
||||
const proxyBusyId = ref<number | null>(null)
|
||||
/** 代填/改代理弹窗的目标行(脱敏后没有原文可预填,只能重填账密)。 */
|
||||
const proxyDialog = ref<{ userId: number; username: string; provider: string | null; locked: boolean } | null>(null)
|
||||
|
||||
/** 余额侧写(实时查上游、不落库):按 userId 存,列表接口本身不带这些数。 */
|
||||
const balances = ref<Record<number, AdminUserSecretBalanceItem>>({})
|
||||
const balanceLoading = ref(false)
|
||||
/** 本轮「没取到」的原因(越权剔除/上游未应答/请求失败):进工具行悬停,不弹全局打扰。 */
|
||||
const balanceNotice = ref('')
|
||||
/** 服务端单次上限 20 个用户;超出会被当场拒,所以这里按批顺取(并发留给服务端那个线程池)。 */
|
||||
const BALANCE_BATCH = 20
|
||||
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||
|
||||
@@ -76,157 +28,78 @@ const STATUS_OPTIONS = [
|
||||
{ value: 'passed', label: '检测通过' },
|
||||
{ value: 'failed', label: '检测失败' },
|
||||
{ value: 'incomplete', label: '未配齐' },
|
||||
// 后端的行级值仍是 error:这一档现在既可能是「问不出结论」,也可能是「通道还没释放、等一会再点」,
|
||||
// 界面按码把后者补成「可重试」(见 user-secret-model.ts 的档位表),筛选项就得把两档都点名。
|
||||
{ value: 'error', label: '无法判定/可重试' },
|
||||
{ value: 'error', label: '无法判定' },
|
||||
{ value: 'unknown', label: '未检测' },
|
||||
]
|
||||
|
||||
/* 状态药丸的档位表在 `user-secret-model.ts`(唯一出处,页面不带第二张表):
|
||||
行级传整行而不是 `row.status`——后端把 failed/incomplete 都判掉之后就只剩一个「error」,
|
||||
这一行到底是「查不出」还是「等青果释放」只有逐格的 `check_code` 说得清。 */
|
||||
/** 行级状态药丸:三类都检测通过才显示「检测通过」。 */
|
||||
function rowStatusMeta(status: string) {
|
||||
switch (status) {
|
||||
case 'passed':
|
||||
return { label: '检测通过', tone: 'is-allowed' }
|
||||
case 'failed':
|
||||
return { label: '检测失败', tone: 'is-blocked' }
|
||||
case 'incomplete':
|
||||
return { label: '未配齐', tone: 'is-warn' }
|
||||
case 'error':
|
||||
return { label: '无法判定', tone: 'is-warn' }
|
||||
default:
|
||||
return { label: '未检测', tone: 'is-unknown' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单格悬停详情:后端下发的**脱敏值** + 锁定说明 + **检测结果原文 `check_message`** + 检测时间 + 耗时。
|
||||
* 运维要判「是欠费还是被自己的采集占着」,靠的就是这句后端原文——档名只是扫一眼用的短词,
|
||||
* 前端一律不按码自己拼句子。
|
||||
* ⚠ 只读 `masked`:`full` 在后台侧恒空(2026-11-02 `SecretMasking.maskProxy` 收口),
|
||||
* 这里不做任何「masked 空就回落原文」的兜底,也不给复制整条链接的旁路。
|
||||
*/
|
||||
/** 单格状态药丸:未配置时统一灰色。 */
|
||||
function moduleStatusMeta(module: AdminUserSecretModule | undefined) {
|
||||
if (!module || !module.exists) {
|
||||
return { label: '未配置', tone: 'is-unknown' }
|
||||
}
|
||||
switch (module.checkStatus) {
|
||||
case 'passed':
|
||||
return { label: '通过', tone: 'is-allowed' }
|
||||
case 'failed':
|
||||
return { label: '失败', tone: 'is-blocked' }
|
||||
case 'error':
|
||||
return { label: '无法判定', tone: 'is-warn' }
|
||||
default:
|
||||
return { label: '未检测', tone: 'is-unknown' }
|
||||
}
|
||||
}
|
||||
|
||||
/** 单格悬停详情:检测消息 + 检测时间 + 耗时。 */
|
||||
function moduleTooltip(module: AdminUserSecretModule | undefined) {
|
||||
if (!module || !module.exists) return '未配置'
|
||||
const parts: string[] = []
|
||||
const display = String(module.masked || '').trim()
|
||||
if (display) {
|
||||
parts.push(isProxyModule(module) ? `代理地址(已脱敏,不含 key/pwd):${display}` : `密钥:${display}`)
|
||||
}
|
||||
if (module.locked) parts.push('已由后台代填并锁定:客户端不可修改或清空,改代理需重新填写账密')
|
||||
// 后端的这句话就是给人看的结论,原样透出(不动一个字、不按码另拼一句)
|
||||
const message = String(module.checkMessage || '').trim()
|
||||
if (message) parts.push(message)
|
||||
if (module.checkMessage) parts.push(module.checkMessage)
|
||||
if (module.checkedAt) parts.push(`检测时间:${formatDateTime(module.checkedAt)}`)
|
||||
if (module.checkLatencyMs != null) parts.push(`耗时:${module.checkLatencyMs}ms`)
|
||||
return parts.join(';') || '暂无检测记录'
|
||||
}
|
||||
|
||||
/** 该格是不是代理模块:按后端下发的 moduleKey 判,货源标签与文案都走这一条口径。 */
|
||||
function isProxyModule(module: AdminUserSecretModule) {
|
||||
return String(module.moduleKey || '').trim().toLowerCase() === PROXY_MODULE_KEY
|
||||
}
|
||||
|
||||
/** 分组列文案:优先分组名;未建分组的用户回退展示所属主管,便于判断归属。 */
|
||||
function groupTextOf(row: AdminUserSecretRow) {
|
||||
if (row.groups?.length) return row.groups.join('、')
|
||||
if (row.leaderUsername) return `${row.leaderUsername}(未建分组)`
|
||||
return '—'
|
||||
}
|
||||
|
||||
/**
|
||||
* 行级悬停详情:后端的行级摘要 + 逐格的 `check_message` 原文 + 更新时间。
|
||||
* 行级状态一旦补成「可重试」,管理员得能立刻看出是哪一格在等、后端原话怎么说;
|
||||
* 逐格那句一律取后端下发文本(`rowDetailLines` 只搬运、不改写、不另拼一句)。
|
||||
*/
|
||||
function rowStatusTooltip(row: AdminUserSecretRow) {
|
||||
const parts: string[] = []
|
||||
if (row.statusMessage) parts.push(row.statusMessage)
|
||||
parts.push(...rowDetailLines(row))
|
||||
if (row.updatedAt) parts.push(`最近更新:${formatDateTime(row.updatedAt)}`)
|
||||
return parts.join(';') || '暂无检测记录'
|
||||
}
|
||||
|
||||
const batchListGate = createLatestRequestGate()
|
||||
|
||||
async function load() {
|
||||
const token = batchListGate.begin()
|
||||
loading.value = true
|
||||
loadFailure.value = ''
|
||||
try {
|
||||
const result = await fetchUserSecretList({
|
||||
keyword: keyword.value.trim() || undefined,
|
||||
checkStatus: statusFilter.value || undefined,
|
||||
groupId: groupFilter.value || undefined,
|
||||
companyId: companyTab.requestCompanyId,
|
||||
// 平台 tab(2026-11-22)与公司同形状:由上方 tab 决定而不是用户填的筛选项,每次现取。
|
||||
platform: platformTab.active,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
})
|
||||
if (!batchListGate.isCurrent(token)) return
|
||||
rows.value = result?.items || []
|
||||
total.value = Number(result?.total || 0)
|
||||
groupOptions.value = result?.groupOptions || []
|
||||
void loadBalances()
|
||||
} catch (error) {
|
||||
if (!batchListGate.isCurrent(token)) return
|
||||
loadFailure.value = error instanceof Error ? error.message : '加载失败'
|
||||
showAdminFeedback(loadFailure.value, 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '加载失败')
|
||||
} finally {
|
||||
if (batchListGate.isCurrent(token)) loading.value = false
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取本页用户的余额:列表已经画完,这两列随后填(余额要实时打上游,不能让它在列表主数据前占位)。
|
||||
*
|
||||
* 失败只影响这两列并留一句说明——不 `showAdminFeedback`、不把整页判成加载失败:
|
||||
* 一次上游抖动就红整页,管理员会以为密钥数据本身出了问题。
|
||||
*/
|
||||
async function loadBalances() {
|
||||
const ids = rows.value.map((row) => row.userId)
|
||||
balances.value = {}
|
||||
balanceNotice.value = ''
|
||||
if (!ids.length) return
|
||||
balanceLoading.value = true
|
||||
try {
|
||||
const merged: Record<number, AdminUserSecretBalanceItem> = {}
|
||||
let denied = 0
|
||||
let timedOut = 0
|
||||
for (let start = 0; start < ids.length; start += BALANCE_BATCH) {
|
||||
const batch = ids.slice(start, start + BALANCE_BATCH)
|
||||
const result = await fetchAdminSecretBalances(batch, companyTab.requestCompanyId)
|
||||
for (const item of result?.items || []) {
|
||||
if (item && item.userId != null) merged[Number(item.userId)] = item
|
||||
}
|
||||
denied += result?.deniedUserIds?.length || 0
|
||||
timedOut += result?.timedOutUserIds?.length || 0
|
||||
}
|
||||
balances.value = merged
|
||||
const notices: string[] = []
|
||||
if (denied) notices.push(`${denied} 个用户不在当前数据权限内,本轮未查`)
|
||||
if (timedOut) notices.push(`${timedOut} 个用户本轮上游未应答(不是余额为 0)`)
|
||||
balanceNotice.value = notices.join(';')
|
||||
} catch (error) {
|
||||
balanceNotice.value = error instanceof Error ? error.message : '余额本轮没取到(不是余额为 0)'
|
||||
} finally {
|
||||
balanceLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 某行的 LLM 余额行(按渠道折叠);没取到时给一格占位而不是空白。 */
|
||||
function llmLinesOf(userId: number) {
|
||||
const lines = llmBalanceLines(balances.value[userId]?.llm, balanceLoading.value)
|
||||
return lines.length ? lines : [{ text: '—', title: balanceNotice.value || '本轮没取到数(不是余额为 0)' }]
|
||||
}
|
||||
|
||||
function proxyLineOf(userId: number) {
|
||||
const item = balances.value[userId]
|
||||
if (item?.proxy) return proxyBalanceLine(item.proxy, false)
|
||||
return balanceLoading.value
|
||||
? { text: '查询中…', title: '余额按实时查询,不落库' }
|
||||
: { text: '—', title: balanceNotice.value || '本轮没取到数(不是余量为 0)' }
|
||||
}
|
||||
|
||||
// 切公司 = 重新取数。不重取的页 = tab 在那页上是假的(G1 的 pageFiles 断言盯着这条)。
|
||||
watch(() => companyTab.activeId, () => void load())
|
||||
|
||||
// 切平台 tab(2026-11-22 密钥两页进京东侧)= 同 UsersPage 的重取数:列表按平台过滤,
|
||||
// 关键字/翻页跨平台无意义,一并清掉。
|
||||
watch(() => platformTab.active, () => {
|
||||
keyword.value = ''
|
||||
page.value = 1
|
||||
void load()
|
||||
})
|
||||
|
||||
function search() {
|
||||
page.value = 1
|
||||
load()
|
||||
@@ -235,7 +108,6 @@ function search() {
|
||||
function reset() {
|
||||
keyword.value = ''
|
||||
statusFilter.value = ''
|
||||
groupFilter.value = null
|
||||
page.value = 1
|
||||
load()
|
||||
}
|
||||
@@ -253,80 +125,28 @@ async function check(row: AdminUserSecretRow) {
|
||||
if (failed.length) {
|
||||
ElMessage.warning(failed[0].checkMessage || '存在检测失败项')
|
||||
} else if (errors.length) {
|
||||
// 后端这句话会区分「通道被你自己占着,等约 3 分钟」与「真的问不出结论」;
|
||||
// 硬写「无法判定」等于把可重试那一族又抹回一坨(现网 uid=1 就是这个形状)。
|
||||
ElMessage.warning(errors[0].checkMessage || '部分配置本次无法判定')
|
||||
ElMessage.warning('部分配置本次无法判定')
|
||||
} else {
|
||||
ElMessage.success('检测通过')
|
||||
}
|
||||
}
|
||||
load()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '检测失败', 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '检测失败')
|
||||
} finally {
|
||||
checkingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
const batch = useRowSelection({
|
||||
pageRows: () => rows.value,
|
||||
rowId: (row) => row.userId,
|
||||
rowLabel: (row) => row.username || `UID ${row.userId}`,
|
||||
deleteOne: (id) => deleteUserSecret(id),
|
||||
refresh: load,
|
||||
blocked: () => loading.value || !!loadFailure.value,
|
||||
scope: () => companyTab.activeId,
|
||||
consequence: '将清空这些用户的全部密钥与代理配置;后台锁定的代理也会一并清除并解锁,用户需要重新配置。',
|
||||
verb: '清空',
|
||||
})
|
||||
|
||||
async function remove(row: AdminUserSecretRow) {
|
||||
if (batch.busy) return
|
||||
const who = row.username || `UID ${row.userId}`
|
||||
if (!(await openAdminConfirm({ message: `确定清空「${who}」的全部密钥与代理配置吗?后台锁定的代理会一并清除并解锁,该用户需要重新配置。`, danger: true }))) return
|
||||
if (!window.confirm(`确定清空「${who}」的全部密钥与代理配置吗?清空后该用户需要重新配置。`)) return
|
||||
try {
|
||||
await deleteUserSecret(row.userId)
|
||||
batch.removeFromSelection(row.userId)
|
||||
ElMessage.success('已清空')
|
||||
load()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '清空失败', 'error')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开代填/改代理弹窗。
|
||||
* ⚠ 不预填任何已有值:后台侧 `full` 恒空(代理链接里带着 key/pwd,2026-11-02 收口后不再下发),
|
||||
* 所以这一单的语义就是「重新填账密」,界面上也没有把原文取回来的旁路。
|
||||
*/
|
||||
function openProxyDialog(row: AdminUserSecretRow) {
|
||||
proxyDialog.value = {
|
||||
userId: row.userId,
|
||||
username: row.username || `UID ${row.userId}`,
|
||||
provider: row.proxy?.channel ?? null,
|
||||
locked: Boolean(row.proxy?.locked),
|
||||
}
|
||||
}
|
||||
|
||||
/** 弹窗保存成功:关掉并重新取数(列表只拿脱敏值,不参与拼装)。 */
|
||||
function onProxySaved() {
|
||||
proxyDialog.value = null
|
||||
load()
|
||||
}
|
||||
|
||||
/** 解锁代理:清空后台代填值,该用户恢复自行配置。 */
|
||||
async function unlockProxy(row: AdminUserSecretRow) {
|
||||
const who = row.username || `UID ${row.userId}`
|
||||
if (!(await openAdminConfirm({ message: `确定解除「${who}」的代理锁定吗?解锁后当前后台代理值会被清空,客户端恢复自行配置。`, danger: true }))) return
|
||||
proxyBusyId.value = row.userId
|
||||
try {
|
||||
await clearUserSecretModule(row.userId, PROXY_MODULE_KEY)
|
||||
ElMessage.success('已解锁')
|
||||
load()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '解锁失败', 'error')
|
||||
} finally {
|
||||
proxyBusyId.value = null
|
||||
ElMessage.error(error instanceof Error ? error.message : '清空失败')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,89 +179,45 @@ onMounted(load)
|
||||
</div>
|
||||
<div class="form-group" style="min-width: 170px">
|
||||
<label>状态(三项都通过才算通过)</label>
|
||||
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 的弹层是浏览器直角原生物
|
||||
⇒ 换 el-select(admin-filter 同壳 42px/9px 圆角,弹层是 EP 圆角面板)。
|
||||
「全部状态」仍是 STATUS_OPTIONS 里的空串档(下游 checkStatus 照旧传 ''→undefined);
|
||||
model 为空串时 EP 走 placeholder 显示,故 placeholder 与首档同文案。 -->
|
||||
<el-select v-model="statusFilter" class="admin-filter" placeholder="全部状态" aria-label="筛选密钥状态">
|
||||
<el-option v-for="option in STATUS_OPTIONS" :key="option.value" :label="option.label" :value="option.value" />
|
||||
</el-select>
|
||||
</div>
|
||||
<div class="form-group" v-if="isSuperAdmin && groupOptions.length" style="min-width: 170px">
|
||||
<label>分组</label>
|
||||
<!-- 同上(2026-11-17 换 el-select):分组可能很多 ⇒ 保留 filterable 可搜。
|
||||
「全部分组」的值仍是 null(下游 groupId 照旧 `|| undefined`),空档时由
|
||||
placeholder 显示同一句文案。 -->
|
||||
<el-select v-model="groupFilter" class="admin-filter" filterable placeholder="全部分组" aria-label="筛选分组">
|
||||
<el-option label="全部分组" :value="null" />
|
||||
<el-option v-for="group in groupOptions" :key="group.id" :label="group.groupName" :value="group.id" />
|
||||
</el-select>
|
||||
<select v-model="statusFilter">
|
||||
<option v-for="option in STATUS_OPTIONS" :key="option.value" :value="option.value">{{ option.label }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label> </label>
|
||||
<div class="filter-actions">
|
||||
<button class="btn" type="button" @click="search">查询</button>
|
||||
<button class="btn btn-ghost" type="button" @click="reset">重置</button>
|
||||
<button
|
||||
class="btn btn-ghost"
|
||||
type="button"
|
||||
:disabled="balanceLoading || !rows.length"
|
||||
:title="balanceNotice || '余额是实时查上游、不落库;这两列没取到时显示 —,不是 0'"
|
||||
@click="loadBalances"
|
||||
>
|
||||
{{ balanceLoading ? '余额查询中…' : '刷新余额' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<div class="secrets-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="batch-delete-cell" scope="col">
|
||||
<BatchDeleteCheckbox label="全选当前页可删除记录" :checked="batch.pageAll" :partial="batch.pageSome"
|
||||
:disabled="batch.disabled || batch.pageEmpty" @change="batch.togglePage" />
|
||||
</th>
|
||||
<th style="width: 58px">序号</th>
|
||||
<th style="width: 260px">用户</th>
|
||||
<th v-if="isSuperAdmin" style="width: 130px">分组</th>
|
||||
<th style="width: 190px">用户</th>
|
||||
<th style="width: 230px">货源查询密钥</th>
|
||||
<th style="width: 230px">外观专利密钥</th>
|
||||
<th style="width: 170px">LLM 余额</th>
|
||||
<th style="width: 380px">代理设置</th>
|
||||
<th style="width: 160px">代理余量</th>
|
||||
<th style="width: 230px">代理设置</th>
|
||||
<th style="width: 130px">状态</th>
|
||||
<th style="width: 170px">创建时间</th>
|
||||
<th style="width: 170px">更新时间</th>
|
||||
<th style="width: 315px">操作</th>
|
||||
<th style="width: 170px">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-if="rows.length">
|
||||
<tr v-for="(row, index) in rows" :key="row.userId" :class="{ 'batch-selected': batch.isSelected(row) }">
|
||||
<td class="batch-delete-cell">
|
||||
<BatchDeleteCheckbox :label="batch.reason(row) || `选择 ${batch.label(row)}`" :checked="batch.isSelected(row)"
|
||||
:disabled="batch.disabled || !!batch.reason(row)" @change="batch.toggle(row)" />
|
||||
</td>
|
||||
<tr v-for="(row, index) in rows" :key="row.userId">
|
||||
<td>{{ (page - 1) * pageSize + index + 1 }}</td>
|
||||
<td>
|
||||
<span class="user-name">{{ row.username || '—' }}</span>
|
||||
</td>
|
||||
<td v-if="isSuperAdmin">
|
||||
<span class="creator-name">{{ groupTextOf(row) }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="module-cell">
|
||||
<span v-if="row.similarAsin?.exists" class="mono-mask" :title="moduleTooltip(row.similarAsin)">{{ row.similarAsin.masked }}</span>
|
||||
<span v-else class="empty-value">未配置</span>
|
||||
<span v-if="row.similarAsin?.exists" class="wh-pill is-source" title="该用户这把密钥所属渠道">
|
||||
{{ llmSourceLabel(row.similarAsin.channel) }}
|
||||
</span>
|
||||
<span class="wh-pill" :class="moduleStatusBand(row.similarAsin).tone" :title="moduleTooltip(row.similarAsin)">
|
||||
{{ moduleStatusBand(row.similarAsin).label }}
|
||||
<span class="wh-pill" :class="moduleStatusMeta(row.similarAsin).tone" :title="moduleTooltip(row.similarAsin)">
|
||||
{{ moduleStatusMeta(row.similarAsin).label }}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
@@ -449,59 +225,25 @@ onMounted(load)
|
||||
<div class="module-cell">
|
||||
<span v-if="row.appearancePatent?.exists" class="mono-mask" :title="moduleTooltip(row.appearancePatent)">{{ row.appearancePatent.masked }}</span>
|
||||
<span v-else class="empty-value">未配置</span>
|
||||
<span v-if="row.appearancePatent?.exists" class="wh-pill is-source" title="该用户这把密钥所属渠道">
|
||||
{{ llmSourceLabel(row.appearancePatent.channel) }}
|
||||
</span>
|
||||
<span class="wh-pill" :class="moduleStatusBand(row.appearancePatent).tone" :title="moduleTooltip(row.appearancePatent)">
|
||||
{{ moduleStatusBand(row.appearancePatent).label }}
|
||||
<span class="wh-pill" :class="moduleStatusMeta(row.appearancePatent).tone" :title="moduleTooltip(row.appearancePatent)">
|
||||
{{ moduleStatusMeta(row.appearancePatent).label }}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="module-cell module-cell--stack">
|
||||
<span
|
||||
v-for="(line, lineIndex) in llmLinesOf(row.userId)"
|
||||
:key="`llm-${lineIndex}`"
|
||||
class="balance-line"
|
||||
:title="line.title"
|
||||
>{{ line.text }}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="module-cell module-cell--stack">
|
||||
<span v-if="row.proxy?.exists" class="mono-mask" :title="moduleTooltip(row.proxy)">{{ proxyDisplayText(row.proxy) }}</span>
|
||||
<div class="module-cell">
|
||||
<span v-if="row.proxy?.exists" class="mono-mask" :title="moduleTooltip(row.proxy)">{{ row.proxy.masked }}</span>
|
||||
<span v-else class="empty-value">未配置</span>
|
||||
<span class="module-cell-pills">
|
||||
<span v-if="row.proxy?.exists" class="wh-pill is-source" title="该用户代理所属供应商">
|
||||
{{ proxySourceLabel(row.proxy.channel) }}
|
||||
</span>
|
||||
<span class="wh-pill" :class="moduleStatusBand(row.proxy).tone" :title="moduleTooltip(row.proxy)">
|
||||
{{ moduleStatusBand(row.proxy).label }}
|
||||
</span>
|
||||
<span
|
||||
v-if="row.proxy?.locked"
|
||||
class="wh-pill is-locked"
|
||||
title="已由管理员代填并锁定:客户端不可修改或清空"
|
||||
>
|
||||
已锁定
|
||||
</span>
|
||||
<span class="wh-pill" :class="moduleStatusMeta(row.proxy).tone" :title="moduleTooltip(row.proxy)">
|
||||
{{ moduleStatusMeta(row.proxy).label }}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="module-cell module-cell--stack">
|
||||
<span class="balance-line" :title="proxyLineOf(row.userId).title">
|
||||
{{ proxyLineOf(row.userId).text }}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<span class="wh-pill" :class="rowStatusBand(row).tone" :title="rowStatusTooltip(row)">
|
||||
{{ rowStatusBand(row).label }}
|
||||
<span class="wh-pill" :class="rowStatusMeta(row.status).tone" :title="rowStatusTooltip(row)">
|
||||
{{ rowStatusMeta(row.status).label }}
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ formatDateTime(row.createdAt) }}</td>
|
||||
<td>{{ formatDateTime(row.updatedAt) }}</td>
|
||||
<td class="ops-cell">
|
||||
<button
|
||||
class="btn btn-sm"
|
||||
@@ -511,48 +253,249 @@ onMounted(load)
|
||||
>
|
||||
{{ checkingId === row.userId ? '检测中…' : '立即检测' }}
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-sm btn-ghost"
|
||||
type="button"
|
||||
@click="openProxyDialog(row)"
|
||||
>
|
||||
{{ row.proxy?.locked ? '改代理' : '代填代理' }}
|
||||
</button>
|
||||
<button
|
||||
v-if="row.proxy?.locked"
|
||||
class="btn btn-sm btn-ghost"
|
||||
type="button"
|
||||
:disabled="proxyBusyId === row.userId"
|
||||
@click="unlockProxy(row)"
|
||||
>
|
||||
解锁
|
||||
</button>
|
||||
<button class="btn btn-sm btn-danger" type="button" :disabled="batch.busy" @click="remove(row)">清空</button>
|
||||
<button class="btn btn-sm btn-danger" type="button" @click="remove(row)">清空</button>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-else-if="loading">
|
||||
<td :colspan="isSuperAdmin ? 13 : 12" class="empty-tip">加载中...</td>
|
||||
<td colspan="7" class="empty-tip">加载中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td :colspan="isSuperAdmin ? 13 : 12" class="empty-tip">{{ keyword || statusFilter || groupFilter ? '暂无匹配记录' : '暂无用户密钥记录' }}</td>
|
||||
<td colspan="7" class="empty-tip">{{ keyword || statusFilter ? '暂无匹配记录' : '暂无用户密钥记录' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<OldPagination :total="total" :page="page" :page-size="pageSize" @change="changePage" @size-change="changeSize" />
|
||||
</section>
|
||||
|
||||
<ProxyEntryDialog
|
||||
:model-value="proxyDialog != null"
|
||||
:user-id="proxyDialog?.userId ?? null"
|
||||
:username="proxyDialog?.username ?? ''"
|
||||
:provider="proxyDialog?.provider ?? null"
|
||||
:locked="Boolean(proxyDialog?.locked)"
|
||||
@update:model-value="(open: boolean) => { if (!open) proxyDialog = null }"
|
||||
@saved="onProxySaved"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped src="./UserSecretsPage.css"></style>
|
||||
<style scoped>
|
||||
/* 像素复刻旧版 admin.html 面板风格(与店铺密钥页同一视觉语言)。 */
|
||||
.user-secrets-view {
|
||||
font-family: inherit;
|
||||
color: #24384d;
|
||||
}
|
||||
.panel-box {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 20px 22px 24px;
|
||||
border: 1px solid #d8e3ee;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(145deg, #ffffff, #f9fbfd);
|
||||
box-shadow: 0 1px 2px rgba(39, 67, 94, 0.04), 0 14px 30px -24px rgba(39, 67, 94, 0.28);
|
||||
}
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 650;
|
||||
color: #24384d;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
.secrets-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.secrets-filter-row {
|
||||
margin: 0 0 16px;
|
||||
}
|
||||
.form-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
gap: 14px 18px;
|
||||
}
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 7px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.form-group label {
|
||||
color: #5b6f83;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 9px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13.5px;
|
||||
font-family: inherit;
|
||||
color-scheme: light;
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover,
|
||||
.form-group select:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
}
|
||||
.filter-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
min-height: 42px;
|
||||
padding: 9px 18px;
|
||||
border: 1px solid #4f78a5;
|
||||
border-radius: 9px;
|
||||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
||||
color: #ffffff;
|
||||
font-family: inherit;
|
||||
font-size: 13.5px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 8px 18px -14px rgba(79, 120, 165, 0.72);
|
||||
transition: background 160ms ease, box-shadow 160ms ease, transform 120ms ease;
|
||||
}
|
||||
.btn:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #7094ba, #5d83ac);
|
||||
box-shadow: 0 11px 22px -14px rgba(79, 120, 165, 0.8);
|
||||
}
|
||||
.btn:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.55;
|
||||
}
|
||||
.btn-danger {
|
||||
background: linear-gradient(135deg, #c06d77, #b35f6a);
|
||||
border-color: #b35f6a;
|
||||
}
|
||||
.btn-danger:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #cb7c84, #b96570);
|
||||
}
|
||||
.btn-ghost {
|
||||
background: #ffffff;
|
||||
border-color: #c7d7e5;
|
||||
color: #4f78a5;
|
||||
box-shadow: none;
|
||||
}
|
||||
.btn-ghost:hover:not(:disabled) {
|
||||
background: #edf5fb;
|
||||
border-color: #95b1cb;
|
||||
color: #2f5d8b;
|
||||
}
|
||||
.btn-sm {
|
||||
min-height: 36px;
|
||||
padding: 7px 12px;
|
||||
}
|
||||
.secrets-table-scroll {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
overflow-x: auto;
|
||||
border: 1px solid #dbe5ee;
|
||||
border-radius: 10px;
|
||||
background: #ffffff;
|
||||
}
|
||||
.secrets-table-scroll table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
table-layout: fixed;
|
||||
min-width: 1240px;
|
||||
}
|
||||
.secrets-table-scroll th,
|
||||
.secrets-table-scroll td {
|
||||
padding: 10px 12px;
|
||||
text-align: left;
|
||||
font-size: 13.5px;
|
||||
line-height: 1.5;
|
||||
border-bottom: 1px solid #e0e8ef;
|
||||
vertical-align: middle;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.secrets-table-scroll th {
|
||||
background: #edf4fa;
|
||||
color: #4e6479;
|
||||
border-bottom-color: #d5e1eb;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.4px;
|
||||
}
|
||||
.secrets-table-scroll tbody tr:hover td {
|
||||
background: #f1f7fb;
|
||||
}
|
||||
.secrets-table-scroll tbody tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.user-name {
|
||||
color: #24384d;
|
||||
font-weight: 600;
|
||||
}
|
||||
.module-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
.module-cell .mono-mask {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.mono-mask {
|
||||
font-family: Consolas, "Cascadia Mono", monospace;
|
||||
font-size: 12.5px;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
.empty-value {
|
||||
color: #a7b4c1;
|
||||
}
|
||||
.ops-cell {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
.empty-tip {
|
||||
color: #8293a5;
|
||||
text-align: center;
|
||||
}
|
||||
.wh-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 2px 10px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid;
|
||||
font-size: 12px;
|
||||
line-height: 1.7;
|
||||
cursor: help;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.wh-pill.is-allowed {
|
||||
background: #e8f6ee;
|
||||
border-color: #b9e0c9;
|
||||
color: #2f7d52;
|
||||
}
|
||||
.wh-pill.is-blocked {
|
||||
background: #fdecef;
|
||||
border-color: #f2c4cd;
|
||||
color: #b04a5a;
|
||||
}
|
||||
.wh-pill.is-warn {
|
||||
background: #fdf6e3;
|
||||
border-color: #f0dfae;
|
||||
color: #8f6d1e;
|
||||
}
|
||||
.wh-pill.is-unknown {
|
||||
background: #f0f3f6;
|
||||
border-color: #d6dee6;
|
||||
color: #6b7d8f;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,55 +1,31 @@
|
||||
<script setup lang="ts">
|
||||
import BatchDeleteActions from '@/components/BatchDeleteActions.vue'
|
||||
import BatchDeleteCheckbox from '@/components/BatchDeleteCheckbox.vue'
|
||||
import { useRowSelection } from '@/utils/use-row-selection'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
/** 用户管理页 · 像素复刻旧版 admin.html panel-users(自绘:panel-box + 页头按钮 + 筛选 form-row + 旧式表格/分页 + 原生 confirm 删除)。
|
||||
* script 逻辑沿用现有 Vue 实现;创建/编辑弹窗保留现有组件(含用户菜单权限树)。 */
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { AdminUser } from '@/types/admin'
|
||||
import { roleLabel } from '@/types/admin'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { usePlatformTabStore } from '@/stores/platform-tab'
|
||||
import { deleteUser, fetchUserList, setUserDisabled } from '@/api/users'
|
||||
import { fetchCompanies } from '@/api/companies'
|
||||
import { deleteUser, fetchUserList } from '@/api/users'
|
||||
import { createUserFilterState, toUserListParams, type UserFilterState } from './users-filter'
|
||||
import { totalPageCount } from './user-pagination'
|
||||
import { deleteBlockReason, deleteConfirmMessage } from './user-delete-model'
|
||||
import { disableBlockReason, disableConfirmMessage, disabledBadgeText } from './user-disable-model'
|
||||
import { listPhaseOf, userListEmptyHint } from './user-list-state'
|
||||
import { editableBy } from './user-edit-model'
|
||||
import { formatExpiryCell } from './user-expiry'
|
||||
import { isEditableUser } from './user-edit-model'
|
||||
import CreateUserDialog from './CreateUserDialog.vue'
|
||||
import EditUserDialog from './EditUserDialog.vue'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
import { createLatestRequestGate } from '@/utils/latest-request'
|
||||
|
||||
const session = useAdminSessionStore()
|
||||
const companyTab = useCompanyTabStore()
|
||||
// 平台 tab(V206):账号域三页两 tab 共用本组件,列表/新建/编辑都按当前平台收放。
|
||||
const platformTab = usePlatformTabStore()
|
||||
/** 京东侧标记:上架上限列与编辑入口只在京东 tab 显示(用户口径「不需要在亚马逊那边」)。 */
|
||||
const isJdSide = computed(() => platformTab.active === 'jd')
|
||||
const loading = ref(false)
|
||||
const loadError = ref('')
|
||||
// 用户列表竞态门(S1-F4):快速切公司/翻页只让最后一次响应落地
|
||||
const gate = createLatestRequestGate()
|
||||
const rows = ref<AdminUser[]>([])
|
||||
const total = ref(0)
|
||||
/** 所属管理员候选(来自列表响应的 admins),供超管筛选下拉使用。 */
|
||||
const admins = ref<Array<{ id: number; username: string }>>([])
|
||||
/** 公司候选(仅供建号弹窗的「公司超级管理员」下拉使用,2026-10-05 唯一豁免)。 */
|
||||
const companyOptions = ref<Array<{ id: number; companyName: string }>>([])
|
||||
/** 操作者自己那家公司(会话里的 current-user.companyId):建号弹窗据此判断当前 tab 是不是自己家。
|
||||
* 与 GroupEditorDialog 取的是同一个源——两处各取一份会靠约定对齐。 */
|
||||
const operatorCompanyId = computed<number | null>(() => session.user?.companyId ?? null)
|
||||
const filters = reactive<UserFilterState>(createUserFilterState())
|
||||
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
||||
const operatorRole = computed(() => session.user?.role ?? null)
|
||||
const currentUserId = computed(() => session.user?.id ?? null)
|
||||
const statePhase = computed(() => listPhaseOf({ loading: loading.value, error: loadError.value, items: rows.value, total: total.value }))
|
||||
const jumpPage = ref('')
|
||||
@@ -64,35 +40,20 @@ function openCreate(): void {
|
||||
}
|
||||
|
||||
function openEdit(row: AdminUser): void {
|
||||
if (!editableBy(row.role, operatorRole.value)) return
|
||||
if (!isEditableUser(row.role)) return
|
||||
editUser.value = row
|
||||
editVisible.value = true
|
||||
}
|
||||
|
||||
function editableOf(row: AdminUser): boolean {
|
||||
return editableBy(row.role, operatorRole.value)
|
||||
}
|
||||
|
||||
/** 上架上限列文案(仅京东侧渲染该列):null=旧数据未配('-'),0=不限,其余为具体条数。 */
|
||||
function quotaCellText(row: AdminUser): string {
|
||||
if (row.jdPublishQuota == null) return '-'
|
||||
return row.jdPublishQuota === 0 ? '不限' : String(row.jdPublishQuota)
|
||||
}
|
||||
|
||||
/** 列表请求参数 = 用户填的筛选态 + 当前公司 + 当前平台。公司/平台值每次现取、不写进 filters:
|
||||
* 它们由上方 tab 决定而不是用户填的筛选项,住进 filters 就等于多出第二个取值口径(Store 之外再长一个)。 */
|
||||
function listParams() {
|
||||
return { ...toUserListParams(filters), companyId: companyTab.requestCompanyId, platform: platformTab.active }
|
||||
return isEditableUser(row.role)
|
||||
}
|
||||
|
||||
async function loadUsers() {
|
||||
// S1-F4:快速切公司/翻页时旧响应可能后返回并覆盖新结果——回写前必须过竞态门
|
||||
const token = gate.begin()
|
||||
loading.value = true
|
||||
loadError.value = ''
|
||||
try {
|
||||
const page = await fetchUserList(listParams())
|
||||
if (!gate.isCurrent(token)) return
|
||||
const page = await fetchUserList(toUserListParams(filters))
|
||||
rows.value = page.items
|
||||
total.value = page.total
|
||||
if (Array.isArray(page.admins)) admins.value = page.admins
|
||||
@@ -100,17 +61,15 @@ async function loadUsers() {
|
||||
const last = totalPageCount(page.total, filters.pageSize)
|
||||
if (last > 0 && filters.page > last) {
|
||||
filters.page = last
|
||||
const retried = await fetchUserList(listParams())
|
||||
if (!gate.isCurrent(token)) return
|
||||
const retried = await fetchUserList(toUserListParams(filters))
|
||||
rows.value = retried.items
|
||||
total.value = retried.total
|
||||
}
|
||||
} catch (error) {
|
||||
if (!gate.isCurrent(token)) return
|
||||
loadError.value = error instanceof Error ? error.message : '用户列表加载失败'
|
||||
showAdminFeedback(loadError.value, 'error')
|
||||
ElMessage.error(loadError.value)
|
||||
} finally {
|
||||
if (gate.isCurrent(token)) loading.value = false
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,51 +84,20 @@ function search() {
|
||||
void loadUsers()
|
||||
}
|
||||
|
||||
const batch = useRowSelection({
|
||||
pageRows: () => rows.value,
|
||||
rowId: (row) => row.id,
|
||||
rowLabel: (row) => row.username,
|
||||
deleteOne: (id) => deleteUser(id),
|
||||
refresh: loadUsers,
|
||||
blocked: () => loading.value || !!loadError.value,
|
||||
scope: () => [companyTab.activeId, platformTab.active, currentUserId.value],
|
||||
precheck: (row) => deleteBlockReason(row, currentUserId.value),
|
||||
})
|
||||
|
||||
async function removeUser(row: AdminUser) {
|
||||
if (batch.busy) return
|
||||
const reason = deleteBlockReason(row, currentUserId.value)
|
||||
if (reason) {
|
||||
ElMessage.warning(reason)
|
||||
return
|
||||
}
|
||||
// 对齐旧版:浏览器原生 confirm 确认后删除。
|
||||
if (!(await openAdminConfirm({ message: deleteConfirmMessage(row), danger: true }))) return
|
||||
if (!window.confirm(deleteConfirmMessage(row))) return
|
||||
try {
|
||||
await deleteUser(row.id)
|
||||
batch.removeFromSelection(row.id)
|
||||
ElMessage.success('删除成功')
|
||||
await loadUsers()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
||||
}
|
||||
}
|
||||
|
||||
/** 停用/解除停用:先过身份闸,原生 confirm 说出代价(对方会被强制退出到登录页)后提交。 */
|
||||
async function toggleDisable(row: AdminUser) {
|
||||
const wantDisable = !row.disabledAt
|
||||
const reason = disableBlockReason(row, currentUserId.value)
|
||||
if (reason) {
|
||||
ElMessage.warning(reason)
|
||||
return
|
||||
}
|
||||
if (!(await openAdminConfirm({ message: disableConfirmMessage(row, wantDisable), danger: false }))) return
|
||||
try {
|
||||
await setUserDisabled(row.id, wantDisable)
|
||||
ElMessage.success(wantDisable ? '已停用,该账号会被强制退出到登录页' : '已解除停用')
|
||||
await loadUsers()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '操作失败', 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,38 +121,7 @@ function goJump() {
|
||||
changePage(Math.min(Math.max(n, 1), totalPages.value))
|
||||
}
|
||||
|
||||
// 切公司 = 重新取数,并清掉两处上一家遗留:
|
||||
// ①「所属管理员」下拉的候选(admins)随本公司的列表响应给出,上一家选中的 adminId 在新一家的下拉里不存在;
|
||||
// ② 用户名全平台唯一(V143 的唯一索引),留着上一家填的关键字去筛新一家 ⇒ 必然空页,而输入框还显示着那个值。
|
||||
watch(() => companyTab.activeId, () => { filters.createdByAdminId = null; filters.keyword = ''; filters.page = 1; void loadUsers() })
|
||||
|
||||
// 切平台 tab(V206)= 同样的重取数:列表按平台过滤,候选/关键字跨平台无意义,一并清掉;
|
||||
// 建「公司超级管理员」的公司候选也按平台换一份(2026-11-17:京东 tab 下不能还选到亚马逊公司)。
|
||||
watch(() => platformTab.active, () => {
|
||||
filters.createdByAdminId = null
|
||||
filters.keyword = ''
|
||||
filters.page = 1
|
||||
void loadUsers()
|
||||
loadCompanyOptions()
|
||||
})
|
||||
|
||||
// 公司目录仅站点超管拉取(建「公司超级管理员」时选公司用);非超管不发这个请求,后端 403 兜底。
|
||||
// 按当前平台 tab 过滤(V206)——公司本身已按平台分侧,候选下拉跟着 tab 走。
|
||||
function loadCompanyOptions() {
|
||||
if (!isSuperAdmin.value) return
|
||||
void fetchCompanies(platformTab.active)
|
||||
.then((items) => {
|
||||
companyOptions.value = items.map((c) => ({ id: c.id, companyName: c.companyName }))
|
||||
})
|
||||
.catch(() => {
|
||||
companyOptions.value = []
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void loadUsers()
|
||||
loadCompanyOptions()
|
||||
})
|
||||
onMounted(loadUsers)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -251,14 +148,11 @@ onMounted(() => {
|
||||
<label>角色</label>
|
||||
<el-select v-model="filters.role" class="admin-filter" filterable clearable placeholder="全部角色" @change="search">
|
||||
<el-option label="超级管理员" value="super_admin" />
|
||||
<el-option label="公司超级管理员" value="company_super_admin" />
|
||||
<el-option label="管理员" value="admin" />
|
||||
<el-option label="普通账号" value="normal" />
|
||||
</el-select>
|
||||
</div>
|
||||
<button class="btn" type="button" @click="search">查询</button>
|
||||
<!-- 批量删除并入筛选行(2026-11-23 用户口径),margin-left:auto 右对齐,不再独占一行。 -->
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<div v-if="statePhase === 'error' && loadError" class="msg err">
|
||||
@@ -270,42 +164,22 @@ onMounted(() => {
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="batch-delete-cell" scope="col">
|
||||
<BatchDeleteCheckbox label="全选当前页可删除记录" :checked="batch.pageAll" :partial="batch.pageSome"
|
||||
:disabled="batch.disabled || batch.pageEmpty" @change="batch.togglePage" />
|
||||
</th>
|
||||
<th style="width: 70px">ID</th>
|
||||
<th style="width: 180px">用户名</th>
|
||||
<th style="width: 140px">角色</th>
|
||||
<th style="width: 160px">所属管理员</th>
|
||||
<th style="width: 160px">到期时间</th>
|
||||
<th v-if="isJdSide" style="width: 110px">上架上限</th>
|
||||
<th style="width: 90px">状态</th>
|
||||
<th style="width: 180px">创建时间</th>
|
||||
<th style="width: 180px">更新时间</th>
|
||||
<th style="width: 160px">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-if="rows.length">
|
||||
<tr v-for="row in rows" :key="row.id" :class="{ 'batch-selected': batch.isSelected(row) }">
|
||||
<td class="batch-delete-cell">
|
||||
<BatchDeleteCheckbox :label="batch.reason(row) || `选择 ${batch.label(row)}`" :checked="batch.isSelected(row)"
|
||||
:disabled="batch.disabled || !!batch.reason(row)" @change="batch.toggle(row)" />
|
||||
</td>
|
||||
<tr v-for="row in rows" :key="row.id">
|
||||
<td>{{ row.id }}</td>
|
||||
<td>{{ row.username }}</td>
|
||||
<td>{{ roleLabel(row.role) }}</td>
|
||||
<td>{{ row.creatorUsername || '-' }}</td>
|
||||
<td :class="{ 'expiry-cell-expired': formatExpiryCell(row).expired }">
|
||||
{{ formatExpiryCell(row).text }}
|
||||
</td>
|
||||
<td v-if="isJdSide">{{ quotaCellText(row) }}</td>
|
||||
<td class="status-cell" :class="{ 'status-cell-disabled': !!row.disabledAt }" :title="row.disabledAt ? `停用于 ${row.disabledAt}` : undefined">
|
||||
{{ disabledBadgeText(row) }}
|
||||
</td>
|
||||
<td>{{ formatDateTime(row.createdAt) }}</td>
|
||||
<td>{{ formatDateTime(row.updatedAt) }}</td>
|
||||
<td class="ops-cell">
|
||||
<button
|
||||
class="btn btn-sm"
|
||||
@@ -316,19 +190,10 @@ onMounted(() => {
|
||||
>
|
||||
编辑
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-sm btn-secondary"
|
||||
type="button"
|
||||
:disabled="disableBlockReason(row, currentUserId) !== undefined || !editableOf(row)"
|
||||
:title="disableBlockReason(row, currentUserId) || (!editableOf(row) ? '该账号不可操作' : undefined)"
|
||||
@click="toggleDisable(row)"
|
||||
>
|
||||
{{ row.disabledAt ? '解除停用' : '停用' }}
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-sm btn-danger"
|
||||
type="button"
|
||||
:disabled="batch.busy || deleteBlockReason(row, currentUserId) !== undefined"
|
||||
:disabled="deleteBlockReason(row, currentUserId) !== undefined"
|
||||
:title="deleteBlockReason(row, currentUserId) || undefined"
|
||||
@click="removeUser(row)"
|
||||
>
|
||||
@@ -338,10 +203,10 @@ onMounted(() => {
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-else-if="loading">
|
||||
<td :colspan="isJdSide ? 11 : 10" class="empty-tip">加载中...</td>
|
||||
<td colspan="6" class="empty-tip">加载中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td :colspan="isJdSide ? 11 : 10" class="empty-tip">{{ userListEmptyHint() }}</td>
|
||||
<td colspan="6" class="empty-tip">{{ userListEmptyHint() }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -350,18 +215,8 @@ onMounted(() => {
|
||||
<OldPagination :total="total" :page="filters.page" :page-size="filters.pageSize" @change="changePage" @size-change="changeSize" />
|
||||
</section>
|
||||
|
||||
<CreateUserDialog
|
||||
v-model="createVisible"
|
||||
:operator-super="isSuperAdmin"
|
||||
:operator-role="operatorRole"
|
||||
:admin-options="admins"
|
||||
:company-options="companyOptions"
|
||||
:operator-company-id="operatorCompanyId"
|
||||
:active-company-id="companyTab.requestCompanyId"
|
||||
:platform="platformTab.active"
|
||||
@created="loadUsers"
|
||||
/>
|
||||
<EditUserDialog v-model="editVisible" :user="editUser" :operator-super="isSuperAdmin" :company-id="companyTab.requestCompanyId" :platform="platformTab.active" @updated="loadUsers" />
|
||||
<CreateUserDialog v-model="createVisible" :operator-super="isSuperAdmin" :admin-options="admins" @created="loadUsers" />
|
||||
<EditUserDialog v-model="editVisible" :user="editUser" :operator-super="isSuperAdmin" @updated="loadUsers" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -416,7 +271,8 @@ h3 {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input {
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
@@ -430,10 +286,12 @@ h3 {
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover {
|
||||
.form-group input:hover,
|
||||
.form-group select:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus {
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
@@ -514,7 +372,7 @@ h3 {
|
||||
table-layout: fixed;
|
||||
}
|
||||
.user-table-scroll > table {
|
||||
min-width: 1120px;
|
||||
min-width: 860px;
|
||||
}
|
||||
.table-scroll th,
|
||||
.table-scroll td {
|
||||
@@ -547,18 +405,6 @@ h3 {
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
white-space: nowrap;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.expiry-cell-expired {
|
||||
color: #c0392b;
|
||||
font-weight: 600;
|
||||
}
|
||||
.status-cell {
|
||||
color: #3d7158;
|
||||
}
|
||||
.status-cell-disabled {
|
||||
color: #91474f;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
|
||||
@@ -14,28 +14,20 @@ import {
|
||||
export const MENUS_ENDPOINT = '/api/admin/permission-menus'
|
||||
export const REORDER_ENDPOINT = '/api/admin/column/reorder'
|
||||
|
||||
/** 拉取扁平可编辑菜单节点(全量类型,对齐 admin.js loadColumns 的 /api/admin/columns 语义)。
|
||||
* 公司 tab 的值由调用方(MenusPage)传 companyTab.requestCompanyId:菜单字典 2026-10-06 起每家公司一套树,
|
||||
* 不带 company_id 时后端一律取操作者本公司(2026-10-06 生产实测:超管不带也只得本公司那 26 行),
|
||||
* 所以切到别家必须显式传,tab 的值不能省。 */
|
||||
export async function fetchMenuManageNodes(companyId?: number | null): Promise<MenuManageNode[]> {
|
||||
const query: Record<string, string | number> = {}
|
||||
if (companyId != null) query.company_id = companyId
|
||||
const { data } = await http.get<unknown>(MENUS_ENDPOINT, { params: query })
|
||||
/** 拉取扁平可编辑菜单节点(全量类型,对齐 admin.js loadColumns 的 /api/admin/columns 语义)。 */
|
||||
export async function fetchMenuManageNodes(): Promise<MenuManageNode[]> {
|
||||
const { data } = await http.get<unknown>(MENUS_ENDPOINT)
|
||||
return parseMenuManageList(data)
|
||||
}
|
||||
|
||||
/** 拉取并按 parentId 组装成展示树。 */
|
||||
export async function loadMenuManageTree(companyId?: number | null): Promise<MenuManageNode[]> {
|
||||
return buildMenuManageTree(await fetchMenuManageNodes(companyId))
|
||||
export async function loadMenuManageTree(): Promise<MenuManageNode[]> {
|
||||
return buildMenuManageTree(await fetchMenuManageNodes())
|
||||
}
|
||||
|
||||
/** 新建菜单:POST /api/admin/permission-menus,返回后端落库节点。
|
||||
* 归属由端点的 company_id 决定(缺省=操作者本公司),前端不靠从树里猜。 */
|
||||
export async function createMenu(form: MenuManageForm, companyId?: number | null): Promise<MenuManageNode> {
|
||||
const query: Record<string, string | number> = {}
|
||||
if (companyId != null) query.company_id = companyId
|
||||
const { data } = await http.post<unknown>(MENUS_ENDPOINT, toMenuCreateRequest(form), { params: query })
|
||||
/** 新建菜单:POST /api/admin/permission-menus,返回后端落库节点。 */
|
||||
export async function createMenu(form: MenuManageForm): Promise<MenuManageNode> {
|
||||
const { data } = await http.post<unknown>(MENUS_ENDPOINT, toMenuCreateRequest(form))
|
||||
const created = parseMenuManageItem(unwrap<unknown>(data))
|
||||
if (!created) throw new Error('创建菜单响应异常:缺少菜单数据')
|
||||
return created
|
||||
|
||||
@@ -15,7 +15,6 @@ export interface MenuManageNode {
|
||||
routePath: string
|
||||
sortOrder: number
|
||||
createdAt?: string
|
||||
updatedAt?: string
|
||||
children?: MenuManageNode[]
|
||||
}
|
||||
|
||||
@@ -91,8 +90,6 @@ export function parseMenuManageItem(raw: unknown): MenuManageNode | null {
|
||||
if (rootColumnKey) node.rootColumnKey = rootColumnKey
|
||||
const createdAt = text(record.created_at)
|
||||
if (createdAt) node.createdAt = createdAt
|
||||
const updatedAt = text(record.updated_at)
|
||||
if (updatedAt) node.updatedAt = updatedAt
|
||||
return node
|
||||
}
|
||||
|
||||
|
||||
@@ -11,33 +11,22 @@ import {
|
||||
|
||||
export const SHOP_GROUPS_ENDPOINT = '/api/admin/shop-manages/groups'
|
||||
|
||||
/** 列表:company_id 收公司口径(钉住的取值口),platform 收平台 tab 口径(V206),都缺省就不发。 */
|
||||
export async function fetchShopGroups(companyId?: number | null, platform?: string): Promise<ShopGroupItem[]> {
|
||||
const { data } = await http.get<unknown>(SHOP_GROUPS_ENDPOINT, {
|
||||
params: {
|
||||
...(companyId != null ? { company_id: companyId } : {}),
|
||||
...(platform ? { platform } : {}),
|
||||
},
|
||||
})
|
||||
export async function fetchShopGroups(): Promise<ShopGroupItem[]> {
|
||||
const { data } = await http.get<unknown>(SHOP_GROUPS_ENDPOINT)
|
||||
return parseShopGroupList(data)
|
||||
}
|
||||
|
||||
/** 新建分组:POST /api/admin/shop-manages/groups(创建人 = 组长 = 当前操作者)。 */
|
||||
export async function createShopGroup(
|
||||
name: string,
|
||||
memberUserIds: number[],
|
||||
createdById: number,
|
||||
platform?: string,
|
||||
): Promise<ShopGroupItem> {
|
||||
const { data } = await http.post<unknown>(SHOP_GROUPS_ENDPOINT, toShopGroupCreatePayload(name, memberUserIds, createdById, platform))
|
||||
export async function createShopGroup(name: string, memberUserIds: number[], createdById: number): Promise<ShopGroupItem> {
|
||||
const { data } = await http.post<unknown>(SHOP_GROUPS_ENDPOINT, toShopGroupCreatePayload(name, memberUserIds, createdById))
|
||||
const created = parseShopGroupItem(unwrap<unknown>(data))
|
||||
if (!created) throw new Error('创建分组响应异常:缺少分组数据')
|
||||
return created
|
||||
}
|
||||
|
||||
/** 更新分组:PUT /api/admin/shop-manages/groups/{id}。 */
|
||||
export async function updateShopGroup(id: number, name: string, memberUserIds: number[], platform?: string): Promise<ShopGroupItem> {
|
||||
const { data } = await http.put<unknown>(`${SHOP_GROUPS_ENDPOINT}/${id}`, toShopGroupUpdatePayload(name, memberUserIds, platform))
|
||||
export async function updateShopGroup(id: number, name: string, memberUserIds: number[]): Promise<ShopGroupItem> {
|
||||
const { data } = await http.put<unknown>(`${SHOP_GROUPS_ENDPOINT}/${id}`, toShopGroupUpdatePayload(name, memberUserIds))
|
||||
const updated = parseShopGroupItem(unwrap<unknown>(data))
|
||||
if (!updated) throw new Error('更新分组响应异常:缺少分组数据')
|
||||
return updated
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/** 数据权限分组列表模型(任务 59;module 13 task 253 扩展编辑能力):解析 VO + 摘要 + 提交载荷。 */
|
||||
import { unwrap } from '../../api/envelope.ts'
|
||||
import { isSuperAdminRole, roleKind } from '../../types/admin.ts'
|
||||
|
||||
export interface ShopGroupItem {
|
||||
id: number
|
||||
@@ -12,8 +11,6 @@ export interface ShopGroupItem {
|
||||
memberUserIds?: number[]
|
||||
createdAt?: string
|
||||
updatedAt?: string
|
||||
/** 所属平台(V206):'amazon'|'jd';旧负载缺省不渲染该键。 */
|
||||
platform?: string
|
||||
}
|
||||
|
||||
export interface ShopGroupFormErrors {
|
||||
@@ -55,8 +52,6 @@ export function parseShopGroupItem(raw: unknown): ShopGroupItem | null {
|
||||
if (createdAt) item.createdAt = createdAt
|
||||
const updatedAt = text(record.updatedAt ?? record.updated_at)
|
||||
if (updatedAt) item.updatedAt = updatedAt
|
||||
const platform = text(record.platform)
|
||||
if (platform) item.platform = platform
|
||||
return item
|
||||
}
|
||||
|
||||
@@ -83,34 +78,18 @@ export function validateShopGroupForm(name: string): ShopGroupFormErrors {
|
||||
return errors
|
||||
}
|
||||
|
||||
/** 创建载荷:groupName + 成员 + 创建人(= 组长,当前操作者)+ 所属平台(V206,缺省不下发)。 */
|
||||
/** 创建载荷:groupName + 成员 + 创建人(= 组长,当前操作者)。 */
|
||||
export function toShopGroupCreatePayload(
|
||||
name: string,
|
||||
memberUserIds: number[],
|
||||
createdById: number,
|
||||
platform?: string,
|
||||
): { groupName: string; memberUserIds: number[]; createdById: number; platform?: string } {
|
||||
const payload: { groupName: string; memberUserIds: number[]; createdById: number; platform?: string } = {
|
||||
groupName: text(name),
|
||||
memberUserIds: dedupeIds(memberUserIds),
|
||||
createdById,
|
||||
}
|
||||
if (platform) payload.platform = platform
|
||||
return payload
|
||||
): { groupName: string; memberUserIds: number[]; createdById: number } {
|
||||
return { groupName: text(name), memberUserIds: dedupeIds(memberUserIds), createdById }
|
||||
}
|
||||
|
||||
/** 更新载荷:groupName + 成员 + 所属平台(V206;组长/创建人不可改)。 */
|
||||
export function toShopGroupUpdatePayload(
|
||||
name: string,
|
||||
memberUserIds: number[],
|
||||
platform?: string,
|
||||
): { groupName: string; memberUserIds: number[]; platform?: string } {
|
||||
const payload: { groupName: string; memberUserIds: number[]; platform?: string } = {
|
||||
groupName: text(name),
|
||||
memberUserIds: dedupeIds(memberUserIds),
|
||||
}
|
||||
if (platform) payload.platform = platform
|
||||
return payload
|
||||
/** 更新载荷:groupName + 成员(组长/创建人不可改)。 */
|
||||
export function toShopGroupUpdatePayload(name: string, memberUserIds: number[]): { groupName: string; memberUserIds: number[] } {
|
||||
return { groupName: text(name), memberUserIds: dedupeIds(memberUserIds) }
|
||||
}
|
||||
|
||||
/** 组员候选用户(对齐 admin.js getEligibleShopManageGroupUsers 的过滤语义)。 */
|
||||
@@ -122,20 +101,10 @@ export interface GroupMemberCandidateUser {
|
||||
}
|
||||
|
||||
/**
|
||||
* 超管(站点与公司两档)永不进组员候选——它是那家公司的最高账号,不属于任何分组。
|
||||
* 与后端 `ShopManageGroupService#resolveMembers` 抛的「超级管理员不属于任何分组」同一口径。
|
||||
*/
|
||||
export function isGroupIneligibleRole(role: string | null | undefined): boolean {
|
||||
const kind = roleKind(role)
|
||||
return kind === 'super_admin' || kind === 'company_super_admin'
|
||||
}
|
||||
|
||||
/**
|
||||
* 组员候选过滤(对齐 admin.js:3020-3028,2026-10-07 收口):
|
||||
* 组员候选过滤(对齐 admin.js:3020-3028):
|
||||
* - 组长本人永不进候选;
|
||||
* - 超管(站点/公司)永不进候选;
|
||||
* - 超管操作者可选本公司全部账号(公司维度由请求的 company_id 收窄,不在这里再判一次);
|
||||
* - 其余操作者仅可选"组长(创建人)名下"的普通账号。
|
||||
* - 超管可选全部用户(不论角色/归属);
|
||||
* - 非超管仅可选"组长(创建人)名下"的普通账号。
|
||||
*/
|
||||
export function eligibleGroupMembers(
|
||||
users: GroupMemberCandidateUser[],
|
||||
@@ -143,10 +112,9 @@ export function eligibleGroupMembers(
|
||||
operatorRole: string,
|
||||
): GroupMemberCandidateUser[] {
|
||||
const leaderKey = leaderUserId != null && leaderUserId > 0 ? String(leaderUserId) : ''
|
||||
const isSuper = isSuperAdminRole(operatorRole)
|
||||
const isSuper = (operatorRole || '').toLowerCase() === 'super_admin'
|
||||
return users.filter((u) => {
|
||||
if (String(u.id) === leaderKey) return false
|
||||
if (isGroupIneligibleRole(u.role)) return false
|
||||
if (isSuper) return true
|
||||
return (
|
||||
(u.role || '').toLowerCase() === 'normal' &&
|
||||
@@ -155,30 +123,6 @@ export function eligibleGroupMembers(
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 组长候选(2026-11-18 用户口径「新建分组组长要能下拉选」):
|
||||
* - 公司超管永不领衔——与组员「超级管理员不属于任何分组」同源,它是本公司最高账号;
|
||||
* - 站点超管只保留操作者本人(admin 保持「自己领衔建组」的既有能力,其余站点超管不进候选);
|
||||
* - 管理员与普通账号均可领衔(普通账号当组长有既有文案背书:「当前账号只能作为组长使用」)。
|
||||
*
|
||||
* 后端契约:站点超管走 `validateLeaderOperator` 放行通道,可给任意 `createdById` 建组,
|
||||
* 但组长必须与操作者同公司(`ensureLeaderSharesOperatorCompany`)——候选池天然同公司(按操作者
|
||||
* companyId 拉取),不会列出后端要打回的人。非超管操作者不出下拉(后端强制组长=操作者本人)。
|
||||
*/
|
||||
export function eligibleGroupLeaders(
|
||||
users: GroupMemberCandidateUser[],
|
||||
operatorRole: string,
|
||||
operatorId: number | null,
|
||||
): GroupMemberCandidateUser[] {
|
||||
const operatorKey = operatorId != null && operatorId > 0 ? String(operatorId) : ''
|
||||
const operatorIsSiteSuper = isSuperAdminRole(operatorRole)
|
||||
return users.filter((u) => {
|
||||
if (!isGroupIneligibleRole(u.role)) return true
|
||||
// 两档超管默认不领衔;站点超管只保留操作者本人这一个例外。
|
||||
return operatorIsSiteSuper && String(u.id) === operatorKey
|
||||
})
|
||||
}
|
||||
|
||||
/** 组员候选帮助文案(对齐 admin.js:3179-3182)。 */
|
||||
export function groupMemberCandidateHint(candidateCount: number, operatorRole: string): string {
|
||||
if (candidateCount > 0) return '可添加当前组长创建的普通员工账号'
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
/** 新建用户表单模型(任务 45):纯逻辑,镜像 Java AdminUserCreateRequest 字段与后端校验。 */
|
||||
import type { PlatformTabId } from '../../config/platform-scope.ts'
|
||||
|
||||
export const CREATE_USERNAME_MIN_LEN = 2
|
||||
export const CREATE_PASSWORD_MIN_LEN = 6
|
||||
|
||||
/**
|
||||
* 新建用户可选角色:super_admin 不可由表单创建;company_super_admin 仅站点超管可选
|
||||
* (后端 403「只有超级管理员可以创建公司超级管理员」兜底)。
|
||||
*/
|
||||
export type CreatableUserRole = 'normal' | 'admin' | 'company_super_admin'
|
||||
/** 新建用户可选角色:super_admin 不可由表单创建(后端只收 admin|normal)。 */
|
||||
export type CreatableUserRole = 'normal' | 'admin'
|
||||
|
||||
export interface CreateUserForm {
|
||||
username: string
|
||||
@@ -18,18 +14,11 @@ export interface CreateUserForm {
|
||||
columnIds: number[]
|
||||
/** 所属管理员 id(超管创建普通账号时可指定,对齐 admin 的 created_by_id)。 */
|
||||
createdBy?: number | null
|
||||
/** 到期时间(yyyy-MM-dd HH:mm:ss);空串 = 永不过期(V146)。 */
|
||||
expiresAt: string
|
||||
/** 所属公司 id:仅 role=company_super_admin 时由站点超管必选(2026-10-05 需求)。 */
|
||||
companyId?: number | null
|
||||
/** 所属平台(V206):弹窗打开时预填当前平台 tab(不设手选——2026-11-17 用户口径)。 */
|
||||
platform: PlatformTabId
|
||||
}
|
||||
|
||||
export interface CreateUserFormErrors {
|
||||
username?: string
|
||||
password?: string
|
||||
companyId?: string
|
||||
}
|
||||
|
||||
/** 发送 POST /api/admin/user 的请求体(与 Java AdminUserCreateRequest camelCase 对齐)。 */
|
||||
@@ -40,81 +29,19 @@ export interface CreateUserPayload {
|
||||
columnIds: number[]
|
||||
/** 仅 role=normal 且选了所属管理员时发送,与参考 admin.js 的 created_by_id 语义一致。 */
|
||||
createdById?: number
|
||||
/** 到期时间;空串=永不过期,不下发。 */
|
||||
expiresAt?: string
|
||||
/** 仅 role=company_super_admin 且显式选了公司时下发——这是「建号不带 company_id」
|
||||
* 反向钉(company-user-create.test.ts)唯一豁免的例外:公司超管必须落指定公司,
|
||||
* 否则会静默落操作者自己的公司(公司 1),用户需求就是给别家公司开超管。 */
|
||||
companyId?: number
|
||||
/** 所属平台(V206):恒下发(预填当前平台 tab),缺省后端落 amazon。 */
|
||||
platform: PlatformTabId
|
||||
}
|
||||
|
||||
export function createEmptyCreateUserForm(): CreateUserForm {
|
||||
return { username: '', password: '', role: 'normal', columnIds: [], createdBy: null, expiresAt: '', companyId: null, platform: 'amazon' }
|
||||
return { username: '', password: '', role: 'normal', columnIds: [], createdBy: null }
|
||||
}
|
||||
|
||||
/** 未知/空白/超管角色归一:admin/company_super_admin/normal 白名单,其余归 normal。 */
|
||||
/** 未知/空白/超管角色一律归一到 normal,与后端 "admin"/"normal" 白名单一致。 */
|
||||
export function normalizeCreateRole(role: string | null | undefined): CreatableUserRole {
|
||||
const value = (role || '').trim().toLowerCase()
|
||||
if (value === 'admin') return 'admin'
|
||||
if (value === 'company_super_admin') return 'company_super_admin'
|
||||
return 'normal'
|
||||
return (role || '').trim().toLowerCase() === 'admin' ? 'admin' : 'normal'
|
||||
}
|
||||
|
||||
/**
|
||||
* 目标公司是否不是操作者自己那家。任一侧未知时按「不算跨家」处理——未知不是证据,
|
||||
* 拿它当证据会把管理员/普通账号的选项从自己家公司面前也收走。
|
||||
*/
|
||||
export function isCrossCompanyTarget(
|
||||
operatorCompanyId: number | null | undefined,
|
||||
targetCompanyId: number | null | undefined,
|
||||
): boolean {
|
||||
return operatorCompanyId != null && targetCompanyId != null && operatorCompanyId !== targetCompanyId
|
||||
}
|
||||
|
||||
/**
|
||||
* 建号弹窗的可选角色(2026-10-07 口径):站点超管停在别家公司 tab 上时,只剩「给那家开一个
|
||||
* 公司超级管理员」;组长与普通账号由那家自己的公司超管开设。
|
||||
*
|
||||
* 与后端 `AdminUserService#ensureSubSuperAccountStaysWithOperatorCompany` 同一口径,两端各写
|
||||
* 一遍的前提是这两处永远一起改——所以这里做成纯函数,用例直接喂三种角色×两种公司组合。
|
||||
*/
|
||||
export function resolveRoleChoices(
|
||||
operatorSuper: boolean,
|
||||
operatorCompanyId: number | null | undefined,
|
||||
targetCompanyId: number | null | undefined,
|
||||
): CreatableUserRole[] {
|
||||
if (!operatorSuper) return ['admin', 'normal']
|
||||
if (isCrossCompanyTarget(operatorCompanyId, targetCompanyId)) return ['company_super_admin']
|
||||
return ['company_super_admin', 'admin', 'normal']
|
||||
}
|
||||
|
||||
/**
|
||||
* 弹窗默认选中的角色:普通账号优先——那是历史默认值,也是用得最多的一档。
|
||||
* 只有 tab 收窄到不给选普通账号时(跨家公司)才退到唯一合法项,否则超管一进弹窗就落在
|
||||
* 「公司超级管理员」上,点一次创建就多出一个超管账号。
|
||||
*/
|
||||
export function defaultRoleChoice(choices: CreatableUserRole[]): CreatableUserRole {
|
||||
return choices.includes('normal') ? 'normal' : choices[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* 可携带「自己的到期时间」的角色,与后端 AdminUserService#mayCarryOwnExpiry 逐字对齐
|
||||
* (normal-account-no-own-expiry.test.ts 钉两端集合相等)。普通账号的停用只由上级
|
||||
* (组长/公司超管)级联决定,给它单独设到期时间既没入口也没语义。
|
||||
*/
|
||||
export const EXPIRY_OWNABLE_ROLES: ReadonlyArray<string> = ['admin', 'company_super_admin']
|
||||
|
||||
export function mayCarryOwnExpiry(role: string | null | undefined): boolean {
|
||||
return EXPIRY_OWNABLE_ROLES.includes((role || '').trim().toLowerCase())
|
||||
}
|
||||
|
||||
/** 表单校验(镜像后端:用户名≥2、密码≥6、均必填;公司超管必须选公司);返回逐字段错误。 */
|
||||
export function validateCreateUserForm(form: CreateUserForm): {
|
||||
valid: boolean
|
||||
errors: CreateUserFormErrors
|
||||
} {
|
||||
/** 表单校验(镜像后端:用户名≥2、密码≥6、均必填);返回逐字段错误。 */
|
||||
export function validateCreateUserForm(form: CreateUserForm): { valid: boolean; errors: CreateUserFormErrors } {
|
||||
const errors: CreateUserFormErrors = {}
|
||||
const username = (form.username || '').trim()
|
||||
if (!username) {
|
||||
@@ -128,41 +55,20 @@ export function validateCreateUserForm(form: CreateUserForm): {
|
||||
} else if (password.length < CREATE_PASSWORD_MIN_LEN) {
|
||||
errors.password = `密码至少${CREATE_PASSWORD_MIN_LEN}个字符`
|
||||
}
|
||||
if (normalizeCreateRole(form.role) === 'company_super_admin' && form.companyId == null) {
|
||||
errors.companyId = '公司超级管理员必须指定所属公司'
|
||||
}
|
||||
return { valid: Object.keys(errors).length === 0, errors }
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单 → 创建请求体:用户名去空格、角色归一、菜单 id 拷贝不共享引用;
|
||||
* createdById 仅在 role=normal 且选了所属管理员时携带(对齐 admin.js 的 created_by_id 语义)。
|
||||
*
|
||||
* <p>company_id 仅在 role=company_super_admin 且显式选择时下发(见 CreateUserPayload 注释);
|
||||
* 其余角色不带——归属由后端 `AdminUserService#resolveTargetCompanyId` 落操作者自己的公司,
|
||||
* 想给别的公司建普通账号,得用那个公司自己的管理员登录,不是在这里改请求体。</p>
|
||||
*
|
||||
* <p>expiresAt 只对可带到期时间的角色下发:普通账号的停用走上级级联,
|
||||
* 带了会被后端 400 打回(界面已隐藏该输入项,这里是「表单残留值」的兜底)。</p>
|
||||
*/
|
||||
/** 表单 → 创建请求体:用户名去空格、角色归一、菜单 id 拷贝不共享引用;
|
||||
* createdById 仅在 role=normal 且选了所属管理员时携带(对齐 admin.js 的 created_by_id 语义)。 */
|
||||
export function toCreateUserRequest(form: CreateUserForm): CreateUserPayload {
|
||||
const role = normalizeCreateRole(form.role)
|
||||
const payload: CreateUserPayload = {
|
||||
username: (form.username || '').trim(),
|
||||
password: form.password || '',
|
||||
role,
|
||||
role: normalizeCreateRole(form.role),
|
||||
columnIds: Array.isArray(form.columnIds) ? form.columnIds.slice() : [],
|
||||
platform: form.platform,
|
||||
}
|
||||
if (payload.role === 'normal' && form.createdBy != null) {
|
||||
payload.createdById = form.createdBy
|
||||
}
|
||||
if (mayCarryOwnExpiry(role) && form.expiresAt && String(form.expiresAt).trim()) {
|
||||
payload.expiresAt = String(form.expiresAt).trim()
|
||||
}
|
||||
|
||||
if (role === 'company_super_admin' && form.companyId != null) {
|
||||
payload.companyId = form.companyId
|
||||
}
|
||||
return payload
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
/** 停用/解除停用确认模型:确认文案 + 不可停原因,镜像 Java updateUser 的 disabled 闸(V155)。 */
|
||||
import type { AdminUser } from '../../types/admin'
|
||||
|
||||
/** 停用/解除的二次确认文案。停用要说出代价:对方会被立即强制退出到登录页。 */
|
||||
export function disableConfirmMessage(user: AdminUser | null | undefined, disabled: boolean): string {
|
||||
const username = user?.username || ''
|
||||
return disabled
|
||||
? `停用后 "${username}" 在客户端和后台会被立即强制退出到登录页,确定停用吗?`
|
||||
: `解除停用后 "${username}" 可以重新登录,确定解除吗?`
|
||||
}
|
||||
|
||||
/** 返回不可停用原因;可操作时返回 undefined。角色边界由编辑态(editableBy)管,这里只管身份。 */
|
||||
export function disableBlockReason(
|
||||
user: AdminUser | null | undefined,
|
||||
currentUserId?: number | null,
|
||||
): string | undefined {
|
||||
if (!user) return '用户信息缺失,无法操作'
|
||||
if (currentUserId != null && user.id === currentUserId) return '不能停用自己的账号'
|
||||
return undefined
|
||||
}
|
||||
|
||||
/** 列表「状态」列徽标文案。 */
|
||||
export function disabledBadgeText(user: Pick<AdminUser, 'disabledAt'> | null | undefined): string {
|
||||
return user?.disabledAt ? '已停用' : '正常'
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
toEditUserUpdateRequest,
|
||||
validateEditUserForm,
|
||||
type EditUserForm,
|
||||
type EditUserFormOptions,
|
||||
} from './user-edit-model'
|
||||
|
||||
/** Java AdminUserController.updateUser 端点前缀。 */
|
||||
@@ -13,13 +12,12 @@ export const EDIT_USER_ENDPOINT = '/api/admin/user'
|
||||
|
||||
/**
|
||||
* 提交编辑用户:先校验(不通过抛首条错误),再序列化 PUT;http/后端失败交由调用方提示。
|
||||
* options.includeQuota=false(亚马逊侧)不下发上架上限——校验与序列化同口径。
|
||||
*/
|
||||
export async function submitEditUser(form: EditUserForm, options: EditUserFormOptions = {}): Promise<void> {
|
||||
const { valid, errors } = validateEditUserForm(form, options)
|
||||
export async function submitEditUser(form: EditUserForm): Promise<void> {
|
||||
const { valid, errors } = validateEditUserForm(form)
|
||||
if (!valid) {
|
||||
throw new Error(Object.values(errors)[0] || '编辑用户表单校验未通过')
|
||||
}
|
||||
const { data } = await http.put<unknown>(`${EDIT_USER_ENDPOINT}/${form.uid}`, toEditUserUpdateRequest(form, options))
|
||||
const { data } = await http.put<unknown>(`${EDIT_USER_ENDPOINT}/${form.uid}`, toEditUserUpdateRequest(form))
|
||||
unwrap<unknown>(data)
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
/** 编辑用户表单回填模型(任务 47):从用户行回填可编辑表单,镜像 Java AdminUserUpdateRequest。 */
|
||||
import type { AdminUser } from '../../types/admin'
|
||||
import type { PlatformTabId } from '../../config/platform-scope.ts'
|
||||
import { CREATE_PASSWORD_MIN_LEN, mayCarryOwnExpiry } from './user-create-model.ts'
|
||||
import { CREATE_PASSWORD_MIN_LEN } from './user-create-model.ts'
|
||||
|
||||
/** 编辑可选角色:站点/公司超管不可改,未知归 normal;后端只收 admin|normal。 */
|
||||
/** 编辑可选角色:超管不可改,未知归 normal;后端只收 admin|normal。 */
|
||||
export type EditUserRole = 'normal' | 'admin'
|
||||
|
||||
export interface EditUserForm {
|
||||
jdPublishQuota: number
|
||||
uid: number
|
||||
/** 仅展示用,后端不支持改用户名。 */
|
||||
username: string
|
||||
@@ -18,28 +16,17 @@ export interface EditUserForm {
|
||||
columnIds: number[]
|
||||
/** 后端原角色字符串,用于超管禁止编辑判定。 */
|
||||
originalRole: string
|
||||
/** 到期时间(yyyy-MM-dd HH:mm:ss);空串 = 永不过期。null = 后端本来就无到期。 */
|
||||
expiresAt: string
|
||||
/** 所属平台(V206):编辑回填行值(不设手选——2026-11-17 用户口径),未知/缺省归亚马逊(存量默认)。 */
|
||||
platform: PlatformTabId
|
||||
}
|
||||
|
||||
export interface EditUserFormErrors {
|
||||
jdPublishQuota?: string
|
||||
password?: string
|
||||
}
|
||||
|
||||
/** 序列化到 PUT /api/admin/user/{uid} 的请求体(Java AdminUserUpdateRequest,空密码不下发)。 */
|
||||
export interface EditUserUpdateRequest {
|
||||
/** 目标是公司超管时不携带(防止表单把公司超管误降级);站点超管改其密码/到期时间即可。 */
|
||||
role?: EditUserRole
|
||||
jdPublishQuota?: number
|
||||
role: EditUserRole
|
||||
columnIds: number[]
|
||||
password?: string
|
||||
/** 到期时间:空串=清除(恢复永不过期),有值=改期;总是下发(与后端"传了就更新"对齐)。 */
|
||||
expiresAt: string
|
||||
/** 所属平台(V206):总是下发(编辑保持行值原样,后端显式才落)。 */
|
||||
platform: PlatformTabId
|
||||
}
|
||||
|
||||
/** 行角色 → 可编辑角色:仅 admin 映射 admin,其余(含 unknown)归 normal。 */
|
||||
@@ -47,31 +34,9 @@ export function editRoleOf(role: string | null | undefined): EditUserRole {
|
||||
return (role || '').trim().toLowerCase() === 'admin' ? 'admin' : 'normal'
|
||||
}
|
||||
|
||||
/** 该角色是否允许被编辑:站点/公司超级管理员不可经普通编辑入口修改(镜像后端闸门)。 */
|
||||
/** 该角色是否允许被编辑:超级管理员不可编辑(镜像后端“不能修改超级管理员”)。 */
|
||||
export function isEditableUser(role: string | null | undefined): boolean {
|
||||
const value = (role || '').trim().toLowerCase()
|
||||
return value !== 'super_admin' && value !== 'company_super_admin'
|
||||
}
|
||||
|
||||
/**
|
||||
* 结合操作者角色判断可编辑性(UsersPage 用):公司超管的目标只有站点超管能编辑
|
||||
* (改密码/到期时间做续费),站点超管目标谁都不能编辑。
|
||||
*/
|
||||
export function editableBy(
|
||||
targetRole: string | null | undefined,
|
||||
operatorRole: string | null | undefined,
|
||||
): boolean {
|
||||
const target = (targetRole || '').trim().toLowerCase()
|
||||
if (target === 'super_admin') return false
|
||||
if (target === 'company_super_admin') return (operatorRole || '').trim().toLowerCase() === 'super_admin'
|
||||
return true
|
||||
}
|
||||
|
||||
/** 列表的 expires_at 是 yyyy-MM-dd HH:mm;日期选择器按 yyyy-MM-dd HH:mm:ss 回填,秒位补 :00。 */
|
||||
export function normalizeExpiryForPicker(raw: string | null | undefined): string {
|
||||
const value = (raw || '').trim()
|
||||
if (!value) return ''
|
||||
return /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/.test(value) ? `${value}:00` : value
|
||||
return (role || '').trim().toLowerCase() !== 'super_admin'
|
||||
}
|
||||
|
||||
/** 从用户行回填编辑表单:用户名只读、密码留空、columnIds 待授权加载填充。 */
|
||||
@@ -79,71 +44,34 @@ export function fillEditUserForm(user: AdminUser): EditUserForm {
|
||||
const role = typeof user.role === 'string' ? user.role.trim() : ''
|
||||
return {
|
||||
uid: user.id,
|
||||
jdPublishQuota: user.jdPublishQuota ?? 5000,
|
||||
username: user.username || '',
|
||||
password: '',
|
||||
role: editRoleOf(role),
|
||||
columnIds: [],
|
||||
originalRole: role,
|
||||
expiresAt: normalizeExpiryForPicker(user.expiresAt),
|
||||
platform: user.platform === 'jd' ? 'jd' : 'amazon',
|
||||
}
|
||||
}
|
||||
|
||||
/** 编辑表单校验选项:includeQuota=false(亚马逊侧)跳过上架上限校验——该项不下发。 */
|
||||
export interface EditUserFormOptions {
|
||||
/** 是否参与上架上限(jd_publish_quota)的校验与下发;缺省 true(京东侧)。 */
|
||||
includeQuota?: boolean
|
||||
}
|
||||
|
||||
/** 编辑表单校验:密码可留空(不改),非空时须达到最小长度。 */
|
||||
export function validateEditUserForm(
|
||||
form: EditUserForm,
|
||||
options: EditUserFormOptions = {},
|
||||
): { valid: boolean; errors: EditUserFormErrors } {
|
||||
export function validateEditUserForm(form: EditUserForm): { valid: boolean; errors: EditUserFormErrors } {
|
||||
const errors: EditUserFormErrors = {}
|
||||
const password = form.password || ''
|
||||
if (password && password.length < CREATE_PASSWORD_MIN_LEN) {
|
||||
errors.password = `密码至少${CREATE_PASSWORD_MIN_LEN}个字符,留空则不修改`
|
||||
}
|
||||
if (options.includeQuota !== false &&
|
||||
(form.role === 'admin' || form.originalRole === 'company_super_admin') &&
|
||||
(!Number.isInteger(form.jdPublishQuota) || form.jdPublishQuota < 0 || form.jdPublishQuota > 2147483647)) {
|
||||
errors.jdPublishQuota = '请输入 0 至 2147483647 的整数'
|
||||
}
|
||||
return { valid: Object.keys(errors).length === 0, errors }
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑表单 → 更新请求体:站点超管拒绝、空密码不下发、columnIds 拷贝不共享引用。
|
||||
*
|
||||
* <p>expiresAt 按「改完之后的角色」决定:目标角色不能带自己的到期时间时发空串=清空
|
||||
* (后端 400 闸门只拦「有值」,空串走既有的清除分支)。公司超管目标不带 role,
|
||||
* 它的 roleAfter 就是 company_super_admin,续费那条空串不会被误当成清空。</p>
|
||||
*
|
||||
* <p>options.includeQuota=false(亚马逊侧编辑)不下发 jdPublishQuota——上架上限是京东
|
||||
* 口径,亚马逊侧不显示也不改它(用户口径 2026-11-17);platform 恒下发(单选恒渲染)。</p>
|
||||
*/
|
||||
export function toEditUserUpdateRequest(form: EditUserForm, options: EditUserFormOptions = {}): EditUserUpdateRequest {
|
||||
/** 编辑表单 → 更新请求体:超管拒绝、空密码不下发、columnIds 拷贝不共享引用。 */
|
||||
export function toEditUserUpdateRequest(form: EditUserForm): EditUserUpdateRequest {
|
||||
const originalRole = (form.originalRole || '').trim().toLowerCase()
|
||||
if (originalRole === 'super_admin') {
|
||||
throw new Error('不能修改超级管理员')
|
||||
}
|
||||
// 公司超管目标不带 role:弹窗里的单选是给管理员/普通账号用的,带着它会整树提交把
|
||||
// 公司超管静默降级。站点超管要调角色,请删号重建或走接口。
|
||||
const keepsRole = originalRole !== 'company_super_admin'
|
||||
const nextRole: EditUserRole = form.role === 'admin' ? 'admin' : 'normal'
|
||||
const roleAfter = keepsRole ? nextRole : originalRole
|
||||
const role: EditUserRole = form.role === 'admin' ? 'admin' : 'normal'
|
||||
const request: EditUserUpdateRequest = {
|
||||
role,
|
||||
columnIds: Array.isArray(form.columnIds) ? form.columnIds.slice() : [],
|
||||
expiresAt: mayCarryOwnExpiry(roleAfter) ? (form.expiresAt || '').trim() : '',
|
||||
platform: form.platform,
|
||||
}
|
||||
if (keepsRole) {
|
||||
request.role = nextRole
|
||||
}
|
||||
if (options.includeQuota !== false && (roleAfter === 'admin' || roleAfter === 'company_super_admin')) {
|
||||
request.jdPublishQuota = form.jdPublishQuota
|
||||
}
|
||||
const password = form.password || ''
|
||||
if (password) request.password = password
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
/** 用户列表「到期时间」单元格渲染(V146):永不过期 / 具体时间 / 已过期。 */
|
||||
|
||||
export interface ExpiryCell {
|
||||
text: string
|
||||
expired: boolean
|
||||
}
|
||||
|
||||
/** 行 expiresAt 是 yyyy-MM-dd HH:mm 或空(后端空串=永不过期);解析失败按永不过期兜底。 */
|
||||
export function formatExpiryCell(row: { expiresAt?: string | null }): ExpiryCell {
|
||||
const raw = (row?.expiresAt || '').trim()
|
||||
if (!raw) {
|
||||
return { text: '永不过期', expired: false }
|
||||
}
|
||||
const parsed = new Date(raw.replace(' ', 'T'))
|
||||
if (Number.isNaN(parsed.getTime())) {
|
||||
return { text: raw, expired: false }
|
||||
}
|
||||
return { text: raw, expired: parsed.getTime() < Date.now() }
|
||||
}
|
||||
@@ -15,21 +15,11 @@ import {
|
||||
export const GRANT_MENUS_ENDPOINT = '/api/admin/permission-menus'
|
||||
export const USER_PERMISSION_COLUMNS_ENDPOINT = '/api/admin/permission-users'
|
||||
|
||||
/**
|
||||
* 拉取可授权菜单树(后台 admin + 前端客户端 app 两类合并,按 sort 排序)。
|
||||
* grantableOnly:非超管只拿到自己已持有的菜单,范围外的项后端不再下发。
|
||||
* <p>companyId 传 companyTab.requestCompanyId:2026-10-06 起每家公司一套菜单树,同一 column_key 在
|
||||
* 别家有一份**不同 id** 的副本。这一页的授权载荷提交的是 column id,树取错公司就等于
|
||||
* 把别家的 id 授给本公司账号(后端按「id 必须在被授权账号自己的树里」拒 ⇒ 保存必然失败,
|
||||
* 而已授权项因为 id 对不上树根本勾不上,看上去像"这个人一条权限都没有")。
|
||||
* null(非超管、或建号时没指定公司)由后端锁到操作者本公司。
|
||||
*/
|
||||
export async function fetchGrantableMenus(companyId?: number | null): Promise<MenuOptionNode[]> {
|
||||
const query: Record<string, string | number> = {}
|
||||
if (companyId != null) query.company_id = companyId
|
||||
/** 拉取可授权菜单树(后台 admin + 前端客户端 app 两类合并,按 sort 排序)。 */
|
||||
export async function fetchGrantableMenus(): Promise<MenuOptionNode[]> {
|
||||
const [adminRes, appRes] = await Promise.all([
|
||||
http.get<unknown>(GRANT_MENUS_ENDPOINT, { params: { ...query, menuType: ADMIN_MENU_TYPE, grantableOnly: true } }),
|
||||
http.get<unknown>(GRANT_MENUS_ENDPOINT, { params: { ...query, menuType: APP_MENU_TYPE, grantableOnly: true } }),
|
||||
http.get<unknown>(GRANT_MENUS_ENDPOINT, { params: { menuType: ADMIN_MENU_TYPE } }),
|
||||
http.get<unknown>(GRANT_MENUS_ENDPOINT, { params: { menuType: APP_MENU_TYPE } }),
|
||||
])
|
||||
const nodes = [
|
||||
...parseMenuOptionList(adminRes.data, ADMIN_MENU_TYPE),
|
||||
@@ -60,8 +50,8 @@ export interface UserMenuAuthData {
|
||||
checkedIds: number[]
|
||||
}
|
||||
|
||||
export async function loadUserMenuAuth(userId: number, companyId?: number | null): Promise<UserMenuAuthData> {
|
||||
const [tree, checkedIds] = await Promise.all([fetchGrantableMenus(companyId), fetchUserGrantedColumnIds(userId)])
|
||||
export async function loadUserMenuAuth(userId: number): Promise<UserMenuAuthData> {
|
||||
const [tree, checkedIds] = await Promise.all([fetchGrantableMenus(), fetchUserGrantedColumnIds(userId)])
|
||||
return { tree, checkedIds }
|
||||
}
|
||||
|
||||
|
||||
@@ -16,11 +16,6 @@ export interface MenuOptionNode {
|
||||
parentId: number | null
|
||||
/** 所属菜单类型(admin 后台 / app 前端客户端),提交时按类型分区落库。 */
|
||||
type: string
|
||||
/**
|
||||
* 当前操作者无权授予(后端 grantable=false)时置灰。授权树对非超管只下发自己已有
|
||||
* 的菜单,因此这里剩下的只有「为保留层级而带上的祖先分组」:展示但不可勾,提交时剔除。
|
||||
*/
|
||||
disabled?: boolean
|
||||
children?: MenuOptionNode[]
|
||||
}
|
||||
|
||||
@@ -44,8 +39,6 @@ export function parsePermissionMenuItem(raw: unknown, type = ''): MenuOptionNode
|
||||
sort: sortRaw === null ? 0 : sortRaw,
|
||||
parentId: parentId === null ? null : parentId,
|
||||
type,
|
||||
// 缺省(菜单管理页等未标记的接口)按可授予处理,保持旧行为
|
||||
disabled: record.grantable === false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,11 +111,6 @@ export function buildUserColumnPermissionPayload(raw: unknown): { columnIds: num
|
||||
* 重复提交(后端读取/校验时父级授权会向全部后代展开,与旧 admin.html“勾父清
|
||||
* 后代”语义一致,避免 user_column_permission 存储冗余行)。未勾选父级但单独
|
||||
* 勾选子级的部分授权原样保留。
|
||||
*
|
||||
* <p>置灰节点(disabled,即操作者无权授予、只为还原层级而带上的祖先分组)一律剔除,
|
||||
* 且其勾选态不参与“父级覆盖后代”的判断:那是子节点联动派生出来的,不代表用户意图。
|
||||
* 提交它等于把整个分组授出去,会连带授予树上未下发(因此看不见)的后代菜单,
|
||||
* 同时被后端 ensureGrantable 判越权、整单 403 回滚。
|
||||
*/
|
||||
export function compactDirectGrantIds(checkedIds: unknown, tree: MenuOptionNode[]): number[] {
|
||||
const ids = normalizeMenuIds(checkedIds)
|
||||
@@ -130,40 +118,16 @@ export function compactDirectGrantIds(checkedIds: unknown, tree: MenuOptionNode[
|
||||
const idSet = new Set(ids)
|
||||
/** 因“有已勾选祖先”而被父级覆盖、无需直接授权的 id。 */
|
||||
const coveredByAncestor = new Set<number>()
|
||||
/** 操作者无权授予、不得出现在提交里的 id。 */
|
||||
const ungrantable = new Set<number>()
|
||||
const walk = (nodes: MenuOptionNode[], ancestorChecked: boolean): void => {
|
||||
for (const node of nodes) {
|
||||
if (node.disabled) ungrantable.add(node.id)
|
||||
if (ancestorChecked) {
|
||||
coveredByAncestor.add(node.id)
|
||||
if (node.children?.length) walk(node.children, true)
|
||||
continue
|
||||
}
|
||||
if (node.children?.length) walk(node.children, !node.disabled && idSet.has(node.id))
|
||||
if (node.children?.length) walk(node.children, idSet.has(node.id))
|
||||
}
|
||||
}
|
||||
walk(tree, false)
|
||||
return ids.filter((id) => !ungrantable.has(id) && !coveredByAncestor.has(id))
|
||||
}
|
||||
|
||||
/**
|
||||
* 把勾选集收敛到「可见树」内(2026-11-17 用户口径「授权树按平台收」的另一半):
|
||||
* 授权树按平台过滤后,另一侧的已勾 id 在树上不可见、也不再属于这棵树——它们必须
|
||||
* 从表单勾选集里剔除,否则「京东档账号」保存后仍携带整批亚马逊菜单授权(侧边栏
|
||||
* 亚马逊 tab 照样全亮,平台分侧被静默架空)。纯函数:入参不动,返回去重升序交集。
|
||||
*/
|
||||
export function pruneCheckedIdsToTree(checkedIds: unknown, visibleTree: MenuOptionNode[]): number[] {
|
||||
const ids = normalizeMenuIds(checkedIds)
|
||||
if (ids.length === 0) return []
|
||||
if (visibleTree.length === 0) return []
|
||||
const visible = new Set<number>()
|
||||
const walk = (nodes: MenuOptionNode[]): void => {
|
||||
for (const node of nodes) {
|
||||
visible.add(node.id)
|
||||
if (node.children?.length) walk(node.children)
|
||||
}
|
||||
}
|
||||
walk(visibleTree)
|
||||
return ids.filter((id) => visible.has(id))
|
||||
return ids.filter((id) => !coveredByAncestor.has(id))
|
||||
}
|
||||
|
||||
@@ -2,42 +2,39 @@
|
||||
import { roleKind } from '../../types/admin.ts'
|
||||
|
||||
/** 后台角色域(与 AdminUserItemVo.role / is_admin 对齐)。 */
|
||||
export type RoleDomain = 'super_admin' | 'company_super_admin' | 'admin' | 'normal'
|
||||
export type RoleDomain = 'super_admin' | 'admin' | 'normal'
|
||||
|
||||
/** 用户角色下拉可选值;super_admin 只能由系统持有,不入下拉。 */
|
||||
export type EditableRole = 'company_super_admin' | 'admin' | 'normal'
|
||||
export type EditableRole = 'admin' | 'normal'
|
||||
|
||||
export interface UserRoleOption {
|
||||
value: EditableRole
|
||||
label: string
|
||||
}
|
||||
|
||||
/** 建/编辑表单角色下拉候选(镜像后端白名单;company_super_admin 仅站点超管可选)。 */
|
||||
/** 编辑/创建表单角色下拉候选(镜像后端 admin|normal 白名单)。 */
|
||||
export const USER_ROLE_OPTIONS: readonly UserRoleOption[] = [
|
||||
{ value: 'company_super_admin', label: '公司超级管理员' },
|
||||
{ value: 'admin', label: '管理员' },
|
||||
{ value: 'normal', label: '普通账号' },
|
||||
{ value: 'normal', label: '普通用户' },
|
||||
]
|
||||
|
||||
const ROLE_DOMAIN_LABELS: Record<RoleDomain, string> = {
|
||||
super_admin: '超级管理员',
|
||||
company_super_admin: '公司超级管理员',
|
||||
admin: '管理员',
|
||||
normal: '普通账号',
|
||||
normal: '普通用户',
|
||||
}
|
||||
|
||||
/** 行字段 → 角色域:优先 role;为空时按 is_admin 布尔推断(1=管理员);未知归 normal。 */
|
||||
export function roleDomainOf(row: { role?: string | null; isAdmin?: boolean }): RoleDomain {
|
||||
const kind = roleKind(row?.role)
|
||||
if (kind === 'super_admin' || kind === 'company_super_admin' || kind === 'admin' || kind === 'normal') return kind
|
||||
if (kind === 'super_admin' || kind === 'admin' || kind === 'normal') return kind
|
||||
return row?.isAdmin ? 'admin' : 'normal'
|
||||
}
|
||||
|
||||
/** 行 → 可编辑角色值:站点/公司超管不可在此编辑角色(返回 null),其余返回对应值。 */
|
||||
/** 行 → 可编辑角色值:超级管理员返回 null(不可编辑),其余返回 admin/normal。 */
|
||||
export function selectRoleOf(row: { role?: string | null; isAdmin?: boolean }): EditableRole | null {
|
||||
const domain = roleDomainOf(row)
|
||||
if (domain === 'super_admin' || domain === 'company_super_admin') return null
|
||||
return domain
|
||||
return domain === 'super_admin' ? null : domain
|
||||
}
|
||||
|
||||
/** 角色域展示文案。 */
|
||||
@@ -46,16 +43,14 @@ export function roleDomainLabel(domain: RoleDomain): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色下拉锁定原因:目标为站点/公司超管、或操作者非站点超管(镜像后端:admin/公司超管
|
||||
* 编辑时角色不可调、super_admin 与同公司公司超管不可改)。无锁定时返回 undefined。
|
||||
* 角色下拉锁定原因:目标为超管、或操作者非超管(镜像后端:admin 编辑时强制不调角色、
|
||||
* super_admin 不可改)。无锁定时返回 undefined。
|
||||
*/
|
||||
export function userRoleLockMessage(
|
||||
operatorRole: string | null | undefined,
|
||||
target: { role?: string | null; isAdmin?: boolean },
|
||||
): string | undefined {
|
||||
const targetDomain = roleDomainOf(target)
|
||||
if (targetDomain === 'super_admin') return '不能修改超级管理员'
|
||||
if (targetDomain === 'company_super_admin') return '只有超级管理员可以修改公司超级管理员'
|
||||
if (roleDomainOf(target) === 'super_admin') return '不能修改超级管理员'
|
||||
if (roleKind(operatorRole) !== 'super_admin') return '仅超级管理员可调整角色'
|
||||
return undefined
|
||||
}
|
||||
|
||||
@@ -1,463 +0,0 @@
|
||||
/**
|
||||
* 密钥管理页的纯逻辑模型(货源标签 + 代理重填 + 检测结果档位)。
|
||||
*
|
||||
* 四条收口都在这个文件里,页模板只调这里导出的函数,不各写各的字典:
|
||||
*
|
||||
* 1. **货源标签按模块分字典**(2026-11-02 修):原先 `UserSecretsPage.vue` 里是一整张
|
||||
* `sourceLabel()`,把 LLM 渠道(longtaitou/t8star)与代理供应商(qingguo/jikip)混在同一个
|
||||
* switch 上,于是「按值匹配」的字典会把它认识的**任何**值贴到**任何**列上——代理行因此能长出
|
||||
* 「龙抬头」这种标签。后端 VO 的 `channel` 本来就是按模块归一的(`UserSecretModule.channelOrDefault`
|
||||
* 代理走 `ProxyProvider`、密钥走 `LlmChannel`),所以错标只会来自前端这张合表。
|
||||
* 现在两张表互不相通:代理列只认供应商、密钥列只认渠道,跨域的值一律落到「—」而不是被硬认下来。
|
||||
*
|
||||
* 2. **代理列不再显示、也不再回传原文**(2026-11-02 后端 `SecretMasking.maskProxy` 收口):
|
||||
* `AdminUserSecretModuleVo.full` 后台侧恒为空,界面只读 `masked`(`scheme://host`,不含
|
||||
* key/pwd)。因此原先「代填/改代理」用 `window.prompt` 预填整条链接的交互已失效
|
||||
* (预填必然是空的,保存还会把空串顶上去)——改成重新填账密:青果填 Authkey/Authpwd、
|
||||
* 由 `composeQingguoLink` 现拼;极客按其产品口径填自家提取链接。
|
||||
* ⚠ 拼出来的链接是一次性写请求的载荷,**不得**回显、回填、进 tooltip、进剪贴板。
|
||||
*
|
||||
* 3. **检测结果按 `check_code` 分档渲染**(2026-11-02 加,见下方档位表):状态列原先只看
|
||||
* `check_status`,把后端新分出来的一族「等一会再点就行」的码(`channel_busy` 等)一律显示成
|
||||
* 「无法判定」,管理员分不清「被自己占着」「密钥坏了」「欠费」三种完全不同的处置。
|
||||
* 码表只在这一份文件里(页面不再自带第二张表),句子一律用后端的 `check_message` 原文。
|
||||
*
|
||||
* 零 `@/` 别名依赖:本文件被 `node --test` 直测(那颗 runner 不认 Vite 别名)。
|
||||
*/
|
||||
import { composeQingguoLink } from '../../shared/utils/qingguo-link.ts'
|
||||
|
||||
export type LlmChannelKey = 'longtaitou' | 't8star'
|
||||
export type ProxyProviderKey = 'qingguo' | 'jikip'
|
||||
|
||||
/** 代理模块 key(与后端 `UserSecretModule.PROXY.key()` 同值):写请求的路径段与「这一格是代理」的判据。 */
|
||||
export const PROXY_MODULE_KEY = 'proxy'
|
||||
|
||||
/* ------------------------------------------------------------------ *
|
||||
* 检测结果的渲染档位(2026-11-02 加,起因是现网 uid=1 的 proxy 行)
|
||||
*
|
||||
* 后端 `UserApiSecretCheckService` 把青果检测从「无条件假通过」改成真提取后**按供应商返回码分档**,
|
||||
* 于是 `check_code` 成了这一格到底怎么了的最细信号;而界面当时只认 `check_status` 三档
|
||||
* (passed/failed/error),`error` 一律写成「无法判定」——`channel_busy`(青果通道被自己的采集
|
||||
* 占着,等约 3 分钟就能重试)因此被显示成「查不出」,管理员既看不出「等一会就行」,
|
||||
* 也分不清它和「密钥坏了」「欠费」是三种完全不同的处置。
|
||||
*
|
||||
* 所以现在**按码建表、按状态兜底**:
|
||||
* - 认得的码 ⇒ 各有自己的档位(可重试这一族另给独立配色,既不红也不黄);
|
||||
* - 「无法判定」只留给真正没有结论的情况(空码/这表里没有的码 + `check_status=error`);
|
||||
* - `check_status=unknown`(后端 upsert 后的初值,等于「从没检测过」)仍是「未检测」,
|
||||
* 不许冒充「无法判定」——那是两件事,前者点一次检测就有答案,后者点了也还是没答案。
|
||||
*
|
||||
* ⚠ 措辞的权威在后端:给人看的那句中文在 `check_message` 里,界面只出**档名**(一个词),
|
||||
* 绝不按码自己拼句子;句子通过 `moduleTooltip`/行级 tooltip 原样透出。
|
||||
* ------------------------------------------------------------------ */
|
||||
|
||||
/** 药丸配色档位,对应 `UserSecretsPage.vue` 里 `.wh-pill.is-*` 那套样式类。 */
|
||||
export type StatusTone = 'is-allowed' | 'is-blocked' | 'is-warn' | 'is-retry' | 'is-unknown'
|
||||
|
||||
/** 一个渲染档位:档名 + 配色。档名是给管理员扫一眼用的短词,不是解释句。 */
|
||||
export interface StatusBand {
|
||||
label: string
|
||||
tone: StatusTone
|
||||
}
|
||||
|
||||
/** 单格「没配」与「没检测」是两档,但都用灰色:都不代表密钥本身有问题。 */
|
||||
export const NOT_CONFIGURED_BAND: StatusBand = { label: '未配置', tone: 'is-unknown' }
|
||||
export const NOT_CHECKED_BAND: StatusBand = { label: '未检测', tone: 'is-unknown' }
|
||||
/** 真的问不出结论(空码/未知码 + `check_status=error`)才落到这一档。 */
|
||||
export const INDETERMINATE_BAND: StatusBand = { label: '无法判定', tone: 'is-warn' }
|
||||
/** 后端 `STATUS_PASSED`(或码 `ok`):唯一可以当成「这项配好了」的一档。 */
|
||||
export const PASSED_BAND: StatusBand = { label: '通过', tone: 'is-allowed' }
|
||||
/** 后端新增了一档、前端还没登记码名时的兜底:按状态给个不撒谎的词,不当场判死。 */
|
||||
const GENERIC_FAILED_BAND: StatusBand = { label: '失败', tone: 'is-blocked' }
|
||||
|
||||
/** 后端 `UserApiSecretCheckService` 的 `CODE_*` 全集(2026-11-02 逐条对着源码登记)。 */
|
||||
const CHECK_CODE_BANDS: Record<string, StatusBand> = {
|
||||
ok: PASSED_BAND,
|
||||
/** 通道被自己的采集占着:等释放后重点一次,密钥没坏——这一档就是本次要修的错渲染。 */
|
||||
channel_busy: { label: '无可用通道', tone: 'is-retry' },
|
||||
rate_limited: { label: '限流重试', tone: 'is-retry' },
|
||||
timeout: { label: '超时重试', tone: 'is-retry' },
|
||||
/** 传输层失败:后端两个分支都给这个码(提取接口不可达=failed、探测异常=error),都可重试。 */
|
||||
network_error: { label: '网络重试', tone: 'is-retry' },
|
||||
server_error: { label: '上游重试', tone: 'is-retry' },
|
||||
/** 欠费(现网 21 行):修之前就只有 `check_status=failed` 这一条路径认得它,改后按码认、不再吊在状态上。 */
|
||||
insufficient_balance: { label: '欠费', tone: 'is-warn' },
|
||||
/** 提取成功但链接里组不出可验连的地址(没带 key/pwd):要用户重填,不是「查不出」。 */
|
||||
tunnel_unverified: { label: '链接缺账密', tone: 'is-warn' },
|
||||
invalid_key: { label: '密钥失效', tone: 'is-blocked' },
|
||||
forbidden: { label: '鉴权被拒', tone: 'is-blocked' },
|
||||
bad_request: { label: '参数被拒', tone: 'is-blocked' },
|
||||
provider_error: { label: '供应商报错', tone: 'is-blocked' },
|
||||
}
|
||||
|
||||
/** 行级档位:后端 `UserApiSecretService` 按 failed > incomplete > passed > error > unknown 聚合,界面不重排这个优先级。 */
|
||||
const ROW_STATUS_BANDS: Record<string, StatusBand> = {
|
||||
passed: { label: '检测通过', tone: 'is-allowed' },
|
||||
failed: { label: '检测失败', tone: 'is-blocked' },
|
||||
incomplete: { label: '未配齐', tone: 'is-warn' },
|
||||
error: INDETERMINATE_BAND,
|
||||
}
|
||||
/** 行级「可重试」:仅当整行的问题**只**出在可重试那一族码上时替换掉「无法判定」(后端给不了这一档,前端按格子的码补)。 */
|
||||
const ROW_RETRY_BAND: StatusBand = { label: '可重试', tone: 'is-retry' }
|
||||
|
||||
/** 单模块的可比较形状(不引 `@/api/*`:本文件要能被零别名的 `node --test` 直测)。 */
|
||||
interface CheckModuleLike {
|
||||
exists?: boolean | null
|
||||
moduleLabel?: string | null
|
||||
checkStatus?: string | null
|
||||
checkCode?: string | null
|
||||
checkMessage?: string | null
|
||||
}
|
||||
|
||||
/** 一行的可比较形状:只用到行状态 + 三个格子。 */
|
||||
interface SecretRowLike {
|
||||
status?: string | null
|
||||
similarAsin?: CheckModuleLike | null
|
||||
appearancePatent?: CheckModuleLike | null
|
||||
proxy?: CheckModuleLike | null
|
||||
}
|
||||
|
||||
/** 按归一后的键查档位表:空键与表里没有的键都返回 null(调用方兜底,绝不硬认一档)。 */
|
||||
function bandOf(table: Record<string, StatusBand>, raw: unknown): StatusBand | null {
|
||||
const key = normalizeKey(raw)
|
||||
if (!key || !Object.prototype.hasOwnProperty.call(table, key)) return null
|
||||
return table[key] ?? null
|
||||
}
|
||||
|
||||
/** 码 → 档位;空码或这表里没有的码返回 null(由调用方按状态兜底,不硬认一档)。 */
|
||||
export function checkCodeBand(code: string | null | undefined): StatusBand | null {
|
||||
return bandOf(CHECK_CODE_BANDS, code)
|
||||
}
|
||||
|
||||
/** 这一档是不是「等一等再点」那一族(可重试):配色与行级补档都读这一个判据,不散落码名。 */
|
||||
export function isRetryBand(band: StatusBand | null | undefined): boolean {
|
||||
return band?.tone === 'is-retry'
|
||||
}
|
||||
|
||||
/**
|
||||
* 单格状态药丸:先看是否已配置,再看 `check_status=passed`,然后**按 `check_code` 分档**,
|
||||
* 都不认才按状态兜底。
|
||||
*/
|
||||
export function moduleStatusBand(module: CheckModuleLike | null | undefined): StatusBand {
|
||||
if (!module || !module.exists) return NOT_CONFIGURED_BAND
|
||||
const status = normalizeKey(module.checkStatus)
|
||||
if (status === 'passed') return PASSED_BAND
|
||||
const band = checkCodeBand(module.checkCode)
|
||||
if (band) return band
|
||||
if (status === 'error') return INDETERMINATE_BAND
|
||||
if (status === 'failed') return GENERIC_FAILED_BAND
|
||||
// ''/unknown/后端下一版新增的状态值:宁可说「未检测」,也不替后端编造一个结论
|
||||
return NOT_CHECKED_BAND
|
||||
}
|
||||
|
||||
/** 行级状态药丸:后端聚合成 `error` 时,若这一行**没有结论的格子全是可重试那一族**,补成「可重试」。 */
|
||||
export function rowStatusBand(row: SecretRowLike | null | undefined): StatusBand {
|
||||
const status = normalizeKey(row?.status)
|
||||
if (status === 'error' && awaitsRetryOnly(row)) return ROW_RETRY_BAND
|
||||
// 行级 `unknown`=后端还没问过(不是「问了问不出」),留「未检测」这一档,与筛选项里那一行同词
|
||||
return bandOf(ROW_STATUS_BANDS, status) ?? NOT_CHECKED_BAND
|
||||
}
|
||||
|
||||
/**
|
||||
* 这一行是不是「点一次就有答案」:后端把 error 之上的 failed/incomplete 都判掉了才轮到 error,
|
||||
* 所以这里只需再确认剩下那些没通过的格子都落在可重试档——混进一格「链接缺账密」就不算可重试,
|
||||
* 那一格不会自己好,把整行说成「可重试」等于让管理员一直等。
|
||||
*/
|
||||
function awaitsRetryOnly(row: SecretRowLike | null | undefined): boolean {
|
||||
const pending = modulesOf(row).filter(
|
||||
(module) => Boolean(module?.exists) && normalizeKey(module?.checkStatus) !== 'passed',
|
||||
)
|
||||
return pending.length > 0 && pending.every((module) => isRetryBand(moduleStatusBand(module)))
|
||||
}
|
||||
|
||||
/**
|
||||
* 行级 tooltip 的明细:逐格把**后端原文** `check_message` 抄出来(运维判「是欠费还是被自己占着」就靠这句)。
|
||||
* 前端不拼句子、不改一个字;没检测过的格子没有这句话,自然不出现。
|
||||
*/
|
||||
export function rowDetailLines(row: SecretRowLike | null | undefined): string[] {
|
||||
return modulesOf(row)
|
||||
.filter((module) => Boolean(module?.exists))
|
||||
.map((module) => {
|
||||
const message = String(module?.checkMessage ?? '').trim()
|
||||
if (!message) return ''
|
||||
const label = String(module?.moduleLabel ?? '').trim()
|
||||
return label ? `${label}:${message}` : message
|
||||
})
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
function modulesOf(row: SecretRowLike | null | undefined): CheckModuleLike[] {
|
||||
return [row?.similarAsin, row?.appearancePatent, row?.proxy].filter(Boolean) as CheckModuleLike[]
|
||||
}
|
||||
|
||||
/** 后端 `ProxyProvider.DEFAULT`=极客:新建默认极客,青果手动切(2026-10-30 拍板)。 */
|
||||
export const DEFAULT_PROXY_PROVIDER: ProxyProviderKey = 'jikip'
|
||||
|
||||
/** 认不出的货源一律这个占位,不许回退成"某个具体渠道名"(那正是错标的来源)。 */
|
||||
export const UNKNOWN_SOURCE_LABEL = '—'
|
||||
|
||||
const LLM_CHANNEL_LABELS: Record<LlmChannelKey, string> = {
|
||||
longtaitou: '龙抬头',
|
||||
t8star: '贞贞',
|
||||
}
|
||||
|
||||
const PROXY_PROVIDER_LABELS: Record<ProxyProviderKey, string> = {
|
||||
qingguo: '青果',
|
||||
jikip: '极客',
|
||||
}
|
||||
|
||||
function normalizeKey(raw: unknown): string {
|
||||
return String(raw ?? '').trim().toLowerCase()
|
||||
}
|
||||
|
||||
function known<T extends string>(table: Record<T, string>, raw: unknown): string | null {
|
||||
const key = normalizeKey(raw)
|
||||
return Object.prototype.hasOwnProperty.call(table, key)
|
||||
? table[key as T]
|
||||
: null
|
||||
}
|
||||
|
||||
/** LLM 密钥列的渠道名:只查 LLM 字典,代理供应商的值在这里认不出。 */
|
||||
export function llmSourceLabel(channel: string | null | undefined): string {
|
||||
return known(LLM_CHANNEL_LABELS, channel) ?? UNKNOWN_SOURCE_LABEL
|
||||
}
|
||||
|
||||
/**
|
||||
* 代理列的供应商名:只查供应商字典。
|
||||
* 传进 LLM 渠道值(`longtaitou`/`t8star`)必须返回占位——这条是"代理行贴龙抬头"的直接判据。
|
||||
*/
|
||||
export function proxySourceLabel(channel: string | null | undefined): string {
|
||||
return known(PROXY_PROVIDER_LABELS, channel) ?? UNKNOWN_SOURCE_LABEL
|
||||
}
|
||||
|
||||
/**
|
||||
* 归一为可选供应商;未知值不猜,返回 null 让调用方保持原选择。
|
||||
*/
|
||||
export function asProxyProvider(raw: unknown): ProxyProviderKey | null {
|
||||
const key = normalizeKey(raw)
|
||||
return key === 'qingguo' || key === 'jikip' ? key : null
|
||||
}
|
||||
|
||||
/**
|
||||
* 代理列的唯一显示文本:后端下发的 `masked`(青果形状 `https://overseas.proxy.qg.net`)。
|
||||
* 刻意**不读** `full`,也不做任何"masked 空就回落到原文"的兜底——回落等于把脱敏前的行为留在界面里。
|
||||
*/
|
||||
export function proxyDisplayText(module: { masked?: string | null } | null | undefined): string {
|
||||
const masked = String(module?.masked ?? '').trim()
|
||||
return masked || UNKNOWN_SOURCE_LABEL
|
||||
}
|
||||
|
||||
/** 代填/改代理的表单草稿:青果用前三个字段,极客用 `link`。 */
|
||||
export interface ProxyEntryDraft {
|
||||
provider: ProxyProviderKey
|
||||
authkey: string
|
||||
authpwd: string
|
||||
link: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 空草稿:`provider` 用后端已登记的那一列预置(只是选中的单选框,不是凭据),
|
||||
* 三个输入位**一律空**——脱敏后没有任何原文可回填。
|
||||
*/
|
||||
export function emptyProxyEntryDraft(currentProvider?: string | null): ProxyEntryDraft {
|
||||
return {
|
||||
provider: asProxyProvider(currentProvider) ?? DEFAULT_PROXY_PROVIDER,
|
||||
authkey: '',
|
||||
authpwd: '',
|
||||
link: '',
|
||||
}
|
||||
}
|
||||
|
||||
/** 与后端 `PROXY_FORMAT_HINT` 同一句口径:本函数只做前置提示,真判仍在服务端。 */
|
||||
const PROXY_LINK_FORMAT_HINT =
|
||||
'代理地址格式不正确,请填写 http://host:port 形式的代理地址,或代理服务商的提取链接(https://...)'
|
||||
|
||||
/** http(s) + 有主机名:镜像后端 `validateProxyValue`,不在前端扩大判死范围。 */
|
||||
function isHttpUrl(raw: string): boolean {
|
||||
try {
|
||||
const parsed = new URL(raw)
|
||||
return (parsed.protocol === 'http:' || parsed.protocol === 'https:') && Boolean(parsed.hostname)
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验草稿,返回给界面显示的文案(空串=可以提交)。
|
||||
* 点名"缺哪把":缺 pwd 时青果回 `API_AUTH_DENY`,所以两把都得填,不能只填 key 就当配好了。
|
||||
*/
|
||||
export function validateProxyEntry(draft: ProxyEntryDraft): string {
|
||||
if (!asProxyProvider(draft.provider)) return '请选择代理供应商'
|
||||
if (draft.provider === 'qingguo') {
|
||||
if (!String(draft.authkey || '').trim()) return '请填写青果 Authkey'
|
||||
if (!String(draft.authpwd || '').trim()) return '请填写青果 Authpwd(只填 Authkey 青果会判鉴权拒绝)'
|
||||
return ''
|
||||
}
|
||||
const link = String(draft.link || '').trim()
|
||||
if (!link) return '请填写极客提取链接'
|
||||
if (!isHttpUrl(link)) return PROXY_LINK_FORMAT_HINT
|
||||
return ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装 PUT `/api/admin/user-secrets/{userId}/modules/proxy` 的请求体。
|
||||
* 不合法返回 null(调用方不得把 null 顶上去,更不得拿旧值凑数)。
|
||||
*/
|
||||
export function buildProxyEntryPayload(
|
||||
draft: ProxyEntryDraft,
|
||||
): { value: string; channel: ProxyProviderKey } | null {
|
||||
if (validateProxyEntry(draft)) return null
|
||||
if (draft.provider === 'qingguo') {
|
||||
return { value: composeQingguoLink(draft.authkey, draft.authpwd), channel: 'qingguo' }
|
||||
}
|
||||
return { value: String(draft.link || '').trim(), channel: 'jikip' }
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ *
|
||||
* 余额侧写(2026-11-05 B83):第四处收口,仍守「两张字典互不相通」那一条。
|
||||
*
|
||||
* LLM 那格的单位是**钱**(人民币=龙抬头站内 ⚡,后端只取 `credits` 块),
|
||||
* 代理那格的 `surplus` 是**次数**、`scope` 说这份量属于谁的池子。
|
||||
* 两者都叫「余额」,混用一张函数就会读出「极客 ¥34」这种既不像钱也不像次的数——
|
||||
* 所以这里各写各的,跨域字段一个都不读,认不出来一律 `—`(同货源标签那条判据)。
|
||||
* ------------------------------------------------------------------ */
|
||||
|
||||
/** 后端 credits 块登记的单位;不是这个值就说明口径换了,宁可不显示也不猜。 */
|
||||
export const LLM_BALANCE_UNIT = 'CREDIT'
|
||||
|
||||
interface LlmBalanceLike {
|
||||
moduleKey?: string | null
|
||||
moduleLabel?: string | null
|
||||
channel?: string | null
|
||||
channelLabel?: string | null
|
||||
available?: boolean | null
|
||||
balance?: string | null
|
||||
availableBalance?: string | null
|
||||
frozen?: string | null
|
||||
unit?: string | null
|
||||
message?: string | null
|
||||
checkedAt?: string | null
|
||||
}
|
||||
|
||||
interface ProxyBalanceLike {
|
||||
available?: boolean | null
|
||||
surplus?: string | null
|
||||
balance?: string | null
|
||||
scope?: string | null
|
||||
message?: string | null
|
||||
}
|
||||
|
||||
/** 一行的显示内容:`text` 进格子,`title` 进悬停(整句原因与取数时刻都在那儿)。 */
|
||||
export interface BalanceLine {
|
||||
text: string
|
||||
title: string
|
||||
}
|
||||
|
||||
const BALANCE_PLACEHOLDER: BalanceLine = { text: UNKNOWN_SOURCE_LABEL, title: '本轮没取到数(不是余额为 0)' }
|
||||
const BALANCE_PENDING: BalanceLine = { text: '查询中…', title: '余额按实时查询,不落库' }
|
||||
|
||||
/** 人民币读数:解析不出数字时原样回显,不返回 `¥0`(一格 0 会被读成「没钱了」)。 */
|
||||
export function formatYuan(raw: string | null | undefined): string {
|
||||
const text = String(raw ?? '').trim()
|
||||
if (!text) return ''
|
||||
const value = Number(text.replace(/,/g, ''))
|
||||
if (!Number.isFinite(value)) return text
|
||||
return `¥${value.toFixed(2)}`
|
||||
}
|
||||
|
||||
function llmDetail(cell: LlmBalanceLike): string {
|
||||
const parts: string[] = []
|
||||
if (cell.moduleLabel) parts.push(String(cell.moduleLabel))
|
||||
const total = formatYuan(cell.balance)
|
||||
const usable = formatYuan(cell.availableBalance)
|
||||
const frozen = formatYuan(cell.frozen)
|
||||
if (total) parts.push(`总 ${total}`)
|
||||
if (usable) parts.push(`可用 ${usable}`)
|
||||
if (frozen) parts.push(`预冻结 ${frozen}`)
|
||||
if (cell.checkedAt) parts.push(`取数于 ${String(cell.checkedAt).replace('T', ' ').slice(0, 16)}`)
|
||||
const message = String(cell.message ?? '').trim()
|
||||
if (message) parts.push(message)
|
||||
return parts.join(';') || '暂无余额信息'
|
||||
}
|
||||
|
||||
/**
|
||||
* LLM 余额列:一把密钥一行,前缀是**渠道名**(钱挂在渠道账户上,不在模块上)。
|
||||
*
|
||||
* `pending=true` ⇒ 这一轮还在取数;取到但不合格(单位不是 CREDIT/available=false)
|
||||
* 一律走占位与后端原文,不显示金额。
|
||||
*/
|
||||
export function llmBalanceLine(cell: LlmBalanceLike | null | undefined, pending = false): BalanceLine {
|
||||
if (pending && !cell) return BALANCE_PENDING
|
||||
if (!cell) return BALANCE_PLACEHOLDER
|
||||
const label = known(LLM_CHANNEL_LABELS, cell.channel) ?? UNKNOWN_SOURCE_LABEL
|
||||
// 渠道认不出(LLM 列被喂了供应商名这类跨域值)时整格给占位:宁可什么都不显示,
|
||||
// 也不让一个不知道属于谁的数字或句子进界面(同货源标签那张表「跨域一律 —」的判据)
|
||||
if (label === UNKNOWN_SOURCE_LABEL) {
|
||||
return { text: UNKNOWN_SOURCE_LABEL, title: `${llmDetail(cell)}|渠道值认不出,未显示金额` }
|
||||
}
|
||||
if (!cell.available || String(cell.unit ?? '').trim().toUpperCase() !== LLM_BALANCE_UNIT) {
|
||||
const message = String(cell.message ?? '').trim()
|
||||
return { text: message ? `${label} 查不到` : `${label} ${UNKNOWN_SOURCE_LABEL}`, title: llmDetail(cell) }
|
||||
}
|
||||
const total = formatYuan(cell.balance)
|
||||
if (!total) return { text: `${label} ${UNKNOWN_SOURCE_LABEL}`, title: llmDetail(cell) }
|
||||
return { text: `${label} ${total}`, title: llmDetail(cell) }
|
||||
}
|
||||
|
||||
/**
|
||||
* LLM 余额列的整格内容:**按渠道折叠**,一个渠道一行。
|
||||
*
|
||||
* 钱挂在渠道账户上、不挂在模块上:两把密钥(外观专利/货源查询)都在龙抬头时,
|
||||
* 上游回的是同一个余额——排两遍会读成「这个账户有两笔钱」。折叠后 title 里仍留每一把的原文,
|
||||
* 运维要判「是哪把密钥的渠道」看得回来。
|
||||
*/
|
||||
export function llmBalanceLines(
|
||||
cells: Array<LlmBalanceLike | null | undefined> | null | undefined,
|
||||
pending = false,
|
||||
): BalanceLine[] {
|
||||
const list = (cells ?? []).filter((cell): cell is LlmBalanceLike => Boolean(cell))
|
||||
if (!list.length) return pending ? [BALANCE_PENDING] : []
|
||||
const grouped = new Map<string, BalanceLine>()
|
||||
for (const cell of list) {
|
||||
const key = normalizeKey(cell.channel) || 'unknown'
|
||||
const line = llmBalanceLine(cell, pending)
|
||||
const hit = grouped.get(key)
|
||||
grouped.set(key, hit ? { text: hit.text, title: `${hit.title}|${line.title}` } : line)
|
||||
}
|
||||
return [...grouped.values()]
|
||||
}
|
||||
|
||||
/** 代理池子的归属说法:platform 那份是**平台的钱**,绝不允许被读成这个用户的余量。 */
|
||||
const PROXY_SCOPE_LABELS: Record<string, string> = {
|
||||
user: '你的套餐',
|
||||
platform: '平台池',
|
||||
none: '查不了',
|
||||
}
|
||||
|
||||
/**
|
||||
* 代理余量列:极客给「剩余 IP 次数」(单位是次、不是钱);青果按 scope=none 说查不了。
|
||||
* `scope` 认不出来时不硬认(回落「来源未标注」并保留原值进 title 供运维核)。
|
||||
*/
|
||||
export function proxyBalanceLine(cell: ProxyBalanceLike | null | undefined, pending = false): BalanceLine {
|
||||
if (pending && !cell) return BALANCE_PENDING
|
||||
if (!cell) return BALANCE_PLACEHOLDER
|
||||
const scopeKey = normalizeKey(cell.scope)
|
||||
const scopeLabel = Object.prototype.hasOwnProperty.call(PROXY_SCOPE_LABELS, scopeKey)
|
||||
? PROXY_SCOPE_LABELS[scopeKey]
|
||||
: '来源未标注'
|
||||
const message = String(cell.message ?? '').trim()
|
||||
const detailParts = [`${scopeLabel}`]
|
||||
const surplus = String(cell.surplus ?? '').trim()
|
||||
const amount = String(cell.balance ?? '').trim()
|
||||
if (surplus) detailParts.push(`剩余 IP ${surplus}`)
|
||||
if (amount) detailParts.push(`账户余额 ${amount}`)
|
||||
if (message) detailParts.push(message)
|
||||
const title = detailParts.join(';') || '暂无余量信息'
|
||||
if (!cell.available) {
|
||||
// 后端那句原文(「青果不提供余量查询…」「上游未在预算内应答…」)全在 title 里;
|
||||
// 格子只说「查不了」——留 `—` 会被读成「这人没配代理」,那是另一件事。
|
||||
return { text: message ? '查不了' : `${scopeLabel} ${UNKNOWN_SOURCE_LABEL}`, title }
|
||||
}
|
||||
// 次数就是次数:这里不套 ¥ 符号、不换算,读数带「次」把单位写在格子里
|
||||
return { text: `${scopeLabel} ${surplus || UNKNOWN_SOURCE_LABEL} 次`, title }
|
||||
}
|
||||
@@ -14,13 +14,7 @@ export interface UserFilterState {
|
||||
}
|
||||
|
||||
export function createUserFilterState(): UserFilterState {
|
||||
return {
|
||||
keyword: '',
|
||||
createdByAdminId: null,
|
||||
role: '',
|
||||
page: USER_PAGE_MIN_PAGE,
|
||||
pageSize: USER_PAGE_DEFAULT_SIZE,
|
||||
}
|
||||
return { keyword: '', createdByAdminId: null, role: '', page: USER_PAGE_MIN_PAGE, pageSize: USER_PAGE_DEFAULT_SIZE }
|
||||
}
|
||||
|
||||
/** 修改筛选条件时重置回第一页(避免停在可能越界的旧页)。 */
|
||||
|
||||
@@ -1,30 +1,25 @@
|
||||
<script setup lang="ts">
|
||||
import BatchDeleteActions from '@/components/BatchDeleteActions.vue'
|
||||
import BatchDeleteCheckbox from '@/components/BatchDeleteCheckbox.vue'
|
||||
import { useRowSelection } from '@/utils/use-row-selection'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
/** 品牌数据库(不符合ASIN)页 · 像素复刻旧版 admin.html panel-invalid-asin-data(自绘:面板头+新增、筛选、旧式表格/分页、原生 confirm 删除)。
|
||||
* 全平台一份黑名单:分组是行上的归类标签,对任何角色都不构成可见性边界(2026-10-07 定档)。
|
||||
* 弹窗保留现有组件。 */
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
* script 逻辑沿用现有 Vue 实现(分组锁定/来源 AUTO 编辑隐藏分组);弹窗保留现有组件。 */
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { createInvalidAsin, deleteInvalidAsin, fetchInvalidAsinGroupOptions, fetchInvalidAsinPage, updateInvalidAsin } from '../invalidasin/invalid-asin-api.ts'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { createInvalidAsin, deleteInvalidAsin, fetchInvalidAsinPage, updateInvalidAsin } from '../invalidasin/invalid-asin-api.ts'
|
||||
import type { InvalidAsinItem } from '../invalidasin/invalid-asin-model.ts'
|
||||
import { invalidAsinDeleteText, recordSourceLabel } from '../invalidasin/invalid-asin-model.ts'
|
||||
import { invalidAsinDeleteText, invalidAsinLockedGroupId, recordSourceLabel } from '../invalidasin/invalid-asin-model.ts'
|
||||
import { createEmptyInvalidAsinForm, invalidAsinFormFromItem, validateInvalidAsinForm } from '../invalidasin/invalid-asin-form-model.ts'
|
||||
import { fetchShopManageGroups } from '../shop/shop-manage-api.ts'
|
||||
import type { ShopGroupOption } from '../shop/shop-dto.ts'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||||
|
||||
const session = useAdminSessionStore()
|
||||
const loading = ref(false)
|
||||
const loadFailure = ref('')
|
||||
const rows = ref<InvalidAsinItem[]>([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const groupOptions = ref<ShopGroupOption[]>([])
|
||||
const groups = ref<ShopGroupOption[]>([])
|
||||
const jumpPage = ref('')
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||
|
||||
@@ -32,22 +27,35 @@ const filter = reactive({ dataValue: '', brand: '', groupId: null as number | nu
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const editingId = ref<number | null>(null)
|
||||
/** 当前编辑行来源:自动导入(AUTO)记录不在此页改分组。 */
|
||||
/** 当前编辑行来源:自动导入(AUTO)记录不可改分组。 */
|
||||
const editingSource = ref('')
|
||||
const saving = ref(false)
|
||||
const form = reactive(createEmptyInvalidAsinForm())
|
||||
|
||||
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
||||
/** 非超管锁定的分组 id(对齐 admin.js getInvalidAsinDataLockedGroupId);超管为 null。 */
|
||||
const lockedGroupId = computed(() => invalidAsinLockedGroupId(groups.value, null, session.user?.role || ''))
|
||||
/** 分组下拉可用选项:超管全量,非超管仅锁定分组。 */
|
||||
const groupOptions = computed<ShopGroupOption[]>(() => {
|
||||
if (isSuperAdmin.value) return groups.value
|
||||
const locked = lockedGroupId.value
|
||||
return locked == null ? [] : groups.value.filter((group) => group.id === locked)
|
||||
})
|
||||
|
||||
async function loadGroups() {
|
||||
try {
|
||||
groupOptions.value = await fetchInvalidAsinGroupOptions()
|
||||
groups.value = await fetchShopManageGroups()
|
||||
} catch {
|
||||
groupOptions.value = []
|
||||
groups.value = []
|
||||
}
|
||||
// 非超管:筛选强制锁定到本人分组(与参考 refreshShopGroupSelects 的锁定语义一致)。
|
||||
if (!isSuperAdmin.value && lockedGroupId.value != null) {
|
||||
filter.groupId = lockedGroupId.value
|
||||
}
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
loadFailure.value = ''
|
||||
try {
|
||||
const result = await fetchInvalidAsinPage({
|
||||
page: page.value,
|
||||
@@ -60,8 +68,7 @@ async function load() {
|
||||
total.value = result.total
|
||||
page.value = result.page
|
||||
} catch (error) {
|
||||
loadFailure.value = error instanceof Error ? error.message : '数据加载失败'
|
||||
showAdminFeedback(loadFailure.value, 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '数据加载失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@@ -98,6 +105,10 @@ function openCreate() {
|
||||
editingId.value = null
|
||||
editingSource.value = ''
|
||||
Object.assign(form, createEmptyInvalidAsinForm())
|
||||
// 非超管新增预置锁定分组(下拉同时被禁用)。
|
||||
if (!isSuperAdmin.value && lockedGroupId.value != null) {
|
||||
form.groupId = lockedGroupId.value
|
||||
}
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
@@ -127,35 +138,28 @@ async function submit() {
|
||||
dialogVisible.value = false
|
||||
load()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '保存失败', 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '保存失败')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const batch = useRowSelection({
|
||||
pageRows: () => rows.value,
|
||||
rowId: (row) => row.id,
|
||||
rowLabel: (row) => row.dataValue,
|
||||
deleteOne: (id) => deleteInvalidAsin(id),
|
||||
refresh: load,
|
||||
blocked: () => loading.value || !!loadFailure.value,
|
||||
})
|
||||
|
||||
async function remove(row: InvalidAsinItem) {
|
||||
if (batch.busy) return
|
||||
// 对齐旧版:原生 confirm。
|
||||
if (!(await openAdminConfirm({ message: invalidAsinDeleteText(row), danger: true }))) return
|
||||
if (!window.confirm(invalidAsinDeleteText(row))) return
|
||||
try {
|
||||
await deleteInvalidAsin(row.id)
|
||||
batch.removeFromSelection(row.id)
|
||||
ElMessage.success('已删除')
|
||||
load()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||
}
|
||||
}
|
||||
|
||||
watch(isSuperAdmin, () => {
|
||||
if (isSuperAdmin.value) filter.groupId = null
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
loadGroups()
|
||||
load()
|
||||
@@ -171,50 +175,39 @@ onMounted(() => {
|
||||
</div>
|
||||
|
||||
<div class="form-row invalid-filter-row">
|
||||
<div class="form-group">
|
||||
<label for="invalid-asin-filter">ASIN</label>
|
||||
<input id="invalid-asin-filter" v-model="filter.dataValue" type="text" placeholder="输入 ASIN" @keyup.enter="apply" />
|
||||
<div class="form-group" style="min-width: 200px">
|
||||
<label>ASIN</label>
|
||||
<input v-model="filter.dataValue" type="text" placeholder="输入 ASIN" @keyup.enter="apply" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="invalid-brand-filter">品牌</label>
|
||||
<input id="invalid-brand-filter" v-model="filter.brand" type="text" placeholder="输入品牌" @keyup.enter="apply" />
|
||||
<div class="form-group" style="min-width: 200px">
|
||||
<label>品牌</label>
|
||||
<input v-model="filter.brand" type="text" placeholder="输入品牌" @keyup.enter="apply" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="invalid-group-filter">分组</label>
|
||||
<el-select id="invalid-group-filter" v-model="filter.groupId" class="admin-filter" filterable clearable placeholder="全部分组">
|
||||
<div class="form-group" style="min-width: 180px">
|
||||
<label>分组</label>
|
||||
<el-select v-model="filter.groupId" class="admin-filter" filterable clearable placeholder="全部分组" :disabled="!isSuperAdmin">
|
||||
<el-option v-for="group in groupOptions" :key="group.id" :label="group.groupName" :value="group.id" />
|
||||
</el-select>
|
||||
</div>
|
||||
<button class="btn" type="button" @click="apply">查询</button>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<div class="table-scroll invalid-asin-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="batch-delete-cell" scope="col">
|
||||
<BatchDeleteCheckbox label="全选当前页可删除记录" :checked="batch.pageAll" :partial="batch.pageSome"
|
||||
:disabled="batch.disabled || batch.pageEmpty" @change="batch.togglePage" />
|
||||
</th>
|
||||
<th style="width: 70px">ID</th>
|
||||
<th style="width: 170px">ASIN</th>
|
||||
<th style="width: 150px">品牌</th>
|
||||
<th style="width: 140px">分组</th>
|
||||
<th style="width: 110px">来源</th>
|
||||
<th style="width: 170px">创建时间</th>
|
||||
<th style="width: 170px">更新时间</th>
|
||||
<th style="width: 150px">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-if="rows.length">
|
||||
<tr v-for="row in rows" :key="row.id" :class="{ 'batch-selected': batch.isSelected(row) }">
|
||||
<td class="batch-delete-cell">
|
||||
<BatchDeleteCheckbox :label="batch.reason(row) || `选择 ${batch.label(row)}`" :checked="batch.isSelected(row)"
|
||||
:disabled="batch.disabled || !!batch.reason(row)" @change="batch.toggle(row)" />
|
||||
</td>
|
||||
<tr v-for="row in rows" :key="row.id">
|
||||
<td>{{ row.id }}</td>
|
||||
<td class="mono-cell">{{ row.dataValue }}</td>
|
||||
<td>{{ row.brand || '—' }}</td>
|
||||
@@ -225,18 +218,17 @@ onMounted(() => {
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ formatDateTime(row.createdAt) }}</td>
|
||||
<td>{{ formatDateTime(row.updatedAt) }}</td>
|
||||
<td class="ops-cell">
|
||||
<button class="btn btn-sm" type="button" @click="openEdit(row)">编辑</button>
|
||||
<button class="btn btn-sm btn-danger" type="button" :disabled="batch.busy" @click="remove(row)">删除</button>
|
||||
<button class="btn btn-sm btn-danger" type="button" @click="remove(row)">删除</button>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-else-if="loading">
|
||||
<td colspan="9" class="empty-tip">加载中...</td>
|
||||
<td colspan="7" class="empty-tip">加载中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td colspan="9" class="empty-tip">暂无数据</td>
|
||||
<td colspan="7" class="empty-tip">暂无数据</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -253,7 +245,7 @@ onMounted(() => {
|
||||
<el-input v-model="form.brand" placeholder="可选" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="editingId == null || editingSource.toUpperCase() !== 'AUTO'" label="分组" required>
|
||||
<el-select v-model="form.groupId" placeholder="选择分组" filterable>
|
||||
<el-select v-model="form.groupId" placeholder="选择分组" filterable :disabled="!isSuperAdmin">
|
||||
<el-option v-for="group in groupOptions" :key="group.id" :label="group.groupName" :value="group.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -293,7 +285,7 @@ h3 {
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 10px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.form-row {
|
||||
display: flex;
|
||||
@@ -308,17 +300,13 @@ h3 {
|
||||
gap: 7px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.invalid-filter-row > .form-group {
|
||||
flex: 0 1 190px;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
.form-group label {
|
||||
color: #5b6f83;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input {
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
@@ -332,10 +320,12 @@ h3 {
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover {
|
||||
.form-group input:hover,
|
||||
.form-group select:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus {
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
@@ -440,7 +430,6 @@ h3 {
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
white-space: nowrap;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
|
||||
@@ -1,348 +0,0 @@
|
||||
/* 像素复刻旧版 admin.html panel-dedupe-total-data(蓝白末层样式)。 */
|
||||
.dedupe-view {
|
||||
font-family: inherit;
|
||||
color: var(--c-text, #24384d);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 18px;
|
||||
}
|
||||
.form-box,
|
||||
.panel-box {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 20px 22px 24px;
|
||||
border: 1px solid #d8e3ee;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(145deg, #ffffff, #f9fbfd);
|
||||
box-shadow: 0 1px 2px rgba(39, 67, 94, 0.04), 0 14px 30px -24px rgba(39, 67, 94, 0.28);
|
||||
}
|
||||
h3 {
|
||||
margin: 0 0 16px;
|
||||
font-size: 15px;
|
||||
font-weight: 650;
|
||||
color: #24384d;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
.dedupe-panel-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.dedupe-panel-head h3 {
|
||||
margin: 0;
|
||||
}
|
||||
.dedupe-head-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.dedupe-filter-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(160px, 1fr)) auto;
|
||||
gap: 12px;
|
||||
align-items: end;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.dedupe-filter-row .form-group {
|
||||
min-width: 0;
|
||||
}
|
||||
.dedupe-filter-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.dedupe-filter-date-row {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: flex-end;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.dedupe-filter-date-row .form-group {
|
||||
flex: 0 0 200px;
|
||||
min-width: 0;
|
||||
}
|
||||
.dedupe-filter-date-row .dedupe-filter-actions {
|
||||
margin-left: auto;
|
||||
}
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 7px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.form-group label {
|
||||
color: #5b6f83;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
/* 下拉壳由全局 .el-select.admin-filter(main.css:42px/9px 圆角/#f8fbfd 浅底/focus ring)出,
|
||||
与亚马逊面同一套;这里只留 input 的原生壳规则(2026-11-17 原生 select 全换 el-select)。 */
|
||||
.form-group input {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 9px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13.5px;
|
||||
font-family: inherit;
|
||||
color-scheme: light;
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
}
|
||||
.form-group input[type="file"] {
|
||||
background: #ffffff;
|
||||
padding: 6px 10px;
|
||||
}
|
||||
.form-group input[type="date"] {
|
||||
color-scheme: light;
|
||||
}
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
min-height: 42px;
|
||||
padding: 9px 18px;
|
||||
border: 1px solid #4f78a5;
|
||||
border-radius: 9px;
|
||||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
||||
color: #ffffff;
|
||||
font-family: inherit;
|
||||
font-size: 13.5px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 8px 18px -14px rgba(79, 120, 165, 0.72);
|
||||
transition: background 160ms ease, box-shadow 160ms ease, transform 120ms ease;
|
||||
}
|
||||
.btn:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #7094ba, #5d83ac);
|
||||
box-shadow: 0 11px 22px -14px rgba(79, 120, 165, 0.8);
|
||||
}
|
||||
.btn:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.6;
|
||||
}
|
||||
.btn-secondary {
|
||||
background: #ffffff;
|
||||
color: #5b6f83;
|
||||
border-color: #c7d7e5;
|
||||
}
|
||||
.btn-secondary:hover:not(:disabled) {
|
||||
color: #2f5d8b;
|
||||
border-color: #95b1cb;
|
||||
background: #edf5fb;
|
||||
}
|
||||
.btn-danger {
|
||||
background: linear-gradient(135deg, #c06d77, #b35f6a);
|
||||
border-color: #b35f6a;
|
||||
}
|
||||
.btn-danger:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #cb7c84, #b96570);
|
||||
}
|
||||
.btn-sm {
|
||||
min-height: 36px;
|
||||
padding: 7px 12px;
|
||||
}
|
||||
.table-scroll {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
overflow-x: auto;
|
||||
border: 1px solid #dbe5ee;
|
||||
border-radius: 10px;
|
||||
background: #ffffff;
|
||||
}
|
||||
.table-scroll table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
table-layout: fixed;
|
||||
}
|
||||
.dedupe-table-scroll > table {
|
||||
min-width: 900px;
|
||||
}
|
||||
.table-scroll th,
|
||||
.table-scroll td {
|
||||
padding: 10px 12px;
|
||||
text-align: left;
|
||||
font-size: 13.5px;
|
||||
line-height: 1.5;
|
||||
border-bottom: 1px solid #e0e8ef;
|
||||
vertical-align: middle;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.table-scroll th {
|
||||
background: #edf4fa;
|
||||
color: #4e6479;
|
||||
border-bottom-color: #d5e1eb;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.4px;
|
||||
}
|
||||
.table-scroll tbody tr:hover td {
|
||||
background: #f1f7fb;
|
||||
}
|
||||
.table-scroll tbody tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.mono-cell {
|
||||
font-family: "Cascadia Mono", "SF Mono", Consolas, "Courier New", monospace;
|
||||
font-size: 12.5px;
|
||||
}
|
||||
.ops-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
white-space: nowrap;
|
||||
text-align: right;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
padding: 44px 24px;
|
||||
text-align: center;
|
||||
color: #8293a5;
|
||||
font-size: 13.5px;
|
||||
}
|
||||
.pagination {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-top: 18px;
|
||||
color: #5b6f83;
|
||||
font-size: 13px;
|
||||
}
|
||||
.pagination button {
|
||||
min-height: 30px;
|
||||
padding: 4px 12px;
|
||||
border: 1px solid #c7d7e5;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
color: #5b6f83;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.pagination button:hover:not(:disabled) {
|
||||
background: #edf5fb;
|
||||
border-color: #95b1cb;
|
||||
color: #2f5d8b;
|
||||
}
|
||||
.pagination button:disabled {
|
||||
background: #eef3f7;
|
||||
color: #9baaba;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.page-total {
|
||||
margin-right: 4px;
|
||||
}
|
||||
.page-jump {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.page-jump input {
|
||||
width: 56px;
|
||||
min-height: 30px;
|
||||
padding: 4px 8px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 8px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
}
|
||||
.modal-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 3000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40px 20px;
|
||||
background: rgba(45, 66, 86, 0.36);
|
||||
backdrop-filter: blur(6px);
|
||||
}
|
||||
.modal {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: min(560px, 100%);
|
||||
max-height: 84vh;
|
||||
padding: 22px 24px;
|
||||
border: 1px solid #c7d7e5;
|
||||
border-radius: 14px;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 22px 60px rgba(39, 67, 94, 0.2);
|
||||
overflow-y: auto;
|
||||
}
|
||||
.modal .form-group {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.modal-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
.progress-wrap {
|
||||
margin-top: 12px;
|
||||
}
|
||||
.progress-text {
|
||||
font-size: 12.5px;
|
||||
color: #5b6f83;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.dedupe-export-wait-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 3100;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(45, 66, 86, 0.36);
|
||||
backdrop-filter: blur(6px);
|
||||
}
|
||||
.dedupe-export-wait {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 22px 28px;
|
||||
border: 1px solid #c7d7e5;
|
||||
border-radius: 14px;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 22px 60px rgba(39, 67, 94, 0.2);
|
||||
}
|
||||
.request-spinner {
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
flex: none;
|
||||
border: 3px solid #d5e3ef;
|
||||
border-top-color: #5f85ad;
|
||||
border-radius: 50%;
|
||||
animation: dedupe-spin 0.9s linear infinite;
|
||||
}
|
||||
@keyframes dedupe-spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
.dedupe-export-wait-title {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #24384d;
|
||||
}
|
||||
.dedupe-export-wait-detail {
|
||||
margin-top: 4px;
|
||||
font-size: 12.5px;
|
||||
color: #5b6f83;
|
||||
}
|
||||
@@ -1,12 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import BatchDeleteActions from '@/components/BatchDeleteActions.vue'
|
||||
import BatchDeleteCheckbox from '@/components/BatchDeleteCheckbox.vue'
|
||||
import { useRowSelection } from '@/utils/use-row-selection'
|
||||
import { createLatestRequestGate } from '@/utils/latest-request'
|
||||
import { formatDateTime, orderedPair } from '@/utils/datetime'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
/** 数据去重总数据(registry) · 像素复刻旧版 admin.html panel-dedupe-total-data(自绘:分组摘要 + 双行筛选 + 旧式表格/分页 + 编辑/导入弹窗 + 导出等待遮罩)。
|
||||
* script 逻辑沿用现有 Vue 实现(查询/编辑/删除/导入轮询/导出秒表)。 */
|
||||
import { computed, onMounted, onUnmounted, reactive, ref, watch } from 'vue'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import {
|
||||
fetchDedupeTotalList,
|
||||
@@ -28,44 +24,15 @@ import { importOutcomeText, importTaskFinished, isAllowedImportFile } from './de
|
||||
import type { DedupeImportProgress } from './dedupe-import-model.ts'
|
||||
import { toExportUrl } from './dedupe-total-export.ts'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { loadFailureMessage } from '@/components/load-failure-model'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||||
|
||||
const session = useAdminSessionStore()
|
||||
const companyTab = useCompanyTabStore()
|
||||
/** 仅超管需要分组维度:非超管数据由后端裁剪到本人分组,分组筛选/列一律不展示。 */
|
||||
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
||||
|
||||
const loading = ref(false)
|
||||
const loadFailure = ref('')
|
||||
const rows = ref<DedupeTotalItem[]>([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(10)
|
||||
/** 本页是累计台账,日期初值故意留空(默认当天会让首屏只剩今天新增的 ASIN);见 date-filter-default-today 护栏的 EXEMPT。 */
|
||||
const filter = reactive(createDedupeTotalFilterState())
|
||||
/** min/max 挡不住手输,落值后把倒挂的起止交换回来。 */
|
||||
function clampDatePair(): void {
|
||||
const [s, e] = orderedPair(filter.startDate, filter.endDate)
|
||||
filter.startDate = s
|
||||
filter.endDate = e
|
||||
}
|
||||
|
||||
const groups = ref<DedupeGroupOption[]>([])
|
||||
/** 非超管仅有一个可访问分组时,编辑/导入弹窗分组选择锁定为该组(保留展示、不可改)。 */
|
||||
const lockedGroupId = computed<number | null>(() => {
|
||||
if (isSuperAdmin.value) return null
|
||||
return groups.value.length === 1 ? groups.value[0].id : null
|
||||
})
|
||||
const jumpPage = ref('')
|
||||
/** 顺序翻页游标:上一页响应给的 nextLastId;仅在"下一页"时使用,跳页/筛选时清空走 OFFSET。 */
|
||||
const pageCursor = ref<number | null>(null)
|
||||
/** 本次请求实际使用的游标(load 时决定) */
|
||||
let pendingCursor: number | null = null
|
||||
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||
|
||||
@@ -74,10 +41,6 @@ const editSaving = ref(false)
|
||||
const editTarget = ref<DedupeTotalItem | null>(null)
|
||||
const editValue = ref('')
|
||||
const editGroupId = ref<number | null>(null)
|
||||
/** 弹窗分组下拉的清空回填值:EP 的 el-select 默认清空写 undefined,会破 editGroupId/importGroupId
|
||||
* 的 `number | null` 契约(下游 saveEdit/importValid 按假值判「未选」、updateDedupeTotal 的入参是 number)
|
||||
* ⇒ 清空一律钉回 null,与旧原生 select 空行(value=null)同语义。 */
|
||||
const nullOnClear = (): null => null
|
||||
|
||||
type ImportMode = 'add' | 'delete'
|
||||
const importVisible = ref(false)
|
||||
@@ -92,8 +55,6 @@ const exporting = ref(false)
|
||||
const exportWaitVisible = ref(false)
|
||||
const exportWaitSeconds = ref(0)
|
||||
let exportWaitTimer: ReturnType<typeof setInterval> | null = null
|
||||
/** 页面已卸载:导入轮询的下一拍不再发请求(离开页面后不该再挂 5 分钟的节拍)。 */
|
||||
let pageDisposed = false
|
||||
|
||||
function startExportWait(): void {
|
||||
exportWaitSeconds.value = 0
|
||||
@@ -111,43 +72,27 @@ function stopExportWait(): void {
|
||||
exportWaitVisible.value = false
|
||||
}
|
||||
|
||||
const batchListGate = createLatestRequestGate()
|
||||
|
||||
async function load(): Promise<void> {
|
||||
const token = batchListGate.begin()
|
||||
loading.value = true
|
||||
loadFailure.value = ''
|
||||
try {
|
||||
const result = await fetchDedupeTotalList(
|
||||
toDedupeListParams(filter, page.value, pageSize.value, pendingCursor, companyTab.requestCompanyId),
|
||||
)
|
||||
if (!batchListGate.isCurrent(token)) return
|
||||
const result = await fetchDedupeTotalList(toDedupeListParams(filter, page.value, pageSize.value))
|
||||
rows.value = result.items
|
||||
total.value = result.total
|
||||
if (result.page >= 1) page.value = result.page
|
||||
// 本页响应回传的游标留作"下一页"用;空页则清空(没有更多)
|
||||
pageCursor.value = result.nextLastId ?? null
|
||||
pendingCursor = null
|
||||
} catch (error) {
|
||||
if (!batchListGate.isCurrent(token)) return
|
||||
loadFailure.value = loadFailureMessage(error, '去重数据加载失败')
|
||||
showAdminFeedback(loadFailure.value, 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '去重数据加载失败')
|
||||
} finally {
|
||||
if (batchListGate.isCurrent(token)) loading.value = false
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function apply(): void {
|
||||
page.value = 1
|
||||
pageCursor.value = null
|
||||
pendingCursor = null
|
||||
void load()
|
||||
}
|
||||
|
||||
function changePage(next: number): void {
|
||||
if (next < 1 || next > totalPages.value) return
|
||||
// 只有"顺序下一页"用 keyset 游标(避免深分页 offset);跳页/回退走 OFFSET,行为不变
|
||||
pendingCursor = next === page.value + 1 ? pageCursor.value : null
|
||||
page.value = next
|
||||
void load()
|
||||
}
|
||||
@@ -164,15 +109,13 @@ function goJump(): void {
|
||||
function changeSize(size: number) {
|
||||
pageSize.value = size
|
||||
page.value = 1
|
||||
pageCursor.value = null
|
||||
pendingCursor = null
|
||||
void load()
|
||||
}
|
||||
|
||||
function openEdit(row: DedupeTotalItem): void {
|
||||
editTarget.value = row
|
||||
editValue.value = row.dataValue
|
||||
editGroupId.value = row.groupId ?? lockedGroupId.value
|
||||
editGroupId.value = row.groupId
|
||||
editVisible.value = true
|
||||
}
|
||||
|
||||
@@ -195,38 +138,26 @@ async function saveEdit(): Promise<void> {
|
||||
ElMessage.success('保存成功')
|
||||
await load()
|
||||
} catch (error) {
|
||||
showAdminFeedback(loadFailureMessage(error, '保存失败'), 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '保存失败')
|
||||
} finally {
|
||||
editSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const batch = useRowSelection({
|
||||
pageRows: () => rows.value,
|
||||
rowId: (row) => row.id,
|
||||
rowLabel: (row) => row.dataValue,
|
||||
deleteOne: (id) => deleteDedupeTotal(id),
|
||||
refresh: load,
|
||||
blocked: () => loading.value || !!loadFailure.value,
|
||||
scope: () => companyTab.activeId,
|
||||
})
|
||||
|
||||
async function removeRow(row: DedupeTotalItem): Promise<void> {
|
||||
if (batch.busy) return
|
||||
// 对齐旧版:浏览器原生 confirm 确认后删除。
|
||||
if (!(await openAdminConfirm({ message: `确定删除总数据“${row.dataValue}”吗?`, danger: true }))) return
|
||||
if (!window.confirm(`确定删除总数据“${row.dataValue}”吗?`)) return
|
||||
try {
|
||||
await deleteDedupeTotal(row.id)
|
||||
batch.removeFromSelection(row.id)
|
||||
ElMessage.success('删除成功')
|
||||
await load()
|
||||
} catch (error) {
|
||||
showAdminFeedback(loadFailureMessage(error, '删除失败'), 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||
}
|
||||
}
|
||||
|
||||
function resetImport(): void {
|
||||
importGroupId.value = lockedGroupId.value
|
||||
importGroupId.value = null
|
||||
importFile.value = null
|
||||
importProgress.value = ''
|
||||
importRunning.value = false
|
||||
@@ -271,7 +202,6 @@ function sleep(ms: number): Promise<void> {
|
||||
|
||||
async function pollImport(poll: () => Promise<DedupeImportProgress>): Promise<DedupeImportProgress> {
|
||||
for (let i = 0; i < 300; i += 1) {
|
||||
if (pageDisposed) throw new Error('页面已离开,导入进度停止跟踪')
|
||||
const progress = await poll()
|
||||
importProgress.value = importOutcomeText(progress)
|
||||
if (importTaskFinished(progress)) return progress
|
||||
@@ -285,16 +215,14 @@ async function submitImport(): Promise<void> {
|
||||
const file = importFile.value as File
|
||||
const groupId = importGroupId.value as number
|
||||
if (importMode.value === 'delete') {
|
||||
if (!(await openAdminConfirm({ message: '确定按 Excel 中的 ASIN 批量删除匹配的总数据吗?', danger: true }))) return
|
||||
if (!window.confirm('确定按 Excel 中的 ASIN 批量删除匹配的总数据吗?')) return
|
||||
}
|
||||
const mode = importMode.value
|
||||
importRunning.value = true
|
||||
importProgress.value = mode === 'add' ? '正在上传并解析文件…' : '正在上传删除清单…'
|
||||
try {
|
||||
const started =
|
||||
mode === 'add'
|
||||
? await startDedupeImport(file, groupId, companyTab.requestCompanyId)
|
||||
: await startDedupeDeleteImport(file, groupId, companyTab.requestCompanyId)
|
||||
mode === 'add' ? await startDedupeImport(file, groupId) : await startDedupeDeleteImport(file, groupId)
|
||||
const poll = mode === 'add' ? () => fetchDedupeImportProgress(started) : () => fetchDedupeDeleteImportProgress(started)
|
||||
const finished = await pollImport(poll)
|
||||
importVisible.value = false
|
||||
@@ -303,22 +231,27 @@ async function submitImport(): Promise<void> {
|
||||
ElMessage.success(mode === 'add' ? '导入完成' : '删除导入完成')
|
||||
await load()
|
||||
} else {
|
||||
showAdminFeedback(importOutcomeText(finished), 'error')
|
||||
ElMessage.error(importOutcomeText(finished))
|
||||
}
|
||||
} catch (error) {
|
||||
showAdminFeedback(loadFailureMessage(error, '导入失败'), 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '导入失败')
|
||||
} finally {
|
||||
importRunning.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function doExport(): Promise<void> {
|
||||
const { startDate, endDate } = filter
|
||||
if (startDate && endDate && startDate > endDate) {
|
||||
ElMessage.warning('开始日期不能晚于结束日期')
|
||||
return
|
||||
}
|
||||
if (exporting.value) return
|
||||
exporting.value = true
|
||||
startExportWait()
|
||||
try {
|
||||
// 对齐 admin.js:fetch 流式下载,带筛选参数;失败响应(JSON)解析错误提示。
|
||||
const response = await window.fetch(toExportUrl(filter, companyTab.requestCompanyId), { credentials: 'include' })
|
||||
const response = await window.fetch(toExportUrl(filter), { credentials: 'include' })
|
||||
const contentType = response.headers.get('content-type') || ''
|
||||
if (!response.ok || contentType.includes('application/json')) {
|
||||
const body = (await response.json().catch(() => ({}))) as { error?: string; message?: string; msg?: string }
|
||||
@@ -338,35 +271,18 @@ async function doExport(): Promise<void> {
|
||||
URL.revokeObjectURL(url)
|
||||
ElMessage.success('导出完成')
|
||||
} catch (error) {
|
||||
showAdminFeedback(loadFailureMessage(error, '导出失败,请重试'), 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '导出失败,请重试')
|
||||
} finally {
|
||||
stopExportWait()
|
||||
exporting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadGroups(): Promise<void> {
|
||||
try {
|
||||
groups.value = await fetchDedupeTotalGroups(companyTab.requestCompanyId)
|
||||
} catch {
|
||||
groups.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 切公司 = 重新取数:列表与分组下拉共用这一个 watch(少一个 = 那半边的 tab 是装饰品)。
|
||||
// groupId 与 keyset 游标必须一起清:上一家选中的分组在新一家不存在,而上一家响应回传的 lastId
|
||||
// 拿到新一家去翻页会把「游标之后」当成条件,首屏直接筛成空列表。
|
||||
watch(() => companyTab.activeId, () => { filter.groupId = null; pageCursor.value = null; pendingCursor = null; void loadGroups(); void load() })
|
||||
|
||||
onMounted(() => {
|
||||
void load()
|
||||
void loadGroups()
|
||||
})
|
||||
|
||||
// 导出秒表是 setInterval:不随页面卸载收掉的话,离开本页后它仍在每秒改一个已经没人看的 ref。
|
||||
onUnmounted(() => {
|
||||
pageDisposed = true
|
||||
stopExportWait()
|
||||
fetchDedupeTotalGroups().then((items) => {
|
||||
groups.value = items
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -390,7 +306,7 @@ onUnmounted(() => {
|
||||
<label>用户名(模糊搜索)</label>
|
||||
<input v-model="filter.username" type="text" placeholder="输入用户名" @keyup.enter="apply" />
|
||||
</div>
|
||||
<div v-if="isSuperAdmin" class="form-group">
|
||||
<div class="form-group">
|
||||
<label>分组</label>
|
||||
<el-select v-model="filter.groupId" class="admin-filter" filterable clearable placeholder="全部分组">
|
||||
<el-option v-for="group in groups" :key="group.id" :label="group.name" :value="group.id" />
|
||||
@@ -398,29 +314,24 @@ onUnmounted(() => {
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>国家</label>
|
||||
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 的弹层是浏览器直角原生物
|
||||
⇒ 换 el-select(admin-filter 与亚马逊面同壳 42px/9px,弹层是 EP 圆角面板)。
|
||||
「全部国家」保留为空值首行(value="" 与改前同语义,下发参数仍是空串=不限);
|
||||
EP 把 '' 当空值 ⇒ 闭壳显示 placeholder,因此同时钉 placeholder="全部国家",视觉不变。 -->
|
||||
<el-select v-model="filter.country" class="admin-filter" filterable placeholder="全部国家" aria-label="筛选国家">
|
||||
<el-option label="全部国家" value="" />
|
||||
<el-option v-for="code in ASIN_COUNTRY_CODES" :key="code" :label="asinCountryLabel(code)" :value="code" />
|
||||
</el-select>
|
||||
<select v-model="filter.country">
|
||||
<option value="">全部国家</option>
|
||||
<option v-for="code in ASIN_COUNTRY_CODES" :key="code" :value="code">{{ asinCountryLabel(code) }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="dedupe-filter-actions">
|
||||
<button class="btn" type="button" @click="apply">查询</button>
|
||||
</div>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<div class="dedupe-filter-date-row">
|
||||
<div class="form-group">
|
||||
<label>开始日期</label>
|
||||
<input v-model="filter.startDate" type="date" :max="filter.endDate" @change="clampDatePair" />
|
||||
<input v-model="filter.startDate" type="date" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>结束日期</label>
|
||||
<input v-model="filter.endDate" type="date" :min="filter.startDate" @change="clampDatePair" />
|
||||
<input v-model="filter.endDate" type="date" />
|
||||
</div>
|
||||
<div class="dedupe-filter-actions">
|
||||
<button class="btn btn-secondary" type="button" :disabled="exporting" @click="doExport">
|
||||
@@ -429,50 +340,39 @@ onUnmounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<div class="table-scroll dedupe-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="batch-delete-cell" scope="col">
|
||||
<BatchDeleteCheckbox label="全选当前页可删除记录" :checked="batch.pageAll" :partial="batch.pageSome"
|
||||
:disabled="batch.disabled || batch.pageEmpty" @change="batch.togglePage" />
|
||||
</th>
|
||||
<th>ID</th>
|
||||
<th>ASIN</th>
|
||||
<th>国家</th>
|
||||
<th>用户名</th>
|
||||
<th v-if="isSuperAdmin">分组</th>
|
||||
<th>分组</th>
|
||||
<th>创建时间</th>
|
||||
<th>更新时间</th>
|
||||
<th style="width: 140px">操作</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-if="rows.length">
|
||||
<tr v-for="row in rows" :key="row.id" :class="{ 'batch-selected': batch.isSelected(row) }">
|
||||
<td class="batch-delete-cell">
|
||||
<BatchDeleteCheckbox :label="batch.reason(row) || `选择 ${batch.label(row)}`" :checked="batch.isSelected(row)"
|
||||
:disabled="batch.disabled || !!batch.reason(row)" @change="batch.toggle(row)" />
|
||||
</td>
|
||||
<tr v-for="row in rows" :key="row.id">
|
||||
<td>{{ row.id }}</td>
|
||||
<td class="mono-cell">{{ row.dataValue }}</td>
|
||||
<td>{{ asinCountryLabel(row.country || '') }}</td>
|
||||
<td>{{ row.username || '-' }}</td>
|
||||
<td v-if="isSuperAdmin">{{ row.groupName || '未分组' }}</td>
|
||||
<td>{{ row.groupName || '未分组' }}</td>
|
||||
<td>{{ formatDateTime(row.createdAt) }}</td>
|
||||
<td>{{ formatDateTime(row.updatedAt) }}</td>
|
||||
<td class="ops-cell">
|
||||
<button class="btn btn-sm" type="button" @click="openEdit(row)">编辑</button>
|
||||
<button class="btn btn-sm btn-danger" type="button" :disabled="batch.busy" @click="removeRow(row)">删除</button>
|
||||
<button class="btn btn-sm btn-danger" type="button" @click="removeRow(row)">删除</button>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-else-if="loading">
|
||||
<td :colspan="isSuperAdmin ? 9 : 8" class="empty-tip">加载中...</td>
|
||||
<td colspan="7" class="empty-tip">加载中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td :colspan="isSuperAdmin ? 9 : 8" class="empty-tip">暂无总数据</td>
|
||||
<td colspan="7" class="empty-tip">暂无总数据</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -490,23 +390,10 @@ onUnmounted(() => {
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>分组</label>
|
||||
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 弹层是直角原生物 ⇒ el-select。
|
||||
「未选」语义:原写法是 disabled 的空行(:value="null",选中后不可回退),这里改成
|
||||
placeholder="请选择分组" + clearable,并用 :value-on-clear 把清空值钉回 null
|
||||
(理由见上方 nullOnClear 注释:EP 默认回 undefined 会破 number | null 契约)。
|
||||
值域仍是 null 或分组 id(number),下游 editGroupId 的假值判断与入参形状不变;
|
||||
非超管单分组时照旧锁定展示(:disabled 与护栏测试钉住的写法一致)。 -->
|
||||
<el-select
|
||||
v-model="editGroupId"
|
||||
class="admin-filter"
|
||||
placeholder="请选择分组"
|
||||
clearable
|
||||
:value-on-clear="nullOnClear"
|
||||
:disabled="lockedGroupId != null"
|
||||
aria-label="编辑分组"
|
||||
>
|
||||
<el-option v-for="group in groups" :key="group.id" :label="group.name" :value="group.id" />
|
||||
</el-select>
|
||||
<select v-model="editGroupId">
|
||||
<option disabled :value="null">请选择分组</option>
|
||||
<option v-for="group in groups" :key="group.id" :value="group.id">{{ group.name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="modal-actions">
|
||||
<button class="btn" type="button" :disabled="editSaving" @click="saveEdit">保存</button>
|
||||
@@ -524,20 +411,10 @@ onUnmounted(() => {
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>分组</label>
|
||||
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 弹层是直角原生物 ⇒ el-select。
|
||||
与编辑弹窗同款「未选」处理(placeholder + clearable + 清空钉回 null),
|
||||
导入锁定条件(importRunning 或单分组)照旧挂在 :disabled 上。 -->
|
||||
<el-select
|
||||
v-model="importGroupId"
|
||||
class="admin-filter"
|
||||
placeholder="请选择分组"
|
||||
clearable
|
||||
:value-on-clear="nullOnClear"
|
||||
:disabled="importRunning || lockedGroupId != null"
|
||||
aria-label="导入分组"
|
||||
>
|
||||
<el-option v-for="group in groups" :key="group.id" :label="group.name" :value="group.id" />
|
||||
</el-select>
|
||||
<select v-model="importGroupId" :disabled="importRunning">
|
||||
<option disabled :value="null">请选择分组</option>
|
||||
<option v-for="group in groups" :key="group.id" :value="group.id">{{ group.name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-if="importProgress" class="progress-wrap">
|
||||
<div class="progress-text">{{ importProgress }}</div>
|
||||
@@ -571,4 +448,353 @@ onUnmounted(() => {
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped src="./DedupeRegistryPage.css"></style>
|
||||
<style scoped>
|
||||
/* 像素复刻旧版 admin.html panel-dedupe-total-data(蓝白末层样式)。 */
|
||||
.dedupe-view {
|
||||
font-family: inherit;
|
||||
color: var(--c-text, #24384d);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 18px;
|
||||
}
|
||||
.form-box,
|
||||
.panel-box {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 20px 22px 24px;
|
||||
border: 1px solid #d8e3ee;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(145deg, #ffffff, #f9fbfd);
|
||||
box-shadow: 0 1px 2px rgba(39, 67, 94, 0.04), 0 14px 30px -24px rgba(39, 67, 94, 0.28);
|
||||
}
|
||||
h3 {
|
||||
margin: 0 0 16px;
|
||||
font-size: 15px;
|
||||
font-weight: 650;
|
||||
color: #24384d;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
.dedupe-panel-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.dedupe-panel-head h3 {
|
||||
margin: 0;
|
||||
}
|
||||
.dedupe-head-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.dedupe-filter-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(160px, 1fr)) auto;
|
||||
gap: 12px;
|
||||
align-items: end;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.dedupe-filter-row .form-group {
|
||||
min-width: 0;
|
||||
}
|
||||
.dedupe-filter-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.dedupe-filter-date-row {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: flex-end;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.dedupe-filter-date-row .form-group {
|
||||
flex: 0 0 200px;
|
||||
min-width: 0;
|
||||
}
|
||||
.dedupe-filter-date-row .dedupe-filter-actions {
|
||||
margin-left: auto;
|
||||
}
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 7px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.form-group label {
|
||||
color: #5b6f83;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 9px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13.5px;
|
||||
font-family: inherit;
|
||||
color-scheme: light;
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover,
|
||||
.form-group select:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
}
|
||||
.form-group input[type="file"] {
|
||||
background: #ffffff;
|
||||
padding: 6px 10px;
|
||||
}
|
||||
.form-group input[type="date"] {
|
||||
color-scheme: light;
|
||||
}
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
min-height: 42px;
|
||||
padding: 9px 18px;
|
||||
border: 1px solid #4f78a5;
|
||||
border-radius: 9px;
|
||||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
||||
color: #ffffff;
|
||||
font-family: inherit;
|
||||
font-size: 13.5px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 8px 18px -14px rgba(79, 120, 165, 0.72);
|
||||
transition: background 160ms ease, box-shadow 160ms ease, transform 120ms ease;
|
||||
}
|
||||
.btn:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #7094ba, #5d83ac);
|
||||
box-shadow: 0 11px 22px -14px rgba(79, 120, 165, 0.8);
|
||||
}
|
||||
.btn:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.6;
|
||||
}
|
||||
.btn-secondary {
|
||||
background: #ffffff;
|
||||
color: #5b6f83;
|
||||
border-color: #c7d7e5;
|
||||
}
|
||||
.btn-secondary:hover:not(:disabled) {
|
||||
color: #2f5d8b;
|
||||
border-color: #95b1cb;
|
||||
background: #edf5fb;
|
||||
}
|
||||
.btn-danger {
|
||||
background: linear-gradient(135deg, #c06d77, #b35f6a);
|
||||
border-color: #b35f6a;
|
||||
}
|
||||
.btn-danger:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #cb7c84, #b96570);
|
||||
}
|
||||
.btn-sm {
|
||||
min-height: 36px;
|
||||
padding: 7px 12px;
|
||||
}
|
||||
.table-scroll {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
overflow-x: auto;
|
||||
border: 1px solid #dbe5ee;
|
||||
border-radius: 10px;
|
||||
background: #ffffff;
|
||||
}
|
||||
.table-scroll table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
table-layout: fixed;
|
||||
}
|
||||
.dedupe-table-scroll > table {
|
||||
min-width: 900px;
|
||||
}
|
||||
.table-scroll th,
|
||||
.table-scroll td {
|
||||
padding: 10px 12px;
|
||||
text-align: left;
|
||||
font-size: 13.5px;
|
||||
line-height: 1.5;
|
||||
border-bottom: 1px solid #e0e8ef;
|
||||
vertical-align: middle;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.table-scroll th {
|
||||
background: #edf4fa;
|
||||
color: #4e6479;
|
||||
border-bottom-color: #d5e1eb;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.4px;
|
||||
}
|
||||
.table-scroll tbody tr:hover td {
|
||||
background: #f1f7fb;
|
||||
}
|
||||
.table-scroll tbody tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.mono-cell {
|
||||
font-family: "Cascadia Mono", "SF Mono", Consolas, "Courier New", monospace;
|
||||
font-size: 12.5px;
|
||||
}
|
||||
.ops-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
white-space: nowrap;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
padding: 44px 24px;
|
||||
text-align: center;
|
||||
color: #8293a5;
|
||||
font-size: 13.5px;
|
||||
}
|
||||
.pagination {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-top: 18px;
|
||||
color: #5b6f83;
|
||||
font-size: 13px;
|
||||
}
|
||||
.pagination button {
|
||||
min-height: 30px;
|
||||
padding: 4px 12px;
|
||||
border: 1px solid #c7d7e5;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
color: #5b6f83;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.pagination button:hover:not(:disabled) {
|
||||
background: #edf5fb;
|
||||
border-color: #95b1cb;
|
||||
color: #2f5d8b;
|
||||
}
|
||||
.pagination button:disabled {
|
||||
background: #eef3f7;
|
||||
color: #9baaba;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.page-total {
|
||||
margin-right: 4px;
|
||||
}
|
||||
.page-jump {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.page-jump input {
|
||||
width: 56px;
|
||||
min-height: 30px;
|
||||
padding: 4px 8px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 8px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
}
|
||||
.modal-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 3000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40px 20px;
|
||||
background: rgba(45, 66, 86, 0.36);
|
||||
backdrop-filter: blur(6px);
|
||||
}
|
||||
.modal {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: min(560px, 100%);
|
||||
max-height: 84vh;
|
||||
padding: 22px 24px;
|
||||
border: 1px solid #c7d7e5;
|
||||
border-radius: 14px;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 22px 60px rgba(39, 67, 94, 0.2);
|
||||
overflow-y: auto;
|
||||
}
|
||||
.modal .form-group {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.modal-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
.progress-wrap {
|
||||
margin-top: 12px;
|
||||
}
|
||||
.progress-text {
|
||||
font-size: 12.5px;
|
||||
color: #5b6f83;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.dedupe-export-wait-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 3100;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(45, 66, 86, 0.36);
|
||||
backdrop-filter: blur(6px);
|
||||
}
|
||||
.dedupe-export-wait {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 22px 28px;
|
||||
border: 1px solid #c7d7e5;
|
||||
border-radius: 14px;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 22px 60px rgba(39, 67, 94, 0.2);
|
||||
}
|
||||
.request-spinner {
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
flex: none;
|
||||
border: 3px solid #d5e3ef;
|
||||
border-top-color: #5f85ad;
|
||||
border-radius: 50%;
|
||||
animation: dedupe-spin 0.9s linear infinite;
|
||||
}
|
||||
@keyframes dedupe-spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
.dedupe-export-wait-title {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #24384d;
|
||||
}
|
||||
.dedupe-export-wait-detail {
|
||||
margin-top: 4px;
|
||||
font-size: 12.5px;
|
||||
color: #5b6f83;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
/* 像素复刻旧版 admin.html panel-product-categories(蓝白末层)。 */
|
||||
.category-view {
|
||||
font-family: inherit;
|
||||
color: #24384d;
|
||||
}
|
||||
.panel-box {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 20px 22px 24px;
|
||||
border: 1px solid #d8e3ee;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(145deg, #ffffff, #f9fbfd);
|
||||
box-shadow: 0 1px 2px rgba(39, 67, 94, 0.04), 0 14px 30px -24px rgba(39, 67, 94, 0.28);
|
||||
}
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 650;
|
||||
color: #24384d;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
.category-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.category-head-tools {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.category-keyword {
|
||||
width: 240px;
|
||||
min-height: 36px;
|
||||
padding: 6px 12px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 9px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13.5px;
|
||||
font-family: inherit;
|
||||
color-scheme: light;
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.category-keyword:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.category-keyword:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
}
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
min-height: 42px;
|
||||
padding: 9px 18px;
|
||||
border: 1px solid #4f78a5;
|
||||
border-radius: 9px;
|
||||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
||||
color: #ffffff;
|
||||
font-family: inherit;
|
||||
font-size: 13.5px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 8px 18px -14px rgba(79, 120, 165, 0.72);
|
||||
transition: background 160ms ease, box-shadow 160ms ease, transform 120ms ease;
|
||||
}
|
||||
.btn:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #7094ba, #5d83ac);
|
||||
box-shadow: 0 11px 22px -14px rgba(79, 120, 165, 0.8);
|
||||
}
|
||||
.btn:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.55;
|
||||
}
|
||||
.btn-secondary {
|
||||
background: #ffffff;
|
||||
color: #5b6f83;
|
||||
border-color: #c7d7e5;
|
||||
}
|
||||
.btn-secondary:hover:not(:disabled) {
|
||||
color: #2f5d8b;
|
||||
border-color: #95b1cb;
|
||||
background: #edf5fb;
|
||||
}
|
||||
.btn-danger {
|
||||
background: linear-gradient(135deg, #c06d77, #b35f6a);
|
||||
border-color: #b35f6a;
|
||||
}
|
||||
.btn-danger:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #cb7c84, #b96570);
|
||||
}
|
||||
.btn-sm {
|
||||
min-height: 36px;
|
||||
padding: 7px 12px;
|
||||
}
|
||||
.table-scroll {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
overflow-x: auto;
|
||||
border: 1px solid #dbe5ee;
|
||||
border-radius: 10px;
|
||||
background: #ffffff;
|
||||
}
|
||||
.table-scroll table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
table-layout: fixed;
|
||||
}
|
||||
.category-table-scroll > table {
|
||||
/* table-layout:fixed 下,没写宽度的列在容器变窄时第一个被压到 0(10-06 截图:层级路径只剩一个字、
|
||||
备注只剩破折号)。承重的是 thead 里 8 列全部显式 px 定宽;这个下限与它们成对维护,
|
||||
数值由 tests/align-product-category.test.ts 从 markup 现算比对,改列宽要同时改这里。 */
|
||||
min-width: 1262px;
|
||||
}
|
||||
.table-scroll th,
|
||||
.table-scroll td {
|
||||
padding: 10px 12px;
|
||||
text-align: left;
|
||||
font-size: 13.5px;
|
||||
line-height: 1.5;
|
||||
border-bottom: 1px solid #e0e8ef;
|
||||
vertical-align: middle;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.table-scroll th {
|
||||
background: #edf4fa;
|
||||
color: #4e6479;
|
||||
border-bottom-color: #d5e1eb;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.4px;
|
||||
}
|
||||
.table-scroll tbody tr:hover td {
|
||||
background: #f1f7fb;
|
||||
}
|
||||
.table-scroll tbody tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.tree-name-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-height: 24px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.tree-indent {
|
||||
flex: 0 0 auto;
|
||||
display: inline-block;
|
||||
}
|
||||
.tree-node-mark {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: 0;
|
||||
border-radius: 5px;
|
||||
background: var(--admin-primary-soft, #e7f0f8);
|
||||
color: var(--admin-primary-strong, #2f5d8b);
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
line-height: 1;
|
||||
flex: none;
|
||||
transition: background 0.12s ease, color 0.12s ease;
|
||||
}
|
||||
.tree-node-mark:not(.is-leaf):hover {
|
||||
background: var(--admin-primary-strong, #2f5d8b);
|
||||
color: #ffffff;
|
||||
}
|
||||
.tree-node-mark.is-leaf {
|
||||
background: transparent;
|
||||
cursor: default;
|
||||
}
|
||||
.node-name {
|
||||
font-weight: 600;
|
||||
color: #24384d;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.selected-flag {
|
||||
padding: 1px 8px;
|
||||
border-radius: 999px;
|
||||
background: #e7f0f8;
|
||||
color: #2f5d8b;
|
||||
font-size: 11px;
|
||||
}
|
||||
.category-tag {
|
||||
padding: 2px 8px;
|
||||
border-radius: 6px;
|
||||
border: 1px solid #c2d5e6;
|
||||
background: #e7f0f8;
|
||||
color: #2f5d8b;
|
||||
font-size: 12px;
|
||||
}
|
||||
.category-tag.is-custom {
|
||||
border-color: #bcd9c6;
|
||||
background: #eef7f0;
|
||||
color: #3d7158;
|
||||
}
|
||||
.category-path-value {
|
||||
display: block;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.node-desc {
|
||||
color: #5b6f83;
|
||||
font-size: 12px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
max-width: 320px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.dim {
|
||||
color: #8293a5;
|
||||
}
|
||||
.ops-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
white-space: nowrap;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.load-more-row td {
|
||||
background: #fbfdfe;
|
||||
}
|
||||
.load-more-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.loaded-count {
|
||||
color: #8293a5;
|
||||
font-size: 12.5px;
|
||||
}
|
||||
.empty-tip {
|
||||
padding: 44px 24px;
|
||||
text-align: center;
|
||||
color: #8293a5;
|
||||
font-size: 13.5px;
|
||||
}
|
||||
.pagination {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-top: 18px;
|
||||
color: #5b6f83;
|
||||
font-size: 13px;
|
||||
}
|
||||
.pagination button {
|
||||
min-height: 30px;
|
||||
padding: 4px 12px;
|
||||
border: 1px solid #c7d7e5;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
color: #5b6f83;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.pagination button:hover:not(:disabled) {
|
||||
background: #edf5fb;
|
||||
border-color: #95b1cb;
|
||||
color: #2f5d8b;
|
||||
}
|
||||
.pagination button:disabled {
|
||||
background: #eef3f7;
|
||||
color: #9baaba;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.page-total {
|
||||
margin-right: 4px;
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import BatchDeleteActions from '@/components/BatchDeleteActions.vue'
|
||||
import BatchDeleteCheckbox from '@/components/BatchDeleteCheckbox.vue'
|
||||
import { useRowSelection } from '@/utils/use-row-selection'
|
||||
/** 商品类目 · 像素复刻旧版 admin.html panel-product-categories(自绘:面板头搜索框组+新增类目 同行、原生树表格[+/−]折叠+懒加载「加载更多 已加载 x/y」、搜索态旧式分页)。
|
||||
* script 逻辑沿用现有 Vue 实现(懒加载树/编辑删除/导出/弹窗)。 */
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
@@ -18,14 +15,9 @@ import {
|
||||
} from './product-category-model.ts'
|
||||
import { categoryDraftError, createProductCategoryDraft, toCategorySaveRequest, type ProductCategoryDraft } from './product-category-editor-model.ts'
|
||||
import { buildProductCategoryExportUrl } from './product-category-export.ts'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||||
|
||||
const loading = ref(false)
|
||||
const loadFailure = ref('')
|
||||
const tree = ref<ProductCategoryNode[]>([])
|
||||
const keyword = ref('')
|
||||
const selected = ref<ProductCategoryNode | null>(null)
|
||||
@@ -74,7 +66,6 @@ const rootTotal = ref(0)
|
||||
/** 拉取根级当前页(对齐 admin.js loadProductCategoryChildren(null) 懒加载根)。 */
|
||||
async function loadTree(): Promise<void> {
|
||||
loading.value = true
|
||||
loadFailure.value = ''
|
||||
try {
|
||||
const result = await fetchProductCategoryChildren(null, rootPage.value, rootPageSize.value)
|
||||
const state = { page: result.page, total: result.total, hasMore: result.hasMore, loading: false }
|
||||
@@ -83,8 +74,7 @@ async function loadTree(): Promise<void> {
|
||||
tree.value = result.items
|
||||
rootTotal.value = result.total
|
||||
} catch (error) {
|
||||
loadFailure.value = error instanceof Error ? error.message : '类目加载失败'
|
||||
showAdminFeedback(loadFailure.value, 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '类目加载失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@@ -176,7 +166,7 @@ async function loadChildrenPage(parent: ProductCategoryNode | null, page: number
|
||||
const fallback = childrenState.get(key) ?? { page: 0, total: 0, hasMore: false, loading: false }
|
||||
fallback.loading = false
|
||||
childrenState.set(key, fallback)
|
||||
showAdminFeedback(error instanceof Error ? error.message : '子类目加载失败', 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '子类目加载失败')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +200,7 @@ async function runSearch(page: number): Promise<void> {
|
||||
searchPage.value = result.page
|
||||
searchHasMore.value = result.hasMore
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '类目搜索失败', 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '类目搜索失败')
|
||||
} finally {
|
||||
searchLoading.value = false
|
||||
}
|
||||
@@ -260,36 +250,21 @@ function canDelete(node: ProductCategoryNode | null): boolean {
|
||||
return !(node.childCount > 0 || (Array.isArray(node.children) && node.children.some((child) => !isCategoryLoadMoreNode(child))))
|
||||
}
|
||||
|
||||
const batch = useRowSelection({
|
||||
pageRows: () => searching.value ? searchRows.value : treeRows.value.map(({ node }) => node),
|
||||
rowId: (row) => row.id,
|
||||
rowLabel: (row) => row.path || row.name,
|
||||
deleteOne: async (id) => {
|
||||
await deleteProductCategory(id)
|
||||
if (selected.value?.id === id) selected.value = null
|
||||
},
|
||||
refresh: () => searching.value ? runSearch(1) : loadTree(),
|
||||
blocked: () => loading.value || searchLoading.value || saving.value,
|
||||
precheck: (row) => canDelete(row) ? undefined : '存在子类目,不能删除',
|
||||
})
|
||||
|
||||
async function removeCategory(node: ProductCategoryNode): Promise<void> {
|
||||
if (batch.busy) return
|
||||
if (!canDelete(node)) {
|
||||
ElMessage.warning('存在子类目,不能删除')
|
||||
return
|
||||
}
|
||||
// 对齐旧版:原生 confirm。
|
||||
if (!(await openAdminConfirm({ message: `确定删除“${node.name}”?`, danger: true }))) return
|
||||
if (!window.confirm(`确定删除“${node.name}”?`)) return
|
||||
try {
|
||||
await deleteProductCategory(node.id)
|
||||
batch.removeFromSelection(node.id)
|
||||
ElMessage.success('已删除')
|
||||
if (selected.value?.id === node.id) selected.value = null
|
||||
if (searching.value) void runSearch(1)
|
||||
else void loadTree()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +288,7 @@ async function submit(): Promise<void> {
|
||||
if (searching.value) void runSearch(1)
|
||||
else void loadTree()
|
||||
} catch (err) {
|
||||
showAdminFeedback(err instanceof Error ? err.message : '保存失败', 'error')
|
||||
ElMessage.error(err instanceof Error ? err.message : '保存失败')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
@@ -336,41 +311,33 @@ onMounted(loadTree)
|
||||
<section class="panel-box">
|
||||
<div class="category-head">
|
||||
<h3>商品类目</h3>
|
||||
<div class="category-head-tools admin-header-controls">
|
||||
<div class="category-head-tools">
|
||||
<input v-model="keyword" type="text" placeholder="搜索类目名称、编码或备注" class="category-keyword" @keyup.enter="apply" />
|
||||
<button class="btn btn-sm" type="button" @click="apply">搜索</button>
|
||||
<button class="btn btn-sm btn-secondary" type="button" @click="reset">清空</button>
|
||||
<button class="btn btn-sm btn-secondary" type="button" @click="exportCategories">导出</button>
|
||||
<button v-if="selected && !searching" class="btn btn-sm" type="button" @click="openCreate(selected)">新增子类目</button>
|
||||
<button class="btn" type="button" @click="openCreate(null)">新增类目</button>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="loadTree" />
|
||||
<div class="table-scroll category-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="batch-delete-cell" scope="col" style="width: 38px">
|
||||
<BatchDeleteCheckbox label="全选当前页可删除记录" :checked="batch.pageAll" :partial="batch.pageSome"
|
||||
:disabled="batch.disabled || batch.pageEmpty" @change="batch.togglePage" />
|
||||
</th>
|
||||
<th style="width: 220px">类目</th>
|
||||
<th style="width: 230px">层级路径</th>
|
||||
<th style="width: 66px">排序</th>
|
||||
<th style="width: 82px">来源</th>
|
||||
<th style="width: 170px">备注</th>
|
||||
<th style="width: 154px">创建时间</th>
|
||||
<th style="width: 154px">更新时间</th>
|
||||
<th style="width: 148px">操作</th>
|
||||
<th style="width: 34%">类目</th>
|
||||
<th>层级路径</th>
|
||||
<th style="width: 90px">排序</th>
|
||||
<th style="width: 120px">来源</th>
|
||||
<th>备注</th>
|
||||
<th style="width: 150px">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody v-if="!searching">
|
||||
<template v-if="treeRows.length">
|
||||
<template v-for="row in treeRows" :key="String(row.node.id)">
|
||||
<tr v-if="isCategoryLoadMoreNode(row.node)" class="load-more-row">
|
||||
<td colspan="9">
|
||||
<td colspan="6">
|
||||
<div class="load-more-cell">
|
||||
<span class="tree-indent" :style="{ width: `${(row.depth + 1) * 24}px` }"></span>
|
||||
<button class="btn btn-sm btn-secondary" type="button" :disabled="moreLoading(row.node)" @click="loadMoreChildren(row.node)">
|
||||
@@ -380,11 +347,7 @@ onMounted(loadTree)
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-else :class="{ 'batch-selected': batch.isSelected(row.node) }">
|
||||
<td class="batch-delete-cell">
|
||||
<BatchDeleteCheckbox :label="batch.reason(row.node) || `选择 ${batch.label(row.node)}`" :checked="batch.isSelected(row.node)"
|
||||
:disabled="batch.disabled || !!batch.reason(row.node)" @change="batch.toggle(row.node)" />
|
||||
</td>
|
||||
<tr v-else>
|
||||
<td>
|
||||
<div class="tree-name-cell" @click="onNodeClick(row.node)">
|
||||
<span class="tree-indent" :style="{ width: `${row.depth * 24}px` }"></span>
|
||||
@@ -413,14 +376,12 @@ onMounted(loadTree)
|
||||
<span v-if="row.node.description" class="node-desc" :title="row.node.description">{{ row.node.description }}</span>
|
||||
<span v-else class="dim">—</span>
|
||||
</td>
|
||||
<td>{{ formatDateTime(row.node.createdAt) }}</td>
|
||||
<td>{{ formatDateTime(row.node.updatedAt) }}</td>
|
||||
<td class="ops-cell">
|
||||
<button class="btn btn-sm" type="button" @click="openEdit(row.node)">编辑</button>
|
||||
<button
|
||||
class="btn btn-sm btn-danger"
|
||||
type="button"
|
||||
:disabled="batch.busy || !canDelete(row.node)"
|
||||
:disabled="!canDelete(row.node)"
|
||||
:title="!canDelete(row.node) ? '存在子类目,不能删除' : undefined"
|
||||
@click="removeCategory(row.node)"
|
||||
>
|
||||
@@ -431,19 +392,15 @@ onMounted(loadTree)
|
||||
</template>
|
||||
</template>
|
||||
<tr v-else-if="loading">
|
||||
<td colspan="9" class="empty-tip">加载中...</td>
|
||||
<td colspan="6" class="empty-tip">加载中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td colspan="9" class="empty-tip">暂无商品类目</td>
|
||||
<td colspan="6" class="empty-tip">暂无商品类目</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody v-else>
|
||||
<template v-if="searchRows.length">
|
||||
<tr v-for="row in searchRows" :key="row.id" :class="{ 'batch-selected': batch.isSelected(row) }">
|
||||
<td class="batch-delete-cell">
|
||||
<BatchDeleteCheckbox :label="batch.reason(row) || `选择 ${batch.label(row)}`" :checked="batch.isSelected(row)"
|
||||
:disabled="batch.disabled || !!batch.reason(row)" @change="batch.toggle(row)" />
|
||||
</td>
|
||||
<tr v-for="row in searchRows" :key="row.id">
|
||||
<td><strong class="node-name">{{ row.name }}</strong></td>
|
||||
<td><span class="category-path-value" :title="row.path || row.name">{{ row.path || row.name }}</span></td>
|
||||
<td>{{ row.sortOrder ?? '—' }}</td>
|
||||
@@ -454,14 +411,12 @@ onMounted(loadTree)
|
||||
<span v-if="row.description" class="node-desc" :title="row.description">{{ row.description }}</span>
|
||||
<span v-else class="dim">—</span>
|
||||
</td>
|
||||
<td>{{ formatDateTime(row.createdAt) }}</td>
|
||||
<td>{{ formatDateTime(row.updatedAt) }}</td>
|
||||
<td class="ops-cell">
|
||||
<button class="btn btn-sm" type="button" @click="openEdit(row)">编辑</button>
|
||||
<button
|
||||
class="btn btn-sm btn-danger"
|
||||
type="button"
|
||||
:disabled="batch.busy || !canDelete(row)"
|
||||
:disabled="!canDelete(row)"
|
||||
:title="!canDelete(row) ? '存在子类目,不能删除' : undefined"
|
||||
@click="removeCategory(row)"
|
||||
>
|
||||
@@ -471,10 +426,10 @@ onMounted(loadTree)
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-else-if="searchLoading">
|
||||
<td colspan="9" class="empty-tip">搜索中...</td>
|
||||
<td colspan="6" class="empty-tip">搜索中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td colspan="9" class="empty-tip">暂无搜索结果</td>
|
||||
<td colspan="6" class="empty-tip">暂无搜索结果</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -514,4 +469,288 @@ onMounted(loadTree)
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped src="./ProductCategoryPage.css"></style>
|
||||
<style scoped>
|
||||
/* 像素复刻旧版 admin.html panel-product-categories(蓝白末层)。 */
|
||||
.category-view {
|
||||
font-family: inherit;
|
||||
color: #24384d;
|
||||
}
|
||||
.panel-box {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 20px 22px 24px;
|
||||
border: 1px solid #d8e3ee;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(145deg, #ffffff, #f9fbfd);
|
||||
box-shadow: 0 1px 2px rgba(39, 67, 94, 0.04), 0 14px 30px -24px rgba(39, 67, 94, 0.28);
|
||||
}
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 650;
|
||||
color: #24384d;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
.category-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.category-head-tools {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.category-keyword {
|
||||
width: 240px;
|
||||
min-height: 36px;
|
||||
padding: 6px 12px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 9px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13.5px;
|
||||
font-family: inherit;
|
||||
color-scheme: light;
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.category-keyword:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.category-keyword:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
}
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
min-height: 42px;
|
||||
padding: 9px 18px;
|
||||
border: 1px solid #4f78a5;
|
||||
border-radius: 9px;
|
||||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
||||
color: #ffffff;
|
||||
font-family: inherit;
|
||||
font-size: 13.5px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 8px 18px -14px rgba(79, 120, 165, 0.72);
|
||||
transition: background 160ms ease, box-shadow 160ms ease, transform 120ms ease;
|
||||
}
|
||||
.btn:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #7094ba, #5d83ac);
|
||||
box-shadow: 0 11px 22px -14px rgba(79, 120, 165, 0.8);
|
||||
}
|
||||
.btn:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.55;
|
||||
}
|
||||
.btn-secondary {
|
||||
background: #ffffff;
|
||||
color: #5b6f83;
|
||||
border-color: #c7d7e5;
|
||||
}
|
||||
.btn-secondary:hover:not(:disabled) {
|
||||
color: #2f5d8b;
|
||||
border-color: #95b1cb;
|
||||
background: #edf5fb;
|
||||
}
|
||||
.btn-danger {
|
||||
background: linear-gradient(135deg, #c06d77, #b35f6a);
|
||||
border-color: #b35f6a;
|
||||
}
|
||||
.btn-danger:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #cb7c84, #b96570);
|
||||
}
|
||||
.btn-sm {
|
||||
min-height: 36px;
|
||||
padding: 7px 12px;
|
||||
}
|
||||
.table-scroll {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
overflow-x: auto;
|
||||
border: 1px solid #dbe5ee;
|
||||
border-radius: 10px;
|
||||
background: #ffffff;
|
||||
}
|
||||
.table-scroll table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
table-layout: fixed;
|
||||
}
|
||||
.category-table-scroll > table {
|
||||
min-width: 860px;
|
||||
}
|
||||
.table-scroll th,
|
||||
.table-scroll td {
|
||||
padding: 10px 12px;
|
||||
text-align: left;
|
||||
font-size: 13.5px;
|
||||
line-height: 1.5;
|
||||
border-bottom: 1px solid #e0e8ef;
|
||||
vertical-align: middle;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.table-scroll th {
|
||||
background: #edf4fa;
|
||||
color: #4e6479;
|
||||
border-bottom-color: #d5e1eb;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.4px;
|
||||
}
|
||||
.table-scroll tbody tr:hover td {
|
||||
background: #f1f7fb;
|
||||
}
|
||||
.table-scroll tbody tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.tree-name-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-height: 24px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.tree-indent {
|
||||
flex: 0 0 auto;
|
||||
display: inline-block;
|
||||
}
|
||||
.tree-node-mark {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: 0;
|
||||
border-radius: 5px;
|
||||
background: var(--admin-primary-soft, #e7f0f8);
|
||||
color: var(--admin-primary-strong, #2f5d8b);
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
line-height: 1;
|
||||
flex: none;
|
||||
transition: background 0.12s ease, color 0.12s ease;
|
||||
}
|
||||
.tree-node-mark:not(.is-leaf):hover {
|
||||
background: var(--admin-primary-strong, #2f5d8b);
|
||||
color: #ffffff;
|
||||
}
|
||||
.tree-node-mark.is-leaf {
|
||||
background: transparent;
|
||||
cursor: default;
|
||||
}
|
||||
.node-name {
|
||||
font-weight: 600;
|
||||
color: #24384d;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.selected-flag {
|
||||
padding: 1px 8px;
|
||||
border-radius: 999px;
|
||||
background: #e7f0f8;
|
||||
color: #2f5d8b;
|
||||
font-size: 11px;
|
||||
}
|
||||
.category-tag {
|
||||
padding: 2px 8px;
|
||||
border-radius: 6px;
|
||||
border: 1px solid #c2d5e6;
|
||||
background: #e7f0f8;
|
||||
color: #2f5d8b;
|
||||
font-size: 12px;
|
||||
}
|
||||
.category-tag.is-custom {
|
||||
border-color: #bcd9c6;
|
||||
background: #eef7f0;
|
||||
color: #3d7158;
|
||||
}
|
||||
.category-path-value {
|
||||
display: block;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.node-desc {
|
||||
color: #5b6f83;
|
||||
font-size: 12px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
max-width: 320px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.dim {
|
||||
color: #8293a5;
|
||||
}
|
||||
.ops-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.load-more-row td {
|
||||
background: #fbfdfe;
|
||||
}
|
||||
.load-more-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.loaded-count {
|
||||
color: #8293a5;
|
||||
font-size: 12.5px;
|
||||
}
|
||||
.empty-tip {
|
||||
padding: 44px 24px;
|
||||
text-align: center;
|
||||
color: #8293a5;
|
||||
font-size: 13.5px;
|
||||
}
|
||||
.pagination {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-top: 18px;
|
||||
color: #5b6f83;
|
||||
font-size: 13px;
|
||||
}
|
||||
.pagination button {
|
||||
min-height: 30px;
|
||||
padding: 4px 12px;
|
||||
border: 1px solid #c7d7e5;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
color: #5b6f83;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.pagination button:hover:not(:disabled) {
|
||||
background: #edf5fb;
|
||||
border-color: #95b1cb;
|
||||
color: #2f5d8b;
|
||||
}
|
||||
.pagination button:disabled {
|
||||
background: #eef3f7;
|
||||
color: #9baaba;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.page-total {
|
||||
margin-right: 4px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,272 +0,0 @@
|
||||
/* 像素复刻旧版 admin.html panel-query-asin(蓝白末层)。 */
|
||||
.query-view {
|
||||
font-family: inherit;
|
||||
color: #24384d;
|
||||
}
|
||||
.panel-box {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 20px 22px 24px;
|
||||
border: 1px solid #d8e3ee;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(145deg, #ffffff, #f9fbfd);
|
||||
box-shadow: 0 1px 2px rgba(39, 67, 94, 0.04), 0 14px 30px -24px rgba(39, 67, 94, 0.28);
|
||||
}
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 650;
|
||||
color: #24384d;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
.query-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.query-head-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.form-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
gap: 14px 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.query-filter-row > .form-group {
|
||||
flex: 1 1 140px;
|
||||
min-width: 0;
|
||||
}
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 7px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.form-group label {
|
||||
color: #5b6f83;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
/* 下拉壳由全局 .el-select.admin-filter(main.css:42px/9px 圆角/#f8fbfd 浅底/focus ring)出,
|
||||
与亚马逊面同一套;这里只留 input 的原生壳规则(2026-11-17 原生 select 全换 el-select)。 */
|
||||
.form-group input {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 9px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13.5px;
|
||||
font-family: inherit;
|
||||
color-scheme: light;
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
}
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
min-height: 42px;
|
||||
padding: 9px 18px;
|
||||
border: 1px solid #4f78a5;
|
||||
border-radius: 9px;
|
||||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
||||
color: #ffffff;
|
||||
font-family: inherit;
|
||||
font-size: 13.5px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 8px 18px -14px rgba(79, 120, 165, 0.72);
|
||||
transition: background 160ms ease, box-shadow 160ms ease, transform 120ms ease;
|
||||
}
|
||||
.btn:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #7094ba, #5d83ac);
|
||||
box-shadow: 0 11px 22px -14px rgba(79, 120, 165, 0.8);
|
||||
}
|
||||
.btn:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.55;
|
||||
}
|
||||
.btn-secondary {
|
||||
background: #ffffff;
|
||||
color: #5b6f83;
|
||||
border-color: #c7d7e5;
|
||||
}
|
||||
.btn-secondary:hover:not(:disabled) {
|
||||
color: #2f5d8b;
|
||||
border-color: #95b1cb;
|
||||
background: #edf5fb;
|
||||
}
|
||||
.btn-danger {
|
||||
background: linear-gradient(135deg, #c06d77, #b35f6a);
|
||||
border-color: #b35f6a;
|
||||
}
|
||||
.btn-danger:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #cb7c84, #b96570);
|
||||
}
|
||||
.btn-sm {
|
||||
min-height: 36px;
|
||||
padding: 7px 12px;
|
||||
}
|
||||
.table-scroll {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
overflow-x: auto;
|
||||
border: 1px solid #dbe5ee;
|
||||
border-radius: 10px;
|
||||
background: #ffffff;
|
||||
}
|
||||
.table-scroll table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
table-layout: fixed;
|
||||
}
|
||||
.query-asin-table-scroll > table {
|
||||
min-width: 860px;
|
||||
}
|
||||
.table-scroll th,
|
||||
.table-scroll td {
|
||||
padding: 10px 12px;
|
||||
text-align: left;
|
||||
font-size: 13.5px;
|
||||
line-height: 1.5;
|
||||
border-bottom: 1px solid #e0e8ef;
|
||||
vertical-align: middle;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.table-scroll th {
|
||||
background: #edf4fa;
|
||||
color: #4e6479;
|
||||
border-bottom-color: #d5e1eb;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.4px;
|
||||
}
|
||||
.table-scroll tbody tr:hover td {
|
||||
background: #f1f7fb;
|
||||
}
|
||||
.table-scroll tbody tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.table-scroll td {
|
||||
vertical-align: top;
|
||||
}
|
||||
.asin-cell {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
margin: -3px 0 -3px -7px;
|
||||
padding: 3px 7px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 9px;
|
||||
background: none;
|
||||
color: inherit;
|
||||
font-size: 13.5px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
line-height: 1.5;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
cursor: pointer;
|
||||
}
|
||||
.asin-cell:hover {
|
||||
border-color: #c7d7e5;
|
||||
background: #eef4fa;
|
||||
color: #2f5d8b;
|
||||
}
|
||||
.asin-empty {
|
||||
color: #8b9aaa;
|
||||
}
|
||||
.asin-col-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
white-space: nowrap;
|
||||
/* 与最低价 ASIN 同形:列宽已从 9% 改成 140px 下限,再补 wrap 兜住文案变长的情况,
|
||||
让"超宽"从"按钮静默消失"退化成"多占一行"。 */
|
||||
flex-wrap: wrap;
|
||||
background: #ffffff;
|
||||
box-shadow: -9px 0 12px -10px rgba(31, 48, 66, 0.45);
|
||||
}
|
||||
.empty-tip {
|
||||
padding: 44px 24px;
|
||||
text-align: center;
|
||||
color: #8293a5;
|
||||
font-size: 13.5px;
|
||||
}
|
||||
.pagination {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-top: 18px;
|
||||
color: #5b6f83;
|
||||
font-size: 13px;
|
||||
}
|
||||
.pagination button {
|
||||
min-height: 30px;
|
||||
padding: 4px 12px;
|
||||
border: 1px solid #c7d7e5;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
color: #5b6f83;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.pagination button:hover:not(:disabled) {
|
||||
background: #edf5fb;
|
||||
border-color: #95b1cb;
|
||||
color: #2f5d8b;
|
||||
}
|
||||
.pagination button:disabled {
|
||||
background: #eef3f7;
|
||||
color: #9baaba;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.page-total {
|
||||
margin-right: 4px;
|
||||
}
|
||||
.page-jump {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.page-jump input {
|
||||
width: 56px;
|
||||
min-height: 30px;
|
||||
padding: 4px 8px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 8px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
}
|
||||
.drawer-tip {
|
||||
color: #5b6f83;
|
||||
font-size: 12px;
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
.import-tip {
|
||||
margin: 6px 0 0;
|
||||
color: #5b6f83;
|
||||
font-size: 12px;
|
||||
}
|
||||
@@ -1,14 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import BatchDeleteActions from '@/components/BatchDeleteActions.vue'
|
||||
import BatchDeleteCheckbox from '@/components/BatchDeleteCheckbox.vue'
|
||||
import { useRowSelection } from '@/utils/use-row-selection'
|
||||
import { createLatestRequestGate } from '@/utils/latest-request'
|
||||
/** 查询 ASIN · 像素复刻旧版 admin.html panel-query-asin(自绘:面板头操作组、筛选+导出 XLSX、原生 rowspan 表格+可复制 ASIN、旧式分页)。
|
||||
* script 逻辑沿用现有 Vue 实现(新增级联/配置抽屉/导入轮询/导出)。 */
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import CopyText from '@/components/CopyText.vue'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
import { createQueryAsin, fetchQueryAsinList, fetchShopNamesByGroup } from './query-asin-api.ts'
|
||||
import { QUERY_ASIN_COUNTRIES, queryAsinDisplayRows, type QueryAsinItem } from './query-asin-model.ts'
|
||||
import { asinCountryLabel } from './asin-country.ts'
|
||||
@@ -21,29 +16,13 @@ import { isAllowedExcelImportFile } from './import-progress-model.ts'
|
||||
import { fetchShopManageGroups } from '../shop/shop-manage-api.ts'
|
||||
import type { ShopGroupOption } from '../shop/shop-dto.ts'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||||
|
||||
const session = useAdminSessionStore()
|
||||
const companyTab = useCompanyTabStore()
|
||||
/** 仅超管需要分组维度:非超管数据由后端裁剪到本人分组,分组筛选/列一律不展示。 */
|
||||
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
||||
|
||||
const loading = ref(false)
|
||||
const loadFailure = ref('')
|
||||
const rows = ref<QueryAsinItem[]>([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const groups = ref<ShopGroupOption[]>([])
|
||||
/** 非超管仅有一个可访问分组时,弹窗分组选择锁定为该组(保留展示、不可改)。 */
|
||||
const lockedGroupId = computed<number | null>(() => {
|
||||
if (isSuperAdmin.value) return null
|
||||
return groups.value.length === 1 ? groups.value[0].id : null
|
||||
})
|
||||
const filter = reactive<QueryAsinFilterState>(createQueryAsinFilterState())
|
||||
const jumpPage = ref('')
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||
@@ -75,41 +54,17 @@ function normalizeAsinInput(country: string): void {
|
||||
}
|
||||
|
||||
|
||||
// 同一家店铺部分站点删除成功后,重试只发未完成的站点。
|
||||
const pendingCountries = new WeakMap<QueryAsinItem, Set<(typeof QUERY_ASIN_COUNTRIES)[number]>>()
|
||||
|
||||
async function deleteShopCountries(item: QueryAsinItem, isCurrent: () => boolean = () => true) {
|
||||
const pending = pendingCountries.get(item) ?? new Set(QUERY_ASIN_COUNTRIES.filter((country) => asinOf(item, country)))
|
||||
pendingCountries.set(item, pending)
|
||||
for (const country of pending) {
|
||||
if (!isCurrent()) throw new Error('列表范围已切换,店铺剩余站点未删除')
|
||||
await deleteQueryAsinCountryAsin(item.id, country)
|
||||
pending.delete(country)
|
||||
}
|
||||
}
|
||||
|
||||
const batch = useRowSelection({
|
||||
pageRows: () => rows.value,
|
||||
rowId: (row) => row.id,
|
||||
rowLabel: (row) => row.groupName ? `${row.shopName}(${row.groupName})` : row.shopName,
|
||||
deleteOne: (_id, row, isCurrent) => deleteShopCountries(row, isCurrent),
|
||||
refresh: load,
|
||||
blocked: () => loading.value || !!loadFailure.value,
|
||||
scope: () => companyTab.activeId,
|
||||
consequence: '将删除所选店铺全部站点的 ASIN 配置,此操作不可恢复。',
|
||||
})
|
||||
|
||||
async function removeShopAsin(item: QueryAsinItem) {
|
||||
if (batch.busy) return
|
||||
// 删除该店铺全部站点的 ASIN 配置(逐国调用现有端点)。
|
||||
if (!(await openAdminConfirm({ message: `确定删除店铺“${item.shopName}”的全部站点 ASIN 配置吗?`, danger: true }))) return
|
||||
if (!window.confirm(`确定删除店铺“${item.shopName}”的全部站点 ASIN 配置吗?`)) return
|
||||
try {
|
||||
await deleteShopCountries(item)
|
||||
batch.removeFromSelection(item.id)
|
||||
for (const country of QUERY_ASIN_COUNTRIES) {
|
||||
if (asinOf(item, country)) await deleteQueryAsinCountryAsin(item.id, country)
|
||||
}
|
||||
ElMessage.success('已删除')
|
||||
await load()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +89,7 @@ async function saveConfig(): Promise<void> {
|
||||
}
|
||||
}
|
||||
if (errors.length) {
|
||||
showAdminFeedback(errors.join(';'), 'error')
|
||||
ElMessage.error(errors.join(';'))
|
||||
} else {
|
||||
ElMessage.success('保存成功')
|
||||
drawerVisible.value = false
|
||||
@@ -160,7 +115,7 @@ const creating = ref(false)
|
||||
const createAsinInputRef = ref<InstanceType<typeof import('element-plus').ElInput> | null>(null)
|
||||
|
||||
function openCreate(): void {
|
||||
createGroupId.value = lockedGroupId.value
|
||||
createGroupId.value = null
|
||||
createShopName.value = ''
|
||||
createCountry.value = ''
|
||||
createAsin.value = ''
|
||||
@@ -168,8 +123,6 @@ function openCreate(): void {
|
||||
createMsgOk.value = false
|
||||
shopNames.value = []
|
||||
createVisible.value = true
|
||||
// 非超管分组已锁定:直接联动加载该分组店铺,省去一次无意义的选择。
|
||||
if (createGroupId.value != null) void onCreateGroupChange()
|
||||
}
|
||||
|
||||
async function onCreateGroupChange(): Promise<void> {
|
||||
@@ -180,10 +133,10 @@ async function onCreateGroupChange(): Promise<void> {
|
||||
}
|
||||
shopNamesLoading.value = true
|
||||
try {
|
||||
shopNames.value = await fetchShopNamesByGroup(createGroupId.value, companyTab.requestCompanyId)
|
||||
shopNames.value = await fetchShopNamesByGroup(createGroupId.value)
|
||||
} catch (error) {
|
||||
shopNames.value = []
|
||||
showAdminFeedback(error instanceof Error ? error.message : '店铺列表加载失败', 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '店铺列表加载失败')
|
||||
} finally {
|
||||
shopNamesLoading.value = false
|
||||
}
|
||||
@@ -236,7 +189,7 @@ const importRunning = ref(false)
|
||||
const importProgress = ref('')
|
||||
|
||||
function resetImport(): void {
|
||||
importGroupId.value = lockedGroupId.value
|
||||
importGroupId.value = null
|
||||
importFile.value = null
|
||||
importProgress.value = ''
|
||||
importRunning.value = false
|
||||
@@ -274,7 +227,7 @@ async function submitImport(): Promise<void> {
|
||||
return
|
||||
}
|
||||
if (importMode.value === 'delete') {
|
||||
if (!(await openAdminConfirm({ message: '确定按 Excel 中的分组、店铺名和国家 ASIN 批量删除吗?', danger: true }))) return
|
||||
if (!window.confirm('确定按 Excel 中的分组、店铺名和国家 ASIN 批量删除吗?')) return
|
||||
}
|
||||
const mode = importMode.value
|
||||
const groupId = importGroupId.value ?? undefined
|
||||
@@ -295,7 +248,7 @@ async function submitImport(): Promise<void> {
|
||||
if (progress.status === 'failed') {
|
||||
importVisible.value = false
|
||||
resetImport()
|
||||
showAdminFeedback((progress as { errorMessage?: string }).errorMessage || (mode === 'add' ? '导入失败' : '删除导入失败'), 'error')
|
||||
ElMessage.error((progress as { errorMessage?: string }).errorMessage || (mode === 'add' ? '导入失败' : '删除导入失败'))
|
||||
return
|
||||
}
|
||||
importProgress.value = progress.status === 'pending' ? '等待导入任务开始…' : '导入处理中…'
|
||||
@@ -303,7 +256,7 @@ async function submitImport(): Promise<void> {
|
||||
}
|
||||
throw new Error('查询导入进度超时,请稍后刷新列表确认结果')
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '导入失败', 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '导入失败')
|
||||
} finally {
|
||||
importRunning.value = false
|
||||
}
|
||||
@@ -313,7 +266,7 @@ async function submitImport(): Promise<void> {
|
||||
function doExport(): void {
|
||||
// 带当前筛选(分组/店铺名/ASIN/国家)导出,范围与列表筛选一致(此前不带参数导致导出恒为全量)。
|
||||
const anchor = document.createElement('a')
|
||||
anchor.href = toQueryAsinExportUrl(filter, companyTab.requestCompanyId)
|
||||
anchor.href = toQueryAsinExportUrl(filter)
|
||||
document.body.appendChild(anchor)
|
||||
anchor.click()
|
||||
anchor.remove()
|
||||
@@ -322,18 +275,14 @@ function doExport(): void {
|
||||
|
||||
async function loadGroups() {
|
||||
try {
|
||||
groups.value = await fetchShopManageGroups(companyTab.requestCompanyId)
|
||||
groups.value = await fetchShopManageGroups()
|
||||
} catch {
|
||||
groups.value = []
|
||||
}
|
||||
}
|
||||
|
||||
const batchListGate = createLatestRequestGate()
|
||||
|
||||
async function load() {
|
||||
const token = batchListGate.begin()
|
||||
loading.value = true
|
||||
loadFailure.value = ''
|
||||
try {
|
||||
const result = await fetchQueryAsinList({
|
||||
page: page.value,
|
||||
@@ -342,18 +291,14 @@ async function load() {
|
||||
shopName: filter.shopName.trim() || undefined,
|
||||
asin: filter.asin.trim() || undefined,
|
||||
country: filter.country || undefined,
|
||||
companyId: companyTab.requestCompanyId,
|
||||
})
|
||||
if (!batchListGate.isCurrent(token)) return
|
||||
rows.value = result.items
|
||||
total.value = result.total
|
||||
page.value = result.page
|
||||
} catch (error) {
|
||||
if (!batchListGate.isCurrent(token)) return
|
||||
loadFailure.value = error instanceof Error ? error.message : '数据加载失败'
|
||||
showAdminFeedback(loadFailure.value, 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '数据加载失败')
|
||||
} finally {
|
||||
if (batchListGate.isCurrent(token)) loading.value = false
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,11 +329,6 @@ function goJump() {
|
||||
changePage(Math.min(Math.max(n, 1), totalPages.value))
|
||||
}
|
||||
|
||||
// 切公司 = 重新取数:列表与分组下拉共用这一个 watch(少一个 = 那半边的 tab 是装饰品)。
|
||||
// groupId 与 shopName 必须一起清:上一家选中的分组/店铺名在新一家的可见集与候选字典里根本不存在,
|
||||
// 留着会把切 tab 后的首屏筛成空列表(请求、后端、权限三处都没错,最难查的那一型)。
|
||||
watch(() => companyTab.activeId, () => { filter.groupId = null; filter.shopName = ''; void loadGroups(); void load() })
|
||||
|
||||
onMounted(() => {
|
||||
void loadGroups()
|
||||
void load()
|
||||
@@ -408,7 +348,7 @@ onMounted(() => {
|
||||
</div>
|
||||
|
||||
<div class="form-row query-filter-row">
|
||||
<div v-if="isSuperAdmin" class="form-group">
|
||||
<div class="form-group">
|
||||
<label>分组</label>
|
||||
<el-select v-model="filter.groupId" class="admin-filter" filterable clearable placeholder="全部分组">
|
||||
<el-option v-for="group in groups" :key="group.id" :label="group.groupName" :value="group.id" />
|
||||
@@ -420,14 +360,10 @@ onMounted(() => {
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>国家</label>
|
||||
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 的弹层是浏览器直角原生物
|
||||
⇒ 换 el-select(与上面分组同一套 admin-filter 壳 42px/9px,弹层是 EP 圆角面板)。
|
||||
「全部国家」保留为空值首行(value="" 与改前同语义,下发仍是空串=不限);
|
||||
EP 把 '' 视作空值 ⇒ 闭壳走 placeholder,因此同步钉 placeholder="全部国家" 保持文案。 -->
|
||||
<el-select v-model="filter.country" class="admin-filter" filterable placeholder="全部国家" aria-label="筛选国家">
|
||||
<el-option label="全部国家" value="" />
|
||||
<el-option v-for="code in QUERY_ASIN_COUNTRIES" :key="code" :label="asinCountryLabel(code)" :value="code" />
|
||||
</el-select>
|
||||
<select v-model="filter.country">
|
||||
<option value="">全部国家</option>
|
||||
<option v-for="code in QUERY_ASIN_COUNTRIES" :key="code" :value="code">{{ asinCountryLabel(code) }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>ASIN</label>
|
||||
@@ -435,38 +371,26 @@ onMounted(() => {
|
||||
</div>
|
||||
<button class="btn" type="button" @click="apply">查询</button>
|
||||
<button class="btn btn-secondary" type="button" @click="doExport">导出 XLSX</button>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<div class="table-scroll query-asin-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="batch-delete-cell" scope="col">
|
||||
<BatchDeleteCheckbox label="全选当前页可删除记录" :checked="batch.pageAll" :partial="batch.pageSome"
|
||||
:disabled="batch.disabled || batch.pageEmpty" @change="batch.togglePage" />
|
||||
</th>
|
||||
<th style="width: 6%">序号</th>
|
||||
<th v-if="isSuperAdmin" style="width: 13%">分组</th>
|
||||
<th style="width: 13%">分组</th>
|
||||
<th style="width: 15%">店铺名</th>
|
||||
<th style="width: 24%">ASIN</th>
|
||||
<th style="width: 12%">国家</th>
|
||||
<th style="width: 170px">创建时间</th>
|
||||
<th style="width: 170px">更新时间</th>
|
||||
<th style="width: 140px">操作</th>
|
||||
<th style="width: 9%">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-if="displayRows.length">
|
||||
<tr v-for="row in displayRows" :key="`${row.item.id}-${row.country}`" :class="{ 'batch-selected': batch.isSelected(row.item) }">
|
||||
<tr v-for="row in displayRows" :key="`${row.item.id}-${row.country}`">
|
||||
<template v-if="row.isFirst">
|
||||
<td class="batch-delete-cell" :rowspan="row.rowspan">
|
||||
<BatchDeleteCheckbox :label="batch.reason(row.item) || `选择 ${batch.label(row.item)}`" :checked="batch.isSelected(row.item)"
|
||||
:disabled="batch.disabled || !!batch.reason(row.item)" @change="batch.toggle(row.item)" />
|
||||
</td>
|
||||
<td :rowspan="row.rowspan">{{ row.rowNo }}</td>
|
||||
<td v-if="isSuperAdmin" :rowspan="row.rowspan">{{ row.item.groupName || '—' }}</td>
|
||||
<td :rowspan="row.rowspan">{{ row.item.groupName || '—' }}</td>
|
||||
<td :rowspan="row.rowspan">{{ row.item.shopName }}</td>
|
||||
</template>
|
||||
<td>
|
||||
@@ -477,20 +401,18 @@ onMounted(() => {
|
||||
</td>
|
||||
<td>{{ asinCountryLabel(row.country || '') }}</td>
|
||||
<template v-if="row.isFirst">
|
||||
<td :rowspan="row.rowspan">{{ formatDateTime(row.item.createdAt) }}</td>
|
||||
<td :rowspan="row.rowspan">{{ formatDateTime(row.item.updatedAt) }}</td>
|
||||
<td :rowspan="row.rowspan" class="asin-col-actions">
|
||||
<button class="btn btn-sm" type="button" @click="openConfig(row.item as QueryAsinItem)">配置</button>
|
||||
<button class="btn btn-sm btn-danger" type="button" :disabled="batch.busy" @click="removeShopAsin(row.item as QueryAsinItem)">删除</button>
|
||||
<button class="btn btn-sm btn-danger" type="button" @click="removeShopAsin(row.item as QueryAsinItem)">删除</button>
|
||||
</td>
|
||||
</template>
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-else-if="loading">
|
||||
<td :colspan="isSuperAdmin ? 9 : 8" class="empty-tip">加载中...</td>
|
||||
<td colspan="6" class="empty-tip">加载中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td :colspan="isSuperAdmin ? 9 : 8" class="empty-tip">暂无数据</td>
|
||||
<td colspan="6" class="empty-tip">暂无数据</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -501,7 +423,7 @@ onMounted(() => {
|
||||
<el-dialog v-model="createVisible" title="新增查询 ASIN" width="560px" :close-on-click-modal="false">
|
||||
<el-form label-position="top" @submit.prevent>
|
||||
<el-form-item label="分组">
|
||||
<el-select v-model="createGroupId" placeholder="请选择分组" filterable clearable style="width: 100%" :disabled="lockedGroupId != null" @change="onCreateGroupChange">
|
||||
<el-select v-model="createGroupId" placeholder="请选择分组" filterable clearable style="width: 100%" @change="onCreateGroupChange">
|
||||
<el-option v-for="group in groups" :key="group.id" :label="group.groupName" :value="group.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -553,7 +475,7 @@ onMounted(() => {
|
||||
<el-dialog v-model="importVisible" :title="importMode === 'add' ? '导入添加查询 ASIN' : '删除导入查询 ASIN'" width="520px">
|
||||
<el-form label-position="top">
|
||||
<el-form-item label="分组(Excel 未提供时的兜底,可选)">
|
||||
<el-select filterable v-model="importGroupId" placeholder="可不选" clearable style="width: 100%" :disabled="lockedGroupId != null">
|
||||
<el-select filterable v-model="importGroupId" placeholder="可不选" clearable style="width: 100%">
|
||||
<el-option v-for="group in groups" :key="group.id" :label="group.groupName" :value="group.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -573,4 +495,275 @@ onMounted(() => {
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped src="./QueryAsinPage.css"></style>
|
||||
<style scoped>
|
||||
/* 像素复刻旧版 admin.html panel-query-asin(蓝白末层)。 */
|
||||
.query-view {
|
||||
font-family: inherit;
|
||||
color: #24384d;
|
||||
}
|
||||
.panel-box {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 20px 22px 24px;
|
||||
border: 1px solid #d8e3ee;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(145deg, #ffffff, #f9fbfd);
|
||||
box-shadow: 0 1px 2px rgba(39, 67, 94, 0.04), 0 14px 30px -24px rgba(39, 67, 94, 0.28);
|
||||
}
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 650;
|
||||
color: #24384d;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
.query-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.query-head-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.form-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
gap: 14px 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.query-filter-row > .form-group {
|
||||
flex: 1 1 140px;
|
||||
min-width: 0;
|
||||
}
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 7px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.form-group label {
|
||||
color: #5b6f83;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 9px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13.5px;
|
||||
font-family: inherit;
|
||||
color-scheme: light;
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover,
|
||||
.form-group select:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
}
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
min-height: 42px;
|
||||
padding: 9px 18px;
|
||||
border: 1px solid #4f78a5;
|
||||
border-radius: 9px;
|
||||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
||||
color: #ffffff;
|
||||
font-family: inherit;
|
||||
font-size: 13.5px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 8px 18px -14px rgba(79, 120, 165, 0.72);
|
||||
transition: background 160ms ease, box-shadow 160ms ease, transform 120ms ease;
|
||||
}
|
||||
.btn:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #7094ba, #5d83ac);
|
||||
box-shadow: 0 11px 22px -14px rgba(79, 120, 165, 0.8);
|
||||
}
|
||||
.btn:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.55;
|
||||
}
|
||||
.btn-secondary {
|
||||
background: #ffffff;
|
||||
color: #5b6f83;
|
||||
border-color: #c7d7e5;
|
||||
}
|
||||
.btn-secondary:hover:not(:disabled) {
|
||||
color: #2f5d8b;
|
||||
border-color: #95b1cb;
|
||||
background: #edf5fb;
|
||||
}
|
||||
.btn-danger {
|
||||
background: linear-gradient(135deg, #c06d77, #b35f6a);
|
||||
border-color: #b35f6a;
|
||||
}
|
||||
.btn-danger:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #cb7c84, #b96570);
|
||||
}
|
||||
.btn-sm {
|
||||
min-height: 36px;
|
||||
padding: 7px 12px;
|
||||
}
|
||||
.table-scroll {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
overflow-x: auto;
|
||||
border: 1px solid #dbe5ee;
|
||||
border-radius: 10px;
|
||||
background: #ffffff;
|
||||
}
|
||||
.table-scroll table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
table-layout: fixed;
|
||||
}
|
||||
.query-asin-table-scroll > table {
|
||||
min-width: 860px;
|
||||
}
|
||||
.table-scroll th,
|
||||
.table-scroll td {
|
||||
padding: 10px 12px;
|
||||
text-align: left;
|
||||
font-size: 13.5px;
|
||||
line-height: 1.5;
|
||||
border-bottom: 1px solid #e0e8ef;
|
||||
vertical-align: middle;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.table-scroll th {
|
||||
background: #edf4fa;
|
||||
color: #4e6479;
|
||||
border-bottom-color: #d5e1eb;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.4px;
|
||||
}
|
||||
.table-scroll tbody tr:hover td {
|
||||
background: #f1f7fb;
|
||||
}
|
||||
.table-scroll tbody tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.table-scroll td {
|
||||
vertical-align: top;
|
||||
}
|
||||
.asin-cell {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
margin: -3px 0 -3px -7px;
|
||||
padding: 3px 7px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 9px;
|
||||
background: none;
|
||||
color: inherit;
|
||||
font-size: 13.5px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
line-height: 1.5;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
cursor: pointer;
|
||||
}
|
||||
.asin-cell:hover {
|
||||
border-color: #c7d7e5;
|
||||
background: #eef4fa;
|
||||
color: #2f5d8b;
|
||||
}
|
||||
.asin-empty {
|
||||
color: #8b9aaa;
|
||||
}
|
||||
.asin-col-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
white-space: nowrap;
|
||||
background: #ffffff;
|
||||
box-shadow: -9px 0 12px -10px rgba(31, 48, 66, 0.45);
|
||||
}
|
||||
.empty-tip {
|
||||
padding: 44px 24px;
|
||||
text-align: center;
|
||||
color: #8293a5;
|
||||
font-size: 13.5px;
|
||||
}
|
||||
.pagination {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-top: 18px;
|
||||
color: #5b6f83;
|
||||
font-size: 13px;
|
||||
}
|
||||
.pagination button {
|
||||
min-height: 30px;
|
||||
padding: 4px 12px;
|
||||
border: 1px solid #c7d7e5;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
color: #5b6f83;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.pagination button:hover:not(:disabled) {
|
||||
background: #edf5fb;
|
||||
border-color: #95b1cb;
|
||||
color: #2f5d8b;
|
||||
}
|
||||
.pagination button:disabled {
|
||||
background: #eef3f7;
|
||||
color: #9baaba;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.page-total {
|
||||
margin-right: 4px;
|
||||
}
|
||||
.page-jump {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.page-jump input {
|
||||
width: 56px;
|
||||
min-height: 30px;
|
||||
padding: 4px 8px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 8px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
}
|
||||
.drawer-tip {
|
||||
color: #5b6f83;
|
||||
font-size: 12px;
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
.import-tip {
|
||||
margin: 6px 0 0;
|
||||
color: #5b6f83;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,300 +0,0 @@
|
||||
/* 像素复刻旧版 admin.html panel-skip-price-asin(蓝白末层)。 */
|
||||
.skip-view {
|
||||
font-family: inherit;
|
||||
color: #24384d;
|
||||
}
|
||||
.panel-box {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 20px 22px 24px;
|
||||
border: 1px solid #d8e3ee;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(145deg, #ffffff, #f9fbfd);
|
||||
box-shadow: 0 1px 2px rgba(39, 67, 94, 0.04), 0 14px 30px -24px rgba(39, 67, 94, 0.28);
|
||||
}
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 650;
|
||||
color: #24384d;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
.skip-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.skip-head-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.form-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
gap: 14px 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.skip-filter-row > .form-group {
|
||||
flex: 1 1 130px;
|
||||
min-width: 0;
|
||||
}
|
||||
.skip-filter-row .form-group.price-range {
|
||||
flex: 1 1 220px;
|
||||
}
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 7px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.form-group label {
|
||||
color: #5b6f83;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
/* 下拉壳由全局 .el-select.admin-filter(main.css:42px/9px 圆角/#f8fbfd 浅底/focus ring)出,
|
||||
与亚马逊面同一套;这里只留 input 的原生壳规则(2026-11-17 原生 select 全换 el-select)。 */
|
||||
.form-group input {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 9px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13.5px;
|
||||
font-family: inherit;
|
||||
color-scheme: light;
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
}
|
||||
.price-range-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
.price-range-row input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.price-range-row .range-sep {
|
||||
color: #8293a5;
|
||||
flex: none;
|
||||
}
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
min-height: 42px;
|
||||
padding: 9px 18px;
|
||||
border: 1px solid #4f78a5;
|
||||
border-radius: 9px;
|
||||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
||||
color: #ffffff;
|
||||
font-family: inherit;
|
||||
font-size: 13.5px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 8px 18px -14px rgba(79, 120, 165, 0.72);
|
||||
transition: background 160ms ease, box-shadow 160ms ease, transform 120ms ease;
|
||||
}
|
||||
.btn:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #7094ba, #5d83ac);
|
||||
box-shadow: 0 11px 22px -14px rgba(79, 120, 165, 0.8);
|
||||
}
|
||||
.btn:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.55;
|
||||
}
|
||||
.btn-secondary {
|
||||
background: #ffffff;
|
||||
color: #5b6f83;
|
||||
border-color: #c7d7e5;
|
||||
}
|
||||
.btn-secondary:hover:not(:disabled) {
|
||||
color: #2f5d8b;
|
||||
border-color: #95b1cb;
|
||||
background: #edf5fb;
|
||||
}
|
||||
.btn-danger {
|
||||
background: linear-gradient(135deg, #c06d77, #b35f6a);
|
||||
border-color: #b35f6a;
|
||||
}
|
||||
.btn-danger:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #cb7c84, #b96570);
|
||||
}
|
||||
.btn-sm {
|
||||
min-height: 36px;
|
||||
padding: 7px 12px;
|
||||
}
|
||||
.table-scroll {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
overflow-x: auto;
|
||||
border: 1px solid #dbe5ee;
|
||||
border-radius: 10px;
|
||||
background: #ffffff;
|
||||
}
|
||||
.table-scroll table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
table-layout: fixed;
|
||||
}
|
||||
.skip-price-asin-table-scroll > table {
|
||||
min-width: 900px;
|
||||
}
|
||||
.table-scroll th,
|
||||
.table-scroll td {
|
||||
padding: 10px 12px;
|
||||
text-align: left;
|
||||
font-size: 13.5px;
|
||||
line-height: 1.5;
|
||||
border-bottom: 1px solid #e0e8ef;
|
||||
vertical-align: middle;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.table-scroll th {
|
||||
background: #edf4fa;
|
||||
color: #4e6479;
|
||||
border-bottom-color: #d5e1eb;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.4px;
|
||||
}
|
||||
.table-scroll tbody tr:hover td {
|
||||
background: #f1f7fb;
|
||||
}
|
||||
.table-scroll tbody tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.table-scroll td {
|
||||
vertical-align: top;
|
||||
}
|
||||
.asin-cell {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
margin: -3px 0 -3px -7px;
|
||||
padding: 3px 7px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 9px;
|
||||
background: none;
|
||||
color: inherit;
|
||||
font-size: 13.5px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
line-height: 1.5;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
cursor: pointer;
|
||||
}
|
||||
.asin-cell:hover {
|
||||
border-color: #c7d7e5;
|
||||
background: #eef4fa;
|
||||
color: #2f5d8b;
|
||||
}
|
||||
.asin-empty {
|
||||
color: #8b9aaa;
|
||||
}
|
||||
.price-cell {
|
||||
text-align: right;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.asin-col-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
white-space: nowrap;
|
||||
/* 列宽已从 9% 改成 140px 下限(两字按钮 53×2 + gap 8 + td 左右 padding 24 = 138)。
|
||||
百分比会跟着容器一起缩,配上 justify-content:flex-end 后溢出翻到左侧,
|
||||
"配置"整颗被吃掉而"删除"看着完好——2026-10-08 那单截图就是这个形状。 */
|
||||
flex-wrap: wrap;
|
||||
background: #ffffff;
|
||||
box-shadow: -9px 0 12px -10px rgba(31, 48, 66, 0.45);
|
||||
}
|
||||
.empty-tip {
|
||||
padding: 44px 24px;
|
||||
text-align: center;
|
||||
color: #8293a5;
|
||||
font-size: 13.5px;
|
||||
}
|
||||
.pagination {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-top: 18px;
|
||||
color: #5b6f83;
|
||||
font-size: 13px;
|
||||
}
|
||||
.pagination button {
|
||||
min-height: 30px;
|
||||
padding: 4px 12px;
|
||||
border: 1px solid #c7d7e5;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
color: #5b6f83;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.pagination button:hover:not(:disabled) {
|
||||
background: #edf5fb;
|
||||
border-color: #95b1cb;
|
||||
color: #2f5d8b;
|
||||
}
|
||||
.pagination button:disabled {
|
||||
background: #eef3f7;
|
||||
color: #9baaba;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.page-total {
|
||||
margin-right: 4px;
|
||||
}
|
||||
.page-jump {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.page-jump input {
|
||||
width: 56px;
|
||||
min-height: 30px;
|
||||
padding: 4px 8px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 8px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
}
|
||||
.drawer-tip {
|
||||
color: #5b6f83;
|
||||
font-size: 12px;
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
.country-cell {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
}
|
||||
.import-tip {
|
||||
margin: 6px 0 0;
|
||||
color: #5b6f83;
|
||||
font-size: 12px;
|
||||
}
|
||||
@@ -1,16 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import BatchDeleteActions from '@/components/BatchDeleteActions.vue'
|
||||
import BatchDeleteCheckbox from '@/components/BatchDeleteCheckbox.vue'
|
||||
import { useRowSelection } from '@/utils/use-row-selection'
|
||||
import { createLatestRequestGate } from '@/utils/latest-request'
|
||||
/** 最低价 ASIN(跳过跟价)· 像素复刻旧版 admin.html panel-skip-price-asin(自绘:面板头操作组、筛选(分组/店铺/国家/ASIN/最低价≥≤)+导出 XLSX、原生 rowspan 表格、旧式分页)。
|
||||
* script 逻辑沿用现有 Vue 实现(新增级联+最低价、配置抽屉双列、导入轮询、导出)。 */
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import CopyText from '@/components/CopyText.vue'
|
||||
import { formatDateTime } from '@/utils/datetime'
|
||||
import { createSkipPriceAsin, fetchSkipPriceList } from './skip-price-api.ts'
|
||||
import { toSkipPriceExportUrl } from './skip-price-export.ts'
|
||||
import { skipPriceDisplayRows, type SkipPriceItem } from './skip-price-model.ts'
|
||||
import { asinCountryLabel } from './asin-country.ts'
|
||||
import { createSkipPriceFilterState, toSkipPriceParams, type SkipPriceFilterState } from './skip-price-filter.ts'
|
||||
@@ -21,29 +15,13 @@ import { fetchShopNamesByGroup } from './query-asin-api.ts'
|
||||
import { fetchShopManageGroups } from '../shop/shop-manage-api.ts'
|
||||
import type { ShopGroupOption } from '../shop/shop-dto.ts'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||||
|
||||
const session = useAdminSessionStore()
|
||||
const companyTab = useCompanyTabStore()
|
||||
/** 仅超管需要分组维度:非超管数据由后端裁剪到本人分组,分组筛选/列一律不展示。 */
|
||||
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
||||
|
||||
const loading = ref(false)
|
||||
const loadFailure = ref('')
|
||||
const rows = ref<SkipPriceItem[]>([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const groups = ref<ShopGroupOption[]>([])
|
||||
/** 非超管仅有一个可访问分组时,弹窗分组选择锁定为该组(保留展示、不可改)。 */
|
||||
const lockedGroupId = computed<number | null>(() => {
|
||||
if (isSuperAdmin.value) return null
|
||||
return groups.value.length === 1 ? groups.value[0].id : null
|
||||
})
|
||||
const filter = reactive<SkipPriceFilterState>(createSkipPriceFilterState())
|
||||
const jumpPage = ref('')
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||
@@ -79,7 +57,7 @@ const creating = ref(false)
|
||||
const createAsinInputRef = ref<InstanceType<typeof import('element-plus').ElInput> | null>(null)
|
||||
|
||||
function openCreate(): void {
|
||||
createGroupId.value = lockedGroupId.value
|
||||
createGroupId.value = null
|
||||
createShopName.value = ''
|
||||
createCountry.value = ''
|
||||
createAsin.value = ''
|
||||
@@ -88,8 +66,6 @@ function openCreate(): void {
|
||||
createMsgOk.value = false
|
||||
shopNames.value = []
|
||||
createVisible.value = true
|
||||
// 非超管分组已锁定:直接联动加载该分组店铺,省去一次无意义的选择。
|
||||
if (createGroupId.value != null) void onCreateGroupChange()
|
||||
}
|
||||
|
||||
async function onCreateGroupChange(): Promise<void> {
|
||||
@@ -100,10 +76,10 @@ async function onCreateGroupChange(): Promise<void> {
|
||||
}
|
||||
shopNamesLoading.value = true
|
||||
try {
|
||||
shopNames.value = await fetchShopNamesByGroup(createGroupId.value, companyTab.requestCompanyId)
|
||||
shopNames.value = await fetchShopNamesByGroup(createGroupId.value)
|
||||
} catch (error) {
|
||||
shopNames.value = []
|
||||
showAdminFeedback(error instanceof Error ? error.message : '店铺列表加载失败', 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '店铺列表加载失败')
|
||||
} finally {
|
||||
shopNamesLoading.value = false
|
||||
}
|
||||
@@ -216,7 +192,7 @@ async function saveConfig(): Promise<void> {
|
||||
}
|
||||
}
|
||||
if (errors.length) {
|
||||
showAdminFeedback(errors.join(';'), 'error')
|
||||
ElMessage.error(errors.join(';'))
|
||||
} else {
|
||||
ElMessage.success('保存成功')
|
||||
drawerVisible.value = false
|
||||
@@ -229,19 +205,7 @@ async function saveConfig(): Promise<void> {
|
||||
}
|
||||
|
||||
// ---- 整条删除 ----
|
||||
const batch = useRowSelection({
|
||||
pageRows: () => rows.value,
|
||||
rowId: (row) => row.id,
|
||||
rowLabel: (row) => row.groupName ? `${row.shopName}(${row.groupName})` : row.shopName,
|
||||
deleteOne: (id) => deleteSkipPriceAsin(id),
|
||||
refresh: load,
|
||||
blocked: () => loading.value || !!loadFailure.value,
|
||||
scope: () => companyTab.activeId,
|
||||
consequence: '将删除所选店铺全部站点的最低价 ASIN 配置,此操作不可恢复。',
|
||||
})
|
||||
|
||||
async function removeRow(item: SkipPriceItem): Promise<void> {
|
||||
if (batch.busy) return
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确定删除「${item.shopName}」${item.groupName ? `(${item.groupName})` : ''}全部站点的最低价 ASIN 配置吗?`,
|
||||
@@ -253,7 +217,6 @@ async function removeRow(item: SkipPriceItem): Promise<void> {
|
||||
}
|
||||
try {
|
||||
await deleteSkipPriceAsin(item.id)
|
||||
batch.removeFromSelection(item.id)
|
||||
ElMessage.success('删除成功')
|
||||
// 删除后当前页若已空且非首页,回退一页避免展示空页。
|
||||
if (rows.value.length === 1 && page.value > 1) {
|
||||
@@ -261,7 +224,7 @@ async function removeRow(item: SkipPriceItem): Promise<void> {
|
||||
}
|
||||
await load()
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,7 +238,7 @@ const importRunning = ref(false)
|
||||
const importProgress = ref('')
|
||||
|
||||
function resetImport(): void {
|
||||
importGroupId.value = lockedGroupId.value
|
||||
importGroupId.value = null
|
||||
importFile.value = null
|
||||
importProgress.value = ''
|
||||
importRunning.value = false
|
||||
@@ -317,7 +280,7 @@ async function submitImport(): Promise<void> {
|
||||
return
|
||||
}
|
||||
if (importMode.value === 'delete') {
|
||||
if (!(await openAdminConfirm({ message: '确定按 Excel 中的删除ASIN批量删除该店铺跳过跟价 ASIN 吗?', danger: true }))) return
|
||||
if (!window.confirm('确定按 Excel 中的删除ASIN批量删除该店铺跳过跟价 ASIN 吗?')) return
|
||||
}
|
||||
const mode = importMode.value
|
||||
const groupId = importGroupId.value as number
|
||||
@@ -338,7 +301,7 @@ async function submitImport(): Promise<void> {
|
||||
if (progress.status === 'failed') {
|
||||
importVisible.value = false
|
||||
resetImport()
|
||||
showAdminFeedback(progress.errorMessage || (mode === 'add' ? '导入失败' : '删除导入失败'), 'error')
|
||||
ElMessage.error(progress.errorMessage || (mode === 'add' ? '导入失败' : '删除导入失败'))
|
||||
return
|
||||
}
|
||||
importProgress.value = progress.status === 'pending' ? '等待导入任务开始…' : '导入处理中…'
|
||||
@@ -346,16 +309,15 @@ async function submitImport(): Promise<void> {
|
||||
}
|
||||
throw new Error('查询导入进度超时,请稍后刷新列表确认结果')
|
||||
} catch (error) {
|
||||
showAdminFeedback(error instanceof Error ? error.message : '导入失败', 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '导入失败')
|
||||
} finally {
|
||||
importRunning.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function doExport(): void {
|
||||
// 带当前筛选(分组/店铺名/ASIN/国家/最低价区间)+ 公司范围导出:此前不带任何参数,导出恒为全平台全量。
|
||||
const anchor = document.createElement('a')
|
||||
anchor.href = toSkipPriceExportUrl(filter, companyTab.requestCompanyId)
|
||||
anchor.href = '/api/admin/skip-price-asins/export'
|
||||
document.body.appendChild(anchor)
|
||||
anchor.click()
|
||||
anchor.remove()
|
||||
@@ -364,30 +326,23 @@ function doExport(): void {
|
||||
|
||||
async function loadGroups() {
|
||||
try {
|
||||
groups.value = await fetchShopManageGroups(companyTab.requestCompanyId)
|
||||
groups.value = await fetchShopManageGroups()
|
||||
} catch {
|
||||
groups.value = []
|
||||
}
|
||||
}
|
||||
|
||||
const batchListGate = createLatestRequestGate()
|
||||
|
||||
async function load() {
|
||||
const token = batchListGate.begin()
|
||||
loading.value = true
|
||||
loadFailure.value = ''
|
||||
try {
|
||||
const result = await fetchSkipPriceList(toSkipPriceParams(filter, page.value, pageSize.value, companyTab.requestCompanyId))
|
||||
if (!batchListGate.isCurrent(token)) return
|
||||
const result = await fetchSkipPriceList(toSkipPriceParams(filter, page.value, pageSize.value))
|
||||
rows.value = result.items
|
||||
total.value = result.total
|
||||
page.value = result.page
|
||||
} catch (error) {
|
||||
if (!batchListGate.isCurrent(token)) return
|
||||
loadFailure.value = error instanceof Error ? error.message : '数据加载失败'
|
||||
showAdminFeedback(loadFailure.value, 'error')
|
||||
ElMessage.error(error instanceof Error ? error.message : '数据加载失败')
|
||||
} finally {
|
||||
if (batchListGate.isCurrent(token)) loading.value = false
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,11 +373,6 @@ function goJump() {
|
||||
changePage(Math.min(Math.max(n, 1), totalPages.value))
|
||||
}
|
||||
|
||||
// 切公司 = 重新取数:列表与分组下拉共用这一个 watch(少一个 = 那半边的 tab 是装饰品)。
|
||||
// groupId 与 shopName 必须一起清:上一家选中的分组/店铺名在新一家的可见集与候选字典里根本不存在,
|
||||
// 留着会把切 tab 后的首屏筛成空列表(请求、后端、权限三处都没错,最难查的那一型)。
|
||||
watch(() => companyTab.activeId, () => { filter.groupId = null; filter.shopName = ''; void loadGroups(); void load() })
|
||||
|
||||
onMounted(() => {
|
||||
void loadGroups()
|
||||
void load()
|
||||
@@ -442,7 +392,7 @@ onMounted(() => {
|
||||
</div>
|
||||
|
||||
<div class="form-row skip-filter-row">
|
||||
<div v-if="isSuperAdmin" class="form-group">
|
||||
<div class="form-group">
|
||||
<label>分组</label>
|
||||
<el-select v-model="filter.groupId" class="admin-filter" filterable clearable placeholder="全部分组">
|
||||
<el-option v-for="group in groups" :key="group.id" :label="group.groupName" :value="group.id" />
|
||||
@@ -454,14 +404,10 @@ onMounted(() => {
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>国家</label>
|
||||
<!-- 2026-11-17 用户口径「和亚马逊不统一」:原生 select 的弹层是浏览器直角原生物
|
||||
⇒ 换 el-select(与上面分组同一套 admin-filter 壳 42px/9px,弹层是 EP 圆角面板)。
|
||||
「全部国家」保留为空值首行(value="" 与改前同语义,下发仍是空串=不限);
|
||||
EP 把 '' 视作空值 ⇒ 闭壳走 placeholder,因此同步钉 placeholder="全部国家" 保持文案。 -->
|
||||
<el-select v-model="filter.country" class="admin-filter" filterable placeholder="全部国家" aria-label="筛选国家">
|
||||
<el-option label="全部国家" value="" />
|
||||
<el-option v-for="code in COUNTRIES" :key="code" :label="asinCountryLabel(code)" :value="code" />
|
||||
</el-select>
|
||||
<select v-model="filter.country">
|
||||
<option value="">全部国家</option>
|
||||
<option v-for="code in COUNTRIES" :key="code" :value="code">{{ asinCountryLabel(code) }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>ASIN</label>
|
||||
@@ -477,39 +423,27 @@ onMounted(() => {
|
||||
</div>
|
||||
<button class="btn" type="button" @click="apply">查询</button>
|
||||
<button class="btn btn-secondary" type="button" @click="doExport">导出 XLSX</button>
|
||||
<BatchDeleteActions :batch="batch" />
|
||||
</div>
|
||||
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<div class="table-scroll skip-price-asin-table-scroll">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="batch-delete-cell" scope="col">
|
||||
<BatchDeleteCheckbox label="全选当前页可删除记录" :checked="batch.pageAll" :partial="batch.pageSome"
|
||||
:disabled="batch.disabled || batch.pageEmpty" @change="batch.togglePage" />
|
||||
</th>
|
||||
<th style="width: 6%">序号</th>
|
||||
<th v-if="isSuperAdmin" style="width: 13%">分组</th>
|
||||
<th style="width: 13%">分组</th>
|
||||
<th style="width: 15%">店铺名</th>
|
||||
<th style="width: 24%">ASIN</th>
|
||||
<th style="width: 12%">国家</th>
|
||||
<th style="width: 10%">最低价</th>
|
||||
<th style="width: 170px">创建时间</th>
|
||||
<th style="width: 170px">更新时间</th>
|
||||
<th style="width: 140px">操作</th>
|
||||
<th style="width: 9%">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-if="displayRows.length">
|
||||
<tr v-for="row in displayRows" :key="`${row.item.id}-${row.country}`" :class="{ 'batch-selected': batch.isSelected(row.item) }">
|
||||
<tr v-for="row in displayRows" :key="`${row.item.id}-${row.country}`">
|
||||
<template v-if="row.isFirst">
|
||||
<td class="batch-delete-cell" :rowspan="row.rowspan">
|
||||
<BatchDeleteCheckbox :label="batch.reason(row.item) || `选择 ${batch.label(row.item)}`" :checked="batch.isSelected(row.item)"
|
||||
:disabled="batch.disabled || !!batch.reason(row.item)" @change="batch.toggle(row.item)" />
|
||||
</td>
|
||||
<td :rowspan="row.rowspan">{{ row.rowNo }}</td>
|
||||
<td v-if="isSuperAdmin" :rowspan="row.rowspan">{{ row.item.groupName || '—' }}</td>
|
||||
<td :rowspan="row.rowspan">{{ row.item.groupName || '—' }}</td>
|
||||
<td :rowspan="row.rowspan">{{ row.item.shopName }}</td>
|
||||
</template>
|
||||
<td>
|
||||
@@ -521,20 +455,18 @@ onMounted(() => {
|
||||
<td>{{ asinCountryLabel(row.country || '') }}</td>
|
||||
<td class="price-cell">{{ row.minimumPrice !== '' ? row.minimumPrice : '-' }}</td>
|
||||
<template v-if="row.isFirst">
|
||||
<td :rowspan="row.rowspan">{{ formatDateTime(row.item.createdAt) }}</td>
|
||||
<td :rowspan="row.rowspan">{{ formatDateTime(row.item.updatedAt) }}</td>
|
||||
<td :rowspan="row.rowspan" class="asin-col-actions">
|
||||
<button class="btn btn-sm" type="button" @click="openConfig(row.item as SkipPriceItem)">配置</button>
|
||||
<button class="btn btn-sm btn-danger" type="button" :disabled="batch.busy" @click="removeRow(row.item as SkipPriceItem)">删除</button>
|
||||
<button class="btn btn-sm btn-danger" type="button" @click="removeRow(row.item as SkipPriceItem)">删除</button>
|
||||
</td>
|
||||
</template>
|
||||
</tr>
|
||||
</template>
|
||||
<tr v-else-if="loading">
|
||||
<td :colspan="isSuperAdmin ? 10 : 9" class="empty-tip">加载中...</td>
|
||||
<td colspan="7" class="empty-tip">加载中...</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td :colspan="isSuperAdmin ? 10 : 9" class="empty-tip">暂无数据</td>
|
||||
<td colspan="7" class="empty-tip">暂无数据</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -545,7 +477,7 @@ onMounted(() => {
|
||||
<el-dialog v-model="createVisible" title="新增 ASIN" width="560px" :close-on-click-modal="false">
|
||||
<el-form label-position="top" @submit.prevent>
|
||||
<el-form-item label="分组">
|
||||
<el-select v-model="createGroupId" placeholder="请选择分组" filterable clearable style="width: 100%" :disabled="lockedGroupId != null" @change="onCreateGroupChange">
|
||||
<el-select v-model="createGroupId" placeholder="请选择分组" filterable clearable style="width: 100%" @change="onCreateGroupChange">
|
||||
<el-option v-for="group in groups" :key="group.id" :label="group.groupName" :value="group.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -603,7 +535,7 @@ onMounted(() => {
|
||||
<el-dialog v-model="importVisible" :title="importMode === 'add' ? '导入最低价 ASIN' : '删除导入最低价 ASIN'" width="520px">
|
||||
<el-form label-position="top">
|
||||
<el-form-item label="分组(必选)">
|
||||
<el-select filterable v-model="importGroupId" placeholder="请选择分组" style="width: 100%" :disabled="lockedGroupId != null">
|
||||
<el-select filterable v-model="importGroupId" placeholder="请选择分组" style="width: 100%">
|
||||
<el-option v-for="group in groups" :key="group.id" :label="group.groupName" :value="group.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -623,4 +555,302 @@ onMounted(() => {
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped src="./SkipPricePage.css"></style>
|
||||
<style scoped>
|
||||
/* 像素复刻旧版 admin.html panel-skip-price-asin(蓝白末层)。 */
|
||||
.skip-view {
|
||||
font-family: inherit;
|
||||
color: #24384d;
|
||||
}
|
||||
.panel-box {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 20px 22px 24px;
|
||||
border: 1px solid #d8e3ee;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(145deg, #ffffff, #f9fbfd);
|
||||
box-shadow: 0 1px 2px rgba(39, 67, 94, 0.04), 0 14px 30px -24px rgba(39, 67, 94, 0.28);
|
||||
}
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 650;
|
||||
color: #24384d;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
.skip-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.skip-head-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.form-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
gap: 14px 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.skip-filter-row > .form-group {
|
||||
flex: 1 1 130px;
|
||||
min-width: 0;
|
||||
}
|
||||
.skip-filter-row .form-group.price-range {
|
||||
flex: 1 1 220px;
|
||||
}
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 7px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.form-group label {
|
||||
color: #5b6f83;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
min-width: 0;
|
||||
min-height: 42px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 9px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13.5px;
|
||||
font-family: inherit;
|
||||
color-scheme: light;
|
||||
outline: none;
|
||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
||||
}
|
||||
.form-group input:hover,
|
||||
.form-group select:hover {
|
||||
border-color: #9fb7cd;
|
||||
}
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
background: #ffffff;
|
||||
border-color: #5f85ad;
|
||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
||||
}
|
||||
.price-range-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
.price-range-row input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.price-range-row .range-sep {
|
||||
color: #8293a5;
|
||||
flex: none;
|
||||
}
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
min-height: 42px;
|
||||
padding: 9px 18px;
|
||||
border: 1px solid #4f78a5;
|
||||
border-radius: 9px;
|
||||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
||||
color: #ffffff;
|
||||
font-family: inherit;
|
||||
font-size: 13.5px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 8px 18px -14px rgba(79, 120, 165, 0.72);
|
||||
transition: background 160ms ease, box-shadow 160ms ease, transform 120ms ease;
|
||||
}
|
||||
.btn:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #7094ba, #5d83ac);
|
||||
box-shadow: 0 11px 22px -14px rgba(79, 120, 165, 0.8);
|
||||
}
|
||||
.btn:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.55;
|
||||
}
|
||||
.btn-secondary {
|
||||
background: #ffffff;
|
||||
color: #5b6f83;
|
||||
border-color: #c7d7e5;
|
||||
}
|
||||
.btn-secondary:hover:not(:disabled) {
|
||||
color: #2f5d8b;
|
||||
border-color: #95b1cb;
|
||||
background: #edf5fb;
|
||||
}
|
||||
.btn-danger {
|
||||
background: linear-gradient(135deg, #c06d77, #b35f6a);
|
||||
border-color: #b35f6a;
|
||||
}
|
||||
.btn-danger:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #cb7c84, #b96570);
|
||||
}
|
||||
.btn-sm {
|
||||
min-height: 36px;
|
||||
padding: 7px 12px;
|
||||
}
|
||||
.table-scroll {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
overflow-x: auto;
|
||||
border: 1px solid #dbe5ee;
|
||||
border-radius: 10px;
|
||||
background: #ffffff;
|
||||
}
|
||||
.table-scroll table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
table-layout: fixed;
|
||||
}
|
||||
.skip-price-asin-table-scroll > table {
|
||||
min-width: 900px;
|
||||
}
|
||||
.table-scroll th,
|
||||
.table-scroll td {
|
||||
padding: 10px 12px;
|
||||
text-align: left;
|
||||
font-size: 13.5px;
|
||||
line-height: 1.5;
|
||||
border-bottom: 1px solid #e0e8ef;
|
||||
vertical-align: middle;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.table-scroll th {
|
||||
background: #edf4fa;
|
||||
color: #4e6479;
|
||||
border-bottom-color: #d5e1eb;
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.4px;
|
||||
}
|
||||
.table-scroll tbody tr:hover td {
|
||||
background: #f1f7fb;
|
||||
}
|
||||
.table-scroll tbody tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
.table-scroll td {
|
||||
vertical-align: top;
|
||||
}
|
||||
.asin-cell {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
margin: -3px 0 -3px -7px;
|
||||
padding: 3px 7px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 9px;
|
||||
background: none;
|
||||
color: inherit;
|
||||
font-size: 13.5px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
line-height: 1.5;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
cursor: pointer;
|
||||
}
|
||||
.asin-cell:hover {
|
||||
border-color: #c7d7e5;
|
||||
background: #eef4fa;
|
||||
color: #2f5d8b;
|
||||
}
|
||||
.asin-empty {
|
||||
color: #8b9aaa;
|
||||
}
|
||||
.price-cell {
|
||||
text-align: right;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.asin-col-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
white-space: nowrap;
|
||||
background: #ffffff;
|
||||
box-shadow: -9px 0 12px -10px rgba(31, 48, 66, 0.45);
|
||||
}
|
||||
.empty-tip {
|
||||
padding: 44px 24px;
|
||||
text-align: center;
|
||||
color: #8293a5;
|
||||
font-size: 13.5px;
|
||||
}
|
||||
.pagination {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-top: 18px;
|
||||
color: #5b6f83;
|
||||
font-size: 13px;
|
||||
}
|
||||
.pagination button {
|
||||
min-height: 30px;
|
||||
padding: 4px 12px;
|
||||
border: 1px solid #c7d7e5;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
color: #5b6f83;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.pagination button:hover:not(:disabled) {
|
||||
background: #edf5fb;
|
||||
border-color: #95b1cb;
|
||||
color: #2f5d8b;
|
||||
}
|
||||
.pagination button:disabled {
|
||||
background: #eef3f7;
|
||||
color: #9baaba;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.page-total {
|
||||
margin-right: 4px;
|
||||
}
|
||||
.page-jump {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.page-jump input {
|
||||
width: 56px;
|
||||
min-height: 30px;
|
||||
padding: 4px 8px;
|
||||
border: 1px solid #cbd9e6;
|
||||
border-radius: 8px;
|
||||
background: #f8fbfd;
|
||||
color: #24384d;
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
}
|
||||
.drawer-tip {
|
||||
color: #5b6f83;
|
||||
font-size: 12px;
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
.country-cell {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
}
|
||||
.import-tip {
|
||||
margin: 6px 0 0;
|
||||
color: #5b6f83;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -24,12 +24,6 @@ export interface AsinListParams {
|
||||
groupId?: number | null
|
||||
/** 国家代码(如 DE、UK)。 */
|
||||
country?: string
|
||||
/** 顺序翻页游标(上一页返回的 nextLastId):传了就忽略 page 偏移,走 keyset。 */
|
||||
lastId?: number
|
||||
/** 公司 tab 的值。normalizeAsinPageParams 是白名单构造、**故意不点名它**
|
||||
*(归一化函数不认识公司这一维,也不许认识:公司值由发送口自己下传),
|
||||
* 所以取数函数必须从原始入参读这一项,读归一化结果会拿到 undefined。 */
|
||||
companyId?: number | null
|
||||
}
|
||||
|
||||
/** 序列化到 Java 分页接口的查询参数(snake_case)。 */
|
||||
@@ -42,10 +36,6 @@ export interface AsinPageQuery {
|
||||
end_date?: string
|
||||
group_id?: number
|
||||
country?: string
|
||||
/** 顺序翻页游标(keyset):传了就忽略 page 偏移。 */
|
||||
last_id?: number
|
||||
/** 公司 tab:与 Java 各列表接口的 `@RequestParam(name = "company_id")` 逐字对齐。 */
|
||||
company_id?: number
|
||||
}
|
||||
|
||||
function finiteInt(value: unknown): number | null {
|
||||
@@ -87,6 +77,5 @@ export function toAsinPageQuery(params: AsinListParams): AsinPageQuery {
|
||||
if (params.endDate) query.end_date = params.endDate
|
||||
if (params.groupId != null) query.group_id = params.groupId
|
||||
if (params.country) query.country = params.country
|
||||
if (typeof params.lastId === 'number' && params.lastId > 0) query.last_id = params.lastId
|
||||
return query
|
||||
}
|
||||
|
||||
@@ -1,20 +1,14 @@
|
||||
/**
|
||||
* 去重汇总导入启动适配(任务 65):multipart POST /import(file+groupId+company_id) → importId。
|
||||
*
|
||||
* <p>company_id 决定这批数据写进哪一家:超管认页面上方 tab,非超管 requestCompanyId 为 null
|
||||
* ⇒ 一个字段都不发,后端按会话恒锁本公司。</p>
|
||||
*/
|
||||
/** 去重汇总导入启动适配(任务 65):multipart POST /import(file+groupId) → importId。 */
|
||||
import { http } from '@/api/http'
|
||||
import { parseDedupeImportProgress, parseDedupeImportStart, type DedupeImportProgress } from './dedupe-import-model'
|
||||
|
||||
export const DEDUPE_IMPORT_ENDPOINT = '/api/admin/dedupe-total-data/import'
|
||||
export const DEDUPE_DELETE_IMPORT_ENDPOINT = '/api/admin/dedupe-total-data/delete-import'
|
||||
|
||||
export async function startDedupeImport(file: File, groupId: number, companyId?: number | null): Promise<string> {
|
||||
export async function startDedupeImport(file: File, groupId: number): Promise<string> {
|
||||
const form = new FormData()
|
||||
form.append('file', file, file.name)
|
||||
form.append('groupId', String(groupId))
|
||||
if (companyId != null) form.append('company_id', String(companyId))
|
||||
const { data } = await http.post<unknown>(DEDUPE_IMPORT_ENDPOINT, form)
|
||||
return parseDedupeImportStart(data)
|
||||
}
|
||||
@@ -26,12 +20,10 @@ export async function fetchDedupeImportProgress(importId: string): Promise<Dedup
|
||||
}
|
||||
|
||||
/** 删除导入启动:multipart POST /delete-import(file+groupId) → importId。 */
|
||||
export async function startDedupeDeleteImport(file: File, groupId: number,
|
||||
companyId?: number | null): Promise<string> {
|
||||
export async function startDedupeDeleteImport(file: File, groupId: number): Promise<string> {
|
||||
const form = new FormData()
|
||||
form.append('file', file, file.name)
|
||||
form.append('groupId', String(groupId))
|
||||
if (companyId != null) form.append('company_id', String(companyId))
|
||||
const { data } = await http.post<unknown>(DEDUPE_DELETE_IMPORT_ENDPOINT, form)
|
||||
return parseDedupeImportStart(data)
|
||||
}
|
||||
|
||||
@@ -10,11 +10,7 @@ export const DEDUPE_GROUPS_ENDPOINT = '/api/admin/shop-manages/groups'
|
||||
|
||||
export async function fetchDedupeTotalList(params: Partial<AsinListParams> = {}): Promise<DedupeTotalPageResult> {
|
||||
const normalized = normalizeAsinPageParams(params)
|
||||
// normalizeAsinPageParams 是白名单构造(不点名 companyId),所以公司值只能从原始 params 读:
|
||||
// 写成 normalized.companyId 是 TS 绿、运行时恒 undefined,请求里根本没这个参数。
|
||||
const query = toAsinPageQuery(normalized)
|
||||
if (params.companyId != null) query.company_id = params.companyId
|
||||
const { data } = await http.get<unknown>(DEDUPE_TOTAL_ENDPOINT, { params: query })
|
||||
const { data } = await http.get<unknown>(DEDUPE_TOTAL_ENDPOINT, { params: toAsinPageQuery(normalized) })
|
||||
return parseDedupeTotalPage(data)
|
||||
}
|
||||
|
||||
@@ -36,10 +32,7 @@ export async function deleteDedupeTotal(id: number): Promise<void> {
|
||||
}
|
||||
|
||||
/** 加载数据权限分组选项:GET /shop-manages/groups → {id,name,leaderUserId}[]。 */
|
||||
export async function fetchDedupeTotalGroups(companyId?: number | null): Promise<DedupeGroupOption[]> {
|
||||
// null 由发送口自己丢掉(不依赖 axios 丢 null):非超管/未选 tab 时不发 company_id,后端按会话裁剪。
|
||||
// platform 恒 'amazon'(2026-11-22 用户口径「亚马逊的也是同理」):去重/ASIN 面是亚马逊域,
|
||||
// 京东档分组(platform='jd')不得混进本下拉——与分组管理页按平台 tab 过滤同口径。
|
||||
const { data } = await http.get<unknown>(DEDUPE_GROUPS_ENDPOINT, { params: { platform: 'amazon', ...(companyId != null ? { company_id: companyId } : {}) } })
|
||||
export async function fetchDedupeTotalGroups(): Promise<DedupeGroupOption[]> {
|
||||
const { data } = await http.get<unknown>(DEDUPE_GROUPS_ENDPOINT)
|
||||
return parseDedupeGroupOptionList(data)
|
||||
}
|
||||
|
||||
@@ -20,33 +20,23 @@ export function exportStageHint(stage: DedupeExportStage): string | undefined {
|
||||
}
|
||||
}
|
||||
|
||||
/** 按导出可用筛选(用户名/日期区间/分组/国家)构建查询参数;空白/非法条件不下发。
|
||||
* 公司 tab 也在参数里:导出与列表必须同一个范围,否则「tab 筛了表格、导出给全量」就是越权泄露。 */
|
||||
export function buildDedupeExportParams(
|
||||
state: DedupeTotalFilterState,
|
||||
companyId?: number | null,
|
||||
): Record<string, string> {
|
||||
const params: Record<string, string> = {}
|
||||
/** 按导出可用筛选(用户名/日期区间/分组/国家)构建查询串;空白/非法条件不下发。 */
|
||||
export function buildDedupeExportQuery(state: DedupeTotalFilterState): string {
|
||||
const params = new URLSearchParams()
|
||||
const username = (state.username || '').trim()
|
||||
const country = (state.country || '').trim()
|
||||
if (username) params.username = username
|
||||
if (country) params.country = country
|
||||
if (username) params.set('username', username)
|
||||
if (country) params.set('country', country)
|
||||
const startDate = validIsoDateOrUndefined(state.startDate)
|
||||
const endDate = validIsoDateOrUndefined(state.endDate)
|
||||
if (startDate) params.start_date = startDate
|
||||
if (endDate) params.end_date = endDate
|
||||
if (typeof state.groupId === 'number' && state.groupId >= 1) params.group_id = String(state.groupId)
|
||||
if (companyId != null) params.company_id = String(companyId)
|
||||
return params
|
||||
}
|
||||
|
||||
/** 按导出可用筛选构建查询串;条件编码与 URLSearchParams 一致。 */
|
||||
export function buildDedupeExportQuery(state: DedupeTotalFilterState, companyId?: number | null): string {
|
||||
return new URLSearchParams(buildDedupeExportParams(state, companyId)).toString()
|
||||
if (startDate) params.set('start_date', startDate)
|
||||
if (endDate) params.set('end_date', endDate)
|
||||
if (typeof state.groupId === 'number' && state.groupId >= 1) params.set('group_id', String(state.groupId))
|
||||
return params.toString()
|
||||
}
|
||||
|
||||
/** 导出下载地址:浏览器直接访问该 URL 触发流式下载。 */
|
||||
export function toExportUrl(state: DedupeTotalFilterState, companyId?: number | null): string {
|
||||
const query = buildDedupeExportQuery(state, companyId)
|
||||
export function toExportUrl(state: DedupeTotalFilterState): string {
|
||||
const query = buildDedupeExportQuery(state)
|
||||
return query ? `${DEDUPE_TOTAL_EXPORT_ENDPOINT}?${query}` : DEDUPE_TOTAL_EXPORT_ENDPOINT
|
||||
}
|
||||
|
||||
@@ -30,12 +30,8 @@ export function toDedupeListParams(
|
||||
state: DedupeTotalFilterState,
|
||||
page: number,
|
||||
pageSize: number,
|
||||
lastId?: number | null,
|
||||
companyId?: number | null,
|
||||
): AsinListParams {
|
||||
const params: AsinListParams = { page, pageSize }
|
||||
if (typeof lastId === 'number' && lastId > 0) params.lastId = lastId
|
||||
if (companyId != null) params.companyId = companyId
|
||||
const keyword = (state.keyword || '').trim()
|
||||
const username = (state.username || '').trim()
|
||||
const country = (state.country || '').trim()
|
||||
|
||||
@@ -11,7 +11,6 @@ export interface DedupeTotalItem {
|
||||
uploaderUserId: number | null
|
||||
username: string
|
||||
createdAt?: string
|
||||
updatedAt?: string
|
||||
}
|
||||
|
||||
export interface DedupeTotalPageResult {
|
||||
@@ -19,8 +18,6 @@ export interface DedupeTotalPageResult {
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
/** 顺序翻页游标:本页最后一行 id;下一页回传它即可走 keyset。 */
|
||||
nextLastId?: number
|
||||
}
|
||||
|
||||
export function emptyDedupeTotalPage(): DedupeTotalPageResult {
|
||||
@@ -52,8 +49,6 @@ export function toDedupeTotalItem(raw: unknown): DedupeTotalItem | null {
|
||||
}
|
||||
const createdAt = text(record.createdAt ?? record.created_at)
|
||||
if (createdAt) item.createdAt = createdAt
|
||||
const updatedAt = text(record.updatedAt ?? record.updated_at)
|
||||
if (updatedAt) item.updatedAt = updatedAt
|
||||
return item
|
||||
}
|
||||
|
||||
@@ -70,8 +65,6 @@ export function parseDedupeTotalPage(payload: unknown): DedupeTotalPageResult {
|
||||
}
|
||||
if (typeof record.total === 'number') out.total = Math.floor(record.total)
|
||||
if (typeof record.page === 'number' && record.page >= 1) out.page = Math.floor(record.page)
|
||||
const rawNextLastId = record.nextLastId ?? record.next_last_id
|
||||
if (typeof rawNextLastId === 'number' && rawNextLastId > 0) out.nextLastId = Math.floor(rawNextLastId)
|
||||
const rawSize = record.pageSize ?? record.page_size
|
||||
if (typeof rawSize === 'number' && rawSize >= 1) out.pageSize = Math.floor(rawSize)
|
||||
return out
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user