From da7fcbeed12e28f22a41610cb1014f308fc0bd9c Mon Sep 17 00:00:00 2001 From: eight <641137800@qq.com> Date: 星期四, 10 十月 2024 17:58:02 +0800 Subject: [PATCH] 检查类型 (准备人数 + 是否需要领用) 配置 --- src/api/ecg/checktype/index.ts | 43 ++++++ src/views/ecg/checktype/index.vue | 216 ++++++++++++++++++++++++++++++ src/views/ecg/checktype/CheckTypeForm.vue | 111 +++++++++++++++ 3 files changed, 370 insertions(+), 0 deletions(-) diff --git a/src/api/ecg/checktype/index.ts b/src/api/ecg/checktype/index.ts new file mode 100644 index 0000000..e3e7bb0 --- /dev/null +++ b/src/api/ecg/checktype/index.ts @@ -0,0 +1,43 @@ +import request from '@/config/axios' + +// 妫�鏌ョ被鍨� VO +export interface CheckTypeVO { + id: number // id + name: string // 妫�鏌ョ被鍨嬪悕 + value: number // 妫�鏌ョ被鍨嬪�� + readyNum: number // 鍏佽鍑嗗涓汉鏁� + needDevReady: number // 闇�瑕佽澶囬鐢� +} + +// 妫�鏌ョ被鍨� API +export const CheckTypeApi = { + // 鏌ヨ妫�鏌ョ被鍨嬪垎椤� + getCheckTypePage: async (params: any) => { + return await request.get({ url: `/ecg/check-type/page`, params }) + }, + + // 鏌ヨ妫�鏌ョ被鍨嬭鎯� + getCheckType: async (id: number) => { + return await request.get({ url: `/ecg/check-type/get?id=` + id }) + }, + + // 鏂板妫�鏌ョ被鍨� + createCheckType: async (data: CheckTypeVO) => { + return await request.post({ url: `/ecg/check-type/create`, data }) + }, + + // 淇敼妫�鏌ョ被鍨� + updateCheckType: async (data: CheckTypeVO) => { + return await request.put({ url: `/ecg/check-type/update`, data }) + }, + + // 鍒犻櫎妫�鏌ョ被鍨� + deleteCheckType: async (id: number) => { + return await request.delete({ url: `/ecg/check-type/delete?id=` + id }) + }, + + // 瀵煎嚭妫�鏌ョ被鍨� Excel + exportCheckType: async (params) => { + return await request.download({ url: `/ecg/check-type/export-excel`, params }) + } +} \ No newline at end of file diff --git a/src/views/ecg/checktype/CheckTypeForm.vue b/src/views/ecg/checktype/CheckTypeForm.vue new file mode 100644 index 0000000..d3c5148 --- /dev/null +++ b/src/views/ecg/checktype/CheckTypeForm.vue @@ -0,0 +1,111 @@ +<template> + <Dialog :title="dialogTitle" v-model="dialogVisible"> + <el-form + ref="formRef" + :model="formData" + :rules="formRules" + label-width="100px" + v-loading="formLoading" + > + <el-form-item label="妫�鏌ョ被鍨嬪悕" prop="name"> + <el-input v-model="formData.name" placeholder="璇疯緭鍏ユ鏌ョ被鍨嬪悕" /> + </el-form-item> + <el-form-item label="妫�鏌ョ被鍨嬪��" prop="value"> + <el-input v-model="formData.value" placeholder="璇疯緭鍏ユ鏌ョ被鍨嬪��" /> + </el-form-item> + <el-form-item label="鍏佽鍑嗗涓汉鏁�" prop="readyNum"> + <el-input v-model="formData.readyNum" placeholder="璇疯緭鍏ュ厑璁稿噯澶囦腑浜烘暟" /> + </el-form-item> + <el-form-item label="闇�瑕佽澶囬鐢�" prop="needDevReady"> + <el-switch + v-model="formData.needDevReady" + :active-value="1" + :inactive-value="0" + /> + </el-form-item> + </el-form> + <template #footer> + <el-button @click="submitForm" type="primary" :disabled="formLoading">纭� 瀹�</el-button> + <el-button @click="dialogVisible = false">鍙� 娑�</el-button> + </template> + </Dialog> +</template> +<script setup lang="ts"> +import { getIntDictOptions, DICT_TYPE } from '@/utils/dict' +import { CheckTypeApi, CheckTypeVO } from '@/api/ecg/checktype' + +/** 妫�鏌ョ被鍨� 琛ㄥ崟 */ +defineOptions({ name: 'CheckTypeForm' }) + +const { t } = useI18n() // 鍥介檯鍖� +const message = useMessage() // 娑堟伅寮圭獥 + +const dialogVisible = ref(false) // 寮圭獥鐨勬槸鍚﹀睍绀� +const dialogTitle = ref('') // 寮圭獥鐨勬爣棰� +const formLoading = ref(false) // 琛ㄥ崟鐨勫姞杞戒腑锛�1锛変慨鏀规椂鐨勬暟鎹姞杞斤紱2锛夋彁浜ょ殑鎸夐挳绂佺敤 +const formType = ref('') // 琛ㄥ崟鐨勭被鍨嬶細create - 鏂板锛泆pdate - 淇敼 +const formData = ref({ + id: undefined, + name: undefined, + value: undefined, + readyNum: undefined, + needDevReady: [] +}) +const formRules = reactive({ +}) +const formRef = ref() // 琛ㄥ崟 Ref + +/** 鎵撳紑寮圭獥 */ +const open = async (type: string, id?: number) => { + dialogVisible.value = true + dialogTitle.value = t('action.' + type) + formType.value = type + resetForm() + // 淇敼鏃讹紝璁剧疆鏁版嵁 + if (id) { + formLoading.value = true + try { + formData.value = await CheckTypeApi.getCheckType(id) + } finally { + formLoading.value = false + } + } +} +defineExpose({ open }) // 鎻愪緵 open 鏂规硶锛岀敤浜庢墦寮�寮圭獥 + +/** 鎻愪氦琛ㄥ崟 */ +const emit = defineEmits(['success']) // 瀹氫箟 success 浜嬩欢锛岀敤浜庢搷浣滄垚鍔熷悗鐨勫洖璋� +const submitForm = async () => { + // 鏍¢獙琛ㄥ崟 + await formRef.value.validate() + // 鎻愪氦璇锋眰 + formLoading.value = true + try { + const data = formData.value as unknown as CheckTypeVO + if (formType.value === 'create') { + await CheckTypeApi.createCheckType(data) + message.success(t('common.createSuccess')) + } else { + await CheckTypeApi.updateCheckType(data) + message.success(t('common.updateSuccess')) + } + dialogVisible.value = false + // 鍙戦�佹搷浣滄垚鍔熺殑浜嬩欢 + emit('success') + } finally { + formLoading.value = false + } +} + +/** 閲嶇疆琛ㄥ崟 */ +const resetForm = () => { + formData.value = { + id: undefined, + name: undefined, + value: undefined, + readyNum: undefined, + needDevReady: [] + } + formRef.value?.resetFields() +} +</script> \ No newline at end of file diff --git a/src/views/ecg/checktype/index.vue b/src/views/ecg/checktype/index.vue new file mode 100644 index 0000000..e647223 --- /dev/null +++ b/src/views/ecg/checktype/index.vue @@ -0,0 +1,216 @@ +<template> + <ContentWrap> + <!-- 鎼滅储宸ヤ綔鏍� --> + <el-form + class="-mb-15px" + :model="queryParams" + ref="queryFormRef" + :inline="true" + label-width="68px" + > + <el-form-item label="妫�鏌ョ被鍨嬪悕" prop="name"> + <el-input + v-model="queryParams.name" + placeholder="璇疯緭鍏ユ鏌ョ被鍨嬪悕" + clearable + @keyup.enter="handleQuery" + class="!w-240px" + /> + </el-form-item> + <el-form-item label="妫�鏌ョ被鍨嬪��" prop="value"> + <el-input + v-model="queryParams.value" + placeholder="璇疯緭鍏ユ鏌ョ被鍨嬪��" + clearable + @keyup.enter="handleQuery" + class="!w-240px" + /> + </el-form-item> + <el-form-item label="鍏佽鍑嗗涓汉鏁�" prop="readyNum"> + <el-input + v-model="queryParams.readyNum" + placeholder="璇疯緭鍏ュ厑璁稿噯澶囦腑浜烘暟" + clearable + @keyup.enter="handleQuery" + class="!w-240px" + /> + </el-form-item> + <el-form-item label="鍒涘缓鏃堕棿" prop="createTime"> + <el-date-picker + v-model="queryParams.createTime" + value-format="YYYY-MM-DD HH:mm:ss" + type="daterange" + start-placeholder="寮�濮嬫棩鏈�" + end-placeholder="缁撴潫鏃ユ湡" + :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" + class="!w-220px" + /> + </el-form-item> + <el-form-item> + <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 鎼滅储</el-button> + <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 閲嶇疆</el-button> + <el-button + type="primary" + plain + @click="openForm('create')" + v-hasPermi="['ecg:check-type:create']" + > + <Icon icon="ep:plus" class="mr-5px" /> 鏂板 + </el-button> + <el-button + type="success" + plain + @click="handleExport" + :loading="exportLoading" + v-hasPermi="['ecg:check-type:export']" + > + <Icon icon="ep:download" class="mr-5px" /> 瀵煎嚭 + </el-button> + </el-form-item> + </el-form> + </ContentWrap> + + <!-- 鍒楄〃 --> + <ContentWrap> + <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> + <el-table-column label="id" align="center" prop="id" /> + <el-table-column label="妫�鏌ョ被鍨嬪悕" align="center" prop="name" /> + <el-table-column label="妫�鏌ョ被鍨嬪��" align="center" prop="value" /> + <el-table-column label="鍏佽鍑嗗涓汉鏁�" align="center" prop="readyNum" /> + <el-table-column label="闇�瑕佽澶囬鐢�" align="center" prop="needDevReady"> + <template #default="scope"> + {{scope.row.needDevReady === 0 ? "涓嶉渶瑕�":"闇�瑕�"}} + </template> + </el-table-column> + <el-table-column + label="鍒涘缓鏃堕棿" + align="center" + prop="createTime" + :formatter="dateFormatter" + width="180px" + /> + <el-table-column label="鎿嶄綔" align="center" min-width="120px"> + <template #default="scope"> + <el-button + link + type="primary" + @click="openForm('update', scope.row.id)" + v-hasPermi="['ecg:check-type:update']" + > + 缂栬緫 + </el-button> + <el-button + link + type="danger" + @click="handleDelete(scope.row.id)" + v-hasPermi="['ecg:check-type:delete']" + > + 鍒犻櫎 + </el-button> + </template> + </el-table-column> + </el-table> + <!-- 鍒嗛〉 --> + <Pagination + :total="total" + v-model:page="queryParams.pageNo" + v-model:limit="queryParams.pageSize" + @pagination="getList" + /> + </ContentWrap> + + <!-- 琛ㄥ崟寮圭獥锛氭坊鍔�/淇敼 --> + <CheckTypeForm ref="formRef" @success="getList" /> +</template> + +<script setup lang="ts"> +import { DICT_TYPE } from '@/utils/dict' +import { dateFormatter } from '@/utils/formatTime' +import download from '@/utils/download' +import { CheckTypeApi, CheckTypeVO } from '@/api/ecg/checktype' +import CheckTypeForm from './CheckTypeForm.vue' + +/** 妫�鏌ョ被鍨� 鍒楄〃 */ +defineOptions({ name: 'CheckType' }) + +const message = useMessage() // 娑堟伅寮圭獥 +const { t } = useI18n() // 鍥介檯鍖� + +const loading = ref(true) // 鍒楄〃鐨勫姞杞戒腑 +const list = ref<CheckTypeVO[]>([]) // 鍒楄〃鐨勬暟鎹� +const total = ref(0) // 鍒楄〃鐨勬�婚〉鏁� +const queryParams = reactive({ + pageNo: 1, + pageSize: 10, + name: undefined, + value: undefined, + readyNum: undefined, + createTime: [], + needDevReady: undefined +}) +const queryFormRef = ref() // 鎼滅储鐨勮〃鍗� +const exportLoading = ref(false) // 瀵煎嚭鐨勫姞杞戒腑 + +/** 鏌ヨ鍒楄〃 */ +const getList = async () => { + loading.value = true + try { + const data = await CheckTypeApi.getCheckTypePage(queryParams) + list.value = data.list + total.value = data.total + } finally { + loading.value = false + } +} + +/** 鎼滅储鎸夐挳鎿嶄綔 */ +const handleQuery = () => { + queryParams.pageNo = 1 + getList() +} + +/** 閲嶇疆鎸夐挳鎿嶄綔 */ +const resetQuery = () => { + queryFormRef.value.resetFields() + handleQuery() +} + +/** 娣诲姞/淇敼鎿嶄綔 */ +const formRef = ref() +const openForm = (type: string, id?: number) => { + formRef.value.open(type, id) +} + +/** 鍒犻櫎鎸夐挳鎿嶄綔 */ +const handleDelete = async (id: number) => { + try { + // 鍒犻櫎鐨勪簩娆$‘璁� + await message.delConfirm() + // 鍙戣捣鍒犻櫎 + await CheckTypeApi.deleteCheckType(id) + message.success(t('common.delSuccess')) + // 鍒锋柊鍒楄〃 + await getList() + } catch {} +} + +/** 瀵煎嚭鎸夐挳鎿嶄綔 */ +const handleExport = async () => { + try { + // 瀵煎嚭鐨勪簩娆$‘璁� + await message.exportConfirm() + // 鍙戣捣瀵煎嚭 + exportLoading.value = true + const data = await CheckTypeApi.exportCheckType(queryParams) + download.excel(data, '妫�鏌ョ被鍨�.xls') + } catch { + } finally { + exportLoading.value = false + } +} + +/** 鍒濆鍖� **/ +onMounted(() => { + getList() +}) +</script> \ No newline at end of file -- Gitblit v1.9.3