| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561 |
- <template>
- <div class="welcome">
- <HeaderBar />
- <div class="operation-bar">
- <h2 class="page-title">{{ $t('voicePrint.pageTitle') }}</h2>
- </div>
- <div class="main-wrapper">
- <div class="content-panel">
- <div class="content-area">
- <el-card class="voice-print-card" shadow="never">
- <el-table ref="paramsTable" :data="voicePrintList" class="transparent-table" v-loading="loading"
- :element-loading-text="$t('voicePrint.loading')" element-loading-spinner="el-icon-loading"
- element-loading-background="rgba(255, 255, 255, 0.7)">
- <el-table-column :label="$t('voicePrint.name')" prop="sourceName" align="center"></el-table-column>
- <el-table-column :label="$t('voicePrint.description')" prop="introduce" align="center"></el-table-column>
- <el-table-column :label="$t('voicePrint.createTime')" prop="createDate" align="center"></el-table-column>
- <el-table-column :label="$t('voicePrint.action')" align="center">
- <template slot-scope="scope">
- <el-button size="mini" type="text" @click="editVoicePrint(scope.row)">{{ $t('voicePrint.edit') }}</el-button>
- <el-button size="mini" type="text"
- @click="deleteVoicePrint(scope.row.id)">{{ $t('voicePrint.delete') }}</el-button>
- </template>
- </el-table-column>
- </el-table>
- <div class="table_bottom">
- <div class="ctrl_btn">
- <el-button size="mini" type="success" @click="showAddDialog">{{ $t('voicePrint.add') }}</el-button>
- </div>
- </div>
- </el-card>
- </div>
- </div>
- </div>
- <!-- 新增/编辑参数对话框 -->
- <voice-print-dialog :title="dialogTitle" :visible.sync="dialogVisible" :agentId="agentId" :form="paramForm"
- @submit="handleSubmit" @cancel="dialogVisible = false" />
- <el-footer>
- <version-footer />
- </el-footer>
- </div>
- </template>
- <script>
- import Api from "@/apis/api";
- import HeaderBar from "@/components/HeaderBar.vue";
- import VersionFooter from "@/components/VersionFooter.vue";
- import VoicePrintDialog from "@/components/VoicePrintDialog.vue";
- export default {
- components: { HeaderBar, VoicePrintDialog, VersionFooter },
- data() {
- return {
- voicePrintList: [],
- loading: false,
- dialogVisible: false,
- dialogTitle: this.$t('voicePrint.addSpeaker'),
- isAllSelected: false,
- paramForm: {
- id: null,
- audioId: '',
- sourceName: '',
- introduce: ''
- },
- agentId: "1"
- };
- },
- mounted() {
- const agentId = this.$route.query.agentId;
- if (agentId) {
- this.agentId = agentId
- this.fetchVoicePrints();
- }
- },
- methods: {
- fetchVoicePrints() {
- this.loading = true;
- Api.agent.getAgentVoicePrintList(this.agentId,
- ({ data }) => {
- this.loading = false;
- if (data.code === 0) {
- this.voicePrintList = data.data.map(item => ({
- ...item,
- }));
- } else {
- this.$message.error({
- message: data.msg || this.$t('voicePrint.fetchFailed'),
- showClose: true
- });
- }
- }
- );
- },
- showAddDialog() {
- this.dialogTitle = this.$t('voicePrint.addSpeaker');
- this.paramForm = {
- id: null,
- audioId: '',
- sourceName: '',
- introduce: ''
- };
- this.dialogVisible = true;
- },
- editVoicePrint(row) {
- this.dialogTitle = this.$t('voicePrint.editSpeaker');
- this.paramForm = { ...row };
- this.dialogVisible = true;
- },
- handleSubmit({ form, done }) {
- if (form.id) {
- // 编辑
- Api.agent.updateAgentVoicePrint(form, ({ data }) => {
- if (data.code === 0) {
- this.$message.success({
- message: this.$t('voicePrint.updateSuccess'),
- showClose: true
- });
- this.dialogVisible = false;
- this.fetchVoicePrints();
- }
- done && done();
- });
- } else {
- // 新增
- Api.agent.addAgentVoicePrint({
- agentId: this.agentId,
- audioId: form.audioId,
- sourceName: form.sourceName,
- introduce: form.introduce
- }, ({ data }) => {
- if (data.code === 0) {
- this.$message.success({
- message: this.$t('voicePrint.addSuccess'),
- showClose: true
- });
- this.dialogVisible = false;
- this.fetchVoicePrints();
- }
- done && done();
- });
- }
- },
- // 删除按钮
- deleteVoicePrint(id) {
- this.$confirm(this.$t('voicePrint.confirmDelete'), this.$t('voicePrint.warning'), {
- confirmButtonText: this.$t('voicePrint.confirm'),
- cancelButtonText: this.$t('voicePrint.cancel'),
- type: 'warning',
- distinguishCancelAndClose: true
- }).then(() => {
- Api.agent.deleteAgentVoicePrint(id, ({ data }) => {
- if (data.code === 0) {
- this.$message.success({
- message: this.$t('voicePrint.deleteSuccess'),
- showClose: true
- });
- this.fetchVoicePrints();
- } else {
- this.$message.error({
- message: data.msg || this.$t('voicePrint.deleteFailed'),
- showClose: true
- });
- }
- });
- }).catch(action => {
- if (action === 'cancel') {
- this.$message({
- type: 'info',
- message: this.$t('voicePrint.cancelDelete'),
- duration: 1000
- });
- } else {
- this.$message({
- type: 'info',
- message: this.$t('voicePrint.closeOperation'),
- duration: 1000
- });
- }
- });
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .welcome {
- min-width: 900px;
- min-height: 506px;
- height: 100vh;
- display: flex;
- position: relative;
- flex-direction: column;
- background-size: cover;
- background: linear-gradient(to bottom right, #dce8ff, #e4eeff, #e6cbfd) center;
- -webkit-background-size: cover;
- -o-background-size: cover;
- overflow: hidden;
- }
- .main-wrapper {
- height: calc(100vh - 63px - 35px - 60px);
- margin: 0 22px;
- border-radius: 15px;
- box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
- position: relative;
- background: rgba(237, 242, 255, 0.5);
- display: flex;
- flex-direction: column;
- }
- .operation-bar {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 16px 24px;
- }
- .page-title {
- font-size: 24px;
- margin: 0;
- }
- .right-operations {
- display: flex;
- gap: 10px;
- margin-left: auto;
- }
- .search-input {
- width: 240px;
- }
- .btn-search {
- background: linear-gradient(135deg, #6b8cff, #a966ff);
- border: none;
- color: white;
- }
- .content-panel {
- flex: 1;
- display: flex;
- overflow: hidden;
- height: 100%;
- border-radius: 15px;
- background: transparent;
- border: 1px solid #fff;
- }
- .content-area {
- flex: 1;
- height: 100%;
- min-width: 600px;
- overflow: auto;
- background-color: white;
- display: flex;
- flex-direction: column;
- }
- .voice-print-card {
- background: white;
- flex: 1;
- display: flex;
- flex-direction: column;
- border: none;
- box-shadow: none;
- overflow: hidden;
- ::v-deep .el-card__body {
- padding: 15px;
- display: flex;
- flex-direction: column;
- flex: 1;
- overflow: hidden;
- }
- }
- .table_bottom {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-top: 10px;
- // padding-bottom: 10px;
- }
- .ctrl_btn {
- display: flex;
- gap: 8px;
- padding-left: 26px;
- .el-button {
- min-width: 72px;
- height: 32px;
- padding: 7px 12px 7px 10px;
- font-size: 12px;
- border-radius: 4px;
- line-height: 1;
- font-weight: 500;
- border: none;
- transition: all 0.3s ease;
- box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
- &:hover {
- transform: translateY(-1px);
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
- }
- }
- .el-button--primary {
- background: #5f70f3;
- color: white;
- }
- .el-button--danger {
- background: #fd5b63;
- color: white;
- }
- }
- .custom-pagination {
- display: flex;
- align-items: center;
- gap: 10px;
- .el-select {
- margin-right: 8px;
- }
- .pagination-btn:first-child,
- .pagination-btn:nth-child(2),
- .pagination-btn:nth-last-child(2),
- .pagination-btn:nth-child(3) {
- min-width: 60px;
- height: 32px;
- padding: 0 12px;
- border-radius: 4px;
- border: 1px solid #e4e7ed;
- background: #dee7ff;
- color: #606266;
- font-size: 14px;
- cursor: pointer;
- transition: all 0.3s ease;
- &:hover {
- background: #d7dce6;
- }
- &:disabled {
- opacity: 0.6;
- cursor: not-allowed;
- }
- }
- .pagination-btn:not(:first-child):not(:nth-child(3)):not(:nth-child(2)):not(:nth-last-child(2)) {
- min-width: 28px;
- height: 32px;
- padding: 0;
- border-radius: 4px;
- border: 1px solid transparent;
- background: transparent;
- color: #606266;
- font-size: 14px;
- cursor: pointer;
- transition: all 0.3s ease;
- &:hover {
- background: rgba(245, 247, 250, 0.3);
- }
- }
- .pagination-btn.active {
- background: #5f70f3 !important;
- color: #ffffff !important;
- border-color: #5f70f3 !important;
- &:hover {
- background: #6d7cf5 !important;
- }
- }
- .total-text {
- color: #909399;
- font-size: 14px;
- margin-left: 10px;
- }
- }
- :deep(.transparent-table) {
- background: white;
- flex: 1;
- width: 100%;
- display: flex;
- flex-direction: column;
- .el-table__body-wrapper {
- flex: 1;
- overflow-y: auto;
- max-height: none !important;
- }
- .el-table__header-wrapper {
- flex-shrink: 0;
- }
- .el-table__header th {
- background: white !important;
- color: black;
- }
- &::before {
- display: none;
- }
- .el-table__body tr {
- background-color: white;
- td {
- border-top: 1px solid rgba(0, 0, 0, 0.04);
- border-bottom: 1px solid rgba(0, 0, 0, 0.04);
- }
- }
- }
- :deep(.el-checkbox__inner) {
- background-color: #ffffff !important;
- border-color: #cccccc !important;
- }
- :deep(.el-checkbox__inner:hover) {
- border-color: #cccccc !important;
- }
- :deep(.el-checkbox__input.is-checked .el-checkbox__inner) {
- background-color: #5f70f3 !important;
- border-color: #5f70f3 !important;
- }
- @media (min-width: 1144px) {
- .table_bottom {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-top: 40px;
- }
- :deep(.transparent-table) {
- .el-table__body tr {
- td {
- padding-top: 16px;
- padding-bottom: 16px;
- }
- &+tr {
- margin-top: 10px;
- }
- }
- }
- }
- :deep(.el-table .el-button--text) {
- color: #7079aa;
- }
- :deep(.el-table .el-button--text:hover) {
- color: #5a64b5;
- }
- .el-button--success {
- background: #5bc98c;
- color: white;
- }
- :deep(.el-table .cell) {
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .page-size-select {
- width: 100px;
- margin-right: 10px;
- :deep(.el-input__inner) {
- height: 32px;
- line-height: 32px;
- border-radius: 4px;
- border: 1px solid #e4e7ed;
- background: #dee7ff;
- color: #606266;
- font-size: 14px;
- }
- :deep(.el-input__suffix) {
- right: 6px;
- width: 15px;
- height: 20px;
- display: flex;
- justify-content: center;
- align-items: center;
- top: 6px;
- border-radius: 4px;
- }
- :deep(.el-input__suffix-inner) {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 100%;
- }
- :deep(.el-icon-arrow-up:before) {
- content: "";
- display: inline-block;
- border-left: 6px solid transparent;
- border-right: 6px solid transparent;
- border-top: 9px solid #606266;
- position: relative;
- transform: rotate(0deg);
- transition: transform 0.3s;
- }
- }
- :deep(.el-table) {
- .el-table__body-wrapper {
- transition: height 0.3s ease;
- }
- }
- .el-table {
- // --table-max-height: calc(100vh - 40vh);
- max-height: var(--table-max-height);
- .el-table__body-wrapper {
- max-height: calc(var(--table-max-height) - 40px);
- }
- }
- :deep(.el-loading-mask) {
- background-color: rgba(255, 255, 255, 0.6) !important;
- backdrop-filter: blur(2px);
- }
- :deep(.el-loading-spinner .circular) {
- width: 28px;
- height: 28px;
- }
- :deep(.el-loading-spinner .path) {
- stroke: #6b8cff;
- }
- :deep(.el-loading-text) {
- color: #6b8cff !important;
- font-size: 14px;
- margin-top: 8px;
- }
- </style>
|