From e1023bb3313282b00d6dcdefd5d7e30d7aaa1bfc Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期四, 30 十一月 2023 11:13:29 +0800 Subject: [PATCH] update 优化 代码中存在的警告 --- src/views/system/client/index.vue | 66 +++++++++++--------------------- 1 files changed, 23 insertions(+), 43 deletions(-) diff --git a/src/views/system/client/index.vue b/src/views/system/client/index.vue index 2130d03..b39b9e5 100644 --- a/src/views/system/client/index.vue +++ b/src/views/system/client/index.vue @@ -4,10 +4,10 @@ <div class="search" v-show="showSearch"> <el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="100px"> <el-form-item label="瀹㈡埛绔痥ey" prop="clientKey"> - <el-input v-model="queryParams.clientKey" placeholder="璇疯緭鍏ュ鎴风key" clearable @keyup.enter="handleQuery" /> + <el-input v-model="queryParams.clientKey" placeholder="璇疯緭鍏ュ鎴风key" clearable style="width: 240px" @keyup.enter="handleQuery" /> </el-form-item> <el-form-item label="瀹㈡埛绔閽�" prop="clientSecret"> - <el-input v-model="queryParams.clientSecret" placeholder="璇疯緭鍏ュ鎴风绉橀挜" clearable @keyup.enter="handleQuery" /> + <el-input v-model="queryParams.clientSecret" placeholder="璇疯緭鍏ュ鎴风绉橀挜" clearable style="width: 240px" @keyup.enter="handleQuery" /> </el-form-item> <el-form-item label="鐘舵��" prop="status"> <el-select v-model="queryParams.status" placeholder="鐘舵��" clearable> @@ -29,10 +29,14 @@ <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:client:add']">鏂板</el-button> </el-col> <el-col :span="1.5"> - <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['system:client:edit']">淇敼</el-button> + <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['system:client:edit']"> + 淇敼 + </el-button> </el-col> <el-col :span="1.5"> - <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:client:remove']">鍒犻櫎</el-button> + <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:client:remove']"> + 鍒犻櫎 + </el-button> </el-col> <el-col :span="1.5"> <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['system:client:export']">瀵煎嚭</el-button> @@ -49,11 +53,7 @@ <el-table-column label="瀹㈡埛绔閽�" align="center" prop="clientSecret" /> <el-table-column label="鎺堟潈绫诲瀷" align="center"> <template #default="scope"> - <div> - <template v-for="type in scope.row.grantTypeList"> - <dict-tag class="el-check-tag" :options="sys_grant_type" :value="type" /> - </template> - </div> + <dict-tag :options="sys_grant_type" :value="scope.row.grantTypeList" /> </template> </el-table-column> <el-table-column label="璁惧绫诲瀷" align="center"> @@ -80,13 +80,7 @@ </el-table-column> </el-table> - <pagination - v-show="total>0" - :total="total" - v-model:page="queryParams.pageNum" - v-model:limit="queryParams.pageSize" - @pagination="getList" - /> + <pagination v-show="total>0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" /> </el-card> <!-- 娣诲姞鎴栦慨鏀瑰鎴风绠$悊瀵硅瘽妗� --> <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body> @@ -99,18 +93,12 @@ </el-form-item> <el-form-item label="鎺堟潈绫诲瀷" prop="grantTypeList"> <el-select v-model="form.grantTypeList" multiple placeholder="璇疯緭鍏ユ巿鏉冪被鍨�"> - <el-option - v-for="dict in sys_grant_type" - :key="dict.value" :label="dict.label" :value="dict.value" - ></el-option> + <el-option v-for="dict in sys_grant_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option> </el-select> </el-form-item> <el-form-item label="璁惧绫诲瀷" prop="deviceType"> <el-select v-model="form.deviceType" placeholder="璇疯緭鍏ヨ澶囩被鍨�"> - <el-option - v-for="dict in sys_device_type" - :key="dict.value" :label="dict.label" :value="dict.value" - ></el-option> + <el-option v-for="dict in sys_device_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option> </el-select> </el-form-item> <el-form-item prop="activeTimeout" label-width="auto"> @@ -156,8 +144,6 @@ <script setup name="Client" lang="ts"> import { listClient, getClient, delClient, addClient, updateClient, changeStatus } from '@/api/system/client'; import { ClientVO, ClientQuery, ClientForm } from '@/api/system/client/types'; -import { ComponentInternalInstance } from 'vue'; -import { ElForm } from 'element-plus'; const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { sys_normal_disable } = toRefs<any>(proxy?.useDict("sys_normal_disable")); @@ -173,8 +159,8 @@ const multiple = ref(true); const total = ref(0); -const queryFormRef = ref(ElForm); -const clientFormRef = ref(ElForm); +const queryFormRef = ref<ElFormInstance>(); +const clientFormRef = ref<ElFormInstance>(); const dialog = reactive<DialogOption>({ visible: false, @@ -248,7 +234,7 @@ /** 琛ㄥ崟閲嶇疆 */ const reset = () => { form.value = {...initFormData}; - clientFormRef.value.resetFields(); + clientFormRef.value?.resetFields(); } /** 鎼滅储鎸夐挳鎿嶄綔 */ @@ -259,7 +245,7 @@ /** 閲嶇疆鎸夐挳鎿嶄綔 */ const resetQuery = () => { - queryFormRef.value.resetFields(); + queryFormRef.value?.resetFields(); handleQuery(); } @@ -272,30 +258,24 @@ /** 鏂板鎸夐挳鎿嶄綔 */ const handleAdd = () => { + reset(); dialog.visible = true; dialog.title = "娣诲姞瀹㈡埛绔鐞�"; - nextTick(() => { - reset(); - }); } /** 淇敼鎸夐挳鎿嶄綔 */ -const handleUpdate = (row?: ClientVO) => { - loading.value = true +const handleUpdate = async (row?: ClientVO) => { + reset(); + const _id = row?.id || ids.value[0] + const res = await getClient(_id); + Object.assign(form.value, res.data); dialog.visible = true; dialog.title = "淇敼瀹㈡埛绔鐞�"; - nextTick(async () => { - reset(); - const _id = row?.id || ids.value[0] - const res = await getClient(_id); - loading.value = false; - Object.assign(form.value, res.data); - }); } /** 鎻愪氦鎸夐挳 */ const submitForm = () => { - clientFormRef.value.validate(async (valid: boolean) => { + clientFormRef.value?.validate(async (valid: boolean) => { if (valid) { buttonLoading.value = true; if (form.value.id) { -- Gitblit v1.9.3