|
|
@@ -1,243 +1,251 @@
|
|
|
<template>
|
|
|
- <div>
|
|
|
- <el-dialog title="导入数据" append-to-body :visible.sync="excelBox" width="60%" :close-on-click-modal="false"
|
|
|
- v-dialog-drag>
|
|
|
- <span>
|
|
|
- <avue-crud v-if="excelBox" :data="data" :option="option" :table-loading="loading"
|
|
|
- :cell-style="cellStyle" @selection-change="selectionChange">
|
|
|
- <template v-if="!(type==5||type==6)" slot="menuLeft" slot-scope="{size}">
|
|
|
- <el-button type="primary" size="mini" icon="el-icon-download" @click="download()">
|
|
|
- 下载模板
|
|
|
- </el-button>
|
|
|
- <el-upload :action="action" :headers="headers" :on-progress="onProgress" :show-file-list=false
|
|
|
- accept=".xls,.xlsx" multiple :on-success="onSuccess" :on-error="onError"
|
|
|
- :on-change="onChange" style="float: right">
|
|
|
- <el-button type="success" size="mini" icon="el-icon-upload">上传数据</el-button>
|
|
|
- </el-upload>
|
|
|
- </template>
|
|
|
- </avue-crud>
|
|
|
- </span>
|
|
|
- <span slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="excelBox = false" size="mini">取 消</el-button>
|
|
|
- <el-button type="primary" @click="importData" size="mini">导 入</el-button>
|
|
|
- </span>
|
|
|
- </el-dialog>
|
|
|
- </div>
|
|
|
+ <div>
|
|
|
+ <el-dialog title="导入数据" append-to-body :visible.sync="excelBox" width="60%" :close-on-click-modal="false" v-dialog-drag>
|
|
|
+ <span>
|
|
|
+ <avue-crud v-if="excelBox" :data="data" :option="option" :table-loading="loading" :cell-style="cellStyle" @selection-change="selectionChange">
|
|
|
+ <template v-if="!(type == 5 || type == 6)" slot="menuLeft" slot-scope="{ size }">
|
|
|
+ <el-button type="primary" size="mini" icon="el-icon-download" @click="download()">
|
|
|
+ 下载模板
|
|
|
+ </el-button>
|
|
|
+ <el-upload
|
|
|
+ :action="action"
|
|
|
+ :headers="headers"
|
|
|
+ :on-progress="onProgress"
|
|
|
+ :show-file-list="false"
|
|
|
+ accept=".xls,.xlsx"
|
|
|
+ multiple
|
|
|
+ :on-success="onSuccess"
|
|
|
+ :on-error="onError"
|
|
|
+ :on-change="onChange"
|
|
|
+ style="float: right"
|
|
|
+ >
|
|
|
+ <el-button type="success" size="mini" icon="el-icon-upload">上传数据</el-button>
|
|
|
+ </el-upload>
|
|
|
+ </template>
|
|
|
+ </avue-crud>
|
|
|
+ </span>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="excelBox = false" size="mini">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="importData" size="mini">导 入</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import { getDicinit } from "@/api/dicSelect/index";
|
|
|
import { getToken } from "@/util/auth";
|
|
|
export default {
|
|
|
- data() {
|
|
|
- return {
|
|
|
- loading: false,
|
|
|
- headers: { "Blade-Auth": 'Bearer ' + getToken() },
|
|
|
- action: null,
|
|
|
- excelBox: false,
|
|
|
- data: [],
|
|
|
- selectionList: [],
|
|
|
- option: {
|
|
|
- height: 500,
|
|
|
- border: true,
|
|
|
- align: 'center',
|
|
|
- menu: false,
|
|
|
- addBtn: false,
|
|
|
- refreshBtn: false,
|
|
|
- columnBtn: false,
|
|
|
- stripe: true,
|
|
|
- tip: false,
|
|
|
- selection: true,
|
|
|
- column: [
|
|
|
- {
|
|
|
- label: '放箱号',
|
|
|
- prop: 'containerNumber',
|
|
|
- overHidden: true,
|
|
|
- },
|
|
|
- {
|
|
|
- label: '箱号',
|
|
|
- prop: 'boxCode',
|
|
|
- overHidden: true,
|
|
|
- },
|
|
|
- {
|
|
|
- label: '箱型',
|
|
|
- prop: 'boxType',
|
|
|
- overHidden: true,
|
|
|
- },
|
|
|
- {
|
|
|
- label: '港口',
|
|
|
- prop: 'portName',
|
|
|
- overHidden: true,
|
|
|
- },
|
|
|
- {
|
|
|
- label: '场站',
|
|
|
- prop: 'stationName',
|
|
|
- overHidden: true,
|
|
|
- },
|
|
|
- {
|
|
|
- label: '提单号',
|
|
|
- prop: 'mblno',
|
|
|
- overHidden: true,
|
|
|
- },
|
|
|
- {
|
|
|
- label: '箱动态',
|
|
|
- prop: 'boxStatus',
|
|
|
- overHidden: true,
|
|
|
- },
|
|
|
- {
|
|
|
- label: '动态日期',
|
|
|
- prop: 'boxStatusDate',
|
|
|
- overHidden: true,
|
|
|
- width: 100,
|
|
|
- type: "date",
|
|
|
- format: 'yyyy-MM-dd',
|
|
|
- valueFormat: 'yyyy-MM-dd'
|
|
|
- },
|
|
|
- // {
|
|
|
- // label: '单据号',
|
|
|
- // prop: 'billNo',
|
|
|
- // overHidden: true,
|
|
|
- // },
|
|
|
- {
|
|
|
- label: '结果',
|
|
|
- prop: 'result',
|
|
|
- overHidden: true,
|
|
|
- },
|
|
|
- {
|
|
|
- label: '原因',
|
|
|
- prop: 'reason',
|
|
|
- overHidden: true,
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- url: null,
|
|
|
- type: null
|
|
|
- };
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ loading: false,
|
|
|
+ headers: { "Blade-Auth": "Bearer " + getToken() },
|
|
|
+ action: null,
|
|
|
+ excelBox: false,
|
|
|
+ data: [],
|
|
|
+ selectionList: [],
|
|
|
+ option: {
|
|
|
+ height: 500,
|
|
|
+ border: true,
|
|
|
+ align: "center",
|
|
|
+ menu: false,
|
|
|
+ addBtn: false,
|
|
|
+ refreshBtn: false,
|
|
|
+ columnBtn: false,
|
|
|
+ stripe: true,
|
|
|
+ tip: false,
|
|
|
+ selection: true,
|
|
|
+ column: [
|
|
|
+ {
|
|
|
+ label: "放箱号",
|
|
|
+ prop: "containerNumber",
|
|
|
+ overHidden: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "箱号",
|
|
|
+ prop: "boxCode",
|
|
|
+ overHidden: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "箱型",
|
|
|
+ prop: "boxType",
|
|
|
+ overHidden: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "港口",
|
|
|
+ prop: "portName",
|
|
|
+ overHidden: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "场站",
|
|
|
+ prop: "stationName",
|
|
|
+ overHidden: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "提单号",
|
|
|
+ prop: "mblno",
|
|
|
+ overHidden: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "箱动态",
|
|
|
+ prop: "boxStatus",
|
|
|
+ overHidden: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "动态日期",
|
|
|
+ prop: "boxStatusDate",
|
|
|
+ overHidden: true,
|
|
|
+ width: 130,
|
|
|
+ type: "date",
|
|
|
+ format: "yyyy-MM-dd HH:mm:ss",
|
|
|
+ valueFormat: "yyyy-MM-dd HH:mm:ss"
|
|
|
+ },
|
|
|
+ // {
|
|
|
+ // label: '单据号',
|
|
|
+ // prop: 'billNo',
|
|
|
+ // overHidden: true,
|
|
|
+ // },
|
|
|
+ {
|
|
|
+ label: "结果",
|
|
|
+ prop: "result",
|
|
|
+ overHidden: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "原因",
|
|
|
+ prop: "reason",
|
|
|
+ overHidden: true
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ url: null,
|
|
|
+ type: null
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {},
|
|
|
+ methods: {
|
|
|
+ //去重判断
|
|
|
+ mergeAndDeduplicate(arr1, arr2) {
|
|
|
+ // 合并两个数组
|
|
|
+ const combined = [...arr1, ...arr2];
|
|
|
+ // 使用Map来存储唯一对象(基于id和name)
|
|
|
+ const uniqueMap = new Map();
|
|
|
+ combined.forEach(item => {
|
|
|
+ // 创建一个唯一的键值对
|
|
|
+ const key = `${item.containerNumber}-${item.boxCode}`;
|
|
|
+ if (!uniqueMap.has(key)) {
|
|
|
+ // 添加到Map中,确保唯一性
|
|
|
+ uniqueMap.set(key, item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 从Map转换回数组
|
|
|
+ return Array.from(uniqueMap.values());
|
|
|
+ },
|
|
|
+ //文件上传时的钩子
|
|
|
+ onProgress(event, file, fileList) {
|
|
|
+ this.loading = true;
|
|
|
+ },
|
|
|
+ //文件上传成功时的钩子
|
|
|
+ onSuccess(res, file) {
|
|
|
+ this.data = this.mergeAndDeduplicate(this.data, res.data);
|
|
|
+ this.$message.success("上传成功");
|
|
|
+ this.loading = false;
|
|
|
},
|
|
|
- created() { },
|
|
|
- methods: {
|
|
|
- //去重判断
|
|
|
- mergeAndDeduplicate(arr1, arr2) {
|
|
|
- // 合并两个数组
|
|
|
- const combined = [...arr1, ...arr2];
|
|
|
- // 使用Map来存储唯一对象(基于id和name)
|
|
|
- const uniqueMap = new Map();
|
|
|
- combined.forEach(item => {
|
|
|
- // 创建一个唯一的键值对
|
|
|
- const key = `${item.containerNumber}-${item.boxCode}`;
|
|
|
- if (!uniqueMap.has(key)) {
|
|
|
- // 添加到Map中,确保唯一性
|
|
|
- uniqueMap.set(key, item);
|
|
|
- }
|
|
|
- });
|
|
|
- // 从Map转换回数组
|
|
|
- return Array.from(uniqueMap.values());
|
|
|
- },
|
|
|
- //文件上传时的钩子
|
|
|
- onProgress(event, file, fileList) {
|
|
|
- this.loading = true
|
|
|
- },
|
|
|
- //文件上传成功时的钩子
|
|
|
- onSuccess(res, file) {
|
|
|
- this.data = this.mergeAndDeduplicate(this.data, res.data)
|
|
|
- this.$message.success('上传成功');
|
|
|
- this.loading = false
|
|
|
- },
|
|
|
- //文件上传失败时的钩子
|
|
|
- onError(err, file, fileList) {
|
|
|
- let errorMsg = err.toString();
|
|
|
- errorMsg = errorMsg.replace('Error:', '')
|
|
|
- errorMsg = JSON.parse(errorMsg)
|
|
|
- this.$message.error(errorMsg.msg);
|
|
|
- this.loading = false
|
|
|
- },
|
|
|
- //上传成功和上传失败时都会被调用
|
|
|
- onChange(file, fileList) {
|
|
|
- // if (file.status == "fail") {
|
|
|
- // this.$message.error("上传失败");
|
|
|
- // }
|
|
|
- },
|
|
|
- // //上传文件之前的钩子
|
|
|
- // beforeUpload(file) {
|
|
|
+ //文件上传失败时的钩子
|
|
|
+ onError(err, file, fileList) {
|
|
|
+ let errorMsg = err.toString();
|
|
|
+ errorMsg = errorMsg.replace("Error:", "");
|
|
|
+ errorMsg = JSON.parse(errorMsg);
|
|
|
+ this.$message.error(errorMsg.msg);
|
|
|
+ this.loading = false;
|
|
|
+ },
|
|
|
+ //上传成功和上传失败时都会被调用
|
|
|
+ onChange(file, fileList) {
|
|
|
+ // if (file.status == "fail") {
|
|
|
+ // this.$message.error("上传失败");
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ // //上传文件之前的钩子
|
|
|
+ // beforeUpload(file) {
|
|
|
|
|
|
- // },
|
|
|
- openDialog(type, list) {
|
|
|
- this.data = []
|
|
|
- this.selectionList = []
|
|
|
- this.excelBox = true
|
|
|
- if (type == 1) {
|
|
|
- this.action = '/api/blade-los/boxPool/emptyContainerEntryAnalysis'
|
|
|
- this.url = '/blade-los/boxPool/emptyContainerEntry'
|
|
|
- }
|
|
|
- if (type == 2) {
|
|
|
- this.action = '/api/blade-los/boxPool/emptyContainerAppearanceAnalysis'
|
|
|
- this.url = '/blade-los/boxPool/emptyContainerAppearance'
|
|
|
- }
|
|
|
- if (type == 3) {
|
|
|
- this.action = '/api/blade-los/boxPool/giveAnEncoreAnalysis'
|
|
|
- this.url = '/blade-los/boxPool/giveAnEncore'
|
|
|
- }
|
|
|
- if (type == 4) {
|
|
|
- this.action = '/api/blade-los/boxPool/returnEmptyAnalysis'
|
|
|
- this.url = '/blade-los/boxPool/returnEmpty'
|
|
|
- }
|
|
|
- if (type == 5) {
|
|
|
- this.data=list
|
|
|
- this.url = '/blade-los/boxPool/emptyContainerEntry'
|
|
|
- }
|
|
|
- if (type == 6) {
|
|
|
- this.data=list
|
|
|
- this.url = '/blade-los/boxPool/emptyContainerAppearance'
|
|
|
- }
|
|
|
- this.type = type
|
|
|
- },
|
|
|
- download() {
|
|
|
- if (this.type == 1) {
|
|
|
- window.open(`/api/blade-los/boxPool/emptyContainerEntry/template?${this.website.tokenHeader}=${getToken()}`);
|
|
|
- }
|
|
|
- if (this.type == 2) {
|
|
|
- window.open(`/api/blade-los/boxPool/emptyContainerAppearance/template?${this.website.tokenHeader}=${getToken()}`);
|
|
|
- }
|
|
|
- if (this.type == 3 || this.type == 4) {
|
|
|
- window.open(`/api/blade-los/boxPool/giveAnEncore/template?${this.website.tokenHeader}=${getToken()}`);
|
|
|
- }
|
|
|
- },
|
|
|
- selectionChange(list) {
|
|
|
- this.selectionList = list
|
|
|
- },
|
|
|
- importData() {
|
|
|
- if (this.data.length == 0) {
|
|
|
- return this.$message.error("请上传数据");
|
|
|
- }
|
|
|
- if (this.selectionList.length == 0) {
|
|
|
- return this.$message.error("请选择数据");
|
|
|
- }
|
|
|
- this.loading = true
|
|
|
- getDicinit('POST', this.url, this.selectionList).then(res => {
|
|
|
- this.excelBox = false
|
|
|
- this.$emit('refreshData')
|
|
|
- }).finally(() => {
|
|
|
- this.loading = false;
|
|
|
- })
|
|
|
- },
|
|
|
- cellStyle({ row, column, rowIndex, columnIndex }) {
|
|
|
- if (row.result == '失败') {
|
|
|
- return {
|
|
|
- color: '#F56C6C',
|
|
|
- }
|
|
|
- } else {
|
|
|
- return {
|
|
|
- color: '##67C23A',
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // },
|
|
|
+ openDialog(type, list) {
|
|
|
+ this.data = [];
|
|
|
+ this.selectionList = [];
|
|
|
+ this.excelBox = true;
|
|
|
+ if (type == 1) {
|
|
|
+ this.action = "/api/blade-los/boxPool/emptyContainerEntryAnalysis";
|
|
|
+ this.url = "/blade-los/boxPool/emptyContainerEntry";
|
|
|
+ }
|
|
|
+ if (type == 2) {
|
|
|
+ this.action = "/api/blade-los/boxPool/emptyContainerAppearanceAnalysis";
|
|
|
+ this.url = "/blade-los/boxPool/emptyContainerAppearance";
|
|
|
+ }
|
|
|
+ if (type == 3) {
|
|
|
+ this.action = "/api/blade-los/boxPool/giveAnEncoreAnalysis";
|
|
|
+ this.url = "/blade-los/boxPool/giveAnEncore";
|
|
|
+ }
|
|
|
+ if (type == 4) {
|
|
|
+ this.action = "/api/blade-los/boxPool/returnEmptyAnalysis";
|
|
|
+ this.url = "/blade-los/boxPool/returnEmpty";
|
|
|
+ }
|
|
|
+ if (type == 5) {
|
|
|
+ this.data = list;
|
|
|
+ this.url = "/blade-los/boxPool/emptyContainerEntry";
|
|
|
+ }
|
|
|
+ if (type == 6) {
|
|
|
+ this.data = list;
|
|
|
+ this.url = "/blade-los/boxPool/emptyContainerAppearance";
|
|
|
+ }
|
|
|
+ this.type = type;
|
|
|
+ },
|
|
|
+ download() {
|
|
|
+ if (this.type == 1) {
|
|
|
+ window.open(`/api/blade-los/boxPool/emptyContainerEntry/template?${this.website.tokenHeader}=${getToken()}`);
|
|
|
+ }
|
|
|
+ if (this.type == 2) {
|
|
|
+ window.open(`/api/blade-los/boxPool/emptyContainerAppearance/template?${this.website.tokenHeader}=${getToken()}`);
|
|
|
+ }
|
|
|
+ if (this.type == 3 || this.type == 4) {
|
|
|
+ window.open(`/api/blade-los/boxPool/giveAnEncore/template?${this.website.tokenHeader}=${getToken()}`);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ selectionChange(list) {
|
|
|
+ this.selectionList = list;
|
|
|
+ },
|
|
|
+ importData() {
|
|
|
+ if (this.data.length == 0) {
|
|
|
+ return this.$message.error("请上传数据");
|
|
|
+ }
|
|
|
+ if (this.selectionList.length == 0) {
|
|
|
+ return this.$message.error("请选择数据");
|
|
|
+ }
|
|
|
+ this.loading = true;
|
|
|
+ getDicinit("POST", this.url, this.selectionList)
|
|
|
+ .then(res => {
|
|
|
+ this.excelBox = false;
|
|
|
+ this.$emit("refreshData");
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ cellStyle({ row, column, rowIndex, columnIndex }) {
|
|
|
+ if (row.result == "失败") {
|
|
|
+ return {
|
|
|
+ color: "#F56C6C"
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ return {
|
|
|
+ color: "##67C23A"
|
|
|
+ };
|
|
|
+ }
|
|
|
}
|
|
|
-}
|
|
|
-
|
|
|
+ }
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
::v-deep .el-dialog__body {
|
|
|
- padding: 10px 8px !important;
|
|
|
+ padding: 10px 8px !important;
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|