VoicePrint.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. <template>
  2. <div class="welcome">
  3. <HeaderBar />
  4. <div class="operation-bar">
  5. <h2 class="page-title">{{ $t('voicePrint.pageTitle') }}</h2>
  6. </div>
  7. <div class="main-wrapper">
  8. <div class="content-panel">
  9. <div class="content-area">
  10. <el-card class="voice-print-card" shadow="never">
  11. <el-table ref="paramsTable" :data="voicePrintList" class="transparent-table" v-loading="loading"
  12. :element-loading-text="$t('voicePrint.loading')" element-loading-spinner="el-icon-loading"
  13. element-loading-background="rgba(255, 255, 255, 0.7)">
  14. <el-table-column :label="$t('voicePrint.name')" prop="sourceName" align="center"></el-table-column>
  15. <el-table-column :label="$t('voicePrint.description')" prop="introduce" align="center"></el-table-column>
  16. <el-table-column :label="$t('voicePrint.createTime')" prop="createDate" align="center"></el-table-column>
  17. <el-table-column :label="$t('voicePrint.action')" align="center">
  18. <template slot-scope="scope">
  19. <el-button size="mini" type="text" @click="editVoicePrint(scope.row)">{{ $t('voicePrint.edit') }}</el-button>
  20. <el-button size="mini" type="text"
  21. @click="deleteVoicePrint(scope.row.id)">{{ $t('voicePrint.delete') }}</el-button>
  22. </template>
  23. </el-table-column>
  24. </el-table>
  25. <div class="table_bottom">
  26. <div class="ctrl_btn">
  27. <el-button size="mini" type="success" @click="showAddDialog">{{ $t('voicePrint.add') }}</el-button>
  28. </div>
  29. </div>
  30. </el-card>
  31. </div>
  32. </div>
  33. </div>
  34. <!-- 新增/编辑参数对话框 -->
  35. <voice-print-dialog :title="dialogTitle" :visible.sync="dialogVisible" :agentId="agentId" :form="paramForm"
  36. @submit="handleSubmit" @cancel="dialogVisible = false" />
  37. <el-footer>
  38. <version-footer />
  39. </el-footer>
  40. </div>
  41. </template>
  42. <script>
  43. import Api from "@/apis/api";
  44. import HeaderBar from "@/components/HeaderBar.vue";
  45. import VersionFooter from "@/components/VersionFooter.vue";
  46. import VoicePrintDialog from "@/components/VoicePrintDialog.vue";
  47. export default {
  48. components: { HeaderBar, VoicePrintDialog, VersionFooter },
  49. data() {
  50. return {
  51. voicePrintList: [],
  52. loading: false,
  53. dialogVisible: false,
  54. dialogTitle: this.$t('voicePrint.addSpeaker'),
  55. isAllSelected: false,
  56. paramForm: {
  57. id: null,
  58. audioId: '',
  59. sourceName: '',
  60. introduce: ''
  61. },
  62. agentId: "1"
  63. };
  64. },
  65. mounted() {
  66. const agentId = this.$route.query.agentId;
  67. if (agentId) {
  68. this.agentId = agentId
  69. this.fetchVoicePrints();
  70. }
  71. },
  72. methods: {
  73. fetchVoicePrints() {
  74. this.loading = true;
  75. Api.agent.getAgentVoicePrintList(this.agentId,
  76. ({ data }) => {
  77. this.loading = false;
  78. if (data.code === 0) {
  79. this.voicePrintList = data.data.map(item => ({
  80. ...item,
  81. }));
  82. } else {
  83. this.$message.error({
  84. message: data.msg || this.$t('voicePrint.fetchFailed'),
  85. showClose: true
  86. });
  87. }
  88. }
  89. );
  90. },
  91. showAddDialog() {
  92. this.dialogTitle = this.$t('voicePrint.addSpeaker');
  93. this.paramForm = {
  94. id: null,
  95. audioId: '',
  96. sourceName: '',
  97. introduce: ''
  98. };
  99. this.dialogVisible = true;
  100. },
  101. editVoicePrint(row) {
  102. this.dialogTitle = this.$t('voicePrint.editSpeaker');
  103. this.paramForm = { ...row };
  104. this.dialogVisible = true;
  105. },
  106. handleSubmit({ form, done }) {
  107. if (form.id) {
  108. // 编辑
  109. Api.agent.updateAgentVoicePrint(form, ({ data }) => {
  110. if (data.code === 0) {
  111. this.$message.success({
  112. message: this.$t('voicePrint.updateSuccess'),
  113. showClose: true
  114. });
  115. this.dialogVisible = false;
  116. this.fetchVoicePrints();
  117. }
  118. done && done();
  119. });
  120. } else {
  121. // 新增
  122. Api.agent.addAgentVoicePrint({
  123. agentId: this.agentId,
  124. audioId: form.audioId,
  125. sourceName: form.sourceName,
  126. introduce: form.introduce
  127. }, ({ data }) => {
  128. if (data.code === 0) {
  129. this.$message.success({
  130. message: this.$t('voicePrint.addSuccess'),
  131. showClose: true
  132. });
  133. this.dialogVisible = false;
  134. this.fetchVoicePrints();
  135. }
  136. done && done();
  137. });
  138. }
  139. },
  140. // 删除按钮
  141. deleteVoicePrint(id) {
  142. this.$confirm(this.$t('voicePrint.confirmDelete'), this.$t('voicePrint.warning'), {
  143. confirmButtonText: this.$t('voicePrint.confirm'),
  144. cancelButtonText: this.$t('voicePrint.cancel'),
  145. type: 'warning',
  146. distinguishCancelAndClose: true
  147. }).then(() => {
  148. Api.agent.deleteAgentVoicePrint(id, ({ data }) => {
  149. if (data.code === 0) {
  150. this.$message.success({
  151. message: this.$t('voicePrint.deleteSuccess'),
  152. showClose: true
  153. });
  154. this.fetchVoicePrints();
  155. } else {
  156. this.$message.error({
  157. message: data.msg || this.$t('voicePrint.deleteFailed'),
  158. showClose: true
  159. });
  160. }
  161. });
  162. }).catch(action => {
  163. if (action === 'cancel') {
  164. this.$message({
  165. type: 'info',
  166. message: this.$t('voicePrint.cancelDelete'),
  167. duration: 1000
  168. });
  169. } else {
  170. this.$message({
  171. type: 'info',
  172. message: this.$t('voicePrint.closeOperation'),
  173. duration: 1000
  174. });
  175. }
  176. });
  177. },
  178. },
  179. };
  180. </script>
  181. <style lang="scss" scoped>
  182. .welcome {
  183. min-width: 900px;
  184. min-height: 506px;
  185. height: 100vh;
  186. display: flex;
  187. position: relative;
  188. flex-direction: column;
  189. background-size: cover;
  190. background: linear-gradient(to bottom right, #dce8ff, #e4eeff, #e6cbfd) center;
  191. -webkit-background-size: cover;
  192. -o-background-size: cover;
  193. overflow: hidden;
  194. }
  195. .main-wrapper {
  196. height: calc(100vh - 63px - 35px - 60px);
  197. margin: 0 22px;
  198. border-radius: 15px;
  199. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  200. position: relative;
  201. background: rgba(237, 242, 255, 0.5);
  202. display: flex;
  203. flex-direction: column;
  204. }
  205. .operation-bar {
  206. display: flex;
  207. justify-content: space-between;
  208. align-items: center;
  209. padding: 16px 24px;
  210. }
  211. .page-title {
  212. font-size: 24px;
  213. margin: 0;
  214. }
  215. .right-operations {
  216. display: flex;
  217. gap: 10px;
  218. margin-left: auto;
  219. }
  220. .search-input {
  221. width: 240px;
  222. }
  223. .btn-search {
  224. background: linear-gradient(135deg, #6b8cff, #a966ff);
  225. border: none;
  226. color: white;
  227. }
  228. .content-panel {
  229. flex: 1;
  230. display: flex;
  231. overflow: hidden;
  232. height: 100%;
  233. border-radius: 15px;
  234. background: transparent;
  235. border: 1px solid #fff;
  236. }
  237. .content-area {
  238. flex: 1;
  239. height: 100%;
  240. min-width: 600px;
  241. overflow: auto;
  242. background-color: white;
  243. display: flex;
  244. flex-direction: column;
  245. }
  246. .voice-print-card {
  247. background: white;
  248. flex: 1;
  249. display: flex;
  250. flex-direction: column;
  251. border: none;
  252. box-shadow: none;
  253. overflow: hidden;
  254. ::v-deep .el-card__body {
  255. padding: 15px;
  256. display: flex;
  257. flex-direction: column;
  258. flex: 1;
  259. overflow: hidden;
  260. }
  261. }
  262. .table_bottom {
  263. display: flex;
  264. justify-content: space-between;
  265. align-items: center;
  266. margin-top: 10px;
  267. // padding-bottom: 10px;
  268. }
  269. .ctrl_btn {
  270. display: flex;
  271. gap: 8px;
  272. padding-left: 26px;
  273. .el-button {
  274. min-width: 72px;
  275. height: 32px;
  276. padding: 7px 12px 7px 10px;
  277. font-size: 12px;
  278. border-radius: 4px;
  279. line-height: 1;
  280. font-weight: 500;
  281. border: none;
  282. transition: all 0.3s ease;
  283. box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  284. &:hover {
  285. transform: translateY(-1px);
  286. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  287. }
  288. }
  289. .el-button--primary {
  290. background: #5f70f3;
  291. color: white;
  292. }
  293. .el-button--danger {
  294. background: #fd5b63;
  295. color: white;
  296. }
  297. }
  298. .custom-pagination {
  299. display: flex;
  300. align-items: center;
  301. gap: 10px;
  302. .el-select {
  303. margin-right: 8px;
  304. }
  305. .pagination-btn:first-child,
  306. .pagination-btn:nth-child(2),
  307. .pagination-btn:nth-last-child(2),
  308. .pagination-btn:nth-child(3) {
  309. min-width: 60px;
  310. height: 32px;
  311. padding: 0 12px;
  312. border-radius: 4px;
  313. border: 1px solid #e4e7ed;
  314. background: #dee7ff;
  315. color: #606266;
  316. font-size: 14px;
  317. cursor: pointer;
  318. transition: all 0.3s ease;
  319. &:hover {
  320. background: #d7dce6;
  321. }
  322. &:disabled {
  323. opacity: 0.6;
  324. cursor: not-allowed;
  325. }
  326. }
  327. .pagination-btn:not(:first-child):not(:nth-child(3)):not(:nth-child(2)):not(:nth-last-child(2)) {
  328. min-width: 28px;
  329. height: 32px;
  330. padding: 0;
  331. border-radius: 4px;
  332. border: 1px solid transparent;
  333. background: transparent;
  334. color: #606266;
  335. font-size: 14px;
  336. cursor: pointer;
  337. transition: all 0.3s ease;
  338. &:hover {
  339. background: rgba(245, 247, 250, 0.3);
  340. }
  341. }
  342. .pagination-btn.active {
  343. background: #5f70f3 !important;
  344. color: #ffffff !important;
  345. border-color: #5f70f3 !important;
  346. &:hover {
  347. background: #6d7cf5 !important;
  348. }
  349. }
  350. .total-text {
  351. color: #909399;
  352. font-size: 14px;
  353. margin-left: 10px;
  354. }
  355. }
  356. :deep(.transparent-table) {
  357. background: white;
  358. flex: 1;
  359. width: 100%;
  360. display: flex;
  361. flex-direction: column;
  362. .el-table__body-wrapper {
  363. flex: 1;
  364. overflow-y: auto;
  365. max-height: none !important;
  366. }
  367. .el-table__header-wrapper {
  368. flex-shrink: 0;
  369. }
  370. .el-table__header th {
  371. background: white !important;
  372. color: black;
  373. }
  374. &::before {
  375. display: none;
  376. }
  377. .el-table__body tr {
  378. background-color: white;
  379. td {
  380. border-top: 1px solid rgba(0, 0, 0, 0.04);
  381. border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  382. }
  383. }
  384. }
  385. :deep(.el-checkbox__inner) {
  386. background-color: #ffffff !important;
  387. border-color: #cccccc !important;
  388. }
  389. :deep(.el-checkbox__inner:hover) {
  390. border-color: #cccccc !important;
  391. }
  392. :deep(.el-checkbox__input.is-checked .el-checkbox__inner) {
  393. background-color: #5f70f3 !important;
  394. border-color: #5f70f3 !important;
  395. }
  396. @media (min-width: 1144px) {
  397. .table_bottom {
  398. display: flex;
  399. justify-content: space-between;
  400. align-items: center;
  401. margin-top: 40px;
  402. }
  403. :deep(.transparent-table) {
  404. .el-table__body tr {
  405. td {
  406. padding-top: 16px;
  407. padding-bottom: 16px;
  408. }
  409. &+tr {
  410. margin-top: 10px;
  411. }
  412. }
  413. }
  414. }
  415. :deep(.el-table .el-button--text) {
  416. color: #7079aa;
  417. }
  418. :deep(.el-table .el-button--text:hover) {
  419. color: #5a64b5;
  420. }
  421. .el-button--success {
  422. background: #5bc98c;
  423. color: white;
  424. }
  425. :deep(.el-table .cell) {
  426. white-space: nowrap;
  427. overflow: hidden;
  428. text-overflow: ellipsis;
  429. }
  430. .page-size-select {
  431. width: 100px;
  432. margin-right: 10px;
  433. :deep(.el-input__inner) {
  434. height: 32px;
  435. line-height: 32px;
  436. border-radius: 4px;
  437. border: 1px solid #e4e7ed;
  438. background: #dee7ff;
  439. color: #606266;
  440. font-size: 14px;
  441. }
  442. :deep(.el-input__suffix) {
  443. right: 6px;
  444. width: 15px;
  445. height: 20px;
  446. display: flex;
  447. justify-content: center;
  448. align-items: center;
  449. top: 6px;
  450. border-radius: 4px;
  451. }
  452. :deep(.el-input__suffix-inner) {
  453. display: flex;
  454. align-items: center;
  455. justify-content: center;
  456. width: 100%;
  457. }
  458. :deep(.el-icon-arrow-up:before) {
  459. content: "";
  460. display: inline-block;
  461. border-left: 6px solid transparent;
  462. border-right: 6px solid transparent;
  463. border-top: 9px solid #606266;
  464. position: relative;
  465. transform: rotate(0deg);
  466. transition: transform 0.3s;
  467. }
  468. }
  469. :deep(.el-table) {
  470. .el-table__body-wrapper {
  471. transition: height 0.3s ease;
  472. }
  473. }
  474. .el-table {
  475. // --table-max-height: calc(100vh - 40vh);
  476. max-height: var(--table-max-height);
  477. .el-table__body-wrapper {
  478. max-height: calc(var(--table-max-height) - 40px);
  479. }
  480. }
  481. :deep(.el-loading-mask) {
  482. background-color: rgba(255, 255, 255, 0.6) !important;
  483. backdrop-filter: blur(2px);
  484. }
  485. :deep(.el-loading-spinner .circular) {
  486. width: 28px;
  487. height: 28px;
  488. }
  489. :deep(.el-loading-spinner .path) {
  490. stroke: #6b8cff;
  491. }
  492. :deep(.el-loading-text) {
  493. color: #6b8cff !important;
  494. font-size: 14px;
  495. margin-top: 8px;
  496. }
  497. </style>