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> </template>
<script lang="jsx"> <script lang="jsx">
import { addUserApi, userListApi, deleteUserApi } from '@/api/user'
import {
addUserApi,
userListApi,
deleteUserApi,
updateUserInfoApi,
} from '@/api/user'
import moment from 'moment' import moment from 'moment'
const INITIAL_DATA = { const INITIAL_DATA = {
username: '', username: '',
@ -92,6 +97,7 @@ const INITIAL_DATA = {
export default { export default {
data() { data() {
return { return {
updateUserInfo: {},
operType: 1, operType: 1,
formData: { ...INITIAL_DATA }, formData: { ...INITIAL_DATA },
rules: { rules: {
@ -189,7 +195,7 @@ export default {
this.visible = true this.visible = true
}, },
updateUser(row) { updateUser(row) {
console.log(row)
this.updateUserInfo = row
this.formData = { this.formData = {
username: row.username, username: row.username,
role: row.role, role: row.role,
@ -243,7 +249,22 @@ export default {
} }
} else { } 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 { } else {
this.$message.warning(firstError) this.$message.warning(firstError)

Loading…
Cancel
Save