|
@@ -7,11 +7,11 @@
|
|
|
<el-button type="primary" icon="Plus" @click="handleAdd">录入</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="1.5">
|
|
|
- <el-button plain icon="Upload" @click="handleAdds">批量导入</el-button>
|
|
|
+ <el-button plain icon="Upload" @click="importDoc()">批量导入</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="1.5">
|
|
|
请先下载模板:
|
|
|
- <el-button type="primary" icon="Bottom">下载模板</el-button>
|
|
|
+ <el-button type="primary" icon="Bottom" @click="handleTemplate">下载模板</el-button>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<!-- 表格组件 -->
|
|
@@ -51,6 +51,19 @@
|
|
|
<RescueUnitAdd v-if="rescueUnitAddState.show" @close="handleCancel" @refresh="fetchUnitData" />
|
|
|
<RescueUnitEdit v-if="rescueUnitEditState.show" :event-id="rescueUnitEditState.eventId" @close="handleCancel" @refresh="fetchUnitData" />
|
|
|
<RescueUnitView v-if="rescueUnitViewState.show" :event-id="rescueUnitViewState.eventId" @close="handleCancel" />
|
|
|
+
|
|
|
+ <el-dialog ref="formImportDialogRef" v-model="showImportDlg" title="导入结构化文档" width="500px" append-to-body>
|
|
|
+ <el-form ref="formImportRef" :model="form" :rules="rules">
|
|
|
+ <FileUpload v-model="formImport.filename" :file-type="['xls', 'xlsx']" :limit="1" />
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <el-button :loading="buttonLoadingImport" type="primary" @click="submitImportForm">确 定</el-button>
|
|
|
+ <el-button @click="cancelImport">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -58,7 +71,7 @@
|
|
|
import { onMounted, reactive, ref, toRefs } from 'vue';
|
|
|
import { ElTable, ElTableColumn, ElButton, ElText } from 'element-plus';
|
|
|
import { ComponentInternalInstance, getCurrentInstance } from 'vue';
|
|
|
-import { getUnits, deleteUnit } from '@/api/comprehensiveGuarantee/reliefResourceManagement/rescueUnit';
|
|
|
+import { getUnits, deleteUnit, importDocXls } from '@/api/comprehensiveGuarantee/reliefResourceManagement/rescueUnit';
|
|
|
import Pagination from '@/components/Pagination/index.vue';
|
|
|
import RescueUnitAdd from './rescueUnitAdd.vue';
|
|
|
import RescueUnitEdit from './rescueUnitEdit.vue';
|
|
@@ -155,7 +168,7 @@ const handleDelete = (row: any) => {
|
|
|
proxy?.$modal.confirm('是否确认删除选择的数据项?').then(() => {
|
|
|
deleteUnit(row.id).then(() => {
|
|
|
proxy?.$modal.msgSuccess('停用成功');
|
|
|
- deleteUnit();
|
|
|
+ // deleteUnit();
|
|
|
});
|
|
|
});
|
|
|
};
|
|
@@ -166,6 +179,63 @@ const handleCancel = () => {
|
|
|
rescueUnitAddState.show = false;
|
|
|
};
|
|
|
|
|
|
+// 导入相关
|
|
|
+const baseUrl = import.meta.env.VITE_APP_BASE_API;
|
|
|
+const downLoadApi = import.meta.env.VITE_APP_BASE_DOWNLOAD_API;
|
|
|
+
|
|
|
+const showImportDlg = ref(false);
|
|
|
+const formImportDialogRef = ref(null);
|
|
|
+const formImportRef = ref<ElFormInstance>();
|
|
|
+const buttonLoadingImport = ref(false);
|
|
|
+
|
|
|
+const formImport = ref({
|
|
|
+ filename: ''
|
|
|
+});
|
|
|
+
|
|
|
+const rules = reactive({
|
|
|
+ filename: [{ required: true, message: '导入文件不能为空', trigger: 'blur' }]
|
|
|
+});
|
|
|
+
|
|
|
+const importDoc = () => {
|
|
|
+ resetImportForm();
|
|
|
+ showImportDlg.value = true;
|
|
|
+};
|
|
|
+
|
|
|
+const resetImportForm = () => {
|
|
|
+ formImport.value = {
|
|
|
+ filename: ''
|
|
|
+ };
|
|
|
+ formImportRef.value?.resetFields();
|
|
|
+ formImportRef.value?.clearValidate();
|
|
|
+};
|
|
|
+
|
|
|
+/**提交按钮 */
|
|
|
+const submitImportForm = () => {
|
|
|
+ formImportRef.value?.validate(async (valid) => {
|
|
|
+ if (valid) {
|
|
|
+ try {
|
|
|
+ buttonLoadingImport.value = true;
|
|
|
+ await importDocXls({ ...form.value});
|
|
|
+ proxy?.$modal.msgSuccess('导入成功');
|
|
|
+ showImportDlg.value = false;
|
|
|
+ fetchUnitData();
|
|
|
+ } finally {
|
|
|
+ buttonLoadingImport.value = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+/** 取消按钮 */
|
|
|
+const cancelImport = () => {
|
|
|
+ resetImportForm();
|
|
|
+ showImportDlg.value = false;
|
|
|
+};
|
|
|
+
|
|
|
+const handleTemplate = async () => {
|
|
|
+ location.href = baseUrl + downLoadApi + 'rescue_unit_import.xlsx';
|
|
|
+};
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
fetchUnitData();
|
|
|
});
|