|
|
@@ -57,7 +57,19 @@
|
|
|
</el-form>
|
|
|
|
|
|
<div class="check-items-section">
|
|
|
- <div class="section-header">
|
|
|
+ <el-button plain @click="TemplateDownload">
|
|
|
+ 模板下载
|
|
|
+ </el-button>
|
|
|
+ <el-button plain @click="handleeDownload" v-if="isCreateMode || isEditMode">
|
|
|
+ 导入
|
|
|
+ </el-button>
|
|
|
+ <el-button plain @click="handleeTemplateDownload" v-if="isEditMode || isViewMode">
|
|
|
+ 导出
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div>
|
|
|
+ <!-- <div class="section-header">
|
|
|
<el-upload
|
|
|
v-if="isEditMode && props.id"
|
|
|
:show-file-list="false"
|
|
|
@@ -66,7 +78,7 @@
|
|
|
>
|
|
|
<el-button type="primary" size="small">批量导入明细</el-button>
|
|
|
</el-upload>
|
|
|
- </div>
|
|
|
+ </div> -->
|
|
|
<div class="check-items-table">
|
|
|
<el-table :data="checkItems" border :span-method="handleSpanMethod">
|
|
|
<el-table-column label="编号" type="index" width="80" align="center" />
|
|
|
@@ -120,7 +132,18 @@
|
|
|
</el-table>
|
|
|
</div>
|
|
|
</div>
|
|
|
+
|
|
|
</main>
|
|
|
+ <BatchImport
|
|
|
+ v-if="batchImportVisible"
|
|
|
+ :visible="batchImportVisible"
|
|
|
+ :import-api-url="importApiUrl"
|
|
|
+ :template-url="templateUrl"
|
|
|
+ template-name="下载模板"
|
|
|
+ :show-template="false"
|
|
|
+ @close="batchImportVisible = false"
|
|
|
+ @update="handleUpdate"
|
|
|
+ />
|
|
|
<footer class="safety-platform-container__footer">
|
|
|
<el-button @click="router.back()">返回</el-button>
|
|
|
<el-button v-if="!isViewMode" type="primary" @click="handleSubmit">
|
|
|
@@ -140,10 +163,15 @@
|
|
|
saveChecklistTemplate,
|
|
|
updateChecklistTemplate,
|
|
|
importChecklistTemplateItem,
|
|
|
+ checklistTemplateDownload,
|
|
|
+ checklistHandleeTemplateDownload,
|
|
|
type ChecklistTemplateItem,
|
|
|
} from '@/api/production-safety-system';
|
|
|
import { queryDictTypeDetail } from '@/api/dict';
|
|
|
-
|
|
|
+ import { downloadByData } from '@/utils/file/download';
|
|
|
+ import BatchImport from '@/components/batch-import/BatchImport.vue';
|
|
|
+ import { useGlobSetting } from '@/hooks/setting';
|
|
|
+ import urlJoin from 'url-join';
|
|
|
const props = defineProps<{
|
|
|
id?: number;
|
|
|
}>();
|
|
|
@@ -369,6 +397,58 @@
|
|
|
return { rowspan: 1, colspan: 1 };
|
|
|
};
|
|
|
|
|
|
+ // 批量导入
|
|
|
+ const batchImportVisible = ref(false);
|
|
|
+ const { urlPrefix } = useGlobSetting();
|
|
|
+ const importApiUrl = ref(urlJoin(urlPrefix, '/areaCheckPlanManageAdmin/importCheckList'));
|
|
|
+ const templateUrl = ref('./skyeye-file-upload/sfysecurity/TEMPLATE/import-hidden-danger-template.xlsx');
|
|
|
+
|
|
|
+ const handleeDownload = () => {
|
|
|
+ batchImportVisible.value = true;
|
|
|
+ };
|
|
|
+
|
|
|
+ const handleUpdate = (value) => {
|
|
|
+ batchImportVisible.value = false;
|
|
|
+ console.log('批量导入成功:', value);
|
|
|
+ if(value.importData && value.importData.length > 0){
|
|
|
+ let newItems = value.importData.map((item) => ({
|
|
|
+ checkContent: item.checkContent || '',
|
|
|
+ checkStandard: item.checkStandard || '',
|
|
|
+ checkResult: item.checkResult || '待检',
|
|
|
+ checkProblem: item.checkProblem || '',
|
|
|
+ }));
|
|
|
+ checkItems.value = [...checkItems.value, ...newItems];
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ const TemplateDownload = async () => {
|
|
|
+ try {
|
|
|
+ const response = await checklistTemplateDownload();
|
|
|
+ if (response) {
|
|
|
+ const fileName = `检查模板_${new Date().toISOString().split('T')[0]}.xlsx`;
|
|
|
+ downloadByData(response, fileName);
|
|
|
+ ElMessage.success('下载成功');
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.error('下载检查模板失败:', e);
|
|
|
+ ElMessage.error('下载失败,请重试');
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ const handleeTemplateDownload = async () => {
|
|
|
+ try {
|
|
|
+ const response = await checklistHandleeTemplateDownload(Number(props.id));
|
|
|
+ if (response) {
|
|
|
+ const fileName = `检查模板_${new Date().toISOString().split('T')[0]}.xlsx`;
|
|
|
+ downloadByData(response, fileName);
|
|
|
+ ElMessage.success('下载成功');
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.error('下载检查模板失败:', e);
|
|
|
+ ElMessage.error('下载失败,请重试');
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
onMounted(async () => {
|
|
|
await loadCategoryOptions();
|
|
|
if (isEditMode.value || isViewMode.value) {
|
|
|
@@ -398,7 +478,7 @@
|
|
|
}
|
|
|
|
|
|
.check-items-section {
|
|
|
- margin-top: 32px;
|
|
|
+ margin: 32px 0 15px 0;
|
|
|
}
|
|
|
|
|
|
.section-header {
|