fix
This commit is contained in:
@@ -33,11 +33,21 @@
|
|||||||
v-model:show="showBatch"
|
v-model:show="showBatch"
|
||||||
>
|
>
|
||||||
<n-flex vertical>
|
<n-flex vertical>
|
||||||
<n-input placeholder="班级" v-model:value="classname" />
|
<n-input
|
||||||
<n-input rows="20" type="textarea" v-model:value="namesStr" />
|
placeholder="班级"
|
||||||
|
v-model:value="classname"
|
||||||
|
:disabled="batchLoading"
|
||||||
|
/>
|
||||||
|
<n-input
|
||||||
|
rows="20"
|
||||||
|
type="textarea"
|
||||||
|
v-model:value="namesStr"
|
||||||
|
:disabled="batchLoading"
|
||||||
|
/>
|
||||||
<n-button
|
<n-button
|
||||||
type="primary"
|
type="primary"
|
||||||
:disabled="!(classname && !!names.length)"
|
:disabled="!(classname && !!names.length)"
|
||||||
|
:loading="batchLoading"
|
||||||
@click="batchCreateUsers"
|
@click="batchCreateUsers"
|
||||||
>
|
>
|
||||||
提交
|
提交
|
||||||
@@ -72,6 +82,8 @@ const classname = ref("")
|
|||||||
const namesStr = ref("")
|
const namesStr = ref("")
|
||||||
const names = computed(() => namesStr.value.split("\n").filter((it) => !!it))
|
const names = computed(() => namesStr.value.split("\n").filter((it) => !!it))
|
||||||
|
|
||||||
|
const batchLoading = ref(false)
|
||||||
|
|
||||||
const roles = [
|
const roles = [
|
||||||
{ label: "全部权限", value: "" },
|
{ label: "全部权限", value: "" },
|
||||||
{ label: "普通用户", value: Role.Normal },
|
{ label: "普通用户", value: Role.Normal },
|
||||||
@@ -120,13 +132,16 @@ function goDjangoUserAdd() {
|
|||||||
async function batchCreateUsers() {
|
async function batchCreateUsers() {
|
||||||
if (!names.value.length) return
|
if (!names.value.length) return
|
||||||
try {
|
try {
|
||||||
|
batchLoading.value = true
|
||||||
await Account.batchCreate({
|
await Account.batchCreate({
|
||||||
classname: classname.value,
|
classname: classname.value,
|
||||||
names: names.value,
|
names: names.value,
|
||||||
})
|
})
|
||||||
|
batchLoading.value = false
|
||||||
message.success("批量创建成功")
|
message.success("批量创建成功")
|
||||||
showBatch.value = false
|
showBatch.value = false
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
batchLoading.value = false
|
||||||
message.error("有些用户已经存在,创建失败")
|
message.error("有些用户已经存在,创建失败")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user