Commit 4de45599 by 胡悦

编辑用户

2 parents 68766182 59865e25
...@@ -6,7 +6,11 @@ ...@@ -6,7 +6,11 @@
<gl-input v-model="createRuleForm.roleName" clearable></gl-input> <gl-input v-model="createRuleForm.roleName" clearable></gl-input>
</gl-form-item> </gl-form-item>
<gl-form-item label="角色描述:" prop="roleDescript"> <gl-form-item label="角色描述:" prop="roleDescript">
<gl-input v-model="createRuleForm.roleDescript" type="textarea" clearable></gl-input> <gl-input v-model="createRuleForm.roleDescript" type="textarea" :rows="3" clearable></gl-input>
</gl-form-item>
<gl-form-item>
<span style="position:absolute; right:35px; top:-20px;">{{createRuleForm.roleDescript.length}}</span>
<span style="position:absolute; right:5px; top:-20px;">/200</span>
</gl-form-item> </gl-form-item>
<gl-form-item label="所属部门:" prop="department"> <gl-form-item label="所属部门:" prop="department">
<gl-select v-model="createRuleForm.department" placeholder="请选择"> <gl-select v-model="createRuleForm.department" placeholder="请选择">
...@@ -26,11 +30,18 @@ ...@@ -26,11 +30,18 @@
export default { export default {
name: 'RoleCreate', name: 'RoleCreate',
props: { props: {
createVisible: Boolean createVisible: Boolean,
editParams: Object
}, },
watch: { watch: {
createVisible(val) { createVisible(val) {
!val && this.$refs['createRuleForm'].resetFields() !val && this.$refs['createRuleForm'].resetFields()
},
editParams(val) {
if (val) {
this.createRuleForm = val
}
console.log(this.createRuleForm)
} }
}, },
data() { data() {
......
...@@ -85,11 +85,18 @@ ...@@ -85,11 +85,18 @@
export default { export default {
name: 'UserForm', name: 'UserForm',
props: { props: {
dialogFormVisible: Boolean dialogFormVisible: Boolean,
editUser: Object
}, },
watch: { watch: {
dialogFormVisible(val) { dialogFormVisible(val) {
!val && this.$refs['userManageForm'].resetFields() !val && this.$refs['userManageForm'].resetFields()
},
editUser(val) {
if (val) {
this.userManageForm = val
}
console.log(this.userManageForm)
} }
}, },
data() { data() {
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
<div> <div>
<div class="default m-b20"> <div class="default m-b20">
<gl-input class="search-w250" placeholder="请输入角色名称" v-model="roleName" clearable></gl-input> <gl-input class="search-w250" placeholder="请输入角色名称" v-model="roleName" clearable></gl-input>
<gl-button type="primary" @click="handleFindRoleName">搜索</gl-button> <gl-button type="primary" @click="handleSearchRoleName">搜索</gl-button>
</div> </div>
<hr> <hr>
<div class="default p-t15"> <div class="default p-t15">
<gl-button class="control-tabledata-button" size="small" @click="handleCreateRole">创建</gl-button> <gl-button class="control-tabledata-button" size="small" @click="handleCreateRole(editParams)">创建</gl-button>
<role-create :createVisible="createVisible" @createClose="handleCreateClose"></role-create> <role-create :createVisible="createVisible" :editParams="editParams" @createClose="handleCreateClose"></role-create>
<div class="m-b8"> <div class="m-b8">
<gl-table :table="roleData" :pagination="pagination"></gl-table> <gl-table :table="roleData" :pagination="pagination"></gl-table>
</div> </div>
...@@ -28,6 +28,7 @@ export default { ...@@ -28,6 +28,7 @@ export default {
return { return {
roleName: '', roleName: '',
createVisible: false, createVisible: false,
editParams: {},
roleData: { roleData: {
border: true, border: true,
height: 400, height: 400,
...@@ -55,7 +56,7 @@ export default { ...@@ -55,7 +56,7 @@ export default {
label: '编辑', label: '编辑',
type: 'text', type: 'text',
callback: (index, rows) => { callback: (index, rows) => {
this.$alert(rows[index]) this.handleCreateRole(rows[index])
} }
}, { }, {
label: '详细', label: '详细',
...@@ -114,25 +115,28 @@ export default { ...@@ -114,25 +115,28 @@ export default {
this.message('取消删除') this.message('取消删除')
}) })
}, },
dateFormat() { // dateFormat() {
const currentTime = new Date() // const currentTime = new Date()
const date = currentTime.toLocaleDateString().split('/').forEach((item) => { console.log(item) }) // const date = currentTime.toLocaleDateString().split('/').forEach((item) => { console.log(item) })
console.log(date) // console.log(date)
}, // },
roleDataEdit(data) { // 新增用户到页面
this.dateFormat() addRole(data) {
const newData = { roleId: '1038', roleName: data.roleName, department: data.department, roleStatus: '开启', roleCreateTime: '' } const newData = { roleId: '1038', roleName: data.roleName, department: data.department, roleStatus: '开启', roleCreateTime: new Date().toLocaleString().split('/').join('-') }
this.roleData.data.push(newData) this.roleData.data.push(newData)
}, },
handleFindRoleName() { handleSearchRoleName() {
this.roleName = '' this.roleName = ''
}, },
handleCreateRole() { handleCreateRole(params) {
console.log(params)
this.editParams = params
this.createVisible = !this.createVisible this.createVisible = !this.createVisible
}, },
// 关闭新增用户组件
handleCreateClose(data) { handleCreateClose(data) {
this.createVisible = false this.handleCreateRole()
data && this.roleDataEdit(data) data && !this.editParams && this.addRole(data)
} }
} }
} }
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
<hr> <hr>
<div class="default p-t15"> <div class="default p-t15">
<div class="control-tabledata-button"> <div class="control-tabledata-button">
<gl-button size="small" @click="createUser">新增用户</gl-button> <gl-button size="small" @click="createUser(editUser={})">新增用户</gl-button>
<gl-button size="small" @click="delteSelected">删除选中</gl-button> <gl-button size="small" @click="delteSelected">删除选中</gl-button>
<user-form :dialogFormVisible="dialogFormVisible" @userFormData="handleUserFormData"></user-form> <user-form :dialogFormVisible="dialogFormVisible" :editUser="editUser" @userFormData="handleUserFormData"></user-form>
</div> </div>
<div class="m-b8"> <div class="m-b8">
<gl-table :table="userData" ref="multipleTable" :pagination="pagination"></gl-table> <gl-table :table="userData" ref="multipleTable" :pagination="pagination"></gl-table>
...@@ -31,6 +31,7 @@ export default { ...@@ -31,6 +31,7 @@ export default {
return { return {
userName: '', userName: '',
dialogFormVisible: false, dialogFormVisible: false,
editUser: {},
userData: { userData: {
border: true, border: true,
align: 'center', align: 'center',
...@@ -72,7 +73,7 @@ export default { ...@@ -72,7 +73,7 @@ export default {
label: '编辑', label: '编辑',
type: 'text', type: 'text',
callback: (index, rows) => { callback: (index, rows) => {
this.dialogFormVisible = true this.createUser(rows[index])
} }
}, { }, {
label: '详细', label: '详细',
...@@ -119,7 +120,9 @@ export default { ...@@ -119,7 +120,9 @@ export default {
params && this.userDataCreate(params) params && this.userDataCreate(params)
}, },
// 新增按钮 // 新增按钮
createUser() { createUser(editUser) {
console.log(editUser)
this.editUser = editUser
this.dialogFormVisible = !this.dialogFormVisible this.dialogFormVisible = !this.dialogFormVisible
}, },
// 新增事件 // 新增事件
...@@ -129,18 +132,24 @@ export default { ...@@ -129,18 +132,24 @@ export default {
this.userData.data.push(newData) this.userData.data.push(newData)
}, },
dateFormat() { dateFormat() {
const zeroize = function(value) {
if (value < 10) {
value = '0' + value
return value
} else {
return value
}
}
const currentTime = new Date() const currentTime = new Date()
const year = currentTime.getFullYear() const year = currentTime.getFullYear()
const month = currentTime.getMonth() + 1 const month = zeroize(currentTime.getMonth() + 1)
const day = currentTime.getDate() const day = zeroize(currentTime.getDate())
const h = currentTime.getHours() const h = zeroize(currentTime.getHours())
const m = currentTime.getHours() const m = zeroize(currentTime.getHours())
const s = currentTime.getSeconds() const s = zeroize(currentTime.getSeconds())
const createTime = year + '-' + month + '-' + day + ' ' + h + ':' + m + ':' + s const createTime = year + '-' + month + '-' + day + ' ' + h + ':' + m + ':' + s
console.log(createTime) console.log(createTime)
// const createDate = currentTime.toLocaleDateString().split('/').forEach((item) => { console.log(item) })
return createTime return createTime
// const date = currentTime.toLocaleDateString().split('/').forEach((item) => { console.log(item) })
}, },
handleSelectionChange(val) { handleSelectionChange(val) {
this.multipleSelection = val this.multipleSelection = val
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!