feat(qms): 添加导入功能

- 在多个 QMS 相关模块中添加了导入数据的功能- 新增 importData 函数用于处理导入操作
- 在前端页面中添加了导入按钮和相关逻辑
- 优化了部分模块的界面布局
master
zch 1 week ago
parent 2943c8c19d
commit bde016be02

@ -75,3 +75,20 @@ export function getQcInspectionMainList (query) {
params: query
});
};
/**
*
*
* @param file
* @param updateSupport
*/
export const importData = (file: File, updateSupport: boolean) => {
const formData = new FormData();
formData.append('file', file);
formData.append('updateSupport', updateSupport.toString());
return request({
url: '/qms/QcInspectionMain/importData',
method: 'post',
data: formData
});
};

@ -75,3 +75,21 @@ export function getQcInspectionItemList (query) {
params: query
});
};
/**
*
*
* @param file
* @param updateSupport
*/
export const importData = (file: File, updateSupport: boolean) => {
const formData = new FormData();
formData.append('file', file);
formData.append('updateSupport', updateSupport.toString());
return request({
url: '/qms/qcInspectionItem/importData',
method: 'post',
data: formData
});
};

@ -75,3 +75,17 @@ export function getQcInspectionItemCategoryList (query) {
params: query
});
};
/**
*
*
* @param file
* @param updateSupport
*/
export const importData = (file: File, updateSupport: boolean) => {
return request({
url: '/qms/qcInspectionItemCategory/importData',
method: 'post',
data: { file, updateSupport }
});
};

@ -75,3 +75,20 @@ export function getQcInspectionResultList (query) {
params: query
});
};
/**
*
*
* @param file
* @param updateSupport
*/
export const importData = (file: File, updateSupport: boolean) => {
const formData = new FormData();
formData.append('file', file);
formData.append('updateSupport', updateSupport.toString());
return request({
url: '/qms/qcInspectionResult/importData',
method: 'post',
data: formData
});
};

@ -17,7 +17,7 @@ export const listQcInspectionTemplate = (query?: QcInspectionTemplateQuery): Axi
};
/**
*
*
* @param templateId
*/
export const getQcInspectionTemplate = (templateId: string | number): AxiosPromise<QcInspectionTemplateVO> => {
@ -28,7 +28,7 @@ export const getQcInspectionTemplate = (templateId: string | number): AxiosPromi
};
/**
*
*
* @param data
*/
export const addQcInspectionTemplate = (data: QcInspectionTemplateForm) => {
@ -40,7 +40,7 @@ export const addQcInspectionTemplate = (data: QcInspectionTemplateForm) => {
};
/**
*
*
* @param data
*/
export const updateQcInspectionTemplate = (data: QcInspectionTemplateForm) => {
@ -52,7 +52,7 @@ export const updateQcInspectionTemplate = (data: QcInspectionTemplateForm) => {
};
/**
*
*
* @param templateId
*/
export const delQcInspectionTemplate = (templateId: string | number | Array<string | number>) => {
@ -64,7 +64,7 @@ export const delQcInspectionTemplate = (templateId: string | number | Array<stri
/**
*
*
* @param query
* @returns {*}
*/
@ -75,3 +75,20 @@ export function getQcInspectionTemplateList (query) {
params: query
});
};
/**
*
*
* @param file
* @param updateSupport
*/
export const importData = (file: File, updateSupport: boolean) => {
const formData = new FormData();
formData.append('file', file);
formData.append('updateSupport', updateSupport.toString());
return request({
url: '/qms/qcInspectionTemplate/importData',
method: 'post',
data: formData
});
};

@ -75,3 +75,20 @@ export function getQcInspectionTypeList (query) {
params: query
});
};
/**
*
*
* @param file
* @param updateSupport
*/
export const importData = (file: File, updateSupport: boolean) => {
const formData = new FormData();
formData.append('file', file);
formData.append('updateSupport', updateSupport.toString());
return request({
url: '/qms/qcInspectionType/importData',
method: 'post',
data: formData
});
};

@ -75,3 +75,21 @@ export function getQcTemplateItemList (query) {
params: query
});
};
/**
*
*
* @param file
* @param updateSupport
*/
export const importData = (file: File, updateSupport: boolean) => {
const formData = new FormData();
formData.append('file', file);
formData.append('updateSupport', updateSupport.toString());
return request({
url: '/qms/qcTemplateItem/importData',
method: 'post',
data: formData
});
};

@ -51,6 +51,9 @@
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExportTemplate" v-hasPermi="['qms:QcInspectionMain:export']"></el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleImport" v-hasPermi="['qms:QcInspectionMain:import']"></el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" :columns="columns" :search="true" @queryTable="getList"></right-toolbar>
</el-row>
</template>
@ -776,6 +779,31 @@ const calculateUnqualifiedQty = () => {
}
}
/** 导入按钮操作 */
const fileInput = ref<HTMLInputElement>();
const uploading = ref(false);
const handleImport = () => {
fileInput.value?.click();
}
const onFileChange = async (event: Event) => {
const input = event.target as HTMLInputElement;
if (input.files && input.files.length > 0) {
const file = input.files[0];
uploading.value = true;
try {
await importData(file, true);
proxy?.$modal.msgSuccess("导入成功");
await getList();
} catch (err) {
proxy?.$modal.msgError("导入失败");
console.error(err);
} finally {
uploading.value = false;
input.value = '';
}
}
}
onMounted(() => {
getInspectionItemList();
getInspectionTypeList();

@ -93,6 +93,9 @@
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['qms:qcInspectionItem:export']"></el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleImport" v-hasPermi="['qms:qcInspectionItem:import']"></el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" :columns="columns" :search="true" @queryTable="getList"></right-toolbar>
</el-row>
</template>
@ -290,7 +293,7 @@
</template>
<script setup name="QcInspectionItem" lang="ts">
import { listQcInspectionItem, getQcInspectionItem, delQcInspectionItem, addQcInspectionItem, updateQcInspectionItem, getQcInspectionItemList } from '@/api/qms/qcInspectionItem';
import { listQcInspectionItem, getQcInspectionItem, delQcInspectionItem, addQcInspectionItem, updateQcInspectionItem, getQcInspectionItemList, importData } from '@/api/qms/qcInspectionItem';
import { QcInspectionItemVO, QcInspectionItemQuery, QcInspectionItemForm } from '@/api/qms/qcInspectionItem/types';
import { getQcInspectionItemCategoryList } from '@/api/qms/qcInspectionItemCategory';
import { QcInspectionItemCategoryVO } from '@/api/qms/qcInspectionItemCategory/types';
@ -508,6 +511,31 @@ const getTypeList = async () => {
qcInspectionTypeList.value = res.data;
};
/** 导入按钮操作 */
const fileInput = ref<HTMLInputElement>();
const uploading = ref(false);
const handleImport = () => {
fileInput.value?.click();
}
const onFileChange = async (event: Event) => {
const input = event.target as HTMLInputElement;
if (input.files && input.files.length > 0) {
const file = input.files[0];
uploading.value = true;
try {
await importData(file, true);
proxy?.$modal.msgSuccess("导入成功");
await getList();
} catch (err) {
proxy?.$modal.msgError("导入失败");
console.error(err);
} finally {
uploading.value = false;
input.value = '';
}
}
}
onMounted(() => {
getList();
getCategoryList();

@ -1,5 +1,24 @@
<template>
<div class="p-2">
<el-row :gutter="20">
<!--部门树-->
<el-col :lg="4" :xs="24" style="">
<el-card shadow="hover">
<el-input v-model="inspectionTypeName" placeholder="请输入检测类型名称" clearable prefix-icon="Search" />
<el-tree
ref="inspectionTypeTreeRef"
class="mt-2"
:data="qcInspectionTypeList"
:props="{ label: 'typeName', children: 'children' }"
:expand-on-click-node="false"
:filter-node-method="filterNode"
highlight-current
default-expand-all
@node-click="handleNodeClick"
/>
</el-card>
</el-col>
<el-col :lg="20" :xs="24">
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
@ -46,6 +65,9 @@
<el-col :span="1.5">
<el-button type="info" plain icon="Sort" @click="handleToggleExpandAll">/</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="primary" plain icon="Import" @click="handleImport"></el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
</template>
@ -121,11 +143,15 @@
</div>
</template>
</el-dialog>
</el-col>
</el-row>
</div>
</template>
<script setup name="QcInspectionItemCategory" lang="ts">
import { listQcInspectionItemCategory, getQcInspectionItemCategory, delQcInspectionItemCategory, addQcInspectionItemCategory, updateQcInspectionItemCategory } from '@/api/qms/qcInspectionItemCategory';
import { listQcInspectionItemCategory, getQcInspectionItemCategory, delQcInspectionItemCategory, addQcInspectionItemCategory, updateQcInspectionItemCategory, importData } from '@/api/qms/qcInspectionItemCategory';
import { QcInspectionItemCategoryVO, QcInspectionItemCategoryQuery, QcInspectionItemCategoryForm } from '@/api/qms/qcInspectionItemCategory/types';
import {getQcInspectionTypeList} from "@/api/qms/qcInspectionType";
import { QcInspectionTypeVO } from '@/api/qms/qcInspectionType/types';
@ -154,7 +180,7 @@ const total = ref(0);
const queryFormRef = ref<ElFormInstance>();
const qcInspectionItemCategoryFormRef = ref<ElFormInstance>();
// const qcInspectionItemCategoryTableRef = ref<ElTableInstance>();
const qcInspectionItemCategoryTableRef = ref<ElTableInstance>();
const inspectionTypeTreeRef = ref<TreeInstance>();
const inspectionTypeName = ref('');
@ -328,9 +354,35 @@ const handleNodeClick = (data: QcInspectionTypeVO) => {
};
watch(inspectionTypeName, val => {
inspectionTypeTreeRef.value?.filter(val);
});
/** 导入按钮操作 */
const fileInput = ref<HTMLInputElement>();
const uploading = ref(false);
const handleImport = () => {
fileInput.value?.click();
}
const onFileChange = async (event: Event) => {
const input = event.target as HTMLInputElement;
if (input.files && input.files.length > 0) {
const file = input.files[0];
uploading.value = true;
try {
await importData(file, true);
proxy?.$modal.msgSuccess("导入成功");
await getList();
} catch (err) {
proxy?.$modal.msgError("导入失败");
console.error(err);
} finally {
uploading.value = false;
input.value = '';
}
}
}
onMounted(() => {
getList();

@ -47,6 +47,12 @@
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['qms:qcInspectionType:export']"></el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExportTemplate" v-hasPermi="['qms:qcInspectionType:export']"></el-button>
</el-col>
<el-col :span="1.5">
<el-button type="primary" plain icon="Upload" @click="handleImport" v-hasPermi="['qms:qcInspectionType:add']"></el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" :columns="columns" :search="true" @queryTable="getList"></right-toolbar>
</el-row>
</template>
@ -86,6 +92,7 @@
<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>
<el-form ref="qcInspectionTypeFormRef" :model="form" :rules="rules" label-width="120px">
@ -126,11 +133,12 @@
</div>
</template>
</el-dialog>
<input ref="fileInput" type="file" accept=".xlsx, .xls" style="display: none" @change="onFileChange" />
</div>
</template>
<script setup name="QcInspectionType" lang="ts">
import { listQcInspectionType, getQcInspectionType, delQcInspectionType, addQcInspectionType, updateQcInspectionType } from '@/api/qms/qcInspectionType';
import { listQcInspectionType, getQcInspectionType, delQcInspectionType, addQcInspectionType, updateQcInspectionType, importData } from '@/api/qms/qcInspectionType';
import { QcInspectionTypeVO, QcInspectionTypeQuery, QcInspectionTypeForm } from '@/api/qms/qcInspectionType/types';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@ -189,12 +197,12 @@ const data = reactive<PageData<QcInspectionTypeForm, QcInspectionTypeQuery>>({
}
},
rules: {
typeId: [
{ required: true, message: "检测类型主键不能为空", trigger: "blur" }
],
typeCode: [
{ required: true, message: "检测类型编码不能为空", trigger: "blur" }
],
// typeId: [
// { required: true, message: "", trigger: "blur" }
// ],
// typeCode: [
// { required: true, message: "", trigger: "blur" }
// ],
typeName: [
{ required: true, message: "检测类型名称不能为空", trigger: "blur" }
],
@ -299,6 +307,36 @@ const handleExport = () => {
}, `qcInspectionType_${new Date().getTime()}.xlsx`)
}
const handleExportTemplate = () => {
proxy?.download('qms/qcInspectionType/exportTemplate', {
}, `qcInspectionType_${new Date().getTime()}.xlsx`)
}
/** 导入按钮操作 */
const fileInput = ref<HTMLInputElement>();
const uploading = ref(false);
const handleImport = () => {
fileInput.value?.click();
}
const onFileChange = async (event: Event) => {
const input = event.target as HTMLInputElement;
if (input.files && input.files.length > 0) {
const file = input.files[0];
uploading.value = true;
try {
await importData(file, true);
proxy?.$modal.msgSuccess("导入成功");
await getList();
} catch (err) {
proxy?.$modal.msgError("导入失败");
console.error(err);
} finally {
uploading.value = false;
input.value = '';
}
}
}
onMounted(() => {

Loading…
Cancel
Save