Commit c06fab7c by cwq0219

部门-添加和编辑接口;验证

1 parent 25aab8fc
......@@ -29,7 +29,12 @@ const roleDataColumn = [{
}
}, {
label: '创建时间',
prop: 'createTime'
prop: 'createTime',
formatter: (cellValue) => {
if (cellValue.createTime) {
return new Date(cellValue.createTime).format('yyyy-MM-dd HH:mm:ss')
}
}
}]
const userRoleDetailColumn = [{
......
......@@ -26,7 +26,9 @@
v-model="value.form[i.value]"
:disabled="i.disabled">
</gl-input>
<div v-show="err && index === 0" class="err">{{errText}}</div>
<div v-show="err && index === 0" class="err">{{textName}}</div>
<div v-show="errExist && index === 0" class="err">{{textExist}}</div>
<div v-show="errIorder && index === 8" class="err">{{textType}}</div>
</gl-form-item>
<gl-form-item>
<gl-button type="primary" @click="submit">{{value.btnTxt}}</gl-button>
......@@ -48,14 +50,18 @@
</div>
</template>
<script type='text/ecmascript-6'>
import { delDepartment, delMenu, editMenu, addMenu } from '@/api/api'
import { delDepartment, delMenu, editMenu, addMenu, updateDepartment } from '@/api/api'
export default {
name: 'rightForm',
data() {
return {
dialog: false,
err: false,
errText: this.isDepart ? '请填写部门名称' : '请填写列表名称'
textName: this.isDepart ? '请填写部门名称' : '请填写列表名称',
errExist: false,
textExist: '',
errIorder: false,
textType: '请填写数字'
}
},
props: {
......@@ -68,13 +74,29 @@ export default {
},
watch: {
'value.form.urlName'(val) {
if (val !== '') this.err = false
if (val !== '') this.nameTip()
},
'value.form.name'(val) {
if (val !== '') this.err = false
if (val !== '') this.nameTip()
},
'value.form.iorder'(val) {
if (val && !parseInt(val)) {
this.errIorder = true
} else {
this.errIorder = false
}
}
},
methods: {
nameTip() {
this.err = false
this.errExist = false
this.textExist = ''
},
nameExitTip(err) {
this.errExist = true
this.textExist = err
},
getMenuObj(obj = {}) {
for (const key in this.value.form) {
obj[key] = this.value.form[key]
......@@ -82,6 +104,19 @@ export default {
if (!this.isDepart) delete obj.name
return obj
},
// 接口调用-start
addOrEditDepart(params) {
// console.log(obj)
// const params = this.getDepartParams()
console.log(params)
updateDepartment.req(params).then(res => {
this.Tip(true)
console.log(res)
}).catch(err => {
console.log(err)
})
},
// 接口调用-end
// 删除
delData() {
const obj = this.getMenuObj()
......@@ -131,9 +166,8 @@ export default {
const treeData = this.value.allNode
if (this.value.form[this.form[0].value] !== '' && this.value.form[this.form[0].value] !== null) {
const obj = this.getMenuObj()
// obj.updateTime = new Date().getTime()
obj.isHidden = this.value.form.isHidden === true ? 0 : 1
console.log(obj)
// console.log(obj)
// 添加同级
if (this.value.sublings) {
if (treeData.parent === '#') {
......@@ -148,14 +182,17 @@ export default {
this.addData(obj)
// 修改
} else {
// obj.createTime = this.unix(this.value.form.createTime)
editMenu.req(obj).then(res => {
console.log(res)
this.Tip(true)
}).catch(err => {
console.log(err)
this.Tip(false)
})
if (!this.isDepart) {
editMenu.req(obj).then(res => {
console.log(res)
this.Tip(true)
}).catch(err => {
console.log(err)
this.Tip(false)
})
} else {
this.addOrEditDepart(obj)
}
}
} else {
this.err = true
......@@ -167,19 +204,15 @@ export default {
return new Date(time).getTime()
},
addData(obj) {
// obj.createTime = new Date().getTime()
// const objPackge = { menu: obj }
// console.log(objPackge)
// delete obj.createTime
// delete obj.updateTime
if (!this.isDepart) {
addMenu.req(obj).then(res => {
console.log(res)
this.Tip(true)
}).catch(err => {
console.log(err)
this.Tip(false)
this.nameExitTip(err)
// this.Tip(false)
})
} else {
this.addOrEditDepart(obj)
}
},
Tip(val) {
......
......@@ -59,8 +59,10 @@ export default {
this.department.push = false
this.department.form.upDepartment = node.level === 1 ? '广联赛讯' : node.parent.data[props.label]
getDepartTreeNode.req({ id: data.id }).then(res => {
this.department.form.id = res.id
this.department.form.name = res.name
this.department.form.iorder = res.iorder
this.department.form.parentId = res.parentId
}).catch(err => {
console.log(err)
})
......
......@@ -106,14 +106,9 @@ export default {
},
methods: {
message(message, type) {
type && this.$message({
showClose: true,
this.$notify({
type: type,
message: message
})
!type && this.$message({
showClose: true,
message: message
title: message
})
},
confirmDeleteOrNot(index, rows) {
......@@ -125,7 +120,7 @@ export default {
// 删除角色,根据返回的code值来判断是否删除成功(已有拦截器)
this.deleteRole(rows[index].id)
}).catch(() => {
this.message('取消删除')
this.message('取消删除', 'info')
})
},
// 获取页面参数
......@@ -162,21 +157,7 @@ export default {
// 获得角色的相关权限详细信息,并返回树形数据
getMenuTree(params) {
selectMenuTreeRoleId.req({ id: params }).then(res => {
// console.log(res)
// let count = 0
// res.forEach(item => {
// this.roleMenuTree.push(item.id)
// count = count + 1
// })
// console.log(`count = ${count}`)
// console.log(this.roleMenuTree)
// console.log(this.roleParam.rights)
this.roleMenuTree = res
// console.log(this.roleMenuTree)
// console.log('------------------------')
// console.log(this.roleMenuTree instanceof Array)
// console.log(this.roleParam.rights instanceof Array)
// this.editOrDetail && this.createDialogVisible()
this.deleteDialogVisible()
}).catch(err => {
console.log(err)
......@@ -268,7 +249,7 @@ export default {
this.roleParam = roleCreateStructure
if (!data) {
this.createDialogVisible()
this.message(this.flagCOrE ? '取消创建角色' : '取消编辑角色')
this.message(this.flagCOrE ? '取消创建角色' : '取消编辑角色', 'info')
return false
}
// 将数据提交给后台,根据返回结果做判断
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!