Skip to content

Commit

Permalink
hotfix: upload state
Browse files Browse the repository at this point in the history
  • Loading branch information
getrebuild committed Mar 22, 2024
1 parent 0232df8 commit c5efdcb
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/main/resources/web/assets/js/general/rb-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -1598,10 +1598,11 @@ class RbFormImage extends RbFormElement {
}

let mp
let mpCount = 0
const mp_end = function () {
if (--mpCount > 0) return
mpCount = 0
let mp_inpro = []
const mp_end = function (name) {
if (mp_inpro === 0) mp_inpro = []
else mp_inpro.remove(name)
if (mp_inpro.length > 0) return
setTimeout(() => {
if (mp) mp.end()
mp = null
Expand All @@ -1611,25 +1612,24 @@ class RbFormImage extends RbFormElement {
$createUploader(
this._fieldValue__input,
(res) => {
mpCount++
if (!mp_inpro.includes(res.file.name)) mp_inpro.push(res.file.name)
if (!mp) mp = new Mprogress({ template: 2, start: true })
mp.set(res.percent / 100) // 0.x
},
(res) => {
mp_end()
mp_end(res.file.name)
const paths = this.state.value || []
// 最多上传,多余忽略
if (paths.length < this.__maxUpload) {
let hasByName = $fileCutName(res.key)
hasByName = paths.find((x) => $fileCutName(x) === hasByName)
console.log(hasByName)
if (!hasByName) {
paths.push(res.key)
this.handleChange({ target: { value: paths } }, true)
}
}
},
() => mp_end()
() => mp_end(0)
)

// 拖拽上传
Expand Down

0 comments on commit c5efdcb

Please sign in to comment.