From eae12ffeaa667f271a2c548b5e16557cac3686e3 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期三, 18 三月 2026 20:35:46 +0800
Subject: [PATCH] 能耗成本核算图表相关优化
---
src/views/productionManagement/productStructure/ImportDialog.vue | 242 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 242 insertions(+), 0 deletions(-)
diff --git a/src/views/productionManagement/productStructure/ImportDialog.vue b/src/views/productionManagement/productStructure/ImportDialog.vue
new file mode 100644
index 0000000..5e5e58f
--- /dev/null
+++ b/src/views/productionManagement/productStructure/ImportDialog.vue
@@ -0,0 +1,242 @@
+<template>
+ <el-dialog :title="title"
+ v-model="dialogVisible"
+ :width="width"
+ :append-to-body="appendToBody"
+ @close="handleClose">
+ <div v-if="showProductTypeSelect"
+ style="margin-bottom: 20px;">
+ <el-form :inline="true"
+ :model="form">
+ <el-form-item label="浜у搧绫诲瀷"
+ prop="dictCode"
+ style="margin-bottom: 0;">
+ <el-select v-model="form.dictCode"
+ placeholder="璇烽�夋嫨浜у搧绫诲瀷"
+ clearable
+ style="width: 200px;">
+ <el-option v-for="option in productTypeOptions"
+ :key="option.dictCode"
+ :label="option.dictLabel"
+ :value="option.dictCode" />
+ </el-select>
+ </el-form-item>
+ </el-form>
+ </div>
+ <el-upload ref="uploadRef"
+ :limit="limit"
+ :accept="accept"
+ :headers="headers"
+ :action="action"
+ :data="uploadData"
+ :disabled="disabled"
+ :before-upload="beforeUpload"
+ :on-progress="onProgress"
+ :on-success="onSuccess"
+ :on-error="onError"
+ :on-change="onChange"
+ :auto-upload="autoUpload"
+ drag>
+ <el-icon class="el-icon--upload">
+ <UploadFilled />
+ </el-icon>
+ <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div>
+ <template #tip>
+ <div class="el-upload__tip text-center">
+ <span>{{ tipText }}</span>
+ <el-link v-if="showDownloadTemplate"
+ type="primary"
+ :underline="false"
+ style="font-size: 12px; vertical-align: baseline; margin-left: 5px;"
+ @click="handleDownloadTemplate">涓嬭浇妯℃澘</el-link>
+ </div>
+ </template>
+ </el-upload>
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button type="primary"
+ @click="handleConfirm">纭� 瀹�</el-button>
+ <el-button @click="handleCancel">鍙� 娑�</el-button>
+ </div>
+ </template>
+ </el-dialog>
+</template>
+
+<script setup>
+ import { computed, ref, reactive, watch } from "vue";
+ import { UploadFilled } from "@element-plus/icons-vue";
+ import { ElMessage } from "element-plus";
+ import { getDicts } from "@/api/system/dict/data";
+
+ const props = defineProps({
+ modelValue: {
+ type: Boolean,
+ default: false,
+ },
+ title: {
+ type: String,
+ default: "瀵煎叆",
+ },
+ width: {
+ type: String,
+ default: "400px",
+ },
+ appendToBody: {
+ type: Boolean,
+ default: true,
+ },
+ limit: {
+ type: Number,
+ default: 1,
+ },
+ accept: {
+ type: String,
+ default: ".xlsx, .xls",
+ },
+ headers: {
+ type: Object,
+ default: () => ({}),
+ },
+ action: {
+ type: String,
+ required: true,
+ },
+ disabled: {
+ type: Boolean,
+ default: false,
+ },
+ autoUpload: {
+ type: Boolean,
+ default: false,
+ },
+ tipText: {
+ type: String,
+ default: "浠呭厑璁稿鍏ls銆亁lsx鏍煎紡鏂囦欢銆�",
+ },
+ showDownloadTemplate: {
+ type: Boolean,
+ default: true,
+ },
+ showProductTypeSelect: {
+ type: Boolean,
+ default: false,
+ },
+ beforeUpload: {
+ type: Function,
+ default: null,
+ },
+ onProgress: {
+ type: Function,
+ default: null,
+ },
+ onSuccess: {
+ type: Function,
+ default: null,
+ },
+ onError: {
+ type: Function,
+ default: null,
+ },
+ onChange: {
+ type: Function,
+ default: null,
+ },
+ });
+
+ const emit = defineEmits([
+ "update:modelValue",
+ "close",
+ "confirm",
+ "cancel",
+ "download-template",
+ ]);
+
+ const dialogVisible = computed({
+ get: () => props.modelValue,
+ set: val => emit("update:modelValue", val),
+ });
+
+ const uploadRef = ref(null);
+ const productTypeOptions = ref([]);
+ const form = reactive({
+ dictCode: "",
+ });
+
+ // 鑾峰彇浜у搧绫诲瀷瀛楀吀
+ const getProductTypeOptions = () => {
+ getDicts("product_type")
+ .then(res => {
+ if (res.code === 200) {
+ productTypeOptions.value = res.data;
+ }
+ })
+ .catch(err => {
+ console.error("鑾峰彇浜у搧绫诲瀷瀛楀吀澶辫触锛�", err);
+ });
+ };
+
+ // 鐩戝惉瀵硅瘽妗嗘樉绀猴紝鍔犺浇浜у搧绫诲瀷瀛楀吀
+ watch(
+ () => props.modelValue,
+ newVal => {
+ if (newVal && props.showProductTypeSelect) {
+ getProductTypeOptions();
+ }
+ }
+ );
+
+ // 涓婁紶鏁版嵁
+ const uploadData = computed(() => {
+ if (props.showProductTypeSelect) {
+ return {
+ dictCode: form.dictCode,
+ };
+ }
+ return {};
+ });
+
+ const handleClose = () => {
+ form.dictCode = "";
+ emit("close");
+ };
+
+ const handleConfirm = () => {
+ if (props.showProductTypeSelect && !form.dictCode) {
+ ElMessage.warning("璇烽�夋嫨浜у搧绫诲瀷");
+ return;
+ }
+ emit("confirm");
+ };
+
+ const submit = () => {
+ if (uploadRef.value) {
+ uploadRef.value.submit();
+ }
+ };
+
+ const handleCancel = () => {
+ form.dictCode = "";
+ emit("cancel");
+ dialogVisible.value = false;
+ };
+
+ const handleDownloadTemplate = () => {
+ emit("download-template");
+ };
+
+ defineExpose({
+ uploadRef,
+ submit,
+ clearFiles: () => {
+ if (uploadRef.value) {
+ uploadRef.value.clearFiles();
+ }
+ },
+ });
+</script>
+
+<style scoped>
+ .dialog-footer {
+ text-align: center;
+ }
+</style>
\ No newline at end of file
--
Gitblit v1.9.3