Compare commits
1459 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3a49f5f8d1 | |||
| b8792d05c0 | |||
| e7857466e9 | |||
| 569c76f216 | |||
| 0ab379b2d7 | |||
| d519b0b8aa | |||
| ec35707c5f | |||
| 14263dae16 | |||
| cbaab06783 | |||
| 16bb63625f | |||
| c5712f6b17 | |||
| d09bd8a31e | |||
| 53c8b25dfd | |||
| a53ee7cfa0 | |||
| 0ab165319a | |||
| 18e25ee8b5 | |||
| 1d27806a61 | |||
| 5bc886f14d | |||
| fcb7fca0b0 | |||
| e0cdd102d5 | |||
| bb5937fa9b | |||
| 2cae0d742c | |||
| bff7068421 | |||
| 84d72f67ae | |||
| 09aab7292c | |||
| ad94421b53 | |||
| 82c9eedd77 | |||
| b4db01d320 | |||
| 3a7669fbe7 | |||
| 99687f4601 | |||
| 6a355e842f | |||
| c1088cd45e | |||
| 3654d02256 | |||
| 0d7030deb8 | |||
| 3c9754b697 | |||
| 0ffa9ab002 | |||
| 01fe3c2f2d | |||
| a9c74b9ad2 | |||
| 6662d67652 | |||
| adff3b8978 | |||
| 132da8b12c | |||
| 04385487c5 | |||
| c3bb2aaba7 | |||
| 59ff357d9b | |||
| fba3eb985d | |||
| de743399ec | |||
| 950e838ea7 | |||
| db91394837 | |||
| 3793850552 | |||
| fd8942efe7 | |||
| a372560818 | |||
| 0f3fd3e0ec | |||
| d2977a308c | |||
| 8be9892522 | |||
| 47f24162d5 | |||
| 271e98543b | |||
| 5e721cb255 | |||
| 81818c0ccd | |||
| bdd34356d6 | |||
| 71b15b088c | |||
| 6a56f79bd5 | |||
| ce8adb6d68 | |||
| d04f505515 | |||
| ad3c242444 | |||
| e64817c736 | |||
| 1b6e1e4edb | |||
| fdc09c33d4 | |||
| 9a33a2656d | |||
| e965c0f132 | |||
| 812c846644 | |||
| 91c2e53f5e | |||
| 6f880f2b6a | |||
| 5d2b6a2d0e | |||
| c91a6b3011 | |||
| 2d6079c241 | |||
| a36d0dec87 | |||
| a972f21262 | |||
| 5902f87dd3 | |||
| b32ae9f857 | |||
| 356f9f032b | |||
| 51c09c8b6b | |||
| ac2c89e7ca | |||
| acf245f796 | |||
| 85cbd56cd8 | |||
| 06c1a3accd | |||
| 5373160e27 | |||
| 67b62cc3d7 | |||
| 85e1e92ac8 | |||
| b7873209da | |||
| 00e5df0207 | |||
| 8cb53e6bab | |||
| c0361748b9 | |||
| 480180682d | |||
| b404fd2572 | |||
| 9e7c100389 | |||
| edc3008a2b | |||
| 079d6c3700 | |||
| 01250a5999 | |||
| 56fc92a10b | |||
| 5e5c4012d7 | |||
| 27859af824 | |||
| de97040bfc | |||
| c4a35c6447 | |||
| e3913ce7e8 | |||
| 15b8e46af8 | |||
| 4dbac40ef3 | |||
| f81d89bae1 | |||
| 4ffd407c53 | |||
| eba16ea639 | |||
| f20bca1af2 | |||
| 5b8cf59d30 | |||
| f1269f3117 | |||
| 06396d537e | |||
| e4083732a9 | |||
| 60ff3f0434 | |||
| 54c407a0fd | |||
| 0390788f2b | |||
| 861c7b4be5 | |||
| b8c9796d39 | |||
| af5835d010 | |||
| 7ff1fa01a4 | |||
| 1737903ec7 | |||
| bb4a3f2d46 | |||
| a3795e36e1 | |||
| 3fd58ec197 | |||
| 7ffb404a36 | |||
| 91d85ec63e | |||
| 4015563ecc | |||
| 0e4a854169 | |||
| 17cc775176 | |||
| 8c37bcc7e9 | |||
| e90f614962 | |||
| 0384d62968 | |||
| 517b02485b | |||
| 16e2c9a5e7 | |||
| 2f5e0d7b17 | |||
| 904e062ad4 | |||
| 57cc443dff | |||
| da9b559613 | |||
| 84dfc6008c | |||
| b6cbf27799 | |||
| 04ddb1e1ad | |||
| 88998818b1 | |||
| b3c17a066d | |||
| 355b0d3392 | |||
| 553b4f0fb8 | |||
| ca1e363be7 | |||
| ba0e1ca20a | |||
| 762d3bd0d1 | |||
| ab0293c440 | |||
| a38d675624 | |||
| 6fd2c6ecae | |||
| d4974f16d1 | |||
| ecb3be1d15 | |||
| dfb75dd0ff | |||
| 70a6018175 | |||
| 209ace9550 | |||
| ffa7bd1c89 | |||
| 165450201c | |||
| f3fe5f0672 | |||
| 6e0e3a2d26 | |||
| 6b14cebee5 | |||
| 251a7abd35 | |||
| 8143a5114d | |||
| 12d4bdcfee | |||
| 41e29e5fa0 | |||
| aca31935eb | |||
| c6611fbb99 | |||
| 0fe2121ba7 | |||
| e005994fe6 | |||
| c34b3e8e1b | |||
| d430ec54b3 | |||
| 29155e9e0a | |||
| 96d4ca68e1 | |||
| 5e86c2806c | |||
| 293e1d54fb | |||
| 75e486809f | |||
| ccd893ab80 | |||
| 45375296f3 | |||
| 218ec00296 | |||
| cff612e236 | |||
| b6f426ccbd | |||
| fecc19b52f | |||
| a2f278c4c4 | |||
| b169566c2b | |||
| a6e4a589f4 | |||
| 2b77dd1273 | |||
| dd06a1cf0b | |||
| 6d53fd6e6e | |||
| 3dcf1e5907 | |||
| c676645345 | |||
| b1e698c301 | |||
| b7ae4478a5 | |||
| 92c3e8e6c0 | |||
| 7aa9f3df50 | |||
| 10dec56e8e | |||
| eaafd5022a | |||
| 2d33f47816 | |||
| 15384358a0 | |||
| 6a82697a45 | |||
| 8536ddb3b4 | |||
| 569135630b | |||
| 255e8eefed | |||
| 59a991880d | |||
| f0530a50db | |||
| 4a4738318e | |||
| e4143fd98a | |||
| f99dab6cb9 | |||
| dfb0123ffb | |||
| 6c5ec5f9e3 | |||
| b1f4a91a83 | |||
| b127ec60b3 | |||
| 2f51c40e25 | |||
| a376162392 | |||
| 49176d27b6 | |||
| ac49f1d263 | |||
| 8242640da1 | |||
| c9e62f5b0b | |||
| abea76c42d | |||
| 83a4c0f935 | |||
| 67404bbd08 | |||
| 059189805c | |||
| b99ab91a8f | |||
| d99501e572 | |||
| a35a0e9f9d | |||
| 6ce55337d9 | |||
| 5b8105ec2b | |||
| 5fcb449946 | |||
| ff68426c69 | |||
| 46be044121 | |||
| e0303f9cba | |||
| 9d39705c77 | |||
| 986df86e89 | |||
| bd359411a9 | |||
| 3634ea1d62 | |||
| 3ce0569c59 | |||
| d2d95f0b71 | |||
| 2a51006888 | |||
| a89de129ea | |||
| ddefcbed56 | |||
| 3137299bfe | |||
| 1fe3368c5a | |||
| 7aea3a0a50 | |||
| 188aedec84 | |||
| d5952945dd | |||
| 6e1689dfe5 | |||
| 4f16a02658 | |||
| 5e9a59b327 | |||
| ab09cff427 | |||
| 47a9520a82 | |||
| 7a6c3c3fa3 | |||
| 803b5d583d | |||
| 1c52cd529b | |||
| ab28b168ec | |||
| 367b4b7553 | |||
| 25c7323c47 | |||
| aea0e16279 | |||
| f566573fce | |||
| 8fcceb3226 | |||
| ed0d6575c8 | |||
| f2ada02383 | |||
| 5e5816cd74 | |||
| d189d94c3b | |||
| 79b5d40327 | |||
| 228d481211 | |||
| d6f8368493 | |||
| b0f764b6b6 | |||
| 1403fec5fe | |||
| 07b4ebe983 | |||
| 0b2b9303d0 | |||
| 05a2c479a5 | |||
| 52b55df7b2 | |||
| b54f72d3f6 | |||
| 24c5a09c7f | |||
| 8cab9d4bad | |||
| 5ea52e5291 | |||
| 9166656673 | |||
| 1360a44e01 | |||
| 86c05e71a2 | |||
| fae26aa460 | |||
| 8803e22f39 | |||
| 375b89154b | |||
| 6a90adc765 | |||
| bcf66dc1d7 | |||
| c55c4a140b | |||
| 7643094f1d | |||
| 1b480f915f | |||
| ac36c08460 | |||
| ef3a2c9bd6 | |||
| da0f10f1cc | |||
| 9ba231dc4c | |||
| 9a6b57db58 | |||
| 67223f8950 | |||
| e76714c32e | |||
| 95dfb69a18 | |||
| 24ada70997 | |||
| ccce03b4d4 | |||
| 4daf235385 | |||
| 6d46506726 | |||
| c448f49e30 | |||
| 3f5a234c59 | |||
| b05bba50fa | |||
| 9d92fb4af2 | |||
| db6869b77e | |||
| 864c22ffc7 | |||
| fd614004b0 | |||
| ff1ffbbfa3 | |||
| 9ffd68bae5 | |||
| 14a723ab1c | |||
| dc6e8924a9 | |||
| 882ccdac12 | |||
| b70557a077 | |||
| a0f6582914 | |||
| 0c98c5bc15 | |||
| 1066625078 | |||
| fe052879bd | |||
| 51c5fe1129 | |||
| 3d208ea0e5 | |||
| a4f60ef21c | |||
| 3f6ad0c6ad | |||
| 0323f0bb7b | |||
| 1b733b23b9 | |||
| 05ae0c62d6 | |||
| 4bc4969e5a | |||
| 8cd8390d95 | |||
| 2a766efb83 | |||
| afa8560369 | |||
| c81ebb7053 | |||
| 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 |
@@ -46,37 +46,3 @@ jobs:
|
|||||||
- name: Frontend contract tests (npm test → node --test)
|
- name: Frontend contract tests (npm test → node --test)
|
||||||
working-directory: frontend-vue
|
working-directory: frontend-vue
|
||||||
run: npm test
|
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
|
|
||||||
|
|
||||||
|
|||||||
-43
@@ -14,8 +14,6 @@ backend-java/target/
|
|||||||
backend-java/data/
|
backend-java/data/
|
||||||
backend-java/*.log
|
backend-java/*.log
|
||||||
backend-java/logs/
|
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/src/main/resources/application-local.yml
|
||||||
backend-java/.idea/
|
backend-java/.idea/
|
||||||
backend-java/*.iml
|
backend-java/*.iml
|
||||||
@@ -141,44 +139,3 @@ data/logs/
|
|||||||
|
|
||||||
# 生产库转储永不再入库(本体只留 backend-java/data/,那里已被忽略)
|
# 生产库转储永不再入库(本体只留 backend-java/data/,那里已被忽略)
|
||||||
backend-java/src/main/resources/db/aiimage.sql
|
backend-java/src/main/resources/db/aiimage.sql
|
||||||
|
|
||||||
# 打包前由 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,78 +1,38 @@
|
|||||||
import { expect, test, type Page } from '@playwright/test'
|
import { expect, test, type Page } from '@playwright/test'
|
||||||
|
|
||||||
// 站内通知铃铛面板验收:聚合视图(场景 × 自然日 × 事件主体用户)、展开明细、
|
// 站内通知铃铛面板验收:关键字/年月日区间搜索、按天分组、分页。
|
||||||
// 关键字/年月日区间搜索、按组分页、红点按组数。
|
// 依赖 scripts/mock-admin-server.mjs 的通知夹具(14 条:09-13 六条、09-12 四条、09-10 四条)。
|
||||||
// 依赖 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) {
|
async function openBell(page: Page) {
|
||||||
await page.goto('/admin-vue/')
|
await page.goto('/admin-vue/')
|
||||||
await expect(page.locator('.admin-topbar h1')).toHaveText('用户管理')
|
await expect(page.locator('.admin-topbar h1')).toHaveText('用户管理')
|
||||||
await page.locator('.admin-notification-bell .bell-trigger').click()
|
await page.locator('.admin-notification-bell .bell-trigger').click()
|
||||||
await expect(page.locator('.bell-panel')).toBeVisible()
|
await expect(page.locator('.bell-panel')).toBeVisible()
|
||||||
// 面板默认按「当天」过滤,夹具是 09-10~09-13:先清空日期才能拿到全量
|
await expect(page.locator('.bell-item').first()).toBeVisible()
|
||||||
await clearDateFilter(page)
|
|
||||||
await expect(page.locator('.bell-group').first()).toBeVisible()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
test('test_notification_panel_day_group_and_pagination', async ({ page }) => {
|
||||||
* 打开日历并等入场动画落定。
|
|
||||||
*
|
|
||||||
* 两件事必须先做对,否则读数全是假的:
|
|
||||||
* ① 弹层节点是常驻的(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)
|
await openBell(page)
|
||||||
|
|
||||||
const panel = page.locator('.bell-panel')
|
const panel = page.locator('.bell-panel')
|
||||||
const nextPage = panel.getByRole('button', { name: '下一页' })
|
const nextPage = panel.getByRole('button', { name: '下一页' })
|
||||||
|
|
||||||
// 一页 6 组:09-13 的 4 组 + 09-12 的 2 组 ⇒ 日期头 2 个(同一天可以多组)
|
// 每页 10 条,跨两个日期分组,页脚显示页码与总数
|
||||||
await expect(page.locator('.bell-group')).toHaveCount(6)
|
await expect(page.locator('.bell-item')).toHaveCount(10)
|
||||||
await expect(page.locator('.bell-day-head')).toHaveCount(2)
|
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-info')).toHaveText('1 / 2')
|
||||||
await expect(page.locator('.bell-page-total')).toHaveText('共 10 组 · 明细 14 条')
|
await expect(page.locator('.bell-page-total')).toHaveText('共 14 条')
|
||||||
// 聚合行必须把"折叠前几条、其中几条没读"写在行上
|
await expect(page.locator('.bell-day-head').first()).toHaveText(/^(今天|昨天|\d{4}年\d{1,2}月\d{1,2}日)$/)
|
||||||
await expect(page.locator('.bell-group-count').first()).toHaveText('1 条 · 1 未读')
|
|
||||||
|
|
||||||
const page2Request = page.waitForRequest(
|
const page2Request = page.waitForRequest(
|
||||||
(request) => request.url().includes('/api/admin/notifications/groups?') && request.url().includes('page=2'),
|
(request) => request.url().includes('/api/admin/notifications?') && request.url().includes('page=2'),
|
||||||
)
|
)
|
||||||
await nextPage.click()
|
await nextPage.click()
|
||||||
await page2Request
|
await page2Request
|
||||||
|
|
||||||
await expect(page.locator('.bell-group')).toHaveCount(4)
|
await expect(page.locator('.bell-item')).toHaveCount(4)
|
||||||
await expect(page.locator('.bell-page-info')).toHaveText('2 / 2')
|
await expect(page.locator('.bell-page-info')).toHaveText('2 / 2')
|
||||||
|
await expect(page.locator('.bell-day-head')).toHaveCount(1)
|
||||||
await expect(nextPage).toBeDisabled()
|
await expect(nextPage).toBeDisabled()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -85,129 +45,37 @@ test('test_notification_panel_search_by_keyword', async ({ page }) => {
|
|||||||
await page.locator('.bell-search-input').fill('余额不足')
|
await page.locator('.bell-search-input').fill('余额不足')
|
||||||
await keywordRequest
|
await keywordRequest
|
||||||
|
|
||||||
// 关键字命中标题/内容:夹具里 5 条含「余额不足」,且分属 5 个不同的组
|
// 关键字命中标题/内容:夹具里 5 条含「余额不足」
|
||||||
await expect(page.locator('.bell-group')).toHaveCount(5)
|
await expect(page.locator('.bell-item')).toHaveCount(5)
|
||||||
await expect(page.locator('.bell-page-total')).toHaveText('共 5 组 · 明细 5 条')
|
await expect(page.locator('.bell-page-total')).toHaveText('共 5 条')
|
||||||
await expect(page.locator('.bell-search-reset')).toBeVisible()
|
await expect(page.locator('.bell-search-reset')).toBeVisible()
|
||||||
|
|
||||||
await page.locator('.bell-search-reset').click()
|
await page.locator('.bell-search-reset').click()
|
||||||
// 重置回到面板的默认视图:清空关键字、日期恢复「当天」(当天不是清空日期)
|
await expect(page.locator('.bell-item')).toHaveCount(10)
|
||||||
await expect(page.locator('.bell-search-input')).toHaveValue('')
|
|
||||||
await expect(page.locator('.bell-search-reset')).toBeHidden()
|
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 }) => {
|
test('test_notification_panel_search_by_day_range', async ({ page }) => {
|
||||||
await openBell(page)
|
await openBell(page)
|
||||||
const day = await openRangeOnSeptember(page)
|
|
||||||
|
|
||||||
// 09-10 四条折成 3 组(两个用户 × 两个场景组合)
|
|
||||||
const rangeRequest = page.waitForRequest(
|
const rangeRequest = page.waitForRequest(
|
||||||
(request) =>
|
(request) =>
|
||||||
request.url().includes('startDate=2026-09-10') && request.url().includes('endDate=2026-09-12'),
|
request.url().includes('startDate=2026-09-12') && request.url().includes('endDate=2026-09-12'),
|
||||||
)
|
)
|
||||||
await day('10').click()
|
await page.locator('.bell-date-input').first().fill('2026-09-12')
|
||||||
await day('12').click()
|
await page.locator('.bell-date-input').nth(1).fill('2026-09-12')
|
||||||
await rangeRequest
|
await rangeRequest
|
||||||
|
|
||||||
await expect(page.locator('.bell-page-total')).toHaveText('共 6 组 · 明细 8 条')
|
await expect(page.locator('.bell-item')).toHaveCount(4)
|
||||||
await expect(page.locator('.bell-day-head')).toHaveCount(2)
|
await expect(page.locator('.bell-day-head')).toHaveCount(1)
|
||||||
|
await expect(page.locator('.bell-page-total')).toHaveText('共 4 条')
|
||||||
await expect(page.locator('.bell-empty')).toHaveCount(0)
|
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 }) => {
|
// 起止倒挂自动交换:09-13 起 / 09-10 止 → 实际按 09-10 ~ 09-13 查询(全量 14 条)
|
||||||
await openBell(page)
|
await page.locator('.bell-date-input').first().fill('2026-09-13')
|
||||||
const day = await openRangeOnSeptember(page)
|
await page.locator('.bell-date-input').nth(1).fill('2026-09-10')
|
||||||
|
await expect(page.locator('.bell-page-total')).toHaveText('共 14 条')
|
||||||
// 先点 13 再点 10:控件自己保证起 ≤ 止,落到 09-10 ~ 09-13(全量 14 条 / 10 组)
|
await expect(page.locator('.bell-item')).toHaveCount(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 }) => {
|
test('test_notification_panel_not_covered_by_page_content', async ({ page }) => {
|
||||||
@@ -234,47 +102,21 @@ test('test_notification_panel_not_covered_by_page_content', async ({ page }) =>
|
|||||||
test('test_notification_panel_reference_screenshot', async ({ page }) => {
|
test('test_notification_panel_reference_screenshot', async ({ page }) => {
|
||||||
await openBell(page)
|
await openBell(page)
|
||||||
|
|
||||||
|
// 同日多条不得重叠:逐条校验纵向排布严格递增(截图伪影与真实布局问题的分界)
|
||||||
const tops = await page
|
const tops = await page
|
||||||
.locator('.bell-group')
|
.locator('.bell-item')
|
||||||
.evaluateAll((els) => els.map((el) => el.getBoundingClientRect().top))
|
.evaluateAll((els) => els.map((el) => el.getBoundingClientRect().top))
|
||||||
for (let i = 1; i < tops.length; i += 1) {
|
for (let i = 1; i < tops.length; i += 1) {
|
||||||
expect(tops[i], `第 ${i + 1} 组应排在第 ${i} 组下方`).toBeGreaterThan(tops[i - 1])
|
expect(tops[i], `第 ${i + 1} 条应排在第 ${i} 条下方`).toBeGreaterThan(tops[i - 1])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await page.screenshot({ path: 'test-results/notification-panel-admin-page.jpg', animations: 'disabled' })
|
||||||
|
await page.locator('.bell-panel').screenshot({ path: 'test-results/notification-panel-admin.jpg', animations: 'disabled' })
|
||||||
|
|
||||||
|
await page.locator('.bell-search-input').fill('余额不足')
|
||||||
|
await expect(page.locator('.bell-item')).toHaveCount(5)
|
||||||
await page.locator('.bell-panel').screenshot({
|
await page.locator('.bell-panel').screenshot({
|
||||||
path: 'test-results/notification-panel-admin-groups.jpg',
|
path: 'test-results/notification-panel-admin-search.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',
|
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')
|
|
||||||
})
|
|
||||||
|
|||||||
Generated
-1024
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,6 @@
|
|||||||
"build": "vue-tsc --noEmit && vite build",
|
"build": "vue-tsc --noEmit && vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"test": "node --test tests/*.test.ts",
|
"test": "node --test tests/*.test.ts",
|
||||||
"test:mount": "vitest run",
|
|
||||||
"test:live": "node --test tests/live/*.test.ts",
|
"test:live": "node --test tests/live/*.test.ts",
|
||||||
"test:browser": "playwright test"
|
"test:browser": "playwright test"
|
||||||
},
|
},
|
||||||
@@ -23,11 +22,8 @@
|
|||||||
"@playwright/test": "^1.63.0",
|
"@playwright/test": "^1.63.0",
|
||||||
"@types/node": "^26.4.1",
|
"@types/node": "^26.4.1",
|
||||||
"@vitejs/plugin-vue": "^6.0.1",
|
"@vitejs/plugin-vue": "^6.0.1",
|
||||||
"@vue/test-utils": "^2.5.1",
|
|
||||||
"jsdom": "^30.1.2",
|
|
||||||
"typescript": "^5.9.2",
|
"typescript": "^5.9.2",
|
||||||
"vite": "^7.3.1",
|
"vite": "^7.3.1",
|
||||||
"vitest": "^5.0.3",
|
|
||||||
"vue-tsc": "^3.0.6"
|
"vue-tsc": "^3.0.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
import { defineConfig } from '@playwright/test'
|
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。
|
* 本地用已安装的 MS Edge(channel: msedge)运行,无需下载 Chromium。
|
||||||
*
|
|
||||||
* 端口必须可改:5174 被别的项目占用时 vite 会顺延到别的端口,而 reuseExistingServer
|
|
||||||
* 会让 playwright 直接连上那个「不是本站」的服务,整份验收测的是别人的页面。
|
|
||||||
*/
|
*/
|
||||||
const PORT = Number(process.env.E2E_PORT || 5174)
|
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
testDir: './e2e',
|
testDir: './e2e',
|
||||||
timeout: 45_000,
|
timeout: 45_000,
|
||||||
@@ -18,7 +13,7 @@ export default defineConfig({
|
|||||||
retries: 0,
|
retries: 0,
|
||||||
reporter: [['list']],
|
reporter: [['list']],
|
||||||
use: {
|
use: {
|
||||||
baseURL: `http://127.0.0.1:${PORT}`,
|
baseURL: 'http://127.0.0.1:5174',
|
||||||
channel: 'msedge',
|
channel: 'msedge',
|
||||||
headless: true,
|
headless: true,
|
||||||
viewport: { width: 1440, height: 900 },
|
viewport: { width: 1440, height: 900 },
|
||||||
@@ -31,8 +26,8 @@ export default defineConfig({
|
|||||||
reuseExistingServer: true,
|
reuseExistingServer: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: `set VITE_API_TARGET=http://127.0.0.1:18100&& npm run dev -- --port ${PORT} --strictPort`,
|
command: 'set VITE_API_TARGET=http://127.0.0.1:18100&& npm run dev',
|
||||||
port: PORT,
|
port: 5174,
|
||||||
reuseExistingServer: true,
|
reuseExistingServer: true,
|
||||||
timeout: 120_000,
|
timeout: 120_000,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -152,93 +152,33 @@ const TUTORIAL_PACKAGES = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
/* ===================== 站内通知夹具(铃铛面板:搜索/按天分组/分页验收用) ===================== */
|
/* ===================== 站内通知夹具(铃铛面板:搜索/按天分组/分页验收用) ===================== */
|
||||||
/**
|
|
||||||
* 通知夹具。两条约定不能破:
|
|
||||||
* ① id 与 createdAt 同为插入时单调(09-10 最早 ⇒ id 最小)——与真库一致;倒挂会让
|
|
||||||
* "按 id 倒序即按天倒序"这种隐藏假设在 mock 里成立、上线就翻车。
|
|
||||||
* ② 场景显式给,不从 id 取模推——否则换一批 id,「余额不足」命中数与聚合组数一起漂,
|
|
||||||
* 用例断言就成了跟着夹具跑的活字。
|
|
||||||
* 共 14 行、5 行密钥告警;按 场景×自然日×主体用户 折成 10 组,其中 2 组未读、3 行未读。
|
|
||||||
*/
|
|
||||||
const NOTIFICATIONS = [
|
const NOTIFICATIONS = [
|
||||||
['2026-09-10', 18, 1, true, 'task_failed'],
|
...[6, 5, 4, 3, 2, 1].map((seq) => notif(seq, '2026-09-13', 22, seq, seq <= 3)),
|
||||||
['2026-09-10', 18, 2, true, 'task_failed'],
|
...[4, 3, 2, 1].map((seq) => notif(20 + seq, '2026-09-12', 20, seq, true)),
|
||||||
['2026-09-10', 18, 3, true, 'secret_balance'],
|
...[4, 3, 2, 1].map((seq) => notif(30 + seq, '2026-09-10', 18, seq, true)),
|
||||||
['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) {
|
||||||
|
|
||||||
function notif(id, day, hour, seq, read, scene) {
|
|
||||||
const minutes = String(seq * 7).padStart(2, '0')
|
const minutes = String(seq * 7).padStart(2, '0')
|
||||||
const secret = scene === 'secret_balance'
|
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
scene,
|
scene: id % 3 === 0 ? 'secret_balance' : 'task_failed',
|
||||||
level: secret ? 'error' : 'warning',
|
level: id % 3 === 0 ? 'error' : 'warning',
|
||||||
title: secret ? `用户密钥异常:测试用户${seq}` : `跟价任务失败`,
|
title: id % 3 === 0 ? `用户密钥异常:测试用户${seq}` : `跟价任务失败`,
|
||||||
content: secret
|
content: id % 3 === 0 ? `用户 测试用户${seq}(uid=${1100 + seq})的代理设置对应服务商余额不足` : `用户 测试用户${seq} 有 ${seq} 个跟价任务失败`,
|
||||||
? `用户 测试用户${seq}(uid=${1100 + seq})的代理设置对应服务商余额不足`
|
|
||||||
: `用户 测试用户${seq} 有 ${seq} 个跟价任务失败`,
|
|
||||||
// 事件主体用户:与后端 V158 那列同义,聚合分组键的第三维。seq>3 归 1196、其余归 1160,
|
|
||||||
// 让"同一天两个用户"在夹具里真的存在(否则聚合视图测不到按用户拆组这一维)。
|
|
||||||
subjectUserId: seq > 3 ? 1196 : 1160,
|
|
||||||
read,
|
read,
|
||||||
readAt: read ? `${day} ${hour}:${minutes}:00` : null,
|
readAt: read ? `${day} ${hour}:${minutes}:00` : null,
|
||||||
createdAt: `${day} ${hour}:${minutes}:00`,
|
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 侧同语义)。 */
|
/** 通知列表:关键字匹配标题/内容,日期按年月日区间(与 Java 侧同语义)。 */
|
||||||
/** 列表与聚合共用的筛选:关键字 / 日期区间 / 展开某一组(场景 + 自然日 + 主体用户)。 */
|
function notificationPage(searchParams) {
|
||||||
function filteredRows(searchParams) {
|
|
||||||
const keyword = (searchParams.get('keyword') || '').trim()
|
const keyword = (searchParams.get('keyword') || '').trim()
|
||||||
const startDate = searchParams.get('startDate') || ''
|
const startDate = searchParams.get('startDate') || ''
|
||||||
const endDate = searchParams.get('endDate') || ''
|
const endDate = searchParams.get('endDate') || ''
|
||||||
const scene = searchParams.get('scene') || ''
|
const page = Math.max(1, Number(searchParams.get('page') || 1))
|
||||||
const day = searchParams.get('day') || ''
|
const pageSize = Math.min(100, Math.max(1, Number(searchParams.get('pageSize') || 20)))
|
||||||
const subjectUserId = searchParams.get('subjectUserId')
|
|
||||||
const subjectUnlabelled = searchParams.get('subjectUnlabelled') === 'true'
|
|
||||||
let rows = NOTIFICATIONS
|
let rows = NOTIFICATIONS
|
||||||
if (keyword) {
|
if (keyword) {
|
||||||
rows = rows.filter((item) => `${item.title}${item.content}`.includes(keyword))
|
rows = rows.filter((item) => `${item.title}${item.content}`.includes(keyword))
|
||||||
@@ -249,29 +189,7 @@ function filteredRows(searchParams) {
|
|||||||
if (endDate) {
|
if (endDate) {
|
||||||
rows = rows.filter((item) => item.createdAt.slice(0, 10) <= endDate)
|
rows = rows.filter((item) => item.createdAt.slice(0, 10) <= endDate)
|
||||||
}
|
}
|
||||||
if (scene) {
|
const start = (page - 1) * pageSize
|
||||||
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 {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
data: {
|
data: {
|
||||||
@@ -284,25 +202,6 @@ function notificationPage(searchParams) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 聚合出口:分页按组切,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 server = createServer((req, res) => {
|
||||||
const url = (req.url || '').split('?')[0]
|
const url = (req.url || '').split('?')[0]
|
||||||
const method = req.method || 'GET'
|
const method = req.method || 'GET'
|
||||||
@@ -499,32 +398,6 @@ const server = createServer((req, res) => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
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: [],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if (url === '/api/admin/shop-manage-groups') {
|
if (url === '/api/admin/shop-manage-groups') {
|
||||||
return json(res, { success: true, data: { items: [] } })
|
return json(res, { success: true, data: { items: [] } })
|
||||||
}
|
}
|
||||||
@@ -537,44 +410,15 @@ 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 },
|
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') {
|
if (url === '/api/admin/notifications/summary') {
|
||||||
const groups = groupRows(NOTIFICATIONS)
|
|
||||||
return json(res, {
|
return json(res, {
|
||||||
success: true,
|
success: true,
|
||||||
data: {
|
data: {
|
||||||
unreadCount: NOTIFICATIONS.filter((item) => !item.read).length,
|
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),
|
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') {
|
if (url === '/api/admin/notifications') {
|
||||||
return json(res, notificationPage(new URL(req.url || '/', 'http://127.0.0.1').searchParams))
|
return json(res, notificationPage(new URL(req.url || '/', 'http://127.0.0.1').searchParams))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { RouterView } from 'vue-router'
|
import { RouterView } from 'vue-router'
|
||||||
import zhCn from 'element-plus/es/locale/lang/zh-cn'
|
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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<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>
|
|
||||||
}
|
|
||||||
@@ -15,8 +15,6 @@ export interface CompanyItem {
|
|||||||
remark: string | null
|
remark: string | null
|
||||||
createdAt: string | null
|
createdAt: string | null
|
||||||
updatedAt: string | null
|
updatedAt: string | null
|
||||||
/** 所属平台(V206):'amazon'|'jd';后端恒带值(列 NOT NULL DEFAULT 'amazon'),旧负载缺省不渲染。 */
|
|
||||||
platform?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 新建/改名的表单草稿。 */
|
/** 新建/改名的表单草稿。 */
|
||||||
@@ -24,8 +22,6 @@ export interface CompanyDraft {
|
|||||||
companyName: string
|
companyName: string
|
||||||
status?: number
|
status?: number
|
||||||
remark?: string | null
|
remark?: string | null
|
||||||
/** 所属平台(V206):新建必带(页面从平台 tab 取),编辑显式下发,缺省后端不动。 */
|
|
||||||
platform?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function text(value: unknown): string {
|
export function text(value: unknown): string {
|
||||||
@@ -52,6 +48,5 @@ export function toCompanyPayload(draft: CompanyDraft): Record<string, unknown> {
|
|||||||
const payload: Record<string, unknown> = { companyName: text(draft.companyName).trim() }
|
const payload: Record<string, unknown> = { companyName: text(draft.companyName).trim() }
|
||||||
if (typeof draft.status === 'number') payload.status = draft.status
|
if (typeof draft.status === 'number') payload.status = draft.status
|
||||||
payload.remark = trimmedOrNull(draft.remark)
|
payload.remark = trimmedOrNull(draft.remark)
|
||||||
if (draft.platform) payload.platform = draft.platform
|
|
||||||
return payload
|
return payload
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export function toCompanyItem(raw: unknown): CompanyItem | null {
|
|||||||
const r = raw as Record<string, unknown>
|
const r = raw as Record<string, unknown>
|
||||||
const id = numberOrNull(r.id)
|
const id = numberOrNull(r.id)
|
||||||
if (id === null) return null
|
if (id === null) return null
|
||||||
const item: CompanyItem = {
|
return {
|
||||||
id,
|
id,
|
||||||
companyName: text(r.company_name),
|
companyName: text(r.company_name),
|
||||||
// status 列 NOT NULL,取不到就是链路异常;未知一律按停用,不把异常状态当启用。
|
// status 列 NOT NULL,取不到就是链路异常;未知一律按停用,不把异常状态当启用。
|
||||||
@@ -27,10 +27,6 @@ export function toCompanyItem(raw: unknown): CompanyItem | null {
|
|||||||
createdAt: trimmedOrNull(r.created_at),
|
createdAt: trimmedOrNull(r.created_at),
|
||||||
updatedAt: trimmedOrNull(r.updated_at),
|
updatedAt: trimmedOrNull(r.updated_at),
|
||||||
}
|
}
|
||||||
// platform 后端恒带(列 NOT NULL);旧负载/测试桩缺省就不渲染该键,字段形状与 users-model 一致。
|
|
||||||
const platform = text(r.platform)
|
|
||||||
if (platform) item.platform = platform
|
|
||||||
return item
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 解析 GET /api/admin/companies:接受 data 为数组或 {items:[...]},success=false 抛后端文案。 */
|
/** 解析 GET /api/admin/companies:接受 data 为数组或 {items:[...]},success=false 抛后端文案。 */
|
||||||
|
|||||||
@@ -4,10 +4,8 @@ import { toCompanyPayload, type CompanyDraft, type CompanyItem } from './compani
|
|||||||
|
|
||||||
/** 公司目录(设计文档 §2.3)。GET 的可见范围由后端收窄:超管全部、公司内 admin 只自己公司。 */
|
/** 公司目录(设计文档 §2.3)。GET 的可见范围由后端收窄:超管全部、公司内 admin 只自己公司。 */
|
||||||
|
|
||||||
export async function fetchCompanies(platform?: string): Promise<CompanyItem[]> {
|
export async function fetchCompanies(): Promise<CompanyItem[]> {
|
||||||
const { data } = await http.get('/api/admin/companies', {
|
const { data } = await http.get('/api/admin/companies')
|
||||||
params: platform ? { platform } : {},
|
|
||||||
})
|
|
||||||
return parseCompanyList(data)
|
return parseCompanyList(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/** API 响应解包与错误归一化(任务 22):纯函数,无框架依赖(只借 config/app 的 base 常量)。 */
|
/** API 响应解包与错误归一化(任务 22):纯函数,无框架依赖(只借 config/app 的 base 常量)。 */
|
||||||
import { userNotice } from './user-notice.ts'
|
|
||||||
import { joinAdminPath } from '../config/app.ts'
|
import { joinAdminPath } from '../config/app.ts'
|
||||||
|
|
||||||
export const REQUEST_FALLBACK_MESSAGE = '网络异常,请稍后重试'
|
export const REQUEST_FALLBACK_MESSAGE = '网络异常,请稍后重试'
|
||||||
@@ -7,8 +6,8 @@ export const REQUEST_FALLBACK_MESSAGE = '网络异常,请稍后重试'
|
|||||||
function textOf(value: Record<string, unknown>): string {
|
function textOf(value: Record<string, unknown>): string {
|
||||||
const message = value.message
|
const message = value.message
|
||||||
const error = value.error
|
const error = value.error
|
||||||
if (typeof message === 'string' && message.trim()) return userNotice(message)
|
if (typeof message === 'string' && message.trim()) return message.trim()
|
||||||
if (typeof error === 'string' && error.trim()) return userNotice(error)
|
if (typeof error === 'string' && error.trim()) return error.trim()
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,12 +31,12 @@ export function unwrap<T>(payload: unknown): T {
|
|||||||
|
|
||||||
/** 从任意负载取错误文案;缺省回退。 */
|
/** 从任意负载取错误文案;缺省回退。 */
|
||||||
export function errorTextOf(payload: unknown): string {
|
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') {
|
if (payload && typeof payload === 'object') {
|
||||||
const text = textOf(payload as Record<string, unknown>)
|
const text = textOf(payload as Record<string, unknown>)
|
||||||
if (text) return text
|
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
|
return REQUEST_FALLBACK_MESSAGE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,19 +17,12 @@ export const http = axios.create({
|
|||||||
timeout: 30_000,
|
timeout: 30_000,
|
||||||
})
|
})
|
||||||
|
|
||||||
/** 会话失效成因(后端 X-Auth-Reason 头):disabled=已停用、deleted=已删除;其余 401 无成因。 */
|
function redirectToLogin(requestUrl?: string): void {
|
||||||
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 {
|
|
||||||
if (typeof window === 'undefined') return
|
if (typeof window === 'undefined') return
|
||||||
// 已在登录页或失败请求即登录端点时不再跳转,避免登录页循环与吞掉登录失败反馈。
|
// 已在登录页或失败请求即登录端点时不再跳转,避免登录页循环与吞掉登录失败反馈。
|
||||||
if (!shouldRedirectUnauthorized(window.location.pathname, requestUrl)) return
|
if (!shouldRedirectUnauthorized(window.location.pathname, requestUrl)) return
|
||||||
const target = loginRedirectTarget(window.location)
|
const target = loginRedirectTarget(window.location)
|
||||||
// 成因随 query 带给登录页点名(停用/删除),登录页据此显示对应提示
|
window.location.assign('/admin-vue/login?redirect=' + target)
|
||||||
window.location.assign('/admin-vue/login?redirect=' + target + (reason ? `&auth=${reason}` : ''))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 403 只在会话引导端点上才当"进不了后台"处理;其余端点的 403 交给页面自己把原因说出来。 */
|
/** 403 只在会话引导端点上才当"进不了后台"处理;其余端点的 403 交给页面自己把原因说出来。 */
|
||||||
@@ -54,7 +47,7 @@ http.interceptors.response.use(
|
|||||||
if (isKicked(response.data)) {
|
if (isKicked(response.data)) {
|
||||||
redirectToLoginKicked()
|
redirectToLoginKicked()
|
||||||
} else if (isUnauthorized(response.data)) {
|
} else if (isUnauthorized(response.data)) {
|
||||||
redirectToLogin(response.config?.url, authReasonOf(response.headers))
|
redirectToLogin(response.config?.url)
|
||||||
} else if (isForbidden(response.data)) {
|
} else if (isForbidden(response.data)) {
|
||||||
redirectToLoginOnForbidden(response.config?.url)
|
redirectToLoginOnForbidden(response.config?.url)
|
||||||
}
|
}
|
||||||
@@ -64,7 +57,7 @@ http.interceptors.response.use(
|
|||||||
if (isKicked(error?.response?.data)) {
|
if (isKicked(error?.response?.data)) {
|
||||||
redirectToLoginKicked()
|
redirectToLoginKicked()
|
||||||
} else if (error?.response?.status === 401 || isUnauthorized(error?.response?.data)) {
|
} else if (error?.response?.status === 401 || isUnauthorized(error?.response?.data)) {
|
||||||
redirectToLogin(error?.config?.url, authReasonOf(error?.response?.headers))
|
redirectToLogin(error?.config?.url)
|
||||||
} else if (error?.response?.status === 403 || isForbidden(error?.response?.data)) {
|
} else if (error?.response?.status === 403 || isForbidden(error?.response?.data)) {
|
||||||
redirectToLoginOnForbidden(error?.config?.url)
|
redirectToLoginOnForbidden(error?.config?.url)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +1,13 @@
|
|||||||
import { http } from './http'
|
import { http } from './http'
|
||||||
import { unwrap } from './envelope'
|
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 {
|
export interface AdminNotificationItem {
|
||||||
id: number
|
id: number
|
||||||
scene: string
|
scene: string
|
||||||
level: string
|
level: string
|
||||||
/** 业务严重度;旧后端不返回时前端按 level 兜底。 */
|
|
||||||
severity?: string
|
|
||||||
title: string
|
title: string
|
||||||
content: string
|
content: string
|
||||||
/** 可点的定位锚点;旧后端/历史行没有这一列时为空。 */
|
|
||||||
refs?: AdminNotificationRef[] | null
|
|
||||||
read: boolean
|
read: boolean
|
||||||
readAt: string | null
|
readAt: string | null
|
||||||
createdAt: string | null
|
createdAt: string | null
|
||||||
@@ -50,40 +23,9 @@ export interface AdminNotificationPage {
|
|||||||
|
|
||||||
export interface AdminNotificationSummary {
|
export interface AdminNotificationSummary {
|
||||||
unreadCount: number
|
unreadCount: number
|
||||||
/** 有未读的聚合组数;徽标用它。unreadCount 仍是"条数",给老明细视图与对账用。 */
|
|
||||||
unreadGroupCount?: number
|
|
||||||
latestId: 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。 */
|
/** 铃铛轮询:未读数 + 最新通知 id。 */
|
||||||
export async function fetchNotificationSummary(): Promise<AdminNotificationSummary> {
|
export async function fetchNotificationSummary(): Promise<AdminNotificationSummary> {
|
||||||
const { data } = await http.get('/api/admin/notifications/summary')
|
const { data } = await http.get('/api/admin/notifications/summary')
|
||||||
@@ -98,33 +40,6 @@ export interface AdminNotificationListParams {
|
|||||||
keyword?: string
|
keyword?: string
|
||||||
startDate?: string
|
startDate?: string
|
||||||
endDate?: 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(
|
export async function fetchNotificationList(
|
||||||
@@ -139,11 +54,6 @@ export async function fetchNotificationList(
|
|||||||
keyword: keyword || undefined,
|
keyword: keyword || undefined,
|
||||||
startDate: params.startDate || undefined,
|
startDate: params.startDate || undefined,
|
||||||
endDate: params.endDate || 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)
|
return unwrap<AdminNotificationPage>(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
|
|
||||||
}
|
|
||||||
@@ -5,20 +5,8 @@ import { unwrap } from './envelope'
|
|||||||
export interface AdminUserSecretModule {
|
export interface AdminUserSecretModule {
|
||||||
moduleKey: string
|
moduleKey: string
|
||||||
moduleLabel: string
|
moduleLabel: string
|
||||||
/**
|
|
||||||
* 货源:按模块分域,后端 `UserSecretModule.channelOrDefault` 已归一——
|
|
||||||
* LLM 行为渠道(longtaitou/t8star),代理行为供应商(qingguo/jikip)。
|
|
||||||
* ⚠ 界面不得用一张合表渲染这两域(代理行贴出「龙抬头」就是这么来的),
|
|
||||||
* 走 `user-secret-model.ts` 的 `moduleSourceLabel`。
|
|
||||||
*/
|
|
||||||
channel?: string | null
|
|
||||||
/** 脱敏值:代理列为 `scheme://host`,不含提取链接里的 key/pwd。 */
|
|
||||||
masked: string
|
masked: string
|
||||||
/**
|
/** 完整明文值:仅代理列有值(后端对密钥列不下发明文)。 */
|
||||||
* 完整明文值:后台侧**恒为空**(2026-11-02 `SecretMasking.maskProxy` 收口,代理链接里带着账密)。
|
|
||||||
* 字段保留只为接口兼容;界面**不得**读它、更不得拿它做"masked 空就回落原文"的兜底,
|
|
||||||
* 也不许有任何复制/导出整条链接的旁路。
|
|
||||||
*/
|
|
||||||
full: string
|
full: string
|
||||||
exists: boolean
|
exists: boolean
|
||||||
/** 是否由后台代填并锁定:锁定时客户端不可修改或清空。 */
|
/** 是否由后台代填并锁定:锁定时客户端不可修改或清空。 */
|
||||||
@@ -63,53 +51,6 @@ export interface GroupOption {
|
|||||||
groupName: string
|
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 {
|
export interface UserSecretQuery {
|
||||||
keyword?: string
|
keyword?: string
|
||||||
checkStatus?: string
|
checkStatus?: string
|
||||||
@@ -134,23 +75,6 @@ export async function fetchUserSecretList(params: UserSecretQuery): Promise<Admi
|
|||||||
return unwrap<AdminUserSecretPage>(data)
|
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
|
/** 立即检测该用户全部已配置项:POST /api/admin/user-secrets/{userId}/check
|
||||||
* 逐模块检测(每项最多「首查 + 传输层失败重试一次」,最坏约 31s/项),故放宽超时到 180s。 */
|
* 逐模块检测(每项最多「首查 + 传输层失败重试一次」,最坏约 31s/项),故放宽超时到 180s。 */
|
||||||
export async function checkUserSecret(userId: number) {
|
export async function checkUserSecret(userId: number) {
|
||||||
@@ -174,22 +98,13 @@ export async function deleteUserSecret(userId: number): Promise<void> {
|
|||||||
unwrap<unknown>(data)
|
unwrap<unknown>(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 代填并锁定该用户某模块配置(当前仅代理):PUT /api/admin/user-secrets/{userId}/modules/{moduleKey} */
|
||||||
* 代填并锁定该用户某模块配置(当前仅代理):PUT /api/admin/user-secrets/{userId}/modules/{moduleKey}
|
|
||||||
* `value` 是**一次性写载荷**(代理为现拼的提取链接,带着 key/pwd):调用方不得把它渲染回界面、
|
|
||||||
* 不得打进日志;`channel` 是同一单的货源(代理=供应商 key),后端据此选解析分支——
|
|
||||||
* 不给则由后端按链接域名识别,识别不出回落默认供应商,会静默换执行方,所以本面一律显式带上。
|
|
||||||
*/
|
|
||||||
export async function saveUserSecretModule(
|
export async function saveUserSecretModule(
|
||||||
userId: number,
|
userId: number,
|
||||||
moduleKey: string,
|
moduleKey: string,
|
||||||
value: string,
|
value: string,
|
||||||
channel?: string,
|
|
||||||
): Promise<AdminUserSecretModule> {
|
): Promise<AdminUserSecretModule> {
|
||||||
const { data } = await http.put(`/api/admin/user-secrets/${userId}/modules/${moduleKey}`, {
|
const { data } = await http.put(`/api/admin/user-secrets/${userId}/modules/${moduleKey}`, { value })
|
||||||
value,
|
|
||||||
...(channel ? { channel } : {}),
|
|
||||||
})
|
|
||||||
return unwrap<AdminUserSecretModule>(data)
|
return unwrap<AdminUserSecretModule>(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/** 用户管理列表/分页 DTO(任务 41):纯逻辑,无框架依赖,与 Java AdminUserController 对齐。 */
|
/** 用户管理列表/分页 DTO(任务 41):纯逻辑,无框架依赖,与 Java AdminUserController 对齐。 */
|
||||||
import type { AdminUser } from '../types/admin'
|
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_DEFAULT_SIZE = 10
|
||||||
export const USER_PAGE_MIN_PAGE = 1
|
export const USER_PAGE_MIN_PAGE = 1
|
||||||
@@ -19,8 +18,6 @@ export interface UserListParams {
|
|||||||
/** 公司 tab 的当前公司;由页面从 store 传入,**不住在 UserFilterState 里**
|
/** 公司 tab 的当前公司;由页面从 store 传入,**不住在 UserFilterState 里**
|
||||||
* (normalizeUserPageParams 白名单构造会把它丢掉,取值口只认 fetchUserList 的原始入参)。 */
|
* (normalizeUserPageParams 白名单构造会把它丢掉,取值口只认 fetchUserList 的原始入参)。 */
|
||||||
companyId?: number | null
|
companyId?: number | null
|
||||||
/** 平台 tab 的当前平台(V206);同 companyId 形状:白名单构造不收,从原始入参读。 */
|
|
||||||
platform?: PlatformTabId
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 序列化到 GET /api/admin/users 的查询参数(Java snake_case)。 */
|
/** 序列化到 GET /api/admin/users 的查询参数(Java snake_case)。 */
|
||||||
@@ -33,7 +30,6 @@ export interface UserListQuery {
|
|||||||
admin_id?: number
|
admin_id?: number
|
||||||
role?: string
|
role?: string
|
||||||
company_id?: number
|
company_id?: number
|
||||||
platform?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 用户列表项即 AdminUser(与 Java AdminUserItemVo 字段对齐)。 */
|
/** 用户列表项即 AdminUser(与 Java AdminUserItemVo 字段对齐)。 */
|
||||||
|
|||||||
@@ -18,10 +18,6 @@ export function toAdminUserItem(raw: unknown): AdminUser | null {
|
|||||||
const id = numberOrNull(r.id)
|
const id = numberOrNull(r.id)
|
||||||
if (id === null) return null
|
if (id === null) return null
|
||||||
const item: AdminUser = { id, username: text(r.username), role: text(r.role) }
|
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
|
if (typeof r.is_admin === 'boolean') item.isAdmin = r.is_admin
|
||||||
const createdById = numberOrNull(r.created_by_id)
|
const createdById = numberOrNull(r.created_by_id)
|
||||||
if (createdById !== null) item.createdById = createdById
|
if (createdById !== null) item.createdById = createdById
|
||||||
@@ -33,8 +29,6 @@ export function toAdminUserItem(raw: unknown): AdminUser | null {
|
|||||||
if (creator) item.creatorUsername = creator
|
if (creator) item.creatorUsername = creator
|
||||||
const expiresAt = text(r.expires_at)
|
const expiresAt = text(r.expires_at)
|
||||||
if (expiresAt) item.expiresAt = expiresAt
|
if (expiresAt) item.expiresAt = expiresAt
|
||||||
const disabledAt = text(r.disabled_at)
|
|
||||||
if (disabledAt) item.disabledAt = disabledAt
|
|
||||||
const abbr = text(r.pinyin_abbr)
|
const abbr = text(r.pinyin_abbr)
|
||||||
if (abbr) item.pinyinAbbr = abbr
|
if (abbr) item.pinyinAbbr = abbr
|
||||||
return item
|
return item
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ export async function fetchUserList(params: Partial<UserListParams> = {}): Promi
|
|||||||
// normalizeUserPageParams 是白名单构造(只点名 page/pageSize/keyword/createdById/adminId/role),
|
// normalizeUserPageParams 是白名单构造(只点名 page/pageSize/keyword/createdById/adminId/role),
|
||||||
// 公司值必须从原始 params 读:写成 normalized.companyId 会 TS 绿、运行时恒 undefined。
|
// 公司值必须从原始 params 读:写成 normalized.companyId 会 TS 绿、运行时恒 undefined。
|
||||||
if (params.companyId != null) query.company_id = params.companyId
|
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: query })
|
||||||
return parseUserPage(data)
|
return parseUserPage(data)
|
||||||
}
|
}
|
||||||
@@ -26,12 +24,3 @@ export async function deleteUser(uid: number): Promise<void> {
|
|||||||
const { data } = await http.delete<unknown>(`/api/admin/user/${uid}`)
|
const { data } = await http.delete<unknown>(`/api/admin/user/${uid}`)
|
||||||
unwrap<unknown>(data)
|
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)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { copyFeedback, isCopySupported } from './copy-model'
|
import { copyFeedback, isCopySupported } from './copy-model'
|
||||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
|
||||||
|
|
||||||
const props = defineProps<{ text: string }>()
|
const props = defineProps<{ text: string }>()
|
||||||
|
|
||||||
@@ -14,7 +13,7 @@ async function handleCopy(): Promise<void> {
|
|||||||
await navigator.clipboard.writeText(props.text)
|
await navigator.clipboard.writeText(props.text)
|
||||||
ElMessage.success(copyFeedback(props.text))
|
ElMessage.success(copyFeedback(props.text))
|
||||||
} catch {
|
} catch {
|
||||||
showAdminFeedback(copyFeedback(''), 'error')
|
ElMessage.error(copyFeedback(''))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -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>
|
|
||||||
@@ -75,88 +75,27 @@
|
|||||||
重置
|
重置
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</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>
|
||||||
|
|
||||||
<div v-if="loading && !groups.length" class="bell-empty">正在加载...</div>
|
<div v-if="loading && !items.length" class="bell-empty">正在加载...</div>
|
||||||
<div v-else-if="loadError && !groups.length" class="bell-empty bell-empty--error">{{ loadError }}</div>
|
<div v-else-if="loadError && !items.length" class="bell-empty bell-empty--error">{{ loadError }}</div>
|
||||||
<div v-else-if="!groups.length" class="bell-empty">{{ hasFilter ? '没有符合条件的通知' : '暂无通知' }}</div>
|
<div v-else-if="!items.length" class="bell-empty">{{ hasFilter ? '没有符合条件的通知' : '暂无通知' }}</div>
|
||||||
<ul v-else class="bell-list">
|
<ul v-else class="bell-list">
|
||||||
<template v-for="(group, index) in groups" :key="notificationGroupKey(group)">
|
<template v-for="group in groupedItems" :key="group.day || 'unknown'">
|
||||||
<!-- 严重度排序会跨天交错,日期头只在时间排序下有意义 -->
|
<li class="bell-day-head">{{ group.label }}</li>
|
||||||
<li v-if="sortMode === 'time' && startsNewDay(index)" class="bell-day-head">{{ formatDayLabel(group.day) }}</li>
|
|
||||||
<li
|
<li
|
||||||
class="bell-group"
|
v-for="item in group.items"
|
||||||
: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"
|
:key="item.id"
|
||||||
class="bell-item bell-item--detail"
|
class="bell-item"
|
||||||
:class="{ 'bell-item--unread': !item.read }"
|
:class="[`bell-item--${item.level || 'warning'}`, { 'bell-item--unread': !item.read }]"
|
||||||
@click="onItemClick(item)"
|
@click="onItemClick(item)"
|
||||||
>
|
>
|
||||||
<div class="bell-item-head">
|
<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-title">{{ item.title }}</span>
|
||||||
<span class="bell-item-time">{{ formatTime(item.createdAt) }}</span>
|
<span class="bell-item-time">{{ formatTime(item.createdAt) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="bell-item-content">{{ item.content }}</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>
|
||||||
<li v-if="!detailLoading && detailTotal > details.length" class="bell-detail-more">
|
|
||||||
另有 {{ detailTotal - details.length }} 条未列出,可缩小日期范围后查看
|
|
||||||
</li>
|
|
||||||
</template>
|
|
||||||
</template>
|
</template>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
@@ -178,7 +117,7 @@
|
|||||||
>
|
>
|
||||||
下一页
|
下一页
|
||||||
</button>
|
</button>
|
||||||
<span class="bell-page-total">共 {{ total }} 组 · 明细 {{ rowCount }} 条</span>
|
<span class="bell-page-total">共 {{ total }} 条</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Teleport>
|
</Teleport>
|
||||||
@@ -186,89 +125,165 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, onUnmounted, ref } from 'vue'
|
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { ElMessage } from 'element-plus'
|
||||||
|
|
||||||
|
import {
|
||||||
|
fetchNotificationList,
|
||||||
|
fetchNotificationSummary,
|
||||||
|
markAllNotificationsRead,
|
||||||
|
markNotificationRead,
|
||||||
|
type AdminNotificationItem,
|
||||||
|
} from '@/api/notifications'
|
||||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||||
import type { AdminNotificationItem, AdminNotificationRef } from '@/api/notifications'
|
|
||||||
import {
|
import {
|
||||||
NOTIFICATION_POLL_INTERVAL_MS,
|
NOTIFICATION_POLL_INTERVAL_MS,
|
||||||
formatDayLabel,
|
|
||||||
formatGroupCounts,
|
|
||||||
formatNotificationTime,
|
formatNotificationTime,
|
||||||
notificationGroupKey,
|
formatUnreadBadge,
|
||||||
taskCenterRouteForRef,
|
groupNotificationsByDay,
|
||||||
|
hasNewNotification,
|
||||||
|
readLastNotifiedId,
|
||||||
|
writeLastNotifiedId,
|
||||||
} from '@/layout/notification-bell-model'
|
} from '@/layout/notification-bell-model'
|
||||||
import { todayDateInput } from '@/utils/datetime'
|
import { todayDateInput } from '@/utils/datetime'
|
||||||
import {
|
|
||||||
itemLevel,
|
const PAGE_SIZE = 10
|
||||||
itemSeverity,
|
|
||||||
severityLabel,
|
|
||||||
startsNewDay as groupStartsNewDay,
|
|
||||||
useNotificationBellPanel,
|
|
||||||
} from '@/layout/notification-bell-panel'
|
|
||||||
|
|
||||||
const session = useAdminSessionStore()
|
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 rootRef = ref<HTMLElement | null>(null)
|
||||||
const panelRef = ref<HTMLElement | null>(null)
|
const panelRef = ref<HTMLElement | null>(null)
|
||||||
const panelStyle = ref<Record<string, string>>({})
|
const panelStyle = ref<Record<string, string>>({})
|
||||||
const panelOpen = ref(false)
|
|
||||||
|
|
||||||
/** 模板里仍是 startsNewDay(index):组序列在面板层,这里只补一次取值。 */
|
const unreadCount = ref(0)
|
||||||
function startsNewDay(index: number): boolean {
|
const items = ref<AdminNotificationItem[]>([])
|
||||||
return groupStartsNewDay(groups.value, index)
|
const total = ref(0)
|
||||||
|
const page = ref(1)
|
||||||
|
const panelOpen = ref(false)
|
||||||
|
const loading = ref(false)
|
||||||
|
const markingAll = ref(false)
|
||||||
|
const loadError = ref('')
|
||||||
|
const keyword = ref('')
|
||||||
|
const startDate = ref(todayDateInput())
|
||||||
|
const endDate = ref(todayDateInput())
|
||||||
|
|
||||||
|
const badgeText = computed(() => formatUnreadBadge(unreadCount.value))
|
||||||
|
const groupedItems = computed(() => groupNotificationsByDay(items.value))
|
||||||
|
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / PAGE_SIZE)))
|
||||||
|
/** 日期恒为「当天」是默认视图、不算主动筛选:若计入,下方「无筛选才记录已提醒 id」的分支会永久失效。 */
|
||||||
|
const hasFilter = computed(() => Boolean(keyword.value.trim()))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* el-date-picker 的绑定桥:日期区间在内部仍用 startDate/endDate 两个 ref 表示
|
||||||
|
* (hasFilter/normalizedDayRange/resetFilters 都基于它们)。
|
||||||
|
* 此前模板写的是 v-model="dateRange",而 dateRange 从未声明 → vue-tsc 直接报 TS2339 构建失败,
|
||||||
|
* 且日期筛选完全不下发参数。
|
||||||
|
*/
|
||||||
|
const dateRangeValue = computed<[string, string] | null>(() =>
|
||||||
|
startDate.value && endDate.value ? [startDate.value, endDate.value] : null
|
||||||
|
)
|
||||||
|
|
||||||
|
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 formatTime(value: string | null) {
|
let pollTimer: number | null = null
|
||||||
return formatNotificationTime(value)
|
let searchTimer: number | null = null
|
||||||
|
|
||||||
|
function currentUid(): number | string {
|
||||||
|
return session.user?.id ?? 0
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 起止日期倒挂时自动交换,避免用户只看到「没有符合条件的通知」不知原因。 */
|
||||||
|
function normalizedDayRange(): { startDate?: string; endDate?: string } {
|
||||||
|
let start = startDate.value
|
||||||
|
let end = endDate.value
|
||||||
|
if (start && end && start > end) {
|
||||||
|
const swapped = start
|
||||||
|
start = end
|
||||||
|
end = swapped
|
||||||
|
}
|
||||||
|
return { startDate: start || undefined, endDate: end || undefined }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 拉未读数:发现新通知提醒一次(localStorage 记录已提醒过的最大 id,避免重复弹)。 */
|
||||||
|
async function refreshSummary() {
|
||||||
|
try {
|
||||||
|
const summary = await fetchNotificationSummary()
|
||||||
|
unreadCount.value = Number(summary?.unreadCount ?? 0)
|
||||||
|
const latestId = Number(summary?.latestId ?? 0)
|
||||||
|
if (hasNewNotification(latestId, readLastNotifiedId(currentUid()))) {
|
||||||
|
ElMessage.warning('收到新的告警通知,请点击右上角铃铛查看')
|
||||||
|
writeLastNotifiedId(currentUid(), latestId)
|
||||||
|
console.log('[admin-notification] 检测到新通知 latestId=', latestId)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// 通知接口失败静默降级:不显示红点、不打扰使用者
|
||||||
|
console.warn('[admin-notification] 未读数刷新失败(静默降级):', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadPage(targetPage: number) {
|
||||||
|
if (loading.value) return
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const result = await fetchNotificationList({
|
||||||
|
page: targetPage,
|
||||||
|
pageSize: PAGE_SIZE,
|
||||||
|
keyword: keyword.value,
|
||||||
|
...normalizedDayRange(),
|
||||||
|
})
|
||||||
|
const list = Array.isArray(result?.items) ? result.items : []
|
||||||
|
items.value = list
|
||||||
|
total.value = Number(result?.total ?? list.length)
|
||||||
|
unreadCount.value = Number(result?.unreadCount ?? unreadCount.value)
|
||||||
|
page.value = targetPage
|
||||||
|
loadError.value = ''
|
||||||
|
// 无筛选时首页就是最新数据,顺带记录「已提醒过的最大 id」;有筛选时最新 id 不代表真实最新
|
||||||
|
if (targetPage <= 1 && !hasFilter.value && list.length) {
|
||||||
|
const latest = Number(list[0].id)
|
||||||
|
if (latest > 0) {
|
||||||
|
writeLastNotifiedId(currentUid(), Math.max(readLastNotifiedId(currentUid()), latest))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// 列表加载失败在面板内提示,不弹全局消息打扰用户
|
||||||
|
console.warn('[admin-notification] 通知列表加载失败:', error)
|
||||||
|
loadError.value = error instanceof Error ? error.message : '通知加载失败'
|
||||||
|
} finally {
|
||||||
|
loading.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)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 关键字输入防抖 300ms,避免每敲一个字都打一次接口。 */
|
||||||
|
function onKeywordInput() {
|
||||||
|
if (searchTimer != null) {
|
||||||
|
window.clearTimeout(searchTimer)
|
||||||
|
}
|
||||||
|
searchTimer = window.setTimeout(() => {
|
||||||
|
searchTimer = null
|
||||||
|
void loadPage(1)
|
||||||
|
}, 300)
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetFilters() {
|
||||||
|
keyword.value = ''
|
||||||
|
startDate.value = todayDateInput()
|
||||||
|
endDate.value = todayDateInput()
|
||||||
|
void loadPage(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 面板挂到 body 后用 fixed 定位,位置按触发器实时算(右对齐在铃铛下方)。 */
|
/** 面板挂到 body 后用 fixed 定位,位置按触发器实时算(右对齐在铃铛下方)。 */
|
||||||
@@ -286,10 +301,42 @@ function togglePanel() {
|
|||||||
panelOpen.value = !panelOpen.value
|
panelOpen.value = !panelOpen.value
|
||||||
if (panelOpen.value) {
|
if (panelOpen.value) {
|
||||||
syncPanelPosition()
|
syncPanelPosition()
|
||||||
reload()
|
void loadPage(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onItemClick(item: AdminNotificationItem) {
|
||||||
|
if (item.read) return
|
||||||
|
try {
|
||||||
|
await markNotificationRead(item.id)
|
||||||
|
item.read = true
|
||||||
|
unreadCount.value = Math.max(0, unreadCount.value - 1)
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('[admin-notification] 标记已读失败:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function readAll() {
|
||||||
|
if (markingAll.value || unreadCount.value === 0) return
|
||||||
|
markingAll.value = true
|
||||||
|
try {
|
||||||
|
await markAllNotificationsRead()
|
||||||
|
for (const item of items.value) {
|
||||||
|
item.read = true
|
||||||
|
}
|
||||||
|
unreadCount.value = 0
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('[admin-notification] 全部已读失败:', error)
|
||||||
|
ElMessage.error(error instanceof Error ? error.message : '操作失败')
|
||||||
|
} finally {
|
||||||
|
markingAll.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatTime(value: string | null) {
|
||||||
|
return formatNotificationTime(value)
|
||||||
|
}
|
||||||
|
|
||||||
/** 点击组件外部关闭面板(面板已 Teleport 到 body,需连同面板自身一起判断)。 */
|
/** 点击组件外部关闭面板(面板已 Teleport 到 body,需连同面板自身一起判断)。 */
|
||||||
function onDocumentMouseDown(event: MouseEvent) {
|
function onDocumentMouseDown(event: MouseEvent) {
|
||||||
if (!panelOpen.value) return
|
if (!panelOpen.value) return
|
||||||
@@ -309,22 +356,20 @@ function onWindowResize() {
|
|||||||
/** 页面回到前台时立即刷新一次未读数。 */
|
/** 页面回到前台时立即刷新一次未读数。 */
|
||||||
function onVisibilityChange() {
|
function onVisibilityChange() {
|
||||||
if (typeof document !== 'undefined' && document.visibilityState === 'visible') {
|
if (typeof document !== 'undefined' && document.visibilityState === 'visible') {
|
||||||
refreshSummary()
|
void refreshSummary()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let pollTimer: number | null = null
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
document.addEventListener('mousedown', onDocumentMouseDown)
|
document.addEventListener('mousedown', onDocumentMouseDown)
|
||||||
document.addEventListener('visibilitychange', onVisibilityChange)
|
document.addEventListener('visibilitychange', onVisibilityChange)
|
||||||
window.addEventListener('resize', onWindowResize)
|
window.addEventListener('resize', onWindowResize)
|
||||||
refreshSummary()
|
void refreshSummary()
|
||||||
pollTimer = window.setInterval(() => {
|
pollTimer = window.setInterval(() => {
|
||||||
if (typeof document !== 'undefined' && document.visibilityState !== 'visible') {
|
if (typeof document !== 'undefined' && document.visibilityState !== 'visible') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
refreshSummary()
|
void refreshSummary()
|
||||||
}, NOTIFICATION_POLL_INTERVAL_MS)
|
}, NOTIFICATION_POLL_INTERVAL_MS)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -336,6 +381,10 @@ onUnmounted(() => {
|
|||||||
window.clearInterval(pollTimer)
|
window.clearInterval(pollTimer)
|
||||||
pollTimer = null
|
pollTimer = null
|
||||||
}
|
}
|
||||||
|
if (searchTimer != null) {
|
||||||
|
window.clearTimeout(searchTimer)
|
||||||
|
searchTimer = null
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -465,70 +514,6 @@ onUnmounted(() => {
|
|||||||
background: #f7f9fc;
|
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 {
|
.bell-item--unread {
|
||||||
background: #f2f6ff;
|
background: #f2f6ff;
|
||||||
}
|
}
|
||||||
@@ -552,7 +537,6 @@ onUnmounted(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.bell-item-title {
|
.bell-item-title {
|
||||||
flex: 1;
|
|
||||||
color: var(--admin-text, #24384d);
|
color: var(--admin-text, #24384d);
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
@@ -562,36 +546,6 @@ onUnmounted(() => {
|
|||||||
white-space: nowrap;
|
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 {
|
.bell-item--error .bell-item-title {
|
||||||
color: #b23c3c;
|
color: #b23c3c;
|
||||||
}
|
}
|
||||||
@@ -618,12 +572,6 @@ onUnmounted(() => {
|
|||||||
word-break: break-all;
|
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 {
|
.bell-search {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -687,42 +635,6 @@ onUnmounted(() => {
|
|||||||
background: #edf5fb;
|
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 {
|
.bell-day-head {
|
||||||
padding: 6px 14px;
|
padding: 6px 14px;
|
||||||
background: #f4f7fa;
|
background: #f4f7fa;
|
||||||
@@ -771,11 +683,3 @@ onUnmounted(() => {
|
|||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style>
|
|
||||||
/* 日期选择面板与通知面板同为 body 级浮层,须压在通知面板(3200)之上:
|
|
||||||
Element 弹层只自 2000 起递增,不抬就会被面板挡住,表现为「日期点不动」。 */
|
|
||||||
.bell-date-popper {
|
|
||||||
z-index: 3300 !important;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -1,49 +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 = '重试'
|
|
||||||
|
|
||||||
/** 从 axios 错误 / Error / 字符串里取后端给的原因;取不到、或原文不是中文时返回空串。 */
|
|
||||||
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 (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}`
|
|
||||||
}
|
|
||||||
@@ -32,17 +32,13 @@ export const COMPANY_SCOPED_PAGES: readonly CompanyScopedPage[] = [
|
|||||||
// 【这两页已于 2026-10-06 退出注册表】admin_invalid_asin_data(品牌数据库)与 admin_product_categories
|
// 【这两页已于 2026-10-06 退出注册表】admin_invalid_asin_data(品牌数据库)与 admin_product_categories
|
||||||
// (商品类目)按控制方定案退回**全平台共享**,摘的不只是 tab:后端读写两侧的 company_id 谓词一起删
|
// (商品类目)按控制方定案退回**全平台共享**,摘的不只是 tab:后端读写两侧的 company_id 谓词一起删
|
||||||
// (V151 退唯一键)。反向钉在 tests/company-tab-wiring.test.ts——把它们再加回来必须先推翻那条定案。
|
// (V151 退唯一键)。反向钉在 tests/company-tab-wiring.test.ts——把它们再加回来必须先推翻那条定案。
|
||||||
// dedupe-import-api.ts 是 10-09 补进来的:导入/删除导入这两支写侧出口原先不发 company_id,
|
{ menuKey: 'admin_dedupe_total_data', apiFiles: ['src/pages/asin/dedupe-total-api.ts', 'src/pages/asin/dedupe-total-export.ts'], pageFiles: ['src/pages/asin/DedupeRegistryPage.vue'] },
|
||||||
// 超管在别家 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_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'] },
|
{ 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 列筛的,
|
// 批次 3(控制方 2026-10-05 点名「店铺撞款监控 店铺数据也要做隔离」)。这两页的可见集不是按 company_id 列筛的,
|
||||||
// 而是「本公司账号名下的店铺」:后端由 DataReadScope 把公司 → 成员账号 → biz_shop_manage.created_by_id 逐级推导,
|
// 而是「本公司账号名下的店铺」:后端由 DataReadScope 把公司 → 成员账号 → biz_shop_manage.created_by_id 逐级推导,
|
||||||
// 前端只负责把 activeId 当 company_id 送下去。
|
// 前端只负责把 activeId 当 company_id 送下去。
|
||||||
{ menuKey: 'admin_shop_data_duplicate_check', apiFiles: ['src/pages/tasks/duplicate-console-api.ts'], pageFiles: ['src/pages/tasks/DuplicateCheckPage.vue'] },
|
{ 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'] },
|
{ 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 的数据」)。
|
// 批次 4(控制方 2026-10-05 点名「菜单权限和用户管理也要区分公司 tab 的数据」)。
|
||||||
// 这一页的后端早就认 company_id(AdminUserService 只在**站点超管**身上用它筛,公司超管恒锁本公司),
|
// 这一页的后端早就认 company_id(AdminUserService 只在**站点超管**身上用它筛,公司超管恒锁本公司),
|
||||||
@@ -51,7 +47,7 @@ export const COMPANY_SCOPED_PAGES: readonly CompanyScopedPage[] = [
|
|||||||
// 批次 5(控制方 2026-10-06 点名「店铺密钥管理的数据按照公司区分」)。biz_shop_key 原先零归属列,
|
// 批次 5(控制方 2026-10-06 点名「店铺密钥管理的数据按照公司区分」)。biz_shop_key 原先零归属列,
|
||||||
// 拿到这一页菜单的任意管理员读的是同一池全平台紫鸟令牌,而列表 VO 把令牌原文整列下发(悬停即得全文)。
|
// 拿到这一页菜单的任意管理员读的是同一池全平台紫鸟令牌,而列表 VO 把令牌原文整列下发(悬停即得全文)。
|
||||||
// V150 加 company_id;后端读门是 readCompanyIdOrOwn ⇒ 非超管连 company_id 都不带也一律锁本公司,
|
// V150 加 company_id;后端读门是 readCompanyIdOrOwn ⇒ 非超管连 company_id 都不带也一律锁本公司,
|
||||||
// 这一页的 tab 只对超管改变行数(非超管恒锁本公司,与其余页同形)。
|
// 这一页的 tab 只对超管改变行数(与其余页同形,见 COMPANY_TAB_GUIDE_NOTE 开头那句「超级管理员」)。
|
||||||
{ menuKey: 'admin_shop_keys', apiFiles: ['src/pages/shop/shop-key-api.ts'], pageFiles: ['src/pages/shop/ShopKeysPage.vue'] },
|
{ menuKey: 'admin_shop_keys', apiFiles: ['src/pages/shop/shop-key-api.ts'], pageFiles: ['src/pages/shop/ShopKeysPage.vue'] },
|
||||||
// 批次 6(控制方 2026-10-06 点名「菜单权限也加字段来区分」,并选了「每家公司一套菜单树」那一档)。
|
// 批次 6(控制方 2026-10-06 点名「菜单权限也加字段来区分」,并选了「每家公司一套菜单树」那一档)。
|
||||||
// V149 给 columns 加 company_id 并把 52 行复制成每家一套 ⇒ 同一 column_key 在别家有另一份 id:
|
// V149 给 columns 加 company_id 并把 52 行复制成每家一套 ⇒ 同一 column_key 在别家有另一份 id:
|
||||||
@@ -60,12 +56,4 @@ export const COMPANY_SCOPED_PAGES: readonly CompanyScopedPage[] = [
|
|||||||
// 「无效的菜单权限项」。写侧(编辑/删除/重排)不带参数——归属由那一行的 id 与操作者公司共同判定,
|
// 「无效的菜单权限项」。写侧(编辑/删除/重排)不带参数——归属由那一行的 id 与操作者公司共同判定,
|
||||||
// 跨公司写后端 403(见 docs/ops/menu-company-tree-design-2026-10-06.md §5)。
|
// 跨公司写后端 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'] },
|
{ 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,42 +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(含店铺管理/生成记录等
|
|
||||||
* 存量页)一律归亚马逊或双侧清单。 */
|
|
||||||
export const JD_MENU_KEYS: readonly string[] = [
|
|
||||||
'admin_jd_database',
|
|
||||||
]
|
|
||||||
|
|
||||||
/** 双侧共用菜单(2026-11-17 用户口径「这些亚马逊这边也要有」):三个账号域页面在两个
|
|
||||||
* 平台 tab 下都显示——同一套组件、按当前 tab 给接口传 platform,各自只看/管各自平台的
|
|
||||||
* 账号、分组、公司(后端 V206 三表加列,存量默认亚马逊,京东侧数据在编辑弹窗里翻档)。 */
|
|
||||||
export const BOTH_PLATFORM_MENU_KEYS: readonly string[] = [
|
|
||||||
'admin_users',
|
|
||||||
'admin_group_manage',
|
|
||||||
'admin_companies',
|
|
||||||
]
|
|
||||||
|
|
||||||
/** menuKey → 平台归属清单(唯一判定出口):京东独占 → ['jd'];双侧清单 → ['amazon','jd'];
|
|
||||||
* 其余(未知 key 在内)默认亚马逊。 */
|
|
||||||
export function platformsOfMenuKey(key: string): PlatformTabId[] {
|
|
||||||
if (JD_MENU_KEYS.includes(key)) return ['jd']
|
|
||||||
if (BOTH_PLATFORM_MENU_KEYS.includes(key)) return ['amazon', 'jd']
|
|
||||||
return ['amazon']
|
|
||||||
}
|
|
||||||
@@ -1,15 +1,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, watch } from 'vue'
|
import { computed, watch } from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import { ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||||
import { joinAdminPath } from '@/config/app'
|
import { joinAdminPath } from '@/config/app'
|
||||||
import { pageTitleOf, topbarUserOf } from '@/layout/topbar-model'
|
import { pageTitleOf, topbarUserOf } from '@/layout/topbar-model'
|
||||||
import { groupKeysForActive, toSidebarEntries } from '@/layout/menu-mapper'
|
import { groupKeysForActive, toSidebarEntries } from '@/layout/menu-mapper'
|
||||||
import { filterMenuTreeByPlatform, visiblePlatformsFor } 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 {
|
import {
|
||||||
EMPTY_MENU_DESCRIPTION,
|
EMPTY_MENU_DESCRIPTION,
|
||||||
EMPTY_MENU_TITLE,
|
EMPTY_MENU_TITLE,
|
||||||
@@ -21,7 +17,6 @@ import ExpiryNotice from '@/components/ExpiryNotice.vue'
|
|||||||
import OperationGuide from '@/layout/OperationGuide.vue'
|
import OperationGuide from '@/layout/OperationGuide.vue'
|
||||||
import CompanyTabs from '@/layout/CompanyTabs.vue'
|
import CompanyTabs from '@/layout/CompanyTabs.vue'
|
||||||
import { crumbsForActiveRoute, resolveDocumentTitle, updateDocumentTitle } from '@/layout/title-breadcrumb'
|
import { crumbsForActiveRoute, resolveDocumentTitle, updateDocumentTitle } from '@/layout/title-breadcrumb'
|
||||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
|
||||||
import {
|
import {
|
||||||
LOGOUT_CONFIRM_CANCEL,
|
LOGOUT_CONFIRM_CANCEL,
|
||||||
LOGOUT_CONFIRM_MESSAGE,
|
LOGOUT_CONFIRM_MESSAGE,
|
||||||
@@ -35,15 +30,7 @@ const router = useRouter()
|
|||||||
const session = useAdminSessionStore()
|
const session = useAdminSessionStore()
|
||||||
|
|
||||||
const activePath = computed(() => route.path)
|
const activePath = computed(() => route.path)
|
||||||
const platformTab = usePlatformTabStore()
|
const menuEntries = computed(() => toSidebarEntries(session.menuTree))
|
||||||
// 平台 tab(亚马逊/京东,2026-11-16「不混」定案)只做显示分组:准入仍是 session.menuTree
|
|
||||||
// (后端按权限裁剪)+路由守卫,这里只把当前用户已被授权的菜单按平台分侧展示。
|
|
||||||
const menuEntries = computed(() =>
|
|
||||||
toSidebarEntries(filterMenuTreeByPlatform(session.menuTree, platformTab.active)),
|
|
||||||
)
|
|
||||||
const visibleTabIds = computed(() => visiblePlatformsFor(session.menuTree))
|
|
||||||
const visibleTabDefs = computed(() => PLATFORM_TABS.filter((tab) => visibleTabIds.value.includes(tab.id)))
|
|
||||||
const showPlatformTabs = computed(() => visibleTabIds.value.length > 1)
|
|
||||||
const openedKeys = computed(() => groupKeysForActive(menuEntries.value, route.path))
|
const openedKeys = computed(() => groupKeysForActive(menuEntries.value, route.path))
|
||||||
const emptyMenu = computed(() => shouldShowEmptyMenu(menuEntries.value.length > 0, session.loading, session.initialized))
|
const emptyMenu = computed(() => shouldShowEmptyMenu(menuEntries.value.length > 0, session.loading, session.initialized))
|
||||||
const pageTitle = computed(() => pageTitleOf(route.meta.title))
|
const pageTitle = computed(() => pageTitleOf(route.meta.title))
|
||||||
@@ -57,34 +44,6 @@ watch(
|
|||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
)
|
)
|
||||||
|
|
||||||
// 直达 URL/面包屑跳到另一平台的页面时,tab 指示自动跟过去(与侧边栏保持一致)。
|
|
||||||
// 双侧清单里的页面(账号域三页)两个 tab 都算归属:当前 tab 已含它就不动。
|
|
||||||
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) => visibleTabIds.value.includes(platform))
|
|
||||||
if (target && target !== platformTab.active) {
|
|
||||||
platformTab.setActive(target)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ 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() {
|
async function signOut() {
|
||||||
try {
|
try {
|
||||||
await runLogout({
|
await runLogout({
|
||||||
@@ -100,7 +59,7 @@ async function signOut() {
|
|||||||
signOut: () => session.signOut(),
|
signOut: () => session.signOut(),
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '退出登录失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '退出登录失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -117,19 +76,6 @@ async function signOut() {
|
|||||||
</div>
|
</div>
|
||||||
</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-scrollbar class="admin-menu-scroll">
|
||||||
<el-menu :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">
|
<template v-for="entry in menuEntries" :key="entry.key">
|
||||||
|
|||||||
@@ -1,49 +1,30 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
/** 页面上方的公司 tab(spec §4、§9.3):只有超管看得到,而且只画在**注册表里真的按公司取数的那些页**上——
|
/** 页面上方的公司 tab(spec §4、§9.3):只有超管看得到,而且只画在**注册表里真的按公司取数的那些页**上——
|
||||||
* 选中哪家由哪一枚 tab 带 is-active 表达,这里不再挂第二处"这家是谁"的文案(§12 第 5 条把页头提示条算未批的界面暴露),
|
* 选中哪家由哪一枚 tab 带 is-active 表达,这里不再挂第二处"这家是谁"的文案(§12 第 5 条把页头提示条算未批的界面暴露),
|
||||||
* 提示条只讲这一页怎么办,不讲 tab(2026-10-14 公司观感那句已从引导文案撤掉,见 operation-guides 文件头)。 */
|
* 观感说明走 operation-guides 的引导文案。 */
|
||||||
import { computed, watch } from 'vue'
|
import { computed, watch } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { COMPANY_STATUS_ACTIVE } from '@/api/companies-dto'
|
import { COMPANY_STATUS_ACTIVE } from '@/api/companies-dto'
|
||||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||||
import { usePlatformTabStore } from '@/stores/platform-tab'
|
import { companyTabAppliesTo } from '@/layout/company-tab-model'
|
||||||
import { companyTabAppliesTo, companyTabInitFailureMessage } from '@/layout/company-tab-model'
|
|
||||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const tab = useCompanyTabStore()
|
const tab = useCompanyTabStore()
|
||||||
const session = useAdminSessionStore()
|
const session = useAdminSessionStore()
|
||||||
const platformTab = usePlatformTabStore()
|
|
||||||
const tabs = computed(() => tab.companies.filter((c) => c.status === COMPANY_STATUS_ACTIVE))
|
const tabs = computed(() => tab.companies.filter((c) => c.status === COMPANY_STATUS_ACTIVE))
|
||||||
const show = computed(() => tab.visibleForOperator && companyTabAppliesTo(route.meta.menuKey))
|
const show = computed(() => tab.visibleForOperator && companyTabAppliesTo(route.meta.menuKey))
|
||||||
|
|
||||||
function ensureLoaded() {
|
watch(() => session.isSuperAdmin, (v) => {
|
||||||
|
if (!v) return
|
||||||
// 2026-10-05 修复轮 1:改前这里是 `void tab.initialize()`,store 里也只有 try/finally ⇒
|
// 2026-10-05 修复轮 1:改前这里是 `void tab.initialize()`,store 里也只有 try/finally ⇒
|
||||||
// GET /companies 抛错时异常变成 unhandled rejection(全仓 src 无 errorHandler/unhandledrejection 兜底),
|
// GET /companies 抛错时异常变成 unhandled rejection(全仓 src 无 errorHandler/unhandledrejection 兜底),
|
||||||
// 现场只剩"tab 条没画出来",Task 13 人工清单第一项无从判断是权限问题还是接口挂了。
|
// 现场只剩"tab 条没画出来",Task 13 人工清单第一项无从判断是权限问题还是接口挂了。
|
||||||
// 取不到目录 ⇒ fail-closed 不画 tab 条:store 不翻转 loaded,visibleForOperator 仍为 false,观感与改前一致。
|
// 取不到目录 ⇒ fail-closed 不画 tab 条:store 不翻转 loaded,visibleForOperator 仍为 false,观感与改前一致。
|
||||||
// store 照 admin-session.ts:37-39 的口径 catch 出 error 之后仍然 rethrow,所以这一侧必须 .catch 接住。
|
// store 照 admin-session.ts:37-39 的口径 catch 出 error 之后仍然 rethrow,所以这一侧必须 .catch 接住。
|
||||||
// 模板里仍不长出任何新的常驻文字/提示条/图标(§12 第 5 条未批的暴露),但失败不许只剩 console.warn:
|
// 只写 console.warn:不许在模板里长出任何新的用户可见文字/提示条/图标(§12 第 5 条未批的暴露)。
|
||||||
// 文案由 company-tab-model 出,可见出口统一走 admin-feedback-ui 的 showAdminFeedback(一次性提示)。
|
tab.initialize().catch((error: unknown) => console.warn('[company-tab] 公司目录没取到,tab 条不渲染', error))
|
||||||
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 })
|
}, { immediate: true })
|
||||||
|
|
||||||
// 平台 tab 切换=公司目录换一份(V206 平台分侧;2026-11-17 用户口径「亚马逊侧别再挂京东-团队,
|
|
||||||
// 京东侧同理」):store 按 loadedPlatform 对撞早退,切了台必然重拉。非超管目录恒空不发请求,
|
|
||||||
// 这里同样按超管闸早退。
|
|
||||||
watch(() => platformTab.active, () => {
|
|
||||||
if (!session.isSuperAdmin) return
|
|
||||||
ensureLoaded()
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -23,20 +23,6 @@ export function companyIdForRequest(isSuperAdmin: boolean, activeId: number | nu
|
|||||||
return isSuperAdmin ? activeId : 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 口径:不是超管自己所属公司,也不是返回顺序首条)。 */
|
/** 「默认选中第一家」= id 最小的启用公司(spec §4 口径:不是超管自己所属公司,也不是返回顺序首条)。 */
|
||||||
export function firstSelectableCompanyId(companies: readonly CompanyItem[]): number | null {
|
export function firstSelectableCompanyId(companies: readonly CompanyItem[]): number | null {
|
||||||
const active = companies.filter((c) => c.status === COMPANY_STATUS_ACTIVE && c.id > 0)
|
const active = companies.filter((c) => c.status === COMPANY_STATUS_ACTIVE && c.id > 0)
|
||||||
|
|||||||
@@ -88,6 +88,32 @@ export function formatDayLabel(day: string, now: Date = new Date()): string {
|
|||||||
return `${year}年${month}月${date}日`
|
return `${year}年${month}月${date}日`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface NotificationDayGroup<T> {
|
||||||
|
day: string
|
||||||
|
label: string
|
||||||
|
items: T[]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 按年月日分组(组内保持入参顺序,列表本身已按 id 倒序)。 */
|
||||||
|
export function groupNotificationsByDay<T extends { createdAt: string | null }>(
|
||||||
|
items: T[],
|
||||||
|
now: Date = new Date(),
|
||||||
|
): NotificationDayGroup<T>[] {
|
||||||
|
const groups: NotificationDayGroup<T>[] = []
|
||||||
|
const indexByDay = new Map<string, NotificationDayGroup<T>>()
|
||||||
|
for (const item of items ?? []) {
|
||||||
|
const day = notificationDayKey(item.createdAt)
|
||||||
|
let group = indexByDay.get(day)
|
||||||
|
if (!group) {
|
||||||
|
group = { day, label: formatDayLabel(day, now), items: [] }
|
||||||
|
indexByDay.set(day, group)
|
||||||
|
groups.push(group)
|
||||||
|
}
|
||||||
|
group.items.push(item)
|
||||||
|
}
|
||||||
|
return groups
|
||||||
|
}
|
||||||
|
|
||||||
/** 通知时间展示:今天只显示 HH:mm;昨天显示「昨天 HH:mm」;更早显示 MM-DD HH:mm。 */
|
/** 通知时间展示:今天只显示 HH:mm;昨天显示「昨天 HH:mm」;更早显示 MM-DD HH:mm。 */
|
||||||
export function formatNotificationTime(
|
export function formatNotificationTime(
|
||||||
value: string | null | undefined,
|
value: string | null | undefined,
|
||||||
@@ -119,104 +145,3 @@ export function formatNotificationTime(
|
|||||||
}
|
}
|
||||||
return `${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${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,8 @@
|
|||||||
/**
|
/**
|
||||||
* 每菜单页的操作提示(guides)文案,对齐旧版 backend/static/admin-interactions.js 的 guides 表原文
|
* 每菜单页的操作提示(guides)文案,对齐旧版 backend/static/admin-interactions.js 的 guides 表原文
|
||||||
* (duplicate-check 为例外页不展示)。key = 路由 meta.menuKey。
|
* (duplicate-check 为例外页不展示)。key = 路由 meta.menuKey。
|
||||||
* 2026-10-14 控制方定案:提示条按 menuKey 取、不分支角色,谁能进这一页谁就看得到,
|
* 2026-10-05 公司 tab 起有**两处故意偏离**「原文」:group-manage 由通用 fallback 改为自带文案,
|
||||||
* 于是"超级管理员可用上方公司 tab 切换公司""本页全平台共享,不按公司区分"这类只描述超管观感的句子
|
* 参与 tab 的 8 页与不参与 tab 的 C 类 2 页在原文之后各追加一句——见下方三个 *_NOTE 常量。
|
||||||
* 会摊到普通账号脸上 —— 整批撤掉,文案回到旧版原文。tab 本身与它的接线没动。
|
|
||||||
* 反向守门:tests/align-operation-guide.test.ts 钉这几句不得回流。
|
|
||||||
*/
|
*/
|
||||||
export interface OperationGuideData {
|
export interface OperationGuideData {
|
||||||
text: string
|
text: string
|
||||||
@@ -19,21 +17,48 @@ export const OPERATION_GUIDE_FALLBACK: OperationGuideData = {
|
|||||||
/** 折叠状态 localStorage key(沿用旧版 shufuAdminGuideCollapsed 语义)。 */
|
/** 折叠状态 localStorage key(沿用旧版 shufuAdminGuideCollapsed 语义)。 */
|
||||||
export const OPERATION_GUIDE_STORAGE_KEY = 'shufuAdminGuideCollapsed'
|
export const OPERATION_GUIDE_STORAGE_KEY = 'shufuAdminGuideCollapsed'
|
||||||
|
|
||||||
|
/** §9.3 的承载:公司 tab 改的是「行数观感」,只写进既有引导文案,不做页头控件/提示条
|
||||||
|
* (§12 第 5 条把那种提示条算未批的界面暴露;当前哪一家由 is-active 的 tab 表达,一处事实不留两处)。
|
||||||
|
* 这句必须以「超级管理员」开头、不能写成祈使式的「由上方 tab 决定」:引导文案按 menuKey 取、
|
||||||
|
* 不分支角色,而非超管根本看不到 tab 条(company-tab store 的 visibleForOperator 里有 isSuperAdmin)。
|
||||||
|
* 这一句由参与 tab 的 14 页共用、不各抄一遍——文案差一个字,护栏就只盯得住其中一页。
|
||||||
|
* 由 tests/align-operation-guide.test.ts 的 guide_copy_carries_company_tab_note_for_every_scoped_page
|
||||||
|
* 按 COMPANY_SCOPED_PAGES 逐页盯着(分母取注册表,加一页忘了补文案会当场红)。 */
|
||||||
|
const COMPANY_TAB_GUIDE_NOTE = ' 超级管理员可用页面上方的公司 tab 切换公司,切换后行数会变化——行数变少不是数据丢了。'
|
||||||
|
|
||||||
|
/** §5 的承载:注册表里显式 companyScoped:false 的 C 类页要的是**另一句**——"这页不参与",
|
||||||
|
* 不是"会随 tab 变"。同一支护栏反向钉它(不得带 COMPANY_TAB_GUIDE_NOTE)。 */
|
||||||
|
const COMPANY_SCOPE_NOT_APPLIED_NOTE = ' 本页全平台共享,不按公司区分:超级管理员切换上方公司 tab 时它不会变,这不是筛选坏了。'
|
||||||
|
|
||||||
|
/** §6.3 归属口径:店铺落哪家由「负责人」决定,与 tab 无关——这条与直觉相反,不写在界面上就会被报成 bug。 */
|
||||||
|
const SHOP_OWNER_COMPANY_NOTE = ' 店铺归哪家公司由「负责人」决定,不由公司 tab 决定:负责人选自己,店铺就落在你自己那家。'
|
||||||
|
|
||||||
export const OPERATION_GUIDES: Record<string, OperationGuideData> = {
|
export const OPERATION_GUIDES: Record<string, OperationGuideData> = {
|
||||||
admin_users: {
|
admin_users: {
|
||||||
text: '先用筛选定位账号,再编辑角色和菜单权限;删除账号会要求二次确认。',
|
// 2026-10-05 批次 4:与 group-manage 同型偏离——参与公司 tab 的页必须在原文之后带上那句 §9.3,
|
||||||
|
// 所以这一条不再与旧版 guides 逐字相等(护栏改为 match 原句子串,见 align_guide_users_matches_reference_text)。
|
||||||
|
text: '先用筛选定位账号,再编辑角色和菜单权限;删除账号会要求二次确认。'
|
||||||
|
+ COMPANY_TAB_GUIDE_NOTE,
|
||||||
steps: ['筛选账号', '编辑权限', '确认保存'],
|
steps: ['筛选账号', '编辑权限', '确认保存'],
|
||||||
},
|
},
|
||||||
admin_columns: {
|
admin_columns: {
|
||||||
text: '菜单会影响后台和软件端的可见范围。先填写名称并选择对应页面,再设置上级菜单;顺序直接拖动列表左侧手柄调整。',
|
// 2026-10-06 批次 6:V149 起每家公司一套菜单树 ⇒ 这页参与公司 tab,必须带上 §9.3 那句
|
||||||
|
// (align-operation-guide 按注册表数分母,缺了它当场红)。
|
||||||
|
text: '菜单会影响后台和软件端的可见范围。先填写名称并选择对应页面,再设置上级菜单;顺序直接拖动列表左侧手柄调整。'
|
||||||
|
+ COMPANY_TAB_GUIDE_NOTE,
|
||||||
steps: ['新增或调整菜单', '设置层级', '拖动排序'],
|
steps: ['新增或调整菜单', '设置层级', '拖动排序'],
|
||||||
},
|
},
|
||||||
admin_group_manage: {
|
admin_group_manage: {
|
||||||
text: '数据权限分组决定"哪些账号能看到哪些店铺",分组按负责人和归属账号聚拢。',
|
// 2026-10-05 公司 tab(spec §9.3):这页改为**自带文案**,故意偏离文件头「沿用旧版原文」的约定——
|
||||||
|
// tab 那句不能塞进 OPERATION_GUIDE_FALLBACK(fallback 会被没进 tab 的页共用,等于把 tab 端给它们)。
|
||||||
|
// 也不写「跨公司的分组彼此看不见」:那是 Task 11 Step 3 明确没做的半边(附B 记了这条部分强度)。
|
||||||
|
text: '数据权限分组决定"哪些账号能看到哪些店铺",分组按负责人和归属账号聚拢。超级管理员切换上方公司 tab 后,列表只保留当前公司账号相关的分组。'
|
||||||
|
+ COMPANY_TAB_GUIDE_NOTE,
|
||||||
steps: ['选择分组', '维护负责人与归属账号', '核对店铺可见范围'],
|
steps: ['选择分组', '维护负责人与归属账号', '核对店铺可见范围'],
|
||||||
},
|
},
|
||||||
admin_user_secrets: {
|
admin_user_secrets: {
|
||||||
text: '用户密钥按账号绑定,列表只展示脱敏值。可对单条立即检测连通性;清空后该用户需要重新配置密钥。',
|
text: '用户密钥按账号绑定,列表只展示脱敏值。可对单条立即检测连通性;清空后该用户需要重新配置密钥。'
|
||||||
|
+ COMPANY_TAB_GUIDE_NOTE,
|
||||||
steps: ['筛选用户或状态', '立即检测连通性', '必要时清空'],
|
steps: ['筛选用户或状态', '立即检测连通性', '必要时清空'],
|
||||||
},
|
},
|
||||||
admin_companies: {
|
admin_companies: {
|
||||||
@@ -41,92 +66,90 @@ export const OPERATION_GUIDES: Record<string, OperationGuideData> = {
|
|||||||
steps: ['查看公司列表', '新建公司', '改名或启停'],
|
steps: ['查看公司列表', '新建公司', '改名或启停'],
|
||||||
},
|
},
|
||||||
admin_dedupe_total_data: {
|
admin_dedupe_total_data: {
|
||||||
text: '支持按关键词、用户、分组和国家筛选;导入前先确认所选分组,导出会按日期范围生成文件。',
|
text: '支持按关键词、用户、分组和国家筛选;导入前先确认所选分组,导出会按日期范围生成文件。'
|
||||||
|
+ COMPANY_TAB_GUIDE_NOTE,
|
||||||
steps: ['选择分组', '筛选或导入', '核对并导出'],
|
steps: ['选择分组', '筛选或导入', '核对并导出'],
|
||||||
},
|
},
|
||||||
admin_invalid_asin_data: {
|
admin_invalid_asin_data: {
|
||||||
text: '维护不符合规则的 ASIN 或品牌。添加后可使用上方筛选快速回查。',
|
text: '维护不符合规则的 ASIN 或品牌。添加后可使用上方筛选快速回查。'
|
||||||
|
+ COMPANY_SCOPE_NOT_APPLIED_NOTE,
|
||||||
steps: ['填写 ASIN/品牌', '选择分组', '保存并回查'],
|
steps: ['填写 ASIN/品牌', '选择分组', '保存并回查'],
|
||||||
},
|
},
|
||||||
admin_query_asin: {
|
admin_query_asin: {
|
||||||
text: '查询 ASIN 以店铺为单位维护。列表里点击 ASIN 即可复制,点右侧「配置」可一次维护该店铺所有站点的 ASIN。',
|
text: '查询 ASIN 以店铺为单位维护。列表里点击 ASIN 即可复制,点右侧「配置」可一次维护该店铺所有站点的 ASIN。'
|
||||||
|
+ COMPANY_TAB_GUIDE_NOTE,
|
||||||
steps: ['筛选店铺', '打开配置抽屉', '保存或导出'],
|
steps: ['筛选店铺', '打开配置抽屉', '保存或导出'],
|
||||||
},
|
},
|
||||||
admin_product_categories: {
|
admin_product_categories: {
|
||||||
text: '类目树支持展开查看层级。搜索、编辑和删除都在同一列表中完成。',
|
text: '类目树支持展开查看层级。搜索、编辑和删除都在同一列表中完成。'
|
||||||
|
+ COMPANY_SCOPE_NOT_APPLIED_NOTE,
|
||||||
steps: ['搜索类目', '展开层级', '新增或编辑'],
|
steps: ['搜索类目', '展开层级', '新增或编辑'],
|
||||||
},
|
},
|
||||||
admin_skip_price_asin: {
|
admin_skip_price_asin: {
|
||||||
text: '最低价 ASIN 以店铺为单位维护。列表里点击 ASIN 即可复制,点右侧「配置」可一次维护该店铺所有站点的 ASIN 与最低价。',
|
text: '最低价 ASIN 以店铺为单位维护。列表里点击 ASIN 即可复制,点右侧「配置」可一次维护该店铺所有站点的 ASIN 与最低价。'
|
||||||
|
+ COMPANY_TAB_GUIDE_NOTE,
|
||||||
steps: ['筛选店铺', '打开配置抽屉', '保存或批量导入'],
|
steps: ['筛选店铺', '打开配置抽屉', '保存或批量导入'],
|
||||||
},
|
},
|
||||||
admin_shop_keys: {
|
admin_shop_keys: {
|
||||||
text: '紫鸟令牌属于敏感配置。白名单状态可悬停查看检测详情,编辑前请先核对账号名称。',
|
// 2026-10-06 批次 5:这页由「全平台共享」改按公司区分(V150 给 biz_shop_key 加 company_id),
|
||||||
|
// 所以摘掉 COMPANY_SCOPE_NOT_APPLIED_NOTE、换上共用那一句 §9.3。
|
||||||
|
text: '紫鸟令牌属于敏感配置。白名单状态可悬停查看检测详情,编辑前请先核对账号名称。'
|
||||||
|
+ COMPANY_TAB_GUIDE_NOTE,
|
||||||
steps: ['新增或筛选密钥', '查看白名单状态', '编辑或删除'],
|
steps: ['新增或筛选密钥', '查看白名单状态', '编辑或删除'],
|
||||||
},
|
},
|
||||||
admin_shop_manage: {
|
admin_shop_manage: {
|
||||||
text: '店铺信息按分组管理。长商城名会自动缩略,悬停即可查看完整内容。',
|
text: '店铺信息按分组管理。长商城名会自动缩略,悬停即可查看完整内容。'
|
||||||
|
+ COMPANY_TAB_GUIDE_NOTE
|
||||||
|
+ SHOP_OWNER_COMPANY_NOTE,
|
||||||
steps: ['选择分组', '维护店铺信息', '筛选核对结果'],
|
steps: ['选择分组', '维护店铺信息', '筛选核对结果'],
|
||||||
},
|
},
|
||||||
admin_shop_data_crawl_tasks: {
|
admin_shop_data_crawl_tasks: {
|
||||||
text: '店铺数据任务按状态和时间筛选。批量操作前请核对已选任务。',
|
text: '店铺数据任务按状态和时间筛选。批量操作前请核对已选任务。'
|
||||||
|
+ COMPANY_TAB_GUIDE_NOTE,
|
||||||
steps: ['筛选任务', '检查状态', '执行批量操作'],
|
steps: ['筛选任务', '检查状态', '执行批量操作'],
|
||||||
},
|
},
|
||||||
admin_brand_gating: {
|
|
||||||
text: '维护不符合规则的品牌(品牌Gating / 类目Gating)。新增后可用下方筛选快速回查;云端 Gating 库与前端排查软件同步同一份数据,命中后会自动拦截。',
|
|
||||||
steps: ['新增或批量导入', '筛选回查', '按需解除或删除'],
|
|
||||||
},
|
|
||||||
admin_keyword_usage: {
|
|
||||||
text: '本页记录所有关键词操作,只读、不可删除、永久留痕可追溯;与桌面端互通:桌面复制、添加、删除关键词会自动写入本页,两端同源。',
|
|
||||||
steps: ['选择公司与筛选条件', '切换使用/删除记录', '核对操作人与时间'],
|
|
||||||
},
|
|
||||||
// admin_shop_data_duplicate_check(店铺撞款监控)为例外页:不展示全局提示条,不参与对齐。
|
// admin_shop_data_duplicate_check(店铺撞款监控)为例外页:不展示全局提示条,不参与对齐。
|
||||||
|
// 它进了公司 tab 范围(COMPANY_SCOPED_PAGES)却没有文案可挂,所以那句 §9.3 的看守在这一页由
|
||||||
|
// tests/align-operation-guide.test.ts 显式豁免;这一页的「切 tab 行数会变」写在页面自身的说明里。
|
||||||
admin_image_video_tasks: {
|
admin_image_video_tasks: {
|
||||||
text: '可先使用筛选缩小任务范围,再查看任务状态、结果和权限范围。',
|
text: '可先使用筛选缩小任务范围,再查看任务状态、结果和权限范围。'
|
||||||
|
+ COMPANY_TAB_GUIDE_NOTE,
|
||||||
steps: ['设置筛选', '查看任务结果', '按需处理任务'],
|
steps: ['设置筛选', '查看任务结果', '按需处理任务'],
|
||||||
},
|
},
|
||||||
admin_history: {
|
admin_history: {
|
||||||
text: '生成记录可按用户和时间范围回溯,用于核对结果文件和执行时间。',
|
text: '生成记录可按用户和时间范围回溯,用于核对结果文件和执行时间。'
|
||||||
|
+ COMPANY_TAB_GUIDE_NOTE,
|
||||||
steps: ['设置时间范围', '筛选记录', '查看结果预览'],
|
steps: ['设置时间范围', '筛选记录', '查看结果预览'],
|
||||||
},
|
},
|
||||||
admin_version: {
|
admin_version: {
|
||||||
text: '上传版本后请核对版本号和下载链接,再通知用户更新。',
|
text: '上传版本后请核对版本号和下载链接,再通知用户更新。'
|
||||||
|
+ COMPANY_SCOPE_NOT_APPLIED_NOTE,
|
||||||
steps: ['上传压缩包', '检查版本记录', '维护历史版本'],
|
steps: ['上传压缩包', '检查版本记录', '维护历史版本'],
|
||||||
},
|
},
|
||||||
admin_tutorial: {
|
admin_tutorial: {
|
||||||
text: '上传新的教程压缩包后即刻生效:工具台首页「立即下载教程」以下载最新上传的包为准。确认旧包不再需要后再删除。',
|
text: '上传新的教程压缩包后即刻生效:工具台首页「立即下载教程」以下载最新上传的包为准。确认旧包不再需要后再删除。'
|
||||||
|
+ COMPANY_SCOPE_NOT_APPLIED_NOTE,
|
||||||
steps: ['上传教程压缩包', '到工具台核对下载', '清理历史包'],
|
steps: ['上传教程压缩包', '到工具台核对下载', '清理历史包'],
|
||||||
},
|
},
|
||||||
admin_workbench_client_package: {
|
|
||||||
text: '上传新的工作台客户端 ZIP 包后即刻生效;服务端会复算 sha256 供客户端校验。确认旧包不再需要后再删除。',
|
|
||||||
steps: ['填写版本号并上传 ZIP', '核对版本与 sha256', '清理历史包'],
|
|
||||||
},
|
|
||||||
digital_human_version: {
|
digital_human_version: {
|
||||||
text: '数字人版本需先上传草稿,再发布并标记最新版本。',
|
text: '数字人版本需先上传草稿,再发布并标记最新版本。',
|
||||||
steps: ['上传草稿', '确认更新日志', '发布或设为最新'],
|
steps: ['上传草稿', '确认更新日志', '发布或设为最新'],
|
||||||
},
|
},
|
||||||
admin_device_logs: {
|
admin_device_logs: {
|
||||||
text: '桌面客户端与麦象采集机上报的日志按来源、日期和关键字筛选;可查看日志尾部、下载完整文件或删除云端记录,云端日志按保留期自动清理。',
|
text: '桌面客户端与麦象采集机上报的日志按来源、日期和关键字筛选;可查看日志尾部、下载完整文件或删除云端记录,云端日志按保留期自动清理。'
|
||||||
|
+ COMPANY_TAB_GUIDE_NOTE,
|
||||||
steps: ['选择来源与日期', '查看或下载日志', '必要时删除'],
|
steps: ['选择来源与日期', '查看或下载日志', '必要时删除'],
|
||||||
},
|
},
|
||||||
admin_user_secret_usage: {
|
admin_user_secret_usage: {
|
||||||
text: '按日期范围统计各用户的密钥调用次数(货源查询与外观专利按 LLM 请求次数、代理按提取次数),用于评估用户资源损耗。',
|
text: '按日期范围统计各用户的密钥调用次数(货源查询与外观专利按 LLM 请求次数、代理按提取次数),用于评估用户资源损耗。'
|
||||||
|
+ COMPANY_TAB_GUIDE_NOTE,
|
||||||
steps: ['选择日期范围', '筛选用户或分组', '核对各模块次数'],
|
steps: ['选择日期范围', '筛选用户或分组', '核对各模块次数'],
|
||||||
},
|
},
|
||||||
admin_task_center: {
|
admin_task_center: {
|
||||||
text: '按账号、业务、状态、店铺和创建时间筛出客户端任务,点任务查看明细与分组结果;顶部汇总卡给当前在跑与疑似卡住的总量。',
|
text: '按账号、业务、状态、店铺和创建时间筛出客户端任务,点任务查看明细与分组结果;顶部汇总卡给当前在跑与疑似卡住的总量。'
|
||||||
|
+ COMPANY_TAB_GUIDE_NOTE,
|
||||||
steps: ['按条件筛任务', '查看任务明细', '核对汇总卡'],
|
steps: ['按条件筛任务', '查看任务明细', '核对汇总卡'],
|
||||||
},
|
},
|
||||||
admin_appearance_patent_clean_items: {
|
|
||||||
text: '本页只读:出表成功后「结论=无侵权」的明细自动同步到这里,按分公司隔离分页展示;支持任务号/ASIN/国家/同步日期筛选,下载原表请到任务中心取结果文件。',
|
|
||||||
steps: ['筛选记录', '核对结论明细', '到任务中心下载原表'],
|
|
||||||
},
|
|
||||||
admin_jd_database: {
|
|
||||||
// 2026-11-17 分类管理子菜单并入本页(用户口径「京东分类管理并到京东数据库分类编辑里」,
|
|
||||||
// 原 admin_jd_category_manage 条目随之摘除):分类建/改名/删在工具栏「分类管理」。
|
|
||||||
text: '本页只读:客户端采集的京东店铺商品自动同步到这里(同店铺同商品只保留最新一次),按分公司隔离分页展示;点行查看全部属性与图片;分类的新建/改名/删除在工具栏「分类管理」,给商品归类先勾选再「批量编辑分类」。',
|
|
||||||
steps: ['筛选商品记录', '查看属性与图片明细', '用「分类管理」维护分类并批量归类'],
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 全部有独立/兜底提示的后台业务菜单 key。 */
|
/** 全部有独立/兜底提示的后台业务菜单 key。 */
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
import type { AdminMenuNode } from '../types/admin'
|
|
||||||
import { PLATFORM_TABS, platformsOfMenuKey } 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 下展示。
|
|
||||||
* 规则:叶子按 platformsOfMenuKey(key) 是否包含当前平台留下(双侧清单里的账号域三页两个
|
|
||||||
* tab 都显示);分组节点(admin_group_*)自身的 key 不参与平台判定,按「留住的子项数 > 0」
|
|
||||||
* 决定去留——否则京东 tab 下「账号与权限」这类混合分组会被整组误剪。节点的 key/name/
|
|
||||||
* route/children 形状原样透传(浅拷贝不改写),toSidebarEntries、groupKeysForActive 与
|
|
||||||
* 面包屑都不受影响。
|
|
||||||
*/
|
|
||||||
export function filterMenuTreeByPlatform(
|
|
||||||
nodes: AdminMenuNode[] | null | undefined,
|
|
||||||
platform: PlatformTabId,
|
|
||||||
): AdminMenuNode[] {
|
|
||||||
const filtered: AdminMenuNode[] = []
|
|
||||||
for (const node of nodes || []) {
|
|
||||||
const children = filterMenuTreeByPlatform(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
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 当前用户在哪些平台下至少有一个可点页面(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)
|
|
||||||
}
|
|
||||||
@@ -1,36 +1,14 @@
|
|||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
import { createPinia } from 'pinia'
|
import { createPinia } from 'pinia'
|
||||||
import { installElement } from '@/plugins/element'
|
import { installElement } from '@/plugins/element'
|
||||||
import { reportClientError } from '@/shared/api/error-report'
|
|
||||||
import '@/styles/main.css'
|
import '@/styles/main.css'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import router from './router'
|
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);全局中文语言包改由
|
// Element Plus 改为按需注册(见 src/plugins/element.ts);全局中文语言包改由
|
||||||
// App.vue 的 <el-config-provider :locale="zhCn"> 提供,不要再在这里 use(ElementPlus)。
|
// App.vue 的 <el-config-provider :locale="zhCn"> 提供,不要再在这里 use(ElementPlus)。
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
app.use(createPinia())
|
app.use(createPinia())
|
||||||
app.use(router)
|
app.use(router)
|
||||||
installElement(app)
|
installElement(app)
|
||||||
installGlobalError(app)
|
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
|||||||
@@ -2,27 +2,17 @@
|
|||||||
/** 公司管理(设计文档 §2.3):列表 + 新建 + 改名/启停。
|
/** 公司管理(设计文档 §2.3):列表 + 新建 + 改名/启停。
|
||||||
* 可见范围由后端收窄(超管全部、公司内 admin 只自己公司);写操作仅超管,这里隐藏入口只是配合,
|
* 可见范围由后端收窄(超管全部、公司内 admin 只自己公司);写操作仅超管,这里隐藏入口只是配合,
|
||||||
* 真正的把关在 CompanyController,页面不得当作权限边界。 */
|
* 真正的把关在 CompanyController,页面不得当作权限边界。 */
|
||||||
import { computed, onMounted, ref, watch } from 'vue'
|
import { computed, onMounted, ref } from 'vue'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
import { formatDateTime } from '@/utils/datetime'
|
import { formatDateTime } from '@/utils/datetime'
|
||||||
import { fetchCompanies } from '@/api/companies'
|
import { fetchCompanies } from '@/api/companies'
|
||||||
import { COMPANY_STATUS_ACTIVE, type CompanyItem } from '@/api/companies-dto'
|
import { COMPANY_STATUS_ACTIVE, type CompanyItem } from '@/api/companies-dto'
|
||||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
|
||||||
import { usePlatformTabStore } from '@/stores/platform-tab'
|
|
||||||
import OldPagination from '@/components/OldPagination.vue'
|
import OldPagination from '@/components/OldPagination.vue'
|
||||||
import CompanyEditorDialog from './CompanyEditorDialog.vue'
|
import CompanyEditorDialog from './CompanyEditorDialog.vue'
|
||||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
|
||||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
|
||||||
|
|
||||||
const session = useAdminSessionStore()
|
const session = useAdminSessionStore()
|
||||||
// 平台 tab(V206):公司列表按当前平台过滤,新建默认落当前平台。
|
|
||||||
const platformTab = usePlatformTabStore()
|
|
||||||
// 公司 tab 条(2026-11-17 起按平台过滤)共用这一份目录:公司翻档/启停后必须强制重拉,
|
|
||||||
// 否则 18 个页面的 tab 条端着旧名单,刚翻去京东的公司还挂在亚马逊侧。
|
|
||||||
const companyTab = useCompanyTabStore()
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const loadFailure = ref('')
|
|
||||||
const rows = ref<CompanyItem[]>([])
|
const rows = ref<CompanyItem[]>([])
|
||||||
const editorVisible = ref(false)
|
const editorVisible = ref(false)
|
||||||
const editingCompany = ref<CompanyItem | null>(null)
|
const editingCompany = ref<CompanyItem | null>(null)
|
||||||
@@ -43,12 +33,10 @@ function changeSize(size: number) { pageSize.value = size; page.value = 1 }
|
|||||||
|
|
||||||
async function loadCompanies() {
|
async function loadCompanies() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
try {
|
||||||
rows.value = await fetchCompanies(platformTab.active)
|
rows.value = await fetchCompanies()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loadFailure.value = error instanceof Error ? error.message : '公司列表加载失败'
|
ElMessage.error(error instanceof Error ? error.message : '公司列表加载失败')
|
||||||
showAdminFeedback(loadFailure.value, 'error')
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
@@ -64,21 +52,6 @@ function openEdit(company: CompanyItem) {
|
|||||||
editorVisible.value = true
|
editorVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存成功后:本页列表照常重拉,共享公司目录(tab 条)强制重拉一份。
|
|
||||||
// 重拉失败不弹新提示(§12 第 5 条未批的界面暴露):tab 条保留旧名单,下一次切平台 tab / 重进页面会再试。
|
|
||||||
async function onCompaniesSaved() {
|
|
||||||
await loadCompanies()
|
|
||||||
companyTab.refresh().catch((error: unknown) => {
|
|
||||||
console.warn('[company-tab] 公司保存后目录重拉失败', error)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 切平台 tab(V206)= 重新取数:公司归属按平台分列,两 tab 各看各的公司。
|
|
||||||
watch(() => platformTab.active, () => {
|
|
||||||
page.value = 1
|
|
||||||
void loadCompanies()
|
|
||||||
})
|
|
||||||
|
|
||||||
onMounted(loadCompanies)
|
onMounted(loadCompanies)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -97,7 +70,6 @@ onMounted(loadCompanies)
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="loadCompanies" />
|
|
||||||
<div class="table-scroll">
|
<div class="table-scroll">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -149,7 +121,7 @@ onMounted(loadCompanies)
|
|||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<CompanyEditorDialog v-model="editorVisible" :company="editingCompany" :platform="platformTab.active" @saved="onCompaniesSaved" />
|
<CompanyEditorDialog v-model="editorVisible" :company="editingCompany" @saved="loadCompanies" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
import type { PlatformTabId } from '@/config/platform-scope'
|
|
||||||
import { createCompany, updateCompany } from '@/api/companies'
|
import { createCompany, updateCompany } from '@/api/companies'
|
||||||
import {
|
import {
|
||||||
COMPANY_NAME_MAX_LENGTH,
|
COMPANY_NAME_MAX_LENGTH,
|
||||||
@@ -13,11 +12,11 @@ import {
|
|||||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||||
import { actionableErrorText } from '@/components/admin-feedback'
|
import { actionableErrorText } from '@/components/admin-feedback'
|
||||||
|
|
||||||
/** 新建/编辑公司(改名 + 启停 + 备注 + 所属平台 V206);写操作仅超管可用,权限由后端把关。 */
|
/** 新建/编辑公司(改名 + 启停 + 备注);写操作仅超管可用,权限由后端把关。 */
|
||||||
const props = defineProps<{ modelValue: boolean; company: CompanyItem | null; platform?: PlatformTabId }>()
|
const props = defineProps<{ modelValue: boolean; company: CompanyItem | null }>()
|
||||||
const emit = defineEmits<{ (e: 'update:modelValue', v: boolean): void; (e: 'saved'): void }>()
|
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 form = ref<CompanyDraft>({ companyName: '', status: COMPANY_STATUS_ACTIVE, remark: '' })
|
||||||
const errorText = ref('')
|
const errorText = ref('')
|
||||||
const busy = ref(false)
|
const busy = ref(false)
|
||||||
|
|
||||||
@@ -26,13 +25,8 @@ watch(
|
|||||||
(open) => {
|
(open) => {
|
||||||
if (!open) return
|
if (!open) return
|
||||||
form.value = props.company
|
form.value = props.company
|
||||||
? {
|
? { companyName: props.company.companyName, status: props.company.status, remark: props.company.remark || '' }
|
||||||
companyName: props.company.companyName,
|
: { companyName: '', status: COMPANY_STATUS_ACTIVE, remark: '' }
|
||||||
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 = ''
|
errorText.value = ''
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -77,12 +71,6 @@ async function save() {
|
|||||||
placeholder="请输入公司名称(全平台唯一)"
|
placeholder="请输入公司名称(全平台唯一)"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="所属平台">
|
|
||||||
<el-radio-group v-model="form.platform">
|
|
||||||
<el-radio-button value="amazon">亚马逊</el-radio-button>
|
|
||||||
<el-radio-button value="jd">京东</el-radio-button>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="状态">
|
<el-form-item label="状态">
|
||||||
<el-select v-model="form.status" style="width: 100%">
|
<el-select v-model="form.status" style="width: 100%">
|
||||||
<el-option :value="COMPANY_STATUS_ACTIVE" label="启用" />
|
<el-option :value="COMPANY_STATUS_ACTIVE" label="启用" />
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, reactive, ref, watch } from 'vue'
|
import { computed, reactive, ref, watch } from 'vue'
|
||||||
import type { PlatformTabId } from '@/config/platform-scope'
|
|
||||||
import { submitCreateUser } from './user-create-adapter'
|
import { submitCreateUser } from './user-create-adapter'
|
||||||
import {
|
import {
|
||||||
createEmptyCreateUserForm,
|
createEmptyCreateUserForm,
|
||||||
defaultRoleChoice,
|
|
||||||
mayCarryOwnExpiry,
|
mayCarryOwnExpiry,
|
||||||
resolveRoleChoices,
|
|
||||||
type CreatableUserRole,
|
|
||||||
type CreateUserForm,
|
type CreateUserForm,
|
||||||
type CreateUserFormErrors,
|
type CreateUserFormErrors,
|
||||||
validateCreateUserForm,
|
validateCreateUserForm,
|
||||||
@@ -21,16 +17,10 @@ const props = defineProps<{
|
|||||||
operatorSuper?: boolean
|
operatorSuper?: boolean
|
||||||
/** 操作者角色(company_super_admin 也能建管理员/普通账号)。 */
|
/** 操作者角色(company_super_admin 也能建管理员/普通账号)。 */
|
||||||
operatorRole?: string | null
|
operatorRole?: string | null
|
||||||
/** 所属管理员候选(列表响应 admins;仅超管创建普通账号时展示,已按当前公司 tab 收窄)。 */
|
/** 所属管理员候选(列表响应 admins;仅超管创建普通账号时展示)。 */
|
||||||
adminOptions?: Array<{ id: number; username: string }>
|
adminOptions?: Array<{ id: number; username: string }>
|
||||||
/** 公司候选(站点超管创建公司超级管理员时必选)。 */
|
/** 公司候选(站点超管创建公司超级管理员时必选)。 */
|
||||||
companyOptions?: Array<{ id: number; companyName: string }>
|
companyOptions?: Array<{ id: number; companyName: string }>
|
||||||
/** 操作者自己那家公司(会话 current-user.companyId)。 */
|
|
||||||
operatorCompanyId?: number | null
|
|
||||||
/** 当前公司 tab:这次建号落在哪家,就决定能建哪些角色。 */
|
|
||||||
activeCompanyId?: number | null
|
|
||||||
/** 当前平台 tab(V206):新号默认落当前平台,单选可改。 */
|
|
||||||
platform?: PlatformTabId
|
|
||||||
}>()
|
}>()
|
||||||
const emit = defineEmits<{ (e: 'update:modelValue', v: boolean): void; (e: 'created'): void }>()
|
const emit = defineEmits<{ (e: 'update:modelValue', v: boolean): void; (e: 'created'): void }>()
|
||||||
|
|
||||||
@@ -40,42 +30,29 @@ const busy = ref(false)
|
|||||||
|
|
||||||
/** 角色下拉:站点超管可选公司超管/管理员/普通账号;公司超管只可选管理员/普通账号;
|
/** 角色下拉:站点超管可选公司超管/管理员/普通账号;公司超管只可选管理员/普通账号;
|
||||||
* 管理员不显示角色选择(后端强制 normal)。 */
|
* 管理员不显示角色选择(后端强制 normal)。 */
|
||||||
const ROLE_LABELS: Record<CreatableUserRole, string> = {
|
const ROLE_CHOICES: Array<{ value: 'company_super_admin' | 'admin' | 'normal'; label: string }> = [
|
||||||
company_super_admin: '公司超级管理员',
|
{ value: 'company_super_admin', label: '公司超级管理员' },
|
||||||
admin: '管理员',
|
{ value: 'admin', label: '管理员' },
|
||||||
normal: '普通账号',
|
{ value: 'normal', label: '普通账号' },
|
||||||
}
|
]
|
||||||
const canChooseRole = computed(() => props.operatorSuper || props.operatorRole === 'company_super_admin')
|
const canChooseRole = computed(() => props.operatorSuper || props.operatorRole === 'company_super_admin')
|
||||||
/** 可选角色集合的唯一来源是 user-create-model 那个纯函数(后端有同一口径的一条 403)。 */
|
const roleChoices = computed(() =>
|
||||||
const allowedRoles = computed<CreatableUserRole[]>(() =>
|
props.operatorSuper ? ROLE_CHOICES : ROLE_CHOICES.filter((opt) => opt.value !== 'company_super_admin'),
|
||||||
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))
|
const expiryEditable = computed(() => mayCarryOwnExpiry(form.role))
|
||||||
|
|
||||||
// 公司 tab 收窄了可选角色时,把残留的旧选择收敛回合法项(并清掉上一家的所属管理员):
|
|
||||||
// 留着它,用户看到的是一个已经不给选的选项,提交会被后端 403 打回。
|
|
||||||
watch(allowedRoles, (roles) => {
|
|
||||||
if (roles.includes(form.role)) return
|
|
||||||
form.role = defaultRoleChoice(roles)
|
|
||||||
form.createdBy = null
|
|
||||||
})
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.modelValue,
|
() => props.modelValue,
|
||||||
(open) => {
|
(open) => {
|
||||||
if (!open) return
|
if (!open) return
|
||||||
form.username = ''
|
form.username = ''
|
||||||
form.password = ''
|
form.password = ''
|
||||||
form.role = defaultRoleChoice(allowedRoles.value)
|
form.role = 'normal'
|
||||||
form.columnIds = []
|
form.columnIds = []
|
||||||
form.createdBy = null
|
form.createdBy = null
|
||||||
form.expiresAt = ''
|
form.expiresAt = ''
|
||||||
// 预填当前 tab:跨公司时角色本来就只剩公司超管,而那一例必须带公司
|
form.companyId = null
|
||||||
form.companyId = props.activeCompanyId ?? null
|
|
||||||
// 预填当前平台 tab(V206):京东侧建的号默认归京东,亚马逊侧默认亚马逊。
|
|
||||||
form.platform = props.platform ?? 'amazon'
|
|
||||||
errors.username = undefined
|
errors.username = undefined
|
||||||
errors.password = undefined
|
errors.password = undefined
|
||||||
errors.companyId = undefined
|
errors.companyId = undefined
|
||||||
@@ -136,12 +113,6 @@ async function create(): Promise<void> {
|
|||||||
<el-option v-for="opt in roleChoices" :key="opt.value" :label="opt.label" :value="opt.value" />
|
<el-option v-for="opt in roleChoices" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="所属平台">
|
|
||||||
<el-radio-group v-model="form.platform">
|
|
||||||
<el-radio-button value="amazon">亚马逊</el-radio-button>
|
|
||||||
<el-radio-button value="jd">京东</el-radio-button>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item
|
<el-form-item
|
||||||
v-if="operatorSuper && form.role === 'company_super_admin'"
|
v-if="operatorSuper && form.role === 'company_super_admin'"
|
||||||
label="所属公司"
|
label="所属公司"
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, reactive, ref, watch } from 'vue'
|
import { computed, reactive, ref, watch } from 'vue'
|
||||||
import type { AdminUser } from '@/types/admin'
|
import type { AdminUser } from '@/types/admin'
|
||||||
import type { PlatformTabId } from '@/config/platform-scope'
|
|
||||||
import { mayCarryOwnExpiry } from './user-create-model'
|
import { mayCarryOwnExpiry } from './user-create-model'
|
||||||
import { fillEditUserForm, validateEditUserForm, type EditUserForm, type EditUserFormErrors } from './user-edit-model'
|
import { fillEditUserForm, validateEditUserForm, type EditUserForm, type EditUserFormErrors } from './user-edit-model'
|
||||||
import { submitEditUser } from './user-edit-adapter'
|
import { submitEditUser } from './user-edit-adapter'
|
||||||
@@ -11,12 +10,11 @@ import { actionableErrorText } from '@/components/admin-feedback'
|
|||||||
import UserMenuAuthTree from './UserMenuAuthTree.vue'
|
import UserMenuAuthTree from './UserMenuAuthTree.vue'
|
||||||
|
|
||||||
/** companyId 由 UsersPage 把 companyTab.requestCompanyId 透传进来(本页的用户列表本来就由它筛 ⇒ 目标账号的公司
|
/** companyId 由 UsersPage 把 companyTab.requestCompanyId 透传进来(本页的用户列表本来就由它筛 ⇒ 目标账号的公司
|
||||||
* 就是 tab 选中的那家);弹窗自己不读 store,公司 tab 的取值口只留在页面组件那一处。
|
* 就是 tab 选中的那家);弹窗自己不读 store,公司 tab 的取值口只留在页面组件那一处。 */
|
||||||
* platform(V206)同理由页面透传:决定上架上限是否参与校验/下发(仅京东侧)。 */
|
const props = defineProps<{ modelValue: boolean; user: AdminUser | null; operatorSuper?: boolean; companyId?: number | null }>()
|
||||||
const props = defineProps<{ modelValue: boolean; user: AdminUser | null; operatorSuper?: boolean; companyId?: number | null; platform?: PlatformTabId }>()
|
|
||||||
const emit = defineEmits<{ (e: 'update:modelValue', v: boolean): void; (e: 'updated'): void }>()
|
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: '', expiresAt: '' })
|
||||||
const errors = reactive<EditUserFormErrors>({})
|
const errors = reactive<EditUserFormErrors>({})
|
||||||
const busy = ref(false)
|
const busy = ref(false)
|
||||||
const loadingAuth = ref(false)
|
const loadingAuth = ref(false)
|
||||||
@@ -24,9 +22,6 @@ const loadingAuth = ref(false)
|
|||||||
const authReady = ref(false)
|
const authReady = ref(false)
|
||||||
/** 公司超管目标:角色单选隐藏(请求体也不带 role),只允许改密码/到期时间/菜单。 */
|
/** 公司超管目标:角色单选隐藏(请求体也不带 role),只允许改密码/到期时间/菜单。 */
|
||||||
const targetIsCompanySuperAdmin = computed(() => (props.user?.role || '').trim().toLowerCase() === 'company_super_admin')
|
const targetIsCompanySuperAdmin = computed(() => (props.user?.role || '').trim().toLowerCase() === 'company_super_admin')
|
||||||
/** 上架上限只属京东口径(用户 2026-11-17:「只要在京东这边用户编辑里加就行,不需要在亚马逊那边」):
|
|
||||||
* 亚马逊侧隐藏该项,且校验与下发都不带 quota——字段留后端不动。 */
|
|
||||||
const includeQuota = computed(() => props.platform === 'jd')
|
|
||||||
/** 公司超管目标的角色单选是隐藏的(改完仍是 company_super_admin),到期时间照旧可改;
|
/** 公司超管目标的角色单选是隐藏的(改完仍是 company_super_admin),到期时间照旧可改;
|
||||||
* 管理员改成普通账号时这一项消失,保存按「清空」下发(见 user-edit-model 的 roleAfter)。 */
|
* 管理员改成普通账号时这一项消失,保存按「清空」下发(见 user-edit-model 的 roleAfter)。 */
|
||||||
const expiryEditable = computed(() =>
|
const expiryEditable = computed(() =>
|
||||||
@@ -45,9 +40,6 @@ watch(
|
|||||||
form.columnIds = []
|
form.columnIds = []
|
||||||
form.originalRole = base.originalRole
|
form.originalRole = base.originalRole
|
||||||
form.expiresAt = base.expiresAt
|
form.expiresAt = base.expiresAt
|
||||||
form.jdPublishQuota = base.jdPublishQuota
|
|
||||||
form.platform = base.platform
|
|
||||||
errors.jdPublishQuota = undefined
|
|
||||||
errors.password = undefined
|
errors.password = undefined
|
||||||
authReady.value = false
|
authReady.value = false
|
||||||
void refreshAuth()
|
void refreshAuth()
|
||||||
@@ -79,12 +71,12 @@ async function save(): Promise<void> {
|
|||||||
showAdminFeedback('菜单权限尚未加载完成,请稍后重试', 'error')
|
showAdminFeedback('菜单权限尚未加载完成,请稍后重试', 'error')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const { valid, errors: errs } = validateEditUserForm(form, { includeQuota: includeQuota.value })
|
const { valid, errors: errs } = validateEditUserForm(form)
|
||||||
Object.assign(errors, errs)
|
Object.assign(errors, errs)
|
||||||
if (!valid) return
|
if (!valid) return
|
||||||
busy.value = true
|
busy.value = true
|
||||||
try {
|
try {
|
||||||
await submitEditUser(form, { includeQuota: includeQuota.value })
|
await submitEditUser(form)
|
||||||
showAdminFeedback('更新成功', 'success')
|
showAdminFeedback('更新成功', 'success')
|
||||||
emit('updated')
|
emit('updated')
|
||||||
close()
|
close()
|
||||||
@@ -128,12 +120,6 @@ async function save(): Promise<void> {
|
|||||||
<el-form-item v-if="targetIsCompanySuperAdmin" label="角色">
|
<el-form-item v-if="targetIsCompanySuperAdmin" label="角色">
|
||||||
<el-input model-value="公司超级管理员" readonly />
|
<el-input model-value="公司超级管理员" readonly />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="所属平台">
|
|
||||||
<el-radio-group v-model="form.platform">
|
|
||||||
<el-radio-button value="amazon">亚马逊</el-radio-button>
|
|
||||||
<el-radio-button value="jd">京东</el-radio-button>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item v-if="expiryEditable" label="到期时间(清空 = 永不过期;到期后该账号及其名下账号将停用)">
|
<el-form-item v-if="expiryEditable" label="到期时间(清空 = 永不过期;到期后该账号及其名下账号将停用)">
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="form.expiresAt"
|
v-model="form.expiresAt"
|
||||||
@@ -144,9 +130,6 @@ async function save(): Promise<void> {
|
|||||||
style="width: 240px"
|
style="width: 240px"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</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-form-item v-if="props.user && props.user.creatorUsername" label="所属管理员">
|
||||||
<el-input :model-value="props.user.creatorUsername" readonly />
|
<el-input :model-value="props.user.creatorUsername" readonly />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, ref, watch } from 'vue'
|
import { computed, onMounted, ref, watch } from 'vue'
|
||||||
import type { AdminUser } from '@/types/admin'
|
import type { AdminUser } from '@/types/admin'
|
||||||
import type { PlatformTabId } from '@/config/platform-scope'
|
|
||||||
import {
|
import {
|
||||||
eligibleGroupMembers,
|
eligibleGroupMembers,
|
||||||
groupMemberCandidateHint,
|
groupMemberCandidateHint,
|
||||||
@@ -14,13 +13,11 @@ import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
|||||||
import { actionableErrorText } from '@/components/admin-feedback'
|
import { actionableErrorText } from '@/components/admin-feedback'
|
||||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
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 emit = defineEmits<{ (e: 'update:modelValue', v: boolean): void; (e: 'saved'): void }>()
|
||||||
|
|
||||||
const session = useAdminSessionStore()
|
const session = useAdminSessionStore()
|
||||||
const groupName = ref('')
|
const groupName = ref('')
|
||||||
/** 所属平台(V206):新建默认当前平台 tab,编辑回填分组原值,单选可翻档。 */
|
|
||||||
const groupPlatform = ref<PlatformTabId>('amazon')
|
|
||||||
const memberIds = ref<number[]>([])
|
const memberIds = ref<number[]>([])
|
||||||
const errorText = ref('')
|
const errorText = ref('')
|
||||||
const busy = ref(false)
|
const busy = ref(false)
|
||||||
@@ -51,9 +48,6 @@ watch(
|
|||||||
if (props.group) {
|
if (props.group) {
|
||||||
groupName.value = props.group.name
|
groupName.value = props.group.name
|
||||||
memberIds.value = props.group.memberUserIds ?? []
|
memberIds.value = props.group.memberUserIds ?? []
|
||||||
groupPlatform.value = props.group.platform === 'jd' ? 'jd' : 'amazon'
|
|
||||||
} else {
|
|
||||||
groupPlatform.value = props.platform ?? 'amazon'
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -61,10 +55,7 @@ watch(
|
|||||||
async function loadCandidates(): Promise<void> {
|
async function loadCandidates(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
// 对齐 admin.js loadUserOptions:page=1&page_size=999 全量拉取,避免归属过滤漏人。
|
// 对齐 admin.js loadUserOptions:page=1&page_size=999 全量拉取,避免归属过滤漏人。
|
||||||
// company_id 必带:不带时后端对站点超管返回全平台账号,别家公司的人就会出现在本公司分组的候选里。
|
const page = await fetchUserList({ page: 1, pageSize: 999 })
|
||||||
// 取的是**组长自己那家**(当前登录用户),不是公司 tab——新建时组长就是操作者本人,
|
|
||||||
// 按 tab 取人会在超管停在别家 tab 时列出那家的人,保存时被后端"只能添加组长本公司的账号"打回。
|
|
||||||
const page = await fetchUserList({ page: 1, pageSize: 999, companyId: session.user?.companyId ?? null })
|
|
||||||
users.value = page.items
|
users.value = page.items
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(actionableErrorText(error), 'error')
|
showAdminFeedback(actionableErrorText(error), 'error')
|
||||||
@@ -82,7 +73,7 @@ async function save(): Promise<void> {
|
|||||||
busy.value = true
|
busy.value = true
|
||||||
try {
|
try {
|
||||||
if (props.group) {
|
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')
|
showAdminFeedback('更新成功', 'success')
|
||||||
} else {
|
} else {
|
||||||
// 对齐 admin:组长恒为当前登录用户,提交 createdBy=当前用户 id。
|
// 对齐 admin:组长恒为当前登录用户,提交 createdBy=当前用户 id。
|
||||||
@@ -91,7 +82,7 @@ async function save(): Promise<void> {
|
|||||||
showAdminFeedback('无法获取当前登录用户,请重新登录', 'error')
|
showAdminFeedback('无法获取当前登录用户,请重新登录', 'error')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await createShopGroup(groupName.value, memberIds.value, operatorId, groupPlatform.value)
|
await createShopGroup(groupName.value, memberIds.value, operatorId)
|
||||||
showAdminFeedback('创建成功', 'success')
|
showAdminFeedback('创建成功', 'success')
|
||||||
}
|
}
|
||||||
emit('saved')
|
emit('saved')
|
||||||
@@ -119,12 +110,6 @@ onMounted(loadCandidates)
|
|||||||
<el-form-item label="分组名称" :error="errorText || undefined">
|
<el-form-item label="分组名称" :error="errorText || undefined">
|
||||||
<el-input v-model="groupName" placeholder="请输入分组名称" />
|
<el-input v-model="groupName" placeholder="请输入分组名称" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="所属平台">
|
|
||||||
<el-radio-group v-model="groupPlatform">
|
|
||||||
<el-radio-button value="amazon">亚马逊</el-radio-button>
|
|
||||||
<el-radio-button value="jd">京东</el-radio-button>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="组长">
|
<el-form-item label="组长">
|
||||||
<el-input :model-value="leaderUsername" readonly placeholder="当前登录用户" />
|
<el-input :model-value="leaderUsername" readonly placeholder="当前登录用户" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|||||||
@@ -6,21 +6,15 @@ import { computed, onMounted, ref, watch } from 'vue'
|
|||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||||
import { usePlatformTabStore } from '@/stores/platform-tab'
|
|
||||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||||
import { deleteShopGroup, fetchShopGroups } from './shop-group-api'
|
import { deleteShopGroup, fetchShopGroups } from './shop-group-api'
|
||||||
import type { ShopGroupItem } from './shop-group-model'
|
import type { ShopGroupItem } from './shop-group-model'
|
||||||
import GroupEditorDialog from './GroupEditorDialog.vue'
|
import GroupEditorDialog from './GroupEditorDialog.vue'
|
||||||
import OldPagination from '@/components/OldPagination.vue'
|
import OldPagination from '@/components/OldPagination.vue'
|
||||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
|
||||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
|
||||||
|
|
||||||
const session = useAdminSessionStore()
|
const session = useAdminSessionStore()
|
||||||
const companyTab = useCompanyTabStore()
|
const companyTab = useCompanyTabStore()
|
||||||
// 平台 tab(V206):分组列表按当前平台过滤,新建默认落当前平台。
|
|
||||||
const platformTab = usePlatformTabStore()
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const loadFailure = ref('')
|
|
||||||
const rows = ref<ShopGroupItem[]>([])
|
const rows = ref<ShopGroupItem[]>([])
|
||||||
const editorVisible = ref(false)
|
const editorVisible = ref(false)
|
||||||
const editingGroup = ref<ShopGroupItem | null>(null)
|
const editingGroup = ref<ShopGroupItem | null>(null)
|
||||||
@@ -53,12 +47,10 @@ function canEditOf(group: ShopGroupItem): boolean {
|
|||||||
|
|
||||||
async function loadGroups() {
|
async function loadGroups() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
try {
|
||||||
rows.value = await fetchShopGroups(companyTab.requestCompanyId, platformTab.active)
|
rows.value = await fetchShopGroups(companyTab.requestCompanyId)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loadFailure.value = error instanceof Error ? error.message : '数据权限分组加载失败'
|
ElMessage.error(error instanceof Error ? error.message : '数据权限分组加载失败')
|
||||||
showAdminFeedback(loadFailure.value, 'error')
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
@@ -67,12 +59,6 @@ async function loadGroups() {
|
|||||||
// 切公司 = 重新取数(G1 的 pageFiles 断言盯着这一条)。
|
// 切公司 = 重新取数(G1 的 pageFiles 断言盯着这一条)。
|
||||||
watch(() => companyTab.activeId, () => void loadGroups())
|
watch(() => companyTab.activeId, () => void loadGroups())
|
||||||
|
|
||||||
// 切平台 tab(V206)= 重新取数:分组归属按平台分列,两 tab 各看各的分组。
|
|
||||||
watch(() => platformTab.active, () => {
|
|
||||||
page.value = 1
|
|
||||||
void loadGroups()
|
|
||||||
})
|
|
||||||
|
|
||||||
function openCreate() {
|
function openCreate() {
|
||||||
editingGroup.value = null
|
editingGroup.value = null
|
||||||
editorVisible.value = true
|
editorVisible.value = true
|
||||||
@@ -92,7 +78,7 @@ async function removeGroup(group: ShopGroupItem) {
|
|||||||
ElMessage.success('删除成功')
|
ElMessage.success('删除成功')
|
||||||
await loadGroups()
|
await loadGroups()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +104,6 @@ onMounted(loadGroups)
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="loadGroups" />
|
|
||||||
<div class="table-scroll">
|
<div class="table-scroll">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -173,7 +158,6 @@ onMounted(loadGroups)
|
|||||||
v-model="editorVisible"
|
v-model="editorVisible"
|
||||||
:group="editingGroup"
|
:group="editingGroup"
|
||||||
:operator-super="isSuperAdmin"
|
:operator-super="isSuperAdmin"
|
||||||
:platform="platformTab.active"
|
|
||||||
@saved="loadGroups"
|
@saved="loadGroups"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -371,7 +355,6 @@ h3 {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-tip {
|
.empty-tip {
|
||||||
|
|||||||
@@ -7,9 +7,6 @@ import { ElMessage, ElMessageBox } from 'element-plus'
|
|||||||
import OldPagination from '@/components/OldPagination.vue'
|
import OldPagination from '@/components/OldPagination.vue'
|
||||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||||
import { createMenu, deleteMenu, loadMenuManageTree, reorderMenus, updateMenu } from './menu-manage-api'
|
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 {
|
import {
|
||||||
MENU_TYPE_OPTIONS,
|
MENU_TYPE_OPTIONS,
|
||||||
createMenuForm,
|
createMenuForm,
|
||||||
@@ -34,7 +31,6 @@ interface MenuRow extends MenuManageNode {
|
|||||||
|
|
||||||
const companyTab = useCompanyTabStore()
|
const companyTab = useCompanyTabStore()
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const loadFailure = ref('')
|
|
||||||
const rows = ref<MenuManageNode[]>([])
|
const rows = ref<MenuManageNode[]>([])
|
||||||
/** 筛选:菜单名称/类型(用户要求账户域子菜单补筛选条件)。 */
|
/** 筛选:菜单名称/类型(用户要求账户域子菜单补筛选条件)。 */
|
||||||
const filterName = ref('')
|
const filterName = ref('')
|
||||||
@@ -89,12 +85,10 @@ function parentNameOf(node: MenuManageNode): string {
|
|||||||
|
|
||||||
async function loadMenus() {
|
async function loadMenus() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
try {
|
||||||
rows.value = await loadMenuManageTree(companyTab.requestCompanyId)
|
rows.value = await loadMenuManageTree(companyTab.requestCompanyId)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loadFailure.value = error instanceof Error ? error.message : '菜单列表加载失败'
|
ElMessage.error(error instanceof Error ? error.message : '菜单列表加载失败')
|
||||||
showAdminFeedback(loadFailure.value, 'error')
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
@@ -160,7 +154,7 @@ async function onDrop(event: DragEvent, target: MenuManageNode): Promise<void> {
|
|||||||
ElMessage.success('排序已保存')
|
ElMessage.success('排序已保存')
|
||||||
await loadMenus()
|
await loadMenus()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '排序保存失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '排序保存失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +183,7 @@ async function saveMenu() {
|
|||||||
createVisible.value = false
|
createVisible.value = false
|
||||||
await loadMenus()
|
await loadMenus()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '保存失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '保存失败')
|
||||||
} finally {
|
} finally {
|
||||||
saving.value = false
|
saving.value = false
|
||||||
}
|
}
|
||||||
@@ -202,13 +196,13 @@ async function removeMenu(node: MenuManageNode) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 对齐旧版:原生 confirm。
|
// 对齐旧版:原生 confirm。
|
||||||
if (!(await openAdminConfirm({ message: `确定删除菜单“${node.name}”吗?`, danger: true }))) return
|
if (!window.confirm(`确定删除菜单“${node.name}”吗?`)) return
|
||||||
try {
|
try {
|
||||||
await deleteMenu(node.id)
|
await deleteMenu(node.id)
|
||||||
ElMessage.success('删除成功')
|
ElMessage.success('删除成功')
|
||||||
await loadMenus()
|
await loadMenus()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +238,6 @@ onMounted(loadMenus)
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="loadMenus" />
|
|
||||||
<div class="table-scroll columns-table-scroll">
|
<div class="table-scroll columns-table-scroll">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -545,7 +538,6 @@ tr.is-column-dragging td {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-tip {
|
.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,8 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, ref, watch } from 'vue'
|
import { computed, onMounted, ref, watch } from 'vue'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
import OldPagination from '@/components/OldPagination.vue'
|
import OldPagination from '@/components/OldPagination.vue'
|
||||||
import { orderedPair, todayDateInput } from '@/utils/datetime'
|
import { todayDateInput } from '@/utils/datetime'
|
||||||
import {
|
import {
|
||||||
fetchUserSecretUsage,
|
fetchUserSecretUsage,
|
||||||
type AdminUserSecretUsageRow,
|
type AdminUserSecretUsageRow,
|
||||||
@@ -10,8 +10,6 @@ import {
|
|||||||
import type { GroupOption } from '@/api/user-secrets'
|
import type { GroupOption } from '@/api/user-secrets'
|
||||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
|
||||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
|
||||||
|
|
||||||
const session = useAdminSessionStore()
|
const session = useAdminSessionStore()
|
||||||
const companyTab = useCompanyTabStore()
|
const companyTab = useCompanyTabStore()
|
||||||
@@ -19,7 +17,6 @@ const companyTab = useCompanyTabStore()
|
|||||||
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const loadFailure = ref('')
|
|
||||||
const rows = ref<AdminUserSecretUsageRow[]>([])
|
const rows = ref<AdminUserSecretUsageRow[]>([])
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
const page = ref(1)
|
const page = ref(1)
|
||||||
@@ -27,13 +24,6 @@ const pageSize = ref(15)
|
|||||||
const keyword = ref('')
|
const keyword = ref('')
|
||||||
const startDate = ref(todayDateInput())
|
const startDate = ref(todayDateInput())
|
||||||
const endDate = 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 groupFilter = ref<number | null>(null)
|
||||||
const groupOptions = ref<GroupOption[]>([])
|
const groupOptions = ref<GroupOption[]>([])
|
||||||
|
|
||||||
@@ -49,7 +39,6 @@ function formatCount(value: number | undefined) {
|
|||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
try {
|
||||||
const result = await fetchUserSecretUsage({
|
const result = await fetchUserSecretUsage({
|
||||||
startDate: startDate.value || undefined,
|
startDate: startDate.value || undefined,
|
||||||
@@ -70,8 +59,7 @@ async function load() {
|
|||||||
proxyCalls: Number(result?.proxyCalls || 0),
|
proxyCalls: Number(result?.proxyCalls || 0),
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loadFailure.value = error instanceof Error ? error.message : '加载失败'
|
ElMessage.error(error instanceof Error ? error.message : '加载失败')
|
||||||
showAdminFeedback(loadFailure.value, 'error')
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
@@ -139,11 +127,11 @@ onMounted(load)
|
|||||||
<div class="form-row usage-filter-row">
|
<div class="form-row usage-filter-row">
|
||||||
<div class="form-group" style="min-width: 160px">
|
<div class="form-group" style="min-width: 160px">
|
||||||
<label>开始日期</label>
|
<label>开始日期</label>
|
||||||
<input v-model="startDate" type="date" :max="endDate" @change="clampDatePair" />
|
<input v-model="startDate" type="date" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" style="min-width: 160px">
|
<div class="form-group" style="min-width: 160px">
|
||||||
<label>结束日期</label>
|
<label>结束日期</label>
|
||||||
<input v-model="endDate" type="date" :min="startDate" @change="clampDatePair" />
|
<input v-model="endDate" type="date" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" style="min-width: 200px">
|
<div class="form-group" style="min-width: 200px">
|
||||||
<label>用户名</label>
|
<label>用户名</label>
|
||||||
@@ -165,7 +153,6 @@ onMounted(load)
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
|
||||||
<div class="usage-table-scroll">
|
<div class="usage-table-scroll">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -3,34 +3,18 @@ import { computed, onMounted, ref, watch } from 'vue'
|
|||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { formatDateTime } from '@/utils/datetime'
|
import { formatDateTime } from '@/utils/datetime'
|
||||||
import OldPagination from '@/components/OldPagination.vue'
|
import OldPagination from '@/components/OldPagination.vue'
|
||||||
import ProxyEntryDialog from './ProxyEntryDialog.vue'
|
|
||||||
import {
|
import {
|
||||||
checkUserSecret,
|
checkUserSecret,
|
||||||
clearUserSecretModule,
|
clearUserSecretModule,
|
||||||
deleteUserSecret,
|
deleteUserSecret,
|
||||||
fetchAdminSecretBalances,
|
|
||||||
fetchUserSecretList,
|
fetchUserSecretList,
|
||||||
type AdminUserSecretBalanceItem,
|
saveUserSecretModule,
|
||||||
type AdminUserSecretModule,
|
type AdminUserSecretModule,
|
||||||
type AdminUserSecretRow,
|
type AdminUserSecretRow,
|
||||||
type GroupOption,
|
type GroupOption,
|
||||||
} from '@/api/user-secrets'
|
} 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 { useAdminSessionStore } from '@/stores/admin-session'
|
||||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
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 session = useAdminSessionStore()
|
||||||
const companyTab = useCompanyTabStore()
|
const companyTab = useCompanyTabStore()
|
||||||
@@ -38,7 +22,6 @@ const companyTab = useCompanyTabStore()
|
|||||||
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const loadFailure = ref('')
|
|
||||||
const rows = ref<AdminUserSecretRow[]>([])
|
const rows = ref<AdminUserSecretRow[]>([])
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
const page = ref(1)
|
const page = ref(1)
|
||||||
@@ -50,18 +33,8 @@ const groupFilter = ref<number | null>(null)
|
|||||||
const groupOptions = ref<GroupOption[]>([])
|
const groupOptions = ref<GroupOption[]>([])
|
||||||
/** 正在检测的行 userId,用于按钮 loading 态。 */
|
/** 正在检测的行 userId,用于按钮 loading 态。 */
|
||||||
const checkingId = ref<number | null>(null)
|
const checkingId = ref<number | null>(null)
|
||||||
/** 正在解锁代理的行 userId,避免重复点击(代填在弹窗里自己管 busy)。 */
|
/** 正在代填/解锁代理的行 userId,避免重复点击。 */
|
||||||
const proxyBusyId = ref<number | null>(null)
|
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)))
|
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||||
|
|
||||||
@@ -70,44 +43,58 @@ const STATUS_OPTIONS = [
|
|||||||
{ value: 'passed', label: '检测通过' },
|
{ value: 'passed', label: '检测通过' },
|
||||||
{ value: 'failed', label: '检测失败' },
|
{ value: 'failed', label: '检测失败' },
|
||||||
{ value: 'incomplete', label: '未配齐' },
|
{ value: 'incomplete', label: '未配齐' },
|
||||||
// 后端的行级值仍是 error:这一档现在既可能是「问不出结论」,也可能是「通道还没释放、等一会再点」,
|
{ value: 'error', label: '无法判定' },
|
||||||
// 界面按码把后者补成「可重试」(见 user-secret-model.ts 的档位表),筛选项就得把两档都点名。
|
|
||||||
{ value: 'error', label: '无法判定/可重试' },
|
|
||||||
{ value: 'unknown', label: '未检测' },
|
{ value: 'unknown', label: '未检测' },
|
||||||
]
|
]
|
||||||
|
|
||||||
/* 状态药丸的档位表在 `user-secret-model.ts`(唯一出处,页面不带第二张表):
|
/** 行级状态药丸:三类都检测通过才显示「检测通过」。 */
|
||||||
行级传整行而不是 `row.status`——后端把 failed/incomplete 都判掉之后就只剩一个「error」,
|
function rowStatusMeta(status: string) {
|
||||||
这一行到底是「查不出」还是「等青果释放」只有逐格的 `check_code` 说得清。 */
|
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`** + 检测时间 + 耗时。
|
function moduleStatusMeta(module: AdminUserSecretModule | undefined) {
|
||||||
* 运维要判「是欠费还是被自己的采集占着」,靠的就是这句后端原文——档名只是扫一眼用的短词,
|
if (!module || !module.exists) {
|
||||||
* 前端一律不按码自己拼句子。
|
return { label: '未配置', tone: 'is-unknown' }
|
||||||
* ⚠ 只读 `masked`:`full` 在后台侧恒空(2026-11-02 `SecretMasking.maskProxy` 收口),
|
}
|
||||||
* 这里不做任何「masked 空就回落原文」的兜底,也不给复制整条链接的旁路。
|
switch (module.checkStatus) {
|
||||||
*/
|
case 'passed':
|
||||||
|
return { label: '通过', tone: 'is-allowed' }
|
||||||
|
case 'failed':
|
||||||
|
if (module.checkCode === 'insufficient_balance') {
|
||||||
|
return { label: '欠费', tone: 'is-warn' }
|
||||||
|
}
|
||||||
|
return { label: '失败', tone: 'is-blocked' }
|
||||||
|
case 'error':
|
||||||
|
return { label: '无法判定', tone: 'is-warn' }
|
||||||
|
default:
|
||||||
|
return { label: '未检测', tone: 'is-unknown' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 单格悬停详情:完整值(代理为全量地址)+ 锁定说明 + 检测消息 + 检测时间 + 耗时。 */
|
||||||
function moduleTooltip(module: AdminUserSecretModule | undefined) {
|
function moduleTooltip(module: AdminUserSecretModule | undefined) {
|
||||||
if (!module || !module.exists) return '未配置'
|
if (!module || !module.exists) return '未配置'
|
||||||
const parts: string[] = []
|
const parts: string[] = []
|
||||||
const display = String(module.masked || '').trim()
|
if (module.full) parts.push(module.full)
|
||||||
if (display) {
|
if (module.locked) parts.push('已由后台代填并锁定:客户端不可修改或清空')
|
||||||
parts.push(isProxyModule(module) ? `代理地址(已脱敏,不含 key/pwd):${display}` : `密钥:${display}`)
|
if (module.checkMessage) parts.push(module.checkMessage)
|
||||||
}
|
|
||||||
if (module.locked) parts.push('已由后台代填并锁定:客户端不可修改或清空,改代理需重新填写账密')
|
|
||||||
// 后端的这句话就是给人看的结论,原样透出(不动一个字、不按码另拼一句)
|
|
||||||
const message = String(module.checkMessage || '').trim()
|
|
||||||
if (message) parts.push(message)
|
|
||||||
if (module.checkedAt) parts.push(`检测时间:${formatDateTime(module.checkedAt)}`)
|
if (module.checkedAt) parts.push(`检测时间:${formatDateTime(module.checkedAt)}`)
|
||||||
if (module.checkLatencyMs != null) parts.push(`耗时:${module.checkLatencyMs}ms`)
|
if (module.checkLatencyMs != null) parts.push(`耗时:${module.checkLatencyMs}ms`)
|
||||||
return parts.join(';') || '暂无检测记录'
|
return parts.join(';') || '暂无检测记录'
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 该格是不是代理模块:按后端下发的 moduleKey 判,货源标签与文案都走这一条口径。 */
|
|
||||||
function isProxyModule(module: AdminUserSecretModule) {
|
|
||||||
return String(module.moduleKey || '').trim().toLowerCase() === PROXY_MODULE_KEY
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 分组列文案:优先分组名;未建分组的用户回退展示所属主管,便于判断归属。 */
|
/** 分组列文案:优先分组名;未建分组的用户回退展示所属主管,便于判断归属。 */
|
||||||
function groupTextOf(row: AdminUserSecretRow) {
|
function groupTextOf(row: AdminUserSecretRow) {
|
||||||
if (row.groups?.length) return row.groups.join('、')
|
if (row.groups?.length) return row.groups.join('、')
|
||||||
@@ -115,22 +102,15 @@ function groupTextOf(row: AdminUserSecretRow) {
|
|||||||
return '—'
|
return '—'
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 行级悬停详情:后端的行级摘要 + 逐格的 `check_message` 原文 + 更新时间。
|
|
||||||
* 行级状态一旦补成「可重试」,管理员得能立刻看出是哪一格在等、后端原话怎么说;
|
|
||||||
* 逐格那句一律取后端下发文本(`rowDetailLines` 只搬运、不改写、不另拼一句)。
|
|
||||||
*/
|
|
||||||
function rowStatusTooltip(row: AdminUserSecretRow) {
|
function rowStatusTooltip(row: AdminUserSecretRow) {
|
||||||
const parts: string[] = []
|
const parts: string[] = []
|
||||||
if (row.statusMessage) parts.push(row.statusMessage)
|
if (row.statusMessage) parts.push(row.statusMessage)
|
||||||
parts.push(...rowDetailLines(row))
|
|
||||||
if (row.updatedAt) parts.push(`最近更新:${formatDateTime(row.updatedAt)}`)
|
if (row.updatedAt) parts.push(`最近更新:${formatDateTime(row.updatedAt)}`)
|
||||||
return parts.join(';') || '暂无检测记录'
|
return parts.join(';') || '暂无检测记录'
|
||||||
}
|
}
|
||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
try {
|
||||||
const result = await fetchUserSecretList({
|
const result = await fetchUserSecretList({
|
||||||
keyword: keyword.value.trim() || undefined,
|
keyword: keyword.value.trim() || undefined,
|
||||||
@@ -143,66 +123,13 @@ async function load() {
|
|||||||
rows.value = result?.items || []
|
rows.value = result?.items || []
|
||||||
total.value = Number(result?.total || 0)
|
total.value = Number(result?.total || 0)
|
||||||
groupOptions.value = result?.groupOptions || []
|
groupOptions.value = result?.groupOptions || []
|
||||||
void loadBalances()
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loadFailure.value = error instanceof Error ? error.message : '加载失败'
|
ElMessage.error(error instanceof Error ? error.message : '加载失败')
|
||||||
showAdminFeedback(loadFailure.value, 'error')
|
|
||||||
} finally {
|
} finally {
|
||||||
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 断言盯着这条)。
|
// 切公司 = 重新取数。不重取的页 = tab 在那页上是假的(G1 的 pageFiles 断言盯着这条)。
|
||||||
watch(() => companyTab.activeId, () => void load())
|
watch(() => companyTab.activeId, () => void load())
|
||||||
|
|
||||||
@@ -232,16 +159,14 @@ async function check(row: AdminUserSecretRow) {
|
|||||||
if (failed.length) {
|
if (failed.length) {
|
||||||
ElMessage.warning(failed[0].checkMessage || '存在检测失败项')
|
ElMessage.warning(failed[0].checkMessage || '存在检测失败项')
|
||||||
} else if (errors.length) {
|
} else if (errors.length) {
|
||||||
// 后端这句话会区分「通道被你自己占着,等约 3 分钟」与「真的问不出结论」;
|
ElMessage.warning('部分配置本次无法判定')
|
||||||
// 硬写「无法判定」等于把可重试那一族又抹回一坨(现网 uid=1 就是这个形状)。
|
|
||||||
ElMessage.warning(errors[0].checkMessage || '部分配置本次无法判定')
|
|
||||||
} else {
|
} else {
|
||||||
ElMessage.success('检测通过')
|
ElMessage.success('检测通过')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
load()
|
load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '检测失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '检测失败')
|
||||||
} finally {
|
} finally {
|
||||||
checkingId.value = null
|
checkingId.value = null
|
||||||
}
|
}
|
||||||
@@ -249,47 +174,52 @@ async function check(row: AdminUserSecretRow) {
|
|||||||
|
|
||||||
async function remove(row: AdminUserSecretRow) {
|
async function remove(row: AdminUserSecretRow) {
|
||||||
const who = row.username || `UID ${row.userId}`
|
const who = row.username || `UID ${row.userId}`
|
||||||
if (!(await openAdminConfirm({ message: `确定清空「${who}」的全部密钥与代理配置吗?后台锁定的代理会一并清除并解锁,该用户需要重新配置。`, danger: true }))) return
|
if (!window.confirm(`确定清空「${who}」的全部密钥与代理配置吗?后台锁定的代理会一并清除并解锁,该用户需要重新配置。`)) return
|
||||||
try {
|
try {
|
||||||
await deleteUserSecret(row.userId)
|
await deleteUserSecret(row.userId)
|
||||||
ElMessage.success('已清空')
|
ElMessage.success('已清空')
|
||||||
load()
|
load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '清空失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '清空失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 代填并锁定代理:写入后客户端只能查看,修改/清空会被服务端拒绝。 */
|
||||||
* 打开代填/改代理弹窗。
|
async function fillProxy(row: AdminUserSecretRow) {
|
||||||
* ⚠ 不预填任何已有值:后台侧 `full` 恒空(代理链接里带着 key/pwd,2026-11-02 收口后不再下发),
|
const who = row.username || `UID ${row.userId}`
|
||||||
* 所以这一单的语义就是「重新填账密」,界面上也没有把原文取回来的旁路。
|
const value = window.prompt(
|
||||||
*/
|
`代填「${who}」的代理地址(保存后客户端不可修改或清空,如需变更先解锁):`,
|
||||||
function openProxyDialog(row: AdminUserSecretRow) {
|
row.proxy?.full || '',
|
||||||
proxyDialog.value = {
|
)
|
||||||
userId: row.userId,
|
if (value == null) return
|
||||||
username: row.username || `UID ${row.userId}`,
|
const trimmed = value.trim()
|
||||||
provider: row.proxy?.channel ?? null,
|
if (!trimmed) {
|
||||||
locked: Boolean(row.proxy?.locked),
|
ElMessage.warning('代理地址不能为空')
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
proxyBusyId.value = row.userId
|
||||||
|
try {
|
||||||
/** 弹窗保存成功:关掉并重新取数(列表只拿脱敏值,不参与拼装)。 */
|
await saveUserSecretModule(row.userId, 'proxy', trimmed)
|
||||||
function onProxySaved() {
|
ElMessage.success(row.proxy?.locked ? '已更新锁定代理' : '已代填并锁定代理')
|
||||||
proxyDialog.value = null
|
|
||||||
load()
|
load()
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error(error instanceof Error ? error.message : '代填失败')
|
||||||
|
} finally {
|
||||||
|
proxyBusyId.value = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 解锁代理:清空后台代填值,该用户恢复自行配置。 */
|
/** 解锁代理:清空后台代填值,该用户恢复自行配置。 */
|
||||||
async function unlockProxy(row: AdminUserSecretRow) {
|
async function unlockProxy(row: AdminUserSecretRow) {
|
||||||
const who = row.username || `UID ${row.userId}`
|
const who = row.username || `UID ${row.userId}`
|
||||||
if (!(await openAdminConfirm({ message: `确定解除「${who}」的代理锁定吗?解锁后当前后台代理值会被清空,客户端恢复自行配置。`, danger: true }))) return
|
if (!window.confirm(`确定解除「${who}」的代理锁定吗?解锁后当前后台代理值会被清空,客户端恢复自行配置。`)) return
|
||||||
proxyBusyId.value = row.userId
|
proxyBusyId.value = row.userId
|
||||||
try {
|
try {
|
||||||
await clearUserSecretModule(row.userId, PROXY_MODULE_KEY)
|
await clearUserSecretModule(row.userId, 'proxy')
|
||||||
ElMessage.success('已解锁')
|
ElMessage.success('已解锁')
|
||||||
load()
|
load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '解锁失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '解锁失败')
|
||||||
} finally {
|
} finally {
|
||||||
proxyBusyId.value = null
|
proxyBusyId.value = null
|
||||||
}
|
}
|
||||||
@@ -340,20 +270,10 @@ onMounted(load)
|
|||||||
<div class="filter-actions">
|
<div class="filter-actions">
|
||||||
<button class="btn" type="button" @click="search">查询</button>
|
<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" @click="reset">重置</button>
|
||||||
<button
|
|
||||||
class="btn btn-ghost"
|
|
||||||
type="button"
|
|
||||||
:disabled="balanceLoading || !rows.length"
|
|
||||||
:title="balanceNotice || '余额是实时查上游、不落库;这两列没取到时显示 —,不是 0'"
|
|
||||||
@click="loadBalances"
|
|
||||||
>
|
|
||||||
{{ balanceLoading ? '余额查询中…' : '刷新余额' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
|
||||||
<div class="secrets-table-scroll">
|
<div class="secrets-table-scroll">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -363,13 +283,11 @@ onMounted(load)
|
|||||||
<th v-if="isSuperAdmin" style="width: 130px">分组</th>
|
<th v-if="isSuperAdmin" style="width: 130px">分组</th>
|
||||||
<th style="width: 230px">货源查询密钥</th>
|
<th style="width: 230px">货源查询密钥</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: 380px">代理设置</th>
|
||||||
<th style="width: 160px">代理余量</th>
|
|
||||||
<th style="width: 130px">状态</th>
|
<th style="width: 130px">状态</th>
|
||||||
<th style="width: 170px">创建时间</th>
|
<th style="width: 170px">创建时间</th>
|
||||||
<th style="width: 170px">更新时间</th>
|
<th style="width: 170px">更新时间</th>
|
||||||
<th style="width: 315px">操作</th>
|
<th style="width: 250px">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -386,11 +304,8 @@ onMounted(load)
|
|||||||
<div class="module-cell">
|
<div class="module-cell">
|
||||||
<span v-if="row.similarAsin?.exists" class="mono-mask" :title="moduleTooltip(row.similarAsin)">{{ row.similarAsin.masked }}</span>
|
<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-else class="empty-value">未配置</span>
|
||||||
<span v-if="row.similarAsin?.exists" class="wh-pill is-source" title="该用户这把密钥所属渠道">
|
<span class="wh-pill" :class="moduleStatusMeta(row.similarAsin).tone" :title="moduleTooltip(row.similarAsin)">
|
||||||
{{ llmSourceLabel(row.similarAsin.channel) }}
|
{{ moduleStatusMeta(row.similarAsin).label }}
|
||||||
</span>
|
|
||||||
<span class="wh-pill" :class="moduleStatusBand(row.similarAsin).tone" :title="moduleTooltip(row.similarAsin)">
|
|
||||||
{{ moduleStatusBand(row.similarAsin).label }}
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@@ -398,34 +313,18 @@ onMounted(load)
|
|||||||
<div class="module-cell">
|
<div class="module-cell">
|
||||||
<span v-if="row.appearancePatent?.exists" class="mono-mask" :title="moduleTooltip(row.appearancePatent)">{{ row.appearancePatent.masked }}</span>
|
<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-else class="empty-value">未配置</span>
|
||||||
<span v-if="row.appearancePatent?.exists" class="wh-pill is-source" title="该用户这把密钥所属渠道">
|
<span class="wh-pill" :class="moduleStatusMeta(row.appearancePatent).tone" :title="moduleTooltip(row.appearancePatent)">
|
||||||
{{ llmSourceLabel(row.appearancePatent.channel) }}
|
{{ moduleStatusMeta(row.appearancePatent).label }}
|
||||||
</span>
|
|
||||||
<span class="wh-pill" :class="moduleStatusBand(row.appearancePatent).tone" :title="moduleTooltip(row.appearancePatent)">
|
|
||||||
{{ moduleStatusBand(row.appearancePatent).label }}
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="module-cell module-cell--stack">
|
<div class="module-cell module-cell--stack">
|
||||||
<span
|
<span v-if="row.proxy?.exists" class="mono-mask mono-full" :title="moduleTooltip(row.proxy)">{{ row.proxy.full || row.proxy.masked }}</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>
|
|
||||||
<span v-else class="empty-value">未配置</span>
|
<span v-else class="empty-value">未配置</span>
|
||||||
<span class="module-cell-pills">
|
<span class="module-cell-pills">
|
||||||
<span v-if="row.proxy?.exists" class="wh-pill is-source" title="该用户代理所属供应商">
|
<span class="wh-pill" :class="moduleStatusMeta(row.proxy).tone" :title="moduleTooltip(row.proxy)">
|
||||||
{{ proxySourceLabel(row.proxy.channel) }}
|
{{ moduleStatusMeta(row.proxy).label }}
|
||||||
</span>
|
|
||||||
<span class="wh-pill" :class="moduleStatusBand(row.proxy).tone" :title="moduleTooltip(row.proxy)">
|
|
||||||
{{ moduleStatusBand(row.proxy).label }}
|
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
v-if="row.proxy?.locked"
|
v-if="row.proxy?.locked"
|
||||||
@@ -438,15 +337,8 @@ onMounted(load)
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="module-cell module-cell--stack">
|
<span class="wh-pill" :class="rowStatusMeta(row.status).tone" :title="rowStatusTooltip(row)">
|
||||||
<span class="balance-line" :title="proxyLineOf(row.userId).title">
|
{{ rowStatusMeta(row.status).label }}
|
||||||
{{ proxyLineOf(row.userId).text }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<span class="wh-pill" :class="rowStatusBand(row).tone" :title="rowStatusTooltip(row)">
|
|
||||||
{{ rowStatusBand(row).label }}
|
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>{{ formatDateTime(row.createdAt) }}</td>
|
<td>{{ formatDateTime(row.createdAt) }}</td>
|
||||||
@@ -463,7 +355,8 @@ onMounted(load)
|
|||||||
<button
|
<button
|
||||||
class="btn btn-sm btn-ghost"
|
class="btn btn-sm btn-ghost"
|
||||||
type="button"
|
type="button"
|
||||||
@click="openProxyDialog(row)"
|
:disabled="proxyBusyId === row.userId"
|
||||||
|
@click="fillProxy(row)"
|
||||||
>
|
>
|
||||||
{{ row.proxy?.locked ? '改代理' : '代填代理' }}
|
{{ row.proxy?.locked ? '改代理' : '代填代理' }}
|
||||||
</button>
|
</button>
|
||||||
@@ -481,26 +374,16 @@ onMounted(load)
|
|||||||
</tr>
|
</tr>
|
||||||
</template>
|
</template>
|
||||||
<tr v-else-if="loading">
|
<tr v-else-if="loading">
|
||||||
<td :colspan="isSuperAdmin ? 12 : 11" class="empty-tip">加载中...</td>
|
<td :colspan="isSuperAdmin ? 10 : 9" class="empty-tip">加载中...</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-else>
|
<tr v-else>
|
||||||
<td :colspan="isSuperAdmin ? 12 : 11" class="empty-tip">{{ keyword || statusFilter || groupFilter ? '暂无匹配记录' : '暂无用户密钥记录' }}</td>
|
<td :colspan="isSuperAdmin ? 10 : 9" class="empty-tip">{{ keyword || statusFilter || groupFilter ? '暂无匹配记录' : '暂无用户密钥记录' }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<OldPagination :total="total" :page="page" :page-size="pageSize" @change="changePage" @size-change="changeSize" />
|
<OldPagination :total="total" :page="page" :page-size="pageSize" @change="changePage" @size-change="changeSize" />
|
||||||
</section>
|
</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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -686,7 +569,7 @@ h3 {
|
|||||||
gap: 8px;
|
gap: 8px;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
/* 代理列:脱敏地址独占一行,状态药丸另起一行(列宽按最长药丸文案留的,不按整条链接) */
|
/* 代理列:完整地址独占一行,状态药丸另起一行,避免长地址被药丸挤压折行 */
|
||||||
.module-cell--stack {
|
.module-cell--stack {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
@@ -697,9 +580,18 @@ h3 {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
/* 代理列只显示后端脱敏后的 scheme://host(短串,单行足够)。
|
/* 代理列展示完整明文:允许折行显示,不截断、不省略 */
|
||||||
这里**不许**再出现"允许折行展示完整明文 + user-select:all"那套样式:
|
.module-cell .mono-full {
|
||||||
它等于给整条带 key/pwd 的链接做了一键全选复制的旁路(2026-11-02 脱敏收口时一并拆掉)。 */
|
flex: 1 1 auto;
|
||||||
|
min-width: 0;
|
||||||
|
overflow: visible;
|
||||||
|
text-overflow: clip;
|
||||||
|
white-space: normal;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
line-height: 1.45;
|
||||||
|
cursor: text;
|
||||||
|
user-select: all;
|
||||||
|
}
|
||||||
.mono-mask {
|
.mono-mask {
|
||||||
font-family: Consolas, "Cascadia Mono", monospace;
|
font-family: Consolas, "Cascadia Mono", monospace;
|
||||||
font-size: 12.5px;
|
font-size: 12.5px;
|
||||||
@@ -708,16 +600,6 @@ h3 {
|
|||||||
.empty-value {
|
.empty-value {
|
||||||
color: #a7b4c1;
|
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 {
|
.ops-cell {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
@@ -738,12 +620,6 @@ h3 {
|
|||||||
cursor: help;
|
cursor: help;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
.wh-pill.is-source {
|
|
||||||
background: #eef2fb;
|
|
||||||
border-color: #ccd8f2;
|
|
||||||
color: #3d5a99;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
.wh-pill.is-allowed {
|
.wh-pill.is-allowed {
|
||||||
background: #e8f6ee;
|
background: #e8f6ee;
|
||||||
border-color: #b9e0c9;
|
border-color: #b9e0c9;
|
||||||
@@ -759,13 +635,6 @@ h3 {
|
|||||||
border-color: #f0dfae;
|
border-color: #f0dfae;
|
||||||
color: #8f6d1e;
|
color: #8f6d1e;
|
||||||
}
|
}
|
||||||
/* 「等一会再点」这一族(无可用通道/限流/超时/网络/上游):既不红(密钥没坏)
|
|
||||||
也不黄(不是欠费)更不是灰(不是查不出),独立一档青色——三种处置一眼分开。 */
|
|
||||||
.wh-pill.is-retry {
|
|
||||||
background: #e6f2f7;
|
|
||||||
border-color: #b6d8e6;
|
|
||||||
color: #2b6b86;
|
|
||||||
}
|
|
||||||
.wh-pill.is-unknown {
|
.wh-pill.is-unknown {
|
||||||
background: #f0f3f6;
|
background: #f0f3f6;
|
||||||
border-color: #d6dee6;
|
border-color: #d6dee6;
|
||||||
|
|||||||
@@ -8,42 +8,28 @@ import type { AdminUser } from '@/types/admin'
|
|||||||
import { roleLabel } from '@/types/admin'
|
import { roleLabel } from '@/types/admin'
|
||||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||||
import { usePlatformTabStore } from '@/stores/platform-tab'
|
import { deleteUser, fetchUserList } from '@/api/users'
|
||||||
import { deleteUser, fetchUserList, setUserDisabled } from '@/api/users'
|
|
||||||
import { fetchCompanies } from '@/api/companies'
|
import { fetchCompanies } from '@/api/companies'
|
||||||
import { createUserFilterState, toUserListParams, type UserFilterState } from './users-filter'
|
import { createUserFilterState, toUserListParams, type UserFilterState } from './users-filter'
|
||||||
import { totalPageCount } from './user-pagination'
|
import { totalPageCount } from './user-pagination'
|
||||||
import { deleteBlockReason, deleteConfirmMessage } from './user-delete-model'
|
import { deleteBlockReason, deleteConfirmMessage } from './user-delete-model'
|
||||||
import { disableBlockReason, disableConfirmMessage, disabledBadgeText } from './user-disable-model'
|
|
||||||
import { listPhaseOf, userListEmptyHint } from './user-list-state'
|
import { listPhaseOf, userListEmptyHint } from './user-list-state'
|
||||||
import { editableBy } from './user-edit-model'
|
import { editableBy } from './user-edit-model'
|
||||||
import { formatExpiryCell } from './user-expiry'
|
import { formatExpiryCell } from './user-expiry'
|
||||||
import CreateUserDialog from './CreateUserDialog.vue'
|
import CreateUserDialog from './CreateUserDialog.vue'
|
||||||
import EditUserDialog from './EditUserDialog.vue'
|
import EditUserDialog from './EditUserDialog.vue'
|
||||||
import OldPagination from '@/components/OldPagination.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 session = useAdminSessionStore()
|
||||||
const companyTab = useCompanyTabStore()
|
const companyTab = useCompanyTabStore()
|
||||||
// 平台 tab(V206):账号域三页两 tab 共用本组件,列表/新建/编辑都按当前平台收放。
|
|
||||||
const platformTab = usePlatformTabStore()
|
|
||||||
/** 京东侧标记:上架上限列与编辑入口只在京东 tab 显示(用户口径「不需要在亚马逊那边」)。 */
|
|
||||||
const isJdSide = computed(() => platformTab.active === 'jd')
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const loadError = ref('')
|
const loadError = ref('')
|
||||||
// 用户列表竞态门(S1-F4):快速切公司/翻页只让最后一次响应落地
|
|
||||||
const gate = createLatestRequestGate()
|
|
||||||
const rows = ref<AdminUser[]>([])
|
const rows = ref<AdminUser[]>([])
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
/** 所属管理员候选(来自列表响应的 admins),供超管筛选下拉使用。 */
|
/** 所属管理员候选(来自列表响应的 admins),供超管筛选下拉使用。 */
|
||||||
const admins = ref<Array<{ id: number; username: string }>>([])
|
const admins = ref<Array<{ id: number; username: string }>>([])
|
||||||
/** 公司候选(仅供建号弹窗的「公司超级管理员」下拉使用,2026-10-05 唯一豁免)。 */
|
/** 公司候选(仅供建号弹窗的「公司超级管理员」下拉使用,2026-10-05 唯一豁免)。 */
|
||||||
const companyOptions = ref<Array<{ id: number; companyName: string }>>([])
|
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 filters = reactive<UserFilterState>(createUserFilterState())
|
||||||
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
||||||
const operatorRole = computed(() => session.user?.role ?? null)
|
const operatorRole = computed(() => session.user?.role ?? null)
|
||||||
@@ -70,26 +56,17 @@ function editableOf(row: AdminUser): boolean {
|
|||||||
return editableBy(row.role, operatorRole.value)
|
return editableBy(row.role, operatorRole.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 上架上限列文案(仅京东侧渲染该列):null=旧数据未配('-'),0=不限,其余为具体条数。 */
|
/** 列表请求参数 = 用户填的筛选态 + 当前公司。公司值每次现取、不写进 filters:
|
||||||
function quotaCellText(row: AdminUser): string {
|
* 它由上方 tab 决定而不是用户填的筛选项,住进 filters 就等于多出第二个取值口径(Store 之外再长一个)。 */
|
||||||
if (row.jdPublishQuota == null) return '-'
|
|
||||||
return row.jdPublishQuota === 0 ? '不限' : String(row.jdPublishQuota)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 列表请求参数 = 用户填的筛选态 + 当前公司 + 当前平台。公司/平台值每次现取、不写进 filters:
|
|
||||||
* 它们由上方 tab 决定而不是用户填的筛选项,住进 filters 就等于多出第二个取值口径(Store 之外再长一个)。 */
|
|
||||||
function listParams() {
|
function listParams() {
|
||||||
return { ...toUserListParams(filters), companyId: companyTab.requestCompanyId, platform: platformTab.active }
|
return { ...toUserListParams(filters), companyId: companyTab.requestCompanyId }
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadUsers() {
|
async function loadUsers() {
|
||||||
// S1-F4:快速切公司/翻页时旧响应可能后返回并覆盖新结果——回写前必须过竞态门
|
|
||||||
const token = gate.begin()
|
|
||||||
loading.value = true
|
loading.value = true
|
||||||
loadError.value = ''
|
loadError.value = ''
|
||||||
try {
|
try {
|
||||||
const page = await fetchUserList(listParams())
|
const page = await fetchUserList(listParams())
|
||||||
if (!gate.isCurrent(token)) return
|
|
||||||
rows.value = page.items
|
rows.value = page.items
|
||||||
total.value = page.total
|
total.value = page.total
|
||||||
if (Array.isArray(page.admins)) admins.value = page.admins
|
if (Array.isArray(page.admins)) admins.value = page.admins
|
||||||
@@ -98,16 +75,14 @@ async function loadUsers() {
|
|||||||
if (last > 0 && filters.page > last) {
|
if (last > 0 && filters.page > last) {
|
||||||
filters.page = last
|
filters.page = last
|
||||||
const retried = await fetchUserList(listParams())
|
const retried = await fetchUserList(listParams())
|
||||||
if (!gate.isCurrent(token)) return
|
|
||||||
rows.value = retried.items
|
rows.value = retried.items
|
||||||
total.value = retried.total
|
total.value = retried.total
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (!gate.isCurrent(token)) return
|
|
||||||
loadError.value = error instanceof Error ? error.message : '用户列表加载失败'
|
loadError.value = error instanceof Error ? error.message : '用户列表加载失败'
|
||||||
showAdminFeedback(loadError.value, 'error')
|
ElMessage.error(loadError.value)
|
||||||
} finally {
|
} finally {
|
||||||
if (gate.isCurrent(token)) loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,31 +104,13 @@ async function removeUser(row: AdminUser) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 对齐旧版:浏览器原生 confirm 确认后删除。
|
// 对齐旧版:浏览器原生 confirm 确认后删除。
|
||||||
if (!(await openAdminConfirm({ message: deleteConfirmMessage(row), danger: true }))) return
|
if (!window.confirm(deleteConfirmMessage(row))) return
|
||||||
try {
|
try {
|
||||||
await deleteUser(row.id)
|
await deleteUser(row.id)
|
||||||
ElMessage.success('删除成功')
|
ElMessage.success('删除成功')
|
||||||
await loadUsers()
|
await loadUsers()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 停用/解除停用:先过身份闸,原生 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')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,32 +139,18 @@ function goJump() {
|
|||||||
// ② 用户名全平台唯一(V143 的唯一索引),留着上一家填的关键字去筛新一家 ⇒ 必然空页,而输入框还显示着那个值。
|
// ② 用户名全平台唯一(V143 的唯一索引),留着上一家填的关键字去筛新一家 ⇒ 必然空页,而输入框还显示着那个值。
|
||||||
watch(() => companyTab.activeId, () => { filters.createdByAdminId = null; filters.keyword = ''; filters.page = 1; void loadUsers() })
|
watch(() => companyTab.activeId, () => { filters.createdByAdminId = null; filters.keyword = ''; filters.page = 1; void loadUsers() })
|
||||||
|
|
||||||
// 切平台 tab(V206)= 同样的重取数:列表按平台过滤,候选/关键字跨平台无意义,一并清掉;
|
onMounted(() => {
|
||||||
// 建「公司超级管理员」的公司候选也按平台换一份(2026-11-17:京东 tab 下不能还选到亚马逊公司)。
|
|
||||||
watch(() => platformTab.active, () => {
|
|
||||||
filters.createdByAdminId = null
|
|
||||||
filters.keyword = ''
|
|
||||||
filters.page = 1
|
|
||||||
void loadUsers()
|
void loadUsers()
|
||||||
loadCompanyOptions()
|
// 公司目录仅站点超管拉取(建「公司超级管理员」时选公司用);非超管不发这个请求,后端 403 兜底
|
||||||
})
|
if (isSuperAdmin.value) {
|
||||||
|
void fetchCompanies()
|
||||||
// 公司目录仅站点超管拉取(建「公司超级管理员」时选公司用);非超管不发这个请求,后端 403 兜底。
|
|
||||||
// 按当前平台 tab 过滤(V206)——公司本身已按平台分侧,候选下拉跟着 tab 走。
|
|
||||||
function loadCompanyOptions() {
|
|
||||||
if (!isSuperAdmin.value) return
|
|
||||||
void fetchCompanies(platformTab.active)
|
|
||||||
.then((items) => {
|
.then((items) => {
|
||||||
companyOptions.value = items.map((c) => ({ id: c.id, companyName: c.companyName }))
|
companyOptions.value = items.map((c) => ({ id: c.id, companyName: c.companyName }))
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
companyOptions.value = []
|
companyOptions.value = []
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
void loadUsers()
|
|
||||||
loadCompanyOptions()
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -257,8 +200,6 @@ onMounted(() => {
|
|||||||
<th style="width: 140px">角色</th>
|
<th style="width: 140px">角色</th>
|
||||||
<th style="width: 160px">所属管理员</th>
|
<th style="width: 160px">所属管理员</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: 180px">更新时间</th>
|
<th style="width: 180px">更新时间</th>
|
||||||
<th style="width: 160px">操作</th>
|
<th style="width: 160px">操作</th>
|
||||||
@@ -274,10 +215,6 @@ onMounted(() => {
|
|||||||
<td :class="{ 'expiry-cell-expired': formatExpiryCell(row).expired }">
|
<td :class="{ 'expiry-cell-expired': formatExpiryCell(row).expired }">
|
||||||
{{ formatExpiryCell(row).text }}
|
{{ formatExpiryCell(row).text }}
|
||||||
</td>
|
</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.createdAt) }}</td>
|
||||||
<td>{{ formatDateTime(row.updatedAt) }}</td>
|
<td>{{ formatDateTime(row.updatedAt) }}</td>
|
||||||
<td class="ops-cell">
|
<td class="ops-cell">
|
||||||
@@ -290,15 +227,6 @@ onMounted(() => {
|
|||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
</button>
|
</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
|
<button
|
||||||
class="btn btn-sm btn-danger"
|
class="btn btn-sm btn-danger"
|
||||||
type="button"
|
type="button"
|
||||||
@@ -312,10 +240,10 @@ onMounted(() => {
|
|||||||
</tr>
|
</tr>
|
||||||
</template>
|
</template>
|
||||||
<tr v-else-if="loading">
|
<tr v-else-if="loading">
|
||||||
<td :colspan="isJdSide ? 10 : 9" class="empty-tip">加载中...</td>
|
<td colspan="8" class="empty-tip">加载中...</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-else>
|
<tr v-else>
|
||||||
<td :colspan="isJdSide ? 10 : 9" class="empty-tip">{{ userListEmptyHint() }}</td>
|
<td colspan="8" class="empty-tip">{{ userListEmptyHint() }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -330,12 +258,9 @@ onMounted(() => {
|
|||||||
:operator-role="operatorRole"
|
:operator-role="operatorRole"
|
||||||
:admin-options="admins"
|
:admin-options="admins"
|
||||||
:company-options="companyOptions"
|
:company-options="companyOptions"
|
||||||
:operator-company-id="operatorCompanyId"
|
|
||||||
:active-company-id="companyTab.requestCompanyId"
|
|
||||||
:platform="platformTab.active"
|
|
||||||
@created="loadUsers"
|
@created="loadUsers"
|
||||||
/>
|
/>
|
||||||
<EditUserDialog v-model="editVisible" :user="editUser" :operator-super="isSuperAdmin" :company-id="companyTab.requestCompanyId" :platform="platformTab.active" @updated="loadUsers" />
|
<EditUserDialog v-model="editVisible" :user="editUser" :operator-super="isSuperAdmin" :company-id="companyTab.requestCompanyId" @updated="loadUsers" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -491,7 +416,7 @@ h3 {
|
|||||||
table-layout: fixed;
|
table-layout: fixed;
|
||||||
}
|
}
|
||||||
.user-table-scroll > table {
|
.user-table-scroll > table {
|
||||||
min-width: 1120px;
|
min-width: 1000px;
|
||||||
}
|
}
|
||||||
.table-scroll th,
|
.table-scroll th,
|
||||||
.table-scroll td {
|
.table-scroll td {
|
||||||
@@ -524,19 +449,11 @@ h3 {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
}
|
||||||
.expiry-cell-expired {
|
.expiry-cell-expired {
|
||||||
color: #c0392b;
|
color: #c0392b;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
.status-cell {
|
|
||||||
color: #3d7158;
|
|
||||||
}
|
|
||||||
.status-cell-disabled {
|
|
||||||
color: #91474f;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.empty-tip {
|
.empty-tip {
|
||||||
padding: 44px 24px;
|
padding: 44px 24px;
|
||||||
|
|||||||
@@ -11,33 +11,22 @@ import {
|
|||||||
|
|
||||||
export const SHOP_GROUPS_ENDPOINT = '/api/admin/shop-manages/groups'
|
export const SHOP_GROUPS_ENDPOINT = '/api/admin/shop-manages/groups'
|
||||||
|
|
||||||
/** 列表:company_id 收公司口径(钉住的取值口),platform 收平台 tab 口径(V206),都缺省就不发。 */
|
export async function fetchShopGroups(companyId?: number | null): Promise<ShopGroupItem[]> {
|
||||||
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 } : {} })
|
||||||
const { data } = await http.get<unknown>(SHOP_GROUPS_ENDPOINT, {
|
|
||||||
params: {
|
|
||||||
...(companyId != null ? { company_id: companyId } : {}),
|
|
||||||
...(platform ? { platform } : {}),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
return parseShopGroupList(data)
|
return parseShopGroupList(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 新建分组:POST /api/admin/shop-manages/groups(创建人 = 组长 = 当前操作者)。 */
|
/** 新建分组:POST /api/admin/shop-manages/groups(创建人 = 组长 = 当前操作者)。 */
|
||||||
export async function createShopGroup(
|
export async function createShopGroup(name: string, memberUserIds: number[], createdById: number): Promise<ShopGroupItem> {
|
||||||
name: string,
|
const { data } = await http.post<unknown>(SHOP_GROUPS_ENDPOINT, toShopGroupCreatePayload(name, memberUserIds, createdById))
|
||||||
memberUserIds: number[],
|
|
||||||
createdById: number,
|
|
||||||
platform?: string,
|
|
||||||
): Promise<ShopGroupItem> {
|
|
||||||
const { data } = await http.post<unknown>(SHOP_GROUPS_ENDPOINT, toShopGroupCreatePayload(name, memberUserIds, createdById, platform))
|
|
||||||
const created = parseShopGroupItem(unwrap<unknown>(data))
|
const created = parseShopGroupItem(unwrap<unknown>(data))
|
||||||
if (!created) throw new Error('创建分组响应异常:缺少分组数据')
|
if (!created) throw new Error('创建分组响应异常:缺少分组数据')
|
||||||
return created
|
return created
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 更新分组:PUT /api/admin/shop-manages/groups/{id}。 */
|
/** 更新分组:PUT /api/admin/shop-manages/groups/{id}。 */
|
||||||
export async function updateShopGroup(id: number, name: string, memberUserIds: number[], platform?: string): Promise<ShopGroupItem> {
|
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, platform))
|
const { data } = await http.put<unknown>(`${SHOP_GROUPS_ENDPOINT}/${id}`, toShopGroupUpdatePayload(name, memberUserIds))
|
||||||
const updated = parseShopGroupItem(unwrap<unknown>(data))
|
const updated = parseShopGroupItem(unwrap<unknown>(data))
|
||||||
if (!updated) throw new Error('更新分组响应异常:缺少分组数据')
|
if (!updated) throw new Error('更新分组响应异常:缺少分组数据')
|
||||||
return updated
|
return updated
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/** 数据权限分组列表模型(任务 59;module 13 task 253 扩展编辑能力):解析 VO + 摘要 + 提交载荷。 */
|
/** 数据权限分组列表模型(任务 59;module 13 task 253 扩展编辑能力):解析 VO + 摘要 + 提交载荷。 */
|
||||||
import { unwrap } from '../../api/envelope.ts'
|
import { unwrap } from '../../api/envelope.ts'
|
||||||
import { isSuperAdminRole, roleKind } from '../../types/admin.ts'
|
|
||||||
|
|
||||||
export interface ShopGroupItem {
|
export interface ShopGroupItem {
|
||||||
id: number
|
id: number
|
||||||
@@ -12,8 +11,6 @@ export interface ShopGroupItem {
|
|||||||
memberUserIds?: number[]
|
memberUserIds?: number[]
|
||||||
createdAt?: string
|
createdAt?: string
|
||||||
updatedAt?: string
|
updatedAt?: string
|
||||||
/** 所属平台(V206):'amazon'|'jd';旧负载缺省不渲染该键。 */
|
|
||||||
platform?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ShopGroupFormErrors {
|
export interface ShopGroupFormErrors {
|
||||||
@@ -55,8 +52,6 @@ export function parseShopGroupItem(raw: unknown): ShopGroupItem | null {
|
|||||||
if (createdAt) item.createdAt = createdAt
|
if (createdAt) item.createdAt = createdAt
|
||||||
const updatedAt = text(record.updatedAt ?? record.updated_at)
|
const updatedAt = text(record.updatedAt ?? record.updated_at)
|
||||||
if (updatedAt) item.updatedAt = updatedAt
|
if (updatedAt) item.updatedAt = updatedAt
|
||||||
const platform = text(record.platform)
|
|
||||||
if (platform) item.platform = platform
|
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,34 +78,18 @@ export function validateShopGroupForm(name: string): ShopGroupFormErrors {
|
|||||||
return errors
|
return errors
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 创建载荷:groupName + 成员 + 创建人(= 组长,当前操作者)+ 所属平台(V206,缺省不下发)。 */
|
/** 创建载荷:groupName + 成员 + 创建人(= 组长,当前操作者)。 */
|
||||||
export function toShopGroupCreatePayload(
|
export function toShopGroupCreatePayload(
|
||||||
name: string,
|
name: string,
|
||||||
memberUserIds: number[],
|
memberUserIds: number[],
|
||||||
createdById: number,
|
createdById: number,
|
||||||
platform?: string,
|
): { groupName: string; memberUserIds: number[]; createdById: number } {
|
||||||
): { groupName: string; memberUserIds: number[]; createdById: number; platform?: string } {
|
return { groupName: text(name), memberUserIds: dedupeIds(memberUserIds), createdById }
|
||||||
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 + 成员 + 所属平台(V206;组长/创建人不可改)。 */
|
/** 更新载荷:groupName + 成员(组长/创建人不可改)。 */
|
||||||
export function toShopGroupUpdatePayload(
|
export function toShopGroupUpdatePayload(name: string, memberUserIds: number[]): { groupName: string; memberUserIds: number[] } {
|
||||||
name: string,
|
return { groupName: text(name), memberUserIds: dedupeIds(memberUserIds) }
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 组员候选用户(对齐 admin.js getEligibleShopManageGroupUsers 的过滤语义)。 */
|
/** 组员候选用户(对齐 admin.js getEligibleShopManageGroupUsers 的过滤语义)。 */
|
||||||
@@ -122,20 +101,10 @@ export interface GroupMemberCandidateUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 超管(站点与公司两档)永不进组员候选——它是那家公司的最高账号,不属于任何分组。
|
* 组员候选过滤(对齐 admin.js:3020-3028):
|
||||||
* 与后端 `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 收口):
|
|
||||||
* - 组长本人永不进候选;
|
* - 组长本人永不进候选;
|
||||||
* - 超管(站点/公司)永不进候选;
|
* - 超管可选全部用户(不论角色/归属);
|
||||||
* - 超管操作者可选本公司全部账号(公司维度由请求的 company_id 收窄,不在这里再判一次);
|
* - 非超管仅可选"组长(创建人)名下"的普通账号。
|
||||||
* - 其余操作者仅可选"组长(创建人)名下"的普通账号。
|
|
||||||
*/
|
*/
|
||||||
export function eligibleGroupMembers(
|
export function eligibleGroupMembers(
|
||||||
users: GroupMemberCandidateUser[],
|
users: GroupMemberCandidateUser[],
|
||||||
@@ -143,10 +112,9 @@ export function eligibleGroupMembers(
|
|||||||
operatorRole: string,
|
operatorRole: string,
|
||||||
): GroupMemberCandidateUser[] {
|
): GroupMemberCandidateUser[] {
|
||||||
const leaderKey = leaderUserId != null && leaderUserId > 0 ? String(leaderUserId) : ''
|
const leaderKey = leaderUserId != null && leaderUserId > 0 ? String(leaderUserId) : ''
|
||||||
const isSuper = isSuperAdminRole(operatorRole)
|
const isSuper = (operatorRole || '').toLowerCase() === 'super_admin'
|
||||||
return users.filter((u) => {
|
return users.filter((u) => {
|
||||||
if (String(u.id) === leaderKey) return false
|
if (String(u.id) === leaderKey) return false
|
||||||
if (isGroupIneligibleRole(u.role)) return false
|
|
||||||
if (isSuper) return true
|
if (isSuper) return true
|
||||||
return (
|
return (
|
||||||
(u.role || '').toLowerCase() === 'normal' &&
|
(u.role || '').toLowerCase() === 'normal' &&
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/** 新建用户表单模型(任务 45):纯逻辑,镜像 Java AdminUserCreateRequest 字段与后端校验。 */
|
/** 新建用户表单模型(任务 45):纯逻辑,镜像 Java AdminUserCreateRequest 字段与后端校验。 */
|
||||||
import type { PlatformTabId } from '../../config/platform-scope.ts'
|
|
||||||
|
|
||||||
export const CREATE_USERNAME_MIN_LEN = 2
|
export const CREATE_USERNAME_MIN_LEN = 2
|
||||||
export const CREATE_PASSWORD_MIN_LEN = 6
|
export const CREATE_PASSWORD_MIN_LEN = 6
|
||||||
@@ -22,8 +21,6 @@ export interface CreateUserForm {
|
|||||||
expiresAt: string
|
expiresAt: string
|
||||||
/** 所属公司 id:仅 role=company_super_admin 时由站点超管必选(2026-10-05 需求)。 */
|
/** 所属公司 id:仅 role=company_super_admin 时由站点超管必选(2026-10-05 需求)。 */
|
||||||
companyId?: number | null
|
companyId?: number | null
|
||||||
/** 所属平台(V206):弹窗打开时预填当前平台 tab,单选可改。 */
|
|
||||||
platform: PlatformTabId
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateUserFormErrors {
|
export interface CreateUserFormErrors {
|
||||||
@@ -46,12 +43,10 @@ export interface CreateUserPayload {
|
|||||||
* 反向钉(company-user-create.test.ts)唯一豁免的例外:公司超管必须落指定公司,
|
* 反向钉(company-user-create.test.ts)唯一豁免的例外:公司超管必须落指定公司,
|
||||||
* 否则会静默落操作者自己的公司(公司 1),用户需求就是给别家公司开超管。 */
|
* 否则会静默落操作者自己的公司(公司 1),用户需求就是给别家公司开超管。 */
|
||||||
companyId?: number
|
companyId?: number
|
||||||
/** 所属平台(V206):恒下发(弹窗单选默认当前平台 tab),缺省后端落 amazon。 */
|
|
||||||
platform: PlatformTabId
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createEmptyCreateUserForm(): CreateUserForm {
|
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, expiresAt: '', companyId: null }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 未知/空白/超管角色归一:admin/company_super_admin/normal 白名单,其余归 normal。 */
|
/** 未知/空白/超管角色归一:admin/company_super_admin/normal 白名单,其余归 normal。 */
|
||||||
@@ -62,43 +57,6 @@ export function normalizeCreateRole(role: string | null | undefined): CreatableU
|
|||||||
return 'normal'
|
return '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 逐字对齐
|
* 可携带「自己的到期时间」的角色,与后端 AdminUserService#mayCarryOwnExpiry 逐字对齐
|
||||||
* (normal-account-no-own-expiry.test.ts 钉两端集合相等)。普通账号的停用只由上级
|
* (normal-account-no-own-expiry.test.ts 钉两端集合相等)。普通账号的停用只由上级
|
||||||
@@ -152,7 +110,6 @@ export function toCreateUserRequest(form: CreateUserForm): CreateUserPayload {
|
|||||||
password: form.password || '',
|
password: form.password || '',
|
||||||
role,
|
role,
|
||||||
columnIds: Array.isArray(form.columnIds) ? form.columnIds.slice() : [],
|
columnIds: Array.isArray(form.columnIds) ? form.columnIds.slice() : [],
|
||||||
platform: form.platform,
|
|
||||||
}
|
}
|
||||||
if (payload.role === 'normal' && form.createdBy != null) {
|
if (payload.role === 'normal' && form.createdBy != null) {
|
||||||
payload.createdById = form.createdBy
|
payload.createdById = form.createdBy
|
||||||
|
|||||||
@@ -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,
|
toEditUserUpdateRequest,
|
||||||
validateEditUserForm,
|
validateEditUserForm,
|
||||||
type EditUserForm,
|
type EditUserForm,
|
||||||
type EditUserFormOptions,
|
|
||||||
} from './user-edit-model'
|
} from './user-edit-model'
|
||||||
|
|
||||||
/** Java AdminUserController.updateUser 端点前缀。 */
|
/** Java AdminUserController.updateUser 端点前缀。 */
|
||||||
@@ -13,13 +12,12 @@ export const EDIT_USER_ENDPOINT = '/api/admin/user'
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交编辑用户:先校验(不通过抛首条错误),再序列化 PUT;http/后端失败交由调用方提示。
|
* 提交编辑用户:先校验(不通过抛首条错误),再序列化 PUT;http/后端失败交由调用方提示。
|
||||||
* options.includeQuota=false(亚马逊侧)不下发上架上限——校验与序列化同口径。
|
|
||||||
*/
|
*/
|
||||||
export async function submitEditUser(form: EditUserForm, options: EditUserFormOptions = {}): Promise<void> {
|
export async function submitEditUser(form: EditUserForm): Promise<void> {
|
||||||
const { valid, errors } = validateEditUserForm(form, options)
|
const { valid, errors } = validateEditUserForm(form)
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
throw new Error(Object.values(errors)[0] || '编辑用户表单校验未通过')
|
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)
|
unwrap<unknown>(data)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
/** 编辑用户表单回填模型(任务 47):从用户行回填可编辑表单,镜像 Java AdminUserUpdateRequest。 */
|
/** 编辑用户表单回填模型(任务 47):从用户行回填可编辑表单,镜像 Java AdminUserUpdateRequest。 */
|
||||||
import type { AdminUser } from '../../types/admin'
|
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, mayCarryOwnExpiry } from './user-create-model.ts'
|
||||||
|
|
||||||
/** 编辑可选角色:站点/公司超管不可改,未知归 normal;后端只收 admin|normal。 */
|
/** 编辑可选角色:站点/公司超管不可改,未知归 normal;后端只收 admin|normal。 */
|
||||||
export type EditUserRole = 'normal' | 'admin'
|
export type EditUserRole = 'normal' | 'admin'
|
||||||
|
|
||||||
export interface EditUserForm {
|
export interface EditUserForm {
|
||||||
jdPublishQuota: number
|
|
||||||
uid: number
|
uid: number
|
||||||
/** 仅展示用,后端不支持改用户名。 */
|
/** 仅展示用,后端不支持改用户名。 */
|
||||||
username: string
|
username: string
|
||||||
@@ -20,12 +18,9 @@ export interface EditUserForm {
|
|||||||
originalRole: string
|
originalRole: string
|
||||||
/** 到期时间(yyyy-MM-dd HH:mm:ss);空串 = 永不过期。null = 后端本来就无到期。 */
|
/** 到期时间(yyyy-MM-dd HH:mm:ss);空串 = 永不过期。null = 后端本来就无到期。 */
|
||||||
expiresAt: string
|
expiresAt: string
|
||||||
/** 所属平台(V206):单选可翻档,未知/缺省归亚马逊(存量默认)。 */
|
|
||||||
platform: PlatformTabId
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EditUserFormErrors {
|
export interface EditUserFormErrors {
|
||||||
jdPublishQuota?: string
|
|
||||||
password?: string
|
password?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,13 +28,10 @@ export interface EditUserFormErrors {
|
|||||||
export interface EditUserUpdateRequest {
|
export interface EditUserUpdateRequest {
|
||||||
/** 目标是公司超管时不携带(防止表单把公司超管误降级);站点超管改其密码/到期时间即可。 */
|
/** 目标是公司超管时不携带(防止表单把公司超管误降级);站点超管改其密码/到期时间即可。 */
|
||||||
role?: EditUserRole
|
role?: EditUserRole
|
||||||
jdPublishQuota?: number
|
|
||||||
columnIds: number[]
|
columnIds: number[]
|
||||||
password?: string
|
password?: string
|
||||||
/** 到期时间:空串=清除(恢复永不过期),有值=改期;总是下发(与后端"传了就更新"对齐)。 */
|
/** 到期时间:空串=清除(恢复永不过期),有值=改期;总是下发(与后端"传了就更新"对齐)。 */
|
||||||
expiresAt: string
|
expiresAt: string
|
||||||
/** 所属平台(V206):总是下发(弹窗单选恒渲染),翻档即把记录挪到另一平台的列表。 */
|
|
||||||
platform: PlatformTabId
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 行角色 → 可编辑角色:仅 admin 映射 admin,其余(含 unknown)归 normal。 */
|
/** 行角色 → 可编辑角色:仅 admin 映射 admin,其余(含 unknown)归 normal。 */
|
||||||
@@ -79,38 +71,22 @@ export function fillEditUserForm(user: AdminUser): EditUserForm {
|
|||||||
const role = typeof user.role === 'string' ? user.role.trim() : ''
|
const role = typeof user.role === 'string' ? user.role.trim() : ''
|
||||||
return {
|
return {
|
||||||
uid: user.id,
|
uid: user.id,
|
||||||
jdPublishQuota: user.jdPublishQuota ?? 5000,
|
|
||||||
username: user.username || '',
|
username: user.username || '',
|
||||||
password: '',
|
password: '',
|
||||||
role: editRoleOf(role),
|
role: editRoleOf(role),
|
||||||
columnIds: [],
|
columnIds: [],
|
||||||
originalRole: role,
|
originalRole: role,
|
||||||
expiresAt: normalizeExpiryForPicker(user.expiresAt),
|
expiresAt: normalizeExpiryForPicker(user.expiresAt),
|
||||||
platform: user.platform === 'jd' ? 'jd' : 'amazon',
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 编辑表单校验选项:includeQuota=false(亚马逊侧)跳过上架上限校验——该项不下发。 */
|
|
||||||
export interface EditUserFormOptions {
|
|
||||||
/** 是否参与上架上限(jd_publish_quota)的校验与下发;缺省 true(京东侧)。 */
|
|
||||||
includeQuota?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 编辑表单校验:密码可留空(不改),非空时须达到最小长度。 */
|
/** 编辑表单校验:密码可留空(不改),非空时须达到最小长度。 */
|
||||||
export function validateEditUserForm(
|
export function validateEditUserForm(form: EditUserForm): { valid: boolean; errors: EditUserFormErrors } {
|
||||||
form: EditUserForm,
|
|
||||||
options: EditUserFormOptions = {},
|
|
||||||
): { valid: boolean; errors: EditUserFormErrors } {
|
|
||||||
const errors: EditUserFormErrors = {}
|
const errors: EditUserFormErrors = {}
|
||||||
const password = form.password || ''
|
const password = form.password || ''
|
||||||
if (password && password.length < CREATE_PASSWORD_MIN_LEN) {
|
if (password && password.length < CREATE_PASSWORD_MIN_LEN) {
|
||||||
errors.password = `密码至少${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 }
|
return { valid: Object.keys(errors).length === 0, errors }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,11 +96,8 @@ export function validateEditUserForm(
|
|||||||
* <p>expiresAt 按「改完之后的角色」决定:目标角色不能带自己的到期时间时发空串=清空
|
* <p>expiresAt 按「改完之后的角色」决定:目标角色不能带自己的到期时间时发空串=清空
|
||||||
* (后端 400 闸门只拦「有值」,空串走既有的清除分支)。公司超管目标不带 role,
|
* (后端 400 闸门只拦「有值」,空串走既有的清除分支)。公司超管目标不带 role,
|
||||||
* 它的 roleAfter 就是 company_super_admin,续费那条空串不会被误当成清空。</p>
|
* 它的 roleAfter 就是 company_super_admin,续费那条空串不会被误当成清空。</p>
|
||||||
*
|
|
||||||
* <p>options.includeQuota=false(亚马逊侧编辑)不下发 jdPublishQuota——上架上限是京东
|
|
||||||
* 口径,亚马逊侧不显示也不改它(用户口径 2026-11-17);platform 恒下发(单选恒渲染)。</p>
|
|
||||||
*/
|
*/
|
||||||
export function toEditUserUpdateRequest(form: EditUserForm, options: EditUserFormOptions = {}): EditUserUpdateRequest {
|
export function toEditUserUpdateRequest(form: EditUserForm): EditUserUpdateRequest {
|
||||||
const originalRole = (form.originalRole || '').trim().toLowerCase()
|
const originalRole = (form.originalRole || '').trim().toLowerCase()
|
||||||
if (originalRole === 'super_admin') {
|
if (originalRole === 'super_admin') {
|
||||||
throw new Error('不能修改超级管理员')
|
throw new Error('不能修改超级管理员')
|
||||||
@@ -137,14 +110,10 @@ export function toEditUserUpdateRequest(form: EditUserForm, options: EditUserFor
|
|||||||
const request: EditUserUpdateRequest = {
|
const request: EditUserUpdateRequest = {
|
||||||
columnIds: Array.isArray(form.columnIds) ? form.columnIds.slice() : [],
|
columnIds: Array.isArray(form.columnIds) ? form.columnIds.slice() : [],
|
||||||
expiresAt: mayCarryOwnExpiry(roleAfter) ? (form.expiresAt || '').trim() : '',
|
expiresAt: mayCarryOwnExpiry(roleAfter) ? (form.expiresAt || '').trim() : '',
|
||||||
platform: form.platform,
|
|
||||||
}
|
}
|
||||||
if (keepsRole) {
|
if (keepsRole) {
|
||||||
request.role = nextRole
|
request.role = nextRole
|
||||||
}
|
}
|
||||||
if (options.includeQuota !== false && (roleAfter === 'admin' || roleAfter === 'company_super_admin')) {
|
|
||||||
request.jdPublishQuota = form.jdPublishQuota
|
|
||||||
}
|
|
||||||
const password = form.password || ''
|
const password = form.password || ''
|
||||||
if (password) request.password = password
|
if (password) request.password = password
|
||||||
return request
|
return request
|
||||||
|
|||||||
@@ -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 }
|
|
||||||
}
|
|
||||||
@@ -11,12 +11,8 @@ import { invalidAsinDeleteText, recordSourceLabel } from '../invalidasin/invalid
|
|||||||
import { createEmptyInvalidAsinForm, invalidAsinFormFromItem, validateInvalidAsinForm } from '../invalidasin/invalid-asin-form-model.ts'
|
import { createEmptyInvalidAsinForm, invalidAsinFormFromItem, validateInvalidAsinForm } from '../invalidasin/invalid-asin-form-model.ts'
|
||||||
import type { ShopGroupOption } from '../shop/shop-dto.ts'
|
import type { ShopGroupOption } from '../shop/shop-dto.ts'
|
||||||
import OldPagination from '@/components/OldPagination.vue'
|
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 loading = ref(false)
|
||||||
const loadFailure = ref('')
|
|
||||||
const rows = ref<InvalidAsinItem[]>([])
|
const rows = ref<InvalidAsinItem[]>([])
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
const page = ref(1)
|
const page = ref(1)
|
||||||
@@ -44,7 +40,6 @@ async function loadGroups() {
|
|||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
try {
|
||||||
const result = await fetchInvalidAsinPage({
|
const result = await fetchInvalidAsinPage({
|
||||||
page: page.value,
|
page: page.value,
|
||||||
@@ -57,8 +52,7 @@ async function load() {
|
|||||||
total.value = result.total
|
total.value = result.total
|
||||||
page.value = result.page
|
page.value = result.page
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loadFailure.value = error instanceof Error ? error.message : '数据加载失败'
|
ElMessage.error(error instanceof Error ? error.message : '数据加载失败')
|
||||||
showAdminFeedback(loadFailure.value, 'error')
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
@@ -124,7 +118,7 @@ async function submit() {
|
|||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
load()
|
load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '保存失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '保存失败')
|
||||||
} finally {
|
} finally {
|
||||||
saving.value = false
|
saving.value = false
|
||||||
}
|
}
|
||||||
@@ -132,13 +126,13 @@ async function submit() {
|
|||||||
|
|
||||||
async function remove(row: InvalidAsinItem) {
|
async function remove(row: InvalidAsinItem) {
|
||||||
// 对齐旧版:原生 confirm。
|
// 对齐旧版:原生 confirm。
|
||||||
if (!(await openAdminConfirm({ message: invalidAsinDeleteText(row), danger: true }))) return
|
if (!window.confirm(invalidAsinDeleteText(row))) return
|
||||||
try {
|
try {
|
||||||
await deleteInvalidAsin(row.id)
|
await deleteInvalidAsin(row.id)
|
||||||
ElMessage.success('已删除')
|
ElMessage.success('已删除')
|
||||||
load()
|
load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +168,6 @@ onMounted(() => {
|
|||||||
<button class="btn" type="button" @click="apply">查询</button>
|
<button class="btn" type="button" @click="apply">查询</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
|
||||||
<div class="table-scroll invalid-asin-table-scroll">
|
<div class="table-scroll invalid-asin-table-scroll">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -415,7 +408,6 @@ h3 {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-tip {
|
.empty-tip {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { formatDateTime, orderedPair } from '@/utils/datetime'
|
import { formatDateTime } from '@/utils/datetime'
|
||||||
/** 数据去重总数据(registry) · 像素复刻旧版 admin.html panel-dedupe-total-data(自绘:分组摘要 + 双行筛选 + 旧式表格/分页 + 编辑/导入弹窗 + 导出等待遮罩)。
|
/** 数据去重总数据(registry) · 像素复刻旧版 admin.html panel-dedupe-total-data(自绘:分组摘要 + 双行筛选 + 旧式表格/分页 + 编辑/导入弹窗 + 导出等待遮罩)。
|
||||||
* script 逻辑沿用现有 Vue 实现(查询/编辑/删除/导入轮询/导出秒表)。 */
|
* script 逻辑沿用现有 Vue 实现(查询/编辑/删除/导入轮询/导出秒表)。 */
|
||||||
import { computed, onMounted, onUnmounted, reactive, ref, watch } from 'vue'
|
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import {
|
import {
|
||||||
fetchDedupeTotalList,
|
fetchDedupeTotalList,
|
||||||
@@ -26,10 +26,6 @@ import { toExportUrl } from './dedupe-total-export.ts'
|
|||||||
import OldPagination from '@/components/OldPagination.vue'
|
import OldPagination from '@/components/OldPagination.vue'
|
||||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
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 session = useAdminSessionStore()
|
||||||
const companyTab = useCompanyTabStore()
|
const companyTab = useCompanyTabStore()
|
||||||
@@ -37,20 +33,12 @@ const companyTab = useCompanyTabStore()
|
|||||||
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const loadFailure = ref('')
|
|
||||||
const rows = ref<DedupeTotalItem[]>([])
|
const rows = ref<DedupeTotalItem[]>([])
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
const page = ref(1)
|
const page = ref(1)
|
||||||
const pageSize = ref(10)
|
const pageSize = ref(10)
|
||||||
/** 本页是累计台账,日期初值故意留空(默认当天会让首屏只剩今天新增的 ASIN);见 date-filter-default-today 护栏的 EXEMPT。 */
|
/** 本页是累计台账,日期初值故意留空(默认当天会让首屏只剩今天新增的 ASIN);见 date-filter-default-today 护栏的 EXEMPT。 */
|
||||||
const filter = reactive(createDedupeTotalFilterState())
|
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 groups = ref<DedupeGroupOption[]>([])
|
||||||
/** 非超管仅有一个可访问分组时,编辑/导入弹窗分组选择锁定为该组(保留展示、不可改)。 */
|
/** 非超管仅有一个可访问分组时,编辑/导入弹窗分组选择锁定为该组(保留展示、不可改)。 */
|
||||||
const lockedGroupId = computed<number | null>(() => {
|
const lockedGroupId = computed<number | null>(() => {
|
||||||
@@ -84,8 +72,6 @@ const exporting = ref(false)
|
|||||||
const exportWaitVisible = ref(false)
|
const exportWaitVisible = ref(false)
|
||||||
const exportWaitSeconds = ref(0)
|
const exportWaitSeconds = ref(0)
|
||||||
let exportWaitTimer: ReturnType<typeof setInterval> | null = null
|
let exportWaitTimer: ReturnType<typeof setInterval> | null = null
|
||||||
/** 页面已卸载:导入轮询的下一拍不再发请求(离开页面后不该再挂 5 分钟的节拍)。 */
|
|
||||||
let pageDisposed = false
|
|
||||||
|
|
||||||
function startExportWait(): void {
|
function startExportWait(): void {
|
||||||
exportWaitSeconds.value = 0
|
exportWaitSeconds.value = 0
|
||||||
@@ -105,7 +91,6 @@ function stopExportWait(): void {
|
|||||||
|
|
||||||
async function load(): Promise<void> {
|
async function load(): Promise<void> {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
try {
|
||||||
const result = await fetchDedupeTotalList(
|
const result = await fetchDedupeTotalList(
|
||||||
toDedupeListParams(filter, page.value, pageSize.value, pendingCursor, companyTab.requestCompanyId),
|
toDedupeListParams(filter, page.value, pageSize.value, pendingCursor, companyTab.requestCompanyId),
|
||||||
@@ -117,8 +102,7 @@ async function load(): Promise<void> {
|
|||||||
pageCursor.value = result.nextLastId ?? null
|
pageCursor.value = result.nextLastId ?? null
|
||||||
pendingCursor = null
|
pendingCursor = null
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loadFailure.value = loadFailureMessage(error, '去重数据加载失败')
|
ElMessage.error(error instanceof Error ? error.message : '去重数据加载失败')
|
||||||
showAdminFeedback(loadFailure.value, 'error')
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
@@ -182,7 +166,7 @@ async function saveEdit(): Promise<void> {
|
|||||||
ElMessage.success('保存成功')
|
ElMessage.success('保存成功')
|
||||||
await load()
|
await load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(loadFailureMessage(error, '保存失败'), 'error')
|
ElMessage.error(error instanceof Error ? error.message : '保存失败')
|
||||||
} finally {
|
} finally {
|
||||||
editSaving.value = false
|
editSaving.value = false
|
||||||
}
|
}
|
||||||
@@ -190,13 +174,13 @@ async function saveEdit(): Promise<void> {
|
|||||||
|
|
||||||
async function removeRow(row: DedupeTotalItem): Promise<void> {
|
async function removeRow(row: DedupeTotalItem): Promise<void> {
|
||||||
// 对齐旧版:浏览器原生 confirm 确认后删除。
|
// 对齐旧版:浏览器原生 confirm 确认后删除。
|
||||||
if (!(await openAdminConfirm({ message: `确定删除总数据“${row.dataValue}”吗?`, danger: true }))) return
|
if (!window.confirm(`确定删除总数据“${row.dataValue}”吗?`)) return
|
||||||
try {
|
try {
|
||||||
await deleteDedupeTotal(row.id)
|
await deleteDedupeTotal(row.id)
|
||||||
ElMessage.success('删除成功')
|
ElMessage.success('删除成功')
|
||||||
await load()
|
await load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(loadFailureMessage(error, '删除失败'), 'error')
|
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,7 +230,6 @@ function sleep(ms: number): Promise<void> {
|
|||||||
|
|
||||||
async function pollImport(poll: () => Promise<DedupeImportProgress>): Promise<DedupeImportProgress> {
|
async function pollImport(poll: () => Promise<DedupeImportProgress>): Promise<DedupeImportProgress> {
|
||||||
for (let i = 0; i < 300; i += 1) {
|
for (let i = 0; i < 300; i += 1) {
|
||||||
if (pageDisposed) throw new Error('页面已离开,导入进度停止跟踪')
|
|
||||||
const progress = await poll()
|
const progress = await poll()
|
||||||
importProgress.value = importOutcomeText(progress)
|
importProgress.value = importOutcomeText(progress)
|
||||||
if (importTaskFinished(progress)) return progress
|
if (importTaskFinished(progress)) return progress
|
||||||
@@ -260,16 +243,14 @@ async function submitImport(): Promise<void> {
|
|||||||
const file = importFile.value as File
|
const file = importFile.value as File
|
||||||
const groupId = importGroupId.value as number
|
const groupId = importGroupId.value as number
|
||||||
if (importMode.value === 'delete') {
|
if (importMode.value === 'delete') {
|
||||||
if (!(await openAdminConfirm({ message: '确定按 Excel 中的 ASIN 批量删除匹配的总数据吗?', danger: true }))) return
|
if (!window.confirm('确定按 Excel 中的 ASIN 批量删除匹配的总数据吗?')) return
|
||||||
}
|
}
|
||||||
const mode = importMode.value
|
const mode = importMode.value
|
||||||
importRunning.value = true
|
importRunning.value = true
|
||||||
importProgress.value = mode === 'add' ? '正在上传并解析文件…' : '正在上传删除清单…'
|
importProgress.value = mode === 'add' ? '正在上传并解析文件…' : '正在上传删除清单…'
|
||||||
try {
|
try {
|
||||||
const started =
|
const started =
|
||||||
mode === 'add'
|
mode === 'add' ? await startDedupeImport(file, groupId) : await startDedupeDeleteImport(file, groupId)
|
||||||
? await startDedupeImport(file, groupId, companyTab.requestCompanyId)
|
|
||||||
: await startDedupeDeleteImport(file, groupId, companyTab.requestCompanyId)
|
|
||||||
const poll = mode === 'add' ? () => fetchDedupeImportProgress(started) : () => fetchDedupeDeleteImportProgress(started)
|
const poll = mode === 'add' ? () => fetchDedupeImportProgress(started) : () => fetchDedupeDeleteImportProgress(started)
|
||||||
const finished = await pollImport(poll)
|
const finished = await pollImport(poll)
|
||||||
importVisible.value = false
|
importVisible.value = false
|
||||||
@@ -278,16 +259,21 @@ async function submitImport(): Promise<void> {
|
|||||||
ElMessage.success(mode === 'add' ? '导入完成' : '删除导入完成')
|
ElMessage.success(mode === 'add' ? '导入完成' : '删除导入完成')
|
||||||
await load()
|
await load()
|
||||||
} else {
|
} else {
|
||||||
showAdminFeedback(importOutcomeText(finished), 'error')
|
ElMessage.error(importOutcomeText(finished))
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(loadFailureMessage(error, '导入失败'), 'error')
|
ElMessage.error(error instanceof Error ? error.message : '导入失败')
|
||||||
} finally {
|
} finally {
|
||||||
importRunning.value = false
|
importRunning.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function doExport(): Promise<void> {
|
async function doExport(): Promise<void> {
|
||||||
|
const { startDate, endDate } = filter
|
||||||
|
if (startDate && endDate && startDate > endDate) {
|
||||||
|
ElMessage.warning('开始日期不能晚于结束日期')
|
||||||
|
return
|
||||||
|
}
|
||||||
if (exporting.value) return
|
if (exporting.value) return
|
||||||
exporting.value = true
|
exporting.value = true
|
||||||
startExportWait()
|
startExportWait()
|
||||||
@@ -313,7 +299,7 @@ async function doExport(): Promise<void> {
|
|||||||
URL.revokeObjectURL(url)
|
URL.revokeObjectURL(url)
|
||||||
ElMessage.success('导出完成')
|
ElMessage.success('导出完成')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(loadFailureMessage(error, '导出失败,请重试'), 'error')
|
ElMessage.error(error instanceof Error ? error.message : '导出失败,请重试')
|
||||||
} finally {
|
} finally {
|
||||||
stopExportWait()
|
stopExportWait()
|
||||||
exporting.value = false
|
exporting.value = false
|
||||||
@@ -337,12 +323,6 @@ onMounted(() => {
|
|||||||
void load()
|
void load()
|
||||||
void loadGroups()
|
void loadGroups()
|
||||||
})
|
})
|
||||||
|
|
||||||
// 导出秒表是 setInterval:不随页面卸载收掉的话,离开本页后它仍在每秒改一个已经没人看的 ref。
|
|
||||||
onUnmounted(() => {
|
|
||||||
pageDisposed = true
|
|
||||||
stopExportWait()
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -386,11 +366,11 @@ onUnmounted(() => {
|
|||||||
<div class="dedupe-filter-date-row">
|
<div class="dedupe-filter-date-row">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>开始日期</label>
|
<label>开始日期</label>
|
||||||
<input v-model="filter.startDate" type="date" :max="filter.endDate" @change="clampDatePair" />
|
<input v-model="filter.startDate" type="date" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>结束日期</label>
|
<label>结束日期</label>
|
||||||
<input v-model="filter.endDate" type="date" :min="filter.startDate" @change="clampDatePair" />
|
<input v-model="filter.endDate" type="date" />
|
||||||
</div>
|
</div>
|
||||||
<div class="dedupe-filter-actions">
|
<div class="dedupe-filter-actions">
|
||||||
<button class="btn btn-secondary" type="button" :disabled="exporting" @click="doExport">
|
<button class="btn btn-secondary" type="button" :disabled="exporting" @click="doExport">
|
||||||
@@ -399,7 +379,6 @@ onUnmounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
|
||||||
<div class="table-scroll dedupe-table-scroll">
|
<div class="table-scroll dedupe-table-scroll">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -411,7 +390,7 @@ onUnmounted(() => {
|
|||||||
<th v-if="isSuperAdmin">分组</th>
|
<th v-if="isSuperAdmin">分组</th>
|
||||||
<th>创建时间</th>
|
<th>创建时间</th>
|
||||||
<th>更新时间</th>
|
<th>更新时间</th>
|
||||||
<th style="width: 140px">操作</th>
|
<th>操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -721,7 +700,6 @@ h3 {
|
|||||||
gap: 8px;
|
gap: 8px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-tip {
|
.empty-tip {
|
||||||
|
|||||||
@@ -17,12 +17,8 @@ import { categoryDraftError, createProductCategoryDraft, toCategorySaveRequest,
|
|||||||
import { buildProductCategoryExportUrl } from './product-category-export.ts'
|
import { buildProductCategoryExportUrl } from './product-category-export.ts'
|
||||||
import { formatDateTime } from '@/utils/datetime'
|
import { formatDateTime } from '@/utils/datetime'
|
||||||
import OldPagination from '@/components/OldPagination.vue'
|
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 loading = ref(false)
|
||||||
const loadFailure = ref('')
|
|
||||||
const tree = ref<ProductCategoryNode[]>([])
|
const tree = ref<ProductCategoryNode[]>([])
|
||||||
const keyword = ref('')
|
const keyword = ref('')
|
||||||
const selected = ref<ProductCategoryNode | null>(null)
|
const selected = ref<ProductCategoryNode | null>(null)
|
||||||
@@ -71,7 +67,6 @@ const rootTotal = ref(0)
|
|||||||
/** 拉取根级当前页(对齐 admin.js loadProductCategoryChildren(null) 懒加载根)。 */
|
/** 拉取根级当前页(对齐 admin.js loadProductCategoryChildren(null) 懒加载根)。 */
|
||||||
async function loadTree(): Promise<void> {
|
async function loadTree(): Promise<void> {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
try {
|
||||||
const result = await fetchProductCategoryChildren(null, rootPage.value, rootPageSize.value)
|
const result = await fetchProductCategoryChildren(null, rootPage.value, rootPageSize.value)
|
||||||
const state = { page: result.page, total: result.total, hasMore: result.hasMore, loading: false }
|
const state = { page: result.page, total: result.total, hasMore: result.hasMore, loading: false }
|
||||||
@@ -80,8 +75,7 @@ async function loadTree(): Promise<void> {
|
|||||||
tree.value = result.items
|
tree.value = result.items
|
||||||
rootTotal.value = result.total
|
rootTotal.value = result.total
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loadFailure.value = error instanceof Error ? error.message : '类目加载失败'
|
ElMessage.error(error instanceof Error ? error.message : '类目加载失败')
|
||||||
showAdminFeedback(loadFailure.value, 'error')
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
@@ -173,7 +167,7 @@ async function loadChildrenPage(parent: ProductCategoryNode | null, page: number
|
|||||||
const fallback = childrenState.get(key) ?? { page: 0, total: 0, hasMore: false, loading: false }
|
const fallback = childrenState.get(key) ?? { page: 0, total: 0, hasMore: false, loading: false }
|
||||||
fallback.loading = false
|
fallback.loading = false
|
||||||
childrenState.set(key, fallback)
|
childrenState.set(key, fallback)
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '子类目加载失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '子类目加载失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +201,7 @@ async function runSearch(page: number): Promise<void> {
|
|||||||
searchPage.value = result.page
|
searchPage.value = result.page
|
||||||
searchHasMore.value = result.hasMore
|
searchHasMore.value = result.hasMore
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '类目搜索失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '类目搜索失败')
|
||||||
} finally {
|
} finally {
|
||||||
searchLoading.value = false
|
searchLoading.value = false
|
||||||
}
|
}
|
||||||
@@ -263,7 +257,7 @@ async function removeCategory(node: ProductCategoryNode): Promise<void> {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 对齐旧版:原生 confirm。
|
// 对齐旧版:原生 confirm。
|
||||||
if (!(await openAdminConfirm({ message: `确定删除“${node.name}”?`, danger: true }))) return
|
if (!window.confirm(`确定删除“${node.name}”?`)) return
|
||||||
try {
|
try {
|
||||||
await deleteProductCategory(node.id)
|
await deleteProductCategory(node.id)
|
||||||
ElMessage.success('已删除')
|
ElMessage.success('已删除')
|
||||||
@@ -271,7 +265,7 @@ async function removeCategory(node: ProductCategoryNode): Promise<void> {
|
|||||||
if (searching.value) void runSearch(1)
|
if (searching.value) void runSearch(1)
|
||||||
else void loadTree()
|
else void loadTree()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,7 +289,7 @@ async function submit(): Promise<void> {
|
|||||||
if (searching.value) void runSearch(1)
|
if (searching.value) void runSearch(1)
|
||||||
else void loadTree()
|
else void loadTree()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
showAdminFeedback(err instanceof Error ? err.message : '保存失败', 'error')
|
ElMessage.error(err instanceof Error ? err.message : '保存失败')
|
||||||
} finally {
|
} finally {
|
||||||
saving.value = false
|
saving.value = false
|
||||||
}
|
}
|
||||||
@@ -328,7 +322,6 @@ onMounted(loadTree)
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="loadTree" />
|
|
||||||
<div class="table-scroll category-table-scroll">
|
<div class="table-scroll category-table-scroll">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -717,7 +710,6 @@ h3 {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.load-more-row td {
|
.load-more-row td {
|
||||||
|
|||||||
@@ -19,9 +19,6 @@ import type { ShopGroupOption } from '../shop/shop-dto.ts'
|
|||||||
import OldPagination from '@/components/OldPagination.vue'
|
import OldPagination from '@/components/OldPagination.vue'
|
||||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
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 session = useAdminSessionStore()
|
||||||
const companyTab = useCompanyTabStore()
|
const companyTab = useCompanyTabStore()
|
||||||
@@ -29,7 +26,6 @@ const companyTab = useCompanyTabStore()
|
|||||||
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const loadFailure = ref('')
|
|
||||||
const rows = ref<QueryAsinItem[]>([])
|
const rows = ref<QueryAsinItem[]>([])
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
const page = ref(1)
|
const page = ref(1)
|
||||||
@@ -73,7 +69,7 @@ function normalizeAsinInput(country: string): void {
|
|||||||
|
|
||||||
async function removeShopAsin(item: QueryAsinItem) {
|
async function removeShopAsin(item: QueryAsinItem) {
|
||||||
// 删除该店铺全部站点的 ASIN 配置(逐国调用现有端点)。
|
// 删除该店铺全部站点的 ASIN 配置(逐国调用现有端点)。
|
||||||
if (!(await openAdminConfirm({ message: `确定删除店铺“${item.shopName}”的全部站点 ASIN 配置吗?`, danger: true }))) return
|
if (!window.confirm(`确定删除店铺“${item.shopName}”的全部站点 ASIN 配置吗?`)) return
|
||||||
try {
|
try {
|
||||||
for (const country of QUERY_ASIN_COUNTRIES) {
|
for (const country of QUERY_ASIN_COUNTRIES) {
|
||||||
if (asinOf(item, country)) await deleteQueryAsinCountryAsin(item.id, country)
|
if (asinOf(item, country)) await deleteQueryAsinCountryAsin(item.id, country)
|
||||||
@@ -81,7 +77,7 @@ async function removeShopAsin(item: QueryAsinItem) {
|
|||||||
ElMessage.success('已删除')
|
ElMessage.success('已删除')
|
||||||
await load()
|
await load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +102,7 @@ async function saveConfig(): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (errors.length) {
|
if (errors.length) {
|
||||||
showAdminFeedback(errors.join(';'), 'error')
|
ElMessage.error(errors.join(';'))
|
||||||
} else {
|
} else {
|
||||||
ElMessage.success('保存成功')
|
ElMessage.success('保存成功')
|
||||||
drawerVisible.value = false
|
drawerVisible.value = false
|
||||||
@@ -155,7 +151,7 @@ async function onCreateGroupChange(): Promise<void> {
|
|||||||
shopNames.value = await fetchShopNamesByGroup(createGroupId.value, companyTab.requestCompanyId)
|
shopNames.value = await fetchShopNamesByGroup(createGroupId.value, companyTab.requestCompanyId)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
shopNames.value = []
|
shopNames.value = []
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '店铺列表加载失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '店铺列表加载失败')
|
||||||
} finally {
|
} finally {
|
||||||
shopNamesLoading.value = false
|
shopNamesLoading.value = false
|
||||||
}
|
}
|
||||||
@@ -246,7 +242,7 @@ async function submitImport(): Promise<void> {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (importMode.value === 'delete') {
|
if (importMode.value === 'delete') {
|
||||||
if (!(await openAdminConfirm({ message: '确定按 Excel 中的分组、店铺名和国家 ASIN 批量删除吗?', danger: true }))) return
|
if (!window.confirm('确定按 Excel 中的分组、店铺名和国家 ASIN 批量删除吗?')) return
|
||||||
}
|
}
|
||||||
const mode = importMode.value
|
const mode = importMode.value
|
||||||
const groupId = importGroupId.value ?? undefined
|
const groupId = importGroupId.value ?? undefined
|
||||||
@@ -267,7 +263,7 @@ async function submitImport(): Promise<void> {
|
|||||||
if (progress.status === 'failed') {
|
if (progress.status === 'failed') {
|
||||||
importVisible.value = false
|
importVisible.value = false
|
||||||
resetImport()
|
resetImport()
|
||||||
showAdminFeedback((progress as { errorMessage?: string }).errorMessage || (mode === 'add' ? '导入失败' : '删除导入失败'), 'error')
|
ElMessage.error((progress as { errorMessage?: string }).errorMessage || (mode === 'add' ? '导入失败' : '删除导入失败'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
importProgress.value = progress.status === 'pending' ? '等待导入任务开始…' : '导入处理中…'
|
importProgress.value = progress.status === 'pending' ? '等待导入任务开始…' : '导入处理中…'
|
||||||
@@ -275,7 +271,7 @@ async function submitImport(): Promise<void> {
|
|||||||
}
|
}
|
||||||
throw new Error('查询导入进度超时,请稍后刷新列表确认结果')
|
throw new Error('查询导入进度超时,请稍后刷新列表确认结果')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '导入失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '导入失败')
|
||||||
} finally {
|
} finally {
|
||||||
importRunning.value = false
|
importRunning.value = false
|
||||||
}
|
}
|
||||||
@@ -302,7 +298,6 @@ async function loadGroups() {
|
|||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
try {
|
||||||
const result = await fetchQueryAsinList({
|
const result = await fetchQueryAsinList({
|
||||||
page: page.value,
|
page: page.value,
|
||||||
@@ -317,8 +312,7 @@ async function load() {
|
|||||||
total.value = result.total
|
total.value = result.total
|
||||||
page.value = result.page
|
page.value = result.page
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loadFailure.value = error instanceof Error ? error.message : '数据加载失败'
|
ElMessage.error(error instanceof Error ? error.message : '数据加载失败')
|
||||||
showAdminFeedback(loadFailure.value, 'error')
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
@@ -400,7 +394,6 @@ onMounted(() => {
|
|||||||
<button class="btn btn-secondary" type="button" @click="doExport">导出 XLSX</button>
|
<button class="btn btn-secondary" type="button" @click="doExport">导出 XLSX</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
|
||||||
<div class="table-scroll query-asin-table-scroll">
|
<div class="table-scroll query-asin-table-scroll">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -412,7 +405,7 @@ onMounted(() => {
|
|||||||
<th style="width: 12%">国家</th>
|
<th style="width: 12%">国家</th>
|
||||||
<th style="width: 170px">创建时间</th>
|
<th style="width: 170px">创建时间</th>
|
||||||
<th style="width: 170px">更新时间</th>
|
<th style="width: 170px">更新时间</th>
|
||||||
<th style="width: 140px">操作</th>
|
<th style="width: 9%">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -730,9 +723,6 @@ h3 {
|
|||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
/* 与最低价 ASIN 同形:列宽已从 9% 改成 140px 下限,再补 wrap 兜住文案变长的情况,
|
|
||||||
让"超宽"从"按钮静默消失"退化成"多占一行"。 */
|
|
||||||
flex-wrap: wrap;
|
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
box-shadow: -9px 0 12px -10px rgba(31, 48, 66, 0.45);
|
box-shadow: -9px 0 12px -10px rgba(31, 48, 66, 0.45);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,6 @@ import type { ShopGroupOption } from '../shop/shop-dto.ts'
|
|||||||
import OldPagination from '@/components/OldPagination.vue'
|
import OldPagination from '@/components/OldPagination.vue'
|
||||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
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 session = useAdminSessionStore()
|
||||||
const companyTab = useCompanyTabStore()
|
const companyTab = useCompanyTabStore()
|
||||||
@@ -29,7 +26,6 @@ const companyTab = useCompanyTabStore()
|
|||||||
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const loadFailure = ref('')
|
|
||||||
const rows = ref<SkipPriceItem[]>([])
|
const rows = ref<SkipPriceItem[]>([])
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
const page = ref(1)
|
const page = ref(1)
|
||||||
@@ -99,7 +95,7 @@ async function onCreateGroupChange(): Promise<void> {
|
|||||||
shopNames.value = await fetchShopNamesByGroup(createGroupId.value, companyTab.requestCompanyId)
|
shopNames.value = await fetchShopNamesByGroup(createGroupId.value, companyTab.requestCompanyId)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
shopNames.value = []
|
shopNames.value = []
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '店铺列表加载失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '店铺列表加载失败')
|
||||||
} finally {
|
} finally {
|
||||||
shopNamesLoading.value = false
|
shopNamesLoading.value = false
|
||||||
}
|
}
|
||||||
@@ -212,7 +208,7 @@ async function saveConfig(): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (errors.length) {
|
if (errors.length) {
|
||||||
showAdminFeedback(errors.join(';'), 'error')
|
ElMessage.error(errors.join(';'))
|
||||||
} else {
|
} else {
|
||||||
ElMessage.success('保存成功')
|
ElMessage.success('保存成功')
|
||||||
drawerVisible.value = false
|
drawerVisible.value = false
|
||||||
@@ -244,7 +240,7 @@ async function removeRow(item: SkipPriceItem): Promise<void> {
|
|||||||
}
|
}
|
||||||
await load()
|
await load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,7 +296,7 @@ async function submitImport(): Promise<void> {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (importMode.value === 'delete') {
|
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 mode = importMode.value
|
||||||
const groupId = importGroupId.value as number
|
const groupId = importGroupId.value as number
|
||||||
@@ -321,7 +317,7 @@ async function submitImport(): Promise<void> {
|
|||||||
if (progress.status === 'failed') {
|
if (progress.status === 'failed') {
|
||||||
importVisible.value = false
|
importVisible.value = false
|
||||||
resetImport()
|
resetImport()
|
||||||
showAdminFeedback(progress.errorMessage || (mode === 'add' ? '导入失败' : '删除导入失败'), 'error')
|
ElMessage.error(progress.errorMessage || (mode === 'add' ? '导入失败' : '删除导入失败'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
importProgress.value = progress.status === 'pending' ? '等待导入任务开始…' : '导入处理中…'
|
importProgress.value = progress.status === 'pending' ? '等待导入任务开始…' : '导入处理中…'
|
||||||
@@ -329,7 +325,7 @@ async function submitImport(): Promise<void> {
|
|||||||
}
|
}
|
||||||
throw new Error('查询导入进度超时,请稍后刷新列表确认结果')
|
throw new Error('查询导入进度超时,请稍后刷新列表确认结果')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '导入失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '导入失败')
|
||||||
} finally {
|
} finally {
|
||||||
importRunning.value = false
|
importRunning.value = false
|
||||||
}
|
}
|
||||||
@@ -355,15 +351,13 @@ async function loadGroups() {
|
|||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
try {
|
||||||
const result = await fetchSkipPriceList(toSkipPriceParams(filter, page.value, pageSize.value, companyTab.requestCompanyId))
|
const result = await fetchSkipPriceList(toSkipPriceParams(filter, page.value, pageSize.value, companyTab.requestCompanyId))
|
||||||
rows.value = result.items
|
rows.value = result.items
|
||||||
total.value = result.total
|
total.value = result.total
|
||||||
page.value = result.page
|
page.value = result.page
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loadFailure.value = error instanceof Error ? error.message : '数据加载失败'
|
ElMessage.error(error instanceof Error ? error.message : '数据加载失败')
|
||||||
showAdminFeedback(loadFailure.value, 'error')
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
@@ -453,7 +447,6 @@ onMounted(() => {
|
|||||||
<button class="btn btn-secondary" type="button" @click="doExport">导出 XLSX</button>
|
<button class="btn btn-secondary" type="button" @click="doExport">导出 XLSX</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
|
||||||
<div class="table-scroll skip-price-asin-table-scroll">
|
<div class="table-scroll skip-price-asin-table-scroll">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -466,7 +459,7 @@ onMounted(() => {
|
|||||||
<th style="width: 10%">最低价</th>
|
<th style="width: 10%">最低价</th>
|
||||||
<th style="width: 170px">创建时间</th>
|
<th style="width: 170px">创建时间</th>
|
||||||
<th style="width: 170px">更新时间</th>
|
<th style="width: 170px">更新时间</th>
|
||||||
<th style="width: 140px">操作</th>
|
<th style="width: 9%">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -812,10 +805,6 @@ h3 {
|
|||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
white-space: nowrap;
|
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;
|
background: #ffffff;
|
||||||
box-shadow: -9px 0 12px -10px rgba(31, 48, 66, 0.45);
|
box-shadow: -9px 0 12px -10px rgba(31, 48, 66, 0.45);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,14 @@
|
|||||||
/**
|
/** 去重汇总导入启动适配(任务 65):multipart POST /import(file+groupId) → importId。 */
|
||||||
* 去重汇总导入启动适配(任务 65):multipart POST /import(file+groupId+company_id) → importId。
|
|
||||||
*
|
|
||||||
* <p>company_id 决定这批数据写进哪一家:超管认页面上方 tab,非超管 requestCompanyId 为 null
|
|
||||||
* ⇒ 一个字段都不发,后端按会话恒锁本公司。</p>
|
|
||||||
*/
|
|
||||||
import { http } from '@/api/http'
|
import { http } from '@/api/http'
|
||||||
import { parseDedupeImportProgress, parseDedupeImportStart, type DedupeImportProgress } from './dedupe-import-model'
|
import { parseDedupeImportProgress, parseDedupeImportStart, type DedupeImportProgress } from './dedupe-import-model'
|
||||||
|
|
||||||
export const DEDUPE_IMPORT_ENDPOINT = '/api/admin/dedupe-total-data/import'
|
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 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()
|
const form = new FormData()
|
||||||
form.append('file', file, file.name)
|
form.append('file', file, file.name)
|
||||||
form.append('groupId', String(groupId))
|
form.append('groupId', String(groupId))
|
||||||
if (companyId != null) form.append('company_id', String(companyId))
|
|
||||||
const { data } = await http.post<unknown>(DEDUPE_IMPORT_ENDPOINT, form)
|
const { data } = await http.post<unknown>(DEDUPE_IMPORT_ENDPOINT, form)
|
||||||
return parseDedupeImportStart(data)
|
return parseDedupeImportStart(data)
|
||||||
}
|
}
|
||||||
@@ -26,12 +20,10 @@ export async function fetchDedupeImportProgress(importId: string): Promise<Dedup
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 删除导入启动:multipart POST /delete-import(file+groupId) → importId。 */
|
/** 删除导入启动:multipart POST /delete-import(file+groupId) → importId。 */
|
||||||
export async function startDedupeDeleteImport(file: File, groupId: number,
|
export async function startDedupeDeleteImport(file: File, groupId: number): Promise<string> {
|
||||||
companyId?: number | null): Promise<string> {
|
|
||||||
const form = new FormData()
|
const form = new FormData()
|
||||||
form.append('file', file, file.name)
|
form.append('file', file, file.name)
|
||||||
form.append('groupId', String(groupId))
|
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)
|
const { data } = await http.post<unknown>(DEDUPE_DELETE_IMPORT_ENDPOINT, form)
|
||||||
return parseDedupeImportStart(data)
|
return parseDedupeImportStart(data)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,288 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
/** 批量编辑分类对话框(2026-11-17 用户口径「店铺分类弹窗删了,加个批量编辑分类」):
|
|
||||||
* 京东数据库页勾选商品(翻页累计,由页面持有勾选集)→ 本对话框选目标分类或移出分类 →
|
|
||||||
* 一次批量归类。归属写「本组」的归属行(biz_jd_product_group_assign,V203 一组一商品一行),
|
|
||||||
* 归类不置人工编辑锁(采集照常更新价格/库存)。本组无分类时只有提示不给提交
|
|
||||||
* (移出对未分类行是无谓操作),引导去工具栏「分类管理」新建(2026-11-17 独立页并回本页)。 */
|
|
||||||
import { computed, ref, watch } from 'vue'
|
|
||||||
import { batchAssignJdProductGroup, type JdProductGroup } from './jd-product-api.ts'
|
|
||||||
import { requestErrorMessage } from '../../api/envelope.ts'
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
visible: boolean
|
|
||||||
/** 当前数据权限分组(归类的落点组;V203 同一商品在其他组可另归一类)。 */
|
|
||||||
ownerGroupId: number
|
|
||||||
ownerGroupName: string
|
|
||||||
/** 当前分组的分类选项(含商品数徽标;由页面在打开时刷新)。 */
|
|
||||||
categories: JdProductGroup[]
|
|
||||||
/** 页面持有的勾选集(跨页累计),展开成 id 数组传入。 */
|
|
||||||
selectedIds: number[]
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const emit = defineEmits<{ (event: 'close'): void; (event: 'done', updated: number, targetName: string | null): void }>()
|
|
||||||
|
|
||||||
/** 选中的目标分类 id;0=移出分类(回到未分类)。 */
|
|
||||||
const pickedId = ref(0)
|
|
||||||
const assigning = ref(false)
|
|
||||||
const errorText = ref('')
|
|
||||||
|
|
||||||
const picked = computed(() => props.categories.find((group) => group.id === pickedId.value) || null)
|
|
||||||
const confirmText = computed(() => (picked.value ? `归入「${picked.value.name}」` : '移出分类'))
|
|
||||||
/** 提交条件:有勾选、未在提交中,且选了目标分类(pickedId>0)或选了移出(pickedId=0,
|
|
||||||
* 但本组得有分类可移——全组无分类时移出是无谓操作,整对话框只留提示)。 */
|
|
||||||
const canSubmit = computed(() => props.selectedIds.length > 0 && !assigning.value
|
|
||||||
&& (picked.value ? true : props.categories.length > 0))
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.visible,
|
|
||||||
(visible) => {
|
|
||||||
if (visible) {
|
|
||||||
pickedId.value = 0
|
|
||||||
errorText.value = ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
async function submit(): Promise<void> {
|
|
||||||
if (!canSubmit.value) return
|
|
||||||
const target = picked.value
|
|
||||||
assigning.value = true
|
|
||||||
errorText.value = ''
|
|
||||||
try {
|
|
||||||
// target null=移出分类(groupId 传 null,后端只解挂本组归属行)。
|
|
||||||
const updated = await batchAssignJdProductGroup(
|
|
||||||
props.selectedIds,
|
|
||||||
target ? target.id : null,
|
|
||||||
props.ownerGroupId,
|
|
||||||
)
|
|
||||||
emit('done', updated, target ? target.name : null)
|
|
||||||
emit('close')
|
|
||||||
} catch (error) {
|
|
||||||
errorText.value = requestErrorMessage(error) || '批量归类失败'
|
|
||||||
} finally {
|
|
||||||
assigning.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div v-if="visible" class="modal-mask" @click.self="emit('close')">
|
|
||||||
<div class="batch-modal">
|
|
||||||
<div class="modal-head">
|
|
||||||
<h3>批量编辑分类<span v-if="ownerGroupName" class="modal-sub">· {{ ownerGroupName }}</span></h3>
|
|
||||||
<button class="modal-close" type="button" aria-label="关闭" @click="emit('close')">×</button>
|
|
||||||
</div>
|
|
||||||
<p class="modal-tip">
|
|
||||||
已勾选 {{ selectedIds.length }} 个商品(翻页累计)。选目标分类后确认;
|
|
||||||
归类只记在分类归属上,不影响采集对价格/库存的更新。
|
|
||||||
</p>
|
|
||||||
<p v-if="errorText" class="group-error">{{ errorText }}</p>
|
|
||||||
|
|
||||||
<div v-if="!categories.length" class="batch-empty">本组暂无分类,先用工具栏「分类管理」新建一个</div>
|
|
||||||
<ul v-else class="option-list">
|
|
||||||
<li
|
|
||||||
v-for="group in categories"
|
|
||||||
:key="group.id"
|
|
||||||
class="option-row"
|
|
||||||
:class="{ active: pickedId === group.id }"
|
|
||||||
@click="pickedId = group.id"
|
|
||||||
>
|
|
||||||
<span class="option-radio" aria-hidden="true"></span>
|
|
||||||
<span class="option-name" :title="group.name">{{ group.name }}</span>
|
|
||||||
<span class="option-meta">{{ group.productCount }}</span>
|
|
||||||
</li>
|
|
||||||
<li class="option-row option-detach" :class="{ active: pickedId === 0 }" @click="pickedId = 0">
|
|
||||||
<span class="option-radio" aria-hidden="true"></span>
|
|
||||||
<span class="option-name">移出分类</span>
|
|
||||||
<span class="option-meta">回到未分类</span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<div class="modal-foot">
|
|
||||||
<button class="btn btn-secondary" type="button" @click="emit('close')">取消</button>
|
|
||||||
<button class="btn" type="button" :disabled="!canSubmit" @click="submit">
|
|
||||||
{{ assigning ? '提交中...' : confirmText }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.modal-mask {
|
|
||||||
position: fixed;
|
|
||||||
inset: 0;
|
|
||||||
z-index: 2800;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 40px 20px;
|
|
||||||
background: rgba(45, 66, 86, 0.36);
|
|
||||||
backdrop-filter: blur(6px);
|
|
||||||
}
|
|
||||||
.batch-modal {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
width: min(430px, 100%);
|
|
||||||
max-height: 80vh;
|
|
||||||
padding: 18px 20px 20px;
|
|
||||||
border: 1px solid #c7d7e5;
|
|
||||||
border-radius: 14px;
|
|
||||||
background: #ffffff;
|
|
||||||
box-shadow: 0 22px 60px rgba(39, 67, 94, 0.2);
|
|
||||||
}
|
|
||||||
.modal-head {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
.modal-head h3 {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 15px;
|
|
||||||
font-weight: 650;
|
|
||||||
color: #24384d;
|
|
||||||
}
|
|
||||||
.modal-sub {
|
|
||||||
margin-left: 6px;
|
|
||||||
color: #5b6f83;
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
.modal-close {
|
|
||||||
width: 30px;
|
|
||||||
height: 30px;
|
|
||||||
border: 1px solid transparent;
|
|
||||||
border-radius: 9px;
|
|
||||||
background: none;
|
|
||||||
color: #5b6f83;
|
|
||||||
font-size: 20px;
|
|
||||||
line-height: 1;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.modal-close:hover {
|
|
||||||
border-color: #cbd9e6;
|
|
||||||
background: #eef4fa;
|
|
||||||
color: #24384d;
|
|
||||||
}
|
|
||||||
.modal-tip {
|
|
||||||
margin: 8px 0 10px;
|
|
||||||
color: #8293a5;
|
|
||||||
font-size: 12.5px;
|
|
||||||
line-height: 1.5;
|
|
||||||
}
|
|
||||||
.group-error {
|
|
||||||
margin: 0 0 8px;
|
|
||||||
padding: 10px 12px;
|
|
||||||
border: 1px solid #f0c9c2;
|
|
||||||
border-radius: 10px;
|
|
||||||
background: #fdf1ef;
|
|
||||||
color: #a04432;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
.batch-empty {
|
|
||||||
padding: 26px 12px;
|
|
||||||
border: 1px dashed #cbd9e6;
|
|
||||||
border-radius: 10px;
|
|
||||||
color: #8293a5;
|
|
||||||
font-size: 13px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
.option-list {
|
|
||||||
flex: 1;
|
|
||||||
min-height: 0;
|
|
||||||
overflow-y: auto;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
list-style: none;
|
|
||||||
border-top: 1px solid #e7eef5;
|
|
||||||
}
|
|
||||||
.option-row {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
padding: 10px 8px;
|
|
||||||
border-bottom: 1px solid #e7eef5;
|
|
||||||
font-size: 13.5px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.option-row:hover {
|
|
||||||
background: #f1f7fb;
|
|
||||||
}
|
|
||||||
/* 点亮=归类目标:与旧弹窗左栏同款左缘蓝条。 */
|
|
||||||
.option-row.active {
|
|
||||||
background: #e8f1fa;
|
|
||||||
box-shadow: inset 3px 0 0 #4f78a5;
|
|
||||||
}
|
|
||||||
.option-radio {
|
|
||||||
flex: none;
|
|
||||||
width: 14px;
|
|
||||||
height: 14px;
|
|
||||||
border: 1.6px solid #9fb7cd;
|
|
||||||
border-radius: 50%;
|
|
||||||
background: #ffffff;
|
|
||||||
}
|
|
||||||
.option-row.active .option-radio {
|
|
||||||
border-color: #4f78a5;
|
|
||||||
background: radial-gradient(circle, #4f78a5 0 4px, #ffffff 4.6px);
|
|
||||||
}
|
|
||||||
.option-name {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
color: #24384d;
|
|
||||||
}
|
|
||||||
.option-detach .option-name {
|
|
||||||
color: #a04432;
|
|
||||||
}
|
|
||||||
.option-meta {
|
|
||||||
flex: none;
|
|
||||||
min-width: 22px;
|
|
||||||
padding: 1px 7px;
|
|
||||||
border-radius: 9px;
|
|
||||||
background: #eef4fa;
|
|
||||||
color: #4e6479;
|
|
||||||
font-size: 12px;
|
|
||||||
text-align: center;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.option-detach .option-meta {
|
|
||||||
background: transparent;
|
|
||||||
color: #8293a5;
|
|
||||||
}
|
|
||||||
.modal-foot {
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 10px;
|
|
||||||
margin-top: 14px;
|
|
||||||
}
|
|
||||||
.btn {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
min-height: 38px;
|
|
||||||
padding: 7px 16px;
|
|
||||||
border: 1px solid #4f78a5;
|
|
||||||
border-radius: 9px;
|
|
||||||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
|
||||||
color: #ffffff;
|
|
||||||
font-family: inherit;
|
|
||||||
font-size: 13px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.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;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,469 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
/** 京东数据库「类目」筛选的京麦同款级联面板(2026-11-16 客户口径「京麦类目是这些 我们
|
|
||||||
* 后台的现在的不对」+「你直接爬」→ 树数据换成京麦授权类目真树,见 ./jd-category-tree.ts
|
|
||||||
* 头注释的取证来源与边界)。
|
|
||||||
*
|
|
||||||
* 交互(京麦真机同款,2026-11-16 面板逐级点开取证):面板按点亮路径动态出栏——第一栏
|
|
||||||
* 一级(3 个)、后续栏=点亮节点的 children(最深 4 栏);**非末级行点击=下钻**(推进
|
|
||||||
* 路径)、**末级行(children 空)点击=选中**(radio 蓝,emit change→按 category_path
|
|
||||||
* 等值过滤,后端契约零改动)。搜索框搜**树内全部末级**(名称或路径命中,行 title 带
|
|
||||||
* 全路径);树外命中(已落库但京麦类目体系变更后的历史名)从 options 兜底段选,语义
|
|
||||||
* 同旧版第三栏。「全部类目」行=清选;触发框已选时出 × 清除;面板外点透明遮罩关闭。
|
|
||||||
* 零依赖自绘(radio 圆点/箭头都是 CSS),无 element 依赖。 */
|
|
||||||
import { computed, nextTick, ref, watch } from 'vue'
|
|
||||||
import {
|
|
||||||
jdCategoryChildren,
|
|
||||||
jdCategoryRoots,
|
|
||||||
jdCategorySearchLeaves,
|
|
||||||
type JdCategoryNode,
|
|
||||||
} from './jd-category-tree.ts'
|
|
||||||
import { clampPanelLeftX } from './jd-category-cascader-position.ts'
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
/** 已落库末级类目全集(/categories 现算,页面传入)——只作**树外兜底**(搜索无树内
|
|
||||||
* 命中时列出「已落库类目(树外历史)」段),不再默认铺第三栏。 */
|
|
||||||
options?: { name: string; productCount: number }[]
|
|
||||||
/** 当前选中末级类目名;'' = 全部类目。 */
|
|
||||||
modelValue: string
|
|
||||||
groups?: { id: number; name: string; productCount: number }[]
|
|
||||||
groupId?: string
|
|
||||||
createVersion?: number
|
|
||||||
busy?: boolean
|
|
||||||
treeOnly?: boolean
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
(event: 'change', value: string): void
|
|
||||||
(event: 'group', value: string): void
|
|
||||||
(event: 'create-group', value: string): void
|
|
||||||
(event: 'delete-group', id: number): void
|
|
||||||
}>()
|
|
||||||
const newGroupName = ref('')
|
|
||||||
watch(() => props.createVersion, () => { newGroupName.value = '' })
|
|
||||||
function createGroup(): void {
|
|
||||||
const name = newGroupName.value.trim()
|
|
||||||
if (name) emit('create-group', name)
|
|
||||||
}
|
|
||||||
function pickGroup(id: number): void {
|
|
||||||
emit('group', String(id))
|
|
||||||
close()
|
|
||||||
}
|
|
||||||
|
|
||||||
const open = ref(false)
|
|
||||||
/** 已下钻的节点名路径(非末级行点击推进)。 */
|
|
||||||
const activePath = ref<string[]>([])
|
|
||||||
const searchText = ref('')
|
|
||||||
|
|
||||||
/** 面板水平定位钳制(2026-11-16「超出视窗了」):触发框在筛选行中部偏右时,锚 left:0
|
|
||||||
* 的多栏面板会伸出视窗右缘。打开与栏数/搜索态变化后用真实 rect 重算 left 偏移——
|
|
||||||
* 右缘贴齐视口后继续下钻即向左生长,不再截掉末栏。钳制数学在
|
|
||||||
* ./jd-category-cascader-position.ts(纯函数,tests/jd-category-cascader-position.test.ts)。 */
|
|
||||||
const hostRef = ref<HTMLElement | null>(null)
|
|
||||||
const panelRef = ref<HTMLElement | null>(null)
|
|
||||||
const panelOffsetX = ref(0)
|
|
||||||
|
|
||||||
function reposition(): void {
|
|
||||||
const host = hostRef.value
|
|
||||||
const panel = panelRef.value
|
|
||||||
if (!host || !panel) return
|
|
||||||
panelOffsetX.value = clampPanelLeftX({
|
|
||||||
hostLeft: host.getBoundingClientRect().left,
|
|
||||||
panelWidth: panel.offsetWidth,
|
|
||||||
viewportWidth: window.innerWidth,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const roots = jdCategoryRoots()
|
|
||||||
/** 树内全部末级名集合(判定 options 哪些是「树外历史」)。 */
|
|
||||||
const treeLeafNames = new Set(
|
|
||||||
jdCategorySearchLeaves('').map((leaf) => leaf.name),
|
|
||||||
)
|
|
||||||
|
|
||||||
/** 面板各栏内容:第 0 栏一级,第 i+1 栏=点亮路径前 i+1 个的 children(路径推进到
|
|
||||||
* 末级时末栏是叶子所在栏,children 空不出栏——栏数随路径动态 1~4)。 */
|
|
||||||
const columns = computed<JdCategoryNode[][]>(() => {
|
|
||||||
const cols: JdCategoryNode[][] = [roots]
|
|
||||||
for (let i = 0; i < activePath.value.length; i++) {
|
|
||||||
const children = jdCategoryChildren(activePath.value.slice(0, i + 1))
|
|
||||||
if (!children.length) break
|
|
||||||
cols.push(children)
|
|
||||||
}
|
|
||||||
return cols
|
|
||||||
})
|
|
||||||
|
|
||||||
/** 搜索激活=搜索词非空:面板切换成扁平末级结果列表。 */
|
|
||||||
const searching = computed(() => searchText.value.trim().length > 0)
|
|
||||||
|
|
||||||
/** 树内命中末级(名称或路径段命中)。 */
|
|
||||||
const searchLeaves = computed(() =>
|
|
||||||
searching.value ? jdCategorySearchLeaves(searchText.value) : [],
|
|
||||||
)
|
|
||||||
|
|
||||||
/** 树外兜底:options 里不在树名集的行按搜索词过滤(历史行仍可选中过滤)。 */
|
|
||||||
const fallbackOptions = computed(() => {
|
|
||||||
if (!searching.value) return []
|
|
||||||
const keyword = searchText.value.trim().toLowerCase()
|
|
||||||
return (props.options ?? [])
|
|
||||||
.filter((option) => !treeLeafNames.has(option.name))
|
|
||||||
.filter((option) => option.name.toLowerCase().includes(keyword))
|
|
||||||
})
|
|
||||||
|
|
||||||
/** 栏数随下钻动态 1~4、搜索态切单栏 ⇒ 面板宽度变,开着就要重算偏移(下钻向左生长)。 */
|
|
||||||
watch(
|
|
||||||
() => [columns.value.length, searching.value] as const,
|
|
||||||
() => {
|
|
||||||
if (open.value) nextTick(reposition)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
function toggle(): void {
|
|
||||||
if (open.value) {
|
|
||||||
close()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
activePath.value = []
|
|
||||||
searchText.value = ''
|
|
||||||
open.value = true
|
|
||||||
nextTick(reposition)
|
|
||||||
}
|
|
||||||
|
|
||||||
function close(): void {
|
|
||||||
open.value = false
|
|
||||||
activePath.value = []
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 非末级行点击=下钻;末级行点击=选中并收面板。 */
|
|
||||||
function pick(node: JdCategoryNode, depth: number): void {
|
|
||||||
if (node.children && node.children.length) {
|
|
||||||
activePath.value = [...activePath.value.slice(0, depth), node.name]
|
|
||||||
return
|
|
||||||
}
|
|
||||||
emit('change', node.name)
|
|
||||||
close()
|
|
||||||
}
|
|
||||||
|
|
||||||
function pickAll(): void {
|
|
||||||
emit('change', '')
|
|
||||||
close()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 搜索结果行点击(树内末级或树外兜底行)=按名选中。 */
|
|
||||||
function pickName(name: string): void {
|
|
||||||
emit('change', name)
|
|
||||||
close()
|
|
||||||
}
|
|
||||||
|
|
||||||
function clear(): void {
|
|
||||||
emit('change', '')
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div ref="hostRef" class="cat-cascader">
|
|
||||||
<button
|
|
||||||
class="cat-trigger"
|
|
||||||
type="button"
|
|
||||||
:class="{ open, filled: !!modelValue || !!groupId }"
|
|
||||||
@click="toggle"
|
|
||||||
>
|
|
||||||
<span class="cat-trigger-text" :title="modelValue || ''">{{ groups?.find(group => String(group.id) === groupId)?.name || modelValue || '全部类目' }}</span>
|
|
||||||
<span
|
|
||||||
v-if="modelValue || groupId"
|
|
||||||
class="cat-clear"
|
|
||||||
role="button"
|
|
||||||
aria-label="清除类目"
|
|
||||||
@click.stop="clear"
|
|
||||||
>×</span>
|
|
||||||
<span class="cat-chevron" aria-hidden="true"></span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<!-- 面板外点透明遮罩关闭(零 document 监听器,无泄漏面)。 -->
|
|
||||||
<div v-if="open" class="cat-mask" @click="close"></div>
|
|
||||||
<div v-if="open" ref="panelRef" class="cat-panel" :style="{ left: `${panelOffsetX}px` }">
|
|
||||||
<div v-if="!treeOnly" class="cat-custom cat-col-custom">
|
|
||||||
<div class="cat-seg">自定义分类</div>
|
|
||||||
<form class="cat-create" @submit.prevent="createGroup">
|
|
||||||
<input v-model="newGroupName" class="cat-search" placeholder="新建分类" aria-label="新建分类名称" />
|
|
||||||
<button type="submit" :disabled="busy || !newGroupName.trim()">添加</button>
|
|
||||||
</form>
|
|
||||||
<div v-for="group in groups || []" :key="group.id" class="cat-row" :class="{ active: groupId === String(group.id) }">
|
|
||||||
<button type="button" class="cat-group-pick" :title="group.name" @click="pickGroup(group.id)">{{ group.name }}({{ group.productCount }})</button>
|
|
||||||
<button type="button" :aria-label="`删除分类 ${group.name}`" @click.stop="emit('delete-group', group.id)">删除</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- 搜索态:树内末级命中+树外兜底段(扁平列表,行 title 带全路径)。 -->
|
|
||||||
<template v-if="searching">
|
|
||||||
<div class="cat-col cat-col-search">
|
|
||||||
<div class="cat-search-row"><input v-model="searchText" type="text" class="cat-search" placeholder="搜索类目" /></div>
|
|
||||||
<template v-if="searchLeaves.length || fallbackOptions.length">
|
|
||||||
<div
|
|
||||||
v-for="leaf in searchLeaves"
|
|
||||||
:key="`tree-${leaf.path.join('/')}`"
|
|
||||||
class="cat-row"
|
|
||||||
:class="{ active: modelValue === leaf.name }"
|
|
||||||
:title="leaf.path.join(' > ')"
|
|
||||||
@click="pickName(leaf.name)"
|
|
||||||
>
|
|
||||||
<span class="cat-dot" :class="{ on: modelValue === leaf.name }" aria-hidden="true"></span>
|
|
||||||
<span class="cat-name">{{ leaf.name }}</span>
|
|
||||||
<span class="cat-path">{{ leaf.path.slice(0, -1).join(' › ') }}</span>
|
|
||||||
</div>
|
|
||||||
<div v-if="fallbackOptions.length" class="cat-seg">已落库类目(树外历史)</div>
|
|
||||||
<div
|
|
||||||
v-for="option in fallbackOptions"
|
|
||||||
:key="`db-${option.name}`"
|
|
||||||
class="cat-row"
|
|
||||||
:class="{ active: modelValue === option.name }"
|
|
||||||
:title="option.name"
|
|
||||||
@click="pickName(option.name)"
|
|
||||||
>
|
|
||||||
<span class="cat-dot" :class="{ on: modelValue === option.name }" aria-hidden="true"></span>
|
|
||||||
<span class="cat-name">{{ option.name }}</span>
|
|
||||||
<span class="cat-count">{{ option.productCount }}</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<div v-else class="cat-empty">未找到类目</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<!-- 下钻态:逐级动态栏;首栏顶部「全部类目」行=清选。 -->
|
|
||||||
<template v-else>
|
|
||||||
<div
|
|
||||||
v-for="(col, depth) in columns"
|
|
||||||
:key="depth"
|
|
||||||
class="cat-col"
|
|
||||||
>
|
|
||||||
<div v-if="depth === 0" class="cat-search-row">
|
|
||||||
<input
|
|
||||||
v-model="searchText"
|
|
||||||
type="text"
|
|
||||||
class="cat-search"
|
|
||||||
placeholder="搜索类目"
|
|
||||||
@click.stop
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div v-if="depth === 0" class="cat-row cat-row-all" :class="{ active: !modelValue }" @click="pickAll">
|
|
||||||
<span class="cat-dot" :class="{ on: !modelValue }" aria-hidden="true"></span>
|
|
||||||
<span class="cat-name">全部类目</span>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-for="node in col"
|
|
||||||
:key="`${depth}-${node.name}`"
|
|
||||||
class="cat-row"
|
|
||||||
:class="{ active: activePath[depth] === node.name || (depth === 0 && modelValue === node.name) }"
|
|
||||||
:title="node.name"
|
|
||||||
@click="pick(node, depth)"
|
|
||||||
>
|
|
||||||
<span class="cat-dot" aria-hidden="true"></span>
|
|
||||||
<span class="cat-name">{{ node.name }}</span>
|
|
||||||
<span v-if="node.children && node.children.length" class="cat-arrow" aria-hidden="true">›</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.cat-custom { flex: none; width: 200px; max-height: 340px; overflow-y: auto; border-right: 1px solid #e7eef5; }
|
|
||||||
.cat-create { display: flex; gap: 4px; padding: 6px 8px; }
|
|
||||||
.cat-create input { min-width: 0; }
|
|
||||||
.cat-group-pick { flex: 1; min-width: 0; text-align: left; border: 0; background: transparent; color: inherit; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
||||||
.cat-cascader {
|
|
||||||
position: relative;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
/* 触发框像素对齐页面 .form-group select(42 高/9 圆角/#cbd9e6 边框/#f8fbfd 底)。 */
|
|
||||||
.cat-trigger {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 6px;
|
|
||||||
width: 100%;
|
|
||||||
min-height: 42px;
|
|
||||||
padding: 8px 12px;
|
|
||||||
border: 1px solid #cbd9e6;
|
|
||||||
border-radius: 9px;
|
|
||||||
background: #f8fbfd;
|
|
||||||
color: #24384d;
|
|
||||||
font-size: 13.5px;
|
|
||||||
font-family: inherit;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
|
||||||
}
|
|
||||||
.cat-trigger:hover {
|
|
||||||
border-color: #9fb7cd;
|
|
||||||
}
|
|
||||||
.cat-trigger.open,
|
|
||||||
.cat-trigger:focus {
|
|
||||||
background: #ffffff;
|
|
||||||
border-color: #5f85ad;
|
|
||||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
|
||||||
}
|
|
||||||
.cat-trigger-text {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
.cat-trigger:not(.filled) .cat-trigger-text {
|
|
||||||
color: #8293a5;
|
|
||||||
}
|
|
||||||
.cat-clear {
|
|
||||||
flex: none;
|
|
||||||
width: 18px;
|
|
||||||
height: 18px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
border-radius: 50%;
|
|
||||||
background: #e7eef5;
|
|
||||||
color: #5b6f83;
|
|
||||||
font-size: 13px;
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
.cat-clear:hover {
|
|
||||||
background: #dbe7f1;
|
|
||||||
color: #24384d;
|
|
||||||
}
|
|
||||||
/* 下拉箭头:CSS 三角(京麦同款向下 chevron,展开翻向上)。 */
|
|
||||||
.cat-chevron {
|
|
||||||
flex: none;
|
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
border-left: 5px solid transparent;
|
|
||||||
border-right: 5px solid transparent;
|
|
||||||
border-top: 6px solid #7b8a99;
|
|
||||||
transition: transform 160ms ease;
|
|
||||||
}
|
|
||||||
.cat-trigger.open .cat-chevron {
|
|
||||||
transform: rotate(180deg);
|
|
||||||
}
|
|
||||||
.cat-mask {
|
|
||||||
position: fixed;
|
|
||||||
inset: 0;
|
|
||||||
z-index: 2550;
|
|
||||||
}
|
|
||||||
.cat-panel {
|
|
||||||
position: absolute;
|
|
||||||
top: calc(100% + 4px);
|
|
||||||
left: 0;
|
|
||||||
z-index: 2560;
|
|
||||||
display: flex;
|
|
||||||
align-items: stretch;
|
|
||||||
max-width: min(820px, 90vw);
|
|
||||||
border: 1px solid #d8e3ee;
|
|
||||||
border-radius: 10px;
|
|
||||||
background: #ffffff;
|
|
||||||
box-shadow: 0 16px 44px rgba(39, 67, 94, 0.18);
|
|
||||||
overflow-x: auto;
|
|
||||||
overflow-y: hidden;
|
|
||||||
}
|
|
||||||
.cat-col {
|
|
||||||
flex: none;
|
|
||||||
width: 200px;
|
|
||||||
max-height: 340px;
|
|
||||||
overflow-y: auto;
|
|
||||||
padding: 6px 0;
|
|
||||||
border-right: 1px solid #e7eef5;
|
|
||||||
}
|
|
||||||
.cat-col:last-child {
|
|
||||||
border-right: 0;
|
|
||||||
}
|
|
||||||
.cat-col-search {
|
|
||||||
width: 300px;
|
|
||||||
}
|
|
||||||
/* 行=京麦同款:圆点 radio + 名称 + 右箭头;hover 浅蓝底。 */
|
|
||||||
.cat-row {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
padding: 8px 12px;
|
|
||||||
font-size: 13.5px;
|
|
||||||
color: #24384d;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.cat-row:hover,
|
|
||||||
.cat-row.active {
|
|
||||||
background: #f1f7fb;
|
|
||||||
}
|
|
||||||
.cat-row.active {
|
|
||||||
color: #2f5d8b;
|
|
||||||
font-weight: 550;
|
|
||||||
}
|
|
||||||
.cat-dot {
|
|
||||||
flex: none;
|
|
||||||
width: 13px;
|
|
||||||
height: 13px;
|
|
||||||
border: 1px solid #c0ccda;
|
|
||||||
border-radius: 50%;
|
|
||||||
background: #ffffff;
|
|
||||||
}
|
|
||||||
/* radio 选中=京麦同款蓝芯。 */
|
|
||||||
.cat-dot.on {
|
|
||||||
border-color: #3b82c4;
|
|
||||||
background: radial-gradient(circle, #3b82c4 0 4px, #ffffff 4.6px);
|
|
||||||
}
|
|
||||||
.cat-name {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
/* 搜索态行尾的路径灰字(同名跨支时定位用)。 */
|
|
||||||
.cat-path {
|
|
||||||
flex: none;
|
|
||||||
max-width: 110px;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
color: #9fb0c0;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
.cat-arrow {
|
|
||||||
flex: none;
|
|
||||||
color: #9fb0c0;
|
|
||||||
font-size: 15px;
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
.cat-count {
|
|
||||||
flex: none;
|
|
||||||
color: #8293a5;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
.cat-seg {
|
|
||||||
padding: 8px 12px 4px;
|
|
||||||
color: #8293a5;
|
|
||||||
font-size: 11.5px;
|
|
||||||
border-top: 1px solid #e7eef5;
|
|
||||||
}
|
|
||||||
.cat-search-row {
|
|
||||||
padding: 4px 8px 6px;
|
|
||||||
border-bottom: 1px solid #e7eef5;
|
|
||||||
}
|
|
||||||
.cat-search {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
min-height: 30px;
|
|
||||||
padding: 4px 10px;
|
|
||||||
border: 1px solid #cbd9e6;
|
|
||||||
border-radius: 8px;
|
|
||||||
background: #f8fbfd;
|
|
||||||
color: #24384d;
|
|
||||||
font-size: 12.5px;
|
|
||||||
font-family: inherit;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
.cat-search:focus {
|
|
||||||
background: #ffffff;
|
|
||||||
border-color: #5f85ad;
|
|
||||||
}
|
|
||||||
.cat-empty {
|
|
||||||
padding: 16px 12px;
|
|
||||||
color: #8293a5;
|
|
||||||
font-size: 12.5px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,454 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
/** 分类管理对话框(2026-11-17 用户口径「京东分类管理并到京东数据库分类编辑里,
|
|
||||||
* 做一个搜索和添加 删除 编辑 分类名称即可」):原 V204 独立子菜单页(JdCategoryManagerPage)
|
|
||||||
* 整体并入本对话框,从京东数据库页工具栏「分类管理」打开。
|
|
||||||
* 职责不变:当前数据权限分组的分类建/改名/删除+新增的名称搜索;商品归类不在这里
|
|
||||||
* (去「批量编辑分类」)。列表状态自管理(写操作后自刷新并 emit changed 让父页刷筛选下拉)。
|
|
||||||
* 权限口径(V203)不变:本组管理员/公司超管/平台超管可写(editable);同组普通号
|
|
||||||
* 只读可看(无新建行,改名/删除按钮逐行不渲染),后端同口径 403 兜底。 */
|
|
||||||
import { computed, ref, watch } from 'vue'
|
|
||||||
import {
|
|
||||||
createJdProductGroup,
|
|
||||||
deleteJdProductGroup,
|
|
||||||
fetchJdProductGroups,
|
|
||||||
updateJdProductGroup,
|
|
||||||
type JdProductGroup,
|
|
||||||
} from './jd-product-api.ts'
|
|
||||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
|
||||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
|
||||||
import { loadFailureMessage } from '@/components/load-failure-model'
|
|
||||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
|
||||||
import { requestErrorMessage } from '../../api/envelope.ts'
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
visible: boolean
|
|
||||||
/** 当前数据权限分组(分类的作用域;<=0=不属于任何分组,只留空态)。 */
|
|
||||||
ownerGroupId: number
|
|
||||||
ownerGroupName: string
|
|
||||||
/** 当前分组可写(scope 的 editable):建/改名/删除控件全挂它。 */
|
|
||||||
editable: boolean
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const emit = defineEmits<{ (event: 'close'): void; (event: 'changed'): void }>()
|
|
||||||
|
|
||||||
const loading = ref(false)
|
|
||||||
/** 首屏取数失败(可见红条+重试);写操作失败走 errorText 红条(无重试语义)。 */
|
|
||||||
const loadFailure = ref('')
|
|
||||||
const errorText = ref('')
|
|
||||||
const groups = ref<JdProductGroup[]>([])
|
|
||||||
/** 搜索:按分类名称包含过滤(本地过滤,不另发请求)。 */
|
|
||||||
const keyword = ref('')
|
|
||||||
/** 新建:只收名称(排序输入 2026-11-15 客户口径下线,sortOrder 恒 0,后端契约不变)。 */
|
|
||||||
const createName = ref('')
|
|
||||||
const creating = ref(false)
|
|
||||||
/** 改名:正在编辑的分类 id 与草稿名。 */
|
|
||||||
const editingId = ref(0)
|
|
||||||
const editingName = ref('')
|
|
||||||
const saving = ref(false)
|
|
||||||
|
|
||||||
const canCreate = computed(() => props.editable && createName.value.trim().length > 0 && !creating.value && !saving.value)
|
|
||||||
/** 搜索命中(名称包含,大小写不敏感;空关键字=全量)。 */
|
|
||||||
const filteredGroups = computed(() => {
|
|
||||||
const kw = keyword.value.trim().toLowerCase()
|
|
||||||
if (!kw) return groups.value
|
|
||||||
return groups.value.filter((group) => group.name.toLowerCase().includes(kw))
|
|
||||||
})
|
|
||||||
/** 空表文案分四种:不属于任何组 / 本组没分类(可管理)/ 本组没分类(只读)/ 搜索无命中。 */
|
|
||||||
const emptyListText = computed(() => {
|
|
||||||
if (props.ownerGroupId <= 0) return '你还不属于任何数据权限分组'
|
|
||||||
if (!groups.value.length) {
|
|
||||||
return props.editable ? '本组暂无分类,先新建一个' : '本组暂无分类'
|
|
||||||
}
|
|
||||||
return '没有匹配的分类'
|
|
||||||
})
|
|
||||||
|
|
||||||
async function loadGroups(): Promise<void> {
|
|
||||||
if (props.ownerGroupId <= 0) {
|
|
||||||
groups.value = []
|
|
||||||
loading.value = false
|
|
||||||
loadFailure.value = ''
|
|
||||||
errorText.value = ''
|
|
||||||
return
|
|
||||||
}
|
|
||||||
loading.value = true
|
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
|
||||||
groups.value = await fetchJdProductGroups(props.ownerGroupId)
|
|
||||||
} catch (error) {
|
|
||||||
loadFailure.value = loadFailureMessage(error, '分类列表加载失败')
|
|
||||||
groups.value = []
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function submitCreate(): Promise<void> {
|
|
||||||
const name = createName.value.trim()
|
|
||||||
if (!name || creating.value || !props.editable) return
|
|
||||||
creating.value = true
|
|
||||||
errorText.value = ''
|
|
||||||
try {
|
|
||||||
await createJdProductGroup({ name, sortOrder: 0, ownerGroupId: props.ownerGroupId })
|
|
||||||
createName.value = ''
|
|
||||||
keyword.value = ''
|
|
||||||
showAdminFeedback(`已新建分类「${name}」`, 'success')
|
|
||||||
emit('changed')
|
|
||||||
await loadGroups()
|
|
||||||
} catch (error) {
|
|
||||||
errorText.value = requestErrorMessage(error) || '新建分类失败'
|
|
||||||
} finally {
|
|
||||||
creating.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function startRename(group: JdProductGroup): void {
|
|
||||||
editingId.value = group.id
|
|
||||||
editingName.value = group.name
|
|
||||||
errorText.value = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
function cancelRename(): void {
|
|
||||||
editingId.value = 0
|
|
||||||
editingName.value = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
async function submitRename(group: JdProductGroup): Promise<void> {
|
|
||||||
const name = editingName.value.trim()
|
|
||||||
if (!name || saving.value) return
|
|
||||||
saving.value = true
|
|
||||||
errorText.value = ''
|
|
||||||
try {
|
|
||||||
await updateJdProductGroup(group.id, { name, sortOrder: group.sortOrder })
|
|
||||||
groups.value = groups.value.map((item) => (item.id === group.id ? { ...item, name } : item))
|
|
||||||
cancelRename()
|
|
||||||
showAdminFeedback(`已把分类改名为「${name}」`, 'success')
|
|
||||||
emit('changed')
|
|
||||||
} catch (error) {
|
|
||||||
errorText.value = requestErrorMessage(error) || '改名失败'
|
|
||||||
} finally {
|
|
||||||
saving.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 删除分类不删商品:只解挂本组归属行(商品回到未分类),后端 JdProductGroupService.delete。 */
|
|
||||||
async function removeGroup(group: JdProductGroup): Promise<void> {
|
|
||||||
const ok = await openAdminConfirm({ title: '删除分类', message: `确定删除分类「${group.name}」吗?删除后该分类下 ${group.productCount} 个商品回到未分类。`, confirmText: '确认删除', danger: true })
|
|
||||||
if (!ok || saving.value) return
|
|
||||||
saving.value = true
|
|
||||||
errorText.value = ''
|
|
||||||
try {
|
|
||||||
await deleteJdProductGroup(group.id)
|
|
||||||
showAdminFeedback(`已删除分类「${group.name}」`, 'success')
|
|
||||||
emit('changed')
|
|
||||||
await loadGroups()
|
|
||||||
} catch (error) {
|
|
||||||
errorText.value = requestErrorMessage(error) || '删除分类失败'
|
|
||||||
} finally {
|
|
||||||
saving.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.visible,
|
|
||||||
(visible) => {
|
|
||||||
if (visible) {
|
|
||||||
keyword.value = ''
|
|
||||||
errorText.value = ''
|
|
||||||
loadFailure.value = ''
|
|
||||||
cancelRename()
|
|
||||||
createName.value = ''
|
|
||||||
void loadGroups()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// immediate:对话框可能以 visible=true 直接挂载(测试/复用场景),这时也要首取。
|
|
||||||
{ immediate: true },
|
|
||||||
)
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div v-if="visible" class="modal-mask" @click.self="emit('close')">
|
|
||||||
<div class="manage-modal">
|
|
||||||
<div class="modal-head">
|
|
||||||
<h3>分类管理<span v-if="ownerGroupName" class="modal-sub">· {{ ownerGroupName }}</span></h3>
|
|
||||||
<button class="modal-close" type="button" aria-label="关闭" @click="emit('close')">×</button>
|
|
||||||
</div>
|
|
||||||
<p class="modal-tip">
|
|
||||||
分类按「数据权限分组」隔离,当前组{{ editable ? '只组长/超管可维护' : '由组长/超管维护' }};
|
|
||||||
给商品归类:关掉本框,勾选商品后点「批量编辑分类」。
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="manage-bar">
|
|
||||||
<input v-model="keyword" class="search-input" type="text" placeholder="搜索分类名称" aria-label="搜索分类名称" />
|
|
||||||
<div v-if="editable" class="group-create">
|
|
||||||
<input v-model="createName" type="text" placeholder="输入新分类名称" aria-label="新分类名称" @keyup.enter="submitCreate" />
|
|
||||||
<button class="btn" type="button" :disabled="!canCreate" @click="submitCreate">新建</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="loadGroups" />
|
|
||||||
<p v-if="errorText" class="group-error">{{ errorText }}</p>
|
|
||||||
|
|
||||||
<ul class="option-list">
|
|
||||||
<template v-if="filteredGroups.length">
|
|
||||||
<li v-for="group in filteredGroups" :key="group.id" class="option-row">
|
|
||||||
<template v-if="editingId === group.id">
|
|
||||||
<input v-model="editingName" class="rename-input" type="text" aria-label="分类新名称" @keyup.enter="submitRename(group)" />
|
|
||||||
<span class="row-actions">
|
|
||||||
<button class="btn btn-sm" type="button" :disabled="saving" @click="submitRename(group)">保存</button>
|
|
||||||
<button class="btn btn-sm btn-secondary" type="button" @click="cancelRename">取消</button>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<span class="option-name" :title="group.name">{{ group.name }}</span>
|
|
||||||
<span class="option-meta" title="该分类下的商品数">{{ group.productCount }}</span>
|
|
||||||
<span v-if="editable" class="row-actions">
|
|
||||||
<button class="btn btn-sm btn-secondary" type="button" :disabled="saving" @click="startRename(group)">改名</button>
|
|
||||||
<button class="btn btn-sm btn-danger" type="button" :disabled="saving" @click="removeGroup(group)">删除</button>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</li>
|
|
||||||
</template>
|
|
||||||
<li v-else-if="loading" class="manage-empty">加载中...</li>
|
|
||||||
<li v-else class="manage-empty">{{ emptyListText }}</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<div class="modal-foot">
|
|
||||||
<button class="btn btn-secondary" type="button" @click="emit('close')">关闭</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.modal-mask {
|
|
||||||
position: fixed;
|
|
||||||
inset: 0;
|
|
||||||
z-index: 2800;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 40px 20px;
|
|
||||||
background: rgba(45, 66, 86, 0.36);
|
|
||||||
backdrop-filter: blur(6px);
|
|
||||||
}
|
|
||||||
.manage-modal {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
width: min(480px, 100%);
|
|
||||||
max-height: 80vh;
|
|
||||||
padding: 18px 20px 20px;
|
|
||||||
border: 1px solid #c7d7e5;
|
|
||||||
border-radius: 14px;
|
|
||||||
background: #ffffff;
|
|
||||||
box-shadow: 0 22px 60px rgba(39, 67, 94, 0.2);
|
|
||||||
}
|
|
||||||
.modal-head {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
.modal-head h3 {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 15px;
|
|
||||||
font-weight: 650;
|
|
||||||
color: #24384d;
|
|
||||||
}
|
|
||||||
.modal-sub {
|
|
||||||
margin-left: 6px;
|
|
||||||
color: #5b6f83;
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
.modal-close {
|
|
||||||
width: 30px;
|
|
||||||
height: 30px;
|
|
||||||
border: 1px solid transparent;
|
|
||||||
border-radius: 9px;
|
|
||||||
background: none;
|
|
||||||
color: #5b6f83;
|
|
||||||
font-size: 20px;
|
|
||||||
line-height: 1;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.modal-close:hover {
|
|
||||||
border-color: #cbd9e6;
|
|
||||||
background: #eef4fa;
|
|
||||||
color: #24384d;
|
|
||||||
}
|
|
||||||
.modal-tip {
|
|
||||||
margin: 8px 0 10px;
|
|
||||||
color: #8293a5;
|
|
||||||
font-size: 12.5px;
|
|
||||||
line-height: 1.5;
|
|
||||||
}
|
|
||||||
.manage-bar {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 8px;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
.search-input,
|
|
||||||
.group-create input {
|
|
||||||
min-height: 36px;
|
|
||||||
padding: 6px 12px;
|
|
||||||
border: 1px solid #cbd9e6;
|
|
||||||
border-radius: 9px;
|
|
||||||
background: #f8fbfd;
|
|
||||||
color: #24384d;
|
|
||||||
font-size: 13px;
|
|
||||||
font-family: inherit;
|
|
||||||
outline: none;
|
|
||||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
|
||||||
}
|
|
||||||
.search-input:hover,
|
|
||||||
.group-create input:hover {
|
|
||||||
border-color: #9fb7cd;
|
|
||||||
}
|
|
||||||
.search-input:focus,
|
|
||||||
.group-create input:focus {
|
|
||||||
background: #ffffff;
|
|
||||||
border-color: #5f85ad;
|
|
||||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
|
||||||
}
|
|
||||||
.search-input {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 140px;
|
|
||||||
}
|
|
||||||
.group-create {
|
|
||||||
display: flex;
|
|
||||||
flex: 1;
|
|
||||||
gap: 8px;
|
|
||||||
min-width: 220px;
|
|
||||||
}
|
|
||||||
.group-create input {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
.group-error {
|
|
||||||
margin: 0 0 8px;
|
|
||||||
padding: 10px 12px;
|
|
||||||
border: 1px solid #f0c9c2;
|
|
||||||
border-radius: 10px;
|
|
||||||
background: #fdf1ef;
|
|
||||||
color: #a04432;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
.option-list {
|
|
||||||
flex: 1;
|
|
||||||
min-height: 0;
|
|
||||||
overflow-y: auto;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
list-style: none;
|
|
||||||
border-top: 1px solid #e7eef5;
|
|
||||||
}
|
|
||||||
.option-row {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
padding: 9px 8px;
|
|
||||||
border-bottom: 1px solid #e7eef5;
|
|
||||||
font-size: 13.5px;
|
|
||||||
}
|
|
||||||
.option-row:hover {
|
|
||||||
background: #f1f7fb;
|
|
||||||
}
|
|
||||||
.option-name {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
color: #24384d;
|
|
||||||
}
|
|
||||||
.option-meta {
|
|
||||||
flex: none;
|
|
||||||
min-width: 22px;
|
|
||||||
padding: 1px 7px;
|
|
||||||
border-radius: 9px;
|
|
||||||
background: #eef4fa;
|
|
||||||
color: #4e6479;
|
|
||||||
font-size: 12px;
|
|
||||||
text-align: center;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.row-actions {
|
|
||||||
flex: none;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.manage-empty {
|
|
||||||
padding: 30px 12px;
|
|
||||||
text-align: center;
|
|
||||||
color: #8293a5;
|
|
||||||
font-size: 13px;
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
.rename-input {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
min-height: 32px;
|
|
||||||
padding: 4px 10px;
|
|
||||||
border: 1px solid #cbd9e6;
|
|
||||||
border-radius: 8px;
|
|
||||||
font-size: 13.5px;
|
|
||||||
font-family: inherit;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
.rename-input:focus {
|
|
||||||
background: #ffffff;
|
|
||||||
border-color: #5f85ad;
|
|
||||||
}
|
|
||||||
.modal-foot {
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 10px;
|
|
||||||
margin-top: 14px;
|
|
||||||
}
|
|
||||||
.btn {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
min-height: 36px;
|
|
||||||
padding: 6px 14px;
|
|
||||||
border: 1px solid #4f78a5;
|
|
||||||
border-radius: 9px;
|
|
||||||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
|
||||||
color: #ffffff;
|
|
||||||
font-family: inherit;
|
|
||||||
font-size: 13px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.btn:disabled {
|
|
||||||
cursor: not-allowed;
|
|
||||||
opacity: 0.55;
|
|
||||||
}
|
|
||||||
.btn-sm {
|
|
||||||
min-height: 28px;
|
|
||||||
padding: 3px 10px;
|
|
||||||
font-size: 12.5px;
|
|
||||||
margin-right: 6px;
|
|
||||||
}
|
|
||||||
.btn-sm:last-child {
|
|
||||||
margin-right: 0;
|
|
||||||
}
|
|
||||||
.btn-secondary {
|
|
||||||
background: #ffffff;
|
|
||||||
color: #5b6f83;
|
|
||||||
border-color: #c7d7e5;
|
|
||||||
}
|
|
||||||
.btn-secondary:hover:not(:disabled) {
|
|
||||||
color: #2f5d8b;
|
|
||||||
border-color: #95b1cb;
|
|
||||||
background: #edf5fb;
|
|
||||||
}
|
|
||||||
/* 危险动作与全站 .btn-danger 同形(实心红渐变+白字)。 */
|
|
||||||
.btn-danger {
|
|
||||||
background: linear-gradient(135deg, #c06d77, #b35f6a);
|
|
||||||
border-color: #b35f6a;
|
|
||||||
color: #ffffff;
|
|
||||||
}
|
|
||||||
.btn-danger:hover:not(:disabled) {
|
|
||||||
background: linear-gradient(135deg, #cb7c84, #b96570);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,526 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
/** 京东公共商品库:支持分类和京麦类目组合筛选。
|
|
||||||
* V203(2026-11-16 用户口径):分类按「数据权限分组」隔离——不同组看不到彼此的分类,
|
|
||||||
* 能看多组的人用筛选行「分组」下拉切换当前组(只有一组时锁定显示)。
|
|
||||||
* 2026-11-17 用户口径:店铺分类弹窗下线,本页工具栏改「批量编辑分类」——勾选商品
|
|
||||||
* (翻页累计记忆)后选目标分类归入或移出;同日第二刀「京东分类管理并到京东数据库分类
|
|
||||||
* 编辑里」:V204 独立子菜单页(JdCategoryManagerPage)下线,建/改名/删分类收进工具栏
|
|
||||||
* 「分类管理」对话框(JdCategoryManageDialog,带名称搜索)。 */
|
|
||||||
import { computed, onMounted, reactive, ref } from 'vue'
|
|
||||||
import {
|
|
||||||
deleteJdProducts,
|
|
||||||
fetchJdCategoryScope,
|
|
||||||
fetchJdProductCategories,
|
|
||||||
fetchJdProductGroups,
|
|
||||||
fetchJdProductList,
|
|
||||||
type JdCategoryGroupOption,
|
|
||||||
type JdProductCategoryOption,
|
|
||||||
type JdProductGroup,
|
|
||||||
} from './jd-product-api.ts'
|
|
||||||
import type { JdProductItem } from './jd-product-model.ts'
|
|
||||||
import { jdPriceRange } from './jd-product-model.ts'
|
|
||||||
import { createJdProductFilterState } from './jd-product-filter.ts'
|
|
||||||
import JdProductDetailDrawer from './JdProductDetailDrawer.vue'
|
|
||||||
import JdProductEditDrawer from './JdProductEditDrawer.vue'
|
|
||||||
import JdCategoryCascader from './JdCategoryCascader.vue'
|
|
||||||
import JdBatchAssignDialog from './JdBatchAssignDialog.vue'
|
|
||||||
import JdCategoryManageDialog from './JdCategoryManageDialog.vue'
|
|
||||||
import OldPagination from '@/components/OldPagination.vue'
|
|
||||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
|
||||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
|
||||||
import { loadFailureMessage } from '@/components/load-failure-model'
|
|
||||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
|
||||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
|
||||||
import { formatDateTime, orderedPair } from '@/utils/datetime'
|
|
||||||
|
|
||||||
/** 写权限口径(2026-11-16 用户口径):商品行写(编辑/删除/勾选批量删)只对平台超级管理员渲染;
|
|
||||||
* 分类写(建/改名/删除、归类)由 scope 的每组 editable 决定(本组管理员/公司超管/平台超管)。 */
|
|
||||||
const session = useAdminSessionStore()
|
|
||||||
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
|
||||||
|
|
||||||
const loading = ref(false)
|
|
||||||
const loadFailure = ref('')
|
|
||||||
const rows = ref<JdProductItem[]>([])
|
|
||||||
const total = ref(0)
|
|
||||||
const page = ref(1)
|
|
||||||
const pageSize = ref(20)
|
|
||||||
const filter = reactive(createJdProductFilterState())
|
|
||||||
/** 分类作用域(V203):可见分组 + 每组可写标记。失败静默回空作用域(分类列全空但商品照常)。 */
|
|
||||||
const categoryScope = ref<JdCategoryGroupOption[]>([])
|
|
||||||
const scopeDefaultGroupId = ref(0)
|
|
||||||
/** 当前分组(数据权限分组 id):分类列/分类筛选/分类管理的共同作用域。 */
|
|
||||||
const ownerGroupId = ref(0)
|
|
||||||
/** 当前分组的分类下拉选项(按 ownerGroupId 取,切组即换)。 */
|
|
||||||
const groupOptions = ref<JdProductGroup[]>([])
|
|
||||||
/** 类目下拉选项(京麦末级类目):与当前行集同源(公共库全量);失败静默回空。 */
|
|
||||||
const categoryOptions = ref<JdProductCategoryOption[]>([])
|
|
||||||
const detailItem = ref<JdProductItem | null>(null)
|
|
||||||
const detailVisible = ref(false)
|
|
||||||
/** 批量编辑分类对话框(2026-11-17 替代下线的店铺分类弹窗)。 */
|
|
||||||
const batchEditVisible = ref(false)
|
|
||||||
/** 分类管理对话框(2026-11-17 第二刀:独立子菜单页并进来,建/改名/删+搜索)。 */
|
|
||||||
const manageVisible = ref(false)
|
|
||||||
/** 行级编辑抽屉(2026-11-15 用户口径「每一条数据后面 需要编辑或者删除;编辑的话
|
|
||||||
* 这里面都是可以编辑的」):删除走下面的 removeOne(同一条删除链),编辑走独立抽屉。 */
|
|
||||||
const editItem = ref<JdProductItem | null>(null)
|
|
||||||
const editVisible = ref(false)
|
|
||||||
|
|
||||||
/** 当前分组的下拉项(带 editable)——分类写入口与「店铺分类」弹窗的可管理档都读它。 */
|
|
||||||
const currentGroupOption = computed<JdCategoryGroupOption | null>(() =>
|
|
||||||
categoryScope.value.find((group) => group.id === ownerGroupId.value) || null)
|
|
||||||
const currentGroupName = computed(() => currentGroupOption.value?.name || '')
|
|
||||||
/** 分类可管理(建/改名/删除/归类):本组管理员、公司超管、平台超管(后端 scope 判)。 */
|
|
||||||
const canManageCategories = computed(() => currentGroupOption.value?.editable === true)
|
|
||||||
/** 勾选列服务两类写:批量删除(只超管)+批量编辑分类(本组可写分类的管理员也要勾)。
|
|
||||||
* 2026-11-17 弹窗下线后管理员失去弹窗右栏的勾选面 ⇒ 勾选列必须对「本组可写」放开,
|
|
||||||
* 否则本组管理员没有归类入口。商品行按钮(编辑/删除/删除勾选)仍只归平台超管。 */
|
|
||||||
const hasSelectionColumn = computed(() => isSuperAdmin.value || canManageCategories.value)
|
|
||||||
/** 空态行 colspan:勾选列有无决定 5/6/7 列三种形状(超管含操作列)。 */
|
|
||||||
const emptyColspan = computed(() => (isSuperAdmin.value ? 7 : hasSelectionColumn.value ? 6 : 5))
|
|
||||||
/** 分组下拉只在能看多组时才渲染;只有一组(含无可见组)时按锁定态展示。 */
|
|
||||||
const canSwitchGroup = computed(() => categoryScope.value.length > 1)
|
|
||||||
|
|
||||||
function openEdit(item: JdProductItem): void {
|
|
||||||
editItem.value = item
|
|
||||||
editVisible.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeEdit(): void {
|
|
||||||
editVisible.value = false
|
|
||||||
editItem.value = null
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 编辑保存成功:刷新列表(该行已置人工编辑锁,标题/价格等即时可见且不再被采集覆盖)。 */
|
|
||||||
async function onEditSaved(): Promise<void> {
|
|
||||||
await load()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** min/max 挡不住手输,落值后把倒挂的起止交换回来。 */
|
|
||||||
function clampJdSyncedRange(): void {
|
|
||||||
const [s, e] = orderedPair(filter.syncedFrom, filter.syncedTo)
|
|
||||||
filter.syncedFrom = s
|
|
||||||
filter.syncedTo = e
|
|
||||||
}
|
|
||||||
|
|
||||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
|
||||||
|
|
||||||
/** 作用域 → 分组列表 → 该组分类:失败一律静默降级(分类只是筛选/归类面,不拦首屏行集)。 */
|
|
||||||
async function loadCategoryScope(): Promise<void> {
|
|
||||||
try {
|
|
||||||
const scope = await fetchJdCategoryScope()
|
|
||||||
categoryScope.value = scope.groups
|
|
||||||
scopeDefaultGroupId.value = scope.defaultGroupId ?? 0
|
|
||||||
} catch {
|
|
||||||
categoryScope.value = []
|
|
||||||
scopeDefaultGroupId.value = 0
|
|
||||||
}
|
|
||||||
// 当前分组:保留用户已选(仍可见时),否则回默认(可见组第一项)。
|
|
||||||
const keep = categoryScope.value.some((group) => group.id === ownerGroupId.value)
|
|
||||||
if (!keep) ownerGroupId.value = scopeDefaultGroupId.value
|
|
||||||
await loadGroupOptions()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 当前分组的分类选项:按 ownerGroupId 取(跨组不可见);失败静默回空下拉。 */
|
|
||||||
async function loadGroupOptions(): Promise<void> {
|
|
||||||
try {
|
|
||||||
groupOptions.value = await fetchJdProductGroups(ownerGroupId.value)
|
|
||||||
} catch {
|
|
||||||
groupOptions.value = []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 类目选项同分组口径:失败静默回空下拉(可见「全部类目」),不拦首屏行集。 */
|
|
||||||
async function loadCategoryOptions(): Promise<void> {
|
|
||||||
try {
|
|
||||||
categoryOptions.value = await fetchJdProductCategories()
|
|
||||||
} catch {
|
|
||||||
categoryOptions.value = []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 切换「分组」下拉:分类筛选(属于上一组的分类)清空,分类选项换成本组,回第一页重取。
|
|
||||||
* 勾选集是按商品 id 记的(跨页累计),切组不清——归类的落点组随 ownerGroupId 走,
|
|
||||||
* 误跨组批量归类由批量对话框里的组名标注防住。 */
|
|
||||||
async function changeOwnerGroup(next: number): Promise<void> {
|
|
||||||
if (next === ownerGroupId.value) return
|
|
||||||
ownerGroupId.value = next
|
|
||||||
filter.groupId = ''
|
|
||||||
await loadGroupOptions()
|
|
||||||
page.value = 1
|
|
||||||
await load()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 打开批量编辑分类:先刷一遍当前组分类(商品数徽标要新鲜),再亮对话框。 */
|
|
||||||
async function openBatchEdit(): Promise<void> {
|
|
||||||
await loadGroupOptions()
|
|
||||||
batchEditVisible.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 打开分类管理(对话框自取列表);入口对所有人渲染——同组普通号只读可看(V203),
|
|
||||||
* 写控件由对话框按 editable 分档。 */
|
|
||||||
function openManage(): void {
|
|
||||||
manageVisible.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 分类管理里有写操作(建/改/删):刷一遍筛选下拉与商品数徽标。 */
|
|
||||||
async function onManaged(): Promise<void> {
|
|
||||||
await loadGroupOptions()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 批量归类完成(对话框已关):清勾选+重取列表(行集 groupName 变了)。
|
|
||||||
* 移出分类 targetName 为 null;updated 是后端实际写入/解挂的归属行数。 */
|
|
||||||
async function onBatchAssigned(updated: number, targetName: string | null): Promise<void> {
|
|
||||||
showAdminFeedback(
|
|
||||||
targetName ? `已把 ${updated} 个商品归入「${targetName}」` : `已把 ${updated} 个商品移出分类`,
|
|
||||||
'success',
|
|
||||||
)
|
|
||||||
selectedIds.value = new Set()
|
|
||||||
await load()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function load(): Promise<void> {
|
|
||||||
loading.value = true
|
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
|
||||||
const result = await fetchJdProductList({
|
|
||||||
page: page.value,
|
|
||||||
pageSize: pageSize.value,
|
|
||||||
productCode: filter.productCode,
|
|
||||||
titleKeyword: filter.titleKeyword,
|
|
||||||
category: filter.category,
|
|
||||||
groupId: filter.groupId,
|
|
||||||
ownerGroupId: ownerGroupId.value,
|
|
||||||
syncedFrom: filter.syncedFrom,
|
|
||||||
syncedTo: filter.syncedTo,
|
|
||||||
})
|
|
||||||
rows.value = result.items
|
|
||||||
total.value = result.total
|
|
||||||
if (result.page >= 1) page.value = result.page
|
|
||||||
// 勾选跨页记忆(2026-11-17 用户口径「支持勾选翻页也要记住」):翻页/重取/改筛选都
|
|
||||||
// 不清勾选集——批量编辑分类与批量删除都按累计 id 提交,操作前的确认弹窗点名数量;
|
|
||||||
// 「清除勾选」按钮同日用户口径删除,勾选只在批量操作成功后自动清。
|
|
||||||
} catch (error) {
|
|
||||||
loadFailure.value = loadFailureMessage(error, '京东商品列表加载失败')
|
|
||||||
showAdminFeedback(loadFailure.value, 'error')
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function apply(): void {
|
|
||||||
page.value = 1
|
|
||||||
void load()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 类目级联面板点末级即查:选完立刻按该类目过滤刷新(回第一页),同分组下拉口径;
|
|
||||||
* 点「全部类目」/触发框 × = 清选重查。 */
|
|
||||||
function onCategoryPicked(name: string): void {
|
|
||||||
filter.category = name
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 重置:筛选面回出厂空态,回第一页重取。 */
|
|
||||||
function reset(): void {
|
|
||||||
Object.assign(filter, createJdProductFilterState())
|
|
||||||
page.value = 1
|
|
||||||
void load()
|
|
||||||
}
|
|
||||||
|
|
||||||
function changePage(next: number): void {
|
|
||||||
if (next < 1 || next > totalPages.value) return
|
|
||||||
page.value = next
|
|
||||||
void load()
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeSize(size: number) {
|
|
||||||
pageSize.value = size
|
|
||||||
page.value = 1
|
|
||||||
void load()
|
|
||||||
}
|
|
||||||
|
|
||||||
function openDetail(item: JdProductItem): void {
|
|
||||||
detailItem.value = item
|
|
||||||
detailVisible.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeDetail(): void {
|
|
||||||
detailVisible.value = false
|
|
||||||
detailItem.value = null
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 商品编码一键复制(京麦同款 ⧉):@click.stop 防冒泡开抽屉;剪贴板不可用(非安全上下文)时弹失败文案。 */
|
|
||||||
async function copyText(text: string): Promise<void> {
|
|
||||||
if (!text) return
|
|
||||||
try {
|
|
||||||
await navigator.clipboard.writeText(text)
|
|
||||||
showAdminFeedback(`已复制 ${text}`, 'success')
|
|
||||||
} catch {
|
|
||||||
showAdminFeedback('复制失败,请手动选择复制', 'error')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------- 删除(先删桶、全成功才删库行,语义在后端 JdProductDeleteService) ----------------
|
|
||||||
|
|
||||||
/** 勾选集(按商品 id,跨页累计记忆,2026-11-17 用户口径)。翻页/重取不清;显式出口
|
|
||||||
* 曾是工具栏「清除勾选」,同日用户口径「清除勾选这个按钮删除」后只剩批量删除/
|
|
||||||
* 批量归类成功后自动清。 */
|
|
||||||
const selectedIds = ref<Set<number>>(new Set())
|
|
||||||
const deleting = ref(false)
|
|
||||||
|
|
||||||
const selectedCount = computed(() => selectedIds.value.size)
|
|
||||||
|
|
||||||
function toggleSelect(row: JdProductItem, checked: boolean): void {
|
|
||||||
const next = new Set(selectedIds.value)
|
|
||||||
if (checked) next.add(row.id)
|
|
||||||
else next.delete(row.id)
|
|
||||||
selectedIds.value = next
|
|
||||||
}
|
|
||||||
|
|
||||||
const allSelected = computed(() => rows.value.length > 0 && rows.value.every((row) => selectedIds.value.has(row.id)))
|
|
||||||
|
|
||||||
function toggleSelectAll(checked: boolean): void {
|
|
||||||
const next = new Set(selectedIds.value)
|
|
||||||
for (const row of rows.value) {
|
|
||||||
if (checked) next.add(row.id)
|
|
||||||
else next.delete(row.id)
|
|
||||||
}
|
|
||||||
selectedIds.value = next
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 单行删除入口(行内按钮):确认弹窗点名商品编码与「桶内图片一并删除」。 */
|
|
||||||
async function removeOne(row: JdProductItem): Promise<void> {
|
|
||||||
await removeMany([row.id], `确定删除商品「${row.productCode || row.title}」吗?`)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 批量删除入口(工具栏按钮):按累计勾选 id 直删(跨页的行也在内),确认弹窗点名总数。 */
|
|
||||||
async function removeSelected(): Promise<void> {
|
|
||||||
await removeMany([...selectedIds.value], `确定删除勾选的 ${selectedIds.value.size} 个商品吗?`)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 删除主流程:二次确认 → 先删桶、全成功才删库行(后端保证)→ 刷新列表并清勾选。 */
|
|
||||||
async function removeMany(ids: number[], message: string): Promise<void> {
|
|
||||||
if (!ids.length || deleting.value) return
|
|
||||||
const ok = await openAdminConfirm({ title: '删除京东商品', message: `${message}删除后该商品的 SKU、图片登记与 jd-products 桶内图片文件一并删除(被其他商品共用的图片会保留);此操作不可恢复。`, confirmText: '确认删除', danger: true })
|
|
||||||
if (!ok) return
|
|
||||||
deleting.value = true
|
|
||||||
try {
|
|
||||||
const receipt = await deleteJdProducts(ids)
|
|
||||||
showAdminFeedback(`已删除 ${receipt.deleted} 个商品,清理 ${receipt.objectsDeleted} 个图片文件` +
|
|
||||||
(receipt.objectsKept ? `(${receipt.objectsKept} 个共用图片保留)` : ''), 'success')
|
|
||||||
selectedIds.value = new Set()
|
|
||||||
if (ids.length >= rows.value.length && page.value > 1) page.value -= 1
|
|
||||||
await load()
|
|
||||||
} catch (error) {
|
|
||||||
const text = error instanceof Error && error.message ? error.message : '删除失败,请稍后重试'
|
|
||||||
showAdminFeedback(text, 'error')
|
|
||||||
} finally {
|
|
||||||
deleting.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
// 先解析作用域再取列表:首屏的 owner_group_id 必须与分类下拉同一个组(铁律 30 同形——
|
|
||||||
// 不要先发一条不带 owner_group_id 的列表请求再补,两次请求会落在不同默认组上)。
|
|
||||||
await loadCategoryScope()
|
|
||||||
void loadCategoryOptions()
|
|
||||||
await load()
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="jd-database-view">
|
|
||||||
<section class="panel-box">
|
|
||||||
<div class="jd-panel-head">
|
|
||||||
<h3>京东数据库</h3>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="jd-filter-row">
|
|
||||||
<div class="form-group">
|
|
||||||
<label>商品编码</label>
|
|
||||||
<input v-model="filter.productCode" type="text" placeholder="输入商品编码" @keyup.enter="apply" />
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>标题关键字</label>
|
|
||||||
<input v-model="filter.titleKeyword" type="text" placeholder="输入标题关键字" @keyup.enter="apply" />
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>类目</label>
|
|
||||||
<!-- 类目(京麦末级类目)京麦同款级联面板(2026-11-16 客户口径):一/二级为静态导航
|
|
||||||
(采集链无层级数据),第三栏已落库末级+搜索,点行选中即查(回第一页)。 -->
|
|
||||||
<JdCategoryCascader
|
|
||||||
:options="categoryOptions"
|
|
||||||
:model-value="filter.category"
|
|
||||||
tree-only
|
|
||||||
@change="onCategoryPicked"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div v-if="categoryScope.length" class="form-group">
|
|
||||||
<label>分组</label>
|
|
||||||
<!-- 当前分组(V203):能看多组的人(平台超管/公司超管)下拉切换;只有一组时锁定显示组名。
|
|
||||||
2026-11-16 用户口径「做成分组」:从工具栏裸下拉上移进筛选行,做成带标签的表单控件
|
|
||||||
(与其他筛选同壳同圆角)。分组是分类列/分类筛选/分类管理的作用域,不是筛选条件
|
|
||||||
⇒ 放在筛选行也只是占位,「重置」不清它(挂载测试钉住)。 -->
|
|
||||||
<select
|
|
||||||
v-if="canSwitchGroup"
|
|
||||||
:value="ownerGroupId"
|
|
||||||
aria-label="当前分组"
|
|
||||||
@change="changeOwnerGroup(Number(($event.target as HTMLSelectElement).value))"
|
|
||||||
>
|
|
||||||
<option v-for="group in categoryScope" :key="group.id" :value="group.id">{{ group.label }}</option>
|
|
||||||
</select>
|
|
||||||
<span v-else class="jd-group-locked" title="你的数据权限内只有这一个分组">{{ currentGroupName }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>同步开始日期</label>
|
|
||||||
<input v-model="filter.syncedFrom" type="date" :max="filter.syncedTo" @change="clampJdSyncedRange" />
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>同步结束日期</label>
|
|
||||||
<input v-model="filter.syncedTo" type="date" :min="filter.syncedFrom" @change="clampJdSyncedRange" />
|
|
||||||
</div>
|
|
||||||
<div class="jd-filter-actions">
|
|
||||||
<button class="btn" type="button" @click="apply">查询</button>
|
|
||||||
<button class="btn btn-secondary" type="button" @click="reset">重置</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
|
||||||
<div class="jd-toolbar">
|
|
||||||
<span class="jd-summary">共 {{ total }} 条京东商品</span>
|
|
||||||
<!-- 批量编辑分类(2026-11-17 用户口径「店铺分类弹窗删了,加个批量编辑分类」):
|
|
||||||
只对当前分组可写档(本组管理员/公司超管/平台超管)渲染;勾选 0 时置灰(与
|
|
||||||
删除勾选同款常显口径),打开后按累计勾选(跨页)提交归入/移出。 -->
|
|
||||||
<button
|
|
||||||
v-if="canManageCategories"
|
|
||||||
class="btn btn-secondary"
|
|
||||||
type="button"
|
|
||||||
:disabled="!selectedCount"
|
|
||||||
@click="openBatchEdit"
|
|
||||||
>批量编辑分类</button>
|
|
||||||
<!-- 商品行写只对平台超管;分类写由当前分组 editable 决定(本组管理员/公司超管/平台超管)。
|
|
||||||
非超管看到只读提示,分类维护入口=工具栏「分类管理」(只读可看,写控件按 editable 分档)。 -->
|
|
||||||
<span v-if="!isSuperAdmin" class="jd-readonly-tip">只读:编辑/删除仅超级管理员可用;分类在本页「分类管理」查看与维护</span>
|
|
||||||
<select v-model="filter.groupId" aria-label="筛选店铺分类" @change="apply">
|
|
||||||
<option value="">全部分类</option>
|
|
||||||
<option v-for="group in groupOptions" :key="group.id" :value="String(group.id)">{{ group.name }}</option>
|
|
||||||
</select>
|
|
||||||
<!-- 分类管理(2026-11-17 用户口径「京东分类管理并到京东数据库分类编辑里」):V204 独立
|
|
||||||
子菜单页整体并入本对话框(搜索+新建+改名+删除)。入口对所有人渲染(同组普通号
|
|
||||||
只读可看,V203),写控件由对话框按当前分组 editable 分档。 -->
|
|
||||||
<button
|
|
||||||
class="btn btn-secondary jd-manage-btn"
|
|
||||||
type="button"
|
|
||||||
@click="openManage"
|
|
||||||
>分类管理</button>
|
|
||||||
<!-- 批量删除 2026-11-16 客户口径「不要勾选后才显示」:常显,勾选 0 时置灰。
|
|
||||||
同日写权限收窄到超管:非超管整颗按钮不渲染(勾选列 2026-11-17 起对本组可写
|
|
||||||
分类管理员开放,服务批量归类)。 -->
|
|
||||||
<button
|
|
||||||
v-if="isSuperAdmin"
|
|
||||||
class="btn btn-danger jd-delete-btn"
|
|
||||||
type="button"
|
|
||||||
:disabled="deleting || !selectedCount"
|
|
||||||
@click="removeSelected"
|
|
||||||
>
|
|
||||||
{{ deleting ? '删除中...' : `删除勾选(${selectedCount})` }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div class="table-scroll jd-table-scroll">
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th v-if="hasSelectionColumn" style="width: 42px"><input type="checkbox" :checked="allSelected" @change="toggleSelectAll(($event.target as HTMLInputElement).checked)" /></th>
|
|
||||||
<th style="width: 92px">分类</th>
|
|
||||||
<th style="width: 520px">商品信息</th>
|
|
||||||
<th style="width: 76px">总库存</th>
|
|
||||||
<th style="width: 120px">价格</th>
|
|
||||||
<!-- 同步时间收尾(创建/修改两列 2026-11-16 客户口径「不要」下线,仍收详情抽屉);
|
|
||||||
操作列 2026-11-16「操作放最后一列」口径置末;同日写权限收窄到超管 ⇒ 非超管不渲染。 -->
|
|
||||||
<th style="width: 170px">同步时间</th>
|
|
||||||
<th v-if="isSuperAdmin" style="width: 138px">操作</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<template v-if="rows.length">
|
|
||||||
<tr v-for="row in rows" :key="row.id" class="jd-row" @click="openDetail(row)">
|
|
||||||
<td v-if="hasSelectionColumn" @click.stop><input type="checkbox" :checked="selectedIds.has(row.id)" @change="toggleSelect(row, ($event.target as HTMLInputElement).checked)" /></td>
|
|
||||||
<td :title="row.groupName || ''">{{ row.groupName || '未分类' }}</td>
|
|
||||||
<td class="jd-info-cell">
|
|
||||||
<div class="jd-info-wrap">
|
|
||||||
<div class="jd-info-figure">
|
|
||||||
<img v-if="row.mainImageUrl" class="jd-thumb" :src="row.mainImageUrl" alt="" loading="lazy" />
|
|
||||||
<span v-else class="jd-thumb jd-thumb-empty">无图</span>
|
|
||||||
<span v-if="row.healthScore !== null" class="jd-health">信息分 {{ row.healthScore }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="jd-info-body">
|
|
||||||
<div class="jd-info-title" :title="row.title">{{ row.title || '-' }}</div>
|
|
||||||
<div class="jd-info-meta">
|
|
||||||
商品编码:<span class="jd-info-code">{{ row.productCode || '-' }}</span>
|
|
||||||
<button v-if="row.productCode" class="jd-copy-btn" type="button" title="复制商品编码" @click.stop="copyText(row.productCode)">⧉</button>
|
|
||||||
</div>
|
|
||||||
<div class="jd-info-meta">货号:<span class="jd-info-code">{{ row.itemNum || '-' }}</span></div>
|
|
||||||
<!-- 品牌·类目行:京麦列表同款(末级类目名紧随品牌),字段与顺序 2026-11-15 对齐京麦。 -->
|
|
||||||
<div v-if="row.brand || row.categoryPath" class="jd-info-meta jd-brand-cat">
|
|
||||||
<span class="jd-brand-name">{{ row.brand || '' }}</span> {{ row.categoryPath || '' }}
|
|
||||||
</div>
|
|
||||||
<div v-if="row.skuCount" class="jd-info-tags"><span class="jd-tag">{{ row.skuCount }}个SKU</span></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>{{ row.stockTotal ?? '-' }}</td>
|
|
||||||
<td>{{ jdPriceRange(row) || '-' }}</td>
|
|
||||||
<td>{{ formatDateTime(row.syncedAt || '') }}</td>
|
|
||||||
<!-- 操作列(2026-11-15 用户口径):编辑/删除;@click.stop 防冒泡开详情抽屉。
|
|
||||||
2026-11-16「操作放最后一列」口径置末;「上架时间 / 商品状态」列同日整列下线;
|
|
||||||
同日写权限收窄到超管 ⇒ 非超管不渲染该列。 -->
|
|
||||||
<td v-if="isSuperAdmin" class="jd-ops-cell" @click.stop>
|
|
||||||
<button class="btn btn-sm" type="button" @click="openEdit(row)">编辑</button>
|
|
||||||
<button class="btn btn-sm btn-danger" type="button" :disabled="deleting" @click="removeOne(row)">删除</button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</template>
|
|
||||||
<tr v-else-if="loading">
|
|
||||||
<td :colspan="emptyColspan" class="empty-tip">加载中...</td>
|
|
||||||
</tr>
|
|
||||||
<tr v-else>
|
|
||||||
<td :colspan="emptyColspan" class="empty-tip">暂无京东商品数据</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<OldPagination :total="total" :page="page" :page-size="pageSize" @change="changePage" @size-change="changeSize" />
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<JdBatchAssignDialog
|
|
||||||
:visible="batchEditVisible"
|
|
||||||
:owner-group-id="ownerGroupId"
|
|
||||||
:owner-group-name="currentGroupName"
|
|
||||||
:categories="groupOptions"
|
|
||||||
:selected-ids="[...selectedIds]"
|
|
||||||
@close="batchEditVisible = false"
|
|
||||||
@done="onBatchAssigned"
|
|
||||||
/>
|
|
||||||
<JdCategoryManageDialog
|
|
||||||
:visible="manageVisible"
|
|
||||||
:owner-group-id="ownerGroupId"
|
|
||||||
:owner-group-name="currentGroupName"
|
|
||||||
:editable="canManageCategories"
|
|
||||||
@close="manageVisible = false"
|
|
||||||
@changed="onManaged"
|
|
||||||
/>
|
|
||||||
<JdProductDetailDrawer
|
|
||||||
:item="detailItem"
|
|
||||||
:visible="detailVisible"
|
|
||||||
@close="closeDetail"
|
|
||||||
/>
|
|
||||||
<JdProductEditDrawer
|
|
||||||
:item="editItem"
|
|
||||||
:visible="editVisible"
|
|
||||||
@close="closeEdit"
|
|
||||||
@saved="onEditSaved"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped src="./jd-database-page.css"></style>
|
|
||||||
@@ -1,685 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
/** 京东商品详情抽屉(v1.4 Phase 5):点行打开,展示基本信息 + attrGroups 分块表格 +
|
|
||||||
* 图片网格(MAIN/ATTR/DETAIL 三区,attr 图按 attrName 归并)。
|
|
||||||
* 基本信息=商品全部字段(B104:列表只摆部分字段,类目/信息分/SKU 数/上架时间/京东创建/
|
|
||||||
* 修改时间/店铺/分组都在这里看)。
|
|
||||||
* 图片点击放大预览用自绘 modal-mask(先例:RecordsHistoryPage 的 thumb + modal-mask +
|
|
||||||
* 原图新标签;不用 element-plus)。数据由本组件按 id 自取(公共库无公司维度),失败条内提示可重试。 */
|
|
||||||
import { computed, ref, watch } from 'vue'
|
|
||||||
import { fetchJdProductDetail } from './jd-product-api.ts'
|
|
||||||
import type {
|
|
||||||
JdProductImage,
|
|
||||||
JdProductItem,
|
|
||||||
JdProductAttrGroup,
|
|
||||||
JdProductSku,
|
|
||||||
} from './jd-product-model.ts'
|
|
||||||
import { jdPriceRange, jdSkuDimensions, jdSkuSummary } from './jd-product-model.ts'
|
|
||||||
import { formatDateTime } from '@/utils/datetime'
|
|
||||||
import { requestErrorMessage } from '../../api/envelope.ts'
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
item: JdProductItem | null
|
|
||||||
visible: boolean
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const emit = defineEmits<{ (event: 'close'): void }>()
|
|
||||||
|
|
||||||
const loading = ref(false)
|
|
||||||
const loadFailure = ref('')
|
|
||||||
const attrGroups = ref<JdProductAttrGroup[]>([])
|
|
||||||
const images = ref<JdProductImage[]>([])
|
|
||||||
const skus = ref<JdProductSku[]>([])
|
|
||||||
const attrJsonRaw = ref('')
|
|
||||||
|
|
||||||
/** SKU 矩阵维度(京麦「颜色 / 尺码」两列)与表头汇总。 */
|
|
||||||
const skuDimensions = computed(() => jdSkuDimensions(skus.value))
|
|
||||||
const skuSummary = computed(() => jdSkuSummary(skus.value))
|
|
||||||
|
|
||||||
function skuAttrValue(sku: JdProductSku, dimension: string): string {
|
|
||||||
return sku.saleAttrs.find((attr) => attr.name === dimension)?.value || '-'
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 图片三区:MAIN / ATTR / DETAIL;未知类型归 DETAIL 之外的「其他」,不丢。 */
|
|
||||||
const mainImages = computed(() => images.value.filter((image) => image.imageType === 'MAIN'))
|
|
||||||
|
|
||||||
/** 顶部画廊(2026-11-16 客户口径「详情页样式和京麦商品详情一样」=左图右信息):
|
|
||||||
* 左侧主图大图+缩略图切换(MAIN 档),右侧关键信息。 */
|
|
||||||
const galleryImages = computed(() => mainImages.value)
|
|
||||||
const activeImageUrl = ref('')
|
|
||||||
|
|
||||||
function switchGallery(image: JdProductImage): void {
|
|
||||||
activeImageUrl.value = image.url
|
|
||||||
}
|
|
||||||
const attrImageGroups = computed(() => {
|
|
||||||
const buckets = new Map<string, JdProductImage[]>()
|
|
||||||
for (const image of images.value) {
|
|
||||||
if (image.imageType !== 'ATTR') continue
|
|
||||||
const key = image.attrName || '属性图'
|
|
||||||
const bucket = buckets.get(key)
|
|
||||||
if (bucket) bucket.push(image)
|
|
||||||
else buckets.set(key, [image])
|
|
||||||
}
|
|
||||||
return [...buckets.entries()].map(([attrName, list]) => ({ attrName, list }))
|
|
||||||
})
|
|
||||||
const detailImages = computed(() => images.value.filter((image) => image.imageType === 'DETAIL'))
|
|
||||||
const otherImages = computed(() =>
|
|
||||||
images.value.filter((image) => image.imageType !== 'MAIN' && image.imageType !== 'ATTR' && image.imageType !== 'DETAIL'),
|
|
||||||
)
|
|
||||||
|
|
||||||
/** 放大预览:点缩略图弹自绘 modal-mask,原图可新标签打开。 */
|
|
||||||
const previewVisible = ref(false)
|
|
||||||
const previewUrl = ref('')
|
|
||||||
|
|
||||||
function openPreview(url: string): void {
|
|
||||||
previewUrl.value = url
|
|
||||||
previewVisible.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
function close(): void {
|
|
||||||
previewVisible.value = false
|
|
||||||
emit('close')
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadDetail(): Promise<void> {
|
|
||||||
const item = props.item
|
|
||||||
if (!item) return
|
|
||||||
loading.value = true
|
|
||||||
loadFailure.value = ''
|
|
||||||
attrGroups.value = []
|
|
||||||
images.value = []
|
|
||||||
skus.value = []
|
|
||||||
attrJsonRaw.value = ''
|
|
||||||
try {
|
|
||||||
const detail = await fetchJdProductDetail(item.id)
|
|
||||||
attrGroups.value = detail.attrGroups
|
|
||||||
images.value = detail.images
|
|
||||||
skus.value = detail.skus
|
|
||||||
attrJsonRaw.value = detail.attrJsonRaw
|
|
||||||
activeImageUrl.value = detail.images.find((image) => image.imageType === 'MAIN')?.url || ''
|
|
||||||
if (!detail.attrGroups.length && detail.attrJsonRaw) {
|
|
||||||
// 结构化解析失败但原文在:兜底展示原文,不静默吞
|
|
||||||
loadFailure.value = ''
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
loadFailure.value = requestErrorMessage(error) || '商品详情加载失败'
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => [props.visible, props.item?.id] as const,
|
|
||||||
([visible]) => {
|
|
||||||
previewVisible.value = false
|
|
||||||
previewUrl.value = ''
|
|
||||||
activeImageUrl.value = ''
|
|
||||||
if (visible && props.item) void loadDetail()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
function dash(value: string | number | null | undefined): string {
|
|
||||||
const text = value === null || value === undefined ? '' : String(value).trim()
|
|
||||||
return text || '-'
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div v-if="visible" class="drawer-mask" @click.self="close">
|
|
||||||
<aside class="drawer">
|
|
||||||
<header class="drawer-head">
|
|
||||||
<h3>商品详情{{ item?.productCode ? ` · ${item.productCode}` : '' }}</h3>
|
|
||||||
<button class="drawer-close" type="button" aria-label="关闭" @click="close">×</button>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<div class="drawer-body">
|
|
||||||
<div v-if="loadFailure" class="drawer-failure">
|
|
||||||
<span>{{ loadFailure }}</span>
|
|
||||||
<button class="btn btn-secondary" type="button" @click="loadDetail">重试</button>
|
|
||||||
</div>
|
|
||||||
<p v-else-if="loading" class="drawer-tip">加载中...</p>
|
|
||||||
|
|
||||||
<template v-else>
|
|
||||||
<!-- 顶部「左图右信息」(2026-11-16 客户口径「详情页的样式要和京麦商品详情一样的布局样式」):
|
|
||||||
左侧主图大图+缩略图切换,右侧关键信息;属性/SKU/详情图等区块保持下方。 -->
|
|
||||||
<section class="detail-block">
|
|
||||||
<div class="detail-hero">
|
|
||||||
<div class="hero-gallery">
|
|
||||||
<img
|
|
||||||
v-if="activeImageUrl"
|
|
||||||
class="hero-main"
|
|
||||||
:src="activeImageUrl"
|
|
||||||
alt=""
|
|
||||||
title="点击放大预览"
|
|
||||||
@click="openPreview(activeImageUrl)"
|
|
||||||
/>
|
|
||||||
<div v-else class="hero-empty">无图</div>
|
|
||||||
<div v-if="galleryImages.length > 1" class="hero-thumbs">
|
|
||||||
<img
|
|
||||||
v-for="image in galleryImages"
|
|
||||||
:key="image.id"
|
|
||||||
:src="image.url"
|
|
||||||
alt=""
|
|
||||||
loading="lazy"
|
|
||||||
:class="{ active: image.url === activeImageUrl }"
|
|
||||||
title="切换主图"
|
|
||||||
@click="switchGallery(image)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<dl class="hero-info">
|
|
||||||
<div class="info-item info-item-wide hero-title">
|
|
||||||
<dt>标题</dt>
|
|
||||||
<dd :title="item?.title || ''">{{ dash(item?.title) }}</dd>
|
|
||||||
</div>
|
|
||||||
<div class="info-item"><dt>价格区间</dt><dd>{{ dash(jdPriceRange(item ?? { priceMin: '', priceMax: '' })) }}</dd></div>
|
|
||||||
<div class="info-item"><dt>总库存</dt><dd>{{ dash(item?.stockTotal) }}</dd></div>
|
|
||||||
<div class="info-item"><dt>状态</dt><dd>{{ dash(item?.saleStatus) }}</dd></div>
|
|
||||||
<div class="info-item"><dt>信息分</dt><dd>{{ dash(item?.healthScore) }}</dd></div>
|
|
||||||
<div class="info-item"><dt>SKU 数</dt><dd>{{ dash(item?.skuCount) }}</dd></div>
|
|
||||||
<div class="info-item"><dt>商品编码</dt><dd>{{ dash(item?.productCode) }}</dd></div>
|
|
||||||
<div class="info-item"><dt>货号</dt><dd>{{ dash(item?.itemNum) }}</dd></div>
|
|
||||||
<div class="info-item"><dt>SKU</dt><dd>{{ dash(item?.skuId) }}</dd></div>
|
|
||||||
<div class="info-item"><dt>品牌</dt><dd>{{ dash(item?.brand) }}</dd></div>
|
|
||||||
<div class="info-item"><dt>店铺</dt><dd :title="item?.shopName || ''">{{ dash(item?.shopName) }}</dd></div>
|
|
||||||
<div class="info-item"><dt>分类</dt><dd>{{ dash(item?.groupName || '未分类') }}</dd></div>
|
|
||||||
<div class="info-item info-item-wide"><dt>类目</dt><dd :title="item?.categoryPath || ''">{{ dash(item?.categoryPath) }}</dd></div>
|
|
||||||
<div class="info-item"><dt>上架时间</dt><dd>{{ item?.jdOnlineAt ? formatDateTime(item.jdOnlineAt) : '-' }}</dd></div>
|
|
||||||
<div class="info-item"><dt>同步时间</dt><dd>{{ formatDateTime(item?.syncedAt || '') }}</dd></div>
|
|
||||||
<div class="info-item"><dt>京东创建时间</dt><dd>{{ item?.jdCreatedAt ? formatDateTime(item.jdCreatedAt) : '-' }}</dd></div>
|
|
||||||
<div class="info-item"><dt>京东修改时间</dt><dd>{{ item?.jdUpdatedAt ? formatDateTime(item.jdUpdatedAt) : '-' }}</dd></div>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section v-if="attrGroups.length" class="detail-block">
|
|
||||||
<h4>属性与设置(按京麦 Tab 分组)</h4>
|
|
||||||
<div v-for="group in attrGroups" :key="group.groupName" class="attr-group">
|
|
||||||
<h5>{{ group.groupName }}</h5>
|
|
||||||
<table>
|
|
||||||
<tbody>
|
|
||||||
<tr v-for="(attr, index) in group.attrs" :key="`${attr.key}-${index}`">
|
|
||||||
<th>{{ attr.label || attr.key || '-' }}</th>
|
|
||||||
<td>{{ attr.value || '-' }}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<section v-else-if="attrJsonRaw" class="detail-block">
|
|
||||||
<h4>属性(原始 JSON)</h4>
|
|
||||||
<pre class="attr-raw">{{ attrJsonRaw }}</pre>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="detail-block">
|
|
||||||
<h4>销售属性 / SKU 矩阵</h4>
|
|
||||||
<template v-if="skus.length">
|
|
||||||
<p class="sku-summary">{{ skuSummary }}</p>
|
|
||||||
<div class="sku-table-wrap">
|
|
||||||
<table class="sku-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>序号</th>
|
|
||||||
<th v-for="dimension in skuDimensions" :key="dimension">{{ dimension }}</th>
|
|
||||||
<th>京东价</th>
|
|
||||||
<th>库存</th>
|
|
||||||
<th>SKU ID</th>
|
|
||||||
<th>SKU 名称</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr v-for="(sku, index) in skus" :key="sku.skuId">
|
|
||||||
<td>{{ sku.skuSeq || index + 1 }}</td>
|
|
||||||
<td v-for="dimension in skuDimensions" :key="dimension">{{ skuAttrValue(sku, dimension) }}</td>
|
|
||||||
<td>{{ sku.price ? `¥${sku.price}` : '-' }}</td>
|
|
||||||
<td>{{ dash(sku.stock) }}</td>
|
|
||||||
<td class="sku-id">{{ sku.skuId }}</td>
|
|
||||||
<td :title="sku.skuName">{{ dash(sku.skuName) }}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<p v-else class="drawer-tip">暂无 SKU 矩阵(V198 之前采集的旧行需重新采集)</p>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="detail-block">
|
|
||||||
<h4>主图</h4>
|
|
||||||
<div v-if="mainImages.length" class="image-grid">
|
|
||||||
<img
|
|
||||||
v-for="image in mainImages"
|
|
||||||
:key="image.url"
|
|
||||||
:src="image.url"
|
|
||||||
alt=""
|
|
||||||
title="点击放大预览"
|
|
||||||
@click="openPreview(image.url)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<p v-else class="drawer-tip">暂无主图</p>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section v-for="bucket in attrImageGroups" :key="bucket.attrName" class="detail-block">
|
|
||||||
<h4>属性图 · {{ bucket.attrName }}</h4>
|
|
||||||
<div class="image-grid">
|
|
||||||
<img
|
|
||||||
v-for="image in bucket.list"
|
|
||||||
:key="image.url"
|
|
||||||
:src="image.url"
|
|
||||||
alt=""
|
|
||||||
title="点击放大预览"
|
|
||||||
@click="openPreview(image.url)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="detail-block">
|
|
||||||
<h4>详情图</h4>
|
|
||||||
<div v-if="detailImages.length" class="image-grid">
|
|
||||||
<img
|
|
||||||
v-for="image in detailImages"
|
|
||||||
:key="image.url"
|
|
||||||
:src="image.url"
|
|
||||||
alt=""
|
|
||||||
title="点击放大预览"
|
|
||||||
@click="openPreview(image.url)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<p v-else class="drawer-tip">暂无详情图</p>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section v-if="otherImages.length" class="detail-block">
|
|
||||||
<h4>其他图</h4>
|
|
||||||
<div class="image-grid">
|
|
||||||
<img
|
|
||||||
v-for="image in otherImages"
|
|
||||||
:key="image.url"
|
|
||||||
:src="image.url"
|
|
||||||
alt=""
|
|
||||||
title="点击放大预览"
|
|
||||||
@click="openPreview(image.url)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</aside>
|
|
||||||
|
|
||||||
<div v-if="previewVisible" class="modal-mask" @click.self="previewVisible = false">
|
|
||||||
<div class="preview-modal">
|
|
||||||
<div class="preview-head">
|
|
||||||
<h3>图片预览</h3>
|
|
||||||
<button class="drawer-close" type="button" aria-label="关闭" @click="previewVisible = false">×</button>
|
|
||||||
</div>
|
|
||||||
<img class="preview-image" :src="previewUrl" alt="" />
|
|
||||||
<div class="preview-foot">
|
|
||||||
<a :href="previewUrl" target="_blank" rel="noopener">新标签打开原图</a>
|
|
||||||
<button class="btn btn-secondary" type="button" @click="previewVisible = false">关闭</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.drawer-mask {
|
|
||||||
position: fixed;
|
|
||||||
inset: 0;
|
|
||||||
z-index: 2600;
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
background: rgba(45, 66, 86, 0.36);
|
|
||||||
backdrop-filter: blur(4px);
|
|
||||||
}
|
|
||||||
.drawer {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
width: min(920px, 100%);
|
|
||||||
height: 100%;
|
|
||||||
background: #ffffff;
|
|
||||||
box-shadow: -18px 0 40px rgba(39, 67, 94, 0.18);
|
|
||||||
}
|
|
||||||
.drawer-head {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding: 16px 20px;
|
|
||||||
border-bottom: 1px solid #dbe5ee;
|
|
||||||
}
|
|
||||||
.drawer-head h3 {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 15px;
|
|
||||||
font-weight: 650;
|
|
||||||
color: #24384d;
|
|
||||||
}
|
|
||||||
.drawer-close {
|
|
||||||
width: 30px;
|
|
||||||
height: 30px;
|
|
||||||
border: 1px solid transparent;
|
|
||||||
border-radius: 9px;
|
|
||||||
background: none;
|
|
||||||
color: #5b6f83;
|
|
||||||
font-size: 20px;
|
|
||||||
line-height: 1;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.drawer-close:hover {
|
|
||||||
border-color: #cbd9e6;
|
|
||||||
background: #eef4fa;
|
|
||||||
color: #24384d;
|
|
||||||
}
|
|
||||||
.drawer-body {
|
|
||||||
flex: 1;
|
|
||||||
min-height: 0;
|
|
||||||
overflow-y: auto;
|
|
||||||
padding: 16px 20px 28px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 18px;
|
|
||||||
}
|
|
||||||
.drawer-tip {
|
|
||||||
margin: 0;
|
|
||||||
color: #8293a5;
|
|
||||||
font-size: 13.5px;
|
|
||||||
}
|
|
||||||
.drawer-failure {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 12px;
|
|
||||||
padding: 12px 14px;
|
|
||||||
border: 1px solid #f0c9c2;
|
|
||||||
border-radius: 10px;
|
|
||||||
background: #fdf1ef;
|
|
||||||
color: #a04432;
|
|
||||||
font-size: 13.5px;
|
|
||||||
}
|
|
||||||
.detail-block h4 {
|
|
||||||
margin: 0 0 10px;
|
|
||||||
font-size: 13.5px;
|
|
||||||
font-weight: 650;
|
|
||||||
color: #4e6479;
|
|
||||||
}
|
|
||||||
/* 顶部「左图右信息」(京麦详情布局):左侧主图大图+缩略图切换,右侧关键信息网格。 */
|
|
||||||
.detail-hero {
|
|
||||||
display: flex;
|
|
||||||
align-items: flex-start;
|
|
||||||
gap: 16px;
|
|
||||||
}
|
|
||||||
.hero-gallery {
|
|
||||||
flex: 0 0 300px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 8px;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
.hero-main {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
aspect-ratio: 1;
|
|
||||||
object-fit: cover;
|
|
||||||
border: 1px solid #d8e3ee;
|
|
||||||
border-radius: 10px;
|
|
||||||
background: #f2f7fb;
|
|
||||||
cursor: zoom-in;
|
|
||||||
}
|
|
||||||
.hero-empty {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 100%;
|
|
||||||
aspect-ratio: 1;
|
|
||||||
border: 1px dashed #c7d7e5;
|
|
||||||
border-radius: 10px;
|
|
||||||
background: #f8fbfd;
|
|
||||||
color: #8293a5;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
.hero-thumbs {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 6px;
|
|
||||||
}
|
|
||||||
.hero-thumbs img {
|
|
||||||
width: 44px;
|
|
||||||
height: 44px;
|
|
||||||
object-fit: cover;
|
|
||||||
border: 1px solid #d8e3ee;
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
opacity: 0.85;
|
|
||||||
}
|
|
||||||
.hero-thumbs img.active {
|
|
||||||
outline: 2px solid #2f5d8b;
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
.hero-info {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
||||||
gap: 10px 16px;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
.hero-info dt {
|
|
||||||
color: #5b6f83;
|
|
||||||
font-size: 12px;
|
|
||||||
margin-bottom: 3px;
|
|
||||||
}
|
|
||||||
.hero-info dd {
|
|
||||||
margin: 0;
|
|
||||||
color: #24384d;
|
|
||||||
font-size: 13.5px;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.hero-title dd {
|
|
||||||
font-size: 14.5px;
|
|
||||||
font-weight: 650;
|
|
||||||
color: #24384d;
|
|
||||||
white-space: normal;
|
|
||||||
display: -webkit-box;
|
|
||||||
-webkit-line-clamp: 2;
|
|
||||||
-webkit-box-orient: vertical;
|
|
||||||
}
|
|
||||||
@media (max-width: 760px) {
|
|
||||||
.detail-hero {
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
.hero-gallery {
|
|
||||||
flex-basis: auto;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.info-grid {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
||||||
gap: 10px 16px;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
.info-item {
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
.info-item-wide {
|
|
||||||
grid-column: 1 / -1;
|
|
||||||
}
|
|
||||||
.info-item dt {
|
|
||||||
color: #5b6f83;
|
|
||||||
font-size: 12px;
|
|
||||||
margin-bottom: 3px;
|
|
||||||
}
|
|
||||||
.info-item dd {
|
|
||||||
margin: 0;
|
|
||||||
color: #24384d;
|
|
||||||
font-size: 13.5px;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.attr-group {
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
.attr-group h5 {
|
|
||||||
margin: 0 0 6px;
|
|
||||||
color: #5b6f83;
|
|
||||||
font-size: 12.5px;
|
|
||||||
}
|
|
||||||
.attr-group table {
|
|
||||||
width: 100%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
border: 1px solid #dbe5ee;
|
|
||||||
border-radius: 8px;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
.attr-group th,
|
|
||||||
.attr-group td {
|
|
||||||
padding: 7px 10px;
|
|
||||||
border-bottom: 1px solid #e7eef5;
|
|
||||||
font-size: 13px;
|
|
||||||
text-align: left;
|
|
||||||
vertical-align: top;
|
|
||||||
}
|
|
||||||
.attr-group th {
|
|
||||||
width: 180px;
|
|
||||||
background: #f2f7fb;
|
|
||||||
color: #4e6479;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
.attr-group tr:last-child th,
|
|
||||||
.attr-group tr:last-child td {
|
|
||||||
border-bottom: 0;
|
|
||||||
}
|
|
||||||
.attr-raw {
|
|
||||||
margin: 0;
|
|
||||||
padding: 10px 12px;
|
|
||||||
border: 1px solid #dbe5ee;
|
|
||||||
border-radius: 8px;
|
|
||||||
background: #f8fbfd;
|
|
||||||
color: #24384d;
|
|
||||||
font-size: 12px;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
word-break: break-all;
|
|
||||||
max-height: 240px;
|
|
||||||
overflow-y: auto;
|
|
||||||
}
|
|
||||||
.sku-summary {
|
|
||||||
margin: 0 0 8px;
|
|
||||||
color: #5b6f83;
|
|
||||||
font-size: 12.5px;
|
|
||||||
}
|
|
||||||
.sku-table-wrap {
|
|
||||||
overflow-x: auto;
|
|
||||||
border: 1px solid #dbe5ee;
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
.sku-table {
|
|
||||||
width: 100%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
font-size: 12.5px;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.sku-table th,
|
|
||||||
.sku-table td {
|
|
||||||
padding: 7px 10px;
|
|
||||||
border-bottom: 1px solid #e7eef5;
|
|
||||||
text-align: left;
|
|
||||||
color: #24384d;
|
|
||||||
}
|
|
||||||
.sku-table th {
|
|
||||||
background: #f2f7fb;
|
|
||||||
color: #4e6479;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
.sku-table tbody tr:last-child td {
|
|
||||||
border-bottom: 0;
|
|
||||||
}
|
|
||||||
.sku-table .sku-id {
|
|
||||||
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
|
||||||
font-size: 12px;
|
|
||||||
color: #4e6479;
|
|
||||||
}
|
|
||||||
.image-grid {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
.image-grid img {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
aspect-ratio: 1;
|
|
||||||
object-fit: cover;
|
|
||||||
border: 1px solid #d8e3ee;
|
|
||||||
border-radius: 8px;
|
|
||||||
background: #f2f7fb;
|
|
||||||
cursor: zoom-in;
|
|
||||||
}
|
|
||||||
.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);
|
|
||||||
}
|
|
||||||
.preview-modal {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
width: min(880px, 100%);
|
|
||||||
max-height: 88vh;
|
|
||||||
padding: 16px 20px;
|
|
||||||
border: 1px solid #c7d7e5;
|
|
||||||
border-radius: 14px;
|
|
||||||
background: #ffffff;
|
|
||||||
box-shadow: 0 22px 60px rgba(39, 67, 94, 0.2);
|
|
||||||
}
|
|
||||||
.preview-head {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
.preview-head h3 {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 15px;
|
|
||||||
color: #24384d;
|
|
||||||
}
|
|
||||||
.preview-image {
|
|
||||||
display: block;
|
|
||||||
flex: 1;
|
|
||||||
min-height: 0;
|
|
||||||
max-height: 68vh;
|
|
||||||
margin: 12px 0;
|
|
||||||
object-fit: contain;
|
|
||||||
background: #f2f7fb;
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
.preview-foot {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
.preview-foot a {
|
|
||||||
color: #2f5d8b;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
.btn {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
min-height: 38px;
|
|
||||||
padding: 7px 16px;
|
|
||||||
border-radius: 9px;
|
|
||||||
font-size: 13px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.btn-secondary {
|
|
||||||
background: #ffffff;
|
|
||||||
color: #5b6f83;
|
|
||||||
border: 1px solid #c7d7e5;
|
|
||||||
}
|
|
||||||
.btn-secondary:hover {
|
|
||||||
color: #2f5d8b;
|
|
||||||
border-color: #95b1cb;
|
|
||||||
background: #edf5fb;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,616 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
/** 京东商品编辑抽屉(2026-11-15 用户口径「每一条数据后面 需要编辑或者删除;编辑的话
|
|
||||||
* 这里面都是可以编辑的」):详情抽屉的可编辑版——基本信息/属性与设置/SKU 矩阵(价格、
|
|
||||||
* 库存)/图片(标删)四块。形状照 JdProductDetailDrawer(自绘 drawer + 分块 + attr-group
|
|
||||||
* 表格 + image-grid,零 element-plus)。
|
|
||||||
* 保存语义在后端 JdProductUpdateService(PUT /api/admin/jd-products/{id}):主字段全量提交
|
|
||||||
* +可选块(attrGroups 重建 attr_json 的 tabs 段、skus 按 skuId 改价格库存、deleteImageIds
|
|
||||||
* 删图——先删桶、共用对象保留)。保存即置人工编辑锁 manual_locked=1:后续采集不再覆盖该行,
|
|
||||||
* 底部常驻提示点名这件事。
|
|
||||||
* V203(2026-11-16):分类<b>不在本抽屉编辑</b>(分类按数据权限分组隔离,归属存
|
|
||||||
* biz_jd_product_group_assign,归类只走「店铺分类」弹窗)——原「分类」下拉与 groupId 负载已下线,
|
|
||||||
* 避免写遗留的 biz_jd_product.group_id 列造成「界面改了、列表分组没变」。
|
|
||||||
* 图片区拆在 JdProductImageManager 子组件(2026-11-16:× 右上角标删+替换/新增本地图,
|
|
||||||
* B109-01 落地;标删集合经 update:deleteIds 上抛进保存负载,上传立即生效由子组件自理)。
|
|
||||||
* 京东时间/信息分/商品编码只读。
|
|
||||||
* 数据自取 fetchJdProductDetail 回填,保存成功用返回的刷新详情直接回填并 emit('saved')。 */
|
|
||||||
import { computed, ref, watch } from 'vue'
|
|
||||||
import {
|
|
||||||
fetchJdProductDetail,
|
|
||||||
updateJdProduct,
|
|
||||||
} from './jd-product-api.ts'
|
|
||||||
import JdProductImageManager from './JdProductImageManager.vue'
|
|
||||||
import type {
|
|
||||||
JdProductAttrEntry,
|
|
||||||
JdProductAttrGroup,
|
|
||||||
JdProductImage,
|
|
||||||
JdProductItem,
|
|
||||||
JdProductSku,
|
|
||||||
} from './jd-product-model.ts'
|
|
||||||
import { jdSkuDimensions } from './jd-product-model.ts'
|
|
||||||
import { requestErrorMessage } from '../../api/envelope.ts'
|
|
||||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
item: JdProductItem | null
|
|
||||||
visible: boolean
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const emit = defineEmits<{ (event: 'close'): void; (event: 'saved'): void }>()
|
|
||||||
|
|
||||||
const loading = ref(false)
|
|
||||||
const loadFailure = ref('')
|
|
||||||
const saving = ref(false)
|
|
||||||
/** 保存失败红条(后端校验/业务文案原样展示,如价格倒挂、SKU 行不存在)。 */
|
|
||||||
const saveError = ref('')
|
|
||||||
|
|
||||||
// ---------------- 草稿(基本信息 + 属性 + SKU + 删图标记) ----------------
|
|
||||||
|
|
||||||
interface DraftAttrGroup {
|
|
||||||
groupName: string
|
|
||||||
attrs: JdProductAttrEntry[]
|
|
||||||
}
|
|
||||||
|
|
||||||
const form = ref({
|
|
||||||
title: '',
|
|
||||||
brand: '',
|
|
||||||
categoryPath: '',
|
|
||||||
itemNum: '',
|
|
||||||
priceMin: '',
|
|
||||||
priceMax: '',
|
|
||||||
stockTotal: '' as string,
|
|
||||||
saleStatus: '',
|
|
||||||
})
|
|
||||||
const draftAttrGroups = ref<DraftAttrGroup[]>([])
|
|
||||||
const draftSkus = ref<JdProductSku[]>([])
|
|
||||||
const images = ref<JdProductImage[]>([])
|
|
||||||
/** 图片子组件上抛的标删行 id(保存时一次提交 deleteImageIds)。 */
|
|
||||||
const managerDeleteIds = ref<number[]>([])
|
|
||||||
/** attr_json 解析失败(attrJsonRaw 兜底行):属性块禁用,防保存把原文形状弄丢。 */
|
|
||||||
const attrJsonRaw = ref('')
|
|
||||||
|
|
||||||
const skuDimensions = computed(() => jdSkuDimensions(draftSkus.value))
|
|
||||||
|
|
||||||
function skuAttrValue(sku: JdProductSku, dimension: string): string {
|
|
||||||
return sku.saleAttrs.find((attr) => attr.name === dimension)?.value || '-'
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeAttrRow(group: DraftAttrGroup, index: number): void {
|
|
||||||
group.attrs.splice(index, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------- 取数与保存 ----------------
|
|
||||||
|
|
||||||
async function loadDetail(): Promise<void> {
|
|
||||||
const item = props.item
|
|
||||||
if (!item) return
|
|
||||||
loading.value = true
|
|
||||||
loadFailure.value = ''
|
|
||||||
saveError.value = ''
|
|
||||||
try {
|
|
||||||
const detail = await fetchJdProductDetail(item.id)
|
|
||||||
const row = detail.item
|
|
||||||
form.value = {
|
|
||||||
title: row.title,
|
|
||||||
brand: row.brand,
|
|
||||||
categoryPath: row.categoryPath,
|
|
||||||
itemNum: row.itemNum,
|
|
||||||
priceMin: row.priceMin,
|
|
||||||
priceMax: row.priceMax,
|
|
||||||
stockTotal: row.stockTotal === null ? '' : String(row.stockTotal),
|
|
||||||
saleStatus: row.saleStatus,
|
|
||||||
}
|
|
||||||
// 深拷贝草稿:直接改副本,保存前才拼负载。
|
|
||||||
draftAttrGroups.value = detail.attrGroups.map((group: JdProductAttrGroup) => ({
|
|
||||||
groupName: group.groupName,
|
|
||||||
attrs: group.attrs.map((attr) => ({ ...attr })),
|
|
||||||
}))
|
|
||||||
draftSkus.value = detail.skus.map((sku) => ({ ...sku }))
|
|
||||||
images.value = detail.images
|
|
||||||
managerDeleteIds.value = []
|
|
||||||
attrJsonRaw.value = detail.attrJsonRaw
|
|
||||||
} catch (error) {
|
|
||||||
loadFailure.value = requestErrorMessage(error) || '商品详情加载失败'
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function close(): void {
|
|
||||||
emit('close')
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 保存:主字段全量 + 有改动的可选块。前端先拦「标题为空」(后端 @NotBlank 同判),失败红条。 */
|
|
||||||
async function save(): Promise<void> {
|
|
||||||
if (!props.item || saving.value) return
|
|
||||||
saveError.value = ''
|
|
||||||
if (!form.value.title.trim()) {
|
|
||||||
saveError.value = '标题不能为空'
|
|
||||||
return
|
|
||||||
}
|
|
||||||
saving.value = true
|
|
||||||
try {
|
|
||||||
const detail = await updateJdProduct(props.item.id, {
|
|
||||||
title: form.value.title.trim(),
|
|
||||||
brand: form.value.brand.trim() || null,
|
|
||||||
categoryPath: form.value.categoryPath.trim() || null,
|
|
||||||
itemNum: form.value.itemNum.trim() || null,
|
|
||||||
priceMin: form.value.priceMin.trim() || null,
|
|
||||||
priceMax: form.value.priceMax.trim() || null,
|
|
||||||
stockTotal: form.value.stockTotal.trim() === '' ? null : Number(form.value.stockTotal),
|
|
||||||
saleStatus: form.value.saleStatus.trim() || null,
|
|
||||||
// 属性块:原文兜底行(解析失败)不提交,防保存把解析不出的原文形状弄丢。
|
|
||||||
attrGroups: attrJsonRaw.value
|
|
||||||
? null
|
|
||||||
: draftAttrGroups.value.map((group) => ({
|
|
||||||
groupName: group.groupName,
|
|
||||||
attrs: group.attrs.map((attr) => ({
|
|
||||||
key: attr.key,
|
|
||||||
label: attr.label,
|
|
||||||
value: attr.value,
|
|
||||||
})),
|
|
||||||
})),
|
|
||||||
skus: draftSkus.value.length
|
|
||||||
? draftSkus.value.map((sku) => ({
|
|
||||||
skuId: sku.skuId,
|
|
||||||
price: sku.price || null,
|
|
||||||
stock: sku.stock,
|
|
||||||
}))
|
|
||||||
: null,
|
|
||||||
deleteImageIds: managerDeleteIds.value.length ? [...managerDeleteIds.value] : null,
|
|
||||||
})
|
|
||||||
// 保存成功:用返回的刷新详情直接回填(图片行集已扣掉删掉的行、计数已刷新)。
|
|
||||||
form.value.title = detail.item.title
|
|
||||||
form.value.brand = detail.item.brand
|
|
||||||
form.value.categoryPath = detail.item.categoryPath
|
|
||||||
form.value.itemNum = detail.item.itemNum
|
|
||||||
form.value.priceMin = detail.item.priceMin
|
|
||||||
form.value.priceMax = detail.item.priceMax
|
|
||||||
form.value.stockTotal = detail.item.stockTotal === null ? '' : String(detail.item.stockTotal)
|
|
||||||
form.value.saleStatus = detail.item.saleStatus
|
|
||||||
draftAttrGroups.value = detail.attrGroups.map((group) => ({
|
|
||||||
groupName: group.groupName,
|
|
||||||
attrs: group.attrs.map((attr) => ({ ...attr })),
|
|
||||||
}))
|
|
||||||
draftSkus.value = detail.skus.map((sku) => ({ ...sku }))
|
|
||||||
images.value = detail.images
|
|
||||||
managerDeleteIds.value = []
|
|
||||||
showAdminFeedback('已保存,该商品已转为人工维护(采集不再覆盖)', 'success')
|
|
||||||
emit('saved')
|
|
||||||
} catch (error) {
|
|
||||||
saveError.value = requestErrorMessage(error) || '保存失败,请稍后重试'
|
|
||||||
} finally {
|
|
||||||
saving.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => [props.visible, props.item?.id] as const,
|
|
||||||
([visible]) => {
|
|
||||||
if (visible && props.item) void loadDetail()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
function dash(value: string | number | null | undefined): string {
|
|
||||||
const text = value === null || value === undefined ? '' : String(value).trim()
|
|
||||||
return text || '-'
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div v-if="visible" class="drawer-mask" @click.self="close">
|
|
||||||
<aside class="drawer">
|
|
||||||
<header class="drawer-head">
|
|
||||||
<h3>编辑商品{{ item?.productCode ? ` · ${item.productCode}` : '' }}</h3>
|
|
||||||
<button class="drawer-close" type="button" aria-label="关闭" @click="close">×</button>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<div class="drawer-body">
|
|
||||||
<div v-if="loadFailure" class="drawer-failure">
|
|
||||||
<span>{{ loadFailure }}</span>
|
|
||||||
<button class="btn btn-secondary" type="button" @click="loadDetail">重试</button>
|
|
||||||
</div>
|
|
||||||
<p v-else-if="loading" class="drawer-tip">加载中...</p>
|
|
||||||
|
|
||||||
<template v-else>
|
|
||||||
<section class="detail-block">
|
|
||||||
<h4>基本信息</h4>
|
|
||||||
<div class="edit-grid">
|
|
||||||
<div class="edit-item edit-item-wide">
|
|
||||||
<label>标题</label>
|
|
||||||
<input v-model="form.title" type="text" />
|
|
||||||
</div>
|
|
||||||
<div class="edit-item">
|
|
||||||
<label>品牌</label>
|
|
||||||
<input v-model="form.brand" type="text" />
|
|
||||||
</div>
|
|
||||||
<div class="edit-item">
|
|
||||||
<label>类目</label>
|
|
||||||
<input v-model="form.categoryPath" type="text" />
|
|
||||||
</div>
|
|
||||||
<div class="edit-item">
|
|
||||||
<label>货号(系统生成=行号,可改)</label>
|
|
||||||
<input v-model="form.itemNum" type="text" />
|
|
||||||
</div>
|
|
||||||
<div class="edit-item">
|
|
||||||
<label>状态</label>
|
|
||||||
<input v-model="form.saleStatus" type="text" />
|
|
||||||
</div>
|
|
||||||
<div class="edit-item">
|
|
||||||
<label>价格下限</label>
|
|
||||||
<input v-model="form.priceMin" type="text" inputmode="decimal" />
|
|
||||||
</div>
|
|
||||||
<div class="edit-item">
|
|
||||||
<label>价格上限</label>
|
|
||||||
<input v-model="form.priceMax" type="text" inputmode="decimal" />
|
|
||||||
</div>
|
|
||||||
<div class="edit-item">
|
|
||||||
<label>总库存</label>
|
|
||||||
<input v-model="form.stockTotal" type="text" inputmode="numeric" />
|
|
||||||
</div>
|
|
||||||
<div class="edit-item">
|
|
||||||
<label>商品编码(只读)</label>
|
|
||||||
<input type="text" :value="dash(item?.productCode)" readonly class="readonly" />
|
|
||||||
</div>
|
|
||||||
<div class="edit-item">
|
|
||||||
<label>信息分(只读)</label>
|
|
||||||
<input type="text" :value="dash(item?.healthScore)" readonly class="readonly" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section v-if="draftAttrGroups.length" class="detail-block">
|
|
||||||
<h4>属性与设置(键值可改,行可删)</h4>
|
|
||||||
<div v-for="group in draftAttrGroups" :key="group.groupName" class="attr-group">
|
|
||||||
<h5>{{ group.groupName }}</h5>
|
|
||||||
<table>
|
|
||||||
<tbody>
|
|
||||||
<tr v-for="(attr, index) in group.attrs" :key="`${attr.key}-${index}`">
|
|
||||||
<th>{{ attr.label || attr.key || '-' }}</th>
|
|
||||||
<td><input v-model="attr.value" type="text" class="attr-input" /></td>
|
|
||||||
<td class="attr-remove-cell">
|
|
||||||
<button class="attr-remove" type="button" title="删除该属性行" @click="removeAttrRow(group, index)">删</button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<p v-else-if="attrJsonRaw" class="drawer-tip">属性原文解析失败(原始 JSON 兜底),属性区不可编辑以防丢失原文;可照常改基本信息。</p>
|
|
||||||
<p v-else class="drawer-tip">暂无属性</p>
|
|
||||||
|
|
||||||
<section class="detail-block">
|
|
||||||
<h4>SKU 矩阵(京东价 / 库存可改)</h4>
|
|
||||||
<template v-if="draftSkus.length">
|
|
||||||
<div class="sku-table-wrap">
|
|
||||||
<table class="sku-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th v-for="dimension in skuDimensions" :key="dimension">{{ dimension }}</th>
|
|
||||||
<th>京东价</th>
|
|
||||||
<th>库存</th>
|
|
||||||
<th>SKU ID</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr v-for="sku in draftSkus" :key="sku.skuId">
|
|
||||||
<td v-for="dimension in skuDimensions" :key="dimension">{{ skuAttrValue(sku, dimension) }}</td>
|
|
||||||
<td><input v-model="sku.price" type="text" inputmode="decimal" class="sku-input" /></td>
|
|
||||||
<td>
|
|
||||||
<input
|
|
||||||
:value="sku.stock === null ? '' : String(sku.stock)"
|
|
||||||
type="text"
|
|
||||||
inputmode="numeric"
|
|
||||||
class="sku-input"
|
|
||||||
@input="sku.stock = ($event.target as HTMLInputElement).value === '' ? null : Number(($event.target as HTMLInputElement).value)"
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
<td class="sku-id">{{ sku.skuId }}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<p v-else class="drawer-tip">暂无 SKU 矩阵(V198 之前采集的旧行需重新采集)</p>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<JdProductImageManager
|
|
||||||
:product-id="item?.id ?? 0"
|
|
||||||
:images="images"
|
|
||||||
:disabled="loading"
|
|
||||||
@update:images="images = $event"
|
|
||||||
@update:delete-ids="managerDeleteIds = $event"
|
|
||||||
@saved="emit('saved')"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div v-if="saveError" class="drawer-failure">{{ saveError }}</div>
|
|
||||||
<p class="save-hint">保存后该商品转为人工维护,后续采集不再覆盖它的数据(含本单重爬);删除的图片文件一并从存储桶清理(共用的保留);替换 / 新增图片立即生效并同样置锁。</p>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<footer class="drawer-foot">
|
|
||||||
<button class="btn btn-secondary" type="button" :disabled="saving" @click="close">取消</button>
|
|
||||||
<button class="btn" type="button" :disabled="saving || loading" @click="save">
|
|
||||||
{{ saving ? '保存中...' : '保存' }}
|
|
||||||
</button>
|
|
||||||
</footer>
|
|
||||||
</aside>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.drawer-mask {
|
|
||||||
position: fixed;
|
|
||||||
inset: 0;
|
|
||||||
z-index: 2600;
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
background: rgba(45, 66, 86, 0.36);
|
|
||||||
backdrop-filter: blur(4px);
|
|
||||||
}
|
|
||||||
.drawer {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
width: min(920px, 100%);
|
|
||||||
height: 100%;
|
|
||||||
background: #ffffff;
|
|
||||||
box-shadow: -18px 0 40px rgba(39, 67, 94, 0.18);
|
|
||||||
}
|
|
||||||
.drawer-head {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding: 16px 20px;
|
|
||||||
border-bottom: 1px solid #dbe5ee;
|
|
||||||
}
|
|
||||||
.drawer-head h3 {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 15px;
|
|
||||||
font-weight: 650;
|
|
||||||
color: #24384d;
|
|
||||||
}
|
|
||||||
.drawer-close {
|
|
||||||
width: 30px;
|
|
||||||
height: 30px;
|
|
||||||
border: 1px solid transparent;
|
|
||||||
border-radius: 9px;
|
|
||||||
background: none;
|
|
||||||
color: #5b6f83;
|
|
||||||
font-size: 20px;
|
|
||||||
line-height: 1;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.drawer-close:hover {
|
|
||||||
border-color: #cbd9e6;
|
|
||||||
background: #eef4fa;
|
|
||||||
color: #24384d;
|
|
||||||
}
|
|
||||||
.drawer-body {
|
|
||||||
flex: 1;
|
|
||||||
min-height: 0;
|
|
||||||
overflow-y: auto;
|
|
||||||
padding: 16px 20px 28px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 18px;
|
|
||||||
}
|
|
||||||
.drawer-foot {
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 12px;
|
|
||||||
padding: 14px 20px;
|
|
||||||
border-top: 1px solid #dbe5ee;
|
|
||||||
background: #f8fbfd;
|
|
||||||
}
|
|
||||||
.drawer-tip {
|
|
||||||
margin: 0;
|
|
||||||
color: #8293a5;
|
|
||||||
font-size: 13.5px;
|
|
||||||
}
|
|
||||||
.drawer-failure {
|
|
||||||
padding: 12px 14px;
|
|
||||||
border: 1px solid #f0c9c2;
|
|
||||||
border-radius: 10px;
|
|
||||||
background: #fdf1ef;
|
|
||||||
color: #a04432;
|
|
||||||
font-size: 13.5px;
|
|
||||||
}
|
|
||||||
.detail-block h4 {
|
|
||||||
margin: 0 0 10px;
|
|
||||||
font-size: 13.5px;
|
|
||||||
font-weight: 650;
|
|
||||||
color: #4e6479;
|
|
||||||
}
|
|
||||||
.edit-grid {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
||||||
gap: 10px 16px;
|
|
||||||
}
|
|
||||||
.edit-item {
|
|
||||||
min-width: 0;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 5px;
|
|
||||||
}
|
|
||||||
.edit-item-wide {
|
|
||||||
grid-column: 1 / -1;
|
|
||||||
}
|
|
||||||
.edit-item label {
|
|
||||||
color: #5b6f83;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
.edit-item input,
|
|
||||||
.edit-item select {
|
|
||||||
min-width: 0;
|
|
||||||
min-height: 36px;
|
|
||||||
padding: 6px 10px;
|
|
||||||
border: 1px solid #cbd9e6;
|
|
||||||
border-radius: 8px;
|
|
||||||
background: #ffffff;
|
|
||||||
color: #24384d;
|
|
||||||
font-size: 13px;
|
|
||||||
font-family: inherit;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
.edit-item input:focus,
|
|
||||||
.edit-item select:focus {
|
|
||||||
border-color: #5f85ad;
|
|
||||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
|
||||||
}
|
|
||||||
.edit-item input.readonly {
|
|
||||||
background: #f2f7fb;
|
|
||||||
color: #5b6f83;
|
|
||||||
}
|
|
||||||
.attr-group {
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
.attr-group h5 {
|
|
||||||
margin: 0 0 6px;
|
|
||||||
color: #5b6f83;
|
|
||||||
font-size: 12.5px;
|
|
||||||
}
|
|
||||||
.attr-group table {
|
|
||||||
width: 100%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
border: 1px solid #dbe5ee;
|
|
||||||
border-radius: 8px;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
.attr-group th,
|
|
||||||
.attr-group td {
|
|
||||||
padding: 6px 10px;
|
|
||||||
border-bottom: 1px solid #e7eef5;
|
|
||||||
font-size: 13px;
|
|
||||||
text-align: left;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.attr-group th {
|
|
||||||
width: 180px;
|
|
||||||
background: #f2f7fb;
|
|
||||||
color: #4e6479;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
.attr-group tr:last-child th,
|
|
||||||
.attr-group tr:last-child td {
|
|
||||||
border-bottom: 0;
|
|
||||||
}
|
|
||||||
.attr-input {
|
|
||||||
width: 100%;
|
|
||||||
min-height: 32px;
|
|
||||||
padding: 5px 8px;
|
|
||||||
border: 1px solid #cbd9e6;
|
|
||||||
border-radius: 7px;
|
|
||||||
background: #ffffff;
|
|
||||||
color: #24384d;
|
|
||||||
font-size: 13px;
|
|
||||||
font-family: inherit;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
.attr-input:focus {
|
|
||||||
border-color: #5f85ad;
|
|
||||||
}
|
|
||||||
.attr-remove-cell {
|
|
||||||
width: 44px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
.attr-remove {
|
|
||||||
border: 1px solid #e4b3a8;
|
|
||||||
border-radius: 6px;
|
|
||||||
background: #ffffff;
|
|
||||||
color: #a04432;
|
|
||||||
font-size: 12px;
|
|
||||||
padding: 3px 8px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.attr-remove:hover {
|
|
||||||
background: #fdf1ef;
|
|
||||||
}
|
|
||||||
.sku-table-wrap {
|
|
||||||
overflow-x: auto;
|
|
||||||
border: 1px solid #dbe5ee;
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
.sku-table {
|
|
||||||
width: 100%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
font-size: 12.5px;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.sku-table th,
|
|
||||||
.sku-table td {
|
|
||||||
padding: 6px 10px;
|
|
||||||
border-bottom: 1px solid #e7eef5;
|
|
||||||
text-align: left;
|
|
||||||
color: #24384d;
|
|
||||||
}
|
|
||||||
.sku-table th {
|
|
||||||
background: #f2f7fb;
|
|
||||||
color: #4e6479;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
.sku-table tbody tr:last-child td {
|
|
||||||
border-bottom: 0;
|
|
||||||
}
|
|
||||||
.sku-input {
|
|
||||||
width: 110px;
|
|
||||||
min-height: 32px;
|
|
||||||
padding: 5px 8px;
|
|
||||||
border: 1px solid #cbd9e6;
|
|
||||||
border-radius: 7px;
|
|
||||||
background: #ffffff;
|
|
||||||
color: #24384d;
|
|
||||||
font-size: 13px;
|
|
||||||
font-family: inherit;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
.sku-input:focus {
|
|
||||||
border-color: #5f85ad;
|
|
||||||
}
|
|
||||||
.sku-id {
|
|
||||||
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
|
||||||
font-size: 12px;
|
|
||||||
color: #4e6479;
|
|
||||||
}
|
|
||||||
.save-hint {
|
|
||||||
margin: 0;
|
|
||||||
padding: 10px 14px;
|
|
||||||
border: 1px solid #cfe3f5;
|
|
||||||
border-radius: 10px;
|
|
||||||
background: #eef5fc;
|
|
||||||
color: #3b6d99;
|
|
||||||
font-size: 12.5px;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
|
||||||
.btn {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
min-height: 38px;
|
|
||||||
padding: 7px 16px;
|
|
||||||
border-radius: 9px;
|
|
||||||
font-size: 13px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.btn:disabled {
|
|
||||||
cursor: not-allowed;
|
|
||||||
opacity: 0.6;
|
|
||||||
}
|
|
||||||
.btn-secondary {
|
|
||||||
background: #ffffff;
|
|
||||||
color: #5b6f83;
|
|
||||||
border: 1px solid #c7d7e5;
|
|
||||||
}
|
|
||||||
.btn-secondary:hover:not(:disabled) {
|
|
||||||
color: #2f5d8b;
|
|
||||||
border-color: #95b1cb;
|
|
||||||
background: #edf5fb;
|
|
||||||
}
|
|
||||||
.btn:not(.btn-secondary) {
|
|
||||||
border: 1px solid #4f78a5;
|
|
||||||
background: linear-gradient(135deg, #5f85ad, #4f78a5);
|
|
||||||
color: #ffffff;
|
|
||||||
}
|
|
||||||
.btn:not(.btn-secondary):hover:not(:disabled) {
|
|
||||||
background: linear-gradient(135deg, #7094ba, #5d83ac);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,300 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
/** 京东商品编辑抽屉「图片区」子组件(2026-11-16 从 JdProductEditDrawer 拆出:编辑抽屉
|
|
||||||
* 856 行超后管 800 报警线,图片区自洽成件——× 右上角标删+hover 替换+新增主图,
|
|
||||||
* B109-01 落地,2026-11-16 客户口径「删除做成打叉的 icon 放图右上角,也要支持编辑
|
|
||||||
* 替换本地的图」)。
|
|
||||||
*
|
|
||||||
* 交互语义:× 标删=前端标记、随父级「保存」一并提交(deleteImageIds 上抛);替换/新增
|
|
||||||
* =multipart 立即生效(服务端置锁+刷投影),上传成功用返回详情回填本区并上抛 saved。
|
|
||||||
* objectKey 由服务端按上传字节 sha256 内容寻址生成(铁律 32),前端不自造 key。
|
|
||||||
* 形状照 JdProductEditDrawer 原图片区(image-grid + image-cell,零 element-plus)。 */
|
|
||||||
import { computed, ref, watch } from 'vue'
|
|
||||||
import { uploadJdProductImage } from './jd-product-api.ts'
|
|
||||||
import type { JdProductImage } from './jd-product-model.ts'
|
|
||||||
import { requestErrorMessage } from '../../api/envelope.ts'
|
|
||||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
productId: number
|
|
||||||
images: JdProductImage[]
|
|
||||||
/** 父级 loading 中禁上传入口。 */
|
|
||||||
disabled: boolean
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
(event: 'update:images', images: JdProductImage[]): void
|
|
||||||
(event: 'update:deleteIds', ids: number[]): void
|
|
||||||
(event: 'saved'): void
|
|
||||||
}>()
|
|
||||||
|
|
||||||
/** 标删的图片行 id(前端只标记,父级保存时一次提交 deleteImageIds)。 */
|
|
||||||
const deleteImageIds = ref<Set<number>>(new Set())
|
|
||||||
|
|
||||||
function toggleDeleteImage(image: JdProductImage): void {
|
|
||||||
const next = new Set(deleteImageIds.value)
|
|
||||||
if (next.has(image.id)) next.delete(image.id)
|
|
||||||
else next.add(image.id)
|
|
||||||
deleteImageIds.value = next
|
|
||||||
emit('update:deleteIds', [...next])
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------- 图片上传/替换(立即生效,与标删的「保存时生效」不同) ----------------
|
|
||||||
|
|
||||||
/** 文件选择上下文:null=新增主图;有值=替换该登记行(档位继承原行,后端语义)。 */
|
|
||||||
const pendingReplaceImageId = ref<number | null>(null)
|
|
||||||
const fileInputRef = ref<HTMLInputElement | null>(null)
|
|
||||||
/** 上传中的图行 id(0=新增上传中);上传期间防重复点。 */
|
|
||||||
const uploadingImageId = ref<number | null>(null)
|
|
||||||
const uploadError = ref('')
|
|
||||||
|
|
||||||
function pickImage(replaceImageId: number | null): void {
|
|
||||||
if (uploadingImageId.value !== null || props.disabled) return
|
|
||||||
uploadError.value = ''
|
|
||||||
pendingReplaceImageId.value = replaceImageId
|
|
||||||
// 同选一张图也要重触发 change:先清值再弹窗。
|
|
||||||
if (fileInputRef.value) {
|
|
||||||
fileInputRef.value.value = ''
|
|
||||||
fileInputRef.value.click()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onFileChosen(event: Event): Promise<void> {
|
|
||||||
const input = event.target as HTMLInputElement
|
|
||||||
const file = input.files?.[0]
|
|
||||||
if (!file || props.disabled) return
|
|
||||||
uploadingImageId.value = pendingReplaceImageId.value ?? 0
|
|
||||||
try {
|
|
||||||
const detail = await uploadJdProductImage(props.productId, file, pendingReplaceImageId.value
|
|
||||||
? { replaceImageId: pendingReplaceImageId.value }
|
|
||||||
: { imageType: 'MAIN' })
|
|
||||||
// 立即生效:用返回详情回填图片区(标删集合里已不存在的行 id 由 images watch 清理)。
|
|
||||||
emit('update:images', detail.images)
|
|
||||||
showAdminFeedback(pendingReplaceImageId.value ? '图片已替换(该商品已转为人工维护)' : '图片已新增(该商品已转为人工维护)', 'success')
|
|
||||||
emit('saved')
|
|
||||||
} catch (error) {
|
|
||||||
uploadError.value = requestErrorMessage(error) || '图片上传失败,请稍后重试'
|
|
||||||
} finally {
|
|
||||||
uploadingImageId.value = null
|
|
||||||
pendingReplaceImageId.value = null
|
|
||||||
input.value = ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 换商品打开时标删集合必须清零(父级 loadDetail 换 item.id)。 */
|
|
||||||
watch(() => props.productId, () => {
|
|
||||||
deleteImageIds.value = new Set()
|
|
||||||
emit('update:deleteIds', [])
|
|
||||||
})
|
|
||||||
|
|
||||||
/** 行集变化时清掉已不存在的标删 id(保存删行回填/上传回填两路共用;不清理的话
|
|
||||||
* 下次保存会把已删的 id 再提交一遍=后端按「图片不存在」整笔拒绝)。 */
|
|
||||||
watch(() => props.images, (images) => {
|
|
||||||
const live = new Set(images.map((image) => image.id))
|
|
||||||
const next = new Set([...deleteImageIds.value].filter((id) => live.has(id)))
|
|
||||||
if (next.size !== deleteImageIds.value.size) {
|
|
||||||
deleteImageIds.value = next
|
|
||||||
emit('update:deleteIds', [...next])
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const markedCount = computed(() => deleteImageIds.value.size)
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<section class="detail-block">
|
|
||||||
<div class="image-head">
|
|
||||||
<h4>图片(右上角 × 标记删除,保存时一并删除;替换 / 新增立即生效)</h4>
|
|
||||||
<button class="btn-add-image" type="button" :disabled="uploadingImageId !== null || disabled" @click="pickImage(null)">
|
|
||||||
{{ uploadingImageId === 0 ? '上传中...' : '+ 新增主图' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<input ref="fileInputRef" type="file" accept="image/jpeg,image/png,image/webp,image/gif" hidden @change="onFileChosen" />
|
|
||||||
<div v-if="images.length" class="image-grid">
|
|
||||||
<div
|
|
||||||
v-for="image in images"
|
|
||||||
:key="`${image.id}-${image.url}`"
|
|
||||||
class="image-cell"
|
|
||||||
:class="{ marked: deleteImageIds.has(image.id) }"
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
:src="image.url"
|
|
||||||
alt=""
|
|
||||||
loading="lazy"
|
|
||||||
:class="{ dimmed: deleteImageIds.has(image.id) || uploadingImageId === image.id }"
|
|
||||||
/>
|
|
||||||
<!-- 右上角 × 删除标记(京麦样式,2026-11-16 客户口径):点 × 标记,再点撤销。 -->
|
|
||||||
<button
|
|
||||||
class="image-x"
|
|
||||||
type="button"
|
|
||||||
:title="deleteImageIds.has(image.id) ? '撤销删除标记' : '标记删除(保存时一并删除)'"
|
|
||||||
@click="toggleDeleteImage(image)"
|
|
||||||
>×</button>
|
|
||||||
<!-- 标删遮罩(整格可点撤销),未标删时 hover 底部出现「替换」条。 -->
|
|
||||||
<button
|
|
||||||
v-if="deleteImageIds.has(image.id)"
|
|
||||||
class="image-marked-mask"
|
|
||||||
type="button"
|
|
||||||
title="点击撤销删除标记"
|
|
||||||
@click="toggleDeleteImage(image)"
|
|
||||||
>已标记删除 · 点击撤销</button>
|
|
||||||
<button
|
|
||||||
v-else
|
|
||||||
class="image-replace"
|
|
||||||
type="button"
|
|
||||||
:disabled="uploadingImageId !== null"
|
|
||||||
@click="pickImage(image.id)"
|
|
||||||
>{{ uploadingImageId === image.id ? '上传中...' : '替换' }}</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<p v-else class="drawer-tip">暂无图片(可点右上「+ 新增主图」上传本地图)</p>
|
|
||||||
<p v-if="uploadError" class="drawer-failure">{{ uploadError }}</p>
|
|
||||||
<p v-if="markedCount" class="delete-count">已标记删除 {{ markedCount }} 张,保存后剩余 {{ images.length - markedCount }} 张</p>
|
|
||||||
</section>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.image-head {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
.image-head h4 {
|
|
||||||
margin: 0 0 10px;
|
|
||||||
font-size: 13.5px;
|
|
||||||
font-weight: 650;
|
|
||||||
color: #4e6479;
|
|
||||||
}
|
|
||||||
.btn-add-image {
|
|
||||||
min-height: 30px;
|
|
||||||
padding: 4px 12px;
|
|
||||||
border: 1px solid #95b1cb;
|
|
||||||
border-radius: 8px;
|
|
||||||
background: #ffffff;
|
|
||||||
color: #2f5d8b;
|
|
||||||
font-size: 12.5px;
|
|
||||||
cursor: pointer;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.btn-add-image:hover {
|
|
||||||
background: #edf5fb;
|
|
||||||
}
|
|
||||||
.btn-add-image:disabled {
|
|
||||||
opacity: 0.55;
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
.image-grid {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
.image-cell {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.image-cell img {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
aspect-ratio: 1;
|
|
||||||
object-fit: cover;
|
|
||||||
border: 1px solid #d8e3ee;
|
|
||||||
border-radius: 8px;
|
|
||||||
background: #f2f7fb;
|
|
||||||
}
|
|
||||||
.image-cell img.dimmed {
|
|
||||||
opacity: 0.35;
|
|
||||||
}
|
|
||||||
.image-cell.marked img {
|
|
||||||
outline: 2px solid #d08a7b;
|
|
||||||
}
|
|
||||||
/* 右上角 × 删除标记(京麦样式):hover 格子时出现;已标删常显。 */
|
|
||||||
.image-x {
|
|
||||||
position: absolute;
|
|
||||||
top: 4px;
|
|
||||||
right: 4px;
|
|
||||||
display: none;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 22px;
|
|
||||||
height: 22px;
|
|
||||||
border: none;
|
|
||||||
border-radius: 50%;
|
|
||||||
background: rgba(38, 50, 63, 0.72);
|
|
||||||
color: #ffffff;
|
|
||||||
font-size: 15px;
|
|
||||||
line-height: 1;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.image-cell:hover .image-x,
|
|
||||||
.image-cell.marked .image-x {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
.image-x:hover {
|
|
||||||
background: #a04432;
|
|
||||||
}
|
|
||||||
/* 标删态:整格遮罩可点撤销。 */
|
|
||||||
.image-marked-mask {
|
|
||||||
position: absolute;
|
|
||||||
inset: 0;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 6px;
|
|
||||||
border: none;
|
|
||||||
border-radius: 8px;
|
|
||||||
background: rgba(160, 68, 50, 0.32);
|
|
||||||
color: #ffffff;
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 1.5;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.image-marked-mask:hover {
|
|
||||||
background: rgba(160, 68, 50, 0.5);
|
|
||||||
}
|
|
||||||
/* hover 底部替换条(京麦替换入口);上传中常显。 */
|
|
||||||
.image-replace {
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
display: none;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
min-height: 26px;
|
|
||||||
border: none;
|
|
||||||
border-radius: 0 0 8px 8px;
|
|
||||||
background: rgba(38, 50, 63, 0.72);
|
|
||||||
color: #ffffff;
|
|
||||||
font-size: 12px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.image-cell:hover .image-replace {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
.image-cell .image-replace:disabled {
|
|
||||||
display: flex;
|
|
||||||
background: rgba(38, 50, 63, 0.55);
|
|
||||||
cursor: wait;
|
|
||||||
}
|
|
||||||
.image-replace:hover {
|
|
||||||
background: #2f5d8b;
|
|
||||||
}
|
|
||||||
.delete-count {
|
|
||||||
margin: 10px 0 0;
|
|
||||||
color: #a04432;
|
|
||||||
font-size: 12.5px;
|
|
||||||
}
|
|
||||||
.drawer-tip {
|
|
||||||
margin: 0;
|
|
||||||
color: #8293a5;
|
|
||||||
font-size: 13.5px;
|
|
||||||
}
|
|
||||||
.drawer-failure {
|
|
||||||
margin: 10px 0 0;
|
|
||||||
padding: 10px 14px;
|
|
||||||
border: 1px solid #f0c9c2;
|
|
||||||
border-radius: 10px;
|
|
||||||
background: #fdf1ef;
|
|
||||||
color: #a04432;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
/** 类目级联面板的水平定位钳制(2026-11-16 客户截图「超出视窗了」:面板锚在触发框
|
|
||||||
* left:0,下钻到 3~4 栏时宽 600~800px,而「类目」筛选框在 jd-filter-row 流式布局里
|
|
||||||
* 常落在页面中部偏右 ⇒ 面板右半截伸出视窗,末栏被窗缘裁到只剩一列 radio 圆点)。
|
|
||||||
*
|
|
||||||
* 本文件是**纯钳制数学**(零依赖,node --test 可直测):默认锚左(偏移 0);视口右缘
|
|
||||||
* 装不下时整体左移到右缘贴齐(留 margin),左移后越出左缘则贴左缘为止。组件侧在面板
|
|
||||||
* 打开与栏数/搜索态变化后用真实 rect 调它(JdCategoryCascader.vue),栏数随下钻动态
|
|
||||||
* 1~4,宽度变了要重算——右贴齐后继续下钻即向左生长,不会再伸出右缘。 */
|
|
||||||
|
|
||||||
export interface PanelClampInput {
|
|
||||||
/** 触发框(.cat-cascader)的视口左缘 x。 */
|
|
||||||
hostLeft: number
|
|
||||||
/** 面板当前实际渲染宽(含边框;栏数不同宽度不同)。 */
|
|
||||||
panelWidth: number
|
|
||||||
/** 视口宽(window.innerWidth)。 */
|
|
||||||
viewportWidth: number
|
|
||||||
/** 视口两侧最小留白,默认 8px。 */
|
|
||||||
margin?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 返回面板相对触发框左缘应加的 left 偏移(px;负=左移、0=默认锚左即可、正=触发框
|
|
||||||
* 本身已贴近视口左缘时把面板推回 margin 内,物理上只在窄窗极端值出现)。 */
|
|
||||||
export function clampPanelLeftX(input: PanelClampInput): number {
|
|
||||||
const margin = input.margin ?? 8
|
|
||||||
const overflowRight = input.hostLeft + input.panelWidth - (input.viewportWidth - margin)
|
|
||||||
if (overflowRight <= 0) return 0
|
|
||||||
const desiredLeft = Math.max(margin, input.hostLeft - overflowRight)
|
|
||||||
return desiredLeft - input.hostLeft
|
|
||||||
}
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,402 +0,0 @@
|
|||||||
/* 像素复刻「外观专利数据库」页样式(panel-box + 自绘表格 + 旧式分页);列表只摆部分字段,全量属性在详情抽屉。 */
|
|
||||||
.jd-database-view {
|
|
||||||
font-family: inherit;
|
|
||||||
color: var(--c-text, #24384d);
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 18px;
|
|
||||||
}
|
|
||||||
.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;
|
|
||||||
}
|
|
||||||
.jd-panel-head {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
.jd-panel-head h3 {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
.jd-filter-row {
|
|
||||||
/* 可换行流式布局:固定 6 列 minmax(140px) 的网格在窄面板下最小宽超出容器,
|
|
||||||
把查询/重置挤出面板右缘(与「管理分组」重叠)。flex-wrap 让放不下的项自然折行。 */
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 12px;
|
|
||||||
align-items: flex-end;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
.jd-filter-row .form-group {
|
|
||||||
flex: 1 1 160px;
|
|
||||||
min-width: 150px;
|
|
||||||
max-width: 260px;
|
|
||||||
}
|
|
||||||
.jd-filter-actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 10px;
|
|
||||||
align-items: center;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.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="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.55;
|
|
||||||
}
|
|
||||||
.btn-secondary {
|
|
||||||
background: #ffffff;
|
|
||||||
color: #5b6f83;
|
|
||||||
border-color: #c7d7e5;
|
|
||||||
}
|
|
||||||
.btn-secondary:hover:not(:disabled) {
|
|
||||||
color: #2f5d8b;
|
|
||||||
border-color: #95b1cb;
|
|
||||||
background: #edf5fb;
|
|
||||||
}
|
|
||||||
.jd-toolbar {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
/* 工具栏里的下拉与按钮统一 42px 外壳(2026-11-16 用户口径「样式要统一」):
|
|
||||||
这一行此前只有 .btn 有壳,原生 <select> 落成 28px 灰框、字号也不跟,
|
|
||||||
与旁边按钮同排时高矮不齐(分组下拉同日上移进筛选行,本行只剩分类筛选一颗)。
|
|
||||||
数值与 .form-group select / .btn 同一套(42px 高、
|
|
||||||
9px 圆角、#cbd9e6 描边、#f8fbfd 底),箭头用内联 SVG 自绘,避免各浏览器原生
|
|
||||||
箭头粗细不一(appearance:none 后必须补 padding-right 给箭头留位)。 */
|
|
||||||
.jd-toolbar select {
|
|
||||||
min-height: 42px;
|
|
||||||
max-width: 220px;
|
|
||||||
padding: 0 34px 0 12px;
|
|
||||||
border: 1px solid #cbd9e6;
|
|
||||||
border-radius: 9px;
|
|
||||||
background-color: #f8fbfd;
|
|
||||||
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%235b6f83' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: right 12px center;
|
|
||||||
appearance: none;
|
|
||||||
-webkit-appearance: none;
|
|
||||||
color: #24384d;
|
|
||||||
font-family: inherit;
|
|
||||||
font-size: 13.5px;
|
|
||||||
cursor: pointer;
|
|
||||||
outline: none;
|
|
||||||
transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
|
|
||||||
}
|
|
||||||
.jd-toolbar select:hover {
|
|
||||||
border-color: #9fb7cd;
|
|
||||||
}
|
|
||||||
.jd-toolbar select:focus {
|
|
||||||
background-color: #ffffff;
|
|
||||||
border-color: #5f85ad;
|
|
||||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
|
||||||
}
|
|
||||||
/* 危险动作(删除勾选)推到行尾:留在「批量编辑分类/分类筛选」旁边会被读成同一组动作。 */
|
|
||||||
.jd-delete-btn {
|
|
||||||
margin-left: auto;
|
|
||||||
}
|
|
||||||
/* 分类管理(2026-11-17 独立分类管理页并入本页的对话框入口):贴着分类筛选下拉。 */
|
|
||||||
.jd-manage-btn {
|
|
||||||
margin-left: 6px;
|
|
||||||
}
|
|
||||||
/* 危险动作(删除勾选):与全站 .btn-danger 同形——实心红渐变+白字。
|
|
||||||
旧版是白底红字描边,落在工具栏里看着像「未激活的次要按钮」,与打卡/分组等页不统一。 */
|
|
||||||
.btn-danger {
|
|
||||||
background: linear-gradient(135deg, #c06d77, #b35f6a);
|
|
||||||
border-color: #b35f6a;
|
|
||||||
color: #ffffff;
|
|
||||||
}
|
|
||||||
.btn-danger:hover:not(:disabled) {
|
|
||||||
background: linear-gradient(135deg, #cb7c84, #b96570);
|
|
||||||
}
|
|
||||||
.jd-summary {
|
|
||||||
color: #5b6f83;
|
|
||||||
font-size: 13px;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
/* 非超管只读提示(2026-11-16 写权限收窄):紧跟汇总的一句话,不冒充可点按钮。 */
|
|
||||||
.jd-readonly-tip {
|
|
||||||
color: #8293a5;
|
|
||||||
font-size: 12.5px;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
/* 只有一个可见分组时锁定的组名(不可切):筛选行「分组」标签下的静态芯片(2026-11-16 用户口径
|
|
||||||
「做成分组」把下拉从工具栏上移进筛选行后跟着搬),与同排 select 同高同壳(42px/9px 圆角),
|
|
||||||
"一组锁定"和"多组下拉"两种形态占位一致;组名超宽省略号收口,不把筛选行撑破。 */
|
|
||||||
.jd-group-locked {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
min-height: 42px;
|
|
||||||
padding: 0 12px;
|
|
||||||
border: 1px solid #dbe5ee;
|
|
||||||
border-radius: 9px;
|
|
||||||
background: #f1f6fb;
|
|
||||||
color: #4e6479;
|
|
||||||
font-size: 13.5px;
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
|
||||||
.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;
|
|
||||||
}
|
|
||||||
/* 列宽收口(2026-11-16 用户口径「列表间距有点大」):1500px 的 min-width 让宽屏下
|
|
||||||
唯一的弹性列(商品信息)独吞剩余宽度,标题右侧留出近 800px 空白,价格/库存被推到最右。
|
|
||||||
商品信息改固定 520px 后各列按比例分摊余量,min-width 降到 1180px 即可无横向滚动。 */
|
|
||||||
.jd-table-scroll > table {
|
|
||||||
min-width: 1180px;
|
|
||||||
}
|
|
||||||
/* 操作列(编辑/删除):双小按钮需 138px(ops-cell-must-wrap 实测口径:两字按钮 53×2+24 padding)。
|
|
||||||
overflow 显式放开:td 全局是 overflow:hidden(611 行),压线时第二颗(删除)会被裁成
|
|
||||||
「编辑+…」的形状——2026-11-16 用户报「删除没了」的真因,列宽 120px < 实测 138px。 */
|
|
||||||
.jd-ops-cell {
|
|
||||||
white-space: nowrap;
|
|
||||||
text-overflow: clip;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
.btn-sm {
|
|
||||||
min-height: 28px;
|
|
||||||
padding: 3px 10px;
|
|
||||||
font-size: 12.5px;
|
|
||||||
margin-right: 6px;
|
|
||||||
}
|
|
||||||
.btn-sm:last-child {
|
|
||||||
margin-right: 0;
|
|
||||||
}
|
|
||||||
.table-scroll th,
|
|
||||||
.table-scroll td {
|
|
||||||
/* 单元格左右内距 12→10px(同上「间距有点大」):列与列之间少 4px,行内更紧凑。 */
|
|
||||||
padding: 10px 10px;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
/* 首列勾选格:checkbox 的 UA 默认 margin(3px 3px 3px 4px)使其 margin-box 溢出
|
|
||||||
42px 格的内容盒(42−24 padding=18px),配合上面的 overflow:hidden,Chromium 在
|
|
||||||
首次渲染时会把被裁的 checkbox 碎片留在裁剪边缘,看起来像格子右边多出 ".."。
|
|
||||||
margin 归零后 margin-box 收进内容盒,首渲染即干净(playwright 三次冷加载已验)。 */
|
|
||||||
.table-scroll th:first-child input,
|
|
||||||
.table-scroll td:first-child input {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
.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;
|
|
||||||
}
|
|
||||||
/* 点行开详情抽屉:行级 hover 已有底色反馈,光标再点一下提示可点。 */
|
|
||||||
.jd-row {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.jd-thumb {
|
|
||||||
display: block;
|
|
||||||
width: 48px;
|
|
||||||
height: 48px;
|
|
||||||
object-fit: cover;
|
|
||||||
border: 1px solid #d8e3ee;
|
|
||||||
border-radius: 6px;
|
|
||||||
background: #f2f7fb;
|
|
||||||
}
|
|
||||||
/* 商品信息列=京麦同款合并布局:td 的全局 nowrap/ellipsis 与多行内容冲突,本列放开换行,
|
|
||||||
截断交给内部各行(标题两行 line-clamp、编码/货号单行 ellipsis)。 */
|
|
||||||
.jd-info-cell {
|
|
||||||
white-space: normal;
|
|
||||||
text-overflow: clip;
|
|
||||||
}
|
|
||||||
.jd-info-wrap {
|
|
||||||
display: flex;
|
|
||||||
align-items: flex-start;
|
|
||||||
gap: 10px;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
.jd-info-figure {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
gap: 3px;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
.jd-thumb-empty {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
color: #8293a5;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
.jd-health {
|
|
||||||
color: #2e9e6b;
|
|
||||||
font-size: 11px;
|
|
||||||
line-height: 1.2;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.jd-info-body {
|
|
||||||
min-width: 0;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 3px;
|
|
||||||
}
|
|
||||||
.jd-info-title {
|
|
||||||
color: #24384d;
|
|
||||||
font-size: 13.5px;
|
|
||||||
font-weight: 500;
|
|
||||||
line-height: 1.45;
|
|
||||||
display: -webkit-box;
|
|
||||||
-webkit-line-clamp: 2;
|
|
||||||
-webkit-box-orient: vertical;
|
|
||||||
overflow: hidden;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
.jd-info-meta {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 4px;
|
|
||||||
color: #7b8a99;
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 1.4;
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
.jd-info-code {
|
|
||||||
font-family: "Cascadia Mono", "SF Mono", Consolas, "Courier New", monospace;
|
|
||||||
color: #4e6479;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
|
||||||
.jd-copy-btn {
|
|
||||||
flex-shrink: 0;
|
|
||||||
border: 0;
|
|
||||||
background: transparent;
|
|
||||||
color: #8aa5bf;
|
|
||||||
font-size: 12px;
|
|
||||||
cursor: pointer;
|
|
||||||
padding: 0 2px;
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
.jd-copy-btn:hover {
|
|
||||||
color: #3b82c4;
|
|
||||||
}
|
|
||||||
.jd-info-tags {
|
|
||||||
display: flex;
|
|
||||||
gap: 6px;
|
|
||||||
margin-top: 2px;
|
|
||||||
}
|
|
||||||
/* 品牌·类目行(京麦列表同款深色文字):信息 meta 是灰色,这行按京麦用主文字色。 */
|
|
||||||
.jd-brand-cat {
|
|
||||||
color: #3d5368;
|
|
||||||
font-weight: 550;
|
|
||||||
}
|
|
||||||
.jd-tag {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
height: 18px;
|
|
||||||
padding: 0 6px;
|
|
||||||
border: 1px solid #cfe3f5;
|
|
||||||
border-radius: 3px;
|
|
||||||
background: #eef5fc;
|
|
||||||
color: #3b82c4;
|
|
||||||
font-size: 11.5px;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.empty-tip {
|
|
||||||
padding: 44px 24px;
|
|
||||||
text-align: center;
|
|
||||||
color: #8293a5;
|
|
||||||
font-size: 13.5px;
|
|
||||||
}
|
|
||||||
@@ -1,305 +0,0 @@
|
|||||||
/** 京东数据库查询适配(v1.4 Phase 5):GET /api/admin/jd-products + 删除(DELETE /{id} +
|
|
||||||
* POST /batch-delete)+ 分组端点 /api/admin/jd-product-groups。
|
|
||||||
* 公司口径(2026-11-16 用户定案「删除掉公司 tab,参考品牌数据库」):全页零公司维度——
|
|
||||||
* 只读列表与类目下拉的 company_id 发送口已随公司 tab 摘除(后端读侧谓词同窗撤,重上时
|
|
||||||
* 从 git 历史找回),详情/编辑/删除/分组管理本就不带;行 company_id 列仍是同步来源标记、
|
|
||||||
* 随详情下发。反向钉在 company-tab-wiring「公司维度不得回流」清单。
|
|
||||||
* 导出发送口已随 2026-11-15 客户口径「导出也不用」从前端下线(后端 /export 端点保留)。 */
|
|
||||||
import { http } from '@/api/http'
|
|
||||||
import { errorTextOf, unwrap } from '../../api/envelope.ts'
|
|
||||||
import {
|
|
||||||
toJdProductListParams,
|
|
||||||
type JdProductListParams,
|
|
||||||
} from './jd-product-filter.ts'
|
|
||||||
import {
|
|
||||||
parseJdProductDetail,
|
|
||||||
parseJdProductPage,
|
|
||||||
type JdProductPageResult,
|
|
||||||
} from './jd-product-model.ts'
|
|
||||||
|
|
||||||
export const JD_PRODUCT_ENDPOINT = '/api/admin/jd-products'
|
|
||||||
export const JD_PRODUCT_GROUP_ENDPOINT = '/api/admin/jd-product-groups'
|
|
||||||
|
|
||||||
export async function fetchJdProductList(
|
|
||||||
params: JdProductListParams,
|
|
||||||
): Promise<JdProductPageResult> {
|
|
||||||
const query = toJdProductListParams(
|
|
||||||
{
|
|
||||||
productCode: params.productCode ?? '',
|
|
||||||
titleKeyword: params.titleKeyword ?? '',
|
|
||||||
category: params.category ?? '',
|
|
||||||
groupId: params.groupId ?? '',
|
|
||||||
syncedFrom: params.syncedFrom ?? '',
|
|
||||||
syncedTo: params.syncedTo ?? '',
|
|
||||||
},
|
|
||||||
params.page,
|
|
||||||
params.pageSize,
|
|
||||||
params.ownerGroupId ?? null,
|
|
||||||
)
|
|
||||||
const { data } = await http.get<unknown>(JD_PRODUCT_ENDPOINT, { params: query })
|
|
||||||
return parseJdProductPage(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 详情:GET /api/admin/jd-products/{id}(信封 data=主字段 + attrGroups + attrJsonRaw + images)。
|
|
||||||
* 公共库无公司维度,按 id 直取;分类字段按「当前分组」(owner_group_id)取(V203)。 */
|
|
||||||
export async function fetchJdProductDetail(
|
|
||||||
id: number,
|
|
||||||
ownerGroupId?: number | null,
|
|
||||||
): Promise<ReturnType<typeof parseJdProductDetail>> {
|
|
||||||
const params = typeof ownerGroupId === 'number' && ownerGroupId > 0
|
|
||||||
? { owner_group_id: ownerGroupId }
|
|
||||||
: undefined
|
|
||||||
const { data } = await http.get<unknown>(`${JD_PRODUCT_ENDPOINT}/${id}`, { params })
|
|
||||||
return parseJdProductDetail(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 删除回执(后端 JdProductDeleteVo):三个对象计数分开报——真删的、共用的、前缀外不敢动的。 */
|
|
||||||
export interface JdProductDeleteResult {
|
|
||||||
deleted: number
|
|
||||||
imagesDeleted: number
|
|
||||||
objectsDeleted: number
|
|
||||||
objectsKept: number
|
|
||||||
objectsSkipped: number
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 删除是先删桶、全成功才删库行(后端 JdProductDeleteService);失败文案原样抛给页面。
|
|
||||||
* 公共库写侧无公司维度(2026-11-15 用户定案)。 */
|
|
||||||
export async function deleteJdProducts(
|
|
||||||
ids: number[],
|
|
||||||
): Promise<JdProductDeleteResult> {
|
|
||||||
if (ids.length === 1) {
|
|
||||||
const { data } = await http.delete<unknown>(`${JD_PRODUCT_ENDPOINT}/${ids[0]}`)
|
|
||||||
return unwrap<JdProductDeleteResult>(data)
|
|
||||||
}
|
|
||||||
const { data } = await http.post<unknown>(`${JD_PRODUCT_ENDPOINT}/batch-delete`, { ids })
|
|
||||||
return unwrap<JdProductDeleteResult>(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 编辑提交负载(PUT /api/admin/jd-products/{id} body,后端 JdProductUpdateRequest):
|
|
||||||
* 主字段全量提交;attrGroups/skus/deleteImageIds 可选——null=不修改该块
|
|
||||||
* (后端对 null 块零触碰)。分类不在本负载里(V203:分类按数据权限分组归属存
|
|
||||||
* biz_jd_product_group_assign,编辑面不写 group_id,归类只走列表页「批量编辑分类」)。 */
|
|
||||||
export interface JdProductUpdatePayload {
|
|
||||||
title: string
|
|
||||||
brand: string | null
|
|
||||||
categoryPath: string | null
|
|
||||||
itemNum: string | null
|
|
||||||
priceMin: string | null
|
|
||||||
priceMax: string | null
|
|
||||||
stockTotal: number | null
|
|
||||||
saleStatus: string | null
|
|
||||||
attrGroups: { groupName: string; attrs: { key: string; label: string; value: string }[] }[] | null
|
|
||||||
skus: { skuId: string; price: string | null; stock: number | null }[] | null
|
|
||||||
deleteImageIds: number[] | null
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 编辑保存(PUT):主字段保存即置人工编辑锁(V199 manual_locked=1,后续采集不再覆盖该行);
|
|
||||||
* 失败文案原样抛给抽屉红条。公共库写侧无公司维度。返回刷新后的详情(与
|
|
||||||
* fetchJdProductDetail 同一信封),抽屉用它回填。 */
|
|
||||||
export async function updateJdProduct(
|
|
||||||
id: number,
|
|
||||||
payload: JdProductUpdatePayload,
|
|
||||||
): Promise<ReturnType<typeof parseJdProductDetail>> {
|
|
||||||
const { data } = await http.put<unknown>(`${JD_PRODUCT_ENDPOINT}/${id}`, payload)
|
|
||||||
return parseJdProductDetail(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 图片上传参数(POST /{id}/images multipart):replaceImageId 有值=替换该登记行
|
|
||||||
* (后端继承原行档位,imageType/attrName 忽略);缺省=新增(imageType=MAIN/DETAIL,
|
|
||||||
* ATTR 需带 attrName)。objectKey 由服务端按上传字节 sha256 内容寻址生成(铁律 32),
|
|
||||||
* 前端不自造 key。返回刷新后的详情(与 fetchJdProductDetail 同一信封)。 */
|
|
||||||
export interface JdProductImageUploadParams {
|
|
||||||
replaceImageId?: number
|
|
||||||
imageType?: 'MAIN' | 'ATTR' | 'DETAIL'
|
|
||||||
attrName?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 上传/替换商品图片(multipart 后端中转):上传/替换即生效(服务端立即落库并置
|
|
||||||
* 人工编辑锁),与「删图保存时批量生效」不同。失败文案原样抛给抽屉。 */
|
|
||||||
export async function uploadJdProductImage(
|
|
||||||
id: number,
|
|
||||||
file: File,
|
|
||||||
params: JdProductImageUploadParams,
|
|
||||||
): Promise<ReturnType<typeof parseJdProductDetail>> {
|
|
||||||
const body = new FormData()
|
|
||||||
body.append('file', file)
|
|
||||||
if (params.replaceImageId != null) {
|
|
||||||
body.append('replace_image_id', String(params.replaceImageId))
|
|
||||||
}
|
|
||||||
if (params.imageType) body.append('image_type', params.imageType)
|
|
||||||
if (params.attrName) body.append('attr_name', params.attrName)
|
|
||||||
const { data } = await http.post<unknown>(`${JD_PRODUCT_ENDPOINT}/${id}/images`, body, {
|
|
||||||
headers: { 'Content-Type': 'multipart/form-data' },
|
|
||||||
})
|
|
||||||
return parseJdProductDetail(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 分组行(GET 列表返回:[{id,name,ownerGroupId,sortOrder,productCount}])。 */
|
|
||||||
export interface JdProductGroup {
|
|
||||||
id: number
|
|
||||||
name: string
|
|
||||||
ownerGroupId: number
|
|
||||||
sortOrder: number
|
|
||||||
productCount: number
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 分组管理的写入负载(POST / PUT body:{name, sortOrder, ownerGroupId?})。 */
|
|
||||||
export interface JdProductGroupPayload {
|
|
||||||
name: string
|
|
||||||
sortOrder: number
|
|
||||||
/** 新建时归属的数据权限分组(缺省=操作者自己带的组,后端 requireWritableGroup 收敛)。 */
|
|
||||||
ownerGroupId?: number | null
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 「当前分组」下拉的一项(GET /scope 的 groups[],V203):editable=本账号对该组分类可写
|
|
||||||
* (建/改名/删除/归类)。跨公司的组名由后端拼进 label,前端不解析公司字段。 */
|
|
||||||
export interface JdCategoryGroupOption {
|
|
||||||
id: number
|
|
||||||
name: string
|
|
||||||
label: string
|
|
||||||
editable: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 分类作用域回执(GET /api/admin/jd-product-groups/scope):分组下拉 + 平台超管标记。 */
|
|
||||||
export interface JdCategoryScope {
|
|
||||||
platformSuperAdmin: boolean
|
|
||||||
defaultGroupId: number | null
|
|
||||||
groups: JdCategoryGroupOption[]
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 分组信封是 `{code, message, data}` 三段式:code 非 0 =业务失败,message 是中文文案
|
|
||||||
* (重名等),用 errorTextOf 取出来抛给界面展示(unwrap 只认 success=false,不认 code)。 */
|
|
||||||
function groupDataOf<T>(payload: unknown): T {
|
|
||||||
const record = payload && typeof payload === 'object' ? (payload as Record<string, unknown>) : null
|
|
||||||
if (record && typeof record.code === 'number' && record.code !== 0) {
|
|
||||||
throw new Error(errorTextOf(payload))
|
|
||||||
}
|
|
||||||
return unwrap<T>(payload)
|
|
||||||
}
|
|
||||||
|
|
||||||
function numberOr(value: unknown, fallback: number): number {
|
|
||||||
return typeof value === 'number' && Number.isFinite(value) ? Math.floor(value) : fallback
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 分组下拉/管理列表:按「当前分组」(owner_group_id)取该组的分类(V203,跨组不可见);
|
|
||||||
* 缺省=后端按作用域默认分组取。失败由页面自己兜(分类只是筛选项,不拦首屏行集)。 */
|
|
||||||
export async function fetchJdProductGroups(ownerGroupId?: number | null): Promise<JdProductGroup[]> {
|
|
||||||
const params = typeof ownerGroupId === 'number' && ownerGroupId > 0
|
|
||||||
? { owner_group_id: ownerGroupId }
|
|
||||||
: undefined
|
|
||||||
const { data } = await http.get<unknown>(JD_PRODUCT_GROUP_ENDPOINT, { params })
|
|
||||||
const core = unwrap<unknown>(data)
|
|
||||||
if (!Array.isArray(core)) return []
|
|
||||||
const out: JdProductGroup[] = []
|
|
||||||
for (const raw of core) {
|
|
||||||
if (!raw || typeof raw !== 'object') continue
|
|
||||||
const record = raw as Record<string, unknown>
|
|
||||||
const id = numberOr(record.id, 0)
|
|
||||||
if (id <= 0) continue
|
|
||||||
out.push({
|
|
||||||
id,
|
|
||||||
name: typeof record.name === 'string' ? record.name.trim() : '',
|
|
||||||
ownerGroupId: numberOr(record.ownerGroupId ?? record.owner_group_id, 0),
|
|
||||||
sortOrder: numberOr(record.sortOrder ?? record.sort_order, 0),
|
|
||||||
productCount: numberOr(record.productCount ?? record.product_count, 0),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 分类作用域(GET /scope):本账号可见的数据权限分组 + 每组可写标记。
|
|
||||||
* 页面用它渲染「分组」下拉并按 editable 渲染分类写入口;失败由页面自己兜(回空作用域=
|
|
||||||
* 分类列全空、分类管理页提示不属于任何分组,但商品列表照常可用)。 */
|
|
||||||
export async function fetchJdCategoryScope(): Promise<JdCategoryScope> {
|
|
||||||
const { data } = await http.get<unknown>(`${JD_PRODUCT_GROUP_ENDPOINT}/scope`)
|
|
||||||
const core = groupDataOf<unknown>(data)
|
|
||||||
const record = core && typeof core === 'object' ? (core as Record<string, unknown>) : {}
|
|
||||||
const rawGroups = Array.isArray(record.groups) ? record.groups : []
|
|
||||||
const groups: JdCategoryGroupOption[] = []
|
|
||||||
for (const raw of rawGroups) {
|
|
||||||
if (!raw || typeof raw !== 'object') continue
|
|
||||||
const row = raw as Record<string, unknown>
|
|
||||||
const id = numberOr(row.id, 0)
|
|
||||||
if (id <= 0) continue
|
|
||||||
const name = typeof row.name === 'string' ? row.name.trim() : ''
|
|
||||||
groups.push({
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
label: typeof row.label === 'string' && row.label.trim() ? row.label.trim() : name,
|
|
||||||
editable: row.editable === true,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
platformSuperAdmin: record.platformSuperAdmin === true || record.platform_super_admin === true,
|
|
||||||
defaultGroupId: numberOr(record.defaultGroupId ?? record.default_group_id, 0) || null,
|
|
||||||
groups,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 类目下拉选项(GET /categories 返回 [{name, productCount}],name=京麦末级类目即
|
|
||||||
* 落库的 category_path;等值过滤)。失败由页面自己兜(类目只是筛选项,不拦首屏行集)。 */
|
|
||||||
export interface JdProductCategoryOption {
|
|
||||||
name: string
|
|
||||||
productCount: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function fetchJdProductCategories(): Promise<JdProductCategoryOption[]> {
|
|
||||||
const { data } = await http.get<unknown>(`${JD_PRODUCT_ENDPOINT}/categories`)
|
|
||||||
const core = unwrap<unknown>(data)
|
|
||||||
if (!Array.isArray(core)) return []
|
|
||||||
const out: JdProductCategoryOption[] = []
|
|
||||||
for (const raw of core) {
|
|
||||||
if (!raw || typeof raw !== 'object') continue
|
|
||||||
const record = raw as Record<string, unknown>
|
|
||||||
const name = typeof record.name === 'string' ? record.name.trim() : ''
|
|
||||||
if (!name) continue
|
|
||||||
out.push({ name, productCount: numberOr(record.productCount ?? record.product_count, 0) })
|
|
||||||
}
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 新建分类(归属当前分组,V203):ownerGroupId 缺省=后端取操作者自己带的组;
|
|
||||||
* 同一分组内重名等业务失败把后端中文文案抛回(页面直接展示)。 */
|
|
||||||
export async function createJdProductGroup(
|
|
||||||
payload: JdProductGroupPayload,
|
|
||||||
): Promise<JdProductGroup | null> {
|
|
||||||
const body: Record<string, unknown> = { name: payload.name, sortOrder: payload.sortOrder }
|
|
||||||
if (typeof payload.ownerGroupId === 'number' && payload.ownerGroupId > 0) {
|
|
||||||
body.ownerGroupId = payload.ownerGroupId
|
|
||||||
}
|
|
||||||
const { data } = await http.post<unknown>(JD_PRODUCT_GROUP_ENDPOINT, body)
|
|
||||||
return groupDataOf<JdProductGroup | null>(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 改名/改排序;业务失败文案同上。 */
|
|
||||||
export async function updateJdProductGroup(
|
|
||||||
id: number,
|
|
||||||
payload: JdProductGroupPayload,
|
|
||||||
): Promise<JdProductGroup | null> {
|
|
||||||
const body: Record<string, unknown> = { name: payload.name, sortOrder: payload.sortOrder }
|
|
||||||
const { data } = await http.put<unknown>(`${JD_PRODUCT_GROUP_ENDPOINT}/${id}`, body)
|
|
||||||
return groupDataOf<JdProductGroup | null>(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 删除分组;业务失败文案同上。 */
|
|
||||||
export async function deleteJdProductGroup(id: number): Promise<void> {
|
|
||||||
const { data } = await http.delete<unknown>(`${JD_PRODUCT_GROUP_ENDPOINT}/${id}`)
|
|
||||||
groupDataOf<unknown>(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 批量人工归类(2026-11-17 起唯一入口=京东数据库页工具栏「批量编辑分类」;
|
|
||||||
* 旧「店铺分类弹窗+工具栏移除分类」已随同日口径下线):勾选商品行(跨页累计)
|
|
||||||
* → 归入当前分组(ownerGroupId)的指定分类或移出分类(V203:归属写
|
|
||||||
* biz_jd_product_group_assign 的 (product_id, owner_group_id) 一行,同一商品各组可各自归类)。
|
|
||||||
* groupId 传 null=移出本组分类;返回实际写入/解挂的归属行数。
|
|
||||||
* 归类<b>不再置人工编辑锁</b>(2026-11-16 用户拍板):分类不在商品行上,采集冲不掉它。
|
|
||||||
* 业务失败(分类不存在/不属于当前分组)把中文文案抛回,对话框红条原样展示。 */
|
|
||||||
export async function batchAssignJdProductGroup(
|
|
||||||
ids: number[],
|
|
||||||
groupId: number | null,
|
|
||||||
ownerGroupId: number,
|
|
||||||
): Promise<number> {
|
|
||||||
const body: Record<string, unknown> = { ids, groupId, ownerGroupId }
|
|
||||||
const { data } = await http.post<unknown>(`${JD_PRODUCT_ENDPOINT}/batch-assign-group`, body)
|
|
||||||
return groupDataOf<number>(data)
|
|
||||||
}
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
/** 京东数据库页筛选纯函数(v1.4 Phase 5):商品编码/标题关键字/类目/分组/同步起止 + snake 分页参数。
|
|
||||||
* 产出与后端契约 §列表 query 逐字对撞:`page`/`page_size`(默认 20、上限 100)、
|
|
||||||
* `product_code`、`title_keyword`、`category`(京麦末级类目等值过滤,2026-11-15 增)、
|
|
||||||
* `group_id`(当前分组下的分类 id)、`owner_group_id`(当前数据权限分组,V203)、
|
|
||||||
* `synced_from`/`synced_to`(ISO yyyy-MM-dd;空白不下发)。
|
|
||||||
* 商品状态筛选与导出(2026-11-15 客户口径「这两个不要/导出也不用」)已从前端下线;
|
|
||||||
* 店铺筛选同日客户口径「店铺不需要」从前端下线(后端 shop_name 参数同窗撤,DB 列与详情不动)。
|
|
||||||
* 后端 `sale_status` 参数与 `/export` 端点保留(无 UI 入口),重上时从 git 历史找回取值口。
|
|
||||||
* 分页钳制(铁律 15):page < 1 归 1、上限 10_000(后端 CR-18 同值),(page-1)*page_size
|
|
||||||
* 最大 999_900,Number.MAX_SAFE_INTEGER 也不会把乘积顶出安全整数。纯逻辑,node --test 直测。
|
|
||||||
* 公司维已整页摘除(2026-11-16 用户定案「删除掉公司 tab,参考品牌数据库」):归一化构造器
|
|
||||||
* 与入参类型都不认识 company_id——读侧发送口已随公司 tab 撤下(品牌库 2026-10-06 先例同形)。
|
|
||||||
* 日期默认空字符串:同步台账是累计数据,默认当天会让首屏只剩今天同步的行
|
|
||||||
* (date-filter-default-today 护栏 EXEMPT 口径,外观专利页同款)。 */
|
|
||||||
import { validIsoDateOrUndefined } from '../asin/asin-filter.ts'
|
|
||||||
|
|
||||||
/** 每页条数默认 20(v1.4 §3.4),上限 100。 */
|
|
||||||
export const JD_PRODUCT_PAGE_SIZE = 20
|
|
||||||
export const JD_PRODUCT_MAX_PAGE_SIZE = 100
|
|
||||||
/** 页码上限:与后端 MAX_PAGE(CR-18 先例,外观专利同值)对齐,两侧不漂。 */
|
|
||||||
export const JD_PRODUCT_MAX_PAGE = 10_000
|
|
||||||
|
|
||||||
export interface JdProductFilterState {
|
|
||||||
/** 商品编码,空串不限。 */
|
|
||||||
productCode: string
|
|
||||||
/** 标题关键字,空串不限。 */
|
|
||||||
titleKeyword: string
|
|
||||||
/** 类目(京麦末级类目名,等值过滤;选项来自 GET /categories),空串=全部类目。 */
|
|
||||||
category: string
|
|
||||||
/** 分组 id 文本(分组管理里那一行),空串=全部分组。 */
|
|
||||||
groupId: string
|
|
||||||
/** 同步开始日期(ISO yyyy-MM-dd;空串不限)。 */
|
|
||||||
syncedFrom: string
|
|
||||||
/** 同步结束日期(ISO yyyy-MM-dd;空串不限)。 */
|
|
||||||
syncedTo: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createJdProductFilterState(): JdProductFilterState {
|
|
||||||
return { productCode: '', titleKeyword: '', category: '', groupId: '', syncedFrom: '', syncedTo: '' }
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 是否有任一激活筛选条件。 */
|
|
||||||
export function jdProductFilterActive(state: JdProductFilterState): boolean {
|
|
||||||
if ((state.productCode || '').trim()) return true
|
|
||||||
if ((state.titleKeyword || '').trim()) return true
|
|
||||||
if ((state.category || '').trim()) return true
|
|
||||||
if ((state.groupId || '').trim()) return true
|
|
||||||
if (validIsoDateOrUndefined(state.syncedFrom) || validIsoDateOrUndefined(state.syncedTo)) return true
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 序列化到后端的列表查询参数(snake_case,仅下发非空字段)。 */
|
|
||||||
export interface JdProductQuery {
|
|
||||||
page: number
|
|
||||||
page_size: number
|
|
||||||
product_code?: string
|
|
||||||
title_keyword?: string
|
|
||||||
/** 京麦末级类目等值过滤(后端 JdProductQueryService.Filter.category)。 */
|
|
||||||
category?: string
|
|
||||||
/** 自定义分类 id(当前分组下的一个分类;V203 起按归属表 EXISTS 过滤)。 */
|
|
||||||
group_id?: number
|
|
||||||
/** 当前数据权限分组 id(分类列/分类筛选都按它取;V203「不同组不能看到跨组的分类」)。 */
|
|
||||||
owner_group_id?: number
|
|
||||||
synced_from?: string
|
|
||||||
synced_to?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
/** api 模块的入参:筛选态 + 分页 + 当前分组(公共库无公司维度)。 */
|
|
||||||
export interface JdProductListParams {
|
|
||||||
page: number
|
|
||||||
pageSize: number
|
|
||||||
productCode?: string
|
|
||||||
titleKeyword?: string
|
|
||||||
category?: string
|
|
||||||
groupId?: string
|
|
||||||
/** 当前分组(数据权限分组 id):分类列/分类筛选的作用域,非筛选条件(重置不清它)。 */
|
|
||||||
ownerGroupId?: number | null
|
|
||||||
syncedFrom?: string
|
|
||||||
syncedTo?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 过滤态 → 过滤面参数(snake_case,仅下发非空字段)。 */
|
|
||||||
function toJdProductFilterQuery(state: JdProductFilterState): Omit<JdProductQuery, 'page' | 'page_size'> {
|
|
||||||
const query: Omit<JdProductQuery, 'page' | 'page_size'> = {}
|
|
||||||
const productCode = (state.productCode || '').trim()
|
|
||||||
if (productCode) query.product_code = productCode
|
|
||||||
const titleKeyword = (state.titleKeyword || '').trim()
|
|
||||||
if (titleKeyword) query.title_keyword = titleKeyword
|
|
||||||
const category = (state.category || '').trim()
|
|
||||||
if (category) query.category = category
|
|
||||||
const groupId = Number.parseInt((state.groupId || '').trim(), 10)
|
|
||||||
if (Number.isFinite(groupId) && groupId > 0) query.group_id = groupId
|
|
||||||
const syncedFrom = validIsoDateOrUndefined(state.syncedFrom)
|
|
||||||
if (syncedFrom) query.synced_from = syncedFrom
|
|
||||||
const syncedTo = validIsoDateOrUndefined(state.syncedTo)
|
|
||||||
if (syncedTo) query.synced_to = syncedTo
|
|
||||||
return query
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 过滤态 + 分页 → 列表查询参数;空白/非法日期不下发,分页钳制在此单出口(不含公司维)。
|
|
||||||
* {@code ownerGroupId} 是「当前分组」(分类列/分类筛选作用域,V203),不是筛选条件:
|
|
||||||
* >0 时下发 `owner_group_id`,缺省/0 不下发=后端按作用域默认分组取。 */
|
|
||||||
export function toJdProductListParams(
|
|
||||||
state: JdProductFilterState,
|
|
||||||
page: number,
|
|
||||||
pageSize: number,
|
|
||||||
ownerGroupId?: number | null,
|
|
||||||
): JdProductQuery {
|
|
||||||
const safePage = Math.min(Math.max(Math.floor(page) || 1, 1), JD_PRODUCT_MAX_PAGE)
|
|
||||||
const rawSize = Math.floor(pageSize) || JD_PRODUCT_PAGE_SIZE
|
|
||||||
const safeSize = Math.min(Math.max(rawSize, 1), JD_PRODUCT_MAX_PAGE_SIZE)
|
|
||||||
const query: JdProductQuery = {
|
|
||||||
page: safePage,
|
|
||||||
page_size: safeSize,
|
|
||||||
...toJdProductFilterQuery(state),
|
|
||||||
}
|
|
||||||
if (typeof ownerGroupId === 'number' && Number.isFinite(ownerGroupId) && ownerGroupId > 0) {
|
|
||||||
query.owner_group_id = Math.floor(ownerGroupId)
|
|
||||||
}
|
|
||||||
return query
|
|
||||||
}
|
|
||||||
@@ -1,347 +0,0 @@
|
|||||||
/** 京东数据库列表查询模型(v1.4 Phase 5):解析 JdProductPageVo(camel),纯逻辑零依赖。
|
|
||||||
* camel 为正、snake 容错(与外观专利/去重页模型同形),缺 id 弃行。
|
|
||||||
* 纯函数、无框架依赖(envelope 只借纯 unwrap),node --test 可直测。 */
|
|
||||||
import { unwrap } from '../../api/envelope.ts'
|
|
||||||
|
|
||||||
/** 京东商品列表行(后端 JdProductItemVo,camel 为正)。 */
|
|
||||||
export interface JdProductItem {
|
|
||||||
id: number
|
|
||||||
shopId: number | null
|
|
||||||
shopName: string
|
|
||||||
productCode: string
|
|
||||||
skuId: string
|
|
||||||
/** 货号(京麦后台「货号」列,与 SKU 不是同一个值)。 */
|
|
||||||
itemNum: string
|
|
||||||
/** SKU 数(京麦后台「12个SKU」列)。 */
|
|
||||||
skuCount: number | null
|
|
||||||
/** 信息分(京麦后台「信息分」列)。 */
|
|
||||||
healthScore: number | null
|
|
||||||
title: string
|
|
||||||
brand: string
|
|
||||||
categoryPath: string
|
|
||||||
/** 价格区间下限(京麦 priceDetailVO.minJdPrice):后端 BigDecimal 序列化成 JSON number,
|
|
||||||
* decimalText 数值/字符串都收——2026-11-16 实录:text() 把 number 丢成空串=生产库
|
|
||||||
* 273/273 行 price_min 全有值而列表价格全显示「-」(用户报「价格没采集到」的真因)。 */
|
|
||||||
priceMin: string
|
|
||||||
/** 价格区间上限(京麦 priceDetailVO.maxJdPrice),解析口径同 priceMin。 */
|
|
||||||
priceMax: string
|
|
||||||
stockTotal: number | null
|
|
||||||
/** 上架中/已下架/审核中/草稿。 */
|
|
||||||
saleStatus: string
|
|
||||||
listTab: string
|
|
||||||
jdCreatedAt: string
|
|
||||||
/** 上架时间(京麦后台「上架时间」列,与创建时间不是同一个值)。 */
|
|
||||||
jdOnlineAt: string
|
|
||||||
jdUpdatedAt: string
|
|
||||||
mainImageUrl: string
|
|
||||||
attrCount: number | null
|
|
||||||
imageCount: number | null
|
|
||||||
groupId: number | null
|
|
||||||
groupName: string
|
|
||||||
syncedAt?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface JdProductPageResult {
|
|
||||||
items: JdProductItem[]
|
|
||||||
total: number
|
|
||||||
page: number
|
|
||||||
pageSize: number
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 前端首屏默认容量(与 filter 侧 JD_PRODUCT_PAGE_SIZE 同值 20)。 */
|
|
||||||
export const JD_PRODUCT_DEFAULT_SIZE = 20
|
|
||||||
|
|
||||||
export function emptyJdProductPage(): JdProductPageResult {
|
|
||||||
return { items: [], total: 0, page: 1, pageSize: JD_PRODUCT_DEFAULT_SIZE }
|
|
||||||
}
|
|
||||||
|
|
||||||
function text(value: unknown): string {
|
|
||||||
return typeof value === 'string' ? value.trim() : ''
|
|
||||||
}
|
|
||||||
|
|
||||||
function numberOrNull(value: unknown): number | null {
|
|
||||||
return typeof value === 'number' && Number.isFinite(value) ? Math.floor(value) : null
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 价格区间展示:min/max 都空为 -,只空一侧给单值。输入数值/字符串都收
|
|
||||||
* (后端 BigDecimal 序列化成 JSON number;列表行解析层之外,mount 测试 mock
|
|
||||||
* 绕过解析层时 number 会原样进这里——对 number 直接 .trim() 抛 TypeError
|
|
||||||
* 炸整页渲染,2026-11-16 实录),统一 decimalText 归一后再拼。 */
|
|
||||||
export function jdPriceRange(item: Pick<JdProductItem, 'priceMin' | 'priceMax'>): string {
|
|
||||||
const min = decimalText(item.priceMin).trim()
|
|
||||||
const max = decimalText(item.priceMax).trim()
|
|
||||||
if (min && max) return min === max ? min : `${min} ~ ${max}`
|
|
||||||
return min || max || ''
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 解析单行;缺 id 视为无效。camel 为正、snake 容错。 */
|
|
||||||
export function toJdProductItem(raw: unknown): JdProductItem | null {
|
|
||||||
if (!raw || typeof raw !== 'object') return null
|
|
||||||
const record = raw as Record<string, unknown>
|
|
||||||
const id = numberOrNull(record.id)
|
|
||||||
if (id === null) return null
|
|
||||||
return {
|
|
||||||
id,
|
|
||||||
shopId: numberOrNull(record.shopId ?? record.shop_id),
|
|
||||||
shopName: text(record.shopName ?? record.shop_name),
|
|
||||||
productCode: text(record.productCode ?? record.product_code),
|
|
||||||
skuId: text(record.skuId ?? record.sku_id),
|
|
||||||
itemNum: text(record.itemNum ?? record.item_num),
|
|
||||||
skuCount: numberOrNull(record.skuCount ?? record.sku_count),
|
|
||||||
healthScore: numberOrNull(record.healthScore ?? record.health_score),
|
|
||||||
title: text(record.title),
|
|
||||||
brand: text(record.brand),
|
|
||||||
categoryPath: text(record.categoryPath ?? record.category_path),
|
|
||||||
// 价格必须走 decimalText(数值/字符串都收):后端 BigDecimal 序列化成 JSON number,
|
|
||||||
// text() 对非字符串一律回空串=采集到的价格在解析层被丢掉(2026-11-16 生产库 273 行
|
|
||||||
// price_min 全有值、列表全「-」实录)。与详情 SKU 价(decimalText)同一出口。
|
|
||||||
priceMin: decimalText(record.priceMin ?? record.price_min),
|
|
||||||
priceMax: decimalText(record.priceMax ?? record.price_max),
|
|
||||||
stockTotal: numberOrNull(record.stockTotal ?? record.stock_total),
|
|
||||||
saleStatus: text(record.saleStatus ?? record.sale_status),
|
|
||||||
listTab: text(record.listTab ?? record.list_tab),
|
|
||||||
jdCreatedAt: text(record.jdCreatedAt ?? record.jd_created_at),
|
|
||||||
jdOnlineAt: text(record.jdOnlineAt ?? record.jd_online_at),
|
|
||||||
jdUpdatedAt: text(record.jdUpdatedAt ?? record.jd_updated_at),
|
|
||||||
mainImageUrl: text(record.mainImageUrl ?? record.main_image_url),
|
|
||||||
attrCount: numberOrNull(record.attrCount ?? record.attr_count),
|
|
||||||
imageCount: numberOrNull(record.imageCount ?? record.image_count),
|
|
||||||
groupId: numberOrNull(record.groupId ?? record.group_id),
|
|
||||||
groupName: text(record.groupName ?? record.group_name),
|
|
||||||
syncedAt: text(record.syncedAt ?? record.synced_at) || undefined,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 归一化分页负载(信封或已解包 VO)为前端结果;缺省字段回默认。 */
|
|
||||||
export function parseJdProductPage(payload: unknown): JdProductPageResult {
|
|
||||||
const out = emptyJdProductPage()
|
|
||||||
const core = unwrap<unknown>(payload)
|
|
||||||
if (!core || typeof core !== 'object') return out
|
|
||||||
const record = core as Record<string, unknown>
|
|
||||||
if (Array.isArray(record.items)) {
|
|
||||||
out.items = record.items
|
|
||||||
.map((raw) => toJdProductItem(raw))
|
|
||||||
.filter((item): item is JdProductItem => item !== null)
|
|
||||||
}
|
|
||||||
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 rawSize = record.pageSize ?? record.page_size
|
|
||||||
if (typeof rawSize === 'number' && rawSize >= 1) out.pageSize = Math.floor(rawSize)
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 详情属性块:attrGroups[{groupName, attrs:[{key,label,value}]}]。 */
|
|
||||||
export interface JdProductAttrEntry {
|
|
||||||
key: string
|
|
||||||
label: string
|
|
||||||
value: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface JdProductAttrGroup {
|
|
||||||
groupName: string
|
|
||||||
attrs: JdProductAttrEntry[]
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 详情图片:images[{id, imageType, attrName, sortNo, url, byteSize, width, height}]
|
|
||||||
* (id=biz_jd_product_image 行号,编辑抽屉按它提交删图;旧后端不带 id 时按缺 0 弃行口径不拦展示)。 */
|
|
||||||
export interface JdProductImage {
|
|
||||||
id: number
|
|
||||||
imageType: string
|
|
||||||
attrName: string
|
|
||||||
sortNo: number
|
|
||||||
url: string
|
|
||||||
byteSize: number | null
|
|
||||||
width: number | null
|
|
||||||
height: number | null
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 销售属性组合的一项(颜色=上衣 / 尺码=S,京麦详情页「销售属性」)。 */
|
|
||||||
export interface JdProductSkuAttr {
|
|
||||||
name: string
|
|
||||||
value: string
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 详情 SKU 行(后端 JdProductDetailVo.SkuVo,V198;京麦 12 行矩阵的一行)。 */
|
|
||||||
export interface JdProductSku {
|
|
||||||
skuId: string
|
|
||||||
skuName: string
|
|
||||||
/** 商家自定义序号(京麦 skuSeq)。 */
|
|
||||||
skuSeq: string
|
|
||||||
/** 京东价(后端 BigDecimal,前端按文本展示,不做金额运算)。 */
|
|
||||||
price: string
|
|
||||||
stock: number | null
|
|
||||||
saleAttrs: JdProductSkuAttr[]
|
|
||||||
sortNo: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface JdProductDetail {
|
|
||||||
item: JdProductItem
|
|
||||||
attrGroups: JdProductAttrGroup[]
|
|
||||||
images: JdProductImage[]
|
|
||||||
/** SKU 矩阵(京麦详情页「销售属性」区,V198;旧数据为空数组)。 */
|
|
||||||
skus: JdProductSku[]
|
|
||||||
/** attrGroups 解析失败时的原始 JSON 兜底(界面原样展示,不静默吞)。 */
|
|
||||||
attrJsonRaw: string
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 归一化 attrGroups(camel/snake 同级容错),非法项跳过、块名缺省归「属性」。 */
|
|
||||||
function toAttrGroups(raw: unknown): JdProductAttrGroup[] {
|
|
||||||
if (!Array.isArray(raw)) return []
|
|
||||||
const out: JdProductAttrGroup[] = []
|
|
||||||
for (const groupRaw of raw) {
|
|
||||||
if (!groupRaw || typeof groupRaw !== 'object') continue
|
|
||||||
const group = groupRaw as Record<string, unknown>
|
|
||||||
const groupName = text(group.groupName ?? group.group_name) || '属性'
|
|
||||||
const attrsRaw = group.attrs
|
|
||||||
if (!Array.isArray(attrsRaw)) continue
|
|
||||||
const attrs: JdProductAttrEntry[] = []
|
|
||||||
for (const attrRaw of attrsRaw) {
|
|
||||||
if (!attrRaw || typeof attrRaw !== 'object') continue
|
|
||||||
const attr = attrRaw as Record<string, unknown>
|
|
||||||
attrs.push({
|
|
||||||
key: text(attr.key),
|
|
||||||
label: text(attr.label),
|
|
||||||
value: text(attr.value),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
out.push({ groupName, attrs })
|
|
||||||
}
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 归一化 images;缺 url 弃行(界面没有可展示/可打开的目标),sortNo 缺省 0。 */
|
|
||||||
function toImages(raw: unknown): JdProductImage[] {
|
|
||||||
if (!Array.isArray(raw)) return []
|
|
||||||
const out: JdProductImage[] = []
|
|
||||||
for (const imageRaw of raw) {
|
|
||||||
if (!imageRaw || typeof imageRaw !== 'object') continue
|
|
||||||
const image = imageRaw as Record<string, unknown>
|
|
||||||
const url = text(image.url)
|
|
||||||
if (!url) continue
|
|
||||||
out.push({
|
|
||||||
id: numberOrNull(image.id) ?? 0,
|
|
||||||
imageType: text(image.imageType ?? image.image_type),
|
|
||||||
attrName: text(image.attrName ?? image.attr_name),
|
|
||||||
sortNo: numberOrNull(image.sortNo ?? image.sort_no) ?? 0,
|
|
||||||
url,
|
|
||||||
byteSize: numberOrNull(image.byteSize ?? image.byte_size),
|
|
||||||
width: numberOrNull(image.width),
|
|
||||||
height: numberOrNull(image.height),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 数值/字符串都收(后端 BigDecimal 序列化成 JSON number),去尾零后展示:
|
|
||||||
* 京麦详情页写 `162`,不给 `162.00`;数字形状之外的原文照原样回(不吞异常值)。 */
|
|
||||||
function decimalText(value: unknown): string {
|
|
||||||
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
||||||
return String(Math.round(value * 100) / 100)
|
|
||||||
}
|
|
||||||
const raw = text(value)
|
|
||||||
if (!/^\d+(?:\.\d+)?$/.test(raw)) return raw
|
|
||||||
return String(Math.round(Number(raw) * 100) / 100)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 归一化 SKU 矩阵(camel/snake 容错);缺 skuId 弃行(京麦每一行都以 skuId 为身份)。 */
|
|
||||||
function toSkus(raw: unknown): JdProductSku[] {
|
|
||||||
if (!Array.isArray(raw)) return []
|
|
||||||
const out: JdProductSku[] = []
|
|
||||||
for (const skuRaw of raw) {
|
|
||||||
if (!skuRaw || typeof skuRaw !== 'object') continue
|
|
||||||
const sku = skuRaw as Record<string, unknown>
|
|
||||||
const skuId = text(sku.skuId ?? sku.sku_id)
|
|
||||||
if (!skuId) continue
|
|
||||||
const saleAttrs: JdProductSkuAttr[] = []
|
|
||||||
const attrsRaw = sku.saleAttrs ?? sku.sale_attrs
|
|
||||||
if (Array.isArray(attrsRaw)) {
|
|
||||||
for (const attrRaw of attrsRaw) {
|
|
||||||
if (!attrRaw || typeof attrRaw !== 'object') continue
|
|
||||||
const attr = attrRaw as Record<string, unknown>
|
|
||||||
const value = text(attr.value)
|
|
||||||
if (!value) continue
|
|
||||||
saleAttrs.push({ name: text(attr.name) || '属性', value })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
out.push({
|
|
||||||
skuId,
|
|
||||||
skuName: text(sku.skuName ?? sku.sku_name),
|
|
||||||
skuSeq: text(sku.skuSeq ?? sku.sku_seq),
|
|
||||||
price: decimalText(sku.price),
|
|
||||||
stock: numberOrNull(sku.stock),
|
|
||||||
saleAttrs,
|
|
||||||
sortNo: numberOrNull(sku.sortNo ?? sku.sort_no) ?? 0,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 销售属性维度名(按首次出现顺序):京麦详情页「颜色 / 尺码」两列。 */
|
|
||||||
export function jdSkuDimensions(skus: JdProductSku[]): string[] {
|
|
||||||
const order: string[] = []
|
|
||||||
for (const sku of skus) {
|
|
||||||
for (const attr of sku.saleAttrs) {
|
|
||||||
if (!order.includes(attr.name)) order.push(attr.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return order
|
|
||||||
}
|
|
||||||
|
|
||||||
/** SKU 矩阵汇总:`12 个 SKU · ¥162 ~ ¥168 · 库存 2400`(缺项不硬凑)。 */
|
|
||||||
export function jdSkuSummary(skus: JdProductSku[]): string {
|
|
||||||
if (!skus.length) return ''
|
|
||||||
const prices = skus
|
|
||||||
.map((sku) => Number(sku.price))
|
|
||||||
.filter((value) => Number.isFinite(value) && value > 0)
|
|
||||||
const priceText = prices.length
|
|
||||||
? Math.min(...prices) === Math.max(...prices)
|
|
||||||
? `¥${Math.min(...prices)}`
|
|
||||||
: `¥${Math.min(...prices)} ~ ¥${Math.max(...prices)}`
|
|
||||||
: ''
|
|
||||||
const stocks = skus.map((sku) => sku.stock).filter((value): value is number => typeof value === 'number')
|
|
||||||
const stockText = stocks.length ? `库存 ${stocks.reduce((sum, value) => sum + value, 0)}` : ''
|
|
||||||
return [`${skus.length} 个 SKU`, priceText, stockText].filter(Boolean).join(' · ')
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 解析详情负载(信封或已解包 VO);attrGroups 解析不出时回 attrJsonRaw 原文兜底。 */
|
|
||||||
export function parseJdProductDetail(payload: unknown): JdProductDetail {
|
|
||||||
const core = unwrap<unknown>(payload)
|
|
||||||
const record = core && typeof core === 'object' ? (core as Record<string, unknown>) : {}
|
|
||||||
const item = toJdProductItem(record) ?? {
|
|
||||||
id: 0,
|
|
||||||
shopId: null,
|
|
||||||
shopName: '',
|
|
||||||
productCode: '',
|
|
||||||
skuId: '',
|
|
||||||
itemNum: '',
|
|
||||||
skuCount: null,
|
|
||||||
healthScore: null,
|
|
||||||
title: '',
|
|
||||||
brand: '',
|
|
||||||
categoryPath: '',
|
|
||||||
priceMin: '',
|
|
||||||
priceMax: '',
|
|
||||||
stockTotal: null,
|
|
||||||
saleStatus: '',
|
|
||||||
listTab: '',
|
|
||||||
jdCreatedAt: '',
|
|
||||||
jdOnlineAt: '',
|
|
||||||
jdUpdatedAt: '',
|
|
||||||
mainImageUrl: '',
|
|
||||||
attrCount: null,
|
|
||||||
imageCount: null,
|
|
||||||
groupId: null,
|
|
||||||
groupName: '',
|
|
||||||
}
|
|
||||||
const attrGroups = toAttrGroups(record.attrGroups ?? record.attr_groups)
|
|
||||||
const attrJsonRaw = typeof record.attrJsonRaw === 'string'
|
|
||||||
? record.attrJsonRaw
|
|
||||||
: typeof record.attr_json_raw === 'string' ? record.attr_json_raw : ''
|
|
||||||
return {
|
|
||||||
item,
|
|
||||||
attrGroups,
|
|
||||||
images: toImages(record.images),
|
|
||||||
skus: toSkus(record.skus),
|
|
||||||
attrJsonRaw,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -21,12 +21,6 @@ const logoUrl = joinAdminPath('assets', 'logo.jpg')
|
|||||||
const inputType = computed(() => (showPassword.value ? 'text' : 'password'))
|
const inputType = computed(() => (showPassword.value ? 'text' : 'password'))
|
||||||
/** 单设备登录:被新设备顶下线后跳回登录页(整页跳转携带 ?kicked=1) */
|
/** 单设备登录:被新设备顶下线后跳回登录页(整页跳转携带 ?kicked=1) */
|
||||||
const kickedNotice = computed(() => route.query.kicked === '1')
|
const kickedNotice = computed(() => route.query.kicked === '1')
|
||||||
/** 会话被服务端终止的成因(拦截器读 X-Auth-Reason 带成 ?auth=):停用/删除点名,其余不显示。 */
|
|
||||||
const authNotice = computed(() => {
|
|
||||||
if (route.query.auth === 'disabled') return '该账号已被管理员停用,本设备已退出登录。如有疑问请联系管理员。'
|
|
||||||
if (route.query.auth === 'deleted') return '该账号已被删除,本设备已退出登录。'
|
|
||||||
return ''
|
|
||||||
})
|
|
||||||
|
|
||||||
function deviceId(): string {
|
function deviceId(): string {
|
||||||
try {
|
try {
|
||||||
@@ -136,7 +130,6 @@ onMounted(() => {
|
|||||||
</header>
|
</header>
|
||||||
<form novalidate @submit.prevent="submit">
|
<form novalidate @submit.prevent="submit">
|
||||||
<p v-if="kickedNotice" class="kicked-msg" role="alert">该账号已在其他设备登录,本设备已下线。如非本人操作,请及时修改密码。</p>
|
<p v-if="kickedNotice" class="kicked-msg" role="alert">该账号已在其他设备登录,本设备已下线。如非本人操作,请及时修改密码。</p>
|
||||||
<p v-if="authNotice" class="kicked-msg" role="alert">{{ authNotice }}</p>
|
|
||||||
<p v-if="errorMessage" class="error-msg" role="alert">{{ errorMessage }}</p>
|
<p v-if="errorMessage" class="error-msg" role="alert">{{ errorMessage }}</p>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="loginUsername">用户名</label>
|
<label for="loginUsername">用户名</label>
|
||||||
|
|||||||
@@ -1,444 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { formatDateTime, orderedPair } from '@/utils/datetime'
|
|
||||||
/** 外观专利数据库 · 明细分页表(2026-11-11 晚间按客户口径恢复「昨天那个格式」:
|
|
||||||
* 「不是这种格式 你就按照昨天那个格式」——撤掉一主管一卡视图,恢复只读明细表;
|
|
||||||
* 「添加个管理员 跟导出数据就可以」——表上加「管理员」列(后端读侧现算:主管/公司超管=自己,
|
|
||||||
* 普通账户=创建人,读不到为空展示 -,不猜名),筛选行加「导出」(与「去重数据库」页同款:
|
|
||||||
* 当前过滤面+公司 tab 全量出 xlsx,不传 supervisor_user_id——传了会走按主管分支并忽略任务号/ASIN);
|
|
||||||
* 「任务号/ASIN 两个筛选框恢复」(后端能力一直在,之前产品决定下过架,客户要「一目了然」选数据);
|
|
||||||
* 分组(主管)下拉保留「选中即查」。数据按 ASIN 累计:同 ASIN 只保留一条(V192 唯一键,
|
|
||||||
* 重复检测更新那条),不同 ASIN 同品牌全保留——页面只管展示,累计语义在后端同步链。
|
|
||||||
* 主管卡片视图与卡片级删除按钮从页面下架(客户下午反馈数据疑似被误删,删除入口先撤;
|
|
||||||
* 后端 /supervisors 两接口保留不动)。 */
|
|
||||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
|
||||||
import {
|
|
||||||
exportAppearancePatentCleanList,
|
|
||||||
fetchAppearancePatentCleanList,
|
|
||||||
fetchDedupeTotalGroups,
|
|
||||||
type DedupeGroupOption,
|
|
||||||
} from './appearance-patent-clean-api.ts'
|
|
||||||
import type { AppearancePatentCleanItem } from './appearance-patent-clean-model.ts'
|
|
||||||
import { cleanItemReasonTooltip } from './appearance-patent-clean-model.ts'
|
|
||||||
import { createAppearancePatentCleanFilterState } from './appearance-patent-clean-filter.ts'
|
|
||||||
import { ASIN_COUNTRY_CODES, asinCountryLabel } from '../asin/asin-country.ts'
|
|
||||||
import OldPagination from '@/components/OldPagination.vue'
|
|
||||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
|
||||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
|
||||||
import { loadFailureMessage } from '@/components/load-failure-model'
|
|
||||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
|
||||||
|
|
||||||
const companyTab = useCompanyTabStore()
|
|
||||||
|
|
||||||
const loading = ref(false)
|
|
||||||
const loadFailure = ref('')
|
|
||||||
const rows = ref<AppearancePatentCleanItem[]>([])
|
|
||||||
const total = ref(0)
|
|
||||||
const page = ref(1)
|
|
||||||
const pageSize = ref(10)
|
|
||||||
/** 导出在途锁:避免连点导出把同一份过滤面重复请求两遍。 */
|
|
||||||
const exporting = ref(false)
|
|
||||||
/** 同步台账是累计数据,日期初值故意留空(默认当天会让首屏只剩今天同步的行);见 date-filter-default-today 护栏的 EXEMPT。 */
|
|
||||||
const filter = reactive(createAppearancePatentCleanFilterState())
|
|
||||||
/** 分组(主管)下拉选项:公司 tab 切换时重取;选项失败不拦列表,只回空下拉(可见「全部分组」)。 */
|
|
||||||
const groupOptions = ref<DedupeGroupOption[]>([])
|
|
||||||
/** min/max 挡不住手输,落值后把倒挂的起止交换回来。 */
|
|
||||||
function clampDatePair(): void {
|
|
||||||
const [s, e] = orderedPair(filter.startDate, filter.endDate)
|
|
||||||
filter.startDate = s
|
|
||||||
filter.endDate = e
|
|
||||||
}
|
|
||||||
|
|
||||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
|
||||||
|
|
||||||
/** 分组选项与去重页/店铺管理同源(GET /shop-manages/groups);失败静默回空——分组只是筛选项,
|
|
||||||
* 不该让它把首屏行集一起拖死(列表失败有自己的 LoadFailureBar)。 */
|
|
||||||
async function loadGroupOptions(): Promise<void> {
|
|
||||||
try {
|
|
||||||
groupOptions.value = await fetchDedupeTotalGroups(companyTab.requestCompanyId)
|
|
||||||
} catch {
|
|
||||||
groupOptions.value = []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function load(): Promise<void> {
|
|
||||||
loading.value = true
|
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
|
||||||
const result = await fetchAppearancePatentCleanList({
|
|
||||||
page: page.value,
|
|
||||||
pageSize: pageSize.value,
|
|
||||||
taskId: filter.taskId,
|
|
||||||
asin: filter.asin,
|
|
||||||
country: filter.country,
|
|
||||||
groupId: filter.groupId,
|
|
||||||
startDate: filter.startDate,
|
|
||||||
endDate: filter.endDate,
|
|
||||||
companyId: companyTab.requestCompanyId,
|
|
||||||
})
|
|
||||||
rows.value = result.items
|
|
||||||
total.value = result.total
|
|
||||||
if (result.page >= 1) page.value = result.page
|
|
||||||
} catch (error) {
|
|
||||||
loadFailure.value = loadFailureMessage(error, '无侵权数据加载失败')
|
|
||||||
showAdminFeedback(loadFailure.value, 'error')
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 导出与页签同一过滤面(含公司 tab 与分组),服务端全量出 xlsx;成功后浏览器落盘,失败弹可读文案。
|
|
||||||
* 不传 supervisor_user_id:按主管分支会忽略任务号/ASIN 参数,「按当前筛选导出」必须走明细分支。 */
|
|
||||||
async function exportAll(): Promise<void> {
|
|
||||||
if (exporting.value) return
|
|
||||||
exporting.value = true
|
|
||||||
try {
|
|
||||||
const result = await exportAppearancePatentCleanList({
|
|
||||||
taskId: filter.taskId,
|
|
||||||
asin: filter.asin,
|
|
||||||
country: filter.country,
|
|
||||||
groupId: filter.groupId,
|
|
||||||
startDate: filter.startDate,
|
|
||||||
endDate: filter.endDate,
|
|
||||||
companyId: companyTab.requestCompanyId,
|
|
||||||
})
|
|
||||||
const url = URL.createObjectURL(result.blob)
|
|
||||||
const anchor = document.createElement('a')
|
|
||||||
anchor.href = url
|
|
||||||
anchor.download = result.filename
|
|
||||||
document.body.appendChild(anchor)
|
|
||||||
anchor.click()
|
|
||||||
anchor.remove()
|
|
||||||
URL.revokeObjectURL(url)
|
|
||||||
showAdminFeedback(`已导出 ${result.filename}`, 'success')
|
|
||||||
} catch (error) {
|
|
||||||
const message = error instanceof Error && error.message ? error.message : '导出失败,请稍后重试'
|
|
||||||
showAdminFeedback(message, 'error')
|
|
||||||
} finally {
|
|
||||||
exporting.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function apply(): void {
|
|
||||||
page.value = 1
|
|
||||||
void load()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 重置(对齐店铺数据记录页样式):筛选面回出厂空态,回第一页重取。 */
|
|
||||||
function reset(): void {
|
|
||||||
Object.assign(filter, createAppearancePatentCleanFilterState())
|
|
||||||
page.value = 1
|
|
||||||
void load()
|
|
||||||
}
|
|
||||||
|
|
||||||
function changePage(next: number): void {
|
|
||||||
if (next < 1 || next > totalPages.value) return
|
|
||||||
page.value = next
|
|
||||||
void load()
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeSize(size: number) {
|
|
||||||
pageSize.value = size
|
|
||||||
page.value = 1
|
|
||||||
void load()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 切公司 = 重新取数:任务号/ASIN/分组是上一家选中的值,在新一家的行集里筛不出东西,必须一起清,
|
|
||||||
// 分组选项也按新公司重取(选项集是公司隔离的)。
|
|
||||||
watch(() => companyTab.activeId, () => { filter.taskId = ''; filter.asin = ''; filter.groupId = ''; page.value = 1; void loadGroupOptions(); void load() })
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
void loadGroupOptions()
|
|
||||||
void load()
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="clean-items-view">
|
|
||||||
<section class="panel-box">
|
|
||||||
<div class="clean-panel-head">
|
|
||||||
<h3>外观专利数据库</h3>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="clean-filter-row">
|
|
||||||
<div class="form-group">
|
|
||||||
<label>任务号</label>
|
|
||||||
<input v-model="filter.taskId" type="text" placeholder="输入任务号" @keyup.enter="apply" />
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>ASIN</label>
|
|
||||||
<input v-model="filter.asin" type="text" placeholder="输入 ASIN" @keyup.enter="apply" />
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>国家</label>
|
|
||||||
<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="form-group">
|
|
||||||
<label>分组</label>
|
|
||||||
<!-- 分组(主管)选中即查:选完立刻按该主管过滤刷新(回第一页),不必再点查询。 -->
|
|
||||||
<select v-model="filter.groupId" @change="apply">
|
|
||||||
<option value="">全部分组</option>
|
|
||||||
<option v-for="group in groupOptions" :key="group.id" :value="String(group.id)">{{ group.name }}</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>同步开始日期</label>
|
|
||||||
<input v-model="filter.startDate" type="date" :max="filter.endDate" @change="clampDatePair" />
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>同步结束日期</label>
|
|
||||||
<input v-model="filter.endDate" type="date" :min="filter.startDate" @change="clampDatePair" />
|
|
||||||
</div>
|
|
||||||
<div class="clean-filter-actions">
|
|
||||||
<button class="btn" type="button" @click="apply">查询</button>
|
|
||||||
<button class="btn btn-export" type="button" :disabled="exporting" @click="exportAll">
|
|
||||||
{{ exporting ? '导出中...' : '导出' }}
|
|
||||||
</button>
|
|
||||||
<button class="btn btn-secondary" type="button" @click="reset">重置</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
|
||||||
<div class="clean-toolbar">
|
|
||||||
<span class="clean-summary">共 {{ total }} 条无侵权数据</span>
|
|
||||||
</div>
|
|
||||||
<div class="table-scroll clean-table-scroll">
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th style="width: 90px">任务号</th>
|
|
||||||
<th style="width: 110px">管理员</th>
|
|
||||||
<th>ASIN</th>
|
|
||||||
<th style="width: 64px">国家</th>
|
|
||||||
<th>SKU</th>
|
|
||||||
<th>品牌</th>
|
|
||||||
<th style="width: 90px">价格</th>
|
|
||||||
<th>标题</th>
|
|
||||||
<th style="width: 130px">结论</th>
|
|
||||||
<th style="width: 170px">同步时间</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<template v-if="rows.length">
|
|
||||||
<tr v-for="row in rows" :key="row.id">
|
|
||||||
<td>{{ row.taskId ?? '-' }}</td>
|
|
||||||
<td :title="row.supervisorName || ''">{{ row.supervisorName || '-' }}</td>
|
|
||||||
<td class="mono-cell">{{ row.asin || '-' }}</td>
|
|
||||||
<td>{{ asinCountryLabel(row.country || '') }}</td>
|
|
||||||
<td class="mono-cell">{{ row.sku || '-' }}</td>
|
|
||||||
<td>{{ row.brand || '-' }}</td>
|
|
||||||
<td>{{ row.price || '-' }}</td>
|
|
||||||
<td class="title-cell" :title="row.title">{{ row.title || '-' }}</td>
|
|
||||||
<td class="conclusion-cell" :title="cleanItemReasonTooltip(row)">{{ row.conclusion || '-' }}</td>
|
|
||||||
<td>{{ formatDateTime(row.syncedAt || '') }}</td>
|
|
||||||
</tr>
|
|
||||||
</template>
|
|
||||||
<tr v-else-if="loading">
|
|
||||||
<td colspan="10" class="empty-tip">加载中...</td>
|
|
||||||
</tr>
|
|
||||||
<tr v-else>
|
|
||||||
<td colspan="10" class="empty-tip">暂无无侵权数据</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<OldPagination :total="total" :page="page" :page-size="pageSize" @change="changePage" @size-change="changeSize" />
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
/* 像素复刻参照「去重数据库」页(panel-box + 自绘表格 + 旧式分页),只读无操作列。
|
|
||||||
2026-11-11 晚间恢复明细表形态(客户「按照昨天那个格式」),表头第二列=管理员。 */
|
|
||||||
.clean-items-view {
|
|
||||||
font-family: inherit;
|
|
||||||
color: var(--c-text, #24384d);
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 18px;
|
|
||||||
}
|
|
||||||
.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;
|
|
||||||
}
|
|
||||||
.clean-panel-head h3 {
|
|
||||||
margin: 0 0 16px;
|
|
||||||
}
|
|
||||||
.clean-filter-row {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(6, minmax(150px, 1fr)) auto;
|
|
||||||
gap: 12px;
|
|
||||||
align-items: end;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
.clean-filter-row .form-group {
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
.clean-filter-actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 10px;
|
|
||||||
align-items: center;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.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="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;
|
|
||||||
}
|
|
||||||
.clean-toolbar {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
.clean-summary {
|
|
||||||
color: #5b6f83;
|
|
||||||
font-size: 13px;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.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;
|
|
||||||
}
|
|
||||||
/* 同步时间列=`YYYY-MM-DD HH:mm:ss` 固定 19 字符,13.5px 下实测约 133px;全局 `* { box-sizing: border-box }`
|
|
||||||
把 24px 左右内边距算进列宽,旧的 150px 只剩 126px 内容宽 ⇒ 末尾被 ellipsis 吃掉(客户 2026-11-12
|
|
||||||
反馈「日期显示不全」)。170px 与店铺管理/跳过价格等页的时间列同值(内容宽 146px,留 13px 余量);
|
|
||||||
表 min-width 同步 +20px,其余列的可用宽度与改前一致。 */
|
|
||||||
.clean-table-scroll > table {
|
|
||||||
min-width: 1060px;
|
|
||||||
}
|
|
||||||
.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;
|
|
||||||
}
|
|
||||||
.title-cell {
|
|
||||||
max-width: 260px;
|
|
||||||
}
|
|
||||||
.conclusion-cell {
|
|
||||||
max-width: 130px;
|
|
||||||
}
|
|
||||||
.empty-tip {
|
|
||||||
padding: 44px 24px;
|
|
||||||
text-align: center;
|
|
||||||
color: #8293a5;
|
|
||||||
font-size: 13.5px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
/** 外观专利无侵权数据列表查询适配(v1.3 AC-5):GET /api/admin/appearance-patent-clean-items。
|
|
||||||
* 只读页+导出(2026-11-11 客户需求「数据得导出来」):公司 tab 的值由本发送口从原始入参自己下传
|
|
||||||
* (白名单构造不认识 company_id),取值口形状由 company-tab-wiring 护栏钉住。
|
|
||||||
* 2026-11-11 晚间恢复明细表:主管聚合(/supervisors)与按主管删除的前端发送口随卡片视图一并
|
|
||||||
* 下架(客户「不是这种格式 按照昨天那个格式」+删除入口先撤);后端两接口保留,要恢复时
|
|
||||||
* 从 git 历史(e1767faf)找回。 */
|
|
||||||
import { http } from '@/api/http'
|
|
||||||
import { errorTextOf, unwrap } from '../../api/envelope.ts'
|
|
||||||
import {
|
|
||||||
toAppearancePatentCleanExportParams,
|
|
||||||
toAppearancePatentCleanListParams,
|
|
||||||
type AppearancePatentCleanExportParams,
|
|
||||||
type AppearancePatentCleanExportQuery,
|
|
||||||
type AppearancePatentCleanListParams,
|
|
||||||
} from './appearance-patent-clean-filter.ts'
|
|
||||||
import {
|
|
||||||
parseAppearancePatentCleanPage,
|
|
||||||
type AppearancePatentCleanPageResult,
|
|
||||||
} from './appearance-patent-clean-model.ts'
|
|
||||||
|
|
||||||
export const APPEARANCE_PATENT_CLEAN_ENDPOINT = '/api/admin/appearance-patent-clean-items'
|
|
||||||
|
|
||||||
export async function fetchAppearancePatentCleanList(
|
|
||||||
params: AppearancePatentCleanListParams,
|
|
||||||
): Promise<AppearancePatentCleanPageResult> {
|
|
||||||
const query = toAppearancePatentCleanListParams(
|
|
||||||
{
|
|
||||||
taskId: params.taskId ?? '',
|
|
||||||
asin: params.asin ?? '',
|
|
||||||
country: params.country ?? '',
|
|
||||||
groupId: params.groupId ?? '',
|
|
||||||
startDate: params.startDate ?? '',
|
|
||||||
endDate: params.endDate ?? '',
|
|
||||||
},
|
|
||||||
params.page,
|
|
||||||
params.pageSize,
|
|
||||||
)
|
|
||||||
if (params.companyId != null) query.company_id = params.companyId
|
|
||||||
const { data } = await http.get<unknown>(APPEARANCE_PATENT_CLEAN_ENDPOINT, { params: query })
|
|
||||||
return parseAppearancePatentCleanPage(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AppearancePatentCleanExportResult {
|
|
||||||
blob: Blob
|
|
||||||
filename: string
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 从 Content-Disposition 取 filename*(UTF-8 轨,后端 DownloadHeaderUtil 双轨口径),取不到回退常量名。 */
|
|
||||||
function exportFilenameOf(disposition: unknown): string {
|
|
||||||
const raw = typeof disposition === 'string' ? disposition : ''
|
|
||||||
const star = /filename\*=(?:UTF-8'')?([^;]+)/i.exec(raw)
|
|
||||||
if (star?.[1]) {
|
|
||||||
try {
|
|
||||||
return decodeURIComponent(star[1].trim().replace(/^"|"$/g, '')) || '外观专利数据库.xlsx'
|
|
||||||
} catch {
|
|
||||||
// 编码坏的 filename* 当作没有,走 ASCII 轨或常量名
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const plain = /filename="([^"]+)"/i.exec(raw)
|
|
||||||
return plain?.[1] || '外观专利数据库.xlsx'
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 导出当前过滤面全量明细:与列表共用同一过滤面取值口(含公司 tab),blob 下载交给页面触发保存。 */
|
|
||||||
export async function exportAppearancePatentCleanList(
|
|
||||||
params: AppearancePatentCleanExportParams,
|
|
||||||
): Promise<AppearancePatentCleanExportResult> {
|
|
||||||
const query: AppearancePatentCleanExportQuery = toAppearancePatentCleanExportParams({
|
|
||||||
taskId: params.taskId ?? '',
|
|
||||||
asin: params.asin ?? '',
|
|
||||||
country: params.country ?? '',
|
|
||||||
groupId: params.groupId ?? '',
|
|
||||||
startDate: params.startDate ?? '',
|
|
||||||
endDate: params.endDate ?? '',
|
|
||||||
})
|
|
||||||
if (params.companyId != null) query.company_id = params.companyId
|
|
||||||
const response = await http.get<Blob>(`${APPEARANCE_PATENT_CLEAN_ENDPOINT}/export`, {
|
|
||||||
params: query,
|
|
||||||
responseType: 'blob',
|
|
||||||
timeout: 120_000,
|
|
||||||
})
|
|
||||||
const disposition = response.headers?.['content-disposition']
|
|
||||||
if (!disposition) {
|
|
||||||
// 没有附件头=服务端回了业务错误信封(HTTP 200 + JSON),把 blob 文本解回错误文案抛给页面
|
|
||||||
const blob = response.data
|
|
||||||
let payload: unknown = null
|
|
||||||
if (blob && typeof blob.text === 'function') {
|
|
||||||
const text = await blob.text()
|
|
||||||
try {
|
|
||||||
payload = JSON.parse(text)
|
|
||||||
} catch {
|
|
||||||
payload = text
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new Error(errorTextOf(payload))
|
|
||||||
}
|
|
||||||
return { blob: response.data, filename: exportFilenameOf(disposition) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 分组(主管)下拉选项:复用既有 GET /shop-manages/groups(与去重页/店铺管理共用同一分组集,
|
|
||||||
* 不下新端点)。2026-11-11 客户口径「主管就是组长,可以筛选组长来导出,就是分组」——
|
|
||||||
* 选项是分组管理里那一行(DedupeGroupOption {id, name, leaderUserId}),选中后以 group_id
|
|
||||||
* 走本文件 list/export 同一过滤面。 */
|
|
||||||
export { fetchDedupeTotalGroups } from '../asin/dedupe-total-api.ts'
|
|
||||||
export type { DedupeGroupOption } from '../asin/dedupe-total-api.ts'
|
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
/** 外观专利无侵权数据页筛选纯函数(v1.3 AC-5):任务号/ASIN/国家/分组/起止时间 + snake 分页参数。
|
|
||||||
* 产出与后端 §3.2 参数归一逐字对撞:`page`/`page_size`(默认 10、上限 100)、`task_id`、
|
|
||||||
* `asin`、`country`、`group_id`、`start_date`/`end_date`(ISO yyyy-MM-dd;空白不下发)。
|
|
||||||
* 分页钳制(铁律 15):page < 1 归 1、上限 10_000(后端 CR-18 同值),(page-1)*page_size
|
|
||||||
* 最大 999_900,Number.MAX_SAFE_INTEGER 也不会把乘积顶出安全整数。纯逻辑,node --test 直测。
|
|
||||||
* 公司维不在这里:归一化构造器不认识 company_id(同 asin-filter 惯例),由 api 发送口从
|
|
||||||
* 原始入参自己下传——取值口由 company-tab-wiring 护栏的发送行钉看守。
|
|
||||||
* 分组语义(2026-11-11 客户口径「主管就是组长,可以筛选组长来导出,就是分组」):下拉选项是
|
|
||||||
* 分组管理里那一行(biz_shop_manage_group),group_id 下发后服务端解析「组长本人+名下子账户」
|
|
||||||
* 整集 SQL 下推;表上「管理员」列与它同源(组长行=自己,子账户行=创建人)。 */
|
|
||||||
import { validIsoDateOrUndefined } from '../asin/asin-filter.ts'
|
|
||||||
|
|
||||||
/** 每页条数默认 10(蓝图 §3.2),上限 100。 */
|
|
||||||
export const APPEARANCE_PATENT_CLEAN_PAGE_SIZE = 10
|
|
||||||
export const APPEARANCE_PATENT_CLEAN_MAX_PAGE_SIZE = 100
|
|
||||||
/** 页码上限:与后端 AppearancePatentCleanItemQueryService.MAX_PAGE(CR-18 先例)同值,两侧不漂。 */
|
|
||||||
export const APPEARANCE_PATENT_CLEAN_MAX_PAGE = 10_000
|
|
||||||
|
|
||||||
export interface AppearancePatentCleanFilterState {
|
|
||||||
/** 任务号(纯数字文本,空串不限)。 */
|
|
||||||
taskId: string
|
|
||||||
/** ASIN 前缀。 */
|
|
||||||
asin: string
|
|
||||||
/** 国家代码,空串=全部。 */
|
|
||||||
country: string
|
|
||||||
/** 分组 id 文本(分组管理里那一行,组长即该组主管),空串=全部分组。 */
|
|
||||||
groupId: string
|
|
||||||
/** 同步开始日期(ISO yyyy-MM-dd;空串不限)。 */
|
|
||||||
startDate: string
|
|
||||||
/** 同步结束日期(ISO yyyy-MM-dd;空串不限)。 */
|
|
||||||
endDate: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createAppearancePatentCleanFilterState(): AppearancePatentCleanFilterState {
|
|
||||||
return { taskId: '', asin: '', country: '', groupId: '', startDate: '', endDate: '' }
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 是否有任一激活筛选条件。 */
|
|
||||||
export function appearancePatentCleanFilterActive(state: AppearancePatentCleanFilterState): boolean {
|
|
||||||
if ((state.taskId || '').trim()) return true
|
|
||||||
if ((state.asin || '').trim()) return true
|
|
||||||
if ((state.country || '').trim()) return true
|
|
||||||
if ((state.groupId || '').trim()) return true
|
|
||||||
if (validIsoDateOrUndefined(state.startDate) || validIsoDateOrUndefined(state.endDate)) return true
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 序列化到后端的查询参数(snake_case,仅下发非空字段)。 */
|
|
||||||
export interface AppearancePatentCleanQuery {
|
|
||||||
page: number
|
|
||||||
page_size: number
|
|
||||||
task_id?: number
|
|
||||||
asin?: string
|
|
||||||
country?: string
|
|
||||||
group_id?: number
|
|
||||||
start_date?: string
|
|
||||||
end_date?: string
|
|
||||||
/** 公司 tab:白名单构造不点名它,字段只为 api 发送口的 `query.company_id = params.companyId` 存在。 */
|
|
||||||
company_id?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 导出查询参数:与列表同一过滤面、无分页(全量导出由服务侧 EXPORT_MAX_ROWS 上限兜住)。 */
|
|
||||||
export interface AppearancePatentCleanExportQuery {
|
|
||||||
task_id?: number
|
|
||||||
asin?: string
|
|
||||||
country?: string
|
|
||||||
group_id?: number
|
|
||||||
start_date?: string
|
|
||||||
end_date?: string
|
|
||||||
/** 公司 tab 同列表口径:白名单构造不点名,由 api 发送口下传。 */
|
|
||||||
company_id?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
/** api 模块的入参:筛选态 + 分页 + 公司值(camel)。 */
|
|
||||||
export interface AppearancePatentCleanListParams {
|
|
||||||
page: number
|
|
||||||
pageSize: number
|
|
||||||
taskId?: string
|
|
||||||
asin?: string
|
|
||||||
country?: string
|
|
||||||
groupId?: string
|
|
||||||
startDate?: string
|
|
||||||
endDate?: string
|
|
||||||
companyId?: number | null
|
|
||||||
}
|
|
||||||
|
|
||||||
/** api 导出入口的入参:筛选态 + 公司值(camel,无分页)。 */
|
|
||||||
export interface AppearancePatentCleanExportParams {
|
|
||||||
taskId?: string
|
|
||||||
asin?: string
|
|
||||||
country?: string
|
|
||||||
groupId?: string
|
|
||||||
startDate?: string
|
|
||||||
endDate?: string
|
|
||||||
companyId?: number | null
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 过滤态 → 过滤面参数(snake_case,仅下发非空字段);列表与导出共用这一个取值口,
|
|
||||||
* 「导出的过滤面和页签看到的永远同源」由这条单出口保证,不出现两处各算各的。 */
|
|
||||||
function toAppearancePatentCleanFilterQuery(state: AppearancePatentCleanFilterState): AppearancePatentCleanExportQuery {
|
|
||||||
const query: AppearancePatentCleanExportQuery = {}
|
|
||||||
const taskId = Number.parseInt((state.taskId || '').trim(), 10)
|
|
||||||
if (Number.isFinite(taskId) && taskId > 0) query.task_id = taskId
|
|
||||||
const asin = (state.asin || '').trim()
|
|
||||||
if (asin) query.asin = asin
|
|
||||||
const country = (state.country || '').trim()
|
|
||||||
if (country) query.country = country
|
|
||||||
const groupId = Number.parseInt((state.groupId || '').trim(), 10)
|
|
||||||
if (Number.isFinite(groupId) && groupId > 0) query.group_id = groupId
|
|
||||||
const startDate = validIsoDateOrUndefined(state.startDate)
|
|
||||||
if (startDate) query.start_date = startDate
|
|
||||||
const endDate = validIsoDateOrUndefined(state.endDate)
|
|
||||||
if (endDate) query.end_date = endDate
|
|
||||||
return query
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 过滤态 + 分页 → 列表查询参数;空白/非法日期不下发,分页钳制在此单出口(不含公司维)。 */
|
|
||||||
export function toAppearancePatentCleanListParams(
|
|
||||||
state: AppearancePatentCleanFilterState,
|
|
||||||
page: number,
|
|
||||||
pageSize: number,
|
|
||||||
): AppearancePatentCleanQuery {
|
|
||||||
const safePage = Math.min(Math.max(Math.floor(page) || 1, 1), APPEARANCE_PATENT_CLEAN_MAX_PAGE)
|
|
||||||
const rawSize = Math.floor(pageSize) || APPEARANCE_PATENT_CLEAN_PAGE_SIZE
|
|
||||||
const safeSize = Math.min(Math.max(rawSize, 1), APPEARANCE_PATENT_CLEAN_MAX_PAGE_SIZE)
|
|
||||||
return {
|
|
||||||
page: safePage,
|
|
||||||
page_size: safeSize,
|
|
||||||
...toAppearancePatentCleanFilterQuery(state),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 过滤态 → 导出查询参数(无分页;归一规则与列表逐字同源)。 */
|
|
||||||
export function toAppearancePatentCleanExportParams(
|
|
||||||
state: AppearancePatentCleanFilterState,
|
|
||||||
): AppearancePatentCleanExportQuery {
|
|
||||||
return toAppearancePatentCleanFilterQuery(state)
|
|
||||||
}
|
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
/** 外观专利无侵权数据列表查询模型(v1.3 AC-5):解析 AppearancePatentCleanItemPageVo(camel),纯逻辑。
|
|
||||||
* 行值是同步服务从 chunk payload 原样落的,读侧只搬运不加工(与后端 toVo 同一口径)。 */
|
|
||||||
import { unwrap } from '../../api/envelope.ts'
|
|
||||||
|
|
||||||
export interface AppearancePatentCleanItem {
|
|
||||||
id: number
|
|
||||||
resultId: number | null
|
|
||||||
taskId: number | null
|
|
||||||
userId: number | null
|
|
||||||
/** 管理员列(表头「管理员」,客户 2026-11-11 口径;后端读侧现算:主管/公司超管=自己,普通账户=创建人,读不到为空 → 界面展示 -)。 */
|
|
||||||
supervisorName: string
|
|
||||||
companyId: number | null
|
|
||||||
rowNo: number | null
|
|
||||||
asin: string
|
|
||||||
country: string
|
|
||||||
sku: string
|
|
||||||
brand: string
|
|
||||||
price: string
|
|
||||||
title: string
|
|
||||||
imageUrl: string
|
|
||||||
itemUrl: string
|
|
||||||
conclusion: string
|
|
||||||
titleReason: string
|
|
||||||
appearanceReason: string
|
|
||||||
patentReason: string
|
|
||||||
sourceFilename: string
|
|
||||||
syncedAt?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AppearancePatentCleanPageResult {
|
|
||||||
items: AppearancePatentCleanItem[]
|
|
||||||
total: number
|
|
||||||
page: number
|
|
||||||
pageSize: number
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 前端首屏默认容量:与后端 PageDefaults.CLEAN_ITEMS_PAGE_SIZE(蓝图 §3.2 默认 10)同值。 */
|
|
||||||
export const APPEARANCE_PATENT_CLEAN_DEFAULT_SIZE = 10
|
|
||||||
|
|
||||||
export function emptyAppearancePatentCleanPage(): AppearancePatentCleanPageResult {
|
|
||||||
return { items: [], total: 0, page: 1, pageSize: APPEARANCE_PATENT_CLEAN_DEFAULT_SIZE }
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 结论列悬停提示=三因原文拼装(2026-11-11 随明细表恢复回归;3cfca462 曾随结论徽章一起退役)。 */
|
|
||||||
export function cleanItemReasonTooltip(item: AppearancePatentCleanItem): string {
|
|
||||||
const parts: string[] = []
|
|
||||||
if (item.titleReason) parts.push(`标题:${item.titleReason}`)
|
|
||||||
if (item.appearanceReason) parts.push(`外观:${item.appearanceReason}`)
|
|
||||||
if (item.patentReason) parts.push(`专利:${item.patentReason}`)
|
|
||||||
return parts.join('\n')
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function text(value: unknown): string {
|
|
||||||
return typeof value === 'string' ? value.trim() : ''
|
|
||||||
}
|
|
||||||
|
|
||||||
function numberOrNull(value: unknown): number | null {
|
|
||||||
return typeof value === 'number' && Number.isFinite(value) ? Math.floor(value) : null
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 解析单行明细;缺 id 视为无效。camel 为正、snake 容错(与去重页模型同形)。 */
|
|
||||||
export function toAppearancePatentCleanItem(raw: unknown): AppearancePatentCleanItem | null {
|
|
||||||
if (!raw || typeof raw !== 'object') return null
|
|
||||||
const record = raw as Record<string, unknown>
|
|
||||||
const id = numberOrNull(record.id)
|
|
||||||
if (id === null) return null
|
|
||||||
return {
|
|
||||||
id,
|
|
||||||
resultId: numberOrNull(record.resultId ?? record.result_id),
|
|
||||||
taskId: numberOrNull(record.taskId ?? record.task_id),
|
|
||||||
userId: numberOrNull(record.userId ?? record.user_id),
|
|
||||||
supervisorName: text(record.supervisorName ?? record.supervisor_name),
|
|
||||||
companyId: numberOrNull(record.companyId ?? record.company_id),
|
|
||||||
rowNo: numberOrNull(record.rowNo ?? record.row_no),
|
|
||||||
asin: text(record.asin),
|
|
||||||
country: text(record.country),
|
|
||||||
sku: text(record.sku),
|
|
||||||
brand: text(record.brand),
|
|
||||||
price: text(record.price),
|
|
||||||
title: text(record.title),
|
|
||||||
imageUrl: text(record.imageUrl ?? record.image_url),
|
|
||||||
itemUrl: text(record.itemUrl ?? record.item_url),
|
|
||||||
conclusion: text(record.conclusion),
|
|
||||||
titleReason: text(record.titleReason ?? record.title_reason),
|
|
||||||
appearanceReason: text(record.appearanceReason ?? record.appearance_reason),
|
|
||||||
patentReason: text(record.patentReason ?? record.patent_reason),
|
|
||||||
sourceFilename: text(record.sourceFilename ?? record.source_filename),
|
|
||||||
syncedAt: text(record.syncedAt ?? record.synced_at) || undefined,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 归一化分页负载(信封或已解包 VO)为前端结果;缺省字段回默认。无 keyset 游标(蓝图 Out of Scope)。 */
|
|
||||||
export function parseAppearancePatentCleanPage(payload: unknown): AppearancePatentCleanPageResult {
|
|
||||||
const out = emptyAppearancePatentCleanPage()
|
|
||||||
const core = unwrap<unknown>(payload)
|
|
||||||
if (!core || typeof core !== 'object') return out
|
|
||||||
const record = core as Record<string, unknown>
|
|
||||||
if (Array.isArray(record.items)) {
|
|
||||||
out.items = record.items
|
|
||||||
.map((raw) => toAppearancePatentCleanItem(raw))
|
|
||||||
.filter((item): item is AppearancePatentCleanItem => item !== null)
|
|
||||||
}
|
|
||||||
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 rawSize = record.pageSize ?? record.page_size
|
|
||||||
if (typeof rawSize === 'number' && rawSize >= 1) out.pageSize = Math.floor(rawSize)
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
@@ -5,14 +5,10 @@
|
|||||||
import { computed, nextTick, onMounted, ref, watch } from 'vue'
|
import { computed, nextTick, onMounted, ref, watch } from 'vue'
|
||||||
import OldPagination from '@/components/OldPagination.vue'
|
import OldPagination from '@/components/OldPagination.vue'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { formatDateTime, orderedPair, todayDateInput } from '@/utils/datetime'
|
import { formatDateTime, todayDateInput } from '@/utils/datetime'
|
||||||
import { createLatestRequestGate } from '@/utils/latest-request'
|
|
||||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||||
import { fetchHistoryUserOptions } from './history-api.ts'
|
import { fetchHistoryUserOptions } from './history-api.ts'
|
||||||
import type { HistoryUserOption } from './history-user-option.ts'
|
import type { HistoryUserOption } from './history-user-option.ts'
|
||||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
|
||||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
|
||||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
|
||||||
import {
|
import {
|
||||||
deleteDeviceLogFile,
|
deleteDeviceLogFile,
|
||||||
deleteDeviceLogOverride,
|
deleteDeviceLogOverride,
|
||||||
@@ -57,9 +53,6 @@ function formatBytes(bytes: number | null | undefined): string {
|
|||||||
const companyTab = useCompanyTabStore()
|
const companyTab = useCompanyTabStore()
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const loadFailure = ref('')
|
|
||||||
// 设备日志列表竞态门(S1-F4)
|
|
||||||
const gate = createLatestRequestGate()
|
|
||||||
const rows = ref<DeviceLogFileRow[]>([])
|
const rows = ref<DeviceLogFileRow[]>([])
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
const page = ref(1)
|
const page = ref(1)
|
||||||
@@ -70,22 +63,12 @@ const userOptions = ref<HistoryUserOption[]>([])
|
|||||||
const usersLoading = ref(false)
|
const usersLoading = ref(false)
|
||||||
const startDate = ref(todayDateInput())
|
const startDate = ref(todayDateInput())
|
||||||
const endDate = 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 retentionDays = ref(7)
|
const retentionDays = ref(7)
|
||||||
|
|
||||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
// S1-F4:快速切公司/改筛选时旧响应可能晚到——回写前必须过竞态门
|
|
||||||
const token = gate.begin()
|
|
||||||
loading.value = true
|
loading.value = true
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
try {
|
||||||
const result = await fetchDeviceLogFiles({
|
const result = await fetchDeviceLogFiles({
|
||||||
source: sourceFilter.value || undefined,
|
source: sourceFilter.value || undefined,
|
||||||
@@ -96,16 +79,13 @@ async function load() {
|
|||||||
pageSize: pageSize.value,
|
pageSize: pageSize.value,
|
||||||
companyId: companyTab.requestCompanyId,
|
companyId: companyTab.requestCompanyId,
|
||||||
})
|
})
|
||||||
if (!gate.isCurrent(token)) return
|
|
||||||
rows.value = result?.items || []
|
rows.value = result?.items || []
|
||||||
total.value = Number(result?.total || 0)
|
total.value = Number(result?.total || 0)
|
||||||
if (result?.retentionDays) retentionDays.value = result.retentionDays
|
if (result?.retentionDays) retentionDays.value = result.retentionDays
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (!gate.isCurrent(token)) return
|
ElMessage.error(error instanceof Error ? error.message : '日志列表加载失败')
|
||||||
loadFailure.value = error instanceof Error ? error.message : '日志列表加载失败'
|
|
||||||
showAdminFeedback(loadFailure.value, 'error')
|
|
||||||
} finally {
|
} finally {
|
||||||
if (gate.isCurrent(token)) loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +160,7 @@ async function loadContent(scrollToBottom: boolean) {
|
|||||||
if (viewerPre.value) viewerPre.value.scrollTop = viewerPre.value.scrollHeight
|
if (viewerPre.value) viewerPre.value.scrollTop = viewerPre.value.scrollHeight
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '日志内容加载失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '日志内容加载失败')
|
||||||
} finally {
|
} finally {
|
||||||
viewerLoading.value = false
|
viewerLoading.value = false
|
||||||
}
|
}
|
||||||
@@ -192,13 +172,13 @@ function loadMore() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function remove(row: DeviceLogFileRow) {
|
async function remove(row: DeviceLogFileRow) {
|
||||||
if (!(await openAdminConfirm({ message: `确认删除「${row.fileName}」(${row.deviceName || row.deviceId})的云端日志?删除后不可恢复。`, danger: true }))) return
|
if (!window.confirm(`确认删除「${row.fileName}」(${row.deviceName || row.deviceId})的云端日志?删除后不可恢复。`)) return
|
||||||
try {
|
try {
|
||||||
await deleteDeviceLogFile(row.id)
|
await deleteDeviceLogFile(row.id)
|
||||||
ElMessage.success('已删除')
|
ElMessage.success('已删除')
|
||||||
load()
|
load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +214,7 @@ async function loadConfig() {
|
|||||||
overrides.value = data.overrides || []
|
overrides.value = data.overrides || []
|
||||||
devices.value = (await fetchDeviceLogDevices()) || []
|
devices.value = (await fetchDeviceLogDevices()) || []
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '采集配置加载失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '采集配置加载失败')
|
||||||
} finally {
|
} finally {
|
||||||
configLoading.value = false
|
configLoading.value = false
|
||||||
}
|
}
|
||||||
@@ -247,7 +227,7 @@ async function saveGlobalMode(mode: string) {
|
|||||||
globalMode.value = mode
|
globalMode.value = mode
|
||||||
ElMessage.success(`全局采集模式已切换为「${modeLabel(mode)}」`)
|
ElMessage.success(`全局采集模式已切换为「${modeLabel(mode)}」`)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '保存失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '保存失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,19 +244,19 @@ async function addOverride() {
|
|||||||
newOverrideKey.value = ''
|
newOverrideKey.value = ''
|
||||||
await loadConfig()
|
await loadConfig()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '保存失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '保存失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function removeOverride(row: DeviceLogOverride) {
|
async function removeOverride(row: DeviceLogOverride) {
|
||||||
const who = row.deviceName || row.deviceId
|
const who = row.deviceName || row.deviceId
|
||||||
if (!(await openAdminConfirm({ message: `确认删除终端「${who}」的采集覆盖(回落到全局默认)?`, danger: true }))) return
|
if (!window.confirm(`确认删除终端「${who}」的采集覆盖(回落到全局默认)?`)) return
|
||||||
try {
|
try {
|
||||||
await deleteDeviceLogOverride(row.id)
|
await deleteDeviceLogOverride(row.id)
|
||||||
ElMessage.success('已删除')
|
ElMessage.success('已删除')
|
||||||
await loadConfig()
|
await loadConfig()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,11 +294,11 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group" style="min-width: 150px">
|
<div class="form-group" style="min-width: 150px">
|
||||||
<label>日志日期(起)</label>
|
<label>日志日期(起)</label>
|
||||||
<input v-model="startDate" type="date" :max="endDate" @change="clampDatePair" />
|
<input v-model="startDate" type="date" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" style="min-width: 150px">
|
<div class="form-group" style="min-width: 150px">
|
||||||
<label>日志日期(止)</label>
|
<label>日志日期(止)</label>
|
||||||
<input v-model="endDate" type="date" :min="startDate" @change="clampDatePair" />
|
<input v-model="endDate" type="date" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label> </label>
|
<label> </label>
|
||||||
@@ -329,7 +309,6 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
|
||||||
<div class="logs-table-scroll">
|
<div class="logs-table-scroll">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -23,12 +23,8 @@ import { canReleaseDigitalHumanVersion, releaseDigitalHumanConfirmText } from '.
|
|||||||
import { canSetLatestDigitalHumanVersion, setLatestDigitalHumanConfirmText } from './digitalhuman-latest.ts'
|
import { canSetLatestDigitalHumanVersion, setLatestDigitalHumanConfirmText } from './digitalhuman-latest.ts'
|
||||||
import OldPagination from '@/components/OldPagination.vue'
|
import OldPagination from '@/components/OldPagination.vue'
|
||||||
import { digitalHumanStatusDisplay } from './digitalhuman-status-display.ts'
|
import { digitalHumanStatusDisplay } from './digitalhuman-status-display.ts'
|
||||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
|
||||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
|
||||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const loadFailure = ref('')
|
|
||||||
const items = ref<DigitalHumanVersion[]>([])
|
const items = ref<DigitalHumanVersion[]>([])
|
||||||
|
|
||||||
/** 分页(对齐 admin.js:6311 pageSize=20 + 数字页码 + 跳转;Java 列表接口不分页,前端分页呈现)。 */
|
/** 分页(对齐 admin.js:6311 pageSize=20 + 数字页码 + 跳转;Java 列表接口不分页,前端分页呈现)。 */
|
||||||
@@ -58,13 +54,11 @@ const downloadingVersion = ref<string | null>(null)
|
|||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
try {
|
||||||
items.value = (await fetchDigitalHumanVersions()).items
|
items.value = (await fetchDigitalHumanVersions()).items
|
||||||
// 页码越界回钳见下方 watch(items)。
|
// 页码越界回钳见下方 watch(items)。
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loadFailure.value = error instanceof Error ? error.message : '版本列表加载失败'
|
ElMessage.error(error instanceof Error ? error.message : '版本列表加载失败')
|
||||||
showAdminFeedback(loadFailure.value, 'error')
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
@@ -122,7 +116,7 @@ async function submitUpload() {
|
|||||||
form.value = { version: '', file: null, changelog: '', minClientVersion: '' }
|
form.value = { version: '', file: null, changelog: '', minClientVersion: '' }
|
||||||
load()
|
load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '上传失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '上传失败')
|
||||||
} finally {
|
} finally {
|
||||||
uploading.value = false
|
uploading.value = false
|
||||||
}
|
}
|
||||||
@@ -132,14 +126,14 @@ async function release(row: DigitalHumanVersion) {
|
|||||||
const text = releaseDigitalHumanConfirmText(row.version)
|
const text = releaseDigitalHumanConfirmText(row.version)
|
||||||
if (!text) return
|
if (!text) return
|
||||||
// 对齐旧版:原生 confirm。
|
// 对齐旧版:原生 confirm。
|
||||||
if (!(await openAdminConfirm({ message: text, danger: false }))) return
|
if (!window.confirm(text)) return
|
||||||
confirming.value = row.version
|
confirming.value = row.version
|
||||||
try {
|
try {
|
||||||
await releaseDigitalHumanVersion(row.version)
|
await releaseDigitalHumanVersion(row.version)
|
||||||
ElMessage.success('已发布')
|
ElMessage.success('已发布')
|
||||||
load()
|
load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '发布失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '发布失败')
|
||||||
} finally {
|
} finally {
|
||||||
confirming.value = null
|
confirming.value = null
|
||||||
}
|
}
|
||||||
@@ -148,14 +142,14 @@ async function release(row: DigitalHumanVersion) {
|
|||||||
async function setLatest(row: DigitalHumanVersion) {
|
async function setLatest(row: DigitalHumanVersion) {
|
||||||
const text = setLatestDigitalHumanConfirmText(row.version)
|
const text = setLatestDigitalHumanConfirmText(row.version)
|
||||||
if (!text) return
|
if (!text) return
|
||||||
if (!(await openAdminConfirm({ message: text, danger: false }))) return
|
if (!window.confirm(text)) return
|
||||||
confirming.value = row.version
|
confirming.value = row.version
|
||||||
try {
|
try {
|
||||||
await setLatestDigitalHumanVersion(row.version)
|
await setLatestDigitalHumanVersion(row.version)
|
||||||
ElMessage.success('已设为最新')
|
ElMessage.success('已设为最新')
|
||||||
load()
|
load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '操作失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '操作失败')
|
||||||
} finally {
|
} finally {
|
||||||
confirming.value = null
|
confirming.value = null
|
||||||
}
|
}
|
||||||
@@ -176,7 +170,7 @@ async function download(row: DigitalHumanVersion) {
|
|||||||
anchor.click()
|
anchor.click()
|
||||||
document.body.removeChild(anchor)
|
document.body.removeChild(anchor)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '下载失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '下载失败')
|
||||||
} finally {
|
} finally {
|
||||||
downloadingVersion.value = null
|
downloadingVersion.value = null
|
||||||
}
|
}
|
||||||
@@ -185,14 +179,14 @@ async function download(row: DigitalHumanVersion) {
|
|||||||
async function remove(row: DigitalHumanVersion) {
|
async function remove(row: DigitalHumanVersion) {
|
||||||
const text = digitalHumanDeleteConfirmText(row.version)
|
const text = digitalHumanDeleteConfirmText(row.version)
|
||||||
if (!text) return
|
if (!text) return
|
||||||
if (!(await openAdminConfirm({ message: text, danger: true }))) return
|
if (!window.confirm(text)) return
|
||||||
confirming.value = row.version
|
confirming.value = row.version
|
||||||
try {
|
try {
|
||||||
await deleteDigitalHumanVersion(row.version)
|
await deleteDigitalHumanVersion(row.version)
|
||||||
ElMessage.success('删除成功')
|
ElMessage.success('删除成功')
|
||||||
load()
|
load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||||
} finally {
|
} finally {
|
||||||
confirming.value = null
|
confirming.value = null
|
||||||
}
|
}
|
||||||
@@ -220,7 +214,6 @@ onMounted(load)
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
|
||||||
<div class="table-scroll digital-human-version-table-scroll">
|
<div class="table-scroll digital-human-version-table-scroll">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -232,7 +225,7 @@ onMounted(load)
|
|||||||
<th style="width: 120px">MD5</th>
|
<th style="width: 120px">MD5</th>
|
||||||
<th>更新日志</th>
|
<th>更新日志</th>
|
||||||
<th style="width: 140px">发布时间</th>
|
<th style="width: 140px">发布时间</th>
|
||||||
<th style="width: 290px">操作</th>
|
<th style="width: 240px">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -495,7 +488,6 @@ h3 {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-tip {
|
.empty-tip {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
/** 生成记录页 · 像素复刻旧版 admin.html panel-history(自绘:form-box 筛选 + panel-box 表格 + 旧式分页 + thumb 缩略图)。
|
/** 生成记录页 · 像素复刻旧版 admin.html panel-history(自绘:form-box 筛选 + panel-box 表格 + 旧式分页 + thumb 缩略图)。
|
||||||
* script 逻辑沿用现有 Vue 实现(查询/翻页/跳页/点击缩略图放大预览)。 */
|
* script 逻辑沿用现有 Vue 实现(查询/翻页/跳页/点击缩略图放大预览)。 */
|
||||||
import { formatDateTime, orderedPair } from '@/utils/datetime'
|
import { formatDateTime } from '@/utils/datetime'
|
||||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||||
import { fetchHistoryList, fetchHistoryUserOptions } from './history-api.ts'
|
import { fetchHistoryList, fetchHistoryUserOptions } from './history-api.ts'
|
||||||
import type { HistoryUserOption } from './history-user-option.ts'
|
import type { HistoryUserOption } from './history-user-option.ts'
|
||||||
@@ -23,13 +23,6 @@ const userOptions = ref<HistoryUserOption[]>([])
|
|||||||
const errorText = ref('')
|
const errorText = ref('')
|
||||||
/** 起止时间初值故意留空:默认锁当天会让首屏只剩今天的生成记录(用户 2026-10-04 定案),见 date-filter-default-today 护栏的 EXEMPT。 */
|
/** 起止时间初值故意留空:默认锁当天会让首屏只剩今天的生成记录(用户 2026-10-04 定案),见 date-filter-default-today 护栏的 EXEMPT。 */
|
||||||
const filter = reactive({ userId: '', timeStart: '', timeEnd: '' })
|
const filter = reactive({ userId: '', timeStart: '', timeEnd: '' })
|
||||||
/** min/max 挡不住手输,落值后把倒挂的起止交换回来。 */
|
|
||||||
function clampDatePair(): void {
|
|
||||||
const [s, e] = orderedPair(filter.timeStart, filter.timeEnd)
|
|
||||||
filter.timeStart = s
|
|
||||||
filter.timeEnd = e
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const previewVisible = ref(false)
|
const previewVisible = ref(false)
|
||||||
const previewItem = ref<HistoryRecordItem | null>(null)
|
const previewItem = ref<HistoryRecordItem | null>(null)
|
||||||
@@ -153,11 +146,11 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group" style="min-width: 176px">
|
<div class="form-group" style="min-width: 176px">
|
||||||
<label>开始时间</label>
|
<label>开始时间</label>
|
||||||
<input v-model="filter.timeStart" type="datetime-local" :max="filter.timeEnd" @change="clampDatePair" />
|
<input v-model="filter.timeStart" type="datetime-local" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" style="min-width: 176px">
|
<div class="form-group" style="min-width: 176px">
|
||||||
<label>结束时间</label>
|
<label>结束时间</label>
|
||||||
<input v-model="filter.timeEnd" type="datetime-local" :min="filter.timeStart" @change="clampDatePair" />
|
<input v-model="filter.timeEnd" type="datetime-local" />
|
||||||
</div>
|
</div>
|
||||||
<button class="btn" type="button" @click="apply">查询</button>
|
<button class="btn" type="button" @click="apply">查询</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,13 +8,8 @@ import { ElMessage } from 'element-plus'
|
|||||||
import { fetchSoftwareVersions, uploadSoftwareVersion, deleteSoftwareVersions } from './version-api.ts'
|
import { fetchSoftwareVersions, uploadSoftwareVersion, deleteSoftwareVersions } from './version-api.ts'
|
||||||
import type { SoftwareVersionItem } from './version-dto.ts'
|
import type { SoftwareVersionItem } from './version-dto.ts'
|
||||||
import { isNonEmptyVersion } from './version-dto.ts'
|
import { isNonEmptyVersion } from './version-dto.ts'
|
||||||
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 loading = ref(false)
|
const loading = ref(false)
|
||||||
const loadFailure = ref('')
|
|
||||||
const items = ref<SoftwareVersionItem[]>([])
|
const items = ref<SoftwareVersionItem[]>([])
|
||||||
/** 版本号搜索(客户端过滤)。 */
|
/** 版本号搜索(客户端过滤)。 */
|
||||||
const versionKeyword = ref('')
|
const versionKeyword = ref('')
|
||||||
@@ -56,25 +51,25 @@ async function removeSelected() {
|
|||||||
const rows = items.value.filter((row) => selectedIds.value.has(row.id))
|
const rows = items.value.filter((row) => selectedIds.value.has(row.id))
|
||||||
const sample = rows.slice(0, 3).map((row) => row.version).join('、')
|
const sample = rows.slice(0, 3).map((row) => row.version).join('、')
|
||||||
const summary = rows.length > 3 ? `${sample} 等 ${rows.length} 个` : sample
|
const summary = rows.length > 3 ? `${sample} 等 ${rows.length} 个` : sample
|
||||||
if (!(await openAdminConfirm({ message: `确认删除选中的 ${rows.length} 个版本(${summary})?此操作不可恢复。`, danger: true }))) return
|
if (!window.confirm(`确认删除选中的 ${rows.length} 个版本(${summary})?此操作不可恢复。`)) return
|
||||||
try {
|
try {
|
||||||
await deleteSoftwareVersions(Array.from(selectedIds.value))
|
await deleteSoftwareVersions(Array.from(selectedIds.value))
|
||||||
ElMessage.success(`已删除 ${rows.length} 个版本`)
|
ElMessage.success(`已删除 ${rows.length} 个版本`)
|
||||||
selectedIds.value = new Set()
|
selectedIds.value = new Set()
|
||||||
await load()
|
await load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(loadFailureMessage(error, '删除失败'), 'error')
|
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function removeOne(row: SoftwareVersionItem) {
|
async function removeOne(row: SoftwareVersionItem) {
|
||||||
if (!(await openAdminConfirm({ message: `确认删除版本 ${row.version}?此操作不可恢复。`, danger: true }))) return
|
if (!window.confirm(`确认删除版本 ${row.version}?此操作不可恢复。`)) return
|
||||||
try {
|
try {
|
||||||
await deleteSoftwareVersions([row.id])
|
await deleteSoftwareVersions([row.id])
|
||||||
ElMessage.success('删除成功')
|
ElMessage.success('删除成功')
|
||||||
selectedIds.value = new Set([...selectedIds.value].filter((id) => id !== row.id))
|
selectedIds.value = new Set([...selectedIds.value].filter((id) => id !== row.id))
|
||||||
await load()
|
await load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(loadFailureMessage(error, '删除失败'), 'error')
|
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,12 +84,10 @@ const uploadMsgOk = ref(false)
|
|||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
try {
|
||||||
items.value = (await fetchSoftwareVersions()).items
|
items.value = (await fetchSoftwareVersions()).items
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loadFailure.value = loadFailureMessage(error, '版本列表加载失败')
|
ElMessage.error(error instanceof Error ? error.message : '版本列表加载失败')
|
||||||
showAdminFeedback(loadFailure.value, 'error')
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
@@ -147,8 +140,7 @@ async function submitUpload() {
|
|||||||
uploadPercent.value = 0
|
uploadPercent.value = 0
|
||||||
load()
|
load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// P2-10:api/http 拦截器不 sanitize,error.message 可能是英文异常原文——界面只吃中文出口,原文进 console。
|
uploadMsg.value = error instanceof Error ? error.message : '上传失败'
|
||||||
uploadMsg.value = loadFailureMessage(error, '上传失败')
|
|
||||||
} finally {
|
} finally {
|
||||||
uploading.value = false
|
uploading.value = false
|
||||||
}
|
}
|
||||||
@@ -169,7 +161,6 @@ onMounted(load)
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
|
||||||
<div class="table-scroll version-table-scroll">
|
<div class="table-scroll version-table-scroll">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -10,13 +10,8 @@ import { ElMessage } from 'element-plus'
|
|||||||
import { fetchTutorialPackages, uploadTutorialPackage, deleteTutorialPackages } from './tutorial-api.ts'
|
import { fetchTutorialPackages, uploadTutorialPackage, deleteTutorialPackages } from './tutorial-api.ts'
|
||||||
import { formatFileSize } from './tutorial-model.ts'
|
import { formatFileSize } from './tutorial-model.ts'
|
||||||
import type { TutorialPackageItem } from './tutorial-dto.ts'
|
import type { TutorialPackageItem } from './tutorial-dto.ts'
|
||||||
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 loading = ref(false)
|
const loading = ref(false)
|
||||||
const loadFailure = ref('')
|
|
||||||
const items = ref<TutorialPackageItem[]>([])
|
const items = ref<TutorialPackageItem[]>([])
|
||||||
/** 文件名搜索(客户端过滤)。 */
|
/** 文件名搜索(客户端过滤)。 */
|
||||||
const keyword = ref('')
|
const keyword = ref('')
|
||||||
@@ -113,25 +108,25 @@ async function removeSelected() {
|
|||||||
const rows = items.value.filter((row) => selectedIds.value.has(row.id))
|
const rows = items.value.filter((row) => selectedIds.value.has(row.id))
|
||||||
const sample = rows.slice(0, 3).map((row) => row.fileName).join('、')
|
const sample = rows.slice(0, 3).map((row) => row.fileName).join('、')
|
||||||
const summary = rows.length > 3 ? `${sample} 等 ${rows.length} 个` : sample
|
const summary = rows.length > 3 ? `${sample} 等 ${rows.length} 个` : sample
|
||||||
if (!(await openAdminConfirm({ message: `确认删除选中的 ${rows.length} 个教程包(${summary})?此操作不可恢复。`, danger: true }))) return
|
if (!window.confirm(`确认删除选中的 ${rows.length} 个教程包(${summary})?此操作不可恢复。`)) return
|
||||||
try {
|
try {
|
||||||
await deleteTutorialPackages(Array.from(selectedIds.value))
|
await deleteTutorialPackages(Array.from(selectedIds.value))
|
||||||
ElMessage.success(`已删除 ${rows.length} 个教程包`)
|
ElMessage.success(`已删除 ${rows.length} 个教程包`)
|
||||||
selectedIds.value = new Set()
|
selectedIds.value = new Set()
|
||||||
await load()
|
await load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(loadFailureMessage(error, '删除失败'), 'error')
|
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function removeOne(row: TutorialPackageItem) {
|
async function removeOne(row: TutorialPackageItem) {
|
||||||
if (!(await openAdminConfirm({ message: `确认删除教程包 ${row.fileName}?此操作不可恢复。`, danger: true }))) return
|
if (!window.confirm(`确认删除教程包 ${row.fileName}?此操作不可恢复。`)) return
|
||||||
try {
|
try {
|
||||||
await deleteTutorialPackages([row.id])
|
await deleteTutorialPackages([row.id])
|
||||||
ElMessage.success('删除成功')
|
ElMessage.success('删除成功')
|
||||||
selectedIds.value = new Set([...selectedIds.value].filter((id) => id !== row.id))
|
selectedIds.value = new Set([...selectedIds.value].filter((id) => id !== row.id))
|
||||||
await load()
|
await load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(loadFailureMessage(error, '删除失败'), 'error')
|
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,12 +141,10 @@ const uploadMsgOk = ref(false)
|
|||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
try {
|
||||||
items.value = (await fetchTutorialPackages()).items
|
items.value = (await fetchTutorialPackages()).items
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loadFailure.value = loadFailureMessage(error, '教程包列表加载失败')
|
ElMessage.error(error instanceof Error ? error.message : '教程包列表加载失败')
|
||||||
showAdminFeedback(loadFailure.value, 'error')
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
@@ -199,8 +192,7 @@ async function submitUpload() {
|
|||||||
uploadPercent.value = 0
|
uploadPercent.value = 0
|
||||||
load()
|
load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// P2-10:api/http 拦截器不 sanitize,error.message 可能是英文异常原文——界面只吃中文出口,原文进 console。
|
uploadMsg.value = error instanceof Error ? error.message : '上传失败'
|
||||||
uploadMsg.value = loadFailureMessage(error, '上传失败')
|
|
||||||
} finally {
|
} finally {
|
||||||
uploading.value = false
|
uploading.value = false
|
||||||
}
|
}
|
||||||
@@ -221,7 +213,6 @@ onMounted(load)
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
|
||||||
<div class="table-scroll tutorial-table-scroll">
|
<div class="table-scroll tutorial-table-scroll">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -1,502 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { formatDateTime } from '@/utils/datetime'
|
|
||||||
/** 数富AI工作台客户端包管理页:上传 ZIP → 直传 MinIO → 服务端复算 sha256 落库。
|
|
||||||
* 列表默认按上传时间倒序,第一条即当前生效版本;删除最新包后自动回落到上一版。 */
|
|
||||||
import { computed, onMounted, ref, watch } from 'vue'
|
|
||||||
import OldPagination from '@/components/OldPagination.vue'
|
|
||||||
import { ElMessage } from 'element-plus'
|
|
||||||
import {
|
|
||||||
deleteWorkbenchClientPackages,
|
|
||||||
fetchWorkbenchClientPackages,
|
|
||||||
uploadWorkbenchClientPackage,
|
|
||||||
} from './workbench-client-api.ts'
|
|
||||||
import { formatFileSize, isValidWorkbenchClientVersion, WORKBENCH_CLIENT_VERSION_MAX_LENGTH } from './workbench-client-model.ts'
|
|
||||||
import type { WorkbenchClientPackageItem } from './workbench-client-dto.ts'
|
|
||||||
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 items = ref<WorkbenchClientPackageItem[]>([])
|
|
||||||
/** 版本号/文件名搜索(客户端过滤)。 */
|
|
||||||
const keyword = ref('')
|
|
||||||
const filteredItems = computed(() => {
|
|
||||||
const kw = (keyword.value || '').trim().toLowerCase()
|
|
||||||
if (!kw) return items.value
|
|
||||||
return items.value.filter((item) =>
|
|
||||||
`${item.version}`.toLowerCase().includes(kw) || item.fileName.toLowerCase().includes(kw),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
/** 全站分页统一:客户端分页(10/20/50/100)。 */
|
|
||||||
const page = ref(1)
|
|
||||||
const pageSize = ref(10)
|
|
||||||
const pagedItems = computed(() => filteredItems.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 }
|
|
||||||
// 搜索导致数据收缩时回钳页码,避免停在空页。
|
|
||||||
watch(filteredItems, () => {
|
|
||||||
page.value = Math.min(page.value, Math.max(1, Math.ceil(filteredItems.value.length / pageSize.value)))
|
|
||||||
})
|
|
||||||
|
|
||||||
/** 当前生效版本 = 列表第一条(客户端更新接口下发的就是它)。 */
|
|
||||||
const activeId = computed(() => items.value[0]?.id ?? null)
|
|
||||||
|
|
||||||
// 勾选删除:选中跨页累计;表头复选只作用于当前页,避免误选整表。
|
|
||||||
const selectedIds = ref<Set<number>>(new Set())
|
|
||||||
const selectedCount = computed(() => selectedIds.value.size)
|
|
||||||
function toggleSelect(id: number) {
|
|
||||||
const next = new Set(selectedIds.value)
|
|
||||||
if (next.has(id)) next.delete(id)
|
|
||||||
else next.add(id)
|
|
||||||
selectedIds.value = next
|
|
||||||
}
|
|
||||||
function toggleSelectAllPage() {
|
|
||||||
const pageRows = pagedItems.value
|
|
||||||
const allOn = pageRows.length > 0 && pageRows.every((row) => selectedIds.value.has(row.id))
|
|
||||||
const next = new Set(selectedIds.value)
|
|
||||||
if (allOn) pageRows.forEach((row) => next.delete(row.id))
|
|
||||||
else pageRows.forEach((row) => next.add(row.id))
|
|
||||||
selectedIds.value = next
|
|
||||||
}
|
|
||||||
async function removeSelected() {
|
|
||||||
if (!selectedCount.value) return
|
|
||||||
const rows = items.value.filter((row) => selectedIds.value.has(row.id))
|
|
||||||
const sample = rows.slice(0, 3).map((row) => row.version).join('、')
|
|
||||||
const summary = rows.length > 3 ? `${sample} 等 ${rows.length} 个` : sample
|
|
||||||
if (!(await openAdminConfirm({ message: `确认删除选中的 ${rows.length} 个客户端包(${summary})?此操作不可恢复。`, danger: true }))) return
|
|
||||||
try {
|
|
||||||
await deleteWorkbenchClientPackages(Array.from(selectedIds.value))
|
|
||||||
ElMessage.success(`已删除 ${rows.length} 个客户端包`)
|
|
||||||
selectedIds.value = new Set()
|
|
||||||
await load()
|
|
||||||
} catch (error) {
|
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async function removeOne(row: WorkbenchClientPackageItem) {
|
|
||||||
if (!(await openAdminConfirm({ message: `确认删除客户端包 ${row.version}(${row.fileName})?此操作不可恢复。`, danger: true }))) return
|
|
||||||
try {
|
|
||||||
await deleteWorkbenchClientPackages([row.id])
|
|
||||||
ElMessage.success('删除成功')
|
|
||||||
selectedIds.value = new Set([...selectedIds.value].filter((id) => id !== row.id))
|
|
||||||
await load()
|
|
||||||
} catch (error) {
|
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const uploadVisible = ref(false)
|
|
||||||
const uploading = ref(false)
|
|
||||||
const uploadPercent = ref(0)
|
|
||||||
const newVersion = ref('')
|
|
||||||
const pickedFile = ref<File | null>(null)
|
|
||||||
const uploadMsg = ref('')
|
|
||||||
const uploadMsgOk = ref(false)
|
|
||||||
|
|
||||||
async function load() {
|
|
||||||
loading.value = true
|
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
|
||||||
items.value = (await fetchWorkbenchClientPackages()).items
|
|
||||||
} catch (error) {
|
|
||||||
loadFailure.value = error instanceof Error ? error.message : '客户端包列表加载失败'
|
|
||||||
showAdminFeedback(loadFailure.value, 'error')
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onFileChange(file: File) {
|
|
||||||
pickedFile.value = file
|
|
||||||
}
|
|
||||||
|
|
||||||
function openUpload() {
|
|
||||||
uploadMsg.value = ''
|
|
||||||
uploadMsgOk.value = false
|
|
||||||
newVersion.value = ''
|
|
||||||
pickedFile.value = null
|
|
||||||
uploadVisible.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
async function submitUpload() {
|
|
||||||
uploadMsg.value = ''
|
|
||||||
uploadMsgOk.value = false
|
|
||||||
uploadPercent.value = 0
|
|
||||||
if (!newVersion.value.trim()) {
|
|
||||||
uploadMsg.value = '请填写版本号'
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!isValidWorkbenchClientVersion(newVersion.value)) {
|
|
||||||
uploadMsg.value = '版本号必须是纯数字 x.y.z 格式(如 1.0.113),不能带 v 前缀或其他后缀'
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!pickedFile.value) {
|
|
||||||
uploadMsg.value = '请选择 zip 压缩包'
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!/\.zip$/i.test(pickedFile.value.name)) {
|
|
||||||
uploadMsg.value = '仅支持 .zip 格式'
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (pickedFile.value.size > 512 * 1024 * 1024) {
|
|
||||||
uploadMsg.value = '文件超过允许的大小限制'
|
|
||||||
return
|
|
||||||
}
|
|
||||||
uploading.value = true
|
|
||||||
try {
|
|
||||||
await uploadWorkbenchClientPackage(pickedFile.value, pickedFile.value.name, newVersion.value.trim(), (p) => {
|
|
||||||
uploadPercent.value = p
|
|
||||||
uploadMsg.value = p >= 100 ? '上传完成,正在复算 sha256 并登记...' : `正在上传:${p}%`
|
|
||||||
})
|
|
||||||
uploadMsg.value = '上传成功,客户端已可检测到新版本'
|
|
||||||
uploadMsgOk.value = true
|
|
||||||
newVersion.value = ''
|
|
||||||
pickedFile.value = null
|
|
||||||
uploadPercent.value = 0
|
|
||||||
load()
|
|
||||||
} catch (error) {
|
|
||||||
uploadMsg.value = error instanceof Error ? error.message : '上传失败'
|
|
||||||
} finally {
|
|
||||||
uploading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(load)
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="workbench-view">
|
|
||||||
<section class="panel-box">
|
|
||||||
<div class="workbench-head">
|
|
||||||
<h3>客户端包列表</h3>
|
|
||||||
<div class="workbench-head-tools">
|
|
||||||
<input v-model="keyword" type="text" placeholder="搜索版本号或文件名" class="workbench-keyword" />
|
|
||||||
<button class="btn btn-danger" type="button" :disabled="!selectedCount" @click="removeSelected">删除选中{{ selectedCount ? `(${selectedCount})` : '' }}</button>
|
|
||||||
<button class="btn" type="button" @click="openUpload">上传客户端包</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<p class="page-hint">最新上传的一条即当前生效版本。</p>
|
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
|
||||||
<div class="table-scroll workbench-table-scroll">
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th style="width: 40px" class="th-select">
|
|
||||||
<input type="checkbox" :checked="pagedItems.length > 0 && pagedItems.every((r) => selectedIds.has(r.id))" @change="toggleSelectAllPage" :disabled="!pagedItems.length" />
|
|
||||||
</th>
|
|
||||||
<th style="width: 120px">版本号</th>
|
|
||||||
<th style="width: 220px">文件名</th>
|
|
||||||
<th style="width: 100px">大小</th>
|
|
||||||
<th style="width: 220px">SHA-256</th>
|
|
||||||
<th style="width: 150px">上传时间</th>
|
|
||||||
<th>下载链接</th>
|
|
||||||
<th style="width: 170px">操作</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<template v-if="filteredItems.length">
|
|
||||||
<tr v-for="row in pagedItems" :key="row.id" :class="{ 'row-selected': selectedIds.has(row.id) }">
|
|
||||||
<td class="td-select">
|
|
||||||
<input type="checkbox" :checked="selectedIds.has(row.id)" @change="toggleSelect(row.id)" />
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<span class="version-cell" :title="row.version">{{ row.version }}</span>
|
|
||||||
<span v-if="row.id === activeId" class="tag-active">当前生效</span>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<span class="file-name" :title="row.fileName">{{ row.fileName }}</span>
|
|
||||||
</td>
|
|
||||||
<td>{{ formatFileSize(row.fileSize) }}</td>
|
|
||||||
<td>
|
|
||||||
<span v-if="row.sha256" class="sha-cell" :title="row.sha256">{{ row.sha256 }}</span>
|
|
||||||
<span v-else class="dim">—</span>
|
|
||||||
</td>
|
|
||||||
<td>{{ formatDateTime(row.createdAt) }}</td>
|
|
||||||
<td>
|
|
||||||
<a v-if="row.fileUrl" class="link-cell" :href="row.fileUrl" target="_blank" rel="noopener" :title="row.fileUrl">{{ row.fileUrl }}</a>
|
|
||||||
<span v-else class="dim">—</span>
|
|
||||||
</td>
|
|
||||||
<td class="ops-cell">
|
|
||||||
<a v-if="row.fileUrl" class="btn btn-sm dl-btn" :href="row.fileUrl" download>下载</a>
|
|
||||||
<span v-else class="dim">—</span>
|
|
||||||
<button class="btn btn-sm btn-danger" type="button" @click="removeOne(row)">删除</button>
|
|
||||||
</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">{{ keyword ? '暂无匹配客户端包' : '暂无客户端包记录' }}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<OldPagination v-if="filteredItems.length > 0" :total="filteredItems.length" :page="page" :page-size="pageSize" @change="changePage" @size-change="changeSize" />
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<el-dialog v-model="uploadVisible" title="上传客户端包" width="540px">
|
|
||||||
<p class="upload-desc">上传数富AI工作台客户端 ZIP 包后,客户端会从公开版本接口自动检测到新版本并升级;服务端会复算 sha256 供客户端校验。</p>
|
|
||||||
<el-form label-width="110px">
|
|
||||||
<el-form-item label="版本号" required>
|
|
||||||
<el-input v-model="newVersion" :placeholder="`例如:1.0.113(纯数字 x.y.z,最长 ${WORKBENCH_CLIENT_VERSION_MAX_LENGTH} 字符)`" :maxlength="WORKBENCH_CLIENT_VERSION_MAX_LENGTH" />
|
|
||||||
<p class="zip-hint">客户端按版本号判断是否需要升级,必填;不要带 v 前缀</p>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="ZIP 压缩包" required>
|
|
||||||
<el-upload :auto-upload="false" :limit="1" accept=".zip" :on-change="(file: any) => onFileChange(file.raw)" :on-remove="() => (pickedFile = null)">
|
|
||||||
<el-button>选择文件</el-button>
|
|
||||||
</el-upload>
|
|
||||||
<p class="zip-hint">仅支持 .zip 格式,最大 512MB</p>
|
|
||||||
<div v-if="pickedFile" class="dim">{{ pickedFile.name }}({{ formatFileSize(pickedFile.size) }})</div>
|
|
||||||
</el-form-item>
|
|
||||||
<el-progress v-if="uploading && uploadPercent > 0" :percentage="uploadPercent" :stroke-width="10" :status="uploadPercent >= 100 ? 'success' : undefined" class="upload-progress" />
|
|
||||||
<el-alert v-if="uploadMsg" :title="uploadMsg" :type="uploadMsgOk ? 'success' : 'error'" :closable="false" show-icon class="upload-msg" />
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="uploadVisible = false">取消</el-button>
|
|
||||||
<el-button type="primary" :loading="uploading" @click="submitUpload">上传客户端包</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
/* 沿用软件版本/教程管理页(旧版 admin.html panel-version)的样式语言。 */
|
|
||||||
.workbench-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;
|
|
||||||
}
|
|
||||||
.workbench-head {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 12px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
.workbench-head-tools {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
.workbench-keyword {
|
|
||||||
width: 220px;
|
|
||||||
min-height: 42px;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
.workbench-keyword:hover {
|
|
||||||
border-color: #9fb7cd;
|
|
||||||
}
|
|
||||||
.workbench-keyword:focus {
|
|
||||||
background: #ffffff;
|
|
||||||
border-color: #5f85ad;
|
|
||||||
box-shadow: 0 0 0 3px rgba(95, 133, 173, 0.16);
|
|
||||||
}
|
|
||||||
.page-hint {
|
|
||||||
margin: -6px 0 14px;
|
|
||||||
color: #5b6f83;
|
|
||||||
font-size: 12.5px;
|
|
||||||
}
|
|
||||||
.page-hint code {
|
|
||||||
padding: 1px 6px;
|
|
||||||
border-radius: 5px;
|
|
||||||
background: #edf4fa;
|
|
||||||
color: #2f5d8b;
|
|
||||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
.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-sm {
|
|
||||||
min-height: 36px;
|
|
||||||
padding: 7px 12px;
|
|
||||||
}
|
|
||||||
.btn-danger {
|
|
||||||
background: linear-gradient(135deg, #c06d77, #b35f6a);
|
|
||||||
border-color: #b35f6a;
|
|
||||||
}
|
|
||||||
.btn-danger:hover:not(:disabled) {
|
|
||||||
background: linear-gradient(135deg, #cb7c84, #b96570);
|
|
||||||
}
|
|
||||||
.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;
|
|
||||||
}
|
|
||||||
.workbench-table-scroll > table {
|
|
||||||
min-width: 1200px;
|
|
||||||
}
|
|
||||||
.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;
|
|
||||||
}
|
|
||||||
.file-name,
|
|
||||||
.version-cell {
|
|
||||||
display: inline-block;
|
|
||||||
max-width: 100%;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.tag-active {
|
|
||||||
display: inline-block;
|
|
||||||
margin-left: 6px;
|
|
||||||
padding: 1px 7px;
|
|
||||||
border: 1px solid #4f9a72;
|
|
||||||
border-radius: 999px;
|
|
||||||
background: #eaf6ef;
|
|
||||||
color: #2f7a55;
|
|
||||||
font-size: 11.5px;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
.sha-cell {
|
|
||||||
display: block;
|
|
||||||
overflow: hidden;
|
|
||||||
color: #5b6f83;
|
|
||||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
||||||
font-size: 12px;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
|
||||||
.link-cell {
|
|
||||||
display: block;
|
|
||||||
color: #2f5d8b;
|
|
||||||
text-decoration: none;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
|
||||||
.link-cell:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
.dl-btn {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
.dim {
|
|
||||||
color: #8293a5;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
.empty-tip {
|
|
||||||
padding: 44px 24px;
|
|
||||||
text-align: center;
|
|
||||||
color: #8293a5;
|
|
||||||
font-size: 13.5px;
|
|
||||||
}
|
|
||||||
.upload-desc {
|
|
||||||
margin: 0 0 12px;
|
|
||||||
color: #5b6f83;
|
|
||||||
font-size: 12.5px;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
|
||||||
.zip-hint {
|
|
||||||
margin: 4px 0 0;
|
|
||||||
color: #5b6f83;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
.ops-cell {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
.row-selected td {
|
|
||||||
background: #fdf0ee;
|
|
||||||
}
|
|
||||||
.th-select,
|
|
||||||
.td-select {
|
|
||||||
text-align: center;
|
|
||||||
padding-left: 4px !important;
|
|
||||||
padding-right: 4px !important;
|
|
||||||
}
|
|
||||||
.th-select input,
|
|
||||||
.td-select input {
|
|
||||||
cursor: pointer;
|
|
||||||
accent-color: #b33a2e;
|
|
||||||
}
|
|
||||||
.upload-progress {
|
|
||||||
margin: 2px 0 10px;
|
|
||||||
}
|
|
||||||
.upload-msg {
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
.upload-msg :deep(.el-alert__title) {
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
/** 教程包接口适配(教程管理页):列表 / 直传预签名 / 确认 / 删除。 */
|
/** 教程包接口适配(教程管理页):列表 / 直传预签名 / 确认 / 删除。 */
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { http, unwrap } from '@/api/http'
|
import { http, unwrap } from '@/api/http'
|
||||||
import { CHUNK_UPLOAD_THRESHOLD, uploadFileInChunks } from '@/api/chunk-upload'
|
|
||||||
import { parseTutorialPackageList, parseTutorialPackageUpload } from './tutorial-model.ts'
|
import { parseTutorialPackageList, parseTutorialPackageUpload } from './tutorial-model.ts'
|
||||||
import type { TutorialPackageItem, TutorialPackageList } from './tutorial-dto.ts'
|
import type { TutorialPackageItem, TutorialPackageList } from './tutorial-dto.ts'
|
||||||
|
|
||||||
@@ -44,15 +43,10 @@ export async function requestTutorialPresign(fileName: string, version = ''): Pr
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 第三步:直传完成后通知后端校验对象并写入记录(data.item 为新记录行)。 */
|
/** 第三步:直传完成后通知后端校验对象并写入记录(data.item 为新记录行)。 */
|
||||||
export async function confirmTutorialPackage(
|
export async function confirmTutorialPackage(objectKey: string, fileName: string, version = ''): Promise<TutorialPackageItem | null> {
|
||||||
objectKey: string,
|
const { data } = await http.post<unknown>(TUTORIAL_CONFIRM_ENDPOINT, null, {
|
||||||
fileName: string,
|
params: { object_key: objectKey, file_name: fileName, version },
|
||||||
version = '',
|
})
|
||||||
fileKey = '',
|
|
||||||
): Promise<TutorialPackageItem | null> {
|
|
||||||
const params: Record<string, string> = { object_key: objectKey, file_name: fileName, version }
|
|
||||||
if (fileKey) params.file_key = fileKey
|
|
||||||
const { data } = await http.post<unknown>(TUTORIAL_CONFIRM_ENDPOINT, null, { params })
|
|
||||||
return parseTutorialPackageUpload(data)
|
return parseTutorialPackageUpload(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,11 +68,6 @@ export async function uploadTutorialPackage(
|
|||||||
version = '',
|
version = '',
|
||||||
onProgress?: (percent: number) => void,
|
onProgress?: (percent: number) => void,
|
||||||
): Promise<TutorialPackageItem | null> {
|
): Promise<TutorialPackageItem | null> {
|
||||||
if (file.size > CHUNK_UPLOAD_THRESHOLD) {
|
|
||||||
const uploaded = await uploadFileInChunks(file, fileName, onProgress)
|
|
||||||
const fileKey = String(uploaded.fileKey ?? uploaded.file_key ?? '')
|
|
||||||
return confirmTutorialPackage(String(uploaded.objectKey ?? ''), fileName, version, fileKey)
|
|
||||||
}
|
|
||||||
const target = await requestTutorialPresign(fileName, version)
|
const target = await requestTutorialPresign(fileName, version)
|
||||||
await directPut.put(target.uploadUrl, file, {
|
await directPut.put(target.uploadUrl, file, {
|
||||||
headers: { 'Content-Type': 'application/octet-stream' },
|
headers: { 'Content-Type': 'application/octet-stream' },
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/** 软件版本列表加载适配(任务 127):GET /api/admin/versions。 */
|
/** 软件版本列表加载适配(任务 127):GET /api/admin/versions。 */
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { http, unwrap } from '@/api/http'
|
import { http, unwrap } from '@/api/http'
|
||||||
import { CHUNK_UPLOAD_THRESHOLD, uploadFileInChunks } from '@/api/chunk-upload'
|
|
||||||
import { parseSoftwareVersionList, parseSoftwareVersionUpload } from './version-model.ts'
|
import { parseSoftwareVersionList, parseSoftwareVersionUpload } from './version-model.ts'
|
||||||
import type { SoftwareVersionItem, SoftwareVersionList } from './version-dto.ts'
|
import type { SoftwareVersionItem, SoftwareVersionList } from './version-dto.ts'
|
||||||
|
|
||||||
@@ -46,14 +45,9 @@ export async function requestSoftwareVersionPresign(version: string): Promise<So
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 第三步:直传完成后通知后端校验对象并写入版本记录(data.item 为新版本行)。 */
|
||||||
* 第三步:上传完成后通知后端校验并写入版本记录(data.item 为新版本行)。
|
export async function confirmSoftwareVersion(version: string): Promise<SoftwareVersionItem | null> {
|
||||||
* 分片通道把拼装件留在 Java 临时目录,服务端按 file_key 搬进 client 桶后再落库。
|
const { data } = await http.post<unknown>(SOFTWARE_VERSION_CONFIRM_ENDPOINT, null, { params: { version } })
|
||||||
*/
|
|
||||||
export async function confirmSoftwareVersion(version: string, fileKey = ''): Promise<SoftwareVersionItem | null> {
|
|
||||||
const params: Record<string, string> = { version }
|
|
||||||
if (fileKey) params.file_key = fileKey
|
|
||||||
const { data } = await http.post<unknown>(SOFTWARE_VERSION_CONFIRM_ENDPOINT, null, { params })
|
|
||||||
return parseSoftwareVersionUpload(data)
|
return parseSoftwareVersionUpload(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,12 +69,6 @@ export async function uploadSoftwareVersion(
|
|||||||
_filename = '',
|
_filename = '',
|
||||||
onProgress?: (percent: number) => void,
|
onProgress?: (percent: number) => void,
|
||||||
): Promise<SoftwareVersionUploadResult> {
|
): Promise<SoftwareVersionUploadResult> {
|
||||||
if (file.size > CHUNK_UPLOAD_THRESHOLD) {
|
|
||||||
const uploaded = await uploadFileInChunks(file, `${version}.zip`, onProgress)
|
|
||||||
const fileKey = String(uploaded.fileKey ?? uploaded.file_key ?? '')
|
|
||||||
const item = await confirmSoftwareVersion(version, fileKey)
|
|
||||||
return { version, fileUrl: item?.fileUrl || String(uploaded.url ?? ''), item }
|
|
||||||
}
|
|
||||||
const target = await requestSoftwareVersionPresign(version)
|
const target = await requestSoftwareVersionPresign(version)
|
||||||
await directPut.put(target.uploadUrl, file, {
|
await directPut.put(target.uploadUrl, file, {
|
||||||
headers: { 'Content-Type': 'application/octet-stream' },
|
headers: { 'Content-Type': 'application/octet-stream' },
|
||||||
|
|||||||
@@ -1,247 +0,0 @@
|
|||||||
/** 工作台客户端包接口适配:列表 / 直传预签名 / 分片上传 / 确认 / 删除。 */
|
|
||||||
import axios from 'axios'
|
|
||||||
import { http, unwrap } from '@/api/http'
|
|
||||||
import {
|
|
||||||
parseWorkbenchClientPackageList,
|
|
||||||
parseWorkbenchClientPackageUpload,
|
|
||||||
} from './workbench-client-model.ts'
|
|
||||||
import type { WorkbenchClientPackageItem, WorkbenchClientPackageList } from './workbench-client-dto.ts'
|
|
||||||
|
|
||||||
export const WORKBENCH_CLIENT_PACKAGES_ENDPOINT = '/api/admin/workbench-client/packages'
|
|
||||||
export const WORKBENCH_CLIENT_PACKAGE_ENDPOINT = '/api/admin/workbench-client/package'
|
|
||||||
export const WORKBENCH_CLIENT_PRESIGN_ENDPOINT = `${WORKBENCH_CLIENT_PACKAGE_ENDPOINT}/presign`
|
|
||||||
export const WORKBENCH_CLIENT_CONFIRM_ENDPOINT = `${WORKBENCH_CLIENT_PACKAGE_ENDPOINT}/confirm`
|
|
||||||
export const WORKBENCH_CLIENT_DELETE_ENDPOINT = `${WORKBENCH_CLIENT_PACKAGE_ENDPOINT}/delete`
|
|
||||||
/** 分片通道(S1-F3/AC-17):init/complete/abort 在工作台端点,分片体走通用 /api/files/chunk。 */
|
|
||||||
export const WORKBENCH_CLIENT_CHUNK_INIT_ENDPOINT = `${WORKBENCH_CLIENT_PACKAGE_ENDPOINT}/chunk/init`
|
|
||||||
export const WORKBENCH_CLIENT_CHUNK_COMPLETE_ENDPOINT = `${WORKBENCH_CLIENT_PACKAGE_ENDPOINT}/chunk/complete`
|
|
||||||
export const WORKBENCH_CLIENT_CHUNK_ENDPOINT = `${WORKBENCH_CLIENT_PACKAGE_ENDPOINT}/chunk`
|
|
||||||
/** confirm 失败的补偿清理:只删"已转存未登记"的对象(已登记后端拒绝)。 */
|
|
||||||
export const WORKBENCH_CLIENT_UNCONFIRMED_OBJECT_ENDPOINT = `${WORKBENCH_CLIENT_PACKAGE_ENDPOINT}/object`
|
|
||||||
export const FILES_CHUNK_ENDPOINT = '/api/files/chunk'
|
|
||||||
|
|
||||||
/** MinIO 直传专用实例:不带 cookie、不挂 401 跳登录拦截器;大 zip 给足超时。 */
|
|
||||||
const directPut = axios.create({ timeout: 600_000, withCredentials: false })
|
|
||||||
|
|
||||||
/** 单片大小:8MB——93MB 包 ≈ 12 片,一片失败只重传 8MB,不再从 0 重来。 */
|
|
||||||
export const UPLOAD_PART_SIZE = 8 * 1024 * 1024
|
|
||||||
|
|
||||||
/** ≤64MB 仍走单次预签名直传(链路最短);再大改分片(S1-F3)。 */
|
|
||||||
export const DIRECT_PUT_MAX_BYTES = 64 * 1024 * 1024
|
|
||||||
|
|
||||||
/** 每片重试次数(不含首次):弱网下一片抖一下不必整单作废。 */
|
|
||||||
const PART_RETRY_LIMIT = 2
|
|
||||||
|
|
||||||
export async function fetchWorkbenchClientPackages(): Promise<WorkbenchClientPackageList> {
|
|
||||||
const { data } = await http.get<unknown>(WORKBENCH_CLIENT_PACKAGES_ENDPOINT)
|
|
||||||
return parseWorkbenchClientPackageList(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface WorkbenchClientUploadTarget {
|
|
||||||
objectKey: string
|
|
||||||
uploadUrl: string
|
|
||||||
fileUrl: string
|
|
||||||
version: string
|
|
||||||
fileName: string
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 第一步:向后端申请直传 PUT 预签名地址(登录会话签发,默认 1 小时有效)。 */
|
|
||||||
export async function requestWorkbenchClientPresign(
|
|
||||||
fileName: string,
|
|
||||||
version: string,
|
|
||||||
): Promise<WorkbenchClientUploadTarget> {
|
|
||||||
const { data } = await http.post<unknown>(WORKBENCH_CLIENT_PRESIGN_ENDPOINT, null, {
|
|
||||||
params: { file_name: fileName, version },
|
|
||||||
})
|
|
||||||
const core = (unwrap(data) ?? {}) as Record<string, unknown>
|
|
||||||
const uploadUrl = typeof core.upload_url === 'string' ? core.upload_url : ''
|
|
||||||
const objectKey = typeof core.object_key === 'string' ? core.object_key : ''
|
|
||||||
if (!uploadUrl || !objectKey) {
|
|
||||||
throw new Error('后端未返回直传地址,请重试')
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
objectKey,
|
|
||||||
uploadUrl,
|
|
||||||
fileUrl: typeof core.file_url === 'string' ? core.file_url : '',
|
|
||||||
version: typeof core.version === 'string' ? core.version : version.trim(),
|
|
||||||
fileName: typeof core.file_name === 'string' ? core.file_name : fileName,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 第三步:直传完成后通知后端核对对象、复算 sha256 并落库(data.item 为新记录行)。 */
|
|
||||||
export async function confirmWorkbenchClientPackage(
|
|
||||||
objectKey: string,
|
|
||||||
fileName: string,
|
|
||||||
version: string,
|
|
||||||
): Promise<WorkbenchClientPackageItem | null> {
|
|
||||||
// confirm 要服务端流式复算最多 512MB 的 sha256;默认 30s 会在慢 MinIO/跨地域回源时
|
|
||||||
// 先超时,而服务端可能已经落库——管理员重试会得到「已登记」的错位(CR-08)。
|
|
||||||
const { data } = await http.post<unknown>(WORKBENCH_CLIENT_CONFIRM_ENDPOINT, null, {
|
|
||||||
params: { object_key: objectKey, file_name: fileName, version },
|
|
||||||
timeout: 600_000,
|
|
||||||
})
|
|
||||||
return parseWorkbenchClientPackageUpload(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* confirm 失败后的补偿清理:删除"已转存但未登记"的对象。
|
|
||||||
* 后端对已登记对象会拒绝清理(防止误删线上正在用的包),失败不覆盖原始错误。
|
|
||||||
* 返回是否确实清理成功——调用方据此决定报错文案是"可重传"还是"先刷新核对"。
|
|
||||||
*/
|
|
||||||
async function deleteUnconfirmedPackageObject(objectKey: string): Promise<boolean> {
|
|
||||||
try {
|
|
||||||
await http.delete(WORKBENCH_CLIENT_UNCONFIRMED_OBJECT_ENDPOINT, {
|
|
||||||
params: { object_key: objectKey },
|
|
||||||
})
|
|
||||||
return true
|
|
||||||
} catch {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* confirm 失败后的补偿清理(分片链):删会话 + 尽力删未登记对象。
|
|
||||||
*/
|
|
||||||
async function cleanupUnconfirmedPackage(uploadId: string, objectKey: string): Promise<void> {
|
|
||||||
try {
|
|
||||||
await http.delete(`${WORKBENCH_CLIENT_CHUNK_ENDPOINT}/${encodeURIComponent(uploadId)}`, {
|
|
||||||
params: objectKey ? { object_key: objectKey } : {},
|
|
||||||
})
|
|
||||||
} catch {
|
|
||||||
// 尽力而为:清理失败只说明残留等人工处置,不能替原始错误改口
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 按 id 批量删除客户端包(后端会顺带清理无引用对象的 MinIO 包体);返回实际删除行数。 */
|
|
||||||
export async function deleteWorkbenchClientPackages(ids: number[]): Promise<number> {
|
|
||||||
if (!ids.length) return 0
|
|
||||||
const { data } = await http.post<unknown>(WORKBENCH_CLIENT_DELETE_ENDPOINT, ids)
|
|
||||||
const core = (unwrap(data) ?? {}) as Record<string, unknown>
|
|
||||||
return typeof core.deleted === 'number' ? core.deleted : ids.length
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 单次预签名 PUT 直传(≤DIRECT_PUT_MAX_BYTES 的短链路)。 */
|
|
||||||
async function directPutUpload(
|
|
||||||
file: Blob,
|
|
||||||
target: WorkbenchClientUploadTarget,
|
|
||||||
onProgress?: (percent: number) => void,
|
|
||||||
): Promise<void> {
|
|
||||||
await directPut.put(target.uploadUrl, file, {
|
|
||||||
headers: { 'Content-Type': 'application/octet-stream' },
|
|
||||||
onUploadProgress: (event) => {
|
|
||||||
if (!onProgress) return
|
|
||||||
const total = event.total || 0
|
|
||||||
onProgress(total > 0 ? Math.min(Math.round((event.loaded / total) * 100), 100) : 0)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分片上传(S1-F3/AC-17):整包切成 partSize 片逐片 POST,每片独立重试;
|
|
||||||
* 开传前先查已到片号——上一次断掉的会话可以直接续传(后端保留 24h)。
|
|
||||||
* 这一问失败不静默按「全缺」重传:93MB 的包问不到续传点就说明链路已经不对了,
|
|
||||||
* 当场报错让人重来,也比闷头把整包再传一遍便宜。
|
|
||||||
*/
|
|
||||||
async function chunkedUpload(
|
|
||||||
file: Blob,
|
|
||||||
uploadId: string,
|
|
||||||
totalParts: number,
|
|
||||||
onProgress?: (percent: number) => void,
|
|
||||||
): Promise<void> {
|
|
||||||
const { data } = await http.get<unknown>(`${FILES_CHUNK_ENDPOINT}/${encodeURIComponent(uploadId)}`)
|
|
||||||
const core = (unwrap(data) ?? {}) as Record<string, unknown>
|
|
||||||
const done = new Set<number>(
|
|
||||||
(Array.isArray(core.uploaded_parts) ? core.uploaded_parts : []).map((index) => Number(index)),
|
|
||||||
)
|
|
||||||
const report = (partial: number) => {
|
|
||||||
if (!onProgress) return
|
|
||||||
const loaded = done.size * UPLOAD_PART_SIZE + partial
|
|
||||||
onProgress(Math.min(Math.round((loaded / file.size) * 100), 99))
|
|
||||||
}
|
|
||||||
for (let index = 0; index < totalParts; index += 1) {
|
|
||||||
if (done.has(index)) {
|
|
||||||
report(0)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
const blob = file.slice(index * UPLOAD_PART_SIZE, Math.min(file.size, (index + 1) * 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 {
|
|
||||||
await http.post(`${FILES_CHUNK_ENDPOINT}/${encodeURIComponent(uploadId)}/part/${index}`, form, {
|
|
||||||
headers: { 'Content-Type': 'multipart/form-data' },
|
|
||||||
timeout: 300_000,
|
|
||||||
onUploadProgress: (event) => report(Math.min(event.loaded || 0, blob.size)),
|
|
||||||
})
|
|
||||||
done.add(index)
|
|
||||||
lastError = null
|
|
||||||
break
|
|
||||||
} catch (error) {
|
|
||||||
lastError = error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (lastError) {
|
|
||||||
throw lastError instanceof Error ? lastError : new Error(`第 ${index} 片上传失败`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (onProgress) onProgress(100)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上传客户端包:≤64MB 走浏览器直传预签名 PUT;大包走后端分片通道(每片可重试/续传,
|
|
||||||
* 服务端拼装后转存 client 桶)。两条链最后都收敛到 confirm:服务端复算 sha256、
|
|
||||||
* 凭据扫描、版本唯一性登记。confirm 失败清理未登记对象,不留孤儿。
|
|
||||||
*/
|
|
||||||
export async function uploadWorkbenchClientPackage(
|
|
||||||
file: Blob,
|
|
||||||
fileName: string,
|
|
||||||
version: string,
|
|
||||||
onProgress?: (percent: number) => void,
|
|
||||||
): Promise<WorkbenchClientPackageItem | null> {
|
|
||||||
if (file.size <= DIRECT_PUT_MAX_BYTES) {
|
|
||||||
const target = await requestWorkbenchClientPresign(fileName, version)
|
|
||||||
await directPutUpload(file, target, onProgress)
|
|
||||||
try {
|
|
||||||
return await confirmWorkbenchClientPackage(target.objectKey, target.fileName, target.version)
|
|
||||||
} catch (error) {
|
|
||||||
// confirm 失败先 cleanup 未登记对象再报错;服务端若已登记会拒绝清理(CR-08 幂等窗口),
|
|
||||||
// 那种情况保留原错误文案引导"先刷新列表",不冒充已处置。
|
|
||||||
const cleaned = await deleteUnconfirmedPackageObject(target.objectKey)
|
|
||||||
const reason = error instanceof Error ? error.message : String(error)
|
|
||||||
if (cleaned) {
|
|
||||||
throw new Error(`安装包已上传但登记未完成(${reason})。未登记对象已清理,可直接重新上传。`)
|
|
||||||
}
|
|
||||||
throw new Error(`安装包已上传,但确认未完成(${reason})。请先刷新列表确认,不要立即重复上传。`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const totalParts = Math.max(1, Math.ceil(file.size / UPLOAD_PART_SIZE))
|
|
||||||
const { data } = await http.post<unknown>(WORKBENCH_CLIENT_CHUNK_INIT_ENDPOINT, null, {
|
|
||||||
params: { file_name: fileName, version, total_parts: totalParts, total_bytes: file.size },
|
|
||||||
})
|
|
||||||
const core = (unwrap(data) ?? {}) as Record<string, unknown>
|
|
||||||
const uploadId = typeof core.upload_id === 'string' ? core.upload_id : ''
|
|
||||||
const objectKey = typeof core.object_key === 'string' ? core.object_key : ''
|
|
||||||
if (!uploadId || !objectKey) {
|
|
||||||
throw new Error('后端未返回分片会话,请重试')
|
|
||||||
}
|
|
||||||
const confirmedName = typeof core.file_name === 'string' ? core.file_name : fileName
|
|
||||||
const confirmedVersion = typeof core.version === 'string' ? core.version : version
|
|
||||||
let assembled = false
|
|
||||||
try {
|
|
||||||
await chunkedUpload(file, uploadId, totalParts, onProgress)
|
|
||||||
await http.post(WORKBENCH_CLIENT_CHUNK_COMPLETE_ENDPOINT, null, {
|
|
||||||
params: { upload_id: uploadId, object_key: objectKey, file_name: confirmedName, version: confirmedVersion },
|
|
||||||
timeout: 600_000,
|
|
||||||
})
|
|
||||||
assembled = true
|
|
||||||
return await confirmWorkbenchClientPackage(objectKey, confirmedName, confirmedVersion)
|
|
||||||
} catch (error) {
|
|
||||||
await cleanupUnconfirmedPackage(uploadId, objectKey)
|
|
||||||
const reason = error instanceof Error ? error.message : String(error)
|
|
||||||
if (assembled) {
|
|
||||||
throw new Error(`安装包已转存但登记未完成(${reason})。未登记对象已清理,可直接重新上传。`)
|
|
||||||
}
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
/** 工作台客户端包 DTO(后管「数富AI工作台客户端包管理」页)。纯类型。 */
|
|
||||||
|
|
||||||
/** 客户端包行(GET /api/admin/workbench-client/packages data.items,Java snake)。 */
|
|
||||||
export interface WorkbenchClientPackageItem {
|
|
||||||
id: number
|
|
||||||
version: string
|
|
||||||
fileName: string
|
|
||||||
objectKey: string
|
|
||||||
fileSize: number
|
|
||||||
/** 更新包 sha256(hex 小写),客户端下载后的完整性锚点 */
|
|
||||||
sha256: string
|
|
||||||
fileUrl: string
|
|
||||||
createdAt: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface WorkbenchClientPackageList {
|
|
||||||
items: WorkbenchClientPackageItem[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export function emptyWorkbenchClientPackageList(): WorkbenchClientPackageList {
|
|
||||||
return { items: [] }
|
|
||||||
}
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
/** 工作台客户端包列表加载模型:解析 snake/camel、格式化大小与版本号校验;纯逻辑。 */
|
|
||||||
import { unwrap } from '../../api/envelope.ts'
|
|
||||||
import { type WorkbenchClientPackageItem, type WorkbenchClientPackageList } from './workbench-client-dto.ts'
|
|
||||||
|
|
||||||
/** 与后端 biz_workbench_client_package.version VARCHAR(64) 对齐。 */
|
|
||||||
export const WORKBENCH_CLIENT_VERSION_MAX_LENGTH = 64
|
|
||||||
|
|
||||||
function text(value: unknown): string {
|
|
||||||
return typeof value === 'string' ? value.trim() : ''
|
|
||||||
}
|
|
||||||
|
|
||||||
function numberOrNull(value: unknown): number | null {
|
|
||||||
return typeof value === 'number' && Number.isFinite(value) ? Math.floor(value) : null
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 解析单条客户端包行;缺 id 视为无效。 */
|
|
||||||
export function toWorkbenchClientPackageItem(raw: unknown): WorkbenchClientPackageItem | 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
|
|
||||||
return {
|
|
||||||
id,
|
|
||||||
version: text(r.version),
|
|
||||||
fileName: text(r.file_name ?? r.fileName),
|
|
||||||
objectKey: text(r.object_key ?? r.objectKey),
|
|
||||||
fileSize: numberOrNull(r.file_size ?? r.fileSize) ?? 0,
|
|
||||||
sha256: text(r.sha256),
|
|
||||||
fileUrl: text(r.file_url ?? r.fileUrl),
|
|
||||||
createdAt: text(r.created_at ?? r.createdAt),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 归一化客户端包列表负载为前端结果;缺省回空列表。 */
|
|
||||||
export function parseWorkbenchClientPackageList(payload: unknown): WorkbenchClientPackageList {
|
|
||||||
const data = unwrap<unknown>(payload)
|
|
||||||
const record = data && typeof data === 'object' ? (data as Record<string, unknown>) : {}
|
|
||||||
const items = Array.isArray(record.items)
|
|
||||||
? record.items
|
|
||||||
.map((raw) => toWorkbenchClientPackageItem(raw))
|
|
||||||
.filter((item): item is WorkbenchClientPackageItem => item !== null)
|
|
||||||
: []
|
|
||||||
return { items }
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 上传成功后返回的新记录行(data.item);无 item 回 null。 */
|
|
||||||
export function parseWorkbenchClientPackageUpload(payload: unknown): WorkbenchClientPackageItem | null {
|
|
||||||
const data = unwrap<unknown>(payload)
|
|
||||||
if (!data || typeof data !== 'object') return null
|
|
||||||
const item = (data as Record<string, unknown>).item
|
|
||||||
return item ? toWorkbenchClientPackageItem(item) : null
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 版本号必填、纯数字 x.y.z、且不超过后端列宽。
|
|
||||||
* 客户端按数字逐段比较,v 前缀/两段/后缀会让严格解析器判非法 ⇒ 检查更新永远回「已是最新」。
|
|
||||||
*/
|
|
||||||
export function isValidWorkbenchClientVersion(value: string): boolean {
|
|
||||||
const normalized = typeof value === 'string' ? value.trim() : ''
|
|
||||||
return normalized.length > 0
|
|
||||||
&& normalized.length <= WORKBENCH_CLIENT_VERSION_MAX_LENGTH
|
|
||||||
&& /^\d+\.\d+\.\d+$/.test(normalized)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 字节数展示:0=未知展示为 -,其余按 KB/MB/GB 人性化。 */
|
|
||||||
export function formatFileSize(bytes: number): string {
|
|
||||||
if (!Number.isFinite(bytes) || bytes <= 0) return '—'
|
|
||||||
if (bytes < 1024) return `${bytes} B`
|
|
||||||
const units = ['KB', 'MB', 'GB']
|
|
||||||
let value = bytes / 1024
|
|
||||||
let unitIndex = 0
|
|
||||||
while (value >= 1024 && unitIndex < units.length - 1) {
|
|
||||||
value /= 1024
|
|
||||||
unitIndex += 1
|
|
||||||
}
|
|
||||||
return `${value >= 100 ? value.toFixed(0) : value.toFixed(1)} ${units[unitIndex]}`
|
|
||||||
}
|
|
||||||
@@ -7,29 +7,27 @@ import { ElMessage } from 'element-plus'
|
|||||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||||
import { fetchShopKeyList, submitCreateShopKey, updateShopKey, deleteShopKey, checkShopKeyWhitelist } from './shop-key-api.ts'
|
import { fetchShopKeyList, submitCreateShopKey, updateShopKey, deleteShopKey, checkShopKeyWhitelist } from './shop-key-api.ts'
|
||||||
import { emptyShopKeyForm, normalizeZiniaoToken, validateProxyUrl } from './shop-key-form-model.ts'
|
import { emptyShopKeyForm, normalizeZiniaoToken, validateProxyUrl } from './shop-key-form-model.ts'
|
||||||
import type { IpWhitelistStatus, ShopKeyItem } from './shop-dto.ts'
|
import type { ShopKeyItem } from './shop-dto.ts'
|
||||||
import { whitelistStatusMeta, whitelistStatusOptions } from './shop-key-model.ts'
|
import { whitelistStatusMeta } from './shop-key-model.ts'
|
||||||
import OldPagination from '@/components/OldPagination.vue'
|
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 companyTab = useCompanyTabStore()
|
const companyTab = useCompanyTabStore()
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const loadFailure = ref('')
|
|
||||||
const rows = ref<ShopKeyItem[]>([])
|
const rows = ref<ShopKeyItem[]>([])
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
const page = ref(1)
|
const page = ref(1)
|
||||||
const pageSize = ref(10)
|
const pageSize = ref(10)
|
||||||
const jumpPage = ref('')
|
const jumpPage = ref('')
|
||||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||||
/** 筛选:三个条件全部交后端做。曾经的"备注名/紫鸟账号"是前端 computed,只在**当前这一页的
|
/** 筛选:备注名/紫鸟账号(用户要求店铺密钥列表补筛选)。 */
|
||||||
* 10 行**里过滤且 total 纹丝不动 —— 第 11 行起就筛不掉,翻页后结果还会自己变回去。 */
|
const filterKeyword = ref('')
|
||||||
const filter = reactive({ keyword: '', token: '', whitelistStatus: null as IpWhitelistStatus | null })
|
const filteredRows = computed(() => {
|
||||||
const statusOptions = whitelistStatusOptions()
|
const kw = (filterKeyword.value || '').trim().toLowerCase()
|
||||||
const anyFilterActive = computed(
|
if (!kw) return rows.value
|
||||||
() => Boolean(filter.keyword.trim() || filter.token.trim() || filter.whitelistStatus),
|
return rows.value.filter((r) =>
|
||||||
)
|
`${r.remarkName || ''} ${r.ziniaoAccountName || ''}`.toLowerCase().includes(kw),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
const editingId = ref<number | null>(null)
|
const editingId = ref<number | null>(null)
|
||||||
@@ -59,22 +57,17 @@ function whitelistTooltip(row: ShopKeyItem): string {
|
|||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
try {
|
||||||
const result = await fetchShopKeyList({
|
const result = await fetchShopKeyList({
|
||||||
page: page.value,
|
page: page.value,
|
||||||
pageSize: pageSize.value,
|
pageSize: pageSize.value,
|
||||||
keyword: filter.keyword.trim() || undefined,
|
|
||||||
token: filter.token.trim() || undefined,
|
|
||||||
whitelistStatus: filter.whitelistStatus || undefined,
|
|
||||||
companyId: companyTab.requestCompanyId,
|
companyId: companyTab.requestCompanyId,
|
||||||
})
|
})
|
||||||
rows.value = result.items
|
rows.value = result.items
|
||||||
total.value = result.total
|
total.value = result.total
|
||||||
page.value = result.page
|
page.value = result.page
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loadFailure.value = error instanceof Error ? error.message : '密钥列表加载失败'
|
ElMessage.error(error instanceof Error ? error.message : '密钥列表加载失败')
|
||||||
showAdminFeedback(loadFailure.value, 'error')
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
@@ -104,13 +97,13 @@ async function checkWhitelist(row: ShopKeyItem) {
|
|||||||
if (updated.ipWhitelistStatus === 'ALLOWED') {
|
if (updated.ipWhitelistStatus === 'ALLOWED') {
|
||||||
ElMessage.success('白名单检测通过')
|
ElMessage.success('白名单检测通过')
|
||||||
} else if (updated.ipWhitelistStatus === 'BLOCKED') {
|
} else if (updated.ipWhitelistStatus === 'BLOCKED') {
|
||||||
showAdminFeedback(`白名单未放行:${updated.ipWhitelistMessage || '请求被拒绝'}`, 'error')
|
ElMessage.error(`白名单未放行:${updated.ipWhitelistMessage || '请求被拒绝'}`)
|
||||||
} else {
|
} else {
|
||||||
ElMessage.warning(updated.ipWhitelistMessage || '检测未通过')
|
ElMessage.warning(updated.ipWhitelistMessage || '检测未通过')
|
||||||
}
|
}
|
||||||
load()
|
load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '检测失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '检测失败')
|
||||||
} finally {
|
} finally {
|
||||||
checkingId.value = null
|
checkingId.value = null
|
||||||
}
|
}
|
||||||
@@ -137,7 +130,7 @@ async function submit() {
|
|||||||
saving.value = true
|
saving.value = true
|
||||||
try {
|
try {
|
||||||
if (creating) {
|
if (creating) {
|
||||||
await submitCreateShopKey({ ...form }, companyTab.requestCompanyId)
|
await submitCreateShopKey({ ...form })
|
||||||
} else {
|
} else {
|
||||||
await updateShopKey(editingId.value as number, { ...form })
|
await updateShopKey(editingId.value as number, { ...form })
|
||||||
}
|
}
|
||||||
@@ -145,7 +138,7 @@ async function submit() {
|
|||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
load()
|
load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '保存失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '保存失败')
|
||||||
} finally {
|
} finally {
|
||||||
saving.value = false
|
saving.value = false
|
||||||
}
|
}
|
||||||
@@ -153,13 +146,13 @@ async function submit() {
|
|||||||
|
|
||||||
async function remove(row: ShopKeyItem) {
|
async function remove(row: ShopKeyItem) {
|
||||||
// 对齐旧版:原生 confirm。
|
// 对齐旧版:原生 confirm。
|
||||||
if (!(await openAdminConfirm({ message: `确定删除店铺密钥“${row.ziniaoAccountName}”吗?`, danger: true }))) return
|
if (!window.confirm(`确定删除店铺密钥“${row.ziniaoAccountName}”吗?`)) return
|
||||||
try {
|
try {
|
||||||
await deleteShopKey(row.id)
|
await deleteShopKey(row.id)
|
||||||
ElMessage.success('已删除')
|
ElMessage.success('已删除')
|
||||||
load()
|
load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,16 +178,7 @@ function goJump() {
|
|||||||
changePage(Math.min(Math.max(n, 1), totalPages.value))
|
changePage(Math.min(Math.max(n, 1), totalPages.value))
|
||||||
}
|
}
|
||||||
|
|
||||||
function apply() {
|
watch(() => companyTab.activeId, () => { filterKeyword.value = ''; page.value = 1; void load() })
|
||||||
page.value = 1
|
|
||||||
void load()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 切公司 = 清掉全部筛选 + 回第 1 页 + 重取数,与其余 9 页同一条约定
|
|
||||||
// (护栏 company-tab-wiring 的 WATCH_BODY_PINS 逐字钉着这一行)。
|
|
||||||
// 筛选改到服务端做之后这条更要守:留着上一家填的词去筛新一家,首屏就是一张
|
|
||||||
// 「暂无匹配密钥」而框里还显示着那个词——tab 看着像坏了,请求/后端/权限三处都没错。
|
|
||||||
watch(() => companyTab.activeId, () => { filter.keyword = ''; filter.token = ''; filter.whitelistStatus = null; page.value = 1; void load() })
|
|
||||||
|
|
||||||
onMounted(load)
|
onMounted(load)
|
||||||
</script>
|
</script>
|
||||||
@@ -210,42 +194,28 @@ onMounted(load)
|
|||||||
<div class="form-row keys-filter-row">
|
<div class="form-row keys-filter-row">
|
||||||
<div class="form-group" style="min-width: 220px">
|
<div class="form-group" style="min-width: 220px">
|
||||||
<label>备注名 / 紫鸟账号</label>
|
<label>备注名 / 紫鸟账号</label>
|
||||||
<input v-model="filter.keyword" type="text" placeholder="模糊搜索备注名或紫鸟账号" @keyup.enter="apply" />
|
<input v-model="filterKeyword" type="text" placeholder="模糊搜索备注名或紫鸟账号" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" style="min-width: 220px">
|
|
||||||
<label>紫鸟令牌</label>
|
|
||||||
<input v-model="filter.token" type="text" placeholder="粘贴令牌或其片段定位这一把" @keyup.enter="apply" />
|
|
||||||
</div>
|
|
||||||
<div class="form-group" style="min-width: 160px">
|
|
||||||
<label>白名单状态</label>
|
|
||||||
<el-select v-model="filter.whitelistStatus" class="admin-filter" clearable placeholder="全部状态">
|
|
||||||
<el-option v-for="option in statusOptions" :key="option.value" :label="option.label" :value="option.value" />
|
|
||||||
</el-select>
|
|
||||||
</div>
|
|
||||||
<button class="btn" type="button" @click="apply">查询</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
|
||||||
<div class="shop-key-table-scroll">
|
<div class="shop-key-table-scroll">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<!-- 刚性列(序号/两个时间/操作)给准 px,文本列收到"能 ellipsis 但不白占"的宽度:
|
|
||||||
原来 1538px 在 ~1280 的内容区里放不下,"操作"整列要横向滚动才看得见。 -->
|
|
||||||
<tr>
|
<tr>
|
||||||
<th style="width: 52px">序号</th>
|
<th style="width: 58px">序号</th>
|
||||||
<th style="width: 110px">备注名</th>
|
<th style="width: 150px">备注名</th>
|
||||||
<th style="width: 140px">紫鸟账号名称</th>
|
<th style="width: 160px">紫鸟账号名称</th>
|
||||||
<th style="width: 160px">紫鸟令牌</th>
|
<th style="width: 220px">紫鸟令牌</th>
|
||||||
<th style="width: 90px">代理</th>
|
<th style="width: 190px">代理</th>
|
||||||
<th style="width: 110px">白名单状态 <span class="table-help" aria-hidden="true">?</span></th>
|
<th style="width: 150px">白名单状态 <span class="table-help" aria-hidden="true">?</span></th>
|
||||||
<th style="width: 160px">创建时间</th>
|
<th style="width: 170px">创建时间</th>
|
||||||
<th style="width: 160px">修改时间</th>
|
<th style="width: 170px">修改时间</th>
|
||||||
<th style="width: 245px">操作</th>
|
<th style="width: 160px">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<template v-if="rows.length">
|
<template v-if="filteredRows.length">
|
||||||
<tr v-for="(row, index) in rows" :key="row.id">
|
<tr v-for="(row, index) in filteredRows" :key="row.id">
|
||||||
<td>{{ (page - 1) * pageSize + index + 1 }}</td>
|
<td>{{ (page - 1) * pageSize + index + 1 }}</td>
|
||||||
<td>{{ row.remarkName || '—' }}</td>
|
<td>{{ row.remarkName || '—' }}</td>
|
||||||
<td>{{ row.ziniaoAccountName }}</td>
|
<td>{{ row.ziniaoAccountName }}</td>
|
||||||
@@ -288,7 +258,7 @@ onMounted(load)
|
|||||||
<td colspan="9" class="empty-tip">加载中...</td>
|
<td colspan="9" class="empty-tip">加载中...</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-else>
|
<tr v-else>
|
||||||
<td colspan="9" class="empty-tip">{{ anyFilterActive ? '暂无匹配密钥' : '暂无店铺密钥' }}</td>
|
<td colspan="9" class="empty-tip">{{ filterKeyword ? '暂无匹配密钥' : '暂无店铺密钥' }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -546,10 +516,6 @@ h3 {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
/* 兜底:单元格是 overflow:hidden + table-layout:fixed,按钮总宽一旦超过列宽,
|
|
||||||
最后一颗会整颗被裁掉(看不见也点不到,2026-10-08 的"删除按钮没了"就是这么来的)。
|
|
||||||
允许换行等于把"静默消失"换成"多占一行"。 */
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-tip {
|
.empty-tip {
|
||||||
|
|||||||
@@ -17,16 +17,12 @@ import {
|
|||||||
import { emptyShopManageForm } from './shop-manage-form-model.ts'
|
import { emptyShopManageForm } from './shop-manage-form-model.ts'
|
||||||
import type { ShopCredential, ShopGroupOption, ShopSummary } from './shop-dto.ts'
|
import type { ShopCredential, ShopGroupOption, ShopSummary } from './shop-dto.ts'
|
||||||
import OldPagination from '@/components/OldPagination.vue'
|
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 session = useAdminSessionStore()
|
||||||
const companyTab = useCompanyTabStore()
|
const companyTab = useCompanyTabStore()
|
||||||
/** 仅超管需要分组维度:非超管数据由后端裁剪到本人分组,分组筛选/列一律不展示。 */
|
/** 仅超管需要分组维度:非超管数据由后端裁剪到本人分组,分组筛选/列一律不展示。 */
|
||||||
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
const isSuperAdmin = computed(() => session.isSuperAdmin)
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const loadFailure = ref('')
|
|
||||||
const rows = ref<ShopSummary[]>([])
|
const rows = ref<ShopSummary[]>([])
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
const page = ref(1)
|
const page = ref(1)
|
||||||
@@ -74,7 +70,7 @@ async function togglePassword(row: ShopSummary) {
|
|||||||
revealedPasswordCache.value[row.id] = cred.password
|
revealedPasswordCache.value[row.id] = cred.password
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
revealedRowId.value = null
|
revealedRowId.value = null
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '读取密码失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '读取密码失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,13 +79,12 @@ async function loadGroups() {
|
|||||||
try {
|
try {
|
||||||
groups.value = await fetchShopManageGroups(companyTab.requestCompanyId)
|
groups.value = await fetchShopManageGroups(companyTab.requestCompanyId)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '分组加载失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '分组加载失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
try {
|
||||||
const result = await fetchShopManageList({
|
const result = await fetchShopManageList({
|
||||||
page: page.value,
|
page: page.value,
|
||||||
@@ -102,8 +97,7 @@ async function load() {
|
|||||||
total.value = result.total
|
total.value = result.total
|
||||||
page.value = result.page
|
page.value = result.page
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loadFailure.value = error instanceof Error ? error.message : '店铺列表加载失败'
|
ElMessage.error(error instanceof Error ? error.message : '店铺列表加载失败')
|
||||||
showAdminFeedback(loadFailure.value, 'error')
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
@@ -184,7 +178,7 @@ async function submit() {
|
|||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
load()
|
load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '保存失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '保存失败')
|
||||||
} finally {
|
} finally {
|
||||||
saving.value = false
|
saving.value = false
|
||||||
}
|
}
|
||||||
@@ -195,19 +189,19 @@ async function showCredential(row: ShopSummary) {
|
|||||||
credential.value = await fetchShopCredential(row.id, row.shopName)
|
credential.value = await fetchShopCredential(row.id, row.shopName)
|
||||||
credentialVisible.value = true
|
credentialVisible.value = true
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '读取凭证失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '读取凭证失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function remove(row: ShopSummary) {
|
async function remove(row: ShopSummary) {
|
||||||
// 对齐旧版:原生 confirm。
|
// 对齐旧版:原生 confirm。
|
||||||
if (!(await openAdminConfirm({ message: `确定删除店铺“${row.shopName}”吗?`, danger: true }))) return
|
if (!window.confirm(`确定删除店铺“${row.shopName}”吗?`)) return
|
||||||
try {
|
try {
|
||||||
await deleteShopManage(row.id)
|
await deleteShopManage(row.id)
|
||||||
ElMessage.success('已删除')
|
ElMessage.success('已删除')
|
||||||
load()
|
load()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '删除失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '删除失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,7 +242,6 @@ onMounted(() => {
|
|||||||
<button class="btn" type="button" @click="apply">查询</button>
|
<button class="btn" type="button" @click="apply">查询</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
|
||||||
<div class="table-scroll shop-manage-table-scroll">
|
<div class="table-scroll shop-manage-table-scroll">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -527,7 +520,6 @@ h3 {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty-tip {
|
.empty-tip {
|
||||||
|
|||||||
@@ -12,10 +12,8 @@ export function toSensitiveString(value: string): SensitiveString {
|
|||||||
return value as SensitiveString
|
return value as SensitiveString
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 紫鸟 IP 白名单状态。取值清单住在这里(DTO 层),model 的归一与筛选下拉共用同一份,
|
/** 紫鸟 IP 白名单状态。 */
|
||||||
* 否则"下拉里有的、后端说非法"和"药丸渲染出的态、筛不出来"会各错一次。 */
|
|
||||||
export type IpWhitelistStatus = 'UNKNOWN' | 'ALLOWED' | 'BLOCKED'
|
export type IpWhitelistStatus = 'UNKNOWN' | 'ALLOWED' | 'BLOCKED'
|
||||||
export const IP_WHITELIST_VALUES: readonly IpWhitelistStatus[] = ['UNKNOWN', 'ALLOWED', 'BLOCKED']
|
|
||||||
|
|
||||||
/** 店铺密钥行(GET /api/admin/shop-keys data.items;Java ShopKeyItemVo)。 */
|
/** 店铺密钥行(GET /api/admin/shop-keys data.items;Java ShopKeyItemVo)。 */
|
||||||
export interface ShopKeyItem {
|
export interface ShopKeyItem {
|
||||||
@@ -83,16 +81,10 @@ export interface ShopGroupOption {
|
|||||||
leaderUsername?: string
|
leaderUsername?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 店铺密钥列表分页参数(分页 + 三个筛选 + 公司 tab;归一是白名单构造,不点名 companyId)。 */
|
/** 店铺密钥列表分页参数(分页 + 公司 tab;归一是白名单构造,不点名 companyId)。 */
|
||||||
export interface ShopKeyListParams {
|
export interface ShopKeyListParams {
|
||||||
page: number
|
page: number
|
||||||
pageSize: number
|
pageSize: number
|
||||||
/** 备注名 / 紫鸟账号 模糊词。 */
|
|
||||||
keyword?: string
|
|
||||||
/** 紫鸟令牌 模糊词。 */
|
|
||||||
token?: string
|
|
||||||
/** 白名单状态等值筛;空 = 不筛。 */
|
|
||||||
whitelistStatus?: IpWhitelistStatus | null
|
|
||||||
/** 公司 tab 的值;normalizeKeyListParams 不点名它,只有 api 层能从原始 params 读到。 */
|
/** 公司 tab 的值;normalizeKeyListParams 不点名它,只有 api 层能从原始 params 读到。 */
|
||||||
companyId?: number | null
|
companyId?: number | null
|
||||||
}
|
}
|
||||||
@@ -110,10 +102,6 @@ export interface ShopManageListParams {
|
|||||||
export interface ShopKeyPageQuery {
|
export interface ShopKeyPageQuery {
|
||||||
page: number
|
page: number
|
||||||
pageSize: number
|
pageSize: number
|
||||||
/** 下划线形:与后端 @RequestParam(name = "keyword"/"token"/"whitelist_status") 逐字对齐。 */
|
|
||||||
keyword?: string
|
|
||||||
token?: string
|
|
||||||
whitelist_status?: string
|
|
||||||
/** 下划线形:与后端 @RequestParam(name = "company_id") 逐字对齐。 */
|
/** 下划线形:与后端 @RequestParam(name = "company_id") 逐字对齐。 */
|
||||||
company_id?: number
|
company_id?: number
|
||||||
}
|
}
|
||||||
@@ -140,14 +128,6 @@ function trimOrUndefined(value: unknown): string | undefined {
|
|||||||
return typeof value === 'string' && value.trim() ? value.trim() : undefined
|
return typeof value === 'string' && value.trim() ? value.trim() : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 白名单状态归一:大小写/空白容忍,不在清单里的一律当"不筛"(下拉只可能给清单内的值)。 */
|
|
||||||
function statusOrUndefined(value: unknown): IpWhitelistStatus | undefined {
|
|
||||||
const textValue = typeof value === 'string' ? value.trim().toUpperCase() : ''
|
|
||||||
return IP_WHITELIST_VALUES.includes(textValue as IpWhitelistStatus)
|
|
||||||
? (textValue as IpWhitelistStatus)
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 归一化分页:页码下限 1、页大小钳制在 1..100(与 Java 服务端一致)。 */
|
/** 归一化分页:页码下限 1、页大小钳制在 1..100(与 Java 服务端一致)。 */
|
||||||
function normalizePageCore(raw: { page?: unknown; pageSize?: unknown }): { page: number; pageSize: number } {
|
function normalizePageCore(raw: { page?: unknown; pageSize?: unknown }): { page: number; pageSize: number } {
|
||||||
const page = Math.max(finiteInt(raw.page) ?? SHOP_PAGE_MIN_PAGE, SHOP_PAGE_MIN_PAGE)
|
const page = Math.max(finiteInt(raw.page) ?? SHOP_PAGE_MIN_PAGE, SHOP_PAGE_MIN_PAGE)
|
||||||
@@ -159,14 +139,9 @@ function normalizePageCore(raw: { page?: unknown; pageSize?: unknown }): { page:
|
|||||||
return { page, pageSize }
|
return { page, pageSize }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 店铺密钥列表分页/筛选归一:空白筛选词与非法状态都归成"不筛",与 toKeyPageQuery 只下发非空一致。 */
|
/** 店铺密钥列表分页归一。 */
|
||||||
export function normalizeKeyListParams(raw: Partial<ShopKeyListParams>): ShopKeyListParams {
|
export function normalizeKeyListParams(raw: Partial<ShopKeyListParams>): ShopKeyListParams {
|
||||||
return {
|
return normalizePageCore(raw)
|
||||||
...normalizePageCore(raw),
|
|
||||||
keyword: trimOrUndefined(raw.keyword),
|
|
||||||
token: trimOrUndefined(raw.token),
|
|
||||||
whitelistStatus: statusOrUndefined(raw.whitelistStatus),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 店铺列表分页/筛选归一:负/缺分组 id 视为无筛选,空白店铺名视为无过滤。 */
|
/** 店铺列表分页/筛选归一:负/缺分组 id 视为无筛选,空白店铺名视为无过滤。 */
|
||||||
@@ -179,11 +154,7 @@ export function normalizeShopListParams(raw: Partial<ShopManageListParams>): Sho
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function toKeyPageQuery(params: ShopKeyListParams): ShopKeyPageQuery {
|
export function toKeyPageQuery(params: ShopKeyListParams): ShopKeyPageQuery {
|
||||||
const query: ShopKeyPageQuery = { page: params.page, pageSize: params.pageSize }
|
return { page: params.page, pageSize: params.pageSize }
|
||||||
if (params.keyword) query.keyword = params.keyword
|
|
||||||
if (params.token) query.token = params.token
|
|
||||||
if (params.whitelistStatus) query.whitelist_status = params.whitelistStatus
|
|
||||||
return query
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 前端状态 → Java 查询参数(camelCase);仅下发非空可选字段。 */
|
/** 前端状态 → Java 查询参数(camelCase);仅下发非空可选字段。 */
|
||||||
|
|||||||
@@ -27,23 +27,13 @@ export async function fetchShopKeyList(params: Partial<ShopKeyListParams> = {}):
|
|||||||
return parseShopKeyPage(data)
|
return parseShopKeyPage(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 提交新增店铺密钥:先校验(失败抛首条错误不发请求),再 POST,解析返回的新记录。 */
|
||||||
* 提交新增店铺密钥:先校验(失败抛首条错误不发请求),再 POST,解析返回的新记录。
|
export async function submitCreateShopKey(form: ShopKeyFormValues): Promise<ShopKeyItem> {
|
||||||
*
|
|
||||||
* 归属走**查询参数** `company_id`(不进请求体——Java 侧 requestDtoCarriesNoCompanyField 钉着 body
|
|
||||||
* 不许有 companyId 字段),取值是公司 tab;非超管时 `requestCompanyId` 恒为 null,
|
|
||||||
* 后端那道门会按会话落本公司,所以这里不为 null 编一个默认公司。
|
|
||||||
*/
|
|
||||||
export async function submitCreateShopKey(form: ShopKeyFormValues, companyId?: number | null): Promise<ShopKeyItem> {
|
|
||||||
const { valid, errors } = validateShopKeyForm(form)
|
const { valid, errors } = validateShopKeyForm(form)
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
throw new Error(Object.values(errors)[0] || '店铺密钥表单校验未通过')
|
throw new Error(Object.values(errors)[0] || '店铺密钥表单校验未通过')
|
||||||
}
|
}
|
||||||
const { data } = await http.post<unknown>(
|
const { data } = await http.post<unknown>(SHOP_KEYS_ENDPOINT, toShopKeyCreateRequest(form))
|
||||||
SHOP_KEYS_ENDPOINT,
|
|
||||||
toShopKeyCreateRequest(form),
|
|
||||||
companyId != null ? { params: { company_id: companyId } } : undefined,
|
|
||||||
)
|
|
||||||
const item = toShopKeyItem(unwrap<unknown>(data))
|
const item = toShopKeyItem(unwrap<unknown>(data))
|
||||||
if (!item) {
|
if (!item) {
|
||||||
throw new Error('新增店铺密钥响应异常:未返回有效记录')
|
throw new Error('新增店铺密钥响应异常:未返回有效记录')
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ import { unwrap } from '../../api/envelope.ts'
|
|||||||
import {
|
import {
|
||||||
emptyShopKeyPageResult,
|
emptyShopKeyPageResult,
|
||||||
toSensitiveString,
|
toSensitiveString,
|
||||||
IP_WHITELIST_VALUES,
|
|
||||||
type IpWhitelistStatus,
|
type IpWhitelistStatus,
|
||||||
type ShopKeyItem,
|
type ShopKeyItem,
|
||||||
type ShopKeyPageResult,
|
type ShopKeyPageResult,
|
||||||
} from './shop-dto.ts'
|
} from './shop-dto.ts'
|
||||||
|
|
||||||
|
const IP_WHITELIST_VALUES: readonly string[] = ['UNKNOWN', 'ALLOWED', 'BLOCKED']
|
||||||
|
|
||||||
function text(value: unknown): string {
|
function text(value: unknown): string {
|
||||||
return typeof value === 'string' ? value.trim() : ''
|
return typeof value === 'string' ? value.trim() : ''
|
||||||
}
|
}
|
||||||
@@ -20,7 +21,7 @@ function numberOrNull(value: unknown): number | null {
|
|||||||
/** 归一白名单状态;未知/缺省一律回 UNKNOWN。 */
|
/** 归一白名单状态;未知/缺省一律回 UNKNOWN。 */
|
||||||
export function normalizeIpWhitelistStatus(value: unknown): IpWhitelistStatus {
|
export function normalizeIpWhitelistStatus(value: unknown): IpWhitelistStatus {
|
||||||
const textValue = typeof value === 'string' ? value.trim().toUpperCase() : ''
|
const textValue = typeof value === 'string' ? value.trim().toUpperCase() : ''
|
||||||
return (IP_WHITELIST_VALUES.includes(textValue as IpWhitelistStatus) ? textValue : 'UNKNOWN') as IpWhitelistStatus
|
return (IP_WHITELIST_VALUES.includes(textValue) ? textValue : 'UNKNOWN') as IpWhitelistStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WhitelistStatusMeta {
|
export interface WhitelistStatusMeta {
|
||||||
@@ -43,18 +44,6 @@ export function whitelistStatusMeta(status: IpWhitelistStatus | null | undefined
|
|||||||
return SHOP_KEY_STATUS_META[key] || SHOP_KEY_STATUS_META.UNKNOWN
|
return SHOP_KEY_STATUS_META[key] || SHOP_KEY_STATUS_META.UNKNOWN
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 筛选下拉的选项表:从上面那张文案表推导,不另立第二份「正常/未加白名单/未检测」。
|
|
||||||
* 顺序照 IP_WHITELIST_VALUES,下拉与列表药丸同名同序才不会让"筛出来的是未检测、
|
|
||||||
* 行上写着未加白名单"这种对不上的读法出现。
|
|
||||||
*/
|
|
||||||
export function whitelistStatusOptions(): Array<{ value: IpWhitelistStatus; label: string }> {
|
|
||||||
return IP_WHITELIST_VALUES.map((value) => ({
|
|
||||||
value: value as IpWhitelistStatus,
|
|
||||||
label: SHOP_KEY_STATUS_META[value as IpWhitelistStatus].label,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 解析单条店铺密钥行;缺 id 视为无效。 */
|
/** 解析单条店铺密钥行;缺 id 视为无效。 */
|
||||||
export function toShopKeyItem(raw: unknown): ShopKeyItem | null {
|
export function toShopKeyItem(raw: unknown): ShopKeyItem | null {
|
||||||
if (!raw || typeof raw !== 'object') return null
|
if (!raw || typeof raw !== 'object') return null
|
||||||
|
|||||||
@@ -4,15 +4,10 @@
|
|||||||
* 页签二「变体采集」= 麦象批量任务(variant-collection),数据口径与列不同故独立页签。
|
* 页签二「变体采集」= 麦象批量任务(variant-collection),数据口径与列不同故独立页签。
|
||||||
* 30s 轮询:页面隐藏暂停、回前台立即刷新、卸载清理;另有手动刷新。 */
|
* 30s 轮询:页面隐藏暂停、回前台立即刷新、卸载清理;另有手动刷新。 */
|
||||||
import { computed, onMounted, onUnmounted, reactive, ref, watch } from 'vue'
|
import { computed, onMounted, onUnmounted, reactive, ref, watch } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
|
||||||
import { userNotice } from '@/api/user-notice'
|
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
|
import OldPagination from '@/components/OldPagination.vue'
|
||||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||||
import { formatDateTime, orderedPair } from '@/utils/datetime'
|
import { formatDateTime } from '@/utils/datetime'
|
||||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
|
||||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
|
||||||
import TaskCenterTaskTable from './TaskCenterTaskTable.vue'
|
|
||||||
import TaskCenterVariantTable from './TaskCenterVariantTable.vue'
|
|
||||||
import {
|
import {
|
||||||
fetchTaskCenterOverview,
|
fetchTaskCenterOverview,
|
||||||
fetchTaskCenterShopOptions,
|
fetchTaskCenterShopOptions,
|
||||||
@@ -31,14 +26,19 @@ import {
|
|||||||
VARIANT_STATUS_OPTIONS,
|
VARIANT_STATUS_OPTIONS,
|
||||||
buildTaskQuery,
|
buildTaskQuery,
|
||||||
buildVariantQuery,
|
buildVariantQuery,
|
||||||
|
countryLabel,
|
||||||
createTaskFilter,
|
createTaskFilter,
|
||||||
createVariantFilter,
|
createVariantFilter,
|
||||||
deviceDisplayName,
|
deviceDisplayName,
|
||||||
|
progressPercent,
|
||||||
progressText,
|
progressText,
|
||||||
shopDisplayName,
|
shopDisplayName,
|
||||||
tabCount,
|
tabCount,
|
||||||
taskStatusLabel,
|
taskStatusLabel,
|
||||||
taskStatusType,
|
taskStatusType,
|
||||||
|
variantAccountText,
|
||||||
|
variantStatusLabel,
|
||||||
|
variantStatusType,
|
||||||
type TaskCenterTaskFilter,
|
type TaskCenterTaskFilter,
|
||||||
type TaskCenterVariantFilter,
|
type TaskCenterVariantFilter,
|
||||||
} from './task-center-model'
|
} from './task-center-model'
|
||||||
@@ -48,7 +48,6 @@ const POLL_INTERVAL_MS = 30_000
|
|||||||
/** 公司 tab 的唯一取值出口:非超管恒 null(store 里 companyIdForRequest 已经把它算成 null),
|
/** 公司 tab 的唯一取值出口:非超管恒 null(store 里 companyIdForRequest 已经把它算成 null),
|
||||||
* 所以这里不需要再判一次角色——第二把尺子就是第二个口径。 */
|
* 所以这里不需要再判一次角色——第二把尺子就是第二个口径。 */
|
||||||
const companyTab = useCompanyTabStore()
|
const companyTab = useCompanyTabStore()
|
||||||
const route = useRoute()
|
|
||||||
|
|
||||||
type BoardTab = 'tasks' | 'variant'
|
type BoardTab = 'tasks' | 'variant'
|
||||||
const activeTab = ref<BoardTab>('tasks')
|
const activeTab = ref<BoardTab>('tasks')
|
||||||
@@ -65,19 +64,11 @@ function defaultTaskFilter(): TaskCenterTaskFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const filter = reactive<TaskCenterTaskFilter>(defaultTaskFilter())
|
const filter = reactive<TaskCenterTaskFilter>(defaultTaskFilter())
|
||||||
/** min/max 挡不住手输,落值后把倒挂的起止交换回来。 */
|
|
||||||
function clampDatePair(): void {
|
|
||||||
const [s, e] = orderedPair(filter.startTime, filter.endTime)
|
|
||||||
filter.startTime = s
|
|
||||||
filter.endTime = e
|
|
||||||
}
|
|
||||||
|
|
||||||
const tasks = ref<TaskCenterTaskRow[]>([])
|
const tasks = ref<TaskCenterTaskRow[]>([])
|
||||||
const taskTotal = ref(0)
|
const taskTotal = ref(0)
|
||||||
const taskPage = ref(1)
|
const taskPage = ref(1)
|
||||||
const taskPageSize = ref(20)
|
const taskPageSize = ref(20)
|
||||||
const tasksLoading = ref(false)
|
const tasksLoading = ref(false)
|
||||||
const tasksFailure = ref('')
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------- 变体采集
|
// ---------------------------------------------------------------- 变体采集
|
||||||
|
|
||||||
@@ -112,7 +103,7 @@ async function loadOverview() {
|
|||||||
try {
|
try {
|
||||||
overview.value = await fetchTaskCenterOverview(companyTab.requestCompanyId)
|
overview.value = await fetchTaskCenterOverview(companyTab.requestCompanyId)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(errorText(error, '汇总数据加载失败'), 'error')
|
ElMessage.error(errorText(error, '汇总数据加载失败'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,13 +112,12 @@ async function loadShopOptions() {
|
|||||||
try {
|
try {
|
||||||
shopOptions.value = (await fetchTaskCenterShopOptions(companyTab.requestCompanyId)) || []
|
shopOptions.value = (await fetchTaskCenterShopOptions(companyTab.requestCompanyId)) || []
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(errorText(error, '店铺候选加载失败'), 'error')
|
ElMessage.error(errorText(error, '店铺候选加载失败'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadTasks(silent = false) {
|
async function loadTasks(silent = false) {
|
||||||
if (!silent) tasksLoading.value = true
|
if (!silent) tasksLoading.value = true
|
||||||
tasksFailure.value = ''
|
|
||||||
try {
|
try {
|
||||||
const result = await fetchTaskCenterTasks(
|
const result = await fetchTaskCenterTasks(
|
||||||
buildTaskQuery(filter, taskPage.value, taskPageSize.value, companyTab.requestCompanyId),
|
buildTaskQuery(filter, taskPage.value, taskPageSize.value, companyTab.requestCompanyId),
|
||||||
@@ -135,8 +125,7 @@ async function loadTasks(silent = false) {
|
|||||||
tasks.value = result?.items || []
|
tasks.value = result?.items || []
|
||||||
taskTotal.value = Number(result?.total || 0)
|
taskTotal.value = Number(result?.total || 0)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
tasksFailure.value = errorText(error, '任务列表加载失败')
|
ElMessage.error(errorText(error, '任务列表加载失败'))
|
||||||
showAdminFeedback(tasksFailure.value, 'error')
|
|
||||||
} finally {
|
} finally {
|
||||||
if (!silent) tasksLoading.value = false
|
if (!silent) tasksLoading.value = false
|
||||||
}
|
}
|
||||||
@@ -152,7 +141,7 @@ async function loadVariants(silent = false) {
|
|||||||
variantTotal.value = tabCount(result?.total)
|
variantTotal.value = tabCount(result?.total)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
variantTotal.value = null
|
variantTotal.value = null
|
||||||
showAdminFeedback(errorText(error, '变体采集加载失败'), 'error')
|
ElMessage.error(errorText(error, '变体采集加载失败'))
|
||||||
} finally {
|
} finally {
|
||||||
if (!silent) variantLoading.value = false
|
if (!silent) variantLoading.value = false
|
||||||
}
|
}
|
||||||
@@ -212,10 +201,6 @@ function resetFilter() {
|
|||||||
void loadTasks()
|
void loadTasks()
|
||||||
}
|
}
|
||||||
|
|
||||||
function retryTasks() {
|
|
||||||
void loadTasks()
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeTaskPage(next: number) {
|
function changeTaskPage(next: number) {
|
||||||
if (next < 1 || next > taskTotalPages.value) return
|
if (next < 1 || next > taskTotalPages.value) return
|
||||||
taskPage.value = next
|
taskPage.value = next
|
||||||
@@ -253,25 +238,21 @@ function changeVariantSize(size: number) {
|
|||||||
|
|
||||||
// ---------------------------------------------------------------- 详情
|
// ---------------------------------------------------------------- 详情
|
||||||
|
|
||||||
async function openDetailByTaskNo(taskNo: string, companyId: number | null = companyTab.requestCompanyId) {
|
async function openDetail(row: TaskCenterTaskRow) {
|
||||||
detailVisible.value = true
|
detailVisible.value = true
|
||||||
detailLoading.value = true
|
detailLoading.value = true
|
||||||
detail.value = null
|
detail.value = null
|
||||||
try {
|
try {
|
||||||
detail.value = await fetchTaskCenterTaskDetail(taskNo, companyId)
|
detail.value = await fetchTaskCenterTaskDetail(row.taskNo, companyTab.requestCompanyId)
|
||||||
if (!detail.value) ElMessage.warning('任务不存在或无权查看')
|
if (!detail.value) ElMessage.warning('任务不存在或无权查看')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(errorText(error, '任务详情加载失败'), 'error')
|
ElMessage.error(errorText(error, '任务详情加载失败'))
|
||||||
detailVisible.value = false
|
detailVisible.value = false
|
||||||
} finally {
|
} finally {
|
||||||
detailLoading.value = false
|
detailLoading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function openDetail(row: TaskCenterTaskRow) {
|
|
||||||
await openDetailByTaskNo(row.taskNo)
|
|
||||||
}
|
|
||||||
|
|
||||||
function accountOf(row: TaskCenterTaskRow): string {
|
function accountOf(row: TaskCenterTaskRow): string {
|
||||||
return row.username || (row.userId != null ? `UID ${row.userId}` : '—')
|
return row.username || (row.userId != null ? `UID ${row.userId}` : '—')
|
||||||
}
|
}
|
||||||
@@ -297,11 +278,6 @@ function onVisibilityChange() {
|
|||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
void refreshAll()
|
void refreshAll()
|
||||||
void loadInactiveTabTotal()
|
void loadInactiveTabTotal()
|
||||||
// 通知明细里的 taskNo 深链:进页直接开抽屉;不锁当前公司 tab(通知可能来自另一家,后端仍按数据权限收口)。
|
|
||||||
const linkedTaskNo = typeof route.query.taskNo === 'string' ? route.query.taskNo.trim() : ''
|
|
||||||
if (linkedTaskNo) {
|
|
||||||
void openDetailByTaskNo(linkedTaskNo, null)
|
|
||||||
}
|
|
||||||
document.addEventListener('visibilitychange', onVisibilityChange)
|
document.addEventListener('visibilitychange', onVisibilityChange)
|
||||||
pollTimer = setInterval(() => {
|
pollTimer = setInterval(() => {
|
||||||
if (typeof document !== 'undefined' && document.visibilityState !== 'visible') return
|
if (typeof document !== 'undefined' && document.visibilityState !== 'visible') return
|
||||||
@@ -408,11 +384,11 @@ onUnmounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group" style="min-width: 190px">
|
<div class="form-group" style="min-width: 190px">
|
||||||
<label>创建时间(起)</label>
|
<label>创建时间(起)</label>
|
||||||
<input v-model="filter.startTime" type="datetime-local" :max="filter.endTime" @change="clampDatePair" />
|
<input v-model="filter.startTime" type="datetime-local" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" style="min-width: 190px">
|
<div class="form-group" style="min-width: 190px">
|
||||||
<label>创建时间(止)</label>
|
<label>创建时间(止)</label>
|
||||||
<input v-model="filter.endTime" type="datetime-local" :min="filter.startTime" @change="clampDatePair" />
|
<input v-model="filter.endTime" type="datetime-local" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label> </label>
|
<label> </label>
|
||||||
@@ -423,16 +399,77 @@ onUnmounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LoadFailureBar v-if="tasksFailure" :message="tasksFailure" @retry="retryTasks" />
|
<div class="table-scroll">
|
||||||
<TaskCenterTaskTable
|
<table>
|
||||||
:rows="tasks"
|
<thead>
|
||||||
:loading="tasksLoading"
|
<tr>
|
||||||
|
<th style="width: 120px">账号</th>
|
||||||
|
<th style="width: 160px">店铺</th>
|
||||||
|
<th style="width: 90px">国家</th>
|
||||||
|
<th style="width: 120px">业务</th>
|
||||||
|
<th style="width: 120px">状态</th>
|
||||||
|
<th style="width: 170px">任务ID</th>
|
||||||
|
<th style="width: 165px">开始时间</th>
|
||||||
|
<th style="width: 165px">最近上报</th>
|
||||||
|
<th style="width: 165px">结束时间</th>
|
||||||
|
<th style="width: 190px">进度</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<template v-if="tasks.length">
|
||||||
|
<tr v-for="row in tasks" :key="row.taskNo">
|
||||||
|
<td>
|
||||||
|
<span class="strong">{{ accountOf(row) }}</span>
|
||||||
|
</td>
|
||||||
|
<td>{{ shopDisplayName(row.shopName, row.shopCount) }}</td>
|
||||||
|
<td>{{ countryLabel(row.country) }}</td>
|
||||||
|
<td>{{ row.moduleLabel || row.moduleType }}</td>
|
||||||
|
<td>
|
||||||
|
<span class="st-pill" :class="`is-${taskStatusType(row.status)}`">{{ taskStatusLabel(row.status) }}</span>
|
||||||
|
<span v-if="row.stuck" class="badge warn">疑似卡住</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button class="cell-link mono" type="button" @click="openDetail(row)">{{ row.id }}</button>
|
||||||
|
</td>
|
||||||
|
<td>{{ formatDateTime(row.createdAt) }}</td>
|
||||||
|
<td>
|
||||||
|
<span :class="{ 'is-warn-text': row.stuck }">
|
||||||
|
{{ row.lastReportAt ? formatDateTime(row.lastReportAt) : '—' }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td>{{ row.finishedAt ? formatDateTime(row.finishedAt) : '—' }}</td>
|
||||||
|
<td>
|
||||||
|
<template v-if="taskStatusType(row.status) === 'failed'">
|
||||||
|
<span v-if="row.progressFailed > 0" class="badge danger">失败 {{ row.progressFailed }}</span>
|
||||||
|
<span v-else>—</span>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<div class="progress-line">
|
||||||
|
<span>{{ progressText(row) }}</span>
|
||||||
|
<span v-if="row.progressFailed > 0" class="badge danger">失败 {{ row.progressFailed }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="p-track" v-if="row.progressTotal > 0">
|
||||||
|
<div class="p-fill" :style="{ width: progressPercent(row) + '%' }"></div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</template>
|
||||||
|
<tr v-else-if="tasksLoading">
|
||||||
|
<td colspan="10" class="empty-tip">加载中...</td>
|
||||||
|
</tr>
|
||||||
|
<tr v-else>
|
||||||
|
<td colspan="10" class="empty-tip">暂无符合条件的任务</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<OldPagination
|
||||||
:total="taskTotal"
|
:total="taskTotal"
|
||||||
:page="taskPage"
|
:page="taskPage"
|
||||||
:page-size="taskPageSize"
|
:page-size="taskPageSize"
|
||||||
@page="changeTaskPage"
|
@change="changeTaskPage"
|
||||||
@size="changeTaskSize"
|
@size-change="changeTaskSize"
|
||||||
@open="openDetail"
|
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
@@ -460,14 +497,55 @@ onUnmounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<TaskCenterVariantTable
|
<div class="table-scroll">
|
||||||
:rows="variantRows"
|
<table>
|
||||||
:loading="variantLoading"
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="width: 150px">账号</th>
|
||||||
|
<th style="width: 200px">任务号</th>
|
||||||
|
<th style="width: 110px">状态</th>
|
||||||
|
<th style="width: 165px">开始时间</th>
|
||||||
|
<th style="width: 165px">更新时间</th>
|
||||||
|
<th>结果信息</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<template v-if="variantRows.length">
|
||||||
|
<tr v-for="row in variantRows" :key="row.taskId">
|
||||||
|
<td>
|
||||||
|
<span class="strong">{{ variantAccountText(row) }}</span>
|
||||||
|
<span v-if="!row.username && row.uid" class="sub" :title="row.uid">{{ row.uid }}</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span class="mono">{{ row.taskId }}</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span class="st-pill" :class="`is-${variantStatusType(row.status)}`">
|
||||||
|
{{ row.statusLabel || variantStatusLabel(row.status) }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td>{{ formatDateTime(row.createTime) }}</td>
|
||||||
|
<td>{{ formatDateTime(row.updateTime) }}</td>
|
||||||
|
<td>
|
||||||
|
<span class="res-mes" :title="row.resMes || ''">{{ row.resMes || '—' }}</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</template>
|
||||||
|
<tr v-else-if="variantLoading">
|
||||||
|
<td colspan="6" class="empty-tip">加载中...</td>
|
||||||
|
</tr>
|
||||||
|
<tr v-else>
|
||||||
|
<td colspan="6" class="empty-tip">暂无变体采集任务</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<OldPagination
|
||||||
:total="variantTotal ?? 0"
|
:total="variantTotal ?? 0"
|
||||||
:page="variantPage"
|
:page="variantPage"
|
||||||
:page-size="variantPageSize"
|
:page-size="variantPageSize"
|
||||||
@page="changeVariantPage"
|
@change="changeVariantPage"
|
||||||
@size="changeVariantSize"
|
@size-change="changeVariantSize"
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
@@ -501,7 +579,7 @@ onUnmounted(() => {
|
|||||||
</template>
|
</template>
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="当前处理">{{ currentScopeOf(detail) }}</el-descriptions-item>
|
<el-descriptions-item label="当前处理">{{ currentScopeOf(detail) }}</el-descriptions-item>
|
||||||
<el-descriptions-item label="错误信息" :span="2">{{ userNotice(detail.errorMessage || detail.message, '—') }}</el-descriptions-item>
|
<el-descriptions-item label="错误信息" :span="2">{{ detail.errorMessage || detail.message || '—' }}</el-descriptions-item>
|
||||||
</el-descriptions>
|
</el-descriptions>
|
||||||
|
|
||||||
<h4 class="detail-title">分组明细({{ (detail.shops || []).length }} 组)</h4>
|
<h4 class="detail-title">分组明细({{ (detail.shops || []).length }} 组)</h4>
|
||||||
@@ -660,6 +738,10 @@ h3 {
|
|||||||
color: #8598ab;
|
color: #8598ab;
|
||||||
font-size: 12.5px;
|
font-size: 12.5px;
|
||||||
}
|
}
|
||||||
|
.is-warn-text {
|
||||||
|
color: #b3803a;
|
||||||
|
font-weight: 650;
|
||||||
|
}
|
||||||
.shop-filter {
|
.shop-filter {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
@@ -747,6 +829,60 @@ h3 {
|
|||||||
border-color: #95b1cb;
|
border-color: #95b1cb;
|
||||||
color: #2f5d8b;
|
color: #2f5d8b;
|
||||||
}
|
}
|
||||||
|
.table-scroll {
|
||||||
|
width: 100%;
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
padding: 10px 12px;
|
||||||
|
text-align: left;
|
||||||
|
color: #5b6f83;
|
||||||
|
font-weight: 650;
|
||||||
|
font-size: 12.5px;
|
||||||
|
border-bottom: 1px solid #dbe6f0;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
td {
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-bottom: 1px solid #eaf1f7;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
.strong {
|
||||||
|
display: block;
|
||||||
|
font-weight: 600;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
.sub {
|
||||||
|
display: block;
|
||||||
|
color: #8598ab;
|
||||||
|
font-size: 11.5px;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
.mono {
|
||||||
|
font-family: Consolas, 'Courier New', monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
/* 任务 ID 单元格:「操作」列删除后,它是详情抽屉唯一的入口。 */
|
||||||
|
.cell-link {
|
||||||
|
padding: 0;
|
||||||
|
border: none;
|
||||||
|
background: none;
|
||||||
|
color: #2f5d8b;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.cell-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
.res-mes {
|
||||||
|
display: block;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
.st-pill {
|
.st-pill {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -798,6 +934,24 @@ h3 {
|
|||||||
background: #f8ebeb;
|
background: #f8ebeb;
|
||||||
color: #91474f;
|
color: #91474f;
|
||||||
}
|
}
|
||||||
|
.progress-line {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
.p-track {
|
||||||
|
height: 6px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: #eaf1f7;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.p-fill {
|
||||||
|
height: 100%;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: linear-gradient(90deg, #6f97bd, #4f78a5);
|
||||||
|
}
|
||||||
.empty-tip {
|
.empty-tip {
|
||||||
padding: 30px 24px;
|
padding: 30px 24px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|||||||
@@ -1,223 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import OldPagination from '@/components/OldPagination.vue'
|
|
||||||
import { formatDateTime } from '@/utils/datetime'
|
|
||||||
import type { TaskCenterTaskRow } from '@/api/task-center'
|
|
||||||
import {
|
|
||||||
countryLabel,
|
|
||||||
progressPercent,
|
|
||||||
progressText,
|
|
||||||
shopDisplayName,
|
|
||||||
taskStatusLabel,
|
|
||||||
taskStatusType,
|
|
||||||
} from './task-center-model'
|
|
||||||
|
|
||||||
defineProps<{
|
|
||||||
rows: TaskCenterTaskRow[]
|
|
||||||
loading: boolean
|
|
||||||
total: number
|
|
||||||
page: number
|
|
||||||
pageSize: number
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
page: [number]
|
|
||||||
size: [number]
|
|
||||||
open: [TaskCenterTaskRow]
|
|
||||||
}>()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="table-scroll">
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th style="width: 120px">账号</th>
|
|
||||||
<th style="width: 160px">店铺</th>
|
|
||||||
<th style="width: 90px">国家</th>
|
|
||||||
<th style="width: 120px">业务</th>
|
|
||||||
<th style="width: 120px">状态</th>
|
|
||||||
<th style="width: 170px">任务ID</th>
|
|
||||||
<th style="width: 165px">开始时间</th>
|
|
||||||
<th style="width: 165px">最近上报</th>
|
|
||||||
<th style="width: 165px">结束时间</th>
|
|
||||||
<th style="width: 190px">进度</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<template v-if="rows.length">
|
|
||||||
<tr v-for="row in rows" :key="row.taskNo">
|
|
||||||
<td>
|
|
||||||
<span class="strong">{{ row.username || (row.userId != null ? `UID ${row.userId}` : '—') }}</span>
|
|
||||||
</td>
|
|
||||||
<td>{{ shopDisplayName(row.shopName, row.shopCount) }}</td>
|
|
||||||
<td>{{ countryLabel(row.country) }}</td>
|
|
||||||
<td>{{ row.moduleLabel || row.moduleType }}</td>
|
|
||||||
<td>
|
|
||||||
<span class="st-pill" :class="`is-${taskStatusType(row.status)}`">{{ taskStatusLabel(row.status) }}</span>
|
|
||||||
<span v-if="row.stuck" class="badge warn">疑似卡住</span>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<button class="cell-link mono" type="button" @click="emit('open', row)">{{ row.id }}</button>
|
|
||||||
</td>
|
|
||||||
<td>{{ formatDateTime(row.createdAt) }}</td>
|
|
||||||
<td>
|
|
||||||
<span :class="{ 'is-warn-text': row.stuck }">
|
|
||||||
{{ row.lastReportAt ? formatDateTime(row.lastReportAt) : '—' }}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td>{{ row.finishedAt ? formatDateTime(row.finishedAt) : '—' }}</td>
|
|
||||||
<td>
|
|
||||||
<template v-if="taskStatusType(row.status) === 'failed'">
|
|
||||||
<span v-if="row.progressFailed > 0" class="badge danger">失败 {{ row.progressFailed }}</span>
|
|
||||||
<span v-else>—</span>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<div class="progress-line">
|
|
||||||
<span>{{ progressText(row) }}</span>
|
|
||||||
<span v-if="row.progressFailed > 0" class="badge danger">失败 {{ row.progressFailed }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="p-track" v-if="row.progressTotal > 0">
|
|
||||||
<div class="p-fill" :style="{ width: progressPercent(row) + '%' }"></div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</template>
|
|
||||||
<tr v-else-if="loading">
|
|
||||||
<td colspan="10" class="empty-tip">加载中...</td>
|
|
||||||
</tr>
|
|
||||||
<tr v-else>
|
|
||||||
<td colspan="10" class="empty-tip">暂无符合条件的任务</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<OldPagination
|
|
||||||
:total="total"
|
|
||||||
:page="page"
|
|
||||||
:page-size="pageSize"
|
|
||||||
@change="emit('page', $event)"
|
|
||||||
@size-change="emit('size', $event)"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.table-scroll {
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
width: 100%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
padding: 10px 12px;
|
|
||||||
text-align: left;
|
|
||||||
color: #5b6f83;
|
|
||||||
font-weight: 650;
|
|
||||||
font-size: 12.5px;
|
|
||||||
border-bottom: 1px solid #dbe6f0;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 10px 12px;
|
|
||||||
border-bottom: 1px solid #eaf1f7;
|
|
||||||
vertical-align: top;
|
|
||||||
}
|
|
||||||
.strong {
|
|
||||||
display: block;
|
|
||||||
font-weight: 600;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
.mono {
|
|
||||||
font-family: Consolas, 'Courier New', monospace;
|
|
||||||
font-size: 12px;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
.cell-link {
|
|
||||||
padding: 0;
|
|
||||||
border: none;
|
|
||||||
background: none;
|
|
||||||
color: #2f5d8b;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.cell-link:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
.is-warn-text {
|
|
||||||
color: #b3803a;
|
|
||||||
font-weight: 650;
|
|
||||||
}
|
|
||||||
.st-pill {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
padding: 2px 10px;
|
|
||||||
border-radius: 999px;
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 1.7;
|
|
||||||
border: 1px solid transparent;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.st-pill.is-success {
|
|
||||||
color: #3d7158;
|
|
||||||
background: #e8f2eb;
|
|
||||||
border-color: #bdd7c5;
|
|
||||||
}
|
|
||||||
.st-pill.is-failed {
|
|
||||||
color: #91474f;
|
|
||||||
background: #f8ebeb;
|
|
||||||
border-color: #e4c2c5;
|
|
||||||
}
|
|
||||||
.st-pill.is-pending {
|
|
||||||
color: #8a6d3b;
|
|
||||||
background: #fbf4ea;
|
|
||||||
border-color: #e7d3ae;
|
|
||||||
}
|
|
||||||
.st-pill.is-running {
|
|
||||||
color: #37618f;
|
|
||||||
background: #e8f1fb;
|
|
||||||
border-color: #c3d8ef;
|
|
||||||
}
|
|
||||||
.badge {
|
|
||||||
display: inline-block;
|
|
||||||
margin-left: 6px;
|
|
||||||
padding: 1px 7px;
|
|
||||||
border-radius: 999px;
|
|
||||||
font-size: 11px;
|
|
||||||
font-weight: 600;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.badge.danger {
|
|
||||||
background: #f8ebeb;
|
|
||||||
color: #91474f;
|
|
||||||
}
|
|
||||||
.badge.warn {
|
|
||||||
background: #fbf4ea;
|
|
||||||
color: #8a6d3b;
|
|
||||||
}
|
|
||||||
.progress-line {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
margin-bottom: 5px;
|
|
||||||
}
|
|
||||||
.p-track {
|
|
||||||
height: 6px;
|
|
||||||
border-radius: 999px;
|
|
||||||
background: #eaf1f7;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
.p-fill {
|
|
||||||
height: 100%;
|
|
||||||
border-radius: 999px;
|
|
||||||
background: linear-gradient(90deg, #6f97bd, #4f78a5);
|
|
||||||
}
|
|
||||||
.empty-tip {
|
|
||||||
padding: 30px 24px;
|
|
||||||
text-align: center;
|
|
||||||
color: #8293a5;
|
|
||||||
font-size: 13.5px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,158 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import OldPagination from '@/components/OldPagination.vue'
|
|
||||||
import { formatDateTime } from '@/utils/datetime'
|
|
||||||
import type { TaskCenterVariantTaskRow } from '@/api/task-center'
|
|
||||||
import {
|
|
||||||
variantAccountText,
|
|
||||||
variantStatusLabel,
|
|
||||||
variantStatusType,
|
|
||||||
} from './task-center-model'
|
|
||||||
|
|
||||||
defineProps<{
|
|
||||||
rows: TaskCenterVariantTaskRow[]
|
|
||||||
loading: boolean
|
|
||||||
total: number
|
|
||||||
page: number
|
|
||||||
pageSize: number
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
page: [number]
|
|
||||||
size: [number]
|
|
||||||
}>()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="table-scroll">
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th style="width: 150px">账号</th>
|
|
||||||
<th style="width: 200px">任务号</th>
|
|
||||||
<th style="width: 110px">状态</th>
|
|
||||||
<th style="width: 165px">开始时间</th>
|
|
||||||
<th style="width: 165px">更新时间</th>
|
|
||||||
<th>结果信息</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<template v-if="rows.length">
|
|
||||||
<tr v-for="row in rows" :key="row.taskId">
|
|
||||||
<td>
|
|
||||||
<span class="strong">{{ variantAccountText(row) }}</span>
|
|
||||||
<span v-if="!row.username && row.uid" class="sub" :title="row.uid">{{ row.uid }}</span>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<span class="mono">{{ row.taskId }}</span>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<span class="st-pill" :class="`is-${variantStatusType(row.status)}`">
|
|
||||||
{{ row.statusLabel || variantStatusLabel(row.status) }}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td>{{ formatDateTime(row.createTime) }}</td>
|
|
||||||
<td>{{ formatDateTime(row.updateTime) }}</td>
|
|
||||||
<td>
|
|
||||||
<span class="res-mes" :title="row.resMes || ''">{{ row.resMes || '—' }}</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</template>
|
|
||||||
<tr v-else-if="loading">
|
|
||||||
<td colspan="6" class="empty-tip">加载中...</td>
|
|
||||||
</tr>
|
|
||||||
<tr v-else>
|
|
||||||
<td colspan="6" class="empty-tip">暂无变体采集任务</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<OldPagination
|
|
||||||
:total="total"
|
|
||||||
:page="page"
|
|
||||||
:page-size="pageSize"
|
|
||||||
@change="emit('page', $event)"
|
|
||||||
@size-change="emit('size', $event)"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.table-scroll {
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
width: 100%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
padding: 10px 12px;
|
|
||||||
text-align: left;
|
|
||||||
color: #5b6f83;
|
|
||||||
font-weight: 650;
|
|
||||||
font-size: 12.5px;
|
|
||||||
border-bottom: 1px solid #dbe6f0;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 10px 12px;
|
|
||||||
border-bottom: 1px solid #eaf1f7;
|
|
||||||
vertical-align: top;
|
|
||||||
}
|
|
||||||
.strong {
|
|
||||||
display: block;
|
|
||||||
font-weight: 600;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
.sub {
|
|
||||||
display: block;
|
|
||||||
color: #8598ab;
|
|
||||||
font-size: 11.5px;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
.mono {
|
|
||||||
font-family: Consolas, 'Courier New', monospace;
|
|
||||||
font-size: 12px;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
.res-mes {
|
|
||||||
display: block;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
.st-pill {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
padding: 2px 10px;
|
|
||||||
border-radius: 999px;
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 1.7;
|
|
||||||
border: 1px solid transparent;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.st-pill.is-success {
|
|
||||||
color: #3d7158;
|
|
||||||
background: #e8f2eb;
|
|
||||||
border-color: #bdd7c5;
|
|
||||||
}
|
|
||||||
.st-pill.is-failed {
|
|
||||||
color: #91474f;
|
|
||||||
background: #f8ebeb;
|
|
||||||
border-color: #e4c2c5;
|
|
||||||
}
|
|
||||||
.st-pill.is-pending {
|
|
||||||
color: #8a6d3b;
|
|
||||||
background: #fbf4ea;
|
|
||||||
border-color: #e7d3ae;
|
|
||||||
}
|
|
||||||
.st-pill.is-running {
|
|
||||||
color: #37618f;
|
|
||||||
background: #e8f1fb;
|
|
||||||
border-color: #c3d8ef;
|
|
||||||
}
|
|
||||||
.empty-tip {
|
|
||||||
padding: 30px 24px;
|
|
||||||
text-align: center;
|
|
||||||
color: #8293a5;
|
|
||||||
font-size: 13.5px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -27,12 +27,7 @@ export function createVariantFilter(): TaskCenterVariantFilter {
|
|||||||
return { status: '' }
|
return { status: '' }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 业务下拉:与后端 TaskModuleRegistry 的客户端模块(biz_file_task 12 个 + 品牌检测)对齐。 */
|
||||||
* 业务下拉:与后端 TaskModuleRegistry 的客户端模块(biz_file_task 10 个 + 品牌检测)对齐。
|
|
||||||
* 2026-10-16 恢复两项:删除ASIN(DELETE_BRAND) 与 巡店删除(PATROL_DELETE) 按用户口径随功能
|
|
||||||
* 一起回到下拉(此前随旧版亚马逊界面退役属连带删错;该退役的只有紫鸟新版/旧版选项控件)。
|
|
||||||
* 用例侧已把原先的反向钉改成正向钉,这两项再消失就是判红。
|
|
||||||
*/
|
|
||||||
export const MODULE_OPTIONS: Array<{ value: string; label: string }> = [
|
export const MODULE_OPTIONS: Array<{ value: string; label: string }> = [
|
||||||
{ value: '', label: '全部业务' },
|
{ value: '', label: '全部业务' },
|
||||||
{ value: 'PUBLISH', label: '上架' },
|
{ value: 'PUBLISH', label: '上架' },
|
||||||
|
|||||||
@@ -1,756 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
/**
|
|
||||||
* 品牌Gating库管理页(独立菜单 admin_brand_gating,V174 恢复)。
|
|
||||||
* 数据源 /api/admin/brand-gating(biz_brand_gating,全平台共享,不随公司 Tab 收窄)。
|
|
||||||
*/
|
|
||||||
import { computed, onMounted, reactive, ref } from 'vue'
|
|
||||||
import { formatDateTime } from '@/utils/datetime'
|
|
||||||
import { actionableErrorText, type AdminFeedbackKind } from '@/components/admin-feedback'
|
|
||||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
|
||||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
|
||||||
import OldPagination from '@/components/OldPagination.vue'
|
|
||||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
|
||||||
import { createLatestRequestGate } from '@/utils/latest-request'
|
|
||||||
import {
|
|
||||||
GATING_COUNTRIES,
|
|
||||||
GATING_SOURCES,
|
|
||||||
GATING_TYPES,
|
|
||||||
createBrandGatingFilter,
|
|
||||||
createBrandGatingForm,
|
|
||||||
validateBrandGatingForm,
|
|
||||||
type BrandGatingFilter,
|
|
||||||
type BrandGatingForm,
|
|
||||||
type BrandGatingRow,
|
|
||||||
type BrandGatingStats,
|
|
||||||
} from './brand-gating-model.ts'
|
|
||||||
import {
|
|
||||||
deleteBrandGating,
|
|
||||||
fetchBrandGatingPage,
|
|
||||||
fetchBrandGatingStats,
|
|
||||||
importBrandGatingText,
|
|
||||||
submitBrandGating,
|
|
||||||
updateBrandGatingStatus,
|
|
||||||
} from './brand-gating-api.ts'
|
|
||||||
|
|
||||||
const filter = reactive<BrandGatingFilter>(createBrandGatingFilter())
|
|
||||||
const page = ref(1)
|
|
||||||
const pageSize = ref(10)
|
|
||||||
const rows = ref<BrandGatingRow[]>([])
|
|
||||||
const total = ref(0)
|
|
||||||
const pageLoading = ref(false)
|
|
||||||
const loadError = ref('')
|
|
||||||
const loaded = ref(false)
|
|
||||||
|
|
||||||
const stats = ref<BrandGatingStats | null>(null)
|
|
||||||
const statsLoading = ref(false)
|
|
||||||
const statsError = ref('')
|
|
||||||
|
|
||||||
const form = reactive<BrandGatingForm>(createBrandGatingForm())
|
|
||||||
const addBusy = ref(false)
|
|
||||||
const batchText = ref('')
|
|
||||||
const importBusy = ref(false)
|
|
||||||
const busyRowId = ref(0)
|
|
||||||
|
|
||||||
// 快速改筛选/翻页时先发的请求可能后返回;列表与统计各一个序号闸(CR-27)
|
|
||||||
const pageGate = createLatestRequestGate()
|
|
||||||
const statsGate = createLatestRequestGate()
|
|
||||||
|
|
||||||
const countryOptions = GATING_COUNTRIES.filter((country) => country !== '全部')
|
|
||||||
const typeOptions = GATING_TYPES
|
|
||||||
|
|
||||||
const statsCards = computed(() => {
|
|
||||||
const current = stats.value
|
|
||||||
const byType = new Map((current?.byType ?? []).map((item) => [item.name, item.count]))
|
|
||||||
return [
|
|
||||||
{ label: 'Gating总记录', value: current?.total ?? 0, tone: '' },
|
|
||||||
{ label: '生效中', value: current?.active ?? 0, tone: 'ok' },
|
|
||||||
{ label: '已解除', value: current?.disabled ?? 0, tone: 'muted' },
|
|
||||||
{ label: '去重品牌数', value: current?.brands ?? 0, tone: '' },
|
|
||||||
{ label: '品牌gating', value: byType.get('品牌gating') ?? 0, tone: 'primary' },
|
|
||||||
{ label: '类目gating', value: byType.get('类目gating') ?? 0, tone: 'warn' },
|
|
||||||
{ label: '账户不符合', value: byType.get('账户不符合') ?? 0, tone: 'danger' },
|
|
||||||
]
|
|
||||||
})
|
|
||||||
|
|
||||||
function feedback(message: string, kind: AdminFeedbackKind): void {
|
|
||||||
showAdminFeedback(message, kind)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadStats(): Promise<void> {
|
|
||||||
const token = statsGate.begin()
|
|
||||||
statsLoading.value = true
|
|
||||||
statsError.value = ''
|
|
||||||
try {
|
|
||||||
const result = await fetchBrandGatingStats()
|
|
||||||
if (!statsGate.isCurrent(token)) return
|
|
||||||
stats.value = result
|
|
||||||
} catch (error) {
|
|
||||||
if (!statsGate.isCurrent(token)) return
|
|
||||||
statsError.value = actionableErrorText(error)
|
|
||||||
} finally {
|
|
||||||
if (statsGate.isCurrent(token)) statsLoading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadPage(nextPage = page.value): Promise<void> {
|
|
||||||
const token = pageGate.begin()
|
|
||||||
pageLoading.value = true
|
|
||||||
loadError.value = ''
|
|
||||||
try {
|
|
||||||
const result = await fetchBrandGatingPage(filter, nextPage, pageSize.value)
|
|
||||||
if (!pageGate.isCurrent(token)) return
|
|
||||||
rows.value = result.rows
|
|
||||||
total.value = result.total
|
|
||||||
page.value = nextPage
|
|
||||||
loaded.value = true
|
|
||||||
} catch (error) {
|
|
||||||
if (!pageGate.isCurrent(token)) return
|
|
||||||
loadError.value = actionableErrorText(error)
|
|
||||||
} finally {
|
|
||||||
if (pageGate.isCurrent(token)) pageLoading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function query(): void {
|
|
||||||
loadPage(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetFilter(): void {
|
|
||||||
Object.assign(filter, createBrandGatingFilter())
|
|
||||||
loadPage(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
function changePageSize(size: number): void {
|
|
||||||
pageSize.value = size
|
|
||||||
loadPage(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function addOne(): Promise<void> {
|
|
||||||
const error = validateBrandGatingForm(form)
|
|
||||||
if (error) {
|
|
||||||
feedback(error, 'warning')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
addBusy.value = true
|
|
||||||
try {
|
|
||||||
const added = await submitBrandGating(form)
|
|
||||||
if (added) {
|
|
||||||
feedback('新增成功', 'success')
|
|
||||||
form.brand = ''
|
|
||||||
form.asin = ''
|
|
||||||
form.remark = ''
|
|
||||||
} else {
|
|
||||||
feedback('该品牌 + 国家已存在,未重复添加', 'warning')
|
|
||||||
}
|
|
||||||
await Promise.all([loadPage(added ? 1 : page.value), loadStats()])
|
|
||||||
} catch (error) {
|
|
||||||
feedback(actionableErrorText(error), 'error')
|
|
||||||
} finally {
|
|
||||||
addBusy.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function batchAdd(): Promise<void> {
|
|
||||||
const text = batchText.value.trim()
|
|
||||||
if (!text) {
|
|
||||||
feedback('请粘贴批量数据', 'warning')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
importBusy.value = true
|
|
||||||
try {
|
|
||||||
const result = await importBrandGatingText(text)
|
|
||||||
feedback(`批量导入完成:新增 ${result.added} 条,跳过重复 ${result.skipped} 条`, 'success')
|
|
||||||
batchText.value = ''
|
|
||||||
await Promise.all([loadPage(1), loadStats()])
|
|
||||||
} catch (error) {
|
|
||||||
feedback(actionableErrorText(error), 'error')
|
|
||||||
} finally {
|
|
||||||
importBusy.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function toggleStatus(row: BrandGatingRow): Promise<void> {
|
|
||||||
const enabling = row.status !== 1
|
|
||||||
if (!enabling) {
|
|
||||||
const confirmed = await openAdminConfirm({ danger: false,
|
|
||||||
title: '解除Gating',
|
|
||||||
message: `确认解除「${row.brand}」的Gating记录?解除后排查会跳过该品牌。`,
|
|
||||||
confirmText: '确认解除',
|
|
||||||
})
|
|
||||||
if (!confirmed) return
|
|
||||||
}
|
|
||||||
busyRowId.value = row.id
|
|
||||||
try {
|
|
||||||
await updateBrandGatingStatus(row.id, enabling ? 1 : 0)
|
|
||||||
feedback(enabling ? '已恢复生效' : '已解除,排查不再拦截', 'success')
|
|
||||||
await Promise.all([loadPage(), loadStats()])
|
|
||||||
} catch (error) {
|
|
||||||
feedback(actionableErrorText(error), 'error')
|
|
||||||
} finally {
|
|
||||||
busyRowId.value = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function removeRow(row: BrandGatingRow): Promise<void> {
|
|
||||||
const confirmed = await openAdminConfirm({ danger: true,
|
|
||||||
targetName: row.brand,
|
|
||||||
message: `确认删除 ID=${row.id} 的「${row.brand}」Gating记录?此操作可能影响已有数据。`,
|
|
||||||
})
|
|
||||||
if (!confirmed) return
|
|
||||||
busyRowId.value = row.id
|
|
||||||
try {
|
|
||||||
await deleteBrandGating(row.id)
|
|
||||||
feedback('已删除', 'success')
|
|
||||||
const nextPage = rows.value.length === 1 && page.value > 1 ? page.value - 1 : page.value
|
|
||||||
await Promise.all([loadPage(nextPage), loadStats()])
|
|
||||||
} catch (error) {
|
|
||||||
feedback(actionableErrorText(error), 'error')
|
|
||||||
} finally {
|
|
||||||
busyRowId.value = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function typeClass(type: string): string {
|
|
||||||
if (type.includes('账户')) return 'g-tag-acc'
|
|
||||||
if (type.includes('类目')) return 'g-tag-cat'
|
|
||||||
return 'g-tag-brand'
|
|
||||||
}
|
|
||||||
|
|
||||||
function sourceText(source: string): string {
|
|
||||||
if (source === 'AUTO') return '自动同步'
|
|
||||||
if (source === 'MANUAL') return '手动'
|
|
||||||
return source || '—'
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
loadStats()
|
|
||||||
loadPage(1)
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="gating-panel">
|
|
||||||
<div v-if="statsError" class="g-stats-error">
|
|
||||||
<span>统计加载失败:{{ statsError }}</span>
|
|
||||||
<button type="button" @click="loadStats">重试</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<section class="g-cards" v-loading="statsLoading">
|
|
||||||
<div v-for="card in statsCards" :key="card.label" class="g-card" :class="card.tone">
|
|
||||||
<div class="g-n">{{ card.value.toLocaleString() }}</div>
|
|
||||||
<div class="g-t">{{ card.label }}</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<div class="g-forms">
|
|
||||||
<section class="g-panel">
|
|
||||||
<div class="g-panel-head">新增 Gating 品牌</div>
|
|
||||||
<div class="g-panel-body">
|
|
||||||
<div class="g-fields">
|
|
||||||
<label class="g-field">
|
|
||||||
<span>品牌 *</span>
|
|
||||||
<input v-model="form.brand" placeholder="品牌(必填)" @keyup.enter="addOne" />
|
|
||||||
</label>
|
|
||||||
<label class="g-field">
|
|
||||||
<span>国家</span>
|
|
||||||
<select v-model="form.country">
|
|
||||||
<option v-for="country in GATING_COUNTRIES" :key="country" :value="country">{{ country }}</option>
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
<label class="g-field">
|
|
||||||
<span>类型</span>
|
|
||||||
<select v-model="form.gatingType">
|
|
||||||
<option v-for="type in typeOptions" :key="type" :value="type">{{ type }}</option>
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
<label class="g-field">
|
|
||||||
<span>ASIN</span>
|
|
||||||
<input v-model="form.asin" placeholder="ASIN(可选)" @keyup.enter="addOne" />
|
|
||||||
</label>
|
|
||||||
<label class="g-field g-field-wide">
|
|
||||||
<span>备注</span>
|
|
||||||
<input v-model="form.remark" placeholder="备注(可选)" @keyup.enter="addOne" />
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="g-form-actions">
|
|
||||||
<button class="g-btn g-btn-primary" type="button" :disabled="addBusy" @click="addOne">
|
|
||||||
{{ addBusy ? '新增中…' : '新增' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="g-panel">
|
|
||||||
<div class="g-panel-head">批量导入 Gating 品牌</div>
|
|
||||||
<div class="g-panel-body">
|
|
||||||
<textarea
|
|
||||||
v-model="batchText"
|
|
||||||
class="g-textarea"
|
|
||||||
placeholder="每行一个,格式:品牌,国家,类型,ASIN,备注(后四列可省略) 示例: tory burch,英国,品牌gating jellycat,全部,品牌gating crocs,德国,类目gating"
|
|
||||||
></textarea>
|
|
||||||
<div class="g-form-actions">
|
|
||||||
<button class="g-btn g-btn-violet" type="button" :disabled="importBusy" @click="batchAdd">
|
|
||||||
{{ importBusy ? '导入中…' : '批量导入' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<section class="g-panel">
|
|
||||||
<div class="g-panel-head">Gating 品牌列表</div>
|
|
||||||
<div class="g-panel-body">
|
|
||||||
<div class="g-filters">
|
|
||||||
<input v-model="filter.keyword" placeholder="搜索品牌 / ASIN" @keyup.enter="query" />
|
|
||||||
<select v-model="filter.country">
|
|
||||||
<option value="">全部国家</option>
|
|
||||||
<option v-for="country in countryOptions" :key="country" :value="country">{{ country }}</option>
|
|
||||||
</select>
|
|
||||||
<select v-model="filter.gatingType">
|
|
||||||
<option value="">全部类型</option>
|
|
||||||
<option v-for="type in typeOptions" :key="type" :value="type">{{ type }}</option>
|
|
||||||
</select>
|
|
||||||
<select v-model="filter.status">
|
|
||||||
<option value="">全部状态</option>
|
|
||||||
<option value="1">生效</option>
|
|
||||||
<option value="0">已解除</option>
|
|
||||||
</select>
|
|
||||||
<select v-model="filter.source">
|
|
||||||
<option value="">全部来源</option>
|
|
||||||
<option v-for="source in GATING_SOURCES" :key="source" :value="source">{{ sourceText(source) }}</option>
|
|
||||||
</select>
|
|
||||||
<button class="g-btn g-btn-primary" type="button" @click="query">查询</button>
|
|
||||||
<button class="g-btn g-btn-ghost" type="button" @click="resetFilter">重置</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<LoadFailureBar v-if="loadError" :message="loadError" @retry="loadPage()" />
|
|
||||||
|
|
||||||
<div class="g-table-wrap" v-loading="pageLoading">
|
|
||||||
<table v-if="rows.length" class="g-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th style="width: 64px">ID</th>
|
|
||||||
<th>品牌</th>
|
|
||||||
<th>ASIN</th>
|
|
||||||
<th style="width: 82px">国家</th>
|
|
||||||
<th style="width: 112px">类型</th>
|
|
||||||
<th style="width: 82px">状态</th>
|
|
||||||
<th style="width: 100px">来源</th>
|
|
||||||
<th>店铺</th>
|
|
||||||
<th>备注</th>
|
|
||||||
<th style="width: 156px">创建时间</th>
|
|
||||||
<th style="width: 118px">操作</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr v-for="row in rows" :key="row.id">
|
|
||||||
<td class="g-dim">{{ row.id }}</td>
|
|
||||||
<td class="g-strong">{{ row.brand }}</td>
|
|
||||||
<td class="g-mono">{{ row.asin || '—' }}</td>
|
|
||||||
<td>{{ row.country || '—' }}</td>
|
|
||||||
<td><span class="g-tag" :class="typeClass(row.gatingType)">{{ row.gatingType || '—' }}</span></td>
|
|
||||||
<td>
|
|
||||||
<span class="g-tag" :class="row.status === 1 ? 'g-tag-on' : 'g-tag-off'">
|
|
||||||
{{ row.status === 1 ? '生效' : '已解除' }}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td :class="row.source === 'AUTO' ? 'g-source-auto' : 'g-source-manual'">{{ sourceText(row.source) }}</td>
|
|
||||||
<td>{{ row.shopName || '—' }}</td>
|
|
||||||
<td class="g-remark" :title="row.remark">{{ row.remark || '—' }}</td>
|
|
||||||
<td class="g-time">{{ formatDateTime(row.createdAt) }}</td>
|
|
||||||
<td>
|
|
||||||
<div class="g-ops">
|
|
||||||
<button
|
|
||||||
class="g-btn g-btn-sm"
|
|
||||||
:class="row.status === 1 ? 'g-btn-ghost' : 'g-btn-green'"
|
|
||||||
type="button"
|
|
||||||
:disabled="busyRowId === row.id"
|
|
||||||
@click="toggleStatus(row)"
|
|
||||||
>
|
|
||||||
{{ row.status === 1 ? '解除' : '恢复' }}
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
class="g-btn g-btn-sm g-btn-danger"
|
|
||||||
type="button"
|
|
||||||
:disabled="busyRowId === row.id"
|
|
||||||
@click="removeRow(row)"
|
|
||||||
>
|
|
||||||
删除
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div v-else-if="!pageLoading && loaded" class="g-empty">暂无数据,请先在上方新增或使用前端排查软件同步</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<OldPagination
|
|
||||||
v-if="total"
|
|
||||||
:total="total"
|
|
||||||
:page="page"
|
|
||||||
:page-size="pageSize"
|
|
||||||
@change="loadPage"
|
|
||||||
@size-change="changePageSize"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.gating-panel {
|
|
||||||
--g-border: #e5e9f0;
|
|
||||||
--g-text: #1c2230;
|
|
||||||
--g-text2: #5a6474;
|
|
||||||
--g-text3: #98a1b1;
|
|
||||||
--g-primary: #2e5be6;
|
|
||||||
--g-danger: #d63a4a;
|
|
||||||
--g-green: #1f9d62;
|
|
||||||
--g-amber: #d9912b;
|
|
||||||
--g-violet: #7c5cd6;
|
|
||||||
--g-surface: #ffffff;
|
|
||||||
--g-mono: "Cascadia Mono", "SF Mono", Consolas, "Courier New", monospace;
|
|
||||||
--g-shadow: 0 1px 2px rgba(20, 30, 60, 0.05), 0 4px 18px rgba(20, 30, 60, 0.06);
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.g-stats-error {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 12px;
|
|
||||||
padding: 9px 14px;
|
|
||||||
border-radius: 9px;
|
|
||||||
border: 1px solid #f3c6cc;
|
|
||||||
background: #fdebed;
|
|
||||||
color: var(--g-danger);
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
.g-stats-error button {
|
|
||||||
border: none;
|
|
||||||
background: none;
|
|
||||||
color: var(--g-danger);
|
|
||||||
font-family: inherit;
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: 700;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.g-cards {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
.g-card {
|
|
||||||
background: var(--g-surface);
|
|
||||||
border: 1px solid var(--g-border);
|
|
||||||
border-top: 3px solid #9ca3af;
|
|
||||||
border-radius: 10px;
|
|
||||||
box-shadow: var(--g-shadow);
|
|
||||||
padding: 12px 14px;
|
|
||||||
}
|
|
||||||
.g-card.ok { border-top-color: var(--g-green); }
|
|
||||||
.g-card.muted { border-top-color: #b8c0ce; }
|
|
||||||
.g-card.primary { border-top-color: var(--g-primary); }
|
|
||||||
.g-card.warn { border-top-color: var(--g-amber); }
|
|
||||||
.g-card.danger { border-top-color: var(--g-danger); }
|
|
||||||
.g-card .g-n {
|
|
||||||
font-size: 24px;
|
|
||||||
font-weight: 700;
|
|
||||||
color: var(--g-text);
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
line-height: 1.2;
|
|
||||||
}
|
|
||||||
.g-card .g-t {
|
|
||||||
margin-top: 3px;
|
|
||||||
font-size: 11.5px;
|
|
||||||
color: var(--g-text3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.g-forms {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
|
|
||||||
gap: 14px;
|
|
||||||
}
|
|
||||||
.g-panel {
|
|
||||||
background: var(--g-surface);
|
|
||||||
border: 1px solid var(--g-border);
|
|
||||||
border-radius: 10px;
|
|
||||||
box-shadow: var(--g-shadow);
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
.g-panel-head {
|
|
||||||
padding: 11px 15px;
|
|
||||||
background: #fafbfd;
|
|
||||||
border-bottom: 1px solid #e9edf3;
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 700;
|
|
||||||
color: var(--g-text);
|
|
||||||
}
|
|
||||||
.g-panel-head::before {
|
|
||||||
content: "";
|
|
||||||
display: inline-block;
|
|
||||||
width: 7px;
|
|
||||||
height: 7px;
|
|
||||||
border-radius: 2px;
|
|
||||||
background: #2dd4bf;
|
|
||||||
margin-right: 8px;
|
|
||||||
vertical-align: 1px;
|
|
||||||
}
|
|
||||||
.g-panel-body {
|
|
||||||
padding: 14px 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.g-fields {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
|
||||||
gap: 10px 12px;
|
|
||||||
}
|
|
||||||
.g-field {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 5px;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
.g-field > span {
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--g-text2);
|
|
||||||
}
|
|
||||||
.g-field-wide {
|
|
||||||
grid-column: span 2;
|
|
||||||
}
|
|
||||||
.g-field input,
|
|
||||||
.g-field select,
|
|
||||||
.g-filters input,
|
|
||||||
.g-filters select {
|
|
||||||
width: 100%;
|
|
||||||
height: 34px;
|
|
||||||
padding: 0 10px;
|
|
||||||
border: 1px solid #d7dce5;
|
|
||||||
border-radius: 7px;
|
|
||||||
background: #fbfcfe;
|
|
||||||
color: var(--g-text);
|
|
||||||
font-family: inherit;
|
|
||||||
font-size: 13px;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
.g-field input:focus,
|
|
||||||
.g-field select:focus,
|
|
||||||
.g-filters input:focus,
|
|
||||||
.g-filters select:focus {
|
|
||||||
border-color: var(--g-primary);
|
|
||||||
box-shadow: 0 0 0 3px rgba(46, 91, 230, 0.12);
|
|
||||||
background: #fff;
|
|
||||||
}
|
|
||||||
.g-form-actions {
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
margin-top: 12px;
|
|
||||||
}
|
|
||||||
.g-textarea {
|
|
||||||
width: 100%;
|
|
||||||
height: 126px;
|
|
||||||
padding: 9px 10px;
|
|
||||||
border: 1px solid #d7dce5;
|
|
||||||
border-radius: 7px;
|
|
||||||
background: #fbfcfe;
|
|
||||||
color: var(--g-text);
|
|
||||||
font-family: inherit;
|
|
||||||
font-size: 12.5px;
|
|
||||||
line-height: 1.6;
|
|
||||||
resize: vertical;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
.g-textarea:focus {
|
|
||||||
border-color: var(--g-primary);
|
|
||||||
box-shadow: 0 0 0 3px rgba(46, 91, 230, 0.12);
|
|
||||||
background: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.g-filters {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
.g-filters input {
|
|
||||||
width: 190px;
|
|
||||||
}
|
|
||||||
.g-filters select {
|
|
||||||
width: 132px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.g-btn {
|
|
||||||
height: 34px;
|
|
||||||
padding: 0 15px;
|
|
||||||
border: 1px solid transparent;
|
|
||||||
border-radius: 7px;
|
|
||||||
font-family: inherit;
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 600;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: background 0.15s, border-color 0.15s, color 0.15s;
|
|
||||||
}
|
|
||||||
.g-btn:disabled {
|
|
||||||
opacity: 0.55;
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
.g-btn-sm {
|
|
||||||
height: 28px;
|
|
||||||
padding: 0 10px;
|
|
||||||
font-size: 12px;
|
|
||||||
border-radius: 6px;
|
|
||||||
}
|
|
||||||
.g-btn-primary {
|
|
||||||
background: var(--g-primary);
|
|
||||||
border-color: var(--g-primary);
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
.g-btn-primary:hover:not(:disabled) {
|
|
||||||
background: #1e4bd8;
|
|
||||||
border-color: #1e4bd8;
|
|
||||||
}
|
|
||||||
.g-btn-violet {
|
|
||||||
background: var(--g-violet);
|
|
||||||
border-color: var(--g-violet);
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
.g-btn-violet:hover:not(:disabled) {
|
|
||||||
background: #6b4bc4;
|
|
||||||
border-color: #6b4bc4;
|
|
||||||
}
|
|
||||||
.g-btn-green {
|
|
||||||
background: #e7f7ef;
|
|
||||||
border-color: #bce7d2;
|
|
||||||
color: var(--g-green);
|
|
||||||
}
|
|
||||||
.g-btn-green:hover:not(:disabled) {
|
|
||||||
background: #d9f2e5;
|
|
||||||
}
|
|
||||||
.g-btn-danger {
|
|
||||||
background: #fdebed;
|
|
||||||
border-color: #f3c6cc;
|
|
||||||
color: var(--g-danger);
|
|
||||||
}
|
|
||||||
.g-btn-danger:hover:not(:disabled) {
|
|
||||||
background: #fbdde1;
|
|
||||||
}
|
|
||||||
.g-btn-ghost {
|
|
||||||
background: #fff;
|
|
||||||
border-color: #d7dce5;
|
|
||||||
color: var(--g-text2);
|
|
||||||
}
|
|
||||||
.g-btn-ghost:hover:not(:disabled) {
|
|
||||||
border-color: var(--g-primary);
|
|
||||||
color: var(--g-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.g-table-wrap {
|
|
||||||
overflow-x: auto;
|
|
||||||
border: 1px solid var(--g-border);
|
|
||||||
border-radius: 9px;
|
|
||||||
min-height: 90px;
|
|
||||||
}
|
|
||||||
.g-table {
|
|
||||||
width: 100%;
|
|
||||||
border-collapse: separate;
|
|
||||||
border-spacing: 0;
|
|
||||||
font-size: 12.5px;
|
|
||||||
}
|
|
||||||
.g-table th {
|
|
||||||
position: sticky;
|
|
||||||
top: 0;
|
|
||||||
z-index: 1;
|
|
||||||
padding: 10px;
|
|
||||||
background: #f7f9fc;
|
|
||||||
border-bottom: 1px solid var(--g-border);
|
|
||||||
color: var(--g-text2);
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: 600;
|
|
||||||
text-align: left;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.g-table td {
|
|
||||||
padding: 9px 10px;
|
|
||||||
border-bottom: 1px solid #eff2f7;
|
|
||||||
color: var(--g-text);
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.g-table tbody tr:hover td {
|
|
||||||
background: #f7faff;
|
|
||||||
}
|
|
||||||
.g-table tbody tr:last-child td {
|
|
||||||
border-bottom: none;
|
|
||||||
}
|
|
||||||
.g-strong {
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
.g-dim {
|
|
||||||
color: var(--g-text3);
|
|
||||||
}
|
|
||||||
.g-mono {
|
|
||||||
font-family: var(--g-mono);
|
|
||||||
}
|
|
||||||
.g-time {
|
|
||||||
color: var(--g-text2);
|
|
||||||
font-size: 11.5px;
|
|
||||||
}
|
|
||||||
.g-remark {
|
|
||||||
max-width: 190px;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
color: var(--g-text2);
|
|
||||||
}
|
|
||||||
.g-source-auto {
|
|
||||||
color: var(--g-violet);
|
|
||||||
}
|
|
||||||
.g-source-manual {
|
|
||||||
color: #0d9488;
|
|
||||||
}
|
|
||||||
|
|
||||||
.g-tag {
|
|
||||||
display: inline-block;
|
|
||||||
padding: 2px 8px;
|
|
||||||
border-radius: 6px;
|
|
||||||
font-size: 11px;
|
|
||||||
font-weight: 600;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.g-tag-brand {
|
|
||||||
background: #eff6ff;
|
|
||||||
color: #2563eb;
|
|
||||||
}
|
|
||||||
.g-tag-cat {
|
|
||||||
background: #fef3c7;
|
|
||||||
color: #b45309;
|
|
||||||
}
|
|
||||||
.g-tag-acc {
|
|
||||||
background: #fee2e2;
|
|
||||||
color: #dc2626;
|
|
||||||
}
|
|
||||||
.g-tag-on {
|
|
||||||
background: #d1fae5;
|
|
||||||
color: #10b981;
|
|
||||||
}
|
|
||||||
.g-tag-off {
|
|
||||||
background: #e5e7eb;
|
|
||||||
color: #9ca3af;
|
|
||||||
}
|
|
||||||
|
|
||||||
.g-ops {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.g-empty {
|
|
||||||
padding: 42px 16px;
|
|
||||||
text-align: center;
|
|
||||||
color: var(--g-text3);
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -4,24 +4,14 @@
|
|||||||
* 数据源保持自家后端:/duplicate-check-console(指标/店铺/撞款全集/分组统计) + /duplicate-check-ledger(台账分页) + /duplicate-check-export(Excel)。
|
* 数据源保持自家后端:/duplicate-check-console(指标/店铺/撞款全集/分组统计) + /duplicate-check-ledger(台账分页) + /duplicate-check-export(Excel)。
|
||||||
* 分组归属来自「店铺管理」真实店铺分组,本页只读展示,仅用于分组撞款范围切换。
|
* 分组归属来自「店铺管理」真实店铺分组,本页只读展示,仅用于分组撞款范围切换。
|
||||||
*/
|
*/
|
||||||
import { computed, onMounted, onUnmounted, reactive, ref, watch } from 'vue'
|
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||||
import type { DuplicateItem, DuplicateOccurrence, DuplicateMetrics, DuplicateShop } from './duplicate-model.ts'
|
import type { DuplicateItem, DuplicateOccurrence, DuplicateMetrics, DuplicateShop } from './duplicate-model.ts'
|
||||||
import { fetchDuplicateConsole, fetchDuplicateLedger, requestDuplicateExportBlob, type LedgerSortKey } from './duplicate-console-api.ts'
|
import { fetchDuplicateConsole, fetchDuplicateLedger, requestDuplicateExportBlob, type LedgerSortKey } from './duplicate-console-api.ts'
|
||||||
import {
|
import { aggregateDrawerRows, drawerSummaryOf, dupWithinGroup, indexShopGroups, type DrawerAggRow, type DrawerSummary, type ShopGroups } from './duplicate-console-logic.ts'
|
||||||
aggregateDrawerRows,
|
|
||||||
drawerSummaryOf,
|
|
||||||
indexShopGroups,
|
|
||||||
itemBrandOf,
|
|
||||||
type DrawerAggRow,
|
|
||||||
type DrawerSummary,
|
|
||||||
type ShopGroups,
|
|
||||||
} from './duplicate-console-logic.ts'
|
|
||||||
import { useDuplicateMatrix } from './duplicate-matrix-window.ts'
|
|
||||||
import type { DuplicateConsole, LedgerRow } from './duplicate-console-model.ts'
|
import type { DuplicateConsole, LedgerRow } from './duplicate-console-model.ts'
|
||||||
import { ASIN_COUNTRY_CODES, asinCountryLabel } from '../asin/asin-country.ts'
|
import { ASIN_COUNTRY_CODES, asinCountryLabel } from '../asin/asin-country.ts'
|
||||||
import { orderedPair } from '@/utils/datetime'
|
|
||||||
|
|
||||||
type Tab = 'dup' | 'ledger'
|
type Tab = 'dup' | 'ledger'
|
||||||
type Scope = 'global' | 'group'
|
type Scope = 'global' | 'group'
|
||||||
@@ -32,13 +22,6 @@ const loadError = ref('')
|
|||||||
const reanalyzing = ref(false)
|
const reanalyzing = ref(false)
|
||||||
|
|
||||||
const filter = reactive({ asin: '', shop: '', group: '', country: '', dateFrom: '', dateTo: '' })
|
const filter = reactive({ asin: '', shop: '', group: '', country: '', dateFrom: '', dateTo: '' })
|
||||||
/** min/max 挡不住手输,落值后把倒挂的起止交换回来。 */
|
|
||||||
function clampDatePair(): void {
|
|
||||||
const [s, e] = orderedPair(filter.dateFrom, filter.dateTo)
|
|
||||||
filter.dateFrom = s
|
|
||||||
filter.dateTo = e
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** 角色范围:超管可看全部分组店铺并可跨分组筛选;管理员数据已由后端裁剪到自己分组,无需分组筛选。 */
|
/** 角色范围:超管可看全部分组店铺并可跨分组筛选;管理员数据已由后端裁剪到自己分组,无需分组筛选。 */
|
||||||
const session = useAdminSessionStore()
|
const session = useAdminSessionStore()
|
||||||
@@ -82,8 +65,7 @@ function toast(msg: string) {
|
|||||||
const overview = computed(() => consoleData.value?.overview ?? null)
|
const overview = computed(() => consoleData.value?.overview ?? null)
|
||||||
const summary = computed<DuplicateMetrics | null>(() => overview.value?.summary ?? null)
|
const summary = computed<DuplicateMetrics | null>(() => overview.value?.summary ?? null)
|
||||||
const shops = computed(() => overview.value?.shops ?? [])
|
const shops = computed(() => overview.value?.shops ?? [])
|
||||||
/** 当前撞款行窗口:服务端按 page/page_size(+dup_group) 切好的一窗(B60),页面不再自切全集。 */
|
const dupItems = computed(() => consoleData.value?.dup ?? [])
|
||||||
const dupItems = computed<DuplicateItem[]>(() => consoleData.value?.dup ?? [])
|
|
||||||
const groupStats = computed(() => consoleData.value?.groups ?? [])
|
const groupStats = computed(() => consoleData.value?.groups ?? [])
|
||||||
|
|
||||||
const countryOptions = computed<string[]>(() => {
|
const countryOptions = computed<string[]>(() => {
|
||||||
@@ -128,33 +110,27 @@ function selectedGroupMembers(): string[] {
|
|||||||
|
|
||||||
const groupChips = computed(() => groupStats.value.filter((group) => group.shopCount >= 2))
|
const groupChips = computed(() => groupStats.value.filter((group) => group.shopCount >= 2))
|
||||||
|
|
||||||
const activeGroupStat = computed(() => groupStats.value.find((group) => group.name === selectedGroup.value) || null)
|
/** 当前撞款行集:全局=撞款全集;分组=组内成员撞款子集;均按 ASIN 升序(reference 台账顺序)。 */
|
||||||
/** 撞款行总数:服务端在本页 + 本范围(全局或所选分组)内未分页的计数,翻页控件与 KPI 共用。 */
|
const dupRows = computed<DuplicateItem[]>(() => {
|
||||||
const totalDupCount = computed(() => consoleData.value?.totalDup ?? 0)
|
const rows = scope.value === 'global' ? dupItems.value : dupWithinGroup(dupItems.value, selectedGroupMembers())
|
||||||
|
return [...rows].sort((a, b) => a.asin.localeCompare(b.asin))
|
||||||
/** 撞款矩阵的行窗 + 列窗 + 格子视图(B60):状态与算法在 `duplicate-matrix-window.ts`,翻页动作交回这里。 */
|
|
||||||
const {
|
|
||||||
matrixPage,
|
|
||||||
matrixPageSize,
|
|
||||||
columnPage,
|
|
||||||
columnWindowTotal,
|
|
||||||
matrixAllColumns,
|
|
||||||
matrixShops,
|
|
||||||
matrixView,
|
|
||||||
matrixHint,
|
|
||||||
goMatrixPage,
|
|
||||||
changeMatrixSize,
|
|
||||||
goColumnPage,
|
|
||||||
resetMatrixWindows,
|
|
||||||
} = useDuplicateMatrix({
|
|
||||||
rows: dupItems,
|
|
||||||
groupMembers: computed(() => selectedGroupMembers()),
|
|
||||||
groupScoped: computed(() => scope.value === 'group'),
|
|
||||||
selectedGroup,
|
|
||||||
reload: () => void loadConsole(),
|
|
||||||
dataVersion: consoleData,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** 矩阵列:分组范围=该组成员店;全店=全部可见店铺(按上架量降序)。 */
|
||||||
|
const matrixShops = computed<string[]>(() => {
|
||||||
|
if (scope.value === 'group') return selectedGroupMembers()
|
||||||
|
return orderedShops.value.map((shop) => shop.shopName)
|
||||||
|
})
|
||||||
|
|
||||||
|
const activeGroupStat = computed(() => groupStats.value.find((group) => group.name === selectedGroup.value) || null)
|
||||||
|
/** 撞款 Tab 计数:全店范围取后端权威 total_dup(防后端截断计数偏小);分组范围取组内子集长度。 */
|
||||||
|
const totalDupCount = computed(() => (scope.value === 'global' ? (consoleData.value?.totalDup ?? dupRows.value.length) : dupRows.value.length))
|
||||||
|
|
||||||
|
function itemBrand(item: DuplicateItem): string {
|
||||||
|
for (const occ of item.occurrences || []) if (occ.brand) return occ.brand
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---- 撞款视图分页(分布/矩阵/撞款详情/抽屉明细;10/20/50/100 可选) ----
|
// ---- 撞款视图分页(分布/矩阵/撞款详情/抽屉明细;10/20/50/100 可选) ----
|
||||||
const distCount = computed(() => storeDistribution.value.list.length)
|
const distCount = computed(() => storeDistribution.value.list.length)
|
||||||
@@ -163,7 +139,16 @@ const distPageSize = ref(10)
|
|||||||
const pagedDistBars = computed(() =>
|
const pagedDistBars = computed(() =>
|
||||||
storeDistribution.value.list.slice((distPage.value - 1) * distPageSize.value, distPage.value * distPageSize.value),
|
storeDistribution.value.list.slice((distPage.value - 1) * distPageSize.value, distPage.value * distPageSize.value),
|
||||||
)
|
)
|
||||||
|
const matrixPage = ref(1)
|
||||||
|
const matrixPageSize = ref(10)
|
||||||
|
const matrixRows = computed(() =>
|
||||||
|
dupRows.value.slice((matrixPage.value - 1) * matrixPageSize.value, matrixPage.value * matrixPageSize.value),
|
||||||
|
)
|
||||||
|
const dupCardPage = ref(1)
|
||||||
|
const dupCardPageSize = ref(10)
|
||||||
|
const dupCardRows = computed(() =>
|
||||||
|
dupRows.value.slice((dupCardPage.value - 1) * dupCardPageSize.value, dupCardPage.value * dupCardPageSize.value),
|
||||||
|
)
|
||||||
const drawerPage = ref(1)
|
const drawerPage = ref(1)
|
||||||
const drawerPageSize = ref(10)
|
const drawerPageSize = ref(10)
|
||||||
const drawerRows = computed(() =>
|
const drawerRows = computed(() =>
|
||||||
@@ -175,15 +160,46 @@ const groupStatsPageSize = ref(10)
|
|||||||
const pagedGroupStats = computed(() =>
|
const pagedGroupStats = computed(() =>
|
||||||
groupStats.value.slice((groupStatsPage.value - 1) * groupStatsPageSize.value, groupStatsPage.value * groupStatsPageSize.value),
|
groupStats.value.slice((groupStatsPage.value - 1) * groupStatsPageSize.value, groupStatsPage.value * groupStatsPageSize.value),
|
||||||
)
|
)
|
||||||
watch([drawerOccurrences, groupStats], () => {
|
watch([dupRows, drawerOccurrences, groupStats], () => {
|
||||||
|
matrixPage.value = Math.min(matrixPage.value, Math.max(1, Math.ceil(dupRows.value.length / matrixPageSize.value)))
|
||||||
|
dupCardPage.value = Math.min(dupCardPage.value, Math.max(1, Math.ceil(dupRows.value.length / dupCardPageSize.value)))
|
||||||
drawerPage.value = 1
|
drawerPage.value = 1
|
||||||
groupStatsPage.value = Math.min(groupStatsPage.value, Math.max(1, Math.ceil(groupStats.value.length / groupStatsPageSize.value)))
|
groupStatsPage.value = Math.min(groupStatsPage.value, Math.max(1, Math.ceil(groupStats.value.length / groupStatsPageSize.value)))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const matrixHint = computed(() =>
|
||||||
|
scope.value === 'global'
|
||||||
|
? '行 = 全店撞款ASIN,列 = 全部店铺;有数字表示该店在售此 ASIN,点击行可看上架时间明细'
|
||||||
|
: selectedGroup.value
|
||||||
|
? `行 = 分组「${selectedGroup.value}」内的撞款ASIN,列 = 该分组店铺;有数字表示组内该店在售此 ASIN`
|
||||||
|
: '行 = 分组内撞款ASIN,列 = 该分组店铺;有数字表示组内该店在售此 ASIN',
|
||||||
|
)
|
||||||
|
|
||||||
/* ----- 矩阵单元格辅助 ----- */
|
/* ----- 矩阵单元格辅助 ----- */
|
||||||
function shopKey(name: string): string {
|
function shopKey(name: string): string {
|
||||||
return (name || '').trim().toLowerCase()
|
return (name || '').trim().toLowerCase()
|
||||||
}
|
}
|
||||||
|
function cellOccurrences(item: DuplicateItem, shop: string): DuplicateOccurrence[] {
|
||||||
|
const key = shopKey(shop)
|
||||||
|
return (item.occurrences || []).filter((occ) => shopKey(occ.shopName) === key)
|
||||||
|
}
|
||||||
|
function cellCount(item: DuplicateItem, shop: string): number {
|
||||||
|
return cellOccurrences(item, shop).length
|
||||||
|
}
|
||||||
|
function cellCountryDots(item: DuplicateItem, shop: string): string[] {
|
||||||
|
const codes = new Set<string>()
|
||||||
|
for (const occ of cellOccurrences(item, shop)) if (occ.country) codes.add(occ.country.toUpperCase())
|
||||||
|
return [...codes]
|
||||||
|
}
|
||||||
|
function cellCountryCount(item: DuplicateItem, shop: string, code: string): number {
|
||||||
|
return cellOccurrences(item, shop).filter((occ) => (occ.country || '').toUpperCase() === code).length
|
||||||
|
}
|
||||||
|
function cellTitle(item: DuplicateItem, shop: string): string {
|
||||||
|
const count = cellCount(item, shop)
|
||||||
|
if (!count) return `${shop} 无此 ASIN`
|
||||||
|
const sites = cellCountryDots(item, shop).map((code) => `${asinCountryLabel(code)} ${cellCountryCount(item, shop, code)}条`).join('、')
|
||||||
|
return `${shop} 在售 ${count} 条 · ${sites}`
|
||||||
|
}
|
||||||
|
|
||||||
function activeFilterParams() {
|
function activeFilterParams() {
|
||||||
return { asin: filter.asin.trim(), shopName: filter.shop.trim(), group: filter.group.trim(), country: filter.country, site: '', dateFrom: filter.dateFrom, dateTo: filter.dateTo }
|
return { asin: filter.asin.trim(), shopName: filter.shop.trim(), group: filter.group.trim(), country: filter.country, site: '', dateFrom: filter.dateFrom, dateTo: filter.dateTo }
|
||||||
@@ -193,13 +209,7 @@ async function loadConsole() {
|
|||||||
loading.value = true
|
loading.value = true
|
||||||
loadError.value = ''
|
loadError.value = ''
|
||||||
try {
|
try {
|
||||||
consoleData.value = await fetchDuplicateConsole(
|
consoleData.value = await fetchDuplicateConsole({ view: '', ...activeFilterParams() }, companyTab.requestCompanyId)
|
||||||
{ view: '', ...activeFilterParams() },
|
|
||||||
companyTab.requestCompanyId,
|
|
||||||
matrixPage.value,
|
|
||||||
matrixPageSize.value,
|
|
||||||
scope.value === 'group' ? selectedGroup.value : '',
|
|
||||||
)
|
|
||||||
shopGroups.value = indexShopGroups(orderedShops.value)
|
shopGroups.value = indexShopGroups(orderedShops.value)
|
||||||
if (groupStats.value.length && !groupStats.value.some((group) => group.name === selectedGroup.value)) {
|
if (groupStats.value.length && !groupStats.value.some((group) => group.name === selectedGroup.value)) {
|
||||||
selectedGroup.value = groupChips.value[0] ? groupChips.value[0].name : ''
|
selectedGroup.value = groupChips.value[0] ? groupChips.value[0].name : ''
|
||||||
@@ -238,6 +248,10 @@ async function loadLedger(page: number, resetSort = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function applyQuery() {
|
function applyQuery() {
|
||||||
|
if (filter.dateFrom && filter.dateTo && filter.dateFrom > filter.dateTo) {
|
||||||
|
toast('开始日期不能晚于结束日期')
|
||||||
|
return
|
||||||
|
}
|
||||||
loadConsole()
|
loadConsole()
|
||||||
if (activeTab.value === 'ledger') loadLedger(1)
|
if (activeTab.value === 'ledger') loadLedger(1)
|
||||||
}
|
}
|
||||||
@@ -252,7 +266,6 @@ function resetQuery() {
|
|||||||
scope.value = 'global'
|
scope.value = 'global'
|
||||||
selectedGroup.value = ''
|
selectedGroup.value = ''
|
||||||
activeTab.value = 'dup'
|
activeTab.value = 'dup'
|
||||||
resetMatrixWindows()
|
|
||||||
applyQuery()
|
applyQuery()
|
||||||
toast('筛选已重置')
|
toast('筛选已重置')
|
||||||
}
|
}
|
||||||
@@ -263,21 +276,8 @@ function switchTab(tab: Tab) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function switchScope(next: Scope) {
|
function switchScope(next: Scope) {
|
||||||
if (scope.value === next) return
|
|
||||||
scope.value = next
|
scope.value = next
|
||||||
if (next === 'group' && !selectedGroup.value && groupChips.value.length) selectedGroup.value = groupChips.value[0].name
|
if (next === 'group' && !selectedGroup.value && groupChips.value.length) selectedGroup.value = groupChips.value[0].name
|
||||||
// 行范围换了(全局 ↔ 组内),服务端裁出来的那一窗也就换了 ⇒ 重新请一窗。
|
|
||||||
resetMatrixWindows()
|
|
||||||
void loadConsole()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 分组 chip:选中即换行范围,与 switchScope 同一条出口(不再在客户端重裁一遍全集)。 */
|
|
||||||
function selectGroup(name: string) {
|
|
||||||
if (selectedGroup.value === name && scope.value === 'group') return
|
|
||||||
scope.value = 'group'
|
|
||||||
selectedGroup.value = name
|
|
||||||
resetMatrixWindows()
|
|
||||||
void loadConsole()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function reAnalyze() {
|
async function reAnalyze() {
|
||||||
@@ -334,7 +334,7 @@ function openDrawer(asin: string, brand: string, dupFlag: boolean, occurrences:
|
|||||||
}
|
}
|
||||||
|
|
||||||
function openDupDrawer(item: DuplicateItem) {
|
function openDupDrawer(item: DuplicateItem) {
|
||||||
openDrawer(item.asin, itemBrandOf(item), item.shopCount >= 2, item.occurrences)
|
openDrawer(item.asin, itemBrand(item), item.shopCount >= 2, item.occurrences)
|
||||||
}
|
}
|
||||||
|
|
||||||
function openLedgerDrawer(row: LedgerRow) {
|
function openLedgerDrawer(row: LedgerRow) {
|
||||||
@@ -410,11 +410,6 @@ function siteColor(code: string): string {
|
|||||||
// loadConsole 的重挑分支(groupStats 为空时不触发)里留着一个不属于本公司的 selectedGroup。
|
// loadConsole 的重挑分支(groupStats 为空时不触发)里留着一个不属于本公司的 selectedGroup。
|
||||||
watch(() => companyTab.activeId, () => { filter.shop = ''; filter.group = ''; selectedGroup.value = ''; scope.value = 'global'; void loadConsole(); void loadLedger(1) })
|
watch(() => companyTab.activeId, () => { filter.shop = ''; filter.group = ''; selectedGroup.value = ''; scope.value = 'global'; void loadConsole(); void loadLedger(1) })
|
||||||
|
|
||||||
// 卸载时收掉 toast 的 2.4s 收尾定时器:否则离开本页后它还会去摸一个已经不存在的节点。
|
|
||||||
onUnmounted(() => {
|
|
||||||
window.clearTimeout(toastTimer)
|
|
||||||
})
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadConsole()
|
loadConsole()
|
||||||
// 台账 Tab 计数打开即显示:挂载时预取第一页拿 total(对齐 reference 渲染即见台账条数)。
|
// 台账 Tab 计数打开即显示:挂载时预取第一页拿 total(对齐 reference 渲染即见台账条数)。
|
||||||
@@ -433,11 +428,10 @@ onMounted(() => {
|
|||||||
|
|
||||||
<div v-if="loadError" class="load-banner">
|
<div v-if="loadError" class="load-banner">
|
||||||
<span>{{ loadError }}</span>
|
<span>{{ loadError }}</span>
|
||||||
<button class="btn btn-ghost btn-sm" type="button" @click="loadConsole">重试</button>
|
|
||||||
<button class="btn btn-ghost btn-sm" type="button" @click="loadError = ''">知道了</button>
|
<button class="btn btn-ghost btn-sm" type="button" @click="loadError = ''">知道了</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 筛选条件(撞款/台账专用) -->
|
<!-- 筛选条件 -->
|
||||||
<section class="card filter">
|
<section class="card filter">
|
||||||
<div class="filter-title">筛选条件</div>
|
<div class="filter-title">筛选条件</div>
|
||||||
<div class="filter-row">
|
<div class="filter-row">
|
||||||
@@ -468,11 +462,11 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
<div class="f-group">
|
<div class="f-group">
|
||||||
<label>上架时间开始</label>
|
<label>上架时间开始</label>
|
||||||
<input type="date" v-model="filter.dateFrom" :max="filter.dateTo" @change="clampDatePair" />
|
<input type="date" v-model="filter.dateFrom" />
|
||||||
</div>
|
</div>
|
||||||
<div class="f-group">
|
<div class="f-group">
|
||||||
<label>上架时间结束</label>
|
<label>上架时间结束</label>
|
||||||
<input type="date" v-model="filter.dateTo" :min="filter.dateFrom" @change="clampDatePair" />
|
<input type="date" v-model="filter.dateTo" />
|
||||||
</div>
|
</div>
|
||||||
<div class="f-group">
|
<div class="f-group">
|
||||||
<label> </label>
|
<label> </label>
|
||||||
@@ -489,8 +483,9 @@ onMounted(() => {
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<div v-loading="loading" class="dup-body-wrap">
|
<div v-loading="loading" class="dup-body-wrap">
|
||||||
|
<template v-if="consoleData">
|
||||||
<!-- KPI 统计 -->
|
<!-- KPI 统计 -->
|
||||||
<section v-if="consoleData" class="kpis">
|
<section class="kpis">
|
||||||
<div v-for="kpi in kpis" :key="kpi.label" class="kpi" :class="kpi.tone">
|
<div v-for="kpi in kpis" :key="kpi.label" class="kpi" :class="kpi.tone">
|
||||||
<div class="k-label"><span class="k-dot"></span>{{ kpi.label }}</div>
|
<div class="k-label"><span class="k-dot"></span>{{ kpi.label }}</div>
|
||||||
<div class="k-value">{{ kpi.value }}</div>
|
<div class="k-value">{{ kpi.value }}</div>
|
||||||
@@ -499,7 +494,7 @@ onMounted(() => {
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- 店铺上架分布 -->
|
<!-- 店铺上架分布 -->
|
||||||
<section v-if="consoleData" class="card store-strip">
|
<section class="card store-strip">
|
||||||
<div class="strip-head">
|
<div class="strip-head">
|
||||||
<span class="strip-title">店铺上架分布</span>
|
<span class="strip-title">店铺上架分布</span>
|
||||||
<span class="strip-note">各店铺在本批站点中的上架记录量(含重复扫描)</span>
|
<span class="strip-note">各店铺在本批站点中的上架记录量(含重复扫描)</span>
|
||||||
@@ -541,7 +536,7 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- ============ 撞款监控 ============ -->
|
<!-- ============ 撞款监控 ============ -->
|
||||||
<template v-if="consoleData && activeTab === 'dup'">
|
<template v-if="activeTab === 'dup'">
|
||||||
<div v-if="isSuper" class="scope-bar">
|
<div v-if="isSuper" class="scope-bar">
|
||||||
<div class="seg">
|
<div class="seg">
|
||||||
<button class="seg-btn" :class="{ active: scope === 'global' }" type="button" @click="switchScope('global')">全店撞款</button>
|
<button class="seg-btn" :class="{ active: scope === 'global' }" type="button" @click="switchScope('global')">全店撞款</button>
|
||||||
@@ -549,7 +544,7 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
<div v-if="scope === 'group'" class="group-chips">
|
<div v-if="scope === 'group'" class="group-chips">
|
||||||
<template v-if="groupChips.length">
|
<template v-if="groupChips.length">
|
||||||
<button v-for="group in groupChips" :key="group.name" type="button" class="g-chip" :class="{ active: selectedGroup === group.name, dup: group.dupCount > 0 }" @click="selectGroup(group.name)">
|
<button v-for="group in groupChips" :key="group.name" type="button" class="g-chip" :class="{ active: selectedGroup === group.name, dup: group.dupCount > 0 }" @click="selectedGroup = group.name">
|
||||||
{{ group.name }} <span class="g-count">{{ group.shopCount }}店 · {{ group.dupCount }}撞款</span>
|
{{ group.name }} <span class="g-count">{{ group.shopCount }}店 · {{ group.dupCount }}撞款</span>
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
@@ -564,16 +559,9 @@ onMounted(() => {
|
|||||||
<div class="gs-item" :class="{ warn: activeGroupStat.dupCount > 0 }"><div class="gs-v">{{ activeGroupStat.dupCount }}</div><div class="gs-l">组内撞款ASIN</div></div>
|
<div class="gs-item" :class="{ warn: activeGroupStat.dupCount > 0 }"><div class="gs-v">{{ activeGroupStat.dupCount }}</div><div class="gs-l">组内撞款ASIN</div></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="section-title">
|
<div class="section-title">撞款覆盖矩阵 <span class="hint">{{ matrixHint }}</span></div>
|
||||||
撞款覆盖矩阵 <span class="hint">{{ matrixHint }}</span>
|
|
||||||
<span v-if="columnWindowTotal > 1" class="col-window">
|
|
||||||
<button type="button" class="link-btn" :disabled="columnPage <= 1" @click="goColumnPage(-1)">‹ 上一窗列</button>
|
|
||||||
列 {{ columnPage }}/{{ columnWindowTotal }}(共 {{ matrixAllColumns.length }} 列)
|
|
||||||
<button type="button" class="link-btn" :disabled="columnPage >= columnWindowTotal" @click="goColumnPage(1)">下一窗列 ›</button>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div class="matrix-wrap">
|
<div class="matrix-wrap">
|
||||||
<table v-if="dupItems.length" class="matrix">
|
<table v-if="dupRows.length" class="matrix">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>ASIN</th>
|
<th>ASIN</th>
|
||||||
@@ -582,13 +570,13 @@ onMounted(() => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="row in matrixView" :key="row.asin" @click="openDupDrawer(row.item)">
|
<tr v-for="item in matrixRows" :key="item.asin" @click="openDupDrawer(item)">
|
||||||
<td><span class="asin-code">{{ row.asin }}</span></td>
|
<td><span class="asin-code">{{ item.asin }}</span></td>
|
||||||
<td><span class="m-brand">{{ row.brand }}</span></td>
|
<td><span class="m-brand">{{ itemBrand(item) || '—' }}</span></td>
|
||||||
<td v-for="(cell, index) in row.cells" :key="matrixShops[index]" style="text-align:center">
|
<td v-for="shop in matrixShops" :key="shop" style="text-align:center">
|
||||||
<div class="m-cell" :class="{ empty: cell.count === 0 }" :title="cell.title">
|
<div class="m-cell" :class="{ empty: cellCount(item, shop) === 0 }" :title="cellTitle(item, shop)">
|
||||||
{{ cell.count || '' }}
|
{{ cellCount(item, shop) || '' }}
|
||||||
<span class="dots"><span v-for="code in cell.dots" :key="code" class="m-dot" :style="{ background: siteColor(code) }"></span></span>
|
<span class="dots"><span v-for="code in cellCountryDots(item, shop)" :key="code" class="m-dot" :style="{ background: siteColor(code) }"></span></span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -599,15 +587,15 @@ onMounted(() => {
|
|||||||
调整筛选条件或切换到其他分组查看
|
调整筛选条件或切换到其他分组查看
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<OldPagination :total="totalDupCount" :page="matrixPage" :page-size="matrixPageSize" @change="goMatrixPage" @size-change="changeMatrixSize" />
|
<OldPagination :total="dupRows.length" :page="matrixPage" :page-size="matrixPageSize" @change="matrixPage = $event" @size-change="(s: number) => { matrixPageSize = s; matrixPage = 1 }" />
|
||||||
|
|
||||||
<div class="section-title" style="margin-top:24px">撞款详情 <span class="hint">同一 ASIN 在多家店铺的上架时间明细</span></div>
|
<div class="section-title" style="margin-top:24px">撞款详情 <span class="hint">同一 ASIN 在多家店铺的上架时间明细</span></div>
|
||||||
<div v-if="dupItems.length" class="dup-grid">
|
<div v-if="dupRows.length" class="dup-grid">
|
||||||
<div v-for="item in dupItems" :key="item.asin" class="dup-card">
|
<div v-for="item in dupCardRows" :key="item.asin" class="dup-card">
|
||||||
<div class="dup-head">
|
<div class="dup-head">
|
||||||
<span class="asin-code">{{ item.asin }}</span>
|
<span class="asin-code">{{ item.asin }}</span>
|
||||||
<span class="badge dup">{{ item.shopCount }}店在售</span>
|
<span class="badge dup">{{ item.shopCount }}店在售</span>
|
||||||
<span class="d-brand">{{ itemBrandOf(item) || '未知品牌' }}</span>
|
<span class="d-brand">{{ itemBrand(item) || '未知品牌' }}</span>
|
||||||
<button class="link-btn" type="button" @click="openDupDrawer(item)">查看明细</button>
|
<button class="link-btn" type="button" @click="openDupDrawer(item)">查看明细</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="dup-body">
|
<div class="dup-body">
|
||||||
@@ -623,12 +611,12 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="dup-empty">当前范围下没有撞款ASIN</div>
|
<div v-else class="dup-empty">当前范围下没有撞款ASIN</div>
|
||||||
<OldPagination :total="totalDupCount" :page="matrixPage" :page-size="matrixPageSize" @change="goMatrixPage" @size-change="changeMatrixSize" />
|
<OldPagination :total="dupRows.length" :page="dupCardPage" :page-size="dupCardPageSize" @change="dupCardPage = $event" @size-change="(s: number) => { dupCardPageSize = s; dupCardPage = 1 }" />
|
||||||
<div class="dup-total">共 <b>{{ dupItems.length }}</b> 条{{ scope === 'group' && selectedGroup ? `分组「${selectedGroup}」组内撞款ASIN` : '全店撞款ASIN' }}</div>
|
<div class="dup-total">共 <b>{{ dupRows.length }}</b> 条{{ scope === 'group' && selectedGroup ? `分组「${selectedGroup}」组内撞款ASIN` : '全店撞款ASIN' }}</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- ============ 全部ASIN台账 ============ -->
|
<!-- ============ 全部ASIN台账 ============ -->
|
||||||
<template v-else-if="consoleData">
|
<template v-else>
|
||||||
<div class="table-wrap" v-loading="ledgerLoading">
|
<div class="table-wrap" v-loading="ledgerLoading">
|
||||||
<table v-if="ledgerItems.length" class="ledger">
|
<table v-if="ledgerItems.length" class="ledger">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -663,8 +651,9 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
<OldPagination v-if="ledgerTotal" :total="ledgerTotal" :page="ledgerPage" :page-size="ledgerPageSize" @change="goPage" @size-change="changeLedgerSize" />
|
<OldPagination v-if="ledgerTotal" :total="ledgerTotal" :page="ledgerPage" :page-size="ledgerPageSize" @change="goPage" @size-change="changeLedgerSize" />
|
||||||
</template>
|
</template>
|
||||||
|
</template>
|
||||||
|
|
||||||
<div v-if="!consoleData && !loadError" class="card empty-state">
|
<div v-else-if="!loadError" class="card empty-state">
|
||||||
<div class="e-title">暂无扫描结果</div>
|
<div class="e-title">暂无扫描结果</div>
|
||||||
请点击右上角「重新分析」触发撞款扫描
|
请点击右上角「重新分析」触发撞款扫描
|
||||||
</div>
|
</div>
|
||||||
@@ -888,9 +877,6 @@ onMounted(() => {
|
|||||||
.dup-ref .section-title { font-size: 14px; font-weight: 700; display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
|
.dup-ref .section-title { font-size: 14px; font-weight: 700; display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
|
||||||
.dup-ref .section-title .hint { font-size: 11px; font-weight: 400; color: var(--text3); }
|
.dup-ref .section-title .hint { font-size: 11px; font-weight: 400; color: var(--text3); }
|
||||||
.dup-ref .matrix-wrap { overflow-x: auto; overflow-y: auto; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); max-height: 480px; }
|
.dup-ref .matrix-wrap { overflow-x: auto; overflow-y: auto; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); max-height: 480px; }
|
||||||
/* 列窗口控件:与 section-title 同行,只在看得到第二窗列时出现。 */
|
|
||||||
.dup-ref .col-window { margin-left: 12px; display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text2); }
|
|
||||||
.dup-ref .col-window .link-btn:disabled { color: var(--text3); cursor: not-allowed; }
|
|
||||||
.dup-ref table.matrix { border-collapse: separate; border-spacing: 0; width: 100%; background: var(--surface); }
|
.dup-ref table.matrix { border-collapse: separate; border-spacing: 0; width: 100%; background: var(--surface); }
|
||||||
.dup-ref table.matrix th {
|
.dup-ref table.matrix th {
|
||||||
background: #F7F9FC; color: var(--text2); font-size: 12px; font-weight: 600; padding: 10px 12px;
|
background: #F7F9FC; color: var(--text2); font-size: 12px; font-weight: 600; padding: 10px 12px;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { formatDateTime, orderedPair } from '@/utils/datetime'
|
import { formatDateTime } from '@/utils/datetime'
|
||||||
import { userNotice } from '@/api/user-notice'
|
|
||||||
/** 视频任务记录页 · 像素复刻旧版 admin.html panel-image-video-tasks(自绘:form-box 筛选[用户名/提交起止+查询/重置] + panel-box toolbar[全选/批量下载/权限配置/汇总] + 任务卡片网格 + 旧式分页)。
|
/** 视频任务记录页 · 像素复刻旧版 admin.html panel-image-video-tasks(自绘:form-box 筛选[用户名/提交起止+查询/重置] + panel-box toolbar[全选/批量下载/权限配置/汇总] + 任务卡片网格 + 旧式分页)。
|
||||||
* script 逻辑沿用现有 Vue 实现(批量打包/明细抽屉/权限授权)。 */
|
* script 逻辑沿用现有 Vue 实现(批量打包/明细抽屉/权限授权)。 */
|
||||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||||
@@ -21,13 +20,10 @@ import { imageVideoDownloadFilename, videoKeysOf } from './image-video-view.ts'
|
|||||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||||
import OldPagination from '@/components/OldPagination.vue'
|
import OldPagination from '@/components/OldPagination.vue'
|
||||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
|
||||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
|
||||||
|
|
||||||
const session = useAdminSessionStore()
|
const session = useAdminSessionStore()
|
||||||
const companyTab = useCompanyTabStore()
|
const companyTab = useCompanyTabStore()
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const loadFailure = ref('')
|
|
||||||
const tasks = ref<ImageVideoRow[]>([])
|
const tasks = ref<ImageVideoRow[]>([])
|
||||||
const totalTasks = ref(0)
|
const totalTasks = ref(0)
|
||||||
const page = ref(1)
|
const page = ref(1)
|
||||||
@@ -35,12 +31,6 @@ const pageSize = ref(10)
|
|||||||
const jumpPage = ref('')
|
const jumpPage = ref('')
|
||||||
const totalPages = computed(() => Math.max(1, Math.ceil(totalTasks.value / pageSize.value)))
|
const totalPages = computed(() => Math.max(1, Math.ceil(totalTasks.value / pageSize.value)))
|
||||||
|
|
||||||
/** min/max 挡不住手输,落值后把倒挂的起止交换回来。 */
|
|
||||||
function clampDatePair(): void {
|
|
||||||
const [s, e] = orderedPair(filter.dateRange[0], filter.dateRange[1])
|
|
||||||
filter.dateRange = [s, e]
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 提交时间初值故意留空:默认锁当天会让首屏只剩今天提交的任务(用户 2026-10-04 定案),见 date-filter-default-today 护栏的 EXEMPT。 */
|
/** 提交时间初值故意留空:默认锁当天会让首屏只剩今天提交的任务(用户 2026-10-04 定案),见 date-filter-default-today 护栏的 EXEMPT。 */
|
||||||
const filter = reactive<ImageVideoFilter & { dateRange: string[] }>({
|
const filter = reactive<ImageVideoFilter & { dateRange: string[] }>({
|
||||||
...createImageVideoFilter(),
|
...createImageVideoFilter(),
|
||||||
@@ -125,15 +115,13 @@ function toFilter(): ImageVideoFilter {
|
|||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
loadFailure.value = ''
|
|
||||||
try {
|
try {
|
||||||
const result = await fetchImageVideoTasks(toFilter(), page.value, pageSize.value, companyTab.requestCompanyId)
|
const result = await fetchImageVideoTasks(toFilter(), page.value, pageSize.value, companyTab.requestCompanyId)
|
||||||
tasks.value = result.items
|
tasks.value = result.items
|
||||||
totalTasks.value = result.total
|
totalTasks.value = result.total
|
||||||
page.value = result.page
|
page.value = result.page
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loadFailure.value = error instanceof Error ? error.message : '视频任务加载失败'
|
ElMessage.error(error instanceof Error ? error.message : '视频任务加载失败')
|
||||||
showAdminFeedback(loadFailure.value, 'error')
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
@@ -206,7 +194,7 @@ async function openDetail(task: ImageVideoRow) {
|
|||||||
try {
|
try {
|
||||||
detail.value = await fetchImageVideoTaskDetail(task.taskId)
|
detail.value = await fetchImageVideoTaskDetail(task.taskId)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '详情加载失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '详情加载失败')
|
||||||
detailVisible.value = false
|
detailVisible.value = false
|
||||||
} finally {
|
} finally {
|
||||||
detailLoading.value = false
|
detailLoading.value = false
|
||||||
@@ -223,7 +211,7 @@ async function downloadVideo(task: ImageVideoRow, index: number, video: ImageVid
|
|||||||
} catch {
|
} catch {
|
||||||
// 打包失败降级:直接打开该视频地址以便下载。
|
// 打包失败降级:直接打开该视频地址以便下载。
|
||||||
if (video.displayUrl) window.open(video.displayUrl, '_blank')
|
if (video.displayUrl) window.open(video.displayUrl, '_blank')
|
||||||
else showAdminFeedback('视频下载失败', 'error')
|
else ElMessage.error('视频下载失败')
|
||||||
} finally {
|
} finally {
|
||||||
downloadingKey.value = ''
|
downloadingKey.value = ''
|
||||||
}
|
}
|
||||||
@@ -242,7 +230,7 @@ async function downloadBatch() {
|
|||||||
const note = errorCount ? `,${errorCount} 个失败` : ''
|
const note = errorCount ? `,${errorCount} 个失败` : ''
|
||||||
ElMessage.success(`正在打包 ${fileCount ?? keys.length} 个视频${note}`)
|
ElMessage.success(`正在打包 ${fileCount ?? keys.length} 个视频${note}`)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '批量下载失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '批量下载失败')
|
||||||
} finally {
|
} finally {
|
||||||
downloading.value = false
|
downloading.value = false
|
||||||
}
|
}
|
||||||
@@ -274,7 +262,7 @@ async function openPermission() {
|
|||||||
permPage.value = 1
|
permPage.value = 1
|
||||||
permissionVisible.value = true
|
permissionVisible.value = true
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '权限用户加载失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '权限用户加载失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,7 +279,7 @@ async function savePermission() {
|
|||||||
ElMessage.success('保存成功')
|
ElMessage.success('保存成功')
|
||||||
permissionVisible.value = false
|
permissionVisible.value = false
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showAdminFeedback(error instanceof Error ? error.message : '保存失败', 'error')
|
ElMessage.error(error instanceof Error ? error.message : '保存失败')
|
||||||
} finally {
|
} finally {
|
||||||
permissionSaving.value = false
|
permissionSaving.value = false
|
||||||
}
|
}
|
||||||
@@ -321,11 +309,11 @@ onMounted(load)
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group" style="min-width: 176px">
|
<div class="form-group" style="min-width: 176px">
|
||||||
<label>提交开始</label>
|
<label>提交开始</label>
|
||||||
<input v-model="filter.dateRange[0]" type="datetime-local" :max="filter.dateRange[1]" @change="clampDatePair" />
|
<input v-model="filter.dateRange[0]" type="datetime-local" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" style="min-width: 176px">
|
<div class="form-group" style="min-width: 176px">
|
||||||
<label>提交结束</label>
|
<label>提交结束</label>
|
||||||
<input v-model="filter.dateRange[1]" type="datetime-local" :min="filter.dateRange[0]" @change="clampDatePair" />
|
<input v-model="filter.dateRange[1]" type="datetime-local" />
|
||||||
</div>
|
</div>
|
||||||
<button class="btn" type="button" @click="apply">查询</button>
|
<button class="btn" type="button" @click="apply">查询</button>
|
||||||
<button class="btn btn-secondary" type="button" @click="reset">重置</button>
|
<button class="btn btn-secondary" type="button" @click="reset">重置</button>
|
||||||
@@ -333,7 +321,6 @@ onMounted(load)
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="panel-box iv-panel">
|
<section class="panel-box iv-panel">
|
||||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
|
||||||
<div class="iv-toolbar">
|
<div class="iv-toolbar">
|
||||||
<div class="iv-toolbar-main">
|
<div class="iv-toolbar-main">
|
||||||
<button v-if="session.isSuperAdmin" class="btn btn-secondary" type="button" @click="openPermission">权限配置</button>
|
<button v-if="session.isSuperAdmin" class="btn btn-secondary" type="button" @click="openPermission">权限配置</button>
|
||||||
@@ -407,7 +394,7 @@ onMounted(load)
|
|||||||
<el-descriptions-item label="提交时间">{{ formatDateTime(detail.submittedAt) }}</el-descriptions-item>
|
<el-descriptions-item label="提交时间">{{ formatDateTime(detail.submittedAt) }}</el-descriptions-item>
|
||||||
<el-descriptions-item label="生成时间">{{ formatDateTime(imageVideoGeneratedAt(detail)) }}</el-descriptions-item>
|
<el-descriptions-item label="生成时间">{{ formatDateTime(imageVideoGeneratedAt(detail)) }}</el-descriptions-item>
|
||||||
<el-descriptions-item label="执行ID">{{ detail.cozeExecuteId || '—' }}</el-descriptions-item>
|
<el-descriptions-item label="执行ID">{{ detail.cozeExecuteId || '—' }}</el-descriptions-item>
|
||||||
<el-descriptions-item label="错误">{{ userNotice(detail.errorMessage, '—') }}</el-descriptions-item>
|
<el-descriptions-item label="错误">{{ detail.errorMessage || '—' }}</el-descriptions-item>
|
||||||
</el-descriptions>
|
</el-descriptions>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,545 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
/**
|
|
||||||
* 关键词使用记录(独立菜单 admin_keyword_usage):只读展示 keyword_usage / keyword_add_log /
|
|
||||||
* keyword_delete_log,按公司 tab 取数。口径对齐独立小网页后台 v1.2.6g。
|
|
||||||
*/
|
|
||||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
|
||||||
import { formatDateTime } from '@/utils/datetime'
|
|
||||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
|
||||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
|
||||||
import { actionableErrorText } from '@/components/admin-feedback'
|
|
||||||
import OldPagination from '@/components/OldPagination.vue'
|
|
||||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
|
||||||
import { createLatestRequestGate } from '@/utils/latest-request'
|
|
||||||
import {
|
|
||||||
KEYWORD_USAGE_PAGE_SIZE,
|
|
||||||
KEYWORD_USAGE_SCENES,
|
|
||||||
createKeywordUsageFilter,
|
|
||||||
keywordUsageCountsText,
|
|
||||||
keywordUsageSceneLabel,
|
|
||||||
type KeywordUsageCounts,
|
|
||||||
type KeywordUsageFilter,
|
|
||||||
type KeywordUsageOverview,
|
|
||||||
type KeywordUsageRow,
|
|
||||||
} from './keyword-usage-model.ts'
|
|
||||||
import {
|
|
||||||
fetchKeywordUsage,
|
|
||||||
fetchKeywordUsageDeletes,
|
|
||||||
fetchKeywordUsageOverview,
|
|
||||||
} from './keyword-usage-api.ts'
|
|
||||||
|
|
||||||
const companyTab = useCompanyTabStore()
|
|
||||||
const session = useAdminSessionStore()
|
|
||||||
const me = computed(() => session.user?.username || '')
|
|
||||||
|
|
||||||
const filter = reactive<KeywordUsageFilter>(createKeywordUsageFilter())
|
|
||||||
const activeTab = ref<'usage' | 'deletes'>('usage')
|
|
||||||
const loadError = ref('')
|
|
||||||
|
|
||||||
const overview = ref<KeywordUsageOverview | null>(null)
|
|
||||||
const overviewLoading = ref(false)
|
|
||||||
|
|
||||||
const usageRows = ref<KeywordUsageRow[]>([])
|
|
||||||
const usageTotal = ref(0)
|
|
||||||
const usagePage = ref(1)
|
|
||||||
const usagePageSize = ref(KEYWORD_USAGE_PAGE_SIZE)
|
|
||||||
const usageCounts = ref<KeywordUsageCounts>({ copy: 0, copyExisting: 0, copyDeleted: 0, add: 0 })
|
|
||||||
const usageLoading = ref(false)
|
|
||||||
|
|
||||||
const deleteRows = ref<KeywordUsageRow[]>([])
|
|
||||||
const deleteTotal = ref(0)
|
|
||||||
const deletePage = ref(1)
|
|
||||||
const deletePageSize = ref(KEYWORD_USAGE_PAGE_SIZE)
|
|
||||||
const deleteLoading = ref(false)
|
|
||||||
|
|
||||||
// 切公司/快速改筛选时,先发的请求可能后返回;每个加载口径各一个序号闸(CR-27)
|
|
||||||
const overviewGate = createLatestRequestGate()
|
|
||||||
const usageGate = createLatestRequestGate()
|
|
||||||
const deleteGate = createLatestRequestGate()
|
|
||||||
|
|
||||||
const statsCards = computed(() => {
|
|
||||||
const stats = overview.value?.stats
|
|
||||||
return [
|
|
||||||
{ label: '复制关键词', value: stats?.used ?? 0, tone: 'primary' },
|
|
||||||
{ label: '现存词', value: stats?.exist ?? 0, tone: 'ok' },
|
|
||||||
{ label: '已删除词留痕', value: stats?.deletedKw ?? 0, tone: 'danger' },
|
|
||||||
{ label: '添加关键词', value: stats?.added ?? 0, tone: 'info' },
|
|
||||||
{ label: '使用记录合计', value: stats?.totalUse ?? 0, tone: '' },
|
|
||||||
{ label: '删除记录', value: stats?.deletes ?? 0, tone: 'violet' },
|
|
||||||
]
|
|
||||||
})
|
|
||||||
const userOptions = computed(() => overview.value?.users ?? [])
|
|
||||||
const countryOptions = computed(() => overview.value?.countries ?? [])
|
|
||||||
const usageSummary = computed(() => keywordUsageCountsText(usageCounts.value, usageTotal.value))
|
|
||||||
|
|
||||||
function queryParams() {
|
|
||||||
return {
|
|
||||||
companyId: companyTab.requestCompanyId,
|
|
||||||
user: filter.user,
|
|
||||||
country: filter.country,
|
|
||||||
keyword: filter.keyword.trim(),
|
|
||||||
scene: filter.scene,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadOverview(): Promise<void> {
|
|
||||||
const token = overviewGate.begin()
|
|
||||||
overviewLoading.value = true
|
|
||||||
try {
|
|
||||||
const result = await fetchKeywordUsageOverview({ companyId: companyTab.requestCompanyId })
|
|
||||||
if (!overviewGate.isCurrent(token)) return
|
|
||||||
overview.value = result
|
|
||||||
} catch (error) {
|
|
||||||
if (!overviewGate.isCurrent(token)) return
|
|
||||||
loadError.value = actionableErrorText(error)
|
|
||||||
} finally {
|
|
||||||
if (overviewGate.isCurrent(token)) overviewLoading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadUsage(page = usagePage.value): Promise<void> {
|
|
||||||
const token = usageGate.begin()
|
|
||||||
usageLoading.value = true
|
|
||||||
try {
|
|
||||||
const result = await fetchKeywordUsage({ ...queryParams(), page, pageSize: usagePageSize.value })
|
|
||||||
if (!usageGate.isCurrent(token)) return
|
|
||||||
usageRows.value = result.rows
|
|
||||||
usageTotal.value = result.total
|
|
||||||
usageCounts.value = result.counts
|
|
||||||
usagePage.value = page
|
|
||||||
} catch (error) {
|
|
||||||
if (!usageGate.isCurrent(token)) return
|
|
||||||
loadError.value = actionableErrorText(error)
|
|
||||||
} finally {
|
|
||||||
if (usageGate.isCurrent(token)) usageLoading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadDeletes(page = deletePage.value): Promise<void> {
|
|
||||||
const token = deleteGate.begin()
|
|
||||||
deleteLoading.value = true
|
|
||||||
try {
|
|
||||||
const result = await fetchKeywordUsageDeletes({ ...queryParams(), page, pageSize: deletePageSize.value })
|
|
||||||
if (!deleteGate.isCurrent(token)) return
|
|
||||||
deleteRows.value = result.rows
|
|
||||||
deleteTotal.value = result.total
|
|
||||||
deletePage.value = page
|
|
||||||
} catch (error) {
|
|
||||||
if (!deleteGate.isCurrent(token)) return
|
|
||||||
loadError.value = actionableErrorText(error)
|
|
||||||
} finally {
|
|
||||||
if (deleteGate.isCurrent(token)) deleteLoading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function reload(): Promise<void> {
|
|
||||||
loadError.value = ''
|
|
||||||
await Promise.all([loadOverview(), loadUsage(1), loadDeletes(1)])
|
|
||||||
}
|
|
||||||
|
|
||||||
function query(): void {
|
|
||||||
loadError.value = ''
|
|
||||||
void Promise.all([loadUsage(1), loadDeletes(1)])
|
|
||||||
}
|
|
||||||
|
|
||||||
function reset(): void {
|
|
||||||
Object.assign(filter, createKeywordUsageFilter())
|
|
||||||
query()
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeUsagePageSize(size: number): void {
|
|
||||||
usagePageSize.value = size
|
|
||||||
void loadUsage(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeDeletePageSize(size: number): void {
|
|
||||||
deletePageSize.value = size
|
|
||||||
void loadDeletes(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(() => companyTab.activeId, () => {
|
|
||||||
filter.user = ''
|
|
||||||
filter.country = ''
|
|
||||||
usagePage.value = 1
|
|
||||||
deletePage.value = 1
|
|
||||||
void reload()
|
|
||||||
})
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
void reload()
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="kw-page">
|
|
||||||
<LoadFailureBar v-if="loadError" :message="loadError" @retry="reload" />
|
|
||||||
|
|
||||||
<section class="kw-cards" v-loading="overviewLoading">
|
|
||||||
<div v-for="card in statsCards" :key="card.label" class="kw-card" :class="card.tone">
|
|
||||||
<div class="kw-n">{{ card.value.toLocaleString() }}</div>
|
|
||||||
<div class="kw-t">{{ card.label }}</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="kw-panel">
|
|
||||||
<div class="kw-panel-head">筛选条件</div>
|
|
||||||
<div class="kw-panel-body">
|
|
||||||
<div class="kw-filters">
|
|
||||||
<label class="kw-field">
|
|
||||||
<span>使用者</span>
|
|
||||||
<select v-model="filter.user">
|
|
||||||
<option value="">全部使用者</option>
|
|
||||||
<option v-for="user in userOptions" :key="user" :value="user">{{ user }}</option>
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
<label class="kw-field">
|
|
||||||
<span>国家</span>
|
|
||||||
<select v-model="filter.country">
|
|
||||||
<option value="">全部国家</option>
|
|
||||||
<option v-for="country in countryOptions" :key="country" :value="country">{{ country }}</option>
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
<label class="kw-field kw-field-wide">
|
|
||||||
<span>关键词</span>
|
|
||||||
<input v-model="filter.keyword" placeholder="搜索关键词" @keyup.enter="query" />
|
|
||||||
</label>
|
|
||||||
<label class="kw-field">
|
|
||||||
<span>场景</span>
|
|
||||||
<select v-model="filter.scene">
|
|
||||||
<option value="">全部场景</option>
|
|
||||||
<option v-for="scene in KEYWORD_USAGE_SCENES" :key="scene" :value="scene">{{ scene }}</option>
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
<div class="kw-actions">
|
|
||||||
<button class="kw-btn kw-btn-primary" type="button" @click="query">查询</button>
|
|
||||||
<button class="kw-btn kw-btn-ghost" type="button" @click="reset">重置</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<div class="kw-tabs">
|
|
||||||
<button class="kw-tab" :class="{ active: activeTab === 'usage' }" type="button" @click="activeTab = 'usage'">使用记录</button>
|
|
||||||
<button class="kw-tab" :class="{ active: activeTab === 'deletes' }" type="button" @click="activeTab = 'deletes'">删除记录</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<section v-show="activeTab === 'usage'" class="kw-panel">
|
|
||||||
<div class="kw-panel-head">
|
|
||||||
使用记录
|
|
||||||
<span class="kw-sub">复制关键词 + 添加关键词,按时间倒序;绿色为本人的记录</span>
|
|
||||||
</div>
|
|
||||||
<div class="kw-panel-body">
|
|
||||||
<div class="kw-table-wrap" v-loading="usageLoading">
|
|
||||||
<table v-if="usageRows.length" class="kw-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th style="width: 130px">使用者</th>
|
|
||||||
<th style="width: 90px">国家</th>
|
|
||||||
<th>关键词</th>
|
|
||||||
<th style="width: 140px">使用场景</th>
|
|
||||||
<th style="width: 170px">使用时间</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr v-for="(row, index) in usageRows" :key="`usage-${row.time}-${index}`" :class="{ mine: row.userName === me }">
|
|
||||||
<td class="kw-user">{{ row.userName || '—' }}</td>
|
|
||||||
<td>{{ row.country || '—' }}</td>
|
|
||||||
<td class="kw-keyword">{{ row.keyword || '—' }}</td>
|
|
||||||
<td>
|
|
||||||
<span class="kw-tag" :class="row.scene === '添加关键词' ? 'add' : 'copy'">
|
|
||||||
{{ keywordUsageSceneLabel(row.scene) }}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td class="kw-time">{{ formatDateTime(row.time) }}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div v-else-if="!usageLoading" class="kw-empty">暂无使用记录</div>
|
|
||||||
</div>
|
|
||||||
<div class="kw-footer">
|
|
||||||
<span class="kw-summary">{{ usageSummary }}</span>
|
|
||||||
<OldPagination
|
|
||||||
v-if="usageTotal"
|
|
||||||
:total="usageTotal"
|
|
||||||
:page="usagePage"
|
|
||||||
:page-size="usagePageSize"
|
|
||||||
@change="loadUsage"
|
|
||||||
@size-change="changeUsagePageSize"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section v-show="activeTab === 'deletes'" class="kw-panel">
|
|
||||||
<div class="kw-panel-head">
|
|
||||||
删除记录
|
|
||||||
<span class="kw-sub">只读、不可删除、永久留痕可追溯;红色为本人的记录</span>
|
|
||||||
</div>
|
|
||||||
<div class="kw-panel-body">
|
|
||||||
<div class="kw-table-wrap" v-loading="deleteLoading">
|
|
||||||
<table v-if="deleteRows.length" class="kw-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th style="width: 130px">删除者</th>
|
|
||||||
<th style="width: 90px">国家</th>
|
|
||||||
<th>关键词</th>
|
|
||||||
<th style="width: 170px">删除时间</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr v-for="(row, index) in deleteRows" :key="`delete-${row.time}-${index}`" :class="{ mine: row.userName === me }">
|
|
||||||
<td class="kw-user">{{ row.userName || '—' }}</td>
|
|
||||||
<td>{{ row.country || '—' }}</td>
|
|
||||||
<td class="kw-keyword">{{ row.keyword || '—' }}</td>
|
|
||||||
<td class="kw-time">{{ formatDateTime(row.time) }}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div v-else-if="!deleteLoading" class="kw-empty">暂无删除记录</div>
|
|
||||||
</div>
|
|
||||||
<div class="kw-footer">
|
|
||||||
<span class="kw-summary">共 {{ deleteTotal }} 条删除记录 · 只读留痕</span>
|
|
||||||
<OldPagination
|
|
||||||
v-if="deleteTotal"
|
|
||||||
:total="deleteTotal"
|
|
||||||
:page="deletePage"
|
|
||||||
:page-size="deletePageSize"
|
|
||||||
@change="loadDeletes"
|
|
||||||
@size-change="changeDeletePageSize"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.kw-page {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.kw-cards {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
.kw-card {
|
|
||||||
background: #fff;
|
|
||||||
border: 1px solid #e5e9f0;
|
|
||||||
border-top: 3px solid #9ca3af;
|
|
||||||
border-radius: 10px;
|
|
||||||
box-shadow: 0 1px 2px rgba(20, 30, 60, 0.05), 0 4px 18px rgba(20, 30, 60, 0.06);
|
|
||||||
padding: 12px 14px;
|
|
||||||
}
|
|
||||||
.kw-card.primary { border-top-color: #2e5be6; }
|
|
||||||
.kw-card.ok { border-top-color: #1f9d62; }
|
|
||||||
.kw-card.danger { border-top-color: #d63a4a; }
|
|
||||||
.kw-card.info { border-top-color: #0d9488; }
|
|
||||||
.kw-card.violet { border-top-color: #7c5cd6; }
|
|
||||||
.kw-card .kw-n {
|
|
||||||
font-size: 24px;
|
|
||||||
font-weight: 700;
|
|
||||||
color: #1c2230;
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
line-height: 1.2;
|
|
||||||
}
|
|
||||||
.kw-card .kw-t {
|
|
||||||
margin-top: 3px;
|
|
||||||
font-size: 11.5px;
|
|
||||||
color: #98a1b1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.kw-panel {
|
|
||||||
background: #fff;
|
|
||||||
border: 1px solid #e5e9f0;
|
|
||||||
border-radius: 10px;
|
|
||||||
box-shadow: 0 1px 2px rgba(20, 30, 60, 0.05), 0 4px 18px rgba(20, 30, 60, 0.06);
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
.kw-panel-head {
|
|
||||||
padding: 11px 15px;
|
|
||||||
background: #fafbfd;
|
|
||||||
border-bottom: 1px solid #e9edf3;
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 700;
|
|
||||||
color: #1c2230;
|
|
||||||
}
|
|
||||||
.kw-panel-head::before {
|
|
||||||
content: "";
|
|
||||||
display: inline-block;
|
|
||||||
width: 7px;
|
|
||||||
height: 7px;
|
|
||||||
border-radius: 2px;
|
|
||||||
background: #2dd4bf;
|
|
||||||
margin-right: 8px;
|
|
||||||
vertical-align: 1px;
|
|
||||||
}
|
|
||||||
.kw-sub {
|
|
||||||
margin-left: 8px;
|
|
||||||
font-size: 11.5px;
|
|
||||||
font-weight: 400;
|
|
||||||
color: #98a1b1;
|
|
||||||
}
|
|
||||||
.kw-panel-body {
|
|
||||||
padding: 14px 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.kw-filters {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
align-items: flex-end;
|
|
||||||
gap: 10px 12px;
|
|
||||||
}
|
|
||||||
.kw-field {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 5px;
|
|
||||||
min-width: 150px;
|
|
||||||
}
|
|
||||||
.kw-field-wide {
|
|
||||||
min-width: 220px;
|
|
||||||
}
|
|
||||||
.kw-field > span {
|
|
||||||
font-size: 12px;
|
|
||||||
color: #5a6474;
|
|
||||||
}
|
|
||||||
.kw-field input,
|
|
||||||
.kw-field select {
|
|
||||||
height: 34px;
|
|
||||||
padding: 0 10px;
|
|
||||||
border: 1px solid #d7dce5;
|
|
||||||
border-radius: 7px;
|
|
||||||
background: #fbfcfe;
|
|
||||||
color: #1c2230;
|
|
||||||
font-family: inherit;
|
|
||||||
font-size: 13px;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
.kw-field input:focus,
|
|
||||||
.kw-field select:focus {
|
|
||||||
border-color: #2e5be6;
|
|
||||||
box-shadow: 0 0 0 3px rgba(46, 91, 230, 0.12);
|
|
||||||
background: #fff;
|
|
||||||
}
|
|
||||||
.kw-actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.kw-btn {
|
|
||||||
height: 34px;
|
|
||||||
padding: 0 15px;
|
|
||||||
border: 1px solid transparent;
|
|
||||||
border-radius: 7px;
|
|
||||||
font-family: inherit;
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 600;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.kw-btn-primary {
|
|
||||||
background: #2e5be6;
|
|
||||||
border-color: #2e5be6;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
.kw-btn-primary:hover { background: #1e4bd8; border-color: #1e4bd8; }
|
|
||||||
.kw-btn-ghost {
|
|
||||||
background: #fff;
|
|
||||||
border-color: #d7dce5;
|
|
||||||
color: #5a6474;
|
|
||||||
}
|
|
||||||
.kw-btn-ghost:hover { border-color: #2e5be6; color: #2e5be6; }
|
|
||||||
|
|
||||||
.kw-tabs {
|
|
||||||
display: flex;
|
|
||||||
gap: 4px;
|
|
||||||
background: #fff;
|
|
||||||
border: 1px solid #e5e9f0;
|
|
||||||
border-radius: 9px;
|
|
||||||
padding: 4px;
|
|
||||||
align-self: flex-start;
|
|
||||||
}
|
|
||||||
.kw-tab {
|
|
||||||
padding: 7px 18px;
|
|
||||||
border: none;
|
|
||||||
border-radius: 7px;
|
|
||||||
background: none;
|
|
||||||
color: #5a6474;
|
|
||||||
font-family: inherit;
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 600;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.kw-tab:hover { color: #2e5be6; }
|
|
||||||
.kw-tab.active { background: #2e5be6; color: #fff; }
|
|
||||||
|
|
||||||
.kw-table-wrap {
|
|
||||||
overflow-x: auto;
|
|
||||||
border: 1px solid #e5e9f0;
|
|
||||||
border-radius: 9px;
|
|
||||||
min-height: 90px;
|
|
||||||
}
|
|
||||||
.kw-table {
|
|
||||||
width: 100%;
|
|
||||||
border-collapse: separate;
|
|
||||||
border-spacing: 0;
|
|
||||||
font-size: 12.5px;
|
|
||||||
}
|
|
||||||
.kw-table th {
|
|
||||||
position: sticky;
|
|
||||||
top: 0;
|
|
||||||
z-index: 1;
|
|
||||||
padding: 10px;
|
|
||||||
background: #f7f9fc;
|
|
||||||
border-bottom: 1px solid #e5e9f0;
|
|
||||||
color: #5a6474;
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: 600;
|
|
||||||
text-align: left;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.kw-table td {
|
|
||||||
padding: 9px 10px;
|
|
||||||
border-bottom: 1px solid #eff2f7;
|
|
||||||
color: #1c2230;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.kw-table tbody tr:hover td { background: #f7faff; }
|
|
||||||
.kw-table tbody tr:last-child td { border-bottom: none; }
|
|
||||||
.kw-table tr.mine td { color: #0f9d58; font-weight: 600; }
|
|
||||||
.kw-user { font-weight: 500; }
|
|
||||||
.kw-keyword { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
|
|
||||||
.kw-time { color: #5a6474; font-size: 11.5px; }
|
|
||||||
|
|
||||||
.kw-tag {
|
|
||||||
display: inline-block;
|
|
||||||
padding: 2px 8px;
|
|
||||||
border-radius: 6px;
|
|
||||||
font-size: 11px;
|
|
||||||
font-weight: 600;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.kw-tag.copy { background: #e8f7f4; color: #0d9488; }
|
|
||||||
.kw-tag.add { background: #eff6ff; color: #2563eb; }
|
|
||||||
|
|
||||||
.kw-empty {
|
|
||||||
padding: 42px 16px;
|
|
||||||
text-align: center;
|
|
||||||
color: #98a1b1;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.kw-footer {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 10px;
|
|
||||||
margin-top: 12px;
|
|
||||||
}
|
|
||||||
.kw-summary {
|
|
||||||
font-size: 11.5px;
|
|
||||||
color: #98a1b1;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user