|
@@ -7,7 +7,7 @@
|
|
|
<el-row :gutter="30" style="height: 50px">
|
|
|
<el-col :span="10">
|
|
|
<el-button type="primary" icon="Plus" @click="handleAdd">新增</el-button>
|
|
|
- <el-button plain icon="Upload" @click="handleImport">数据导入</el-button>
|
|
|
+ <el-button plain icon="Upload" @click="importDoc">数据导入</el-button>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</transition>
|
|
@@ -37,7 +37,19 @@
|
|
|
</div>
|
|
|
<addTypesMaterials v-if="addTypesMaterialsState.show" :id="detailId" @close="handleCancel" />
|
|
|
<TypesMaterialsDetails v-if="TypesMaterialsDetailsState.show" :id="detailId" @close="handleCancel" />
|
|
|
- <impotTypesMaterials v-if="impotTypesMaterialsState.show" @close="handleCancel" />
|
|
|
+ <!--<impotTypesMaterials v-if="impotTypesMaterialsState.show" @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>
|
|
|
<script setup lang="ts">
|
|
@@ -45,7 +57,7 @@ import addTypesMaterials from './addTypesMaterials.vue';
|
|
|
import impotTypesMaterials from './impotTypesMaterials.vue';
|
|
|
import TypesMaterialsDetails from './TypesMaterialsDetails.vue';
|
|
|
import { ref, reactive, onMounted, onBeforeUnmount } from 'vue';
|
|
|
-import { deleteMaterialType, getMaterialTypeList } from '@/api/comprehensiveGuarantee/materialReserveManagement/typesMaterialsManagement';
|
|
|
+import { deleteMaterialType, getMaterialTypeList, importMaterialTypeExcel } from '@/api/comprehensiveGuarantee/materialReserveManagement/typesMaterialsManagement';
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
const { show_status, material_category_level } = toRefs<any>(proxy?.useDict('show_status', 'material_category_level'));
|
|
|
// 定义响应式变量
|
|
@@ -114,9 +126,9 @@ const handleCancel = (needUpdate) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-const handleImport = () => {
|
|
|
- impotTypesMaterialsState.show = true;
|
|
|
-};
|
|
|
+// const handleImport = () => {
|
|
|
+// impotTypesMaterialsState.show = true;
|
|
|
+// };
|
|
|
|
|
|
const handlePaginationChange = (page: number) => {
|
|
|
queryParams.page = page;
|
|
@@ -130,6 +142,60 @@ const getList = () => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+// 导入相关
|
|
|
+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 importMaterialTypeExcel({ ...form.value});
|
|
|
+ proxy?.$modal.msgSuccess('导入成功');
|
|
|
+ showImportDlg.value = false;
|
|
|
+ getList();
|
|
|
+ } finally {
|
|
|
+ buttonLoadingImport.value = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+/** 取消按钮 */
|
|
|
+const cancelImport = () => {
|
|
|
+ resetImportForm();
|
|
|
+ showImportDlg.value = false;
|
|
|
+};
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
getList();
|
|
|
window.addEventListener('resize', handleResize);
|