Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-life-system
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 8f8d2d3b
authored
Jun 01, 2026
by
chenwq
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
新增对账单导入模板下载功能,更新相关组件及单元测试
1 parent
e7cfee60
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
1 deletions
src/views/financeManage/accountStateManage/importBill.js
src/views/financeManage/components/ImportBillDialog.vue
tests/unit/accountStateManage/importBill.spec.js
src/views/financeManage/accountStateManage/importBill.js
View file @
8f8d2d3
...
@@ -40,6 +40,20 @@ export function buildImportBillPayload({ billType, fileName, base64 }) {
...
@@ -40,6 +40,20 @@ export function buildImportBillPayload({ billType, fileName, base64 }) {
}
}
}
}
export
function
buildImportTemplateDownloadTask
(
billType
)
{
const
params
=
{
billType
:
billType
,
method
:
"dj.api.smartcarlife.reconciliationBill.merchant.template.export.async"
}
return
{
name
:
"对账单导入模板"
,
exportParam
:
JSON
.
stringify
(
params
),
status
:
"waiting"
,
timeid
:
new
Date
().
getTime
()
}
}
// 轮询接口返回 100% 后才算结束,再根据失败数量判断成功或失败。
// 轮询接口返回 100% 后才算结束,再根据失败数量判断成功或失败。
export
function
getImportPollStatus
(
result
=
{})
{
export
function
getImportPollStatus
(
result
=
{})
{
if
(
result
.
progress
===
100
&&
Number
(
result
.
failNum
)
===
0
)
{
if
(
result
.
progress
===
100
&&
Number
(
result
.
failNum
)
===
0
)
{
...
...
src/views/financeManage/components/ImportBillDialog.vue
View file @
8f8d2d3
...
@@ -31,6 +31,9 @@
...
@@ -31,6 +31,9 @@
@
change=
"handleFileChange"
@
change=
"handleFileChange"
/>
/>
</el-button>
</el-button>
<el-button
type=
"text"
class=
"template-btn"
:disabled=
"importing"
@
click=
"handleDownloadTemplate"
>
下载模板
</el-button>
<div
v-if=
"form.fileName"
class=
"file-name-box"
>
<div
v-if=
"form.fileName"
class=
"file-name-box"
>
<i
class=
"el-icon-document"
></i>
<i
class=
"el-icon-document"
></i>
<span
class=
"file-name"
>
{{
form
.
fileName
}}
</span>
<span
class=
"file-name"
>
{{
form
.
fileName
}}
</span>
...
@@ -54,11 +57,13 @@
...
@@ -54,11 +57,13 @@
import
{
downLoadFile
}
from
"@/common/util"
import
{
downLoadFile
}
from
"@/common/util"
import
{
readFileAsDataURL
}
from
"@/libs/file"
import
{
readFileAsDataURL
}
from
"@/libs/file"
import
{
startPolling
}
from
"@/libs/interval"
import
{
startPolling
}
from
"@/libs/interval"
import
{
mapActions
,
mapState
}
from
"vuex"
import
{
getImportExcelProcess
,
importReconciliationBill
}
from
"@api/accountManage"
import
{
getImportExcelProcess
,
importReconciliationBill
}
from
"@api/accountManage"
import
{
import
{
IMPORT_BILL_FILE_RULE
,
IMPORT_BILL_FILE_RULE
,
buildImportBillFormData
,
buildImportBillFormData
,
buildImportBillPayload
,
buildImportBillPayload
,
buildImportTemplateDownloadTask
,
getImportPollStatus
,
getImportPollStatus
,
getImportUuid
,
getImportUuid
,
normalizeImportPollResult
normalizeImportPollResult
...
@@ -79,7 +84,7 @@ export default {
...
@@ -79,7 +84,7 @@ export default {
fileRule
:
IMPORT_BILL_FILE_RULE
,
fileRule
:
IMPORT_BILL_FILE_RULE
,
fileInputKey
:
Date
.
now
(),
fileInputKey
:
Date
.
now
(),
form
:
{
form
:
{
billType
:
""
,
billType
:
"
1
"
,
fileName
:
""
,
fileName
:
""
,
file
:
null
file
:
null
},
},
...
@@ -97,7 +102,13 @@ export default {
...
@@ -97,7 +102,13 @@ export default {
beforeDestroy
()
{
beforeDestroy
()
{
this
.
stopPolling
()
this
.
stopPolling
()
},
},
computed
:
{
...
mapState
({
dowloadList
:
state
=>
state
.
d2admin
.
user
.
dowloadList
})
},
methods
:
{
methods
:
{
...
mapActions
(
"d2admin/user"
,
[
"actionSetDownloadList"
]),
handleClose
()
{
handleClose
()
{
if
(
this
.
importing
)
{
if
(
this
.
importing
)
{
this
.
$message
.
warning
(
"正在导入中,请稍后"
)
this
.
$message
.
warning
(
"正在导入中,请稍后"
)
...
@@ -148,6 +159,17 @@ export default {
...
@@ -148,6 +159,17 @@ export default {
await
this
.
submitImport
()
await
this
.
submitImport
()
})
})
},
},
handleDownloadTemplate
()
{
if
(
!
this
.
form
.
billType
)
{
this
.
$message
.
warning
(
"请先选择对账单类型"
)
return
}
const
list
=
[
...
this
.
dowloadList
,
buildImportTemplateDownloadTask
(
this
.
form
.
billType
)
]
this
.
actionSetDownloadList
({
list
,
type
:
"dowloadList"
})
},
async
submitImport
()
{
async
submitImport
()
{
try
{
try
{
this
.
importing
=
true
this
.
importing
=
true
...
@@ -230,6 +252,11 @@ export default {
...
@@ -230,6 +252,11 @@ export default {
overflow
:
hidden
;
overflow
:
hidden
;
}
}
.template-btn
{
margin-left
:
10px
;
padding
:
0
;
}
.file-input
{
.file-input
{
position
:
absolute
;
position
:
absolute
;
top
:
0
;
top
:
0
;
...
...
tests/unit/accountStateManage/importBill.spec.js
View file @
8f8d2d3
...
@@ -3,6 +3,7 @@ import {
...
@@ -3,6 +3,7 @@ import {
IMPORT_BILL_TYPE_OPTIONS
,
IMPORT_BILL_TYPE_OPTIONS
,
buildImportBillFormData
,
buildImportBillFormData
,
buildImportBillPayload
,
buildImportBillPayload
,
buildImportTemplateDownloadTask
,
getImportPollStatus
getImportPollStatus
}
from
"@/views/financeManage/accountStateManage/importBill"
}
from
"@/views/financeManage/accountStateManage/importBill"
...
@@ -45,4 +46,13 @@ describe("importBill helpers", () => {
...
@@ -45,4 +46,13 @@ describe("importBill helpers", () => {
expect
(
getImportPollStatus
({
progress
:
100
,
failNum
:
0
})).
toBe
(
"success"
)
expect
(
getImportPollStatus
({
progress
:
100
,
failNum
:
0
})).
toBe
(
"success"
)
expect
(
getImportPollStatus
({
progress
:
100
,
failNum
:
2
})).
toBe
(
"failed"
)
expect
(
getImportPollStatus
({
progress
:
100
,
failNum
:
2
})).
toBe
(
"failed"
)
})
})
it
(
"builds import template download task by bill type"
,
()
=>
{
const
task
=
buildImportTemplateDownloadTask
(
"1"
)
const
exportParam
=
JSON
.
parse
(
task
.
exportParam
)
expect
(
task
.
name
).
toBe
(
"对账单导入模板"
)
expect
(
exportParam
.
billType
).
toBe
(
"SHOP"
)
expect
(
exportParam
.
method
).
toBe
(
"dj.api.smartcarlife.reconciliationBill.merchant.template.export.async"
)
})
})
})
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment