From ac3ad638949e4d560ddf69320a5f9bb28ca5aaca Mon Sep 17 00:00:00 2001 From: ahaos <8406649+lhailgl@user.noreply.gitee.com> Date: 星期三, 19 七月 2023 22:48:30 +0800 Subject: [PATCH] !29 修改列表打开对话框和接口请求顺序 Merge pull request !29 from ahaos/tspr --- src/views/system/client/index.vue | 58 +++++++++++++++++++++------------------------------------- 1 files changed, 21 insertions(+), 37 deletions(-) diff --git a/src/views/system/client/index.vue b/src/views/system/client/index.vue index 2130d03..827eaf2 100644 --- a/src/views/system/client/index.vue +++ b/src/views/system/client/index.vue @@ -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> @@ -50,7 +54,7 @@ <el-table-column label="鎺堟潈绫诲瀷" align="center"> <template #default="scope"> <div> - <template v-for="type in scope.row.grantTypeList"> + <template v-for="(type, index) in scope.row.grantTypeList" :key="index"> <dict-tag class="el-check-tag" :options="sys_grant_type" :value="type" /> </template> </div> @@ -80,13 +84,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 +97,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 +148,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 +163,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 +238,7 @@ /** 琛ㄥ崟閲嶇疆 */ const reset = () => { form.value = {...initFormData}; - clientFormRef.value.resetFields(); + clientFormRef.value?.resetFields(); } /** 鎼滅储鎸夐挳鎿嶄綔 */ @@ -259,7 +249,7 @@ /** 閲嶇疆鎸夐挳鎿嶄綔 */ const resetQuery = () => { - queryFormRef.value.resetFields(); + queryFormRef.value?.resetFields(); handleQuery(); } @@ -272,30 +262,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