Commit 2e32e3bf by Joey

feat(@gms/gms-plugin-billexpand): 导入excel按钮

parent 4f946b27
......@@ -1306,6 +1306,24 @@ export default {
"title": "导出Excel"
},
{
"value": "importExcel",
"discard": false,
"path": "云报销",
"extends": {
"paramDes": [
{
"isRequired": true,
"ref": "bill",
"type": "metaData",
"title": "billDefine",
"key": "billDefine"
},
]
},
"description": "导入Excel",
"title": "导入Excel"
},
{
"value": "customDeleteAction",
"discard": false,
"path": "云报销",
......
......@@ -63,6 +63,7 @@ import createBill from './query-actions/createBill.js';
import editBill from './query-actions/editBill.js';
import examineAction from './query-actions/examineAction.js'
import exportExcel from './query-actions/exportExcel.js'
import importExcel from './query-actions/importExcel.js'
import createBills from './query-actions/createBills'
import payment from "./query-actions/payments/payment";
import batchPayment from "./query-actions/payments/batchPayment";
......@@ -198,6 +199,7 @@ export default {
editBill,
examineAction,
exportExcel,
importExcel,
customDeleteAction,
createBills,
batchPayment,
......
function popFileSelector () {
return new Promise((resolve, reject) => {
let input = document.createElement('input')
input.value = '选择文件'
input.type = 'file'
input.onchange = event => {
let file = event.target.files[0]
resolve(file)
};
input.click()
});
}
export default {
execute (context, param) {
popFileSelector().then((res) => {
const postParam = new FormData()
postParam.append('file', res)
postParam.append('billDefine', param.billDefine)
window.GMS.$http.post(
`/rbcquery/importExcelBudgetItems`,
postParam,
{
headers: {
'Content-Type': 'multipart/form-data'
}
}
).then((res) => {
if (res.data && res.data.code == 0) {
GMS.$hideContainer.$Message.success(`导入成功,共导入${res.data.successNum}条`)
}
else {
throw new Error()
}
}).catch(() => {
GMS.$hideContainer.$Message.error('导入失败')
})
})
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment