仓库信息导入导出

master
anthonywj 3 years ago
parent 6cd9dda6b2
commit 22727c90bb

@ -41,3 +41,13 @@ export function deleteWarehouse(data) {
data: data
});
}
export function exportJson(query){
return axios({
url: "/spms/inv/warehouse/exportJson",
method: "post",
data: query,
headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
responseType: 'arraybuffer', //一定要设置响应类型否则页面会是空白pdf
});
}

@ -161,7 +161,7 @@
<div class="text item" style="margin-top: 6px">
<el-checkbox v-model="inputQuery.enable"></el-checkbox>
<!-- <el-checkbox v-model="inputQuery.innerOrder"></el-checkbox>-->
<!-- <el-checkbox v-model="inputQuery.genUnit"></el-checkbox>-->
<!-- <el-checkbox v-model="inputQuery.genUnit"></el-checkbox>-->
</div>
@ -196,9 +196,10 @@
<!--&lt;!&ndash; <el-checkbox v-model="inputQuery.checkEnable"></el-checkbox>&ndash;&gt;-->
<!--&lt;!&ndash; </div>&ndash;&gt;-->
<!-- </el-col>-->
<!-- @change="oneCheck"-->
<el-col :span="4" class="el-col">
<div class="text item">
<el-checkbox v-model="inputQuery.checkEnable" @change="oneCheck">()</el-checkbox>
<el-checkbox v-model="inputQuery.checkEnable">()</el-checkbox>
</div>
</el-col>
</el-row>

@ -18,13 +18,26 @@
</el-select>
</el-form-item>
<el-form-item>
<el-button-group>
<el-button-group style="margin-left: 10px;display:flex;">
<el-button type="primary" icon="el-icon-refresh" @click="onReset"></el-button>
<el-button type="primary" icon="search" @click="getList"></el-button>
<el-button type="primary" @click.native="handleForm(null, null,'addTop')"
>添加仓库
</el-button
>
<el-upload
:action="uploadFileUrl"
multiple
:limit="1"
:data="uploadData"
:show-file-list="false"
:on-success="handleChange"
:file-list="fileList"
>
<el-button size="mini" type="primary">导入仓库信息</el-button>
</el-upload>
<el-button type="primary" icon="search" @click="exportInvwarehouse"></el-button>
</el-button-group>
</el-form-item>
</el-form>
@ -259,8 +272,10 @@
import {
filterList,
saveWarehouse,
deleteWarehouse
deleteWarehouse, exportJson
} from "../../api/basic/invWarehouse";
import {formatDate} from "@/utils/date";
import axios from "axios";
const formJson = {
id: null,
@ -290,6 +305,8 @@ export default {
label: "name"
},
treeList: [],
fileList: [],
uploadData: {},
loading: true,
index: null,
formName: null,
@ -316,7 +333,8 @@ export default {
},
pidData: {}
,
deleteLoading: false
deleteLoading: false,
uploadFileUrl: null,
}
;
},
@ -538,8 +556,46 @@ export default {
CurrentDate += '0' + Day
}
return CurrentDate
},
exportInvwarehouse() {
let tquery = {};
exportJson(tquery).then((response) => {
const binaryData = [];
binaryData.push(response);
let url = window.URL.createObjectURL(
new Blob(binaryData, {type: "application/json"})
);
this.loading = false;
const eleLink = document.createElement('a');
var timestamp = formatDate(new Date(), "yyyy-MM-dd_hh:mm")
eleLink.download = "仓库信息导出" + timestamp + ".json";
eleLink.style.display = 'none';
eleLink.href = url;
document.body.appendChild(eleLink)
eleLink.click()
document.body.removeChild(eleLink)
}).catch(() => {
this.loading = false;
});
},
handleChange(response, files, fileList) {
if (response.code != 20000) {
this.$message.error(response.message);
} else {
// console.log(files[0] + "\n" + this.fileList[0] + "\n" + fileList[0]);
this.$message.success(response.data);
this.getList();
}
},
init() {
axios.get("./config.json").then(res => {
//
let response = res.data.BASE_URL;
this.uploadFileUrl = response + "/spms/inv/warehouse/uploadJson";
});
},
},
filters: {
statusFilterType(status) {
const statusMap = {
@ -560,6 +616,7 @@ export default {
},
created() {
//
this.init();
this.getList();
},
};

Loading…
Cancel
Save