Browse Source

用户

master
maochaoying 2 years ago
parent
commit
5f619748bf
  1. 8
      src/api/user.js
  2. 27
      src/components/User.vue

8
src/api/user.js

@ -24,3 +24,11 @@ export const deleteUserApi = username => {
},
})
}
export const updateUserInfoApi = data => {
return request({
url: `/account/update`,
method: 'POST',
data,
})
}

27
src/components/User.vue

@ -81,7 +81,12 @@
</template>
<script lang="jsx">
import { addUserApi, userListApi, deleteUserApi } from '@/api/user'
import {
addUserApi,
userListApi,
deleteUserApi,
updateUserInfoApi,
} from '@/api/user'
import moment from 'moment'
const INITIAL_DATA = {
username: '',
@ -92,6 +97,7 @@ const INITIAL_DATA = {
export default {
data() {
return {
updateUserInfo: {},
operType: 1,
formData: { ...INITIAL_DATA },
rules: {
@ -189,7 +195,7 @@ export default {
this.visible = true
},
updateUser(row) {
console.log(row)
this.updateUserInfo = row
this.formData = {
username: row.username,
role: row.role,
@ -243,7 +249,22 @@ export default {
}
} else {
//
console.log(123)
const res = await updateUserInfoApi({
...this.updateUserInfo,
...this.formData,
})
if (res?.code == 200) {
if (res?.data?.result) {
this.formData = { ...INITIAL_DATA }
this.visible = false
this.$message.success('修改成功')
this.getUserList()
} else {
this.$message.error(res.msg)
}
} else {
this.$message.error(res.msg)
}
}
} else {
this.$message.warning(firstError)

Loading…
Cancel
Save