|
|
@ -14,13 +14,17 @@ |
|
|
|
{{ row.name }} |
|
|
|
{{ row.name }} |
|
|
|
<span v-if="row.default">({{ $t('website.default') }})</span> |
|
|
|
<span v-if="row.default">({{ $t('website.default') }})</span> |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
<el-input v-if="row.edit" v-model="row.name"></el-input> |
|
|
|
<el-form ref="groupForm" :model="row" :rules="rules"> |
|
|
|
|
|
|
|
<el-form-item prop="name" v-if="row.edit"> |
|
|
|
|
|
|
|
<el-input v-model="row.name"></el-input> |
|
|
|
|
|
|
|
</el-form-item> |
|
|
|
|
|
|
|
</el-form> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column :label="$t('commons.table.operate')"> |
|
|
|
<el-table-column :label="$t('commons.table.operate')"> |
|
|
|
<template #default="{ row, $index }"> |
|
|
|
<template #default="{ row, $index }"> |
|
|
|
<div> |
|
|
|
<div> |
|
|
|
<el-button link v-if="row.edit" type="primary" @click="saveGroup(row, false)"> |
|
|
|
<el-button link v-if="row.edit" type="primary" @click="saveGroup(groupForm, row, false)"> |
|
|
|
{{ $t('commons.button.save') }} |
|
|
|
{{ $t('commons.button.save') }} |
|
|
|
</el-button> |
|
|
|
</el-button> |
|
|
|
<el-button link v-if="!row.edit" type="primary" @click="editGroup($index)"> |
|
|
|
<el-button link v-if="!row.edit" type="primary" @click="editGroup($index)"> |
|
|
@ -38,7 +42,12 @@ |
|
|
|
<el-button link v-if="row.edit" type="primary" @click="cancelEdit($index)"> |
|
|
|
<el-button link v-if="row.edit" type="primary" @click="cancelEdit($index)"> |
|
|
|
{{ $t('commons.button.cancel') }} |
|
|
|
{{ $t('commons.button.cancel') }} |
|
|
|
</el-button> |
|
|
|
</el-button> |
|
|
|
<el-button link v-if="!row.edit && !row.default" type="primary" @click="saveGroup(row, true)"> |
|
|
|
<el-button |
|
|
|
|
|
|
|
link |
|
|
|
|
|
|
|
v-if="!row.edit && !row.default" |
|
|
|
|
|
|
|
type="primary" |
|
|
|
|
|
|
|
@click="saveGroup(groupForm, row, true)" |
|
|
|
|
|
|
|
> |
|
|
|
{{ $t('website.setDefault') }} |
|
|
|
{{ $t('website.setDefault') }} |
|
|
|
</el-button> |
|
|
|
</el-button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -54,6 +63,8 @@ import ComplexTable from '@/components/complex-table/index.vue'; |
|
|
|
import { ListGroups, CreateGroup, DeleteGroup, UpdateGroup } from '@/api/modules/website'; |
|
|
|
import { ListGroups, CreateGroup, DeleteGroup, UpdateGroup } from '@/api/modules/website'; |
|
|
|
import Header from '@/components/drawer-header/index.vue'; |
|
|
|
import Header from '@/components/drawer-header/index.vue'; |
|
|
|
import { MsgSuccess } from '@/utils/message'; |
|
|
|
import { MsgSuccess } from '@/utils/message'; |
|
|
|
|
|
|
|
import { Rules } from '@/global/form-rules'; |
|
|
|
|
|
|
|
import { FormInstance } from 'element-plus'; |
|
|
|
|
|
|
|
|
|
|
|
interface groupData { |
|
|
|
interface groupData { |
|
|
|
id: number; |
|
|
|
id: number; |
|
|
@ -62,6 +73,11 @@ interface groupData { |
|
|
|
default: boolean; |
|
|
|
default: boolean; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let rules = ref<any>({ |
|
|
|
|
|
|
|
name: [Rules.name], |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
const groupForm = ref<FormInstance>(); |
|
|
|
|
|
|
|
|
|
|
|
let open = ref(false); |
|
|
|
let open = ref(false); |
|
|
|
let data = ref<groupData[]>([]); |
|
|
|
let data = ref<groupData[]>([]); |
|
|
|
const handleClose = () => { |
|
|
|
const handleClose = () => { |
|
|
@ -84,7 +100,12 @@ const search = () => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const saveGroup = (create: groupData, isDefault: boolean) => { |
|
|
|
const saveGroup = async (formEl: FormInstance, create: groupData, isDefault: boolean) => { |
|
|
|
|
|
|
|
if (!formEl) return; |
|
|
|
|
|
|
|
await formEl.validate((valid) => { |
|
|
|
|
|
|
|
if (!valid) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
const group = { |
|
|
|
const group = { |
|
|
|
name: create.name, |
|
|
|
name: create.name, |
|
|
|
id: create.id, |
|
|
|
id: create.id, |
|
|
@ -104,6 +125,7 @@ const saveGroup = (create: groupData, isDefault: boolean) => { |
|
|
|
search(); |
|
|
|
search(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const acceptParams = async () => { |
|
|
|
const acceptParams = async () => { |
|
|
@ -160,6 +182,7 @@ const cancelEdit = (index: number) => { |
|
|
|
data.value.splice(index, 1); |
|
|
|
data.value.splice(index, 1); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
data.value[index].edit = false; |
|
|
|
data.value[index].edit = false; |
|
|
|
|
|
|
|
search(); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|