refactor: eslint代码检查优化
Former-commit-id: 4c11b5d0cdd10f28148cf3d9b593f85e082cdc51
This commit is contained in:
@@ -3,43 +3,23 @@
|
||||
<!-- 搜索表单 -->
|
||||
<el-form ref="queryFormRef" :model="state.queryParams" :inline="true">
|
||||
<el-form-item>
|
||||
<el-button type="success" :icon="Plus" @click="handleAdd"
|
||||
>新增</el-button
|
||||
>
|
||||
<el-button
|
||||
type="danger"
|
||||
:icon="Delete"
|
||||
:disabled="state.multiple"
|
||||
@click="handleDelete"
|
||||
>删除
|
||||
<el-button type="success" :icon="Plus" @click="handleAdd">新增</el-button>
|
||||
<el-button type="danger" :icon="Delete" :disabled="state.multiple" @click="handleDelete">删除
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item prop="name">
|
||||
<el-input
|
||||
v-model="state.queryParams.name"
|
||||
placeholder="字典名称"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
<el-input v-model="state.queryParams.name" placeholder="字典名称" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" :icon="Search" @click="handleQuery"
|
||||
>搜索</el-button
|
||||
>
|
||||
<el-button :icon="Refresh" @click="resetForm">重置</el-button>
|
||||
<el-button type="primary" :icon="Search" @click="handleQuery()">搜索</el-button>
|
||||
<el-button :icon="Refresh" @click="resetQuery()">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<el-table
|
||||
highlight-current-row
|
||||
:data="dictList"
|
||||
v-loading="loading"
|
||||
@row-click="handleRowClick"
|
||||
@selection-change="handleSelectionChange"
|
||||
border
|
||||
>
|
||||
<el-table highlight-current-row :data="dictList" v-loading="loading" @row-click="handleRowClick"
|
||||
@selection-change="handleSelectionChange" border>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="字典名称" prop="name" width="120" />
|
||||
<el-table-column label="字典编码" prop="code" />
|
||||
@@ -52,45 +32,18 @@
|
||||
|
||||
<el-table-column label="操作" align="center" width="150">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
type="primary"
|
||||
:icon="Edit"
|
||||
circle
|
||||
plain
|
||||
@click.stop="handleUpdate(scope.row)"
|
||||
/>
|
||||
<el-button
|
||||
type="danger"
|
||||
:icon="Delete"
|
||||
circle
|
||||
plain
|
||||
@click.stop="handleDelete(scope.row)"
|
||||
/>
|
||||
<el-button type="primary" :icon="Edit" circle plain @click.stop="handleUpdate(scope.row)" />
|
||||
<el-button type="danger" :icon="Delete" circle plain @click.stop="handleDelete(scope.row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNum"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="handleQuery"
|
||||
/>
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
|
||||
@pagination="handleQuery" />
|
||||
|
||||
<!-- 弹窗表单 -->
|
||||
<el-dialog
|
||||
:title="dialog.title"
|
||||
v-model="dialog.visible"
|
||||
width="500px"
|
||||
@close="cancel"
|
||||
>
|
||||
<el-form
|
||||
ref="dataFormRef"
|
||||
:model="formData"
|
||||
:rules="rules"
|
||||
label-width="80px"
|
||||
>
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" @close="cancel">
|
||||
<el-form ref="dataFormRef" :model="formData" :rules="rules" label-width="80px">
|
||||
<el-form-item label="字典名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入字典名称" />
|
||||
</el-form-item>
|
||||
@@ -104,12 +57,8 @@
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input
|
||||
v-model="formData.remark"
|
||||
type="textarea"
|
||||
placeholder="请输入内容"
|
||||
:autosize="{ minRows: 2, maxRows: 4 }"
|
||||
/>
|
||||
<el-input v-model="formData.remark" type="textarea" placeholder="请输入内容"
|
||||
:autosize="{ minRows: 2, maxRows: 4 }" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
@@ -123,7 +72,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref, toRefs } from "vue";
|
||||
import { onMounted, reactive, ref, toRefs, defineEmits } from "vue";
|
||||
import {
|
||||
listDictPages,
|
||||
getDictFormDetail,
|
||||
@@ -134,7 +83,6 @@ import {
|
||||
import { Search, Plus, Edit, Refresh, Delete } from "@element-plus/icons-vue";
|
||||
import { ElForm, ElMessage, ElMessageBox } from "element-plus";
|
||||
import { Dialog, Dict, DictFormData, DictQueryParam } from "@/types";
|
||||
import { status } from "nprogress";
|
||||
|
||||
const queryFormRef = ref(ElForm);
|
||||
const dataFormRef = ref(ElForm);
|
||||
@@ -155,7 +103,7 @@ const state = reactive({
|
||||
} as DictQueryParam,
|
||||
dictList: [] as Dict[],
|
||||
total: 0,
|
||||
dialog: {visible:false} as Dialog,
|
||||
dialog: { visible: false } as Dialog,
|
||||
formData: {
|
||||
status: 1,
|
||||
} as DictFormData,
|
||||
@@ -168,14 +116,11 @@ const state = reactive({
|
||||
const {
|
||||
total,
|
||||
dialog,
|
||||
ids,
|
||||
loading,
|
||||
single,
|
||||
multiple,
|
||||
queryParams,
|
||||
dictList,
|
||||
formData,
|
||||
rules,
|
||||
queryParams
|
||||
} = toRefs(state);
|
||||
|
||||
function handleQuery() {
|
||||
@@ -221,15 +166,15 @@ function submitForm() {
|
||||
dataFormRef.value.validate((isValid: boolean) => {
|
||||
if (isValid) {
|
||||
if (state.formData.id) {
|
||||
updateDict(state.formData.id, state.formData).then((response) => {
|
||||
updateDict(state.formData.id, state.formData).then(() => {
|
||||
ElMessage.success("修改成功");
|
||||
state.dialog.visible = false;
|
||||
cancel()
|
||||
handleQuery();
|
||||
});
|
||||
} else {
|
||||
addDict(state.formData).then((response) => {
|
||||
addDict(state.formData).then(() => {
|
||||
ElMessage.success("新增成功");
|
||||
state.dialog.visible = false;
|
||||
cancel()
|
||||
handleQuery();
|
||||
});
|
||||
}
|
||||
@@ -237,12 +182,9 @@ function submitForm() {
|
||||
});
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
function cancel() {
|
||||
state.formData.id = undefined;
|
||||
dataFormRef.value.resetFields();
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
state.dialog.visible = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user