Commit ee815659 authored by 周远喜's avatar 周远喜

代码合并完成

parent b6d3f0bc
......@@ -24,9 +24,9 @@
<Select placeholder="请选择系统" v-model="systemId" :data="systemList">
<Option v-for="(li,i) in systemList" :value="li.id" :key="li.id">{{li.name}}</Option>
</Select>
<div class="h400">
<!-- <div class="h400">
<json-viewer :value="systemRouters" :expand-depth="5"></json-viewer>
</div>
</div> -->
</div>
</Modal>
</div>
......@@ -71,7 +71,7 @@ export default {
systemId: 0,
systemList: [],
list: [],
systemRouters: appRouter,
// systemRouters: appRouter,
curId: 0,
columns: [
{
......
<template>
<div>
<div class="contentRight">
<!-- 功能按钮 -->
<div class="topTitle">
<Button @click="open" type="success">新增组织</Button>
</div>
<div style="clear:both;"></div>
<!-- 表格区域 -->
<div class="mt10">
<Table
stripe
ref="table"
:height="tbHeight"
class="tableCommon"
:columns="column1"
:data="tableData"
border
></Table>
</div>
</div>
<!-- 新增 -->
<Modal
v-model="show"
:title="title"
:width="440"
:mask-closable="false"
ok-text="保存"
cancel-text="取消"
@on-ok="saveOk"
@on-cancel="saveCancel"
:loading="loading"
>
<div style="height:200px;padding:20px">
<Form :model="openModel" :label-width="100" inline>
<FormItem label="组织类型名称">
<Input
style="width:240px;"
size="large"
v-model.trim="openModel.name"
placeholder="请输入..."
/>
</FormItem>
<FormItem label="上级组织类型">
<Input
v-model="openModel.upLevelName"
readonly
placeholder="请选择..."
style="width:240px"
>
<Button slot="append" @click="selectOrg">选择</Button>
</Input>
</FormItem>
</Form>
</div>
</Modal>
<Modal
v-model="showS"
:title="title"
:width="440"
:mask-closable="false"
ok-text="保存"
cancel-text="取消"
@on-ok="saveOk"
@on-cancel="saveCancel"
:loading="loading"
>
<div style="height:70px;padding-left:10px;padding-right:10px;">
<Form :model="openModel" :label-width="100" inline>
<Row>
<FormItem label="组织类型名称">
<Input
style="width:240px;"
size="large"
v-model.trim="openModel.name"
placeholder="请输入..."
/>
</FormItem>
</Row>
</Form>
</div>
</Modal>
<OrganizType
:show.sync="showTree"
:value.sync="openModel.upLevel"
:text.sync="openModel.upLevelName"
:isAdd="true"
ref="organ"
/>
</div>
</template>
<script>
import OrganizType from '@/components/modalTree/organizType.vue'
export default {
components: { OrganizType },
data() {
return {
column1: [
{
title: '组织类型名称',
key: 'organizName',
align: 'left',
render: (h, params) => {
let name = params.row.organizName
let isExpand = params.row.isExpand
let isDown = params.row.isDown
let iconType = !isDown ? 'md-arrow-dropright' : 'md-arrow-dropdown'
let level = params.row.level
let margLef = level * 20
if (!isExpand) {
return h(
'div',
{ style: { cursor: 'pointer', marginLeft: margLef + 'px' } },
[
h('Icon', {
props: { type: iconType, size: 22 },
style: { marginRight: '5px' },
on: {
click: (e) => {
e.stopPropagation()
this.expandRow(params)
}
}
}),
h('span', name)
]
)
} else {
return h(
'div',
{ style: { marginLeft: margLef + 10 + 'px' } },
name
)
}
}
},
{ title: '创建人', key: 'creator' },
{
title: '创建时间',
key: 'createDate',
align: 'center',
render: (h, params) => {
let value = params.row.createDate.replace('T', ' ')
return h('span', {}, value)
}
},
{
title: '操作',
key: 'id',
align: 'center',
render: (h, params) => {
let id = params.row.id
//let editColor = params.row.level == 1 ? '#DBDBDB' : 'green'
let editColor = 'green'
//let deleColor = params.row.level == 1 ? '#DBDBDB' : 'red'
let deleColor = 'red'
return h('div',{ class: 'action' }, [
h(
'op',
{
attrs:{
oprate:'detail',
class:'edit'
} ,
on: {
click: () => {
this.editRow(params)
}
}
},
'编辑'
),
h(
'op',
{
attrs:{
oprate:'delete',
class: params.row.level == 1 ? 'disable' : 'remove'
} ,
style: {
color: deleColor,
},
on: {
click: () => {
this.deleteRow(params)
}
}
},
'删除'
)
])
}
}
],
itemCount: 1,
title: '',
show: false,
showS: false,
show2: false,
showTree: false,
isAdd: true,
openModel: {
id: 0,
name: '',
upLevelName: '',
upLevel: 0
},
trees: [],
seleId: 0,
tbHeight: 460,
loading: true
}
},
created() {
this.initTable()
},
computed: {
nameList() {
let list = []
this.fakeData.map((item) => {
list.push(item.organizName)
})
return list
},
fakeData() {
return this.trees
},
tableData() {
//return this.trees.length>0?[this.trees[0]]:[];
let res = []
if (this.trees.length > 0) {
res = this.trees.filter((c) => c.upLevelId == 0)
}
return res
}
},
methods: {
initTable() {
this.trees.splice(0)
this.$http.organization.getTableTree(this.trees)
},
expandRow(params) {
let level = params.row.level
//判断当前行是否展开,如果未展开,执行以下方法,先展开再加载数据到tabledata中当前data index 后
if (!this.tableData[params.index].isDown) {
let newArrayData = this.getRecordData(params.row.id)
this.tableData[params.index].isDown = true
let count = newArrayData.length
this.tableData[params.index].totals = count //将展开操作查询到的数据总条数加到当前行数据的totals上
this.itemCount += count
//逐层叠加totals:
if (level > 1) {
let id = params.row.upLevelId
let up1 = this.tableData.filter((c) => c.id == id)[0]
up1.totals += count
if (level == 3) {
id = up1.upLevelId
let up2 = this.tableData.filter((c) => c.id == id)[0]
up2.totals += count
}
}
newArrayData.map((item) => {
item.isDown = false
item.upLevelId = params.row.id
})
newArrayData.map((value, key) => {
this.tableData.splice(params.index + key + 1, 0, value)
})
} else {
//如果当前行已展开,则隐藏
this.tableData[params.index].isDown = false
//以下注释:因为没有逐层收起
// this.tableData.splice(params.index + 1, params.row.totals);
// this.itemCount -=params.row.totals;
if (level == 3) {
//折叠一层:
this.tableData.splice(params.index + 1, params.row.totals)
this.itemCount -= params.row.totals
} else if (level == 2) {
let index = params.index
//先折叠子,再折叠父:
//子:
let downs = this.tableData.filter((c) => c.upLevelId == params.row.id)
let skip = 1 //累计跳过
if (downs.length > 0) {
//有子节点:循环收起每个
for (let i = 0; i < downs.length; i++) {
skip++
let son0 = downs[i]
if (son0.isDown) {
//收--子:
this.tableData[index + i + 1].isDown = false
this.tableData.splice(index + skip, son0.totals)
this.itemCount -= son0.totals
}
}
} else {
//无子节点:
}
//收--父:
this.tableData.splice(params.index + 1, downs.length)
this.itemCount -= downs.length
} else if (level == 1) {
//以下注释:没有逐层收起
// this.fakeData.map(item=>{item.isDown=false;})
// //两层全折叠:
// this.tableData.splice(1,this.itemCount-1);
// this.itemCount=1;
let index = params.index
let skip = 1 //累计跳过
//孙--子--父
//子:
let downs = this.tableData.filter((c) => c.upLevelId == params.row.id)
if (downs.length > 0) {
for (let i = 0; i < downs.length; i++) {
skip++
let son0 = downs[i]
//孙:
let down1s = this.tableData.filter((c) => c.upLevelId == son0.id)
if (down1s.length > 0) {
for (let j = 0; j < down1s.length; j++) {
skip++
let son1 = down1s[j]
if (son1.isDown) {
this.tableData[index + i + 1 + j + 1].isDown = false
this.tableData.splice(params.index + skip, son1.totals)
this.itemCount -= son1.totals
}
}
//收--子:
this.tableData.splice(params.index + 1 + i + 1, down1s.length)
this.itemCount -= down1s.length
}
}
//收--父:
this.tableData.splice(params.index + 1, downs.length)
this.itemCount -= downs.length
}
}
}
},
getRecordData(id) {
return this.fakeData.filter((c) => c.upLevelId == id)
},
open() {
this.isAdd = true
this.title = '添加组织'
this.clearModal()
this.show = true
},
editRow(params) {
this.isAdd = false
//if(params.row.level==1) return;//顶级也可编辑
this.title = '编辑组织'
//查找上级:
const upId = params.row.upLevelId
let upLevelModel = this.tableData.filter((c) => c.id == upId)[0]
//formModel赋值:
this.openModel.id = params.row.id
this.openModel.name = params.row.organizName
this.openModel.upLevel = params.row.upLevelId
if (upLevelModel) {
this.openModel.upLevelName = upLevelModel.organizName
this.show = true
} else {
this.showS = true
}
},
deleteRow(params) {
this.seleId = params.row.id
this.$http.organization.dele(this.seleId).then((res) => {
if (res.data.result == 1) {
//刷新列表:
this.initTable()
this.$refs.organ.initData()
this.$Message.info('删除成功!')
} else if (res.data.result == 2) {
this.$Message.info('删除失败,找不到数据!')
} else if (res.data.result == 3) {
this.$Message.info('删除失败,该组织下有子节点!')
} else {
this.$Message.info('删除失败!')
}
})
},
clearModal() {
this.openModel.id = 0
this.openModel.name = ''
this.openModel.upLevelName = ''
},
saveCancel() {
this.clearModal()
},
//测试阻止弹窗关闭:
messageWarningFn(text) {
this.$Message.warning(text)
setTimeout(() => {
this.loading = false
this.$nextTick(() => {
this.loading = true
})
}, 500)
},
saveOk() {
//校验:
// if(this.nameList.indexOf(this.openModel.name)>-1){
// this.$Message.info("名称已存在!");
// return;
// }
if (!this.openModel.name) {
//this.$Message.info('名称不能为空!')
this.messageWarningFn('名称不能为空!')
return
}
// if (this.openModel.upLevel == 0) {
// this.$Message.info('上级部门为空!')
// return
// }
//保存操作:
if (this.isAdd) {
this.$http.organization.insert(this.openModel).then((res) => {
if (res.data.result) {
//刷新列表:
this.initTable()
this.$refs.organ.initData()
this.$Message.info('新增成功!')
} else {
this.$Message.info('新增失败!')
}
})
} else {
this.$http.organization.update(this.openModel).then((res) => {
if (res.data.result) {
//刷新列表:
this.initTable()
this.$refs.organ.initData()
this.$Message.info('编辑成功!')
} else {
this.$Message.info('编辑失败!')
}
})
}
this.show = false
this.showS = false
//清空:
this.clearModal()
},
deleOk() {
this.$http.organization.dele(this.seleId).then((res) => {
if (res.data.result == 1) {
//刷新列表:
this.initTable()
this.$refs.organ.initData()
this.$Message.info('删除成功!')
} else if (res.data.result == 2) {
this.$Message.info('删除失败,找不到数据!')
} else if (res.data.result == 3) {
this.$Message.info('删除失败,该组织下有子节点!')
} else {
this.$Message.info('删除失败!')
}
})
},
selectOrg() {
this.showTree = true
}
},
mounted() {
this.tbHeight =
window.innerHeight - this.$refs.table.$el.offsetTop - 60 - 66
}
}
</script>
<style scoped>
.ivu-page {
margin-top: 10px;
}
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment