|
@ -10,7 +10,7 @@ |
|
|
</t-space> |
|
|
</t-space> |
|
|
</template> |
|
|
</template> |
|
|
<template #actions> |
|
|
<template #actions> |
|
|
<t-button theme="primary" @click="visible = true"> 新增用户 </t-button> |
|
|
|
|
|
|
|
|
<t-button theme="primary" @click="addUser"> 新增用户 </t-button> |
|
|
</template> |
|
|
</template> |
|
|
<t-drawer |
|
|
<t-drawer |
|
|
size="medium" |
|
|
size="medium" |
|
@ -20,7 +20,7 @@ |
|
|
:visible="visible" |
|
|
:visible="visible" |
|
|
@close="handleClose" |
|
|
@close="handleClose" |
|
|
:onConfirm="handleClose" |
|
|
:onConfirm="handleClose" |
|
|
header="新增用户" |
|
|
|
|
|
|
|
|
:header="operType == 1 ? '新增用户' : '修改用户'" |
|
|
> |
|
|
> |
|
|
<t-form |
|
|
<t-form |
|
|
:data="formData" |
|
|
:data="formData" |
|
@ -33,6 +33,7 @@ |
|
|
<t-input |
|
|
<t-input |
|
|
v-model="formData.username" |
|
|
v-model="formData.username" |
|
|
placeholder="请输入用户名" |
|
|
placeholder="请输入用户名" |
|
|
|
|
|
:disabled="operType == 2" |
|
|
></t-input> |
|
|
></t-input> |
|
|
</t-form-item> |
|
|
</t-form-item> |
|
|
<t-form-item name="password"> |
|
|
<t-form-item name="password"> |
|
@ -55,7 +56,11 @@ |
|
|
<t-form-item> |
|
|
<t-form-item> |
|
|
<t-space size="10px"> |
|
|
<t-space size="10px"> |
|
|
<t-button theme="primary" type="submit">提交</t-button> |
|
|
<t-button theme="primary" type="submit">提交</t-button> |
|
|
<t-button theme="default" variant="base" type="reset" |
|
|
|
|
|
|
|
|
<t-button |
|
|
|
|
|
v-if="operType == 1" |
|
|
|
|
|
theme="default" |
|
|
|
|
|
variant="base" |
|
|
|
|
|
type="reset" |
|
|
>重置</t-button |
|
|
>重置</t-button |
|
|
> |
|
|
> |
|
|
</t-space> |
|
|
</t-space> |
|
@ -87,6 +92,7 @@ const INITIAL_DATA = { |
|
|
export default { |
|
|
export default { |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
|
|
|
operType: 1, |
|
|
formData: { ...INITIAL_DATA }, |
|
|
formData: { ...INITIAL_DATA }, |
|
|
rules: { |
|
|
rules: { |
|
|
username: [ |
|
|
username: [ |
|
@ -147,6 +153,7 @@ export default { |
|
|
cell: (h, { row }) => { |
|
|
cell: (h, { row }) => { |
|
|
if (row.username != 'admin') { |
|
|
if (row.username != 'admin') { |
|
|
return ( |
|
|
return ( |
|
|
|
|
|
<div style={{ display: 'flex' }}> |
|
|
<div> |
|
|
<div> |
|
|
<t-button |
|
|
<t-button |
|
|
theme="danger" |
|
|
theme="danger" |
|
@ -155,6 +162,15 @@ export default { |
|
|
删除 |
|
|
删除 |
|
|
</t-button> |
|
|
</t-button> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<div style={{ marginLeft: '16px' }}> |
|
|
|
|
|
<t-button |
|
|
|
|
|
theme="primary" |
|
|
|
|
|
onClick={() => this.updateUser(row)} |
|
|
|
|
|
> |
|
|
|
|
|
修改 |
|
|
|
|
|
</t-button> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
@ -162,8 +178,26 @@ export default { |
|
|
], |
|
|
], |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
methods: { |
|
|
methods: { |
|
|
|
|
|
addUser() { |
|
|
|
|
|
this.operType = 1 |
|
|
|
|
|
this.formData = { |
|
|
|
|
|
username: '', |
|
|
|
|
|
role: '', |
|
|
|
|
|
password: '', |
|
|
|
|
|
} |
|
|
|
|
|
this.visible = true |
|
|
|
|
|
}, |
|
|
|
|
|
updateUser(row) { |
|
|
|
|
|
console.log(row) |
|
|
|
|
|
this.formData = { |
|
|
|
|
|
username: row.username, |
|
|
|
|
|
role: row.role, |
|
|
|
|
|
password: '', |
|
|
|
|
|
} |
|
|
|
|
|
this.operType = 2 |
|
|
|
|
|
this.visible = true |
|
|
|
|
|
}, |
|
|
handleClose() { |
|
|
handleClose() { |
|
|
this.formData = { ...INITIAL_DATA } |
|
|
this.formData = { ...INITIAL_DATA } |
|
|
this.visible = false |
|
|
this.visible = false |
|
@ -197,6 +231,7 @@ export default { |
|
|
async onSubmit({ validateResult, firstError }) { |
|
|
async onSubmit({ validateResult, firstError }) { |
|
|
if (validateResult === true) { |
|
|
if (validateResult === true) { |
|
|
// 新增用户 |
|
|
// 新增用户 |
|
|
|
|
|
if (this.operType == 1) { |
|
|
const res = await addUserApi(this.formData) |
|
|
const res = await addUserApi(this.formData) |
|
|
if (res?.code == 200) { |
|
|
if (res?.code == 200) { |
|
|
this.formData = { ...INITIAL_DATA } |
|
|
this.formData = { ...INITIAL_DATA } |
|
@ -207,6 +242,10 @@ export default { |
|
|
this.$message.error(res.msg) |
|
|
this.$message.error(res.msg) |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
// 更新用户 |
|
|
|
|
|
console.log(123) |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
this.$message.warning(firstError) |
|
|
this.$message.warning(firstError) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|