refactor: ♻️ 关闭字典表单清空字典项
This commit is contained in:
@@ -12,27 +12,32 @@
|
|||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="handleQuery()"
|
<el-button type="primary" @click="handleQuery()">
|
||||||
><i-ep-search />搜索</el-button
|
<i-ep-search />
|
||||||
>
|
搜索
|
||||||
<el-button @click="handleResetClick()"
|
</el-button>
|
||||||
><i-ep-refresh />重置</el-button
|
<el-button @click="handleResetClick()">
|
||||||
>
|
<i-ep-refresh />
|
||||||
|
重置
|
||||||
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-card shadow="never">
|
<el-card shadow="never">
|
||||||
<div class="mb-[10px]">
|
<div class="mb-[10px]">
|
||||||
<el-button type="success" @click="handleAddClick()"
|
<el-button type="success" @click="handleAddClick()">
|
||||||
><i-ep-plus />新增</el-button
|
<i-ep-plus />
|
||||||
>
|
新增
|
||||||
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
type="danger"
|
type="danger"
|
||||||
:disabled="ids.length === 0"
|
:disabled="ids.length === 0"
|
||||||
@click="handleDelete()"
|
@click="handleDelete()"
|
||||||
><i-ep-delete />删除</el-button
|
|
||||||
>
|
>
|
||||||
|
<i-ep-delete />
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-table
|
<el-table
|
||||||
@@ -69,15 +74,19 @@
|
|||||||
link
|
link
|
||||||
size="small"
|
size="small"
|
||||||
@click.stop="handleEditClick(scope.row.id, scope.row.name)"
|
@click.stop="handleEditClick(scope.row.id, scope.row.name)"
|
||||||
><i-ep-edit />编辑</el-button
|
|
||||||
>
|
>
|
||||||
|
<i-ep-edit />
|
||||||
|
编辑
|
||||||
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
type="danger"
|
type="danger"
|
||||||
link
|
link
|
||||||
size="small"
|
size="small"
|
||||||
@click.stop="handleDelete(scope.row.id)"
|
@click.stop="handleDelete(scope.row.id)"
|
||||||
><i-ep-delete />删除</el-button
|
|
||||||
>
|
>
|
||||||
|
<i-ep-delete />
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@@ -129,8 +138,10 @@
|
|||||||
type="primary"
|
type="primary"
|
||||||
size="small"
|
size="small"
|
||||||
@click.stop="handleAddAttrClick"
|
@click.stop="handleAddAttrClick"
|
||||||
><i-ep-plus />新增字典</el-button
|
|
||||||
>
|
>
|
||||||
|
<i-ep-plus />
|
||||||
|
新增字典
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<el-table
|
<el-table
|
||||||
@@ -184,8 +195,10 @@
|
|||||||
link
|
link
|
||||||
size="small"
|
size="small"
|
||||||
@click.stop="handleDeleteAttrClick(scope.$index)"
|
@click.stop="handleDeleteAttrClick(scope.$index)"
|
||||||
><i-ep-delete />删除</el-button
|
|
||||||
>
|
>
|
||||||
|
<i-ep-delete />
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@@ -294,7 +307,6 @@ function handleEditClick(id: number, name: string) {
|
|||||||
// 提交字典表单
|
// 提交字典表单
|
||||||
function handleSubmitClick() {
|
function handleSubmitClick() {
|
||||||
dataFormRef.value.validate((isValid: boolean) => {
|
dataFormRef.value.validate((isValid: boolean) => {
|
||||||
console.log("isValid", isValid);
|
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
const id = formData.id;
|
const id = formData.id;
|
||||||
@@ -327,6 +339,7 @@ function handleCloseDialog() {
|
|||||||
dataFormRef.value.clearValidate();
|
dataFormRef.value.clearValidate();
|
||||||
|
|
||||||
formData.id = undefined;
|
formData.id = undefined;
|
||||||
|
formData.dictItems = [];
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 删除字典
|
* 删除字典
|
||||||
@@ -356,12 +369,13 @@ function handleDelete(id?: number) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增字典
|
/** 新增字典项 */
|
||||||
function handleAddAttrClick() {
|
function handleAddAttrClick() {
|
||||||
formData.dictItems = formData.dictItems ?? [];
|
formData.dictItems = formData.dictItems ?? [];
|
||||||
formData.dictItems.push({ sort: 1, status: 1 });
|
formData.dictItems.push({ sort: 1, status: 1 });
|
||||||
}
|
}
|
||||||
// 删除字典
|
|
||||||
|
/** 删除字典项 */
|
||||||
function handleDeleteAttrClick(index: number) {
|
function handleDeleteAttrClick(index: number) {
|
||||||
if (formData.dictItems && formData.dictItems.length > 0) {
|
if (formData.dictItems && formData.dictItems.length > 0) {
|
||||||
formData.dictItems.splice(index, 1);
|
formData.dictItems.splice(index, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user