mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
Merge branch 'main' into server-connect-api
This commit is contained in:
commit
06bd1ac5a9
14 changed files with 725 additions and 393 deletions
|
|
@ -3,7 +3,6 @@ package xiaozhi.modules.sys.controller;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
|
@ -95,11 +94,11 @@ public class SysParamsController {
|
|||
return new Result<Void>();
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@PostMapping("/delete")
|
||||
@Operation(summary = "删除")
|
||||
@LogOperation("删除")
|
||||
@RequiresPermissions("sys:role:superAdmin")
|
||||
public Result<Void> delete(@RequestBody Long[] ids) {
|
||||
public Result<Void> delete(@RequestBody String[] ids) {
|
||||
// 效验数据
|
||||
AssertUtils.isArrayEmpty(ids, "id");
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public interface SysParamsDao extends BaseDao<SysParamsEntity> {
|
|||
* @param ids ids
|
||||
* @return 返回参数编码列表
|
||||
*/
|
||||
List<String> getParamCodeList(Long[] ids);
|
||||
List<String> getParamCodeList(String[] ids);
|
||||
|
||||
/**
|
||||
* 根据参数编码,更新value
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public interface SysParamsService extends BaseService<SysParamsEntity> {
|
|||
|
||||
void update(SysParamsDTO dto);
|
||||
|
||||
void delete(Long[] ids);
|
||||
void delete(String[] ids);
|
||||
|
||||
/**
|
||||
* 根据参数编码,获取参数的value值
|
||||
|
|
|
|||
|
|
@ -139,11 +139,13 @@ public class SysParamsServiceImpl extends BaseServiceImpl<SysParamsDao, SysParam
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Long[] ids) {
|
||||
public void delete(String[] ids) {
|
||||
// 删除Redis数据
|
||||
List<String> paramCodeList = baseDao.getParamCodeList(ids);
|
||||
String[] paramCodes = paramCodeList.toArray(new String[paramCodeList.size()]);
|
||||
sysParamsRedis.delete(paramCodes);
|
||||
if (paramCodes.length > 0) {
|
||||
sysParamsRedis.delete(paramCodes);
|
||||
}
|
||||
|
||||
// 删除
|
||||
deleteBatchIds(Arrays.asList(ids));
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package xiaozhi.modules.timbre.controller;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
|
@ -82,7 +81,7 @@ public class TimbreController {
|
|||
return new Result<>();
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@PostMapping("/delete")
|
||||
@Operation(summary = "音色删除")
|
||||
@RequiresPermissions("sys:role:superAdmin")
|
||||
public Result<Void> delete(@RequestBody String[] ids) {
|
||||
|
|
|
|||
|
|
@ -57,10 +57,12 @@ export default {
|
|||
})
|
||||
}).send()
|
||||
},
|
||||
// 获取参数列表
|
||||
getParamsList(params, callback) {
|
||||
const queryParams = new URLSearchParams({
|
||||
page: params.page,
|
||||
limit: params.limit
|
||||
limit: params.limit,
|
||||
paramCode: params.paramCode || ''
|
||||
}).toString();
|
||||
|
||||
RequestService.sendRequest()
|
||||
|
|
@ -77,6 +79,7 @@ export default {
|
|||
})
|
||||
}).send()
|
||||
},
|
||||
// 保存
|
||||
addParam(data, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/admin/params`)
|
||||
|
|
@ -93,6 +96,7 @@ export default {
|
|||
})
|
||||
}).send()
|
||||
},
|
||||
// 修改
|
||||
updateParam(data, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/admin/params`)
|
||||
|
|
@ -109,36 +113,22 @@ export default {
|
|||
})
|
||||
}).send()
|
||||
},
|
||||
deleteParam(id, callback) {
|
||||
// 删除
|
||||
deleteParam(ids, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/admin/params`)
|
||||
.method('DELETE')
|
||||
.data({ ids: [id] })
|
||||
.url(`${getServiceUrl()}/admin/params/delete`)
|
||||
.method('POST')
|
||||
.data(ids)
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime()
|
||||
callback(res)
|
||||
callback(res);
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('删除参数失败:', err)
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.deleteParam(id, callback)
|
||||
this.deleteParam(ids, callback)
|
||||
})
|
||||
}).send()
|
||||
},
|
||||
batchDeleteParams(ids, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/admin/params`)
|
||||
.method('DELETE')
|
||||
.data({ ids })
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime()
|
||||
callback(res)
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('批量删除参数失败:', err)
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.batchDeleteParams(ids, callback)
|
||||
})
|
||||
}).send()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
// timbre.js
|
||||
import {getServiceUrl} from '../api';
|
||||
import RequestService from '../httpRequest';
|
||||
|
||||
export default {
|
||||
/**
|
||||
* 获取音色数据
|
||||
*/
|
||||
// 获取音色
|
||||
getVoiceList(params, callback) {
|
||||
const queryParams = new URLSearchParams({
|
||||
ttsModelId: params.ttsModelId,
|
||||
|
|
@ -28,9 +25,7 @@ export default {
|
|||
});
|
||||
}).send();
|
||||
},
|
||||
/**
|
||||
* 音色保存
|
||||
*/
|
||||
// 音色保存
|
||||
saveVoice(params, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/ttsVoice`)
|
||||
|
|
@ -54,15 +49,12 @@ export default {
|
|||
});
|
||||
}).send();
|
||||
},
|
||||
/**
|
||||
* 音色删除
|
||||
*/
|
||||
deleteVoice(id, callback) {
|
||||
console.log('尝试删除音色,ID:', id);
|
||||
// 音色删除
|
||||
deleteVoice(ids, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/ttsVoice`)
|
||||
.method('DELETE')
|
||||
.data({ ids: [id] })
|
||||
.url(`${getServiceUrl()}/ttsVoice/delete`)
|
||||
.method('POST')
|
||||
.data(ids)
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime()
|
||||
callback(res);
|
||||
|
|
@ -70,13 +62,11 @@ export default {
|
|||
.fail((err) => {
|
||||
console.error('删除音色失败:', err);
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.deleteVoice(id, callback);
|
||||
this.deleteVoice(ids, callback);
|
||||
});
|
||||
}).send();
|
||||
},
|
||||
/**
|
||||
* 音色修改
|
||||
*/
|
||||
// 音色修改
|
||||
updateVoice(params, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/ttsVoice/${params.id}`)
|
||||
|
|
|
|||
|
|
@ -106,7 +106,8 @@ export default {
|
|||
},
|
||||
// 修改用户状态
|
||||
changeUserStatus(status, userIds, successCallback) {
|
||||
return RequestService.sendRequest()
|
||||
console.log(555,userIds)
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/admin/users/changeStatus/${status}`)
|
||||
.method('put')
|
||||
.data(userIds)
|
||||
|
|
|
|||
|
|
@ -95,23 +95,11 @@
|
|||
import Api from '@/apis/api';
|
||||
|
||||
const DEFAULT_CONFIG_JSON = {
|
||||
type: "",
|
||||
base_url: "",
|
||||
model_name: "",
|
||||
api_key: "",
|
||||
raw: {},
|
||||
config: {
|
||||
keyComparator: {},
|
||||
ignoreError: false,
|
||||
ignoreCase: false,
|
||||
dateFormat: "",
|
||||
ignoreNullValue: false,
|
||||
transientSupport: false,
|
||||
stripTrailingZeros: false,
|
||||
checkDuplicate: false,
|
||||
order: false
|
||||
},
|
||||
empty: false
|
||||
type: "",
|
||||
base_url: "",
|
||||
model_name: "",
|
||||
api_key: "",
|
||||
empty: false
|
||||
};
|
||||
|
||||
export default {
|
||||
|
|
@ -185,60 +173,54 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
resetForm() {
|
||||
this.form = {
|
||||
id: "",
|
||||
modelType: "",
|
||||
modelCode: "",
|
||||
modelName: "",
|
||||
isDefault: false,
|
||||
isEnabled: false,
|
||||
docLink: "",
|
||||
remark: "",
|
||||
sort: "",
|
||||
configJson: JSON.parse(JSON.stringify(DEFAULT_CONFIG_JSON))
|
||||
};
|
||||
this.form = {
|
||||
id: "",
|
||||
modelType: "",
|
||||
modelCode: "",
|
||||
modelName: "",
|
||||
isDefault: false,
|
||||
isEnabled: false,
|
||||
docLink: "",
|
||||
remark: "",
|
||||
sort: 0,
|
||||
configJson: JSON.parse(JSON.stringify(DEFAULT_CONFIG_JSON))
|
||||
};
|
||||
},
|
||||
resetProviders() {
|
||||
this.providers = [];
|
||||
this.providersLoaded = false;
|
||||
},
|
||||
loadModelData() {
|
||||
if (this.modelData.id) {
|
||||
Api.model.getModelConfig(this.modelData.id, ({ data }) => {
|
||||
if (data.code === 0 && data.data) {
|
||||
const model = data.data;
|
||||
this.pendingProviderType = model.configJson.type;
|
||||
this.pendingModelData = model;
|
||||
if (this.modelData.id) {
|
||||
Api.model.getModelConfig(this.modelData.id, ({ data }) => {
|
||||
if (data.code === 0 && data.data) {
|
||||
const model = data.data;
|
||||
this.pendingProviderType = model.configJson.type;
|
||||
this.pendingModelData = model;
|
||||
|
||||
if (this.providersLoaded) {
|
||||
this.loadProviderFields(model.configJson.type);
|
||||
} else {
|
||||
this.loadProviders();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (this.providersLoaded) {
|
||||
this.loadProviderFields(model.configJson.type);
|
||||
} else {
|
||||
this.loadProviders();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
handleSave() {
|
||||
const provideCode = this.form.configJson.type;
|
||||
const { provider, ...restConfigJson } = this.form.configJson;
|
||||
const formData = {
|
||||
id: this.form.id,
|
||||
modelCode: this.form.modelCode,
|
||||
modelName: this.form.modelName,
|
||||
isDefault: this.form.isDefault ? 1 : 0,
|
||||
isEnabled: this.form.isEnabled ? 1 : 0,
|
||||
docLink: this.form.docLink,
|
||||
remark: this.form.remark,
|
||||
sort: this.form.sort || 0,
|
||||
configJson: {
|
||||
...restConfigJson,
|
||||
config: {
|
||||
...restConfigJson.config,
|
||||
ignoreError: !!restConfigJson.config?.ignoreError,
|
||||
ignoreCase: !!restConfigJson.config?.ignoreCase,
|
||||
const provideCode = this.form.configJson.type;
|
||||
const formData = {
|
||||
id: this.modelData.id,
|
||||
modelCode: this.form.modelCode,
|
||||
modelName: this.form.modelName,
|
||||
isDefault: this.form.isDefault ? 1 : 0,
|
||||
isEnabled: this.form.isEnabled ? 1 : 0,
|
||||
docLink: this.form.docLink,
|
||||
remark: this.form.remark,
|
||||
sort: this.form.sort || 0,
|
||||
configJson: {
|
||||
...this.form.configJson,
|
||||
}
|
||||
}
|
||||
};
|
||||
this.$emit("save", { provideCode, formData });
|
||||
this.dialogVisible = false;
|
||||
|
|
@ -249,7 +231,7 @@ export default {
|
|||
Api.model.getModelProviders(this.modelType, (data) => {
|
||||
this.providers = data.map(item => ({
|
||||
label: item.name,
|
||||
value: item.providerCode
|
||||
value: String(item.providerCode)
|
||||
}));
|
||||
this.providersLoaded = true;
|
||||
|
||||
|
|
@ -288,26 +270,21 @@ export default {
|
|||
});
|
||||
|
||||
this.form = {
|
||||
id: model.id || "",
|
||||
modelType: model.modelType || "",
|
||||
modelCode: model.modelCode || "",
|
||||
modelName: model.modelName || "",
|
||||
isDefault: model.isDefault || 0,
|
||||
isEnabled: model.isEnabled || 0,
|
||||
docLink: model.docLink || "",
|
||||
remark: model.remark || "",
|
||||
id: model.id,
|
||||
modelType: model.modelType,
|
||||
modelCode: model.modelCode,
|
||||
modelName: model.modelName,
|
||||
isDefault: model.isDefault,
|
||||
isEnabled: model.isEnabled,
|
||||
docLink: model.docLink,
|
||||
remark: model.remark,
|
||||
sort: Number(model.sort) || 0,
|
||||
configJson: {
|
||||
...JSON.parse(JSON.stringify(DEFAULT_CONFIG_JSON)),
|
||||
...configJson,
|
||||
config: {
|
||||
...DEFAULT_CONFIG_JSON.config,
|
||||
...(configJson.config || {})
|
||||
}
|
||||
...DEFAULT_CONFIG_JSON,
|
||||
...configJson
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
347
main/manager-web/src/components/ParamDialog.vue
Normal file
347
main/manager-web/src/components/ParamDialog.vue
Normal file
|
|
@ -0,0 +1,347 @@
|
|||
<template>
|
||||
<el-dialog :title="title"
|
||||
:visible.sync="visible"
|
||||
width="520px"
|
||||
class="param-dialog-wrapper"
|
||||
:append-to-body="true"
|
||||
:close-on-click-modal="false"
|
||||
:key="dialogKey"
|
||||
custom-class="custom-param-dialog"
|
||||
:show-close="false"
|
||||
>
|
||||
<div class="dialog-container">
|
||||
<div class="dialog-header">
|
||||
<h2 class="dialog-title">{{ title }}</h2>
|
||||
<button class="custom-close-btn" @click="cancel">
|
||||
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M13 1L1 13M1 1L13 13" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<el-form :model="form" :rules="rules" ref="form" label-width="110px" label-position="left" class="param-form">
|
||||
<el-form-item label="参数编码" prop="paramCode" class="form-item">
|
||||
<el-input v-model="form.paramCode" placeholder="请输入参数编码" class="custom-input"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="参数值" prop="paramValue" class="form-item">
|
||||
<el-input v-model="form.paramValue" placeholder="请输入参数值" class="custom-input"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="值类型" prop="valueType" class="form-item">
|
||||
<el-select v-model="form.valueType" placeholder="请选择值类型" class="custom-select">
|
||||
<el-option v-for="item in valueTypeOptions" :key="item.value" :label="item.label" :value="item.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="备注" prop="remark" class="form-item remark-item">
|
||||
<el-input type="textarea" v-model="form.remark" placeholder="请输入备注" :rows="3" class="custom-textarea"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submit" class="save-btn">
|
||||
保存
|
||||
</el-button>
|
||||
<el-button @click="cancel" class="cancel-btn">
|
||||
取消
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
default: '新增参数'
|
||||
},
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
form: {
|
||||
type: Object,
|
||||
default: () => ({
|
||||
id: null,
|
||||
paramCode: '',
|
||||
paramValue: '',
|
||||
valueType: 'string',
|
||||
remark: ''
|
||||
})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogKey: Date.now(),
|
||||
valueTypeOptions: [
|
||||
{ value: 'string', label: '字符串(string)' },
|
||||
{ value: 'number', label: '数字(number)' },
|
||||
{ value: 'boolean', label: '布尔值(boolean)' },
|
||||
{ value: 'array', label: '数组(array)' },
|
||||
{ value: 'json', label: 'JSON对象(json)' }
|
||||
],
|
||||
rules: {
|
||||
paramCode: [
|
||||
{ required: true, message: "请输入参数编码", trigger: "blur" }
|
||||
],
|
||||
paramValue: [
|
||||
{ required: true, message: "请输入参数值", trigger: "blur" }
|
||||
],
|
||||
valueType: [
|
||||
{ required: true, message: "请选择值类型", trigger: "change" }
|
||||
]
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
this.$emit('submit', this.form);
|
||||
}
|
||||
});
|
||||
},
|
||||
cancel() {
|
||||
this.$emit('cancel');
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
visible(newVal) {
|
||||
if (newVal) {
|
||||
this.dialogKey = Date.now();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.custom-param-dialog {
|
||||
border-radius: 16px !important;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
|
||||
border: none !important;
|
||||
|
||||
.el-dialog__header {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.el-dialog__body {
|
||||
padding: 0 !important;
|
||||
border-radius: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.param-dialog-wrapper {
|
||||
.dialog-container {
|
||||
padding: 24px 32px;
|
||||
background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
|
||||
}
|
||||
|
||||
.dialog-header {
|
||||
position: relative;
|
||||
margin-bottom: 24px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.dialog-title {
|
||||
font-size: 20px;
|
||||
color: #1e293b;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.custom-close-btn {
|
||||
position: absolute;
|
||||
top: -8px;
|
||||
right: -8px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 50%;
|
||||
border: none;
|
||||
background: #f1f5f9;
|
||||
color: #64748b;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
outline: none;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
|
||||
&:hover {
|
||||
color: #ffffff;
|
||||
background: #ef4444;
|
||||
transform: rotate(90deg);
|
||||
box-shadow: 0 4px 6px rgba(239, 68, 68, 0.2);
|
||||
}
|
||||
|
||||
svg {
|
||||
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
}
|
||||
|
||||
.param-form {
|
||||
.form-item {
|
||||
margin-bottom: 20px;
|
||||
|
||||
:deep(.el-form-item__label) {
|
||||
color: #475569;
|
||||
font-weight: 500;
|
||||
padding-right: 12px;
|
||||
text-align: right;
|
||||
font-size: 14px;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
}
|
||||
|
||||
.custom-input {
|
||||
:deep(.el-input__inner) {
|
||||
background-color: #ffffff;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #e2e8f0;
|
||||
height: 42px;
|
||||
padding: 0 14px;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
font-size: 14px;
|
||||
color: #334155;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
|
||||
&:focus {
|
||||
border-color: #3b82f6;
|
||||
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
&::placeholder {
|
||||
color: #94a3b8;
|
||||
font-weight: 400;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.custom-select {
|
||||
width: 100%;
|
||||
|
||||
:deep(.el-input__inner) {
|
||||
background-color: #ffffff;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #e2e8f0;
|
||||
height: 42px;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
font-size: 14px;
|
||||
color: #334155;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
|
||||
&:focus {
|
||||
border-color: #3b82f6;
|
||||
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
&::placeholder {
|
||||
color: #94a3b8;
|
||||
font-weight: 400;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.custom-textarea {
|
||||
:deep(.el-textarea__inner) {
|
||||
background-color: #ffffff;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #e2e8f0;
|
||||
padding: 12px 14px;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
font-size: 14px;
|
||||
color: #334155;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
line-height: 1.5;
|
||||
|
||||
&:focus {
|
||||
border-color: #3b82f6;
|
||||
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
&::placeholder {
|
||||
color: #94a3b8;
|
||||
font-weight: 400;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.remark-item :deep(.el-form-item__label) {
|
||||
margin-top: -4px;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 16px 0 0;
|
||||
margin-top: 16px;
|
||||
|
||||
.save-btn {
|
||||
width: 120px;
|
||||
height: 42px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
border-radius: 8px;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
background: #3b82f6;
|
||||
color: white;
|
||||
border: none;
|
||||
letter-spacing: 0.5px;
|
||||
box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
|
||||
|
||||
&:hover {
|
||||
background: #2563eb;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 6px rgba(59, 130, 246, 0.3);
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: translateY(0);
|
||||
box-shadow: 0 2px 3px rgba(59, 130, 246, 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
.cancel-btn {
|
||||
width: 120px;
|
||||
height: 42px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
border-radius: 8px;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
background: #ffffff;
|
||||
color: #64748b;
|
||||
border: 1px solid #e2e8f0;
|
||||
margin-left: 16px;
|
||||
letter-spacing: 0.5px;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
|
||||
&:hover {
|
||||
background: #f8fafc;
|
||||
color: #475569;
|
||||
border-color: #cbd5e1;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: translateY(0);
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<el-dialog
|
||||
:visible.sync="localVisible"
|
||||
width="75%"
|
||||
width="85%"
|
||||
@close="handleClose"
|
||||
:show-close="false"
|
||||
:append-to-body="true"
|
||||
|
|
@ -13,8 +13,7 @@
|
|||
<div
|
||||
class="table-container"
|
||||
ref="tableContainer"
|
||||
@scroll="handleScroll"
|
||||
>
|
||||
@scroll="handleScroll">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="filteredTtsModels"
|
||||
|
|
@ -45,7 +44,7 @@
|
|||
<span v-else>{{ scope.row.languageType }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="试听" align="center" min-width="225" class-name="audio-column">
|
||||
<el-table-column label="试听" align="center" min-width="100px" class-name="audio-column">
|
||||
<template slot-scope="scope">
|
||||
<div class="custom-audio-container">
|
||||
<el-input
|
||||
|
|
@ -53,13 +52,13 @@
|
|||
v-model="scope.row.voiceDemo"
|
||||
placeholder="请输入MP3地址"
|
||||
size="mini"
|
||||
class="audio-input"
|
||||
></el-input>
|
||||
class="audio-input">
|
||||
</el-input>
|
||||
<AudioPlayer v-else-if="isValidAudioUrl(scope.row.voiceDemo)" :audioUrl="scope.row.voiceDemo"/>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" min-width="120">
|
||||
<el-table-column label="备注" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
v-if="scope.row.editing"
|
||||
|
|
@ -75,10 +74,10 @@
|
|||
<el-table-column label="操作" align="center" width="150">
|
||||
<template slot-scope="scope">
|
||||
<template v-if="!scope.row.editing">
|
||||
<el-button type="primary" size="mini" @click="startEdit(scope.row)"
|
||||
style="background: #5cca8e;border:None">编辑
|
||||
<el-button type="text" size="mini" @click="startEdit(scope.row)" class="edit-btn">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button type="primary" size="mini" @click="deleteRow(scope.row)" style="background: red;border:None">
|
||||
<el-button type="text" size="mini" @click="deleteRow(scope.row)" class="delete-btn">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
|
|
@ -105,10 +104,14 @@
|
|||
<el-button type="primary" size="mini" @click="toggleSelectAll" style="background: #606ff3;border: None">
|
||||
{{ selectAll ? '取消全选' : '全选' }}
|
||||
</el-button>
|
||||
<el-button type="primary" size="mini" @click="addNew" style="background: #f6cf79;border: None; color: #000012">
|
||||
<el-button type="primary" size="mini" @click="addNew" style="background: #5bc98c;border: None;">
|
||||
新增
|
||||
</el-button>
|
||||
<el-button type="primary" size="mini" @click="batchDelete" style="background: red;border:None">删除</el-button>
|
||||
<el-button type="primary"
|
||||
size="mini"
|
||||
@click="deleteRow(filteredTtsModels.filter(row => row.selected))"
|
||||
style="background: red;border:None">删除
|
||||
</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
|
@ -419,105 +422,57 @@ export default {
|
|||
},
|
||||
|
||||
deleteRow(row) {
|
||||
this.$confirm("确定要删除该音色吗?", "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
})
|
||||
.then(() => {
|
||||
Api.timbre.deleteVoice(row.id, (response) => {
|
||||
if (response.code === 0) {
|
||||
this.$message.success({
|
||||
message: "删除成功",
|
||||
showClose: true
|
||||
});
|
||||
this.loadData(); // 刷新数据
|
||||
} else {
|
||||
this.$message.error({
|
||||
message: response.msg || "删除失败",
|
||||
showClose: true
|
||||
});
|
||||
// 处理单个音色或音色数组
|
||||
const voices = Array.isArray(row) ? row : [row];
|
||||
|
||||
if (Array.isArray(row) && row.length === 0) {
|
||||
this.$message.warning("请先选择需要删除的音色");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const voiceCount = voices.length;
|
||||
this.$confirm(`确定要删除选中的${voiceCount}个音色吗?`, "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
distinguishCancelAndClose: true
|
||||
}).then(() => {
|
||||
const ids = voices.map(voice => voice.id);
|
||||
if (ids.some(id => !id)) {
|
||||
this.$message.error("存在无效的音色ID");
|
||||
return;
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
this.$message.info("已取消删除");
|
||||
});
|
||||
},
|
||||
|
||||
batchDelete() {
|
||||
const selectedRows = this.filteredTtsModels.filter(row => row.selected);
|
||||
if (selectedRows.length === 0) {
|
||||
this.$message.warning("请先选择需要删除的音色");
|
||||
return;
|
||||
}
|
||||
|
||||
this.$confirm(`确定要删除选中的${selectedRows.length}个音色吗?`, "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
})
|
||||
.then(async () => {
|
||||
const loading = this.$loading({
|
||||
lock: true,
|
||||
text: "正在删除中...",
|
||||
spinner: "el-icon-loading",
|
||||
background: "rgba(0, 0, 0, 0.7)",
|
||||
});
|
||||
|
||||
try {
|
||||
const results = await Promise.all(
|
||||
selectedRows.map((row) => {
|
||||
return new Promise((resolve) => {
|
||||
Api.timbre.deleteVoice(row.id, (response) => {
|
||||
if (response.code === 0) {
|
||||
resolve({ success: true, id: row.id });
|
||||
} else {
|
||||
resolve({
|
||||
success: false,
|
||||
id: row.id,
|
||||
msg: response.msg || '删除失败'
|
||||
});
|
||||
}
|
||||
});
|
||||
Api.timbre.deleteVoice(ids, ({data}) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success({
|
||||
message: `成功删除${voiceCount}个参数`,
|
||||
showClose: true
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
const successCount = results.filter(r => r.success).length;
|
||||
const failCount = results.length - successCount;
|
||||
|
||||
if (failCount === 0) {
|
||||
this.$message.success({
|
||||
message: `成功删除${successCount}个音色`,
|
||||
showClose: true
|
||||
});
|
||||
} else if (successCount === 0) {
|
||||
this.$message.error({
|
||||
message: '删除失败,请重试',
|
||||
showClose: true
|
||||
});
|
||||
this.loadData(); // 刷新参数列表
|
||||
} else {
|
||||
this.$message.warning({
|
||||
message: `成功删除${successCount}个音色,${failCount}个删除失败`,
|
||||
showClose: true
|
||||
});
|
||||
this.$message.error({
|
||||
message: data.msg || '删除失败,请重试',
|
||||
showClose: true
|
||||
});
|
||||
}
|
||||
|
||||
this.loadData(); // 刷新数据
|
||||
} catch (error) {
|
||||
console.error('批量删除出错:', error);
|
||||
this.$message.error({
|
||||
message: '删除过程中发生错误',
|
||||
showClose: true
|
||||
});
|
||||
} finally {
|
||||
loading.close();
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.$message.info("已取消删除");
|
||||
});
|
||||
}).catch(action => {
|
||||
if (action === 'cancel') {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '已取消删除操作',
|
||||
duration: 1000
|
||||
});
|
||||
} else {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '操作已关闭',
|
||||
duration: 1000
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
isValidAudioUrl(url) {
|
||||
|
|
@ -532,7 +487,7 @@ export default {
|
|||
::v-deep .el-dialog {
|
||||
border-radius: 8px !important;
|
||||
overflow: hidden;
|
||||
top: 8vh !important;
|
||||
top: 1vh !important;
|
||||
}
|
||||
|
||||
::v-deep .el-dialog__header {
|
||||
|
|
@ -628,13 +583,13 @@ export default {
|
|||
.table-container {
|
||||
flex: 1;
|
||||
overflow-y: scroll;
|
||||
scrollbar-width: none; /* Firefox */
|
||||
padding-right: 15px; /* 为滚动条留出空间 */
|
||||
width: calc(100% - 16px); /* 减去滚动条宽度 */
|
||||
scrollbar-width: none;
|
||||
padding-right: 15px;
|
||||
width: calc(100% - 16px);
|
||||
}
|
||||
|
||||
.table-container::-webkit-scrollbar {
|
||||
display: none; /* Chrome/Safari */
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* 自定义滚动条 */
|
||||
|
|
@ -684,10 +639,33 @@ export default {
|
|||
display: none;
|
||||
}
|
||||
|
||||
/* 音频播放器容器样式 */
|
||||
.custom-audio-container {
|
||||
width: 280px;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
/* 新增按钮组样式 */
|
||||
.action-buttons {
|
||||
bottom: 20px;
|
||||
padding-top: 10px;
|
||||
}
|
||||
.edit-btn,
|
||||
.delete-btn,
|
||||
.save-btn {
|
||||
margin: 0 8px;
|
||||
color: #7079aa !important;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.edit-btn:hover,
|
||||
.delete-btn:hover,
|
||||
.save-btn:hover {
|
||||
color: #5f70f3 !important;
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.save-btn {
|
||||
color: #5cca8e !important;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -3,7 +3,22 @@
|
|||
<HeaderBar />
|
||||
|
||||
<div class="operation-bar">
|
||||
<h2 class="page-title">模型配置</h2>
|
||||
<h2 class="page-title">{{ modelTypeText }}</h2>
|
||||
<div class="action-group">
|
||||
<div class="search-group">
|
||||
<el-input
|
||||
placeholder="请输入模型名称查询"
|
||||
v-model="search"
|
||||
class="search-input"
|
||||
clearable
|
||||
@keyup.enter.native="handleSearch"
|
||||
style="width: 240px"
|
||||
/>
|
||||
<el-button class="btn-search" @click="handleSearch">
|
||||
搜索
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 主体内容 -->
|
||||
|
|
@ -34,24 +49,6 @@
|
|||
|
||||
<!-- 右侧内容 -->
|
||||
<div class="content-area">
|
||||
<div class="title-bar">
|
||||
<div class="title-wrapper">
|
||||
<h2 class="model-title">{{ modelTypeText }}</h2>
|
||||
<el-button type="primary" size="small" @click="addModel" class="add-btn">
|
||||
添加
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="action-group">
|
||||
<div class="search-group">
|
||||
<el-input placeholder="请输入模型名称查询" v-model="search" size="small" class="search-input" clearable
|
||||
@keyup.enter.native="handleSearch" />
|
||||
<el-button type="primary" size="small" class="search-btn" @click="handleSearch">
|
||||
查询
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-table ref="modelTable" style="width: 100%" :header-cell-style="{ background: 'transparent' }"
|
||||
:data="modelList" class="data-table" header-row-class-name="table-header"
|
||||
:header-cell-class-name="headerCellClassName" @selection-change="handleSelectionChange">
|
||||
|
|
@ -96,9 +93,13 @@
|
|||
|
||||
<div class="table-footer">
|
||||
<div class="batch-actions">
|
||||
<el-button size="mini" @click="selectAll" style="width: 75px; background: #606ff3">{{ isAllSelected ?
|
||||
'取消全选' : '全选'
|
||||
}}</el-button>
|
||||
<el-button size="mini" type="primary" @click="selectAll" >
|
||||
{{ isAllSelected ?
|
||||
'取消全选' : '全选' }}
|
||||
</el-button>
|
||||
<el-button type="success" size="mini" @click="addModel" class="add-btn">
|
||||
新增
|
||||
</el-button>
|
||||
<el-button size="mini" type="danger" icon="el-icon-delete" @click="batchDelete">
|
||||
删除
|
||||
</el-button>
|
||||
|
|
@ -453,7 +454,7 @@ export default {
|
|||
}
|
||||
|
||||
.main-wrapper {
|
||||
margin: 5px 20px;
|
||||
margin: 5px 22px;
|
||||
border-radius: 15px;
|
||||
min-height: 600px;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
||||
|
|
@ -514,7 +515,7 @@ export default {
|
|||
justify-content: flex-end;
|
||||
padding-right: 12px !important;
|
||||
width: fit-content;
|
||||
margin: 8px 0px 8px auto;
|
||||
margin: 8px 0 8px auto;
|
||||
min-width: unset;
|
||||
}
|
||||
|
||||
|
|
@ -564,12 +565,6 @@ export default {
|
|||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.model-title {
|
||||
font-size: 18px;
|
||||
color: #303133;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.action-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
@ -578,28 +573,42 @@ export default {
|
|||
|
||||
.search-group {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
width: 240px;
|
||||
}
|
||||
|
||||
::v-deep .search-input .el-input__inner::placeholder {
|
||||
color: black;
|
||||
opacity: 0.6;
|
||||
.btn-search {
|
||||
background: linear-gradient(135deg, #6b8cff, #a966ff);
|
||||
border: none;
|
||||
color: white;
|
||||
}
|
||||
|
||||
::v-deep .search-input .el-input__inner {
|
||||
background: transparent;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #DCDFE6;
|
||||
background-color: white;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
|
||||
.search-btn {
|
||||
background: linear-gradient(135deg, #6B8CFF, #A966FF);
|
||||
::v-deep .search-input .el-input__inner:focus {
|
||||
border-color: #6b8cff;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.btn-search {
|
||||
background: linear-gradient(135deg, #6b8cff, #a966ff);
|
||||
border: none;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-search:hover {
|
||||
opacity: 0.9;
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.data-table {
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
|
|
@ -644,20 +653,45 @@ export default {
|
|||
width: 100%;
|
||||
}
|
||||
|
||||
.add-btn {
|
||||
background: #cce5f9;
|
||||
width: 75px;
|
||||
border: none;
|
||||
color: black;
|
||||
padding: 8px 16px;
|
||||
}
|
||||
|
||||
.title-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.batch-actions .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);
|
||||
}
|
||||
|
||||
.batch-actions .el-button:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.batch-actions .el-button--primary {
|
||||
background: #5f70f3 !important;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.batch-actions .el-button--success {
|
||||
background: #5bc98c;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.batch-actions .el-button--danger {
|
||||
background: #fd5b63;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.batch-actions .el-button:first-child {
|
||||
background: linear-gradient(135deg, #409EFF, #6B8CFF);
|
||||
border: none;
|
||||
|
|
@ -683,7 +717,6 @@ export default {
|
|||
|
||||
::v-deep .el-table .custom-selection-header .cell .el-checkbox__inner {
|
||||
display: none !important;
|
||||
/* 使表头复选框不可见 */
|
||||
}
|
||||
|
||||
::v-deep .el-table .custom-selection-header .cell::before {
|
||||
|
|
@ -738,8 +771,8 @@ export default {
|
|||
}
|
||||
|
||||
::v-deep .el-checkbox__input.is-checked .el-checkbox__inner {
|
||||
background-color: #409EFF !important;
|
||||
border-color: #409EFF !important;
|
||||
background-color: #5f70f3;
|
||||
border-color: #5f70f3;
|
||||
}
|
||||
|
||||
.voice-management-btn {
|
||||
|
|
|
|||
|
|
@ -6,9 +6,8 @@
|
|||
<h2 class="page-title">参数管理</h2>
|
||||
<div class="right-operations">
|
||||
<el-input placeholder="请输入参数编码查询" v-model="searchCode" class="search-input"
|
||||
@keyup.enter.native="handleSearch" />
|
||||
@keyup.enter.native="handleSearch" clearable />
|
||||
<el-button class="btn-search" @click="handleSearch">搜索</el-button>
|
||||
<el-button type="primary" @click="showAddDialog">新增参数</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -32,10 +31,12 @@
|
|||
|
||||
<div class="table_bottom">
|
||||
<div class="ctrl_btn">
|
||||
<el-button size="mini" type="primary" class="select-all-btn"
|
||||
@click="handleSelectAll">全选</el-button>
|
||||
<el-button size="mini" type="primary" class="select-all-btn" @click="handleSelectAll">
|
||||
{{ isAllSelected ? '取消全选' : '全选' }}
|
||||
</el-button>
|
||||
<el-button size="mini" type="success" @click="showAddDialog">新增</el-button>
|
||||
<el-button size="mini" type="danger" icon="el-icon-delete"
|
||||
@click="batchDelete">删除</el-button>
|
||||
@click="deleteParam($refs.paramsTable.selection)">删除</el-button>
|
||||
</div>
|
||||
<div class="custom-pagination">
|
||||
<button class="pagination-btn" :disabled="currentPage === 1" @click="goFirst">
|
||||
|
|
@ -60,23 +61,7 @@
|
|||
</div>
|
||||
|
||||
<!-- 新增/编辑参数对话框 -->
|
||||
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="500px">
|
||||
<el-form :model="paramForm" :rules="rules" ref="paramForm" label-width="100px">
|
||||
<el-form-item label="参数编码" prop="paramCode">
|
||||
<el-input v-model="paramForm.paramCode" placeholder="请输入参数编码"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="参数值" prop="paramValue">
|
||||
<el-input v-model="paramForm.paramValue" placeholder="请输入参数值"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input type="textarea" v-model="paramForm.remark" placeholder="请输入备注"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<param-dialog :title="dialogTitle" :visible.sync="dialogVisible" :form="paramForm" @submit="handleSubmit" @cancel="dialogVisible = false"/>
|
||||
|
||||
<div class="copyright">©2025 xiaozhi-esp32-server</div>
|
||||
</div>
|
||||
|
|
@ -85,9 +70,10 @@
|
|||
<script>
|
||||
import Api from "@/apis/api";
|
||||
import HeaderBar from "@/components/HeaderBar.vue";
|
||||
import ParamDialog from "@/components/ParamDialog.vue";
|
||||
|
||||
export default {
|
||||
components: { HeaderBar },
|
||||
components: { HeaderBar, ParamDialog },
|
||||
data() {
|
||||
return {
|
||||
searchCode: "",
|
||||
|
|
@ -97,20 +83,13 @@ export default {
|
|||
total: 0,
|
||||
dialogVisible: false,
|
||||
dialogTitle: "新增参数",
|
||||
isAllSelected: false,
|
||||
paramForm: {
|
||||
id: null,
|
||||
paramCode: "",
|
||||
paramValue: "",
|
||||
remark: ""
|
||||
},
|
||||
rules: {
|
||||
paramCode: [
|
||||
{ required: true, message: "请输入参数编码", trigger: "blur" }
|
||||
],
|
||||
paramValue: [
|
||||
{ required: true, message: "请输入参数值", trigger: "blur" }
|
||||
]
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
|
|
@ -148,6 +127,8 @@ export default {
|
|||
if (data.code === 0) {
|
||||
this.paramsList = data.data.list;
|
||||
this.total = data.data.total;
|
||||
} else {
|
||||
this.$message.error(data.msg || '获取参数列表失败');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
@ -157,7 +138,12 @@ export default {
|
|||
this.fetchParams();
|
||||
},
|
||||
handleSelectAll() {
|
||||
this.$refs.paramsTable.toggleAllSelection();
|
||||
if (this.isAllSelected) {
|
||||
this.$refs.paramsTable.clearSelection();
|
||||
} else {
|
||||
this.$refs.paramsTable.toggleAllSelection();
|
||||
}
|
||||
this.isAllSelected = !this.isAllSelected;
|
||||
},
|
||||
showAddDialog() {
|
||||
this.dialogTitle = "新增参数";
|
||||
|
|
@ -174,69 +160,79 @@ export default {
|
|||
this.paramForm = { ...row };
|
||||
this.dialogVisible = true;
|
||||
},
|
||||
submitForm() {
|
||||
this.$refs.paramForm.validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.paramForm.id) {
|
||||
// 编辑
|
||||
Api.admin.updateParam(this.paramForm, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success("修改成功");
|
||||
this.dialogVisible = false;
|
||||
this.fetchParams();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 新增
|
||||
Api.admin.addParam(this.paramForm, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success("新增成功");
|
||||
this.dialogVisible = false;
|
||||
this.fetchParams();
|
||||
}
|
||||
});
|
||||
handleSubmit(form) {
|
||||
if (form.id) {
|
||||
// 编辑
|
||||
Api.admin.updateParam(form, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success("修改成功");
|
||||
this.dialogVisible = false;
|
||||
this.fetchParams();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// 新增
|
||||
Api.admin.addParam(form, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success("新增成功");
|
||||
this.dialogVisible = false;
|
||||
this.fetchParams();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
deleteParam(row) {
|
||||
this.$confirm("确定要删除该参数吗?", "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
})
|
||||
.then(() => {
|
||||
Api.admin.deleteParam(row.id, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success("删除成功");
|
||||
this.fetchParams();
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(() => { });
|
||||
},
|
||||
batchDelete() {
|
||||
const selectedParams = this.$refs.paramsTable.selection;
|
||||
if (selectedParams.length === 0) {
|
||||
// 处理单个参数或参数数组
|
||||
const params = Array.isArray(row) ? row : [row];
|
||||
|
||||
if (Array.isArray(row) && row.length === 0) {
|
||||
this.$message.warning("请先选择需要删除的参数");
|
||||
return;
|
||||
}
|
||||
|
||||
this.$confirm(`确定要删除选中的${selectedParams.length}个参数吗?`, "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
})
|
||||
.then(() => {
|
||||
const ids = selectedParams.map(item => item.id);
|
||||
Api.admin.batchDeleteParams(ids, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success("删除成功");
|
||||
this.fetchParams();
|
||||
}
|
||||
|
||||
const paramCount = params.length;
|
||||
this.$confirm(`确定要删除选中的${paramCount}个参数吗?`, '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
distinguishCancelAndClose: true
|
||||
}).then(() => {
|
||||
const ids = params.map(param => param.id);
|
||||
if (ids.some(id => isNaN(id))) {
|
||||
this.$message.error('存在无效的参数ID');
|
||||
return;
|
||||
}
|
||||
|
||||
Api.admin.deleteParam(ids, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success({
|
||||
message: `成功删除${paramCount}个参数`,
|
||||
showClose: true
|
||||
});
|
||||
this.fetchParams(); // 刷新参数列表
|
||||
} else {
|
||||
this.$message.error({
|
||||
message: data.msg || '删除失败,请重试',
|
||||
showClose: true
|
||||
});
|
||||
}
|
||||
});
|
||||
}).catch(action => {
|
||||
if (action === 'cancel') {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '已取消删除操作',
|
||||
duration: 1000
|
||||
});
|
||||
})
|
||||
.catch(() => { });
|
||||
} else {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '操作已关闭',
|
||||
duration: 1000
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
headerCellClassName({ columnIndex }) {
|
||||
if (columnIndex === 0) {
|
||||
|
|
@ -513,24 +509,36 @@ export default {
|
|||
}
|
||||
|
||||
@media (min-width: 1144px) {
|
||||
.table_bottom {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: 40px;
|
||||
}
|
||||
.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;
|
||||
}
|
||||
:deep(.transparent-table) {
|
||||
.el-table__body tr {
|
||||
td {
|
||||
padding-top: 16px;
|
||||
padding-bottom: 16px;
|
||||
}
|
||||
|
||||
&+tr {
|
||||
margin-top: 10px;
|
||||
}
|
||||
}
|
||||
& + 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;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -41,7 +41,9 @@
|
|||
|
||||
<div class="table_bottom">
|
||||
<div class="ctrl_btn">
|
||||
<el-button size="mini" type="primary" class="select-all-btn" @click="handleSelectAll">全选</el-button>
|
||||
<el-button size="mini" type="primary" class="select-all-btn" @click="handleSelectAll">
|
||||
{{ isAllSelected ? '取消全选' : '全选' }}
|
||||
</el-button>
|
||||
<el-button size="mini" type="success" icon="el-icon-circle-check" @click="batchEnable">启用</el-button>
|
||||
<el-button size="mini" type="warning" @click="batchDisable"><i
|
||||
class="el-icon-remove-outline rotated-icon"></i>禁用</el-button>
|
||||
|
|
@ -89,6 +91,7 @@ export default {
|
|||
currentPage: 1,
|
||||
pageSize: 5,
|
||||
total: 0,
|
||||
isAllSelected: false
|
||||
};
|
||||
},
|
||||
created() {
|
||||
|
|
@ -135,7 +138,12 @@ export default {
|
|||
this.fetchUsers();
|
||||
},
|
||||
handleSelectAll() {
|
||||
this.$refs.userTable.toggleAllSelection();
|
||||
if (this.isAllSelected) {
|
||||
this.$refs.userTable.clearSelection();
|
||||
} else {
|
||||
this.$refs.userTable.toggleAllSelection();
|
||||
}
|
||||
this.isAllSelected = !this.isAllSelected;
|
||||
},
|
||||
batchDelete() {
|
||||
const selectedUsers = this.$refs.userTable.selection;
|
||||
|
|
|
|||
Loading…
Reference in a new issue