2024-06-11 设备管理-备品备件-导入功能

yangwl
A0010407 6 months ago
parent 10f33fac3f
commit 0ecbbb36cb

@ -122,6 +122,19 @@
>导出</el-button >导出</el-button
> >
</el-col> </el-col>
<el-col :span="1.5">
<div>
<el-button
type="warning"
plain
icon="el-icon-upload2"
size="mini"
@click="handleImport"
v-hasPermi="['device:sparePartsLedger:import']"
>导入</el-button
>
</div>
</el-col>
<right-toolbar <right-toolbar
:showSearch.sync="showSearch" :showSearch.sync="showSearch"
@queryTable="getList" @queryTable="getList"
@ -331,7 +344,7 @@
<!-- 添加或修改备品备件台账管理对话框 --> <!-- 添加或修改备品备件台账管理对话框 -->
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="120px"> <el-form ref="form" :model="form" :rules="rules" label-width="120px">
<!-- <!--
<el-form-item label="唯一序列" prop="storageId"> <el-form-item label="唯一序列" prop="storageId">
<el-input v-model="form.storageId" placeholder="请输入唯一序列" /> <el-input v-model="form.storageId" placeholder="请输入唯一序列" />
</el-form-item> </el-form-item>
@ -352,7 +365,7 @@
</el-form-item> </el-form-item>
<el-form-item label="物料描述" prop="materialDesc"> <el-form-item label="物料描述" prop="materialDesc">
<el-input v-model="form.materialDesc" placeholder="请输入物料描述" /> <el-input v-model="form.materialDesc" placeholder="请输入物料描述" />
</el-form-item> </el-form-item>
--> -->
<!-- <el-form-item label="占用数量" prop="occupyAmount"> <!-- <el-form-item label="占用数量" prop="occupyAmount">
<el-input v-model="form.occupyAmount" placeholder="请输入占用数量" /> <el-input v-model="form.occupyAmount" placeholder="请输入占用数量" />
@ -644,7 +657,7 @@
<el-form-item label="循环周期" prop="spareReplacementCycle"> <el-form-item label="循环周期" prop="spareReplacementCycle">
<el-input v-model="form.spareReplacementCycle" placeholder="请输入循环周期" /> <el-input v-model="form.spareReplacementCycle" placeholder="请输入循环周期" />
</el-form-item> --> </el-form-item> -->
<!-- <!--
<el-form-item label="计量单位" prop="spareMeasurementUnit"> <el-form-item label="计量单位" prop="spareMeasurementUnit">
<el-input v-model="form.spareMeasurementUnit" placeholder="请输入计量单位" /> <el-input v-model="form.spareMeasurementUnit" placeholder="请输入计量单位" />
</el-form-item> </el-form-item>
@ -666,6 +679,44 @@
<el-button @click="cancel"> </el-button> <el-button @click="cancel"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- 用户导入对话框 -->
<el-dialog
:title="upload.title"
:visible.sync="upload.open"
width="400px"
append-to-body
>
<el-upload
ref="upload"
:limit="1"
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<span>仅允许导入xlsxlsx格式文件</span>
<el-link
type="primary"
:underline="false"
style="font-size: 12px; vertical-align: baseline"
@click="importTemplate"
>下载模板
</el-link>
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm"> </el-button>
<el-button @click="upload.open = false"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
@ -677,11 +728,32 @@ import {
addSparePartsLedger, addSparePartsLedger,
updateSparePartsLedger, updateSparePartsLedger,
} from "@/api/device/sparePartsLedger"; } from "@/api/device/sparePartsLedger";
import { getToken } from "@/utils/auth";
export default { export default {
name: "SparePartsLedger", name: "SparePartsLedger",
data() { data() {
return { return {
//
upload: {
//
open: false,
//
title: "",
//
isUploading: false,
//
updateSupport: 0,
//
headers: {
poolName: localStorage.getItem("USER_POOL_NAME_CURRENT"),
Authorization: "Bearer " + getToken(),
},
//
url:
process.env.VUE_APP_BASE_API + "/device/sparePartsLedger/importFile",
},
// //
loading: true, loading: true,
// //
@ -924,6 +996,47 @@ export default {
`sparePartsLedger_${new Date().getTime()}.xlsx` `sparePartsLedger_${new Date().getTime()}.xlsx`
); );
}, },
// -
handleImport() {
this.upload.title = "设备信息导入";
this.upload.open = true;
},
// -
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true;
},
// -
handleFileSuccess(response, file, fileList) {
debugger;
this.upload.open = false;
this.upload.isUploading = false;
this.$refs.upload.clearFiles();
this.$alert(
"<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
response.msg +
"</div>",
"导入结果",
{ dangerouslyUseHTMLString: true }
);
this.getList();
},
// -
submitFileForm() {
this.$refs.upload.submit();
},
// -
importTemplate() {
this.download(
"/device/sparePartsLedger/importTemplate",
{},
`sparePartsLedger_template_${new Date().getTime()}.xlsx`
);
},
}, },
}; };
</script> </script>

Loading…
Cancel
Save