组织机构树修改
This commit is contained in:
parent
9a0519601f
commit
756e8f1a9b
|
@ -1,3 +1,4 @@
|
||||||
|
import _ from 'lodash'
|
||||||
export function timeFix() {
|
export function timeFix() {
|
||||||
const time = new Date()
|
const time = new Date()
|
||||||
const hour = time.getHours()
|
const hour = time.getHours()
|
||||||
|
@ -67,6 +68,12 @@ export function removeLoadingAnimate(id = '', timeout = 1500) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function listToTree(list, tree, parentId) {
|
export function listToTree(list, tree, parentId) {
|
||||||
|
list.map(item => {
|
||||||
|
const index = _.findIndex(list, ['id', item.pid])
|
||||||
|
if(index === -1){
|
||||||
|
item.pid = 0
|
||||||
|
}
|
||||||
|
})
|
||||||
list.forEach(item => {
|
list.forEach(item => {
|
||||||
if (item.pid === parentId) {
|
if (item.pid === parentId) {
|
||||||
const child = {
|
const child = {
|
||||||
|
|
|
@ -11,7 +11,13 @@
|
||||||
<a-col :md="5" :sm="24" class="borderTop ">
|
<a-col :md="5" :sm="24" class="borderTop ">
|
||||||
<div>
|
<div>
|
||||||
<div v-if="this.orgTree != ''">
|
<div v-if="this.orgTree != ''">
|
||||||
<a-tree :treeData="orgTree" v-if="orgTree.length" @select="handleClick" :defaultExpandAll="true" :defaultExpandedKeys="defaultExpandedKeys" :replaceFields="replaceFields" />
|
<a-tree
|
||||||
|
:treeData="orgTree"
|
||||||
|
v-if="orgTree.length"
|
||||||
|
@select="handleClick"
|
||||||
|
:defaultExpandAll="true"
|
||||||
|
:expandedKeys="expandedKeys"
|
||||||
|
:replaceFields="replaceFields" />
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<a-empty :image="simpleImage" />
|
<a-empty :image="simpleImage" />
|
||||||
|
@ -63,7 +69,7 @@ export default {
|
||||||
// import引入的组件需要注入到对象中才能使用
|
// import引入的组件需要注入到对象中才能使用
|
||||||
components: { STable, SearchCom },
|
components: { STable, SearchCom },
|
||||||
props: {},
|
props: {},
|
||||||
data() {
|
data () {
|
||||||
// 这里存放数据
|
// 这里存放数据
|
||||||
return {
|
return {
|
||||||
queryParam: { orgId: '', orgType: 1, type: '' },
|
queryParam: { orgId: '', orgType: 1, type: '' },
|
||||||
|
@ -75,7 +81,7 @@ export default {
|
||||||
// 组织机构数需要用到的参数
|
// 组织机构数需要用到的参数
|
||||||
simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
|
simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
|
||||||
orgTree: [],
|
orgTree: [],
|
||||||
defaultExpandedKeys: [],
|
expandedKeys: [],
|
||||||
treeLoading: true,
|
treeLoading: true,
|
||||||
replaceFields: {
|
replaceFields: {
|
||||||
children: 'children',
|
children: 'children',
|
||||||
|
@ -91,25 +97,35 @@ export default {
|
||||||
{ title: '部门信息', width: 'auto', align: 'center', dataIndex: 'bmOrgName', key: 'bmOrgName' },
|
{ title: '部门信息', width: 'auto', align: 'center', dataIndex: 'bmOrgName', key: 'bmOrgName' },
|
||||||
{ title: '证书名称', width: 'auto', align: 'center', dataIndex: 'name', key: 'name' },
|
{ title: '证书名称', width: 'auto', align: 'center', dataIndex: 'name', key: 'name' },
|
||||||
{
|
{
|
||||||
title: '证书类型', width: 'auto', align: 'center', dataIndex: 'type', key: 'type', customRender: (text, record, index) => {
|
title: '证书类型',
|
||||||
let textStr = '';
|
width: 'auto',
|
||||||
this.queryOptions[0].options.forEach(element => { if (element.value.toString() === text) textStr = element.name; });
|
align: 'center',
|
||||||
return textStr;
|
dataIndex: 'type',
|
||||||
|
key: 'type',
|
||||||
|
customRender: (text, record, index) => {
|
||||||
|
let textStr = ''
|
||||||
|
this.queryOptions[0].options.forEach(element => { if (element.value.toString() === text) textStr = element.name })
|
||||||
|
return textStr
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ title: '注册日期', width: 'auto', align: 'center', dataIndex: 'registerDate', key: 'registerDate' },
|
{ title: '注册日期', width: 'auto', align: 'center', dataIndex: 'registerDate', key: 'registerDate' },
|
||||||
{ title: '失效日期', width: 'auto', align: 'center', dataIndex: 'validityEndDate', key: 'validityEndDate' },
|
{ title: '失效日期', width: 'auto', align: 'center', dataIndex: 'validityEndDate', key: 'validityEndDate' },
|
||||||
{
|
{
|
||||||
title: '证书状态', width: '80px', align: 'center', dataIndex: 'state', key: 'state', customRender: (text, record, index) => {
|
title: '证书状态',
|
||||||
let textStr = '';
|
width: '80px',
|
||||||
this.state.forEach(element => { if (element.value.toString() === text) textStr = element.name; });
|
align: 'center',
|
||||||
return textStr;
|
dataIndex: 'state',
|
||||||
|
key: 'state',
|
||||||
|
customRender: (text, record, index) => {
|
||||||
|
let textStr = ''
|
||||||
|
this.state.forEach(element => { if (element.value.toString() === text) textStr = element.name })
|
||||||
|
return textStr
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ title: '操作', width: '70px', key: 'operation', align: 'center', scopedSlots: { customRender: 'action' } }
|
{ title: '操作', width: '70px', key: 'operation', align: 'center', scopedSlots: { customRender: 'action' } }
|
||||||
],
|
],
|
||||||
loadData: null,
|
loadData: null
|
||||||
};
|
}
|
||||||
},
|
},
|
||||||
// 计算属性 类似于data概念
|
// 计算属性 类似于data概念
|
||||||
computed: {},
|
computed: {},
|
||||||
|
@ -118,112 +134,111 @@ export default {
|
||||||
// 方法集合
|
// 方法集合
|
||||||
methods: {
|
methods: {
|
||||||
// 获取到机构树,展开顶级下树节点,考虑到后期数据量变大,不建议全部展开
|
// 获取到机构树,展开顶级下树节点,考虑到后期数据量变大,不建议全部展开
|
||||||
getOrgTree() {
|
getOrgTree () {
|
||||||
orgList({ orgType: this.queryParam.orgType }).then(res => {
|
orgList({ orgType: this.queryParam.orgType }).then(res => {
|
||||||
this.treeLoading = false
|
this.treeLoading = false
|
||||||
if (!res.code === 200 || !res.data.length) {
|
if (!res.code === 200 || !res.data.length) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.defaultExpandedKeys = []
|
this.expandedKeys = []
|
||||||
this.orgTree = listToTree(res.data, [], 0)
|
this.orgTree = listToTree(res.data, [], 0)
|
||||||
this.queryParam.orgId = this.orgTree[0].id
|
this.queryParam.orgId = this.orgTree[0].id
|
||||||
for (var item of this.orgTree) {
|
// 默认展开
|
||||||
if (item.pid === 0) {
|
this.orgTree.forEach(item => {
|
||||||
this.defaultExpandedKeys.push(item.id)
|
this.expandedKeys.push(item.id)
|
||||||
}
|
})
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.loadData) this.loadData = parameter => { return getArchivesCertificatelist(Object.assign(parameter, this.queryParam)).then(res => { return res }) };
|
if (!this.loadData) this.loadData = parameter => { return getArchivesCertificatelist(Object.assign(parameter, this.queryParam)).then(res => { return res }) }
|
||||||
else this.handleRefresh();
|
else this.handleRefresh()
|
||||||
|
})
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 获取词典项
|
// 获取词典项
|
||||||
dictionaryDropDown() {
|
dictionaryDropDown () {
|
||||||
// 获取证书类型
|
// 获取证书类型
|
||||||
dictionaryDropDown({ dictionaryCode: '0001' }).then((res) => {
|
dictionaryDropDown({ dictionaryCode: '0001' }).then((res) => {
|
||||||
this.queryOptions[0].options = res.data;
|
this.queryOptions[0].options = res.data
|
||||||
})
|
})
|
||||||
|
|
||||||
// 获取证书状态
|
// 获取证书状态
|
||||||
dictionaryDropDown({ dictionaryCode: '0010' }).then((res) => {
|
dictionaryDropDown({ dictionaryCode: '0010' }).then((res) => {
|
||||||
this.state = res.data;
|
this.state = res.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
// 编辑证书类型
|
// 编辑证书类型
|
||||||
editCertificateType() {
|
editCertificateType () {
|
||||||
this.$router.push({ path: '/archives/certificate/CertificateType', query: {} });
|
this.$router.push({ path: '/archives/certificate/CertificateType', query: {} })
|
||||||
},
|
},
|
||||||
|
|
||||||
// 搜索区查询按钮
|
// 搜索区查询按钮
|
||||||
handleRefresh() {
|
handleRefresh () {
|
||||||
this.$refs.table.refresh(true)
|
this.$refs.table.refresh(true)
|
||||||
},
|
},
|
||||||
|
|
||||||
// 切换组织树
|
// 切换组织树
|
||||||
changeOrgType() {
|
changeOrgType () {
|
||||||
this.queryParam.orgType = this.queryParam.orgType === 1 ? 2 : 1;
|
this.queryParam.orgType = this.queryParam.orgType === 1 ? 2 : 1
|
||||||
this.getOrgTree();
|
this.getOrgTree()
|
||||||
// this.handleClick();
|
// this.handleClick();
|
||||||
},
|
},
|
||||||
|
|
||||||
// 点击组织树节点时调用
|
// 点击组织树节点时调用
|
||||||
handleClick(e) {
|
handleClick (e) {
|
||||||
this.queryParam.orgId = e.toString()
|
this.queryParam.orgId = e.toString()
|
||||||
this.$refs.table.refresh(true)
|
this.$refs.table.refresh(true)
|
||||||
},
|
},
|
||||||
|
|
||||||
// 修改人员证书
|
// 修改人员证书
|
||||||
editPersonCertificate(record) {
|
editPersonCertificate (record) {
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
path: '/archives/certificate/EditCertificate', query: {
|
path: '/archives/certificate/EditCertificate',
|
||||||
|
query: {
|
||||||
certificateId: record.id
|
certificateId: record.id
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
// 导出人员证书
|
// 导出人员证书
|
||||||
exportPersonCertificate(record) {
|
exportPersonCertificate (record) {
|
||||||
exportCertificate({ id: record.id }).then(res => {
|
exportCertificate({ id: record.id }).then(res => {
|
||||||
downloadExportFile(res.data);
|
downloadExportFile(res.data)
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
// 删除人员证书
|
// 删除人员证书
|
||||||
delPersonCertificate(record) {
|
delPersonCertificate (record) {
|
||||||
delCertificate({ id: record.id }).then(res => {
|
delCertificate({ id: record.id }).then(res => {
|
||||||
this.$message.success("删除证书成功!");
|
this.$message.success('删除证书成功!')
|
||||||
this.$refs.table.refresh(true)
|
this.$refs.table.refresh(true)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 生命周期 - 创建完成(可以访问当前this实例)
|
// 生命周期 - 创建完成(可以访问当前this实例)
|
||||||
created() {
|
created () {
|
||||||
// 获取组织机构树
|
// 获取组织机构树
|
||||||
this.getOrgTree();
|
this.getOrgTree()
|
||||||
|
|
||||||
// 获取所有证书类型
|
// 获取所有证书类型
|
||||||
this.dictionaryDropDown();
|
this.dictionaryDropDown()
|
||||||
},
|
},
|
||||||
// 生命周期 - 挂载完成(可以访问DOM元素)
|
// 生命周期 - 挂载完成(可以访问DOM元素)
|
||||||
mounted() { },
|
mounted () { },
|
||||||
// 生命周期 - 创建之前
|
// 生命周期 - 创建之前
|
||||||
beforeCreate() { },
|
beforeCreate () { },
|
||||||
// 生命周期 - 挂载之前
|
// 生命周期 - 挂载之前
|
||||||
beforeMount() { },
|
beforeMount () { },
|
||||||
// 生命周期 - 更新之前
|
// 生命周期 - 更新之前
|
||||||
beforeUpdate() { },
|
beforeUpdate () { },
|
||||||
// 生命周期 - 更新之后
|
// 生命周期 - 更新之后
|
||||||
updated() { },
|
updated () { },
|
||||||
// 生命周期 - 销毁之前
|
// 生命周期 - 销毁之前
|
||||||
beforeDestroy() { },
|
beforeDestroy () { },
|
||||||
// 生命周期 - 销毁完成
|
// 生命周期 - 销毁完成
|
||||||
destroyed() { },
|
destroyed () { },
|
||||||
// 如果页面有keep-alive缓存功能,这个函数会触发
|
// 如果页面有keep-alive缓存功能,这个函数会触发
|
||||||
activated() { }
|
activated () { }
|
||||||
};
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -233,4 +248,4 @@ export default {
|
||||||
.borderRight {
|
.borderRight {
|
||||||
border-right: 1px solid #e8e8e8;
|
border-right: 1px solid #e8e8e8;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
:onLoadData="orgTree"
|
:onLoadData="orgTree"
|
||||||
v-if="orgTree.length"
|
v-if="orgTree.length"
|
||||||
@select="handleClick"
|
@select="handleClick"
|
||||||
:defaultExpandAll="true"
|
:defaultExpandAll="false"
|
||||||
:defaultExpandedKeys="defaultExpandedKeys"
|
:expandedKeys="expandedKeys"
|
||||||
:defaultSelectedKeys="defaultSelectedKeys"
|
:defaultSelectedKeys="selectedKeys"
|
||||||
:replaceFields="replaceFields" />
|
:replaceFields="replaceFields" />
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
|
@ -60,8 +60,8 @@
|
||||||
v-if="orgTree.length"
|
v-if="orgTree.length"
|
||||||
@select="handleClick"
|
@select="handleClick"
|
||||||
:defaultExpandAll="true"
|
:defaultExpandAll="true"
|
||||||
:defaultExpandedKeys="defaultExpandedKeys"
|
:expandedKeys="expandedKeys"
|
||||||
:defaultSelectedKeys="defaultSelectedKeys"
|
:defaultSelectedKeys="selectedKeys"
|
||||||
:replaceFields="replaceFields" />
|
:replaceFields="replaceFields" />
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
|
@ -86,8 +86,8 @@
|
||||||
</a-form>
|
</a-form>
|
||||||
</div>
|
</div>
|
||||||
<div class="table-operator">
|
<div class="table-operator">
|
||||||
<a-button @click="changeSort(1)" ref="toFocus">按累计学时排序</a-button>
|
<a-button @click="changeSort(1)" ref="toFocus">按累计学时排序</a-button>
|
||||||
<a-button @click="changeSort(2)">按年度学时排序</a-button>
|
<a-button @click="changeSort(2)">按年度学时排序</a-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<s-table
|
<s-table
|
||||||
|
@ -104,8 +104,8 @@
|
||||||
|
|
||||||
<a-divider>前十统计排名</a-divider>
|
<a-divider>前十统计排名</a-divider>
|
||||||
<div class="table-operator">
|
<div class="table-operator">
|
||||||
<a-button @click="changeTopType(1)">公司排名年度学时前十统计</a-button>
|
<a-button @click="changeTopType(1)">公司排名年度学时前十统计</a-button>
|
||||||
<a-button @click="changeTopType(2)">公司累计学时学时前十统计</a-button>
|
<a-button @click="changeTopType(2)">公司累计学时学时前十统计</a-button>
|
||||||
</div>
|
</div>
|
||||||
<s-table
|
<s-table
|
||||||
v-show="topType==1"
|
v-show="topType==1"
|
||||||
|
@ -180,7 +180,7 @@
|
||||||
loadData1: parameter => {
|
loadData1: parameter => {
|
||||||
return dataOrgStatistics(Object.assign(parameter, this.queryParam)).then((res) => {
|
return dataOrgStatistics(Object.assign(parameter, this.queryParam)).then((res) => {
|
||||||
const data = res.rows
|
const data = res.rows
|
||||||
data.forEach(function(val){
|
data.forEach(function (val) {
|
||||||
val.trainRate = val.trainRate + '%'
|
val.trainRate = val.trainRate + '%'
|
||||||
})
|
})
|
||||||
return res
|
return res
|
||||||
|
@ -207,7 +207,7 @@
|
||||||
{
|
{
|
||||||
title: '累计学时',
|
title: '累计学时',
|
||||||
dataIndex: 'sumClassHour'
|
dataIndex: 'sumClassHour'
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
loadData2: parameter => {
|
loadData2: parameter => {
|
||||||
return dataPersonalStatistics(Object.assign(parameter, this.queryParam)).then((res) => {
|
return dataPersonalStatistics(Object.assign(parameter, this.queryParam)).then((res) => {
|
||||||
|
@ -221,7 +221,7 @@
|
||||||
key: 'index',
|
key: 'index',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
width: 60,
|
width: 60,
|
||||||
customRender: (text,record,index) => `${index+1}`,
|
customRender: (text, record, index) => `${index + 1}`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '姓名',
|
title: '姓名',
|
||||||
|
@ -256,7 +256,7 @@
|
||||||
key: 'index',
|
key: 'index',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
width: 60,
|
width: 60,
|
||||||
customRender: (text,record,index) => `${index+1}`,
|
customRender: (text, record, index) => `${index + 1}`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '姓名',
|
title: '姓名',
|
||||||
|
@ -287,8 +287,8 @@
|
||||||
orgTree: [],
|
orgTree: [],
|
||||||
selectedRowKeys: [],
|
selectedRowKeys: [],
|
||||||
selectedRows: [],
|
selectedRows: [],
|
||||||
defaultExpandedKeys: [],
|
expandedKeys: [],
|
||||||
defaultSelectedKeys: [],
|
selectedKeys: [],
|
||||||
treeLoading: true,
|
treeLoading: true,
|
||||||
simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
|
simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
|
||||||
replaceFields: {
|
replaceFields: {
|
||||||
|
@ -314,7 +314,7 @@
|
||||||
this.$refs.table1.refresh(true)
|
this.$refs.table1.refresh(true)
|
||||||
}
|
}
|
||||||
if (key === '2') {
|
if (key === '2') {
|
||||||
this.$nextTick(()=>{
|
this.$nextTick(() => {
|
||||||
// 添加columns事件
|
// 添加columns事件
|
||||||
this.$refs.table2.refresh(true)
|
this.$refs.table2.refresh(true)
|
||||||
this.$refs.toFocus.$el.focus()
|
this.$refs.toFocus.$el.focus()
|
||||||
|
@ -329,16 +329,15 @@
|
||||||
if (!res.code === 200 || !res.data.length) {
|
if (!res.code === 200 || !res.data.length) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.defaultExpandedKeys = []
|
this.expandedKeys = []
|
||||||
this.defaultSelectedKeys = []
|
this.selectedKeys = []
|
||||||
this.orgTree = listToTree(res.data, [], 0)
|
this.orgTree = listToTree(res.data, [], 0)
|
||||||
this.orgId = this.orgTree[0].id
|
this.orgId = this.orgTree[0].id
|
||||||
this.defaultSelectedKeys.push(this.orgId)
|
this.selectedKeys.push(this.orgId)
|
||||||
for (var item of this.orgTree) {
|
// 默认展开
|
||||||
if (item.pid === 0) {
|
this.orgTree.forEach(item => {
|
||||||
this.defaultExpandedKeys.push(item.id)
|
this.expandedKeys.push(item.id)
|
||||||
}
|
})
|
||||||
}
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -109,11 +109,10 @@ export default {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const orgTree = listToTree(res.data, [], rootParentId)
|
const orgTree = listToTree(res.data, [], rootParentId)
|
||||||
for (var item of orgTree) {
|
// 默认展开
|
||||||
if (item.pid === 0) {
|
orgTree.forEach(item => {
|
||||||
this.expandedKeys.push(item.id)
|
this.expandedKeys.push(item.id)
|
||||||
}
|
})
|
||||||
}
|
|
||||||
generateList(orgTree)
|
generateList(orgTree)
|
||||||
this.orgList = orgTree
|
this.orgList = orgTree
|
||||||
})
|
})
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
<a-col :md="12" :sm="24">
|
<a-col :md="12" :sm="24">
|
||||||
<a-form :form="form">
|
<a-form :form="form">
|
||||||
<a-form-item label="年龄" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
|
<a-form-item label="年龄" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
|
||||||
<a-input readOnly v-decorator="['age']" />
|
<a-input disabled v-decorator="['age']" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
</a-col>
|
</a-col>
|
||||||
|
@ -72,7 +72,7 @@
|
||||||
<a-form :form="form">
|
<a-form :form="form">
|
||||||
<a-form-item label="性别" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
<a-form-item label="性别" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||||||
<a-radio-group
|
<a-radio-group
|
||||||
readOnly
|
disabled
|
||||||
v-decorator="['sex', { rules: [{ required: true, message: '请选择性别!' }] }]"
|
v-decorator="['sex', { rules: [{ required: true, message: '请选择性别!' }] }]"
|
||||||
>
|
>
|
||||||
<a-radio :value="1">男</a-radio>
|
<a-radio :value="1">男</a-radio>
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
:onLoadData="orgTree"
|
:onLoadData="orgTree"
|
||||||
v-if="orgTree.length"
|
v-if="orgTree.length"
|
||||||
@select="handleClick"
|
@select="handleClick"
|
||||||
:defaultExpandAll="true"
|
:defaultExpandAll="false"
|
||||||
:defaultExpandedKeys="defaultExpandedKeys"
|
:expandedKeys="expandedKeys"
|
||||||
:defaultSelectedKeys="defaultSelectedKeys"
|
:defaultSelectedKeys="selectedKeys"
|
||||||
:replaceFields="replaceFields" />
|
:replaceFields="replaceFields" />
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
|
@ -165,7 +165,7 @@ export default {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '年度学时要求',
|
title: '年度学时要求',
|
||||||
dataIndex: 'classHours'
|
dataIndex: 'planClassHour'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '注册时间',
|
title: '注册时间',
|
||||||
|
@ -175,6 +175,7 @@ export default {
|
||||||
],
|
],
|
||||||
// 加载数据方法 必须为 Promise 对象
|
// 加载数据方法 必须为 Promise 对象
|
||||||
loadData: parameter => {
|
loadData: parameter => {
|
||||||
|
if (!this.orgId) return []
|
||||||
return personPage(Object.assign(parameter, this.queryParam)).then((res) => {
|
return personPage(Object.assign(parameter, this.queryParam)).then((res) => {
|
||||||
return res
|
return res
|
||||||
})
|
})
|
||||||
|
@ -182,8 +183,8 @@ export default {
|
||||||
orgTree: [],
|
orgTree: [],
|
||||||
selectedRowKeys: [],
|
selectedRowKeys: [],
|
||||||
selectedRows: [],
|
selectedRows: [],
|
||||||
defaultExpandedKeys: [],
|
expandedKeys: [],
|
||||||
defaultSelectedKeys: [],
|
selectedKeys: [],
|
||||||
treeLoading: true,
|
treeLoading: true,
|
||||||
simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
|
simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
|
||||||
replaceFields: {
|
replaceFields: {
|
||||||
|
@ -226,26 +227,28 @@ export default {
|
||||||
async getOrgTree () {
|
async getOrgTree () {
|
||||||
await orgList({ orgType: this.orgType }).then(res => {
|
await orgList({ orgType: this.orgType }).then(res => {
|
||||||
this.treeLoading = false
|
this.treeLoading = false
|
||||||
|
this.expandedKeys = []
|
||||||
|
this.selectedKeys = []
|
||||||
if (!res.code === 200 || !res.data.length) {
|
if (!res.code === 200 || !res.data.length) {
|
||||||
|
this.orgTree = []
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.defaultExpandedKeys = []
|
|
||||||
this.defaultSelectedKeys = []
|
|
||||||
this.orgTree = listToTree(res.data, [], rootParentId)
|
this.orgTree = listToTree(res.data, [], rootParentId)
|
||||||
this.orgId = this.orgTree[0].id
|
this.orgId = this.orgTree[0].id
|
||||||
this.defaultSelectedKeys.push(this.orgId)
|
this.selectedKeys.push(this.orgId)
|
||||||
for (var item of this.orgTree) {
|
// 默认展开
|
||||||
if (item.pid === 0) {
|
this.orgTree.forEach(item => {
|
||||||
this.defaultExpandedKeys.push(item.id)
|
this.expandedKeys.push(item.id)
|
||||||
}
|
})
|
||||||
}
|
|
||||||
|
this.handleClick(this.orgId)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
async changeOrgType () {
|
async changeOrgType () {
|
||||||
this.orgType = this.orgType === 1 ? 2 : 1
|
this.orgType = this.orgType === 1 ? 2 : 1
|
||||||
await this.getOrgTree()
|
await this.getOrgTree()
|
||||||
// 此处使用async和await 由于需要等待orgTree的返回 再往下依据结果继续执行
|
// 此处使用async和await 由于需要等待orgTree的返回 再往下依据结果继续执行
|
||||||
this.handleClick(this.orgId)
|
// this.handleClick(this.orgId)
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 重置密码
|
* 重置密码
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
:treeData="orgTree"
|
:treeData="orgTree"
|
||||||
v-if="orgTree.length"
|
v-if="orgTree.length"
|
||||||
@select="onSelect"
|
@select="onSelect"
|
||||||
:defaultExpandAll="true"
|
:defaultExpandAll="false"
|
||||||
:defaultExpandedKeys="defaultExpandedKeys"
|
:expandedKeys="expandedKeys"
|
||||||
:defaultSelectedKeys="defaultSelectedKeys"
|
:defaultSelectedKeys="selectedKeys"
|
||||||
:replaceFields="replaceFields"
|
:replaceFields="replaceFields"
|
||||||
>
|
>
|
||||||
<a-icon slot="switcherIcon" type="down" />
|
<a-icon slot="switcherIcon" type="down" />
|
||||||
|
@ -105,8 +105,8 @@ export default {
|
||||||
replaceFields: { children: 'children', title: 'name', key: 'id', value: 'id' },
|
replaceFields: { children: 'children', title: 'name', key: 'id', value: 'id' },
|
||||||
expandedKeys: [],
|
expandedKeys: [],
|
||||||
autoExpandParent: true,
|
autoExpandParent: true,
|
||||||
defaultExpandedKeys: [],
|
expandedKeys: [],
|
||||||
defaultSelectedKeys: [],
|
selectedKeys: [],
|
||||||
orgTree: [],
|
orgTree: [],
|
||||||
orgId: this.$route.query.orgId,
|
orgId: this.$route.query.orgId,
|
||||||
orgType: 2,
|
orgType: 2,
|
||||||
|
@ -227,16 +227,15 @@ export default {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var rootParentId = res.data[0].pid
|
var rootParentId = res.data[0].pid
|
||||||
this.defaultExpandedKeys = []
|
this.expandedKeys = []
|
||||||
this.defaultSelectedKeys = []
|
this.selectedKeys = []
|
||||||
this.orgTree = listToTree(res.data, [], rootParentId)
|
this.orgTree = listToTree(res.data, [], rootParentId)
|
||||||
this.orgId = this.orgTree[0].id
|
this.orgId = this.orgTree[0].id
|
||||||
this.defaultSelectedKeys.push(this.orgId)
|
this.selectedKeys.push(this.orgId)
|
||||||
for (var item of this.orgTree) {
|
// 默认展开
|
||||||
if (item.pid === 0) {
|
this.orgTree.forEach(item => {
|
||||||
this.defaultExpandedKeys.push(item.id)
|
this.expandedKeys.push(item.id)
|
||||||
}
|
})
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,7 +10,13 @@
|
||||||
<a-col :span="4" id="tree">
|
<a-col :span="4" id="tree">
|
||||||
<a-page-header title="单位列表" sub-title="" />
|
<a-page-header title="单位列表" sub-title="" />
|
||||||
<div v-if="this.orgTree != ''">
|
<div v-if="this.orgTree != ''">
|
||||||
<a-tree :treeData="orgTree" v-if="orgTree.length" @select="onSelect" :defaultExpandAll="true" :defaultExpandedKeys="defaultExpandedKeys" :replaceFields="replaceFields">
|
<a-tree
|
||||||
|
:treeData="orgTree"
|
||||||
|
v-if="orgTree.length"
|
||||||
|
@select="onSelect"
|
||||||
|
:defaultExpandAll="false"
|
||||||
|
:expandedKeys="expandedKeys"
|
||||||
|
:replaceFields="replaceFields">
|
||||||
<a-icon slot="switcherIcon" type="down" />
|
<a-icon slot="switcherIcon" type="down" />
|
||||||
</a-tree>
|
</a-tree>
|
||||||
</div>
|
</div>
|
||||||
|
@ -71,14 +77,14 @@ export default {
|
||||||
// import引入的组件需要注入到对象中才能使用
|
// import引入的组件需要注入到对象中才能使用
|
||||||
components: {
|
components: {
|
||||||
orgList,
|
orgList,
|
||||||
STable,
|
STable
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
projectForm: {
|
projectForm: {
|
||||||
type: Object,
|
type: Object
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data () {
|
||||||
// 这里存放数据
|
// 这里存放数据
|
||||||
return {
|
return {
|
||||||
form: this.projectForm,
|
form: this.projectForm,
|
||||||
|
@ -87,7 +93,7 @@ export default {
|
||||||
replaceFields: { children: 'children', title: 'name', key: 'id', value: 'id' },
|
replaceFields: { children: 'children', title: 'name', key: 'id', value: 'id' },
|
||||||
expandedKeys: [],
|
expandedKeys: [],
|
||||||
autoExpandParent: true,
|
autoExpandParent: true,
|
||||||
defaultExpandedKeys: [],
|
expandedKeys: [],
|
||||||
selectedRowKeys: [],
|
selectedRowKeys: [],
|
||||||
selectedRows: this.projectForm.projectPersonLists || [],
|
selectedRows: this.projectForm.projectPersonLists || [],
|
||||||
orgTree: [],
|
orgTree: [],
|
||||||
|
@ -96,28 +102,28 @@ export default {
|
||||||
columns: [
|
columns: [
|
||||||
{ title: '序号', key: 'id', dataIndex: 'id', width: 60, scopedSlots: { customRender: 'serial' } },
|
{ title: '序号', key: 'id', dataIndex: 'id', width: 60, scopedSlots: { customRender: 'serial' } },
|
||||||
{ title: '姓名', dataIndex: 'name' },
|
{ title: '姓名', dataIndex: 'name' },
|
||||||
{ title: '用户名', dataIndex: 'userName' },
|
{ title: '用户名', dataIndex: 'userName' }
|
||||||
],
|
],
|
||||||
//人员列表数据
|
// 人员列表数据
|
||||||
loadData: (parameter) => {
|
loadData: (parameter) => {
|
||||||
return personPage(Object.assign(parameter, this.queryParam)).then((res) => {
|
return personPage(Object.assign(parameter, this.queryParam)).then((res) => {
|
||||||
return res
|
return res
|
||||||
})
|
})
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 计算属性 类似于data概念
|
// 计算属性 类似于data概念
|
||||||
computed: {
|
computed: {
|
||||||
hasSelected() {
|
hasSelected () {
|
||||||
return this.selectedRowKeys.length > 0
|
return this.selectedRowKeys.length > 0
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
// 监控data中的数据变化
|
// 监控data中的数据变化
|
||||||
watch: {},
|
watch: {},
|
||||||
// 方法集合
|
// 方法集合
|
||||||
methods: {
|
methods: {
|
||||||
//下一步
|
// 下一步
|
||||||
toNext() {
|
toNext () {
|
||||||
this.form.projectPersonLists = this.selectedRows
|
this.form.projectPersonLists = this.selectedRows
|
||||||
this.form.personIds = this.selectedRowKeys
|
this.form.personIds = this.selectedRowKeys
|
||||||
if (this.form.personIds.length > 0) {
|
if (this.form.personIds.length > 0) {
|
||||||
|
@ -126,35 +132,35 @@ export default {
|
||||||
this.$message.warning('培训人员不能为空')
|
this.$message.warning('培训人员不能为空')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//上一步
|
// 上一步
|
||||||
toPrev() {
|
toPrev () {
|
||||||
this.form.projectPersonLists = this.selectedRows
|
this.form.projectPersonLists = this.selectedRows
|
||||||
this.form.personIds = this.selectedRowKeys
|
this.form.personIds = this.selectedRowKeys
|
||||||
this.$emit('prevStep', this.form)
|
this.$emit('prevStep', this.form)
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 表格行选中后触发 */
|
/** 表格行选中后触发 */
|
||||||
onSelectChange(selectedRowKeys, selectedRows) {
|
onSelectChange (selectedRowKeys, selectedRows) {
|
||||||
console.log('selectedRowKeys changed: ', selectedRowKeys)
|
console.log('selectedRowKeys changed: ', selectedRowKeys)
|
||||||
console.log('选择的表格数据 : ', selectedRows)
|
console.log('选择的表格数据 : ', selectedRows)
|
||||||
this.selectedRowKeys = this.uniqueKeys([...this.selectedRowKeys, ...selectedRowKeys])
|
this.selectedRowKeys = this.uniqueKeys([...this.selectedRowKeys, ...selectedRowKeys])
|
||||||
this.selectedRows = this.unique([...this.selectedRows, ...selectedRows])
|
this.selectedRows = this.unique([...this.selectedRows, ...selectedRows])
|
||||||
},
|
},
|
||||||
|
|
||||||
//对象去重
|
// 对象去重
|
||||||
unique(arr) {
|
unique (arr) {
|
||||||
const res = new Map()
|
const res = new Map()
|
||||||
return arr.filter((arr) => !res.has(arr.id) && res.set(arr.id, 1))
|
return arr.filter((arr) => !res.has(arr.id) && res.set(arr.id, 1))
|
||||||
},
|
},
|
||||||
|
|
||||||
//key去重
|
// key去重
|
||||||
uniqueKeys(arr) {
|
uniqueKeys (arr) {
|
||||||
const res = new Map()
|
const res = new Map()
|
||||||
return arr.filter((arr) => !res.has(arr) && res.set(arr, 1))
|
return arr.filter((arr) => !res.has(arr) && res.set(arr, 1))
|
||||||
},
|
},
|
||||||
|
|
||||||
//列表点击删除列表项
|
// 列表点击删除列表项
|
||||||
changeList(item) {
|
changeList (item) {
|
||||||
console.log('列表点击删除列表项 : ', item)
|
console.log('列表点击删除列表项 : ', item)
|
||||||
this.selectedRows = this.selectedRows.filter(function (i) {
|
this.selectedRows = this.selectedRows.filter(function (i) {
|
||||||
return i.id != item.item.id
|
return i.id != item.item.id
|
||||||
|
@ -164,78 +170,77 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
//清空选择
|
// 清空选择
|
||||||
removeAllSelece() {
|
removeAllSelece () {
|
||||||
this.selectedRowKeys = []
|
this.selectedRowKeys = []
|
||||||
this.selectedRows = []
|
this.selectedRows = []
|
||||||
},
|
},
|
||||||
|
|
||||||
//选中后触发
|
// 选中后触发
|
||||||
onSelect(selectedKey, info) {
|
onSelect (selectedKey, info) {
|
||||||
console.log('selected', selectedKey, info)
|
console.log('selected', selectedKey, info)
|
||||||
this.queryParam.orgId = selectedKey.toString()
|
this.queryParam.orgId = selectedKey.toString()
|
||||||
this.orgId = selectedKey.toString()
|
this.orgId = selectedKey.toString()
|
||||||
this.$refs.table.refresh(true)
|
this.$refs.table.refresh(true)
|
||||||
},
|
},
|
||||||
|
|
||||||
//树使用的方法
|
// 树使用的方法
|
||||||
onExpand(expandedKeys) {
|
onExpand (expandedKeys) {
|
||||||
this.expandedKeys = expandedKeys
|
this.expandedKeys = expandedKeys
|
||||||
this.autoExpandParent = false
|
this.autoExpandParent = false
|
||||||
},
|
},
|
||||||
|
|
||||||
//编辑时初始化人员列表初始化
|
// 编辑时初始化人员列表初始化
|
||||||
initPersonList() {
|
initPersonList () {
|
||||||
if (this.form.projectPersonLists) {
|
if (this.form.projectPersonLists) {
|
||||||
this.selectedRowKeys = [],
|
this.selectedRowKeys = [],
|
||||||
this.form.projectPersonLists.forEach(element => {
|
this.form.projectPersonLists.forEach(element => {
|
||||||
this.selectedRowKeys.push(element.id)
|
this.selectedRowKeys.push(element.id)
|
||||||
});
|
})
|
||||||
console.log('初始化的值',this.selectedRowKeys)
|
console.log('初始化的值', this.selectedRowKeys)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取到机构树,展开顶级下树节点,考虑到后期数据量变大,不建议全部展开
|
* 获取到机构树,展开顶级下树节点,考虑到后期数据量变大,不建议全部展开
|
||||||
*/
|
*/
|
||||||
async getOrgTree() {
|
async getOrgTree () {
|
||||||
await orgList({ orgType: this.orgType }).then((res) => {
|
await orgList({ orgType: this.orgType }).then((res) => {
|
||||||
this.treeLoading = false
|
this.treeLoading = false
|
||||||
if (!res.code === 200 || !res.data.length) {
|
if (!res.code === 200 || !res.data.length) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.defaultExpandedKeys = []
|
this.expandedKeys = []
|
||||||
this.orgTree = listToTree(res.data, [], rootParentId)
|
this.orgTree = listToTree(res.data, [], rootParentId)
|
||||||
this.orgId = this.orgTree[0].id
|
this.orgId = this.orgTree[0].id
|
||||||
for (var item of this.orgTree) {
|
// 默认展开
|
||||||
if (item.pid === 0) {
|
this.orgTree.forEach(item => {
|
||||||
this.defaultExpandedKeys.push(item.id)
|
this.expandedKeys.push(item.id)
|
||||||
}
|
})
|
||||||
}
|
|
||||||
})
|
})
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
// 生命周期 - 创建完成(可以访问当前this实例)
|
// 生命周期 - 创建完成(可以访问当前this实例)
|
||||||
created() {
|
created () {
|
||||||
this.getOrgTree()
|
this.getOrgTree()
|
||||||
this.initPersonList()
|
this.initPersonList()
|
||||||
},
|
},
|
||||||
// 生命周期 - 挂载完成(可以访问DOM元素)
|
// 生命周期 - 挂载完成(可以访问DOM元素)
|
||||||
mounted() { },
|
mounted () { },
|
||||||
// 生命周期 - 创建之前
|
// 生命周期 - 创建之前
|
||||||
beforeCreate() { },
|
beforeCreate () { },
|
||||||
// 生命周期 - 挂载之前
|
// 生命周期 - 挂载之前
|
||||||
beforeMount() { },
|
beforeMount () { },
|
||||||
// 生命周期 - 更新之前
|
// 生命周期 - 更新之前
|
||||||
beforeUpdate() { },
|
beforeUpdate () { },
|
||||||
// 生命周期 - 更新之后
|
// 生命周期 - 更新之后
|
||||||
updated() { },
|
updated () { },
|
||||||
// 生命周期 - 销毁之前
|
// 生命周期 - 销毁之前
|
||||||
beforeDestroy() { },
|
beforeDestroy () { },
|
||||||
// 生命周期 - 销毁完成
|
// 生命周期 - 销毁完成
|
||||||
destroyed() { },
|
destroyed () { },
|
||||||
// 如果页面有keep-alive缓存功能,这个函数会触发
|
// 如果页面有keep-alive缓存功能,这个函数会触发
|
||||||
activated() { },
|
activated () { }
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -249,4 +254,4 @@ export default {
|
||||||
background-color: bisque;
|
background-color: bisque;
|
||||||
} */
|
} */
|
||||||
/* /project/form/ProjectPersonForm.vue */
|
/* /project/form/ProjectPersonForm.vue */
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue