Browse Source

修改用户验证bug及删除bug

master
lihua 5 years ago
parent
commit
ac1b71d6f2
  1. 4
      src/api/material.js
  2. 7
      src/views/asset/public/index.vue
  3. 6
      src/views/asset/staff/index.vue
  4. 9
      src/views/layout/components/Navbar.vue
  5. 9
      src/views/material/warehouse/index.vue
  6. 32
      src/views/user/manage.vue

4
src/api/material.js

@ -26,9 +26,9 @@ export function edit(asset) {
})
}
export function del(code) {
export function del(id) {
return request({
url: `/material/delete/${code}`,
url: `/material/delete/${id}`,
method: 'delete'
})
}

7
src/views/asset/public/index.vue

@ -74,7 +74,7 @@
min-width="10%">
<template slot-scope="scope">
<el-button type="text" size="small" @click="handleEdit(scope.$index)">编辑</el-button>
<el-button type="text" size="small" @click="handleDelete(scope.row.code, scope.$index)">删除</el-button>
<el-button type="text" size="small" @click="handleDelete(scope.row.id, scope.$index)">删除</el-button>
</template>
</el-table-column>
</el-table>
@ -270,20 +270,21 @@ export default {
this.editVisible = false
}
this.visible = false
this.handleSearch()
} else {
console.log('error submit!!')
return false
}
})
},
handleDelete(code, index) {
handleDelete(id, index) {
this.$confirm('此操作将永久删除该资产, 是否继续?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.listLoading = true
del(code).then(response => {
del(id).then(response => {
this.assetList.splice(index, 1)
this.listLoading = false
})

6
src/views/asset/staff/index.vue

@ -64,7 +64,7 @@
min-width="10%">
<template slot-scope="scope">
<el-button type="text" size="small" @click="handleEdit(scope.$index)">编辑</el-button>
<el-button type="text" size="small" @click="handleDelete(scope.row.code, scope.$index)">删除</el-button>
<el-button type="text" size="small" @click="handleDelete(scope.row.id, scope.$index)">删除</el-button>
</template>
</el-table-column>
</el-table>
@ -239,14 +239,14 @@ export default {
}
})
},
handleDelete(code, index) {
handleDelete(id, index) {
this.$confirm('此操作将永久删除该资产, 是否继续?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.listLoading = true
del(code).then(response => {
del(id).then(response => {
this.assetList.splice(index, 1)
this.listLoading = false
})

9
src/views/layout/components/Navbar.vue

@ -32,7 +32,7 @@
<el-input v-model="form.nickname" autocomplete="off" placeholder="请输入用户名称"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="登录名称">
<el-input v-model="form.name" :disabled="false" autocomplete="off" placeholder="请输入登录名称"/>
<el-input v-model="form.name" disabled autocomplete="off" placeholder="请输入登录名称"/>
</el-form-item>
<el-form-item :label-width="formLabelWidth" label="手机号">
<el-input v-model="form.phone" autocomplete="off" placeholder="请输入手机号"/>
@ -108,6 +108,13 @@ export default {
confirmButtonText: '确定',
cancelButtonText: '取消'
}).then(({ value }) => {
if (value.length < 5) {
this.$message({
type: 'error',
message: '密码不能小于5位'
})
return
}
modifyPassword(value).then(response => {
this.$message({
type: 'success',

9
src/views/material/warehouse/index.vue

@ -107,7 +107,7 @@
<template slot-scope="scope">
<el-button type="text" size="small" @click="handleSub(scope.row)">出库</el-button>
<el-button v-if="admin" type="text" size="small" @click="handleEdit(scope.row)">编辑</el-button>
<el-button v-if="admin" type="text" size="small" @click="handleDelete(scope.row.code, scope.$index)">删除</el-button>
<el-button v-if="admin" type="text" size="small" @click="handleDelete(scope.row.id, scope.$index)">删除</el-button>
</template>
</el-table-column>
</el-table>
@ -256,9 +256,6 @@ export default {
],
position: [
{ required: true, message: '位号不能为空', trigger: 'blur' }
],
company: [
{ required: true, message: '公司名称不能为空', trigger: 'blur' }
]
},
addVisible: false,
@ -418,14 +415,14 @@ export default {
}
})
},
handleDelete(code, index) {
handleDelete(id, index) {
this.$confirm('此操作将永久删除该资产, 是否继续?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.listLoading = true
del(code).then(response => {
del(id).then(response => {
this.materialList.splice(index, 1)
this.listLoading = false
})

32
src/views/user/manage.vue

@ -56,7 +56,7 @@
<template slot-scope="scope">
<el-button type="text" size="small" @click="handleResetPassword(scope.row.id)">重置密码</el-button>
<el-button type="text" size="small" @click="handleEdit(scope.$index)">编辑</el-button>
<el-button type="text" size="small" @click="handleDelete(scope.row.id, scope.$index)">删除</el-button>
<el-button v-if="scope.row.isAdmin === 0" type="text" size="small" @click="handleDelete(scope.row.id, scope.$index)">删除</el-button>
</template>
</el-table-column>
</el-table>
@ -121,6 +121,21 @@ export default {
callback()
}
}
const validatePass = (rule, value, callback) => {
if (value.length < 5) {
callback(new Error('密码不能小于5位'))
} else {
callback()
}
}
const validateName = (rule, value, callback) => {
const reg = /^[a-z_A-Z]+$/
if (!reg.test(value)) {
callback(new Error('登录名称只能包含字母和下划线'))
} else {
callback()
}
}
return {
form: {
nickname: '',
@ -134,10 +149,10 @@ export default {
{ required: true, message: '用户名称不能为空', trigger: 'blur' }
],
name: [
{ required: true, message: '登录名称不能为空', trigger: 'blur' }
{ required: true, trigger: 'blur', validator: validateName }
],
password: [
{ required: true, message: '密码不能为空', trigger: 'blur' }
{ required: true, trigger: 'blur', validator: validatePass }
],
phone: [
{ required: true, trigger: 'blur', validator: validPhone }
@ -205,14 +220,13 @@ export default {
if (valid) {
if (this.addVisible) {
add(this.form).then(response => {
this.form.createTime = new Date()
this.userList.push(this.form)
this.handleSearch()
})
this.addVisible = false
}
if (this.editVisible) {
edit(this.form).then(response => {
console.log(response)
edit(this.form, this.form.id).then(response => {
this.handleSearch()
})
this.editVisible = false
}
@ -225,7 +239,7 @@ export default {
},
handleResetPassword(id) {
resetPassword(id).then(response => {
const newPassword = response.data
const newPassword = response.data.password
this.$alert(newPassword, '新密码', {
confirmButtonText: '确定'
})
@ -239,7 +253,7 @@ export default {
}).then(() => {
this.listLoading = true
del(code).then(response => {
this.assetList.splice(index, 1)
this.userList.splice(index, 1)
this.listLoading = false
})
this.$message({

Loading…
Cancel
Save