Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
lexile_question
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
lexile_question
Commits
6b4e0b80
Commit
6b4e0b80
authored
Feb 24, 2025
by
李维
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 修改表单结构
parent
ee8a8474
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
217 additions
and
167 deletions
+217
-167
index.html
form/index.html
+150
-85
index.js
form/index.js
+67
-82
No files found.
form/index.html
View file @
6b4e0b80
This diff is collapsed.
Click to expand it.
form/index.js
View file @
6b4e0b80
...
...
@@ -16,8 +16,42 @@ new Vue({
el
:
'
.edit-data
'
,
created
()
{
window
.
courseware
.
getData
((
data
)
=>
{
this
.
data
=
data
||
[];
this
.
data
=
data
||
{
form_id
:
''
,
form_name
:
''
,
item_number
:
''
,
item_type
:
''
,
ims_id
:
''
,
word_count
:
''
,
passage_text
:
{
text
:
''
,
audio
:
{
url
:
''
,
name
:
''
,
size
:
''
,
duration
:
''
},
image
:
{
url
:
''
,
},
},
stem
:
{
text
:
''
,
audio
:
{
url
:
''
,
name
:
''
,
size
:
''
,
duration
:
''
},
image
:
{
url
:
''
,
},
},
options
:
[]
};
},
key
);
console
.
log
(
"
========== data ==========
"
)
console
.
log
(
this
.
data
)
window
[
'
air
'
].
getUploadCallback
=
(
url
,
data
)
=>
{
this
.
uploadUrl
=
url
;
this
.
uploadData
=
data
;
...
...
@@ -31,55 +65,18 @@ new Vue({
}
},
methods
:
{
handleAudioSuccess
(
res
,
file
,
index
)
{
handleAudioSuccess
(
res
,
file
,
obj
)
{
// 假设上传接口返回的音频URL在 res.url 中
this
.
data
[
index
].
audio_url
=
res
.
url
;
this
.
data
[
index
].
audio_name
=
file
.
name
;
obj
.
url
=
res
.
url
;
obj
.
name
=
file
.
name
;
// 计算文件大小
const
size
=
file
.
size
;
if
(
size
<
1024
)
{
this
.
data
[
index
].
audio_size
=
size
+
'
B
'
;
}
else
if
(
size
<
1024
*
1024
)
{
this
.
data
[
index
].
audio_size
=
(
size
/
1024
).
toFixed
(
2
)
+
'
KB
'
;
}
else
{
this
.
data
[
index
].
audio_size
=
(
size
/
(
1024
*
1024
)).
toFixed
(
2
)
+
'
MB
'
;
}
obj
.
size
=
file
.
size
;
// 获取音频时长
const
audio
=
new
Audio
(
res
.
url
);
audio
.
addEventListener
(
'
loadedmetadata
'
,
()
=>
{
const
duration
=
audio
.
duration
;
const
minutes
=
Math
.
floor
(
duration
/
60
);
const
seconds
=
Math
.
floor
(
duration
%
60
);
this
.
data
[
index
].
audio_duration
=
`
${
minutes
}
:
${
seconds
.
toString
().
padStart
(
2
,
'
0
'
)}
`
;
});
this
.
save
();
},
handleOptionAudioSuccess
(
res
,
file
,
index
,
optionIndex
)
{
// 假设上传接口返回的音频URL在 res.url 中
this
.
data
[
index
].
options
[
optionIndex
].
audio_url
=
res
.
url
;
this
.
data
[
index
].
options
[
optionIndex
].
audio_name
=
file
.
name
;
// 计算文件大小
const
size
=
file
.
size
;
if
(
size
<
1024
)
{
this
.
data
[
index
].
options
[
optionIndex
].
audio_size
=
size
+
'
B
'
;
}
else
if
(
size
<
1024
*
1024
)
{
this
.
data
[
index
].
options
[
optionIndex
].
audio_size
=
(
size
/
1024
).
toFixed
(
2
)
+
'
KB
'
;
}
else
{
this
.
data
[
index
].
options
[
optionIndex
].
audio_size
=
(
size
/
(
1024
*
1024
)).
toFixed
(
2
)
+
'
MB
'
;
}
// 获取音频时长
const
audio
=
new
Audio
(
res
.
url
);
audio
.
addEventListener
(
'
loadedmetadata
'
,
()
=>
{
const
duration
=
audio
.
duration
;
const
minutes
=
Math
.
floor
(
duration
/
60
);
const
seconds
=
Math
.
floor
(
duration
%
60
);
this
.
data
[
index
].
options
[
optionIndex
].
audio_duration
=
`
${
minutes
}
:
${
seconds
.
toString
().
padStart
(
2
,
'
0
'
)}
`
;
obj
.
duration
=
audio
.
duration
;
this
.
save
();
});
this
.
save
();
...
...
@@ -87,10 +84,10 @@ new Vue({
// 播放/暂停音频
togglePlay
(
index
)
{
const
audio
=
this
.
$refs
[
'
audio
'
+
index
][
0
];
if
(
this
.
data
[
index
]
.
isPlaying
)
{
const
audio
=
this
.
$refs
[
'
audio
'
][
0
];
if
(
this
.
data
.
isPlaying
)
{
audio
.
pause
();
this
.
data
[
index
]
.
isPlaying
=
false
;
this
.
data
.
isPlaying
=
false
;
}
else
{
// 先停止其他正在播放的音频
this
.
data
.
forEach
((
item
,
i
)
=>
{
...
...
@@ -100,7 +97,7 @@ new Vue({
}
});
audio
.
play
();
this
.
data
[
index
]
.
isPlaying
=
true
;
this
.
data
.
isPlaying
=
true
;
}
},
...
...
@@ -128,7 +125,7 @@ new Vue({
},
audioOptionEnded
(
index
,
optionIndex
)
{
this
.
data
[
index
]
.
options
[
optionIndex
].
isPlaying
=
false
;
this
.
data
.
options
[
optionIndex
].
isPlaying
=
false
;
},
beforeAudioUpload
(
file
)
{
...
...
@@ -152,46 +149,34 @@ new Vue({
this
.
$message
.
success
(
"
实时保存成功
"
);
},
key
);
},
deleteConf
(
index
)
{
this
.
data
.
splice
(
index
,
1
);
this
.
save
();
},
addConfig
()
{
this
.
data
.
push
({
question
:
''
,
audio_url
:
''
,
image_url
:
''
,
audio_name
:
''
,
audio_size
:
''
,
audio_duration
:
''
,
isPlaying
:
false
,
options
:
[],
});
this
.
save
();
},
addOption
(
index
)
{
this
.
data
[
index
].
options
.
push
({
image_url
:
''
,
audio_url
:
''
,
audio_name
:
''
,
addOption
()
{
this
.
data
.
options
.
push
({
text
:
''
,
audio
:
{
url
:
''
,
name
:
''
,
size
:
''
,
duration
:
''
},
image
:
{
url
:
''
,
},
is_correct
:
false
,
});
this
.
save
();
},
deleteOption
(
index
,
optionIndex
)
{
this
.
data
[
index
]
.
options
.
splice
(
optionIndex
,
1
);
deleteOption
(
optionIndex
)
{
this
.
data
.
options
.
splice
(
optionIndex
,
1
);
this
.
save
();
},
// 图片上传成功的回调
handleImageSuccess
(
res
,
file
,
index
)
{
handleImageSuccess
(
res
,
file
,
obj
)
{
// 假设上传接口返回的图片URL在 res.url 中
console
.
log
(
res
,
file
,
index
);
this
.
data
[
index
].
image_url
=
res
.
url
;
obj
.
url
=
res
.
url
;
this
.
save
();
},
handleOptionImageSuccess
(
res
,
file
,
index
,
optionIndex
)
{
this
.
data
[
index
].
options
[
optionIndex
].
image_
url
=
res
.
url
;
handleOptionImageSuccess
(
res
,
file
,
obj
)
{
obj
.
url
=
res
.
url
;
this
.
save
();
},
...
...
@@ -227,13 +212,13 @@ new Vue({
confirmButtonText
:
'
关闭
'
});
},
removeImage
(
index
)
{
removeImage
(
obj
)
{
this
.
$confirm
(
'
确定要删除这张图片吗?
'
,
'
提示
'
,
{
confirmButtonText
:
'
确定
'
,
cancelButtonText
:
'
取消
'
,
type
:
'
warning
'
}).
then
(()
=>
{
this
.
data
[
index
].
image_
url
=
''
;
obj
.
url
=
''
;
this
.
save
();
this
.
$message
({
type
:
'
success
'
,
...
...
@@ -241,8 +226,8 @@ new Vue({
});
}).
catch
(()
=>
{
});
},
removeOptionImage
(
index
,
optionIndex
)
{
this
.
data
[
index
].
options
[
optionIndex
].
image_
url
=
''
;
removeOptionImage
(
obj
)
{
obj
.
url
=
''
;
this
.
save
();
}
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment