组织机构树修改
This commit is contained in:
parent
9a0519601f
commit
756e8f1a9b
|
@ -1,3 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
export function timeFix() {
|
||||
const time = new Date()
|
||||
const hour = time.getHours()
|
||||
|
@ -67,6 +68,12 @@ export function removeLoadingAnimate(id = '', timeout = 1500) {
|
|||
}
|
||||
|
||||
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 => {
|
||||
if (item.pid === parentId) {
|
||||
const child = {
|
||||
|
|
|
@ -11,7 +11,13 @@
|
|||
<a-col :md="5" :sm="24" class="borderTop ">
|
||||
<div>
|
||||
<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 v-else>
|
||||
<a-empty :image="simpleImage" />
|
||||
|
@ -75,7 +81,7 @@ export default {
|
|||
// 组织机构数需要用到的参数
|
||||
simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
|
||||
orgTree: [],
|
||||
defaultExpandedKeys: [],
|
||||
expandedKeys: [],
|
||||
treeLoading: true,
|
||||
replaceFields: {
|
||||
children: 'children',
|
||||
|
@ -91,25 +97,35 @@ export default {
|
|||
{ title: '部门信息', width: 'auto', align: 'center', dataIndex: 'bmOrgName', key: 'bmOrgName' },
|
||||
{ title: '证书名称', width: 'auto', align: 'center', dataIndex: 'name', key: 'name' },
|
||||
{
|
||||
title: '证书类型', width: 'auto', align: 'center', 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: '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: 'validityEndDate', key: 'validityEndDate' },
|
||||
{
|
||||
title: '证书状态', width: '80px', align: 'center', 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: '80px',
|
||||
align: 'center',
|
||||
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' } }
|
||||
],
|
||||
loadData: null,
|
||||
};
|
||||
loadData: null
|
||||
}
|
||||
},
|
||||
// 计算属性 类似于data概念
|
||||
computed: {},
|
||||
|
@ -124,37 +140,35 @@ export default {
|
|||
if (!res.code === 200 || !res.data.length) {
|
||||
return
|
||||
}
|
||||
this.defaultExpandedKeys = []
|
||||
this.expandedKeys = []
|
||||
this.orgTree = listToTree(res.data, [], 0)
|
||||
this.queryParam.orgId = this.orgTree[0].id
|
||||
for (var item of this.orgTree) {
|
||||
if (item.pid === 0) {
|
||||
this.defaultExpandedKeys.push(item.id)
|
||||
}
|
||||
}
|
||||
// 默认展开
|
||||
this.orgTree.forEach(item => {
|
||||
this.expandedKeys.push(item.id)
|
||||
})
|
||||
|
||||
if (!this.loadData) this.loadData = parameter => { return getArchivesCertificatelist(Object.assign(parameter, this.queryParam)).then(res => { return res }) };
|
||||
else this.handleRefresh();
|
||||
|
||||
});
|
||||
if (!this.loadData) this.loadData = parameter => { return getArchivesCertificatelist(Object.assign(parameter, this.queryParam)).then(res => { return res }) }
|
||||
else this.handleRefresh()
|
||||
})
|
||||
},
|
||||
|
||||
// 获取词典项
|
||||
dictionaryDropDown () {
|
||||
// 获取证书类型
|
||||
dictionaryDropDown({ dictionaryCode: '0001' }).then((res) => {
|
||||
this.queryOptions[0].options = res.data;
|
||||
this.queryOptions[0].options = res.data
|
||||
})
|
||||
|
||||
// 获取证书状态
|
||||
dictionaryDropDown({ dictionaryCode: '0010' }).then((res) => {
|
||||
this.state = res.data;
|
||||
this.state = res.data
|
||||
})
|
||||
},
|
||||
|
||||
// 编辑证书类型
|
||||
editCertificateType () {
|
||||
this.$router.push({ path: '/archives/certificate/CertificateType', query: {} });
|
||||
this.$router.push({ path: '/archives/certificate/CertificateType', query: {} })
|
||||
},
|
||||
|
||||
// 搜索区查询按钮
|
||||
|
@ -164,8 +178,8 @@ export default {
|
|||
|
||||
// 切换组织树
|
||||
changeOrgType () {
|
||||
this.queryParam.orgType = this.queryParam.orgType === 1 ? 2 : 1;
|
||||
this.getOrgTree();
|
||||
this.queryParam.orgType = this.queryParam.orgType === 1 ? 2 : 1
|
||||
this.getOrgTree()
|
||||
// this.handleClick();
|
||||
},
|
||||
|
||||
|
@ -178,34 +192,35 @@ export default {
|
|||
// 修改人员证书
|
||||
editPersonCertificate (record) {
|
||||
this.$router.push({
|
||||
path: '/archives/certificate/EditCertificate', query: {
|
||||
path: '/archives/certificate/EditCertificate',
|
||||
query: {
|
||||
certificateId: record.id
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
|
||||
// 导出人员证书
|
||||
exportPersonCertificate (record) {
|
||||
exportCertificate({ id: record.id }).then(res => {
|
||||
downloadExportFile(res.data);
|
||||
});
|
||||
downloadExportFile(res.data)
|
||||
})
|
||||
},
|
||||
|
||||
// 删除人员证书
|
||||
delPersonCertificate (record) {
|
||||
delCertificate({ id: record.id }).then(res => {
|
||||
this.$message.success("删除证书成功!");
|
||||
this.$message.success('删除证书成功!')
|
||||
this.$refs.table.refresh(true)
|
||||
});
|
||||
})
|
||||
}
|
||||
},
|
||||
// 生命周期 - 创建完成(可以访问当前this实例)
|
||||
created () {
|
||||
// 获取组织机构树
|
||||
this.getOrgTree();
|
||||
this.getOrgTree()
|
||||
|
||||
// 获取所有证书类型
|
||||
this.dictionaryDropDown();
|
||||
this.dictionaryDropDown()
|
||||
},
|
||||
// 生命周期 - 挂载完成(可以访问DOM元素)
|
||||
mounted () { },
|
||||
|
@ -223,7 +238,7 @@ export default {
|
|||
destroyed () { },
|
||||
// 如果页面有keep-alive缓存功能,这个函数会触发
|
||||
activated () { }
|
||||
};
|
||||
}
|
||||
|
||||
</script>
|
||||
<style scoped>
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
:onLoadData="orgTree"
|
||||
v-if="orgTree.length"
|
||||
@select="handleClick"
|
||||
:defaultExpandAll="true"
|
||||
:defaultExpandedKeys="defaultExpandedKeys"
|
||||
:defaultSelectedKeys="defaultSelectedKeys"
|
||||
:defaultExpandAll="false"
|
||||
:expandedKeys="expandedKeys"
|
||||
:defaultSelectedKeys="selectedKeys"
|
||||
:replaceFields="replaceFields" />
|
||||
</div>
|
||||
<div v-else>
|
||||
|
@ -60,8 +60,8 @@
|
|||
v-if="orgTree.length"
|
||||
@select="handleClick"
|
||||
:defaultExpandAll="true"
|
||||
:defaultExpandedKeys="defaultExpandedKeys"
|
||||
:defaultSelectedKeys="defaultSelectedKeys"
|
||||
:expandedKeys="expandedKeys"
|
||||
:defaultSelectedKeys="selectedKeys"
|
||||
:replaceFields="replaceFields" />
|
||||
</div>
|
||||
<div v-else>
|
||||
|
@ -207,7 +207,7 @@
|
|||
{
|
||||
title: '累计学时',
|
||||
dataIndex: 'sumClassHour'
|
||||
},
|
||||
}
|
||||
],
|
||||
loadData2: parameter => {
|
||||
return dataPersonalStatistics(Object.assign(parameter, this.queryParam)).then((res) => {
|
||||
|
@ -221,7 +221,7 @@
|
|||
key: 'index',
|
||||
align: 'center',
|
||||
width: 60,
|
||||
customRender: (text,record,index) => `${index+1}`,
|
||||
customRender: (text, record, index) => `${index + 1}`
|
||||
},
|
||||
{
|
||||
title: '姓名',
|
||||
|
@ -256,7 +256,7 @@
|
|||
key: 'index',
|
||||
align: 'center',
|
||||
width: 60,
|
||||
customRender: (text,record,index) => `${index+1}`,
|
||||
customRender: (text, record, index) => `${index + 1}`
|
||||
},
|
||||
{
|
||||
title: '姓名',
|
||||
|
@ -287,8 +287,8 @@
|
|||
orgTree: [],
|
||||
selectedRowKeys: [],
|
||||
selectedRows: [],
|
||||
defaultExpandedKeys: [],
|
||||
defaultSelectedKeys: [],
|
||||
expandedKeys: [],
|
||||
selectedKeys: [],
|
||||
treeLoading: true,
|
||||
simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
|
||||
replaceFields: {
|
||||
|
@ -329,16 +329,15 @@
|
|||
if (!res.code === 200 || !res.data.length) {
|
||||
return
|
||||
}
|
||||
this.defaultExpandedKeys = []
|
||||
this.defaultSelectedKeys = []
|
||||
this.expandedKeys = []
|
||||
this.selectedKeys = []
|
||||
this.orgTree = listToTree(res.data, [], 0)
|
||||
this.orgId = this.orgTree[0].id
|
||||
this.defaultSelectedKeys.push(this.orgId)
|
||||
for (var item of this.orgTree) {
|
||||
if (item.pid === 0) {
|
||||
this.defaultExpandedKeys.push(item.id)
|
||||
}
|
||||
}
|
||||
this.selectedKeys.push(this.orgId)
|
||||
// 默认展开
|
||||
this.orgTree.forEach(item => {
|
||||
this.expandedKeys.push(item.id)
|
||||
})
|
||||
})
|
||||
},
|
||||
/**
|
||||
|
|
|
@ -109,11 +109,10 @@ export default {
|
|||
return
|
||||
}
|
||||
const orgTree = listToTree(res.data, [], rootParentId)
|
||||
for (var item of orgTree) {
|
||||
if (item.pid === 0) {
|
||||
// 默认展开
|
||||
orgTree.forEach(item => {
|
||||
this.expandedKeys.push(item.id)
|
||||
}
|
||||
}
|
||||
})
|
||||
generateList(orgTree)
|
||||
this.orgList = orgTree
|
||||
})
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
<a-col :md="12" :sm="24">
|
||||
<a-form :form="form">
|
||||
<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>
|
||||
</a-col>
|
||||
|
@ -72,7 +72,7 @@
|
|||
<a-form :form="form">
|
||||
<a-form-item label="性别" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||||
<a-radio-group
|
||||
readOnly
|
||||
disabled
|
||||
v-decorator="['sex', { rules: [{ required: true, message: '请选择性别!' }] }]"
|
||||
>
|
||||
<a-radio :value="1">男</a-radio>
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
:onLoadData="orgTree"
|
||||
v-if="orgTree.length"
|
||||
@select="handleClick"
|
||||
:defaultExpandAll="true"
|
||||
:defaultExpandedKeys="defaultExpandedKeys"
|
||||
:defaultSelectedKeys="defaultSelectedKeys"
|
||||
:defaultExpandAll="false"
|
||||
:expandedKeys="expandedKeys"
|
||||
:defaultSelectedKeys="selectedKeys"
|
||||
:replaceFields="replaceFields" />
|
||||
</div>
|
||||
<div v-else>
|
||||
|
@ -165,7 +165,7 @@ export default {
|
|||
},
|
||||
{
|
||||
title: '年度学时要求',
|
||||
dataIndex: 'classHours'
|
||||
dataIndex: 'planClassHour'
|
||||
},
|
||||
{
|
||||
title: '注册时间',
|
||||
|
@ -175,6 +175,7 @@ export default {
|
|||
],
|
||||
// 加载数据方法 必须为 Promise 对象
|
||||
loadData: parameter => {
|
||||
if (!this.orgId) return []
|
||||
return personPage(Object.assign(parameter, this.queryParam)).then((res) => {
|
||||
return res
|
||||
})
|
||||
|
@ -182,8 +183,8 @@ export default {
|
|||
orgTree: [],
|
||||
selectedRowKeys: [],
|
||||
selectedRows: [],
|
||||
defaultExpandedKeys: [],
|
||||
defaultSelectedKeys: [],
|
||||
expandedKeys: [],
|
||||
selectedKeys: [],
|
||||
treeLoading: true,
|
||||
simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
|
||||
replaceFields: {
|
||||
|
@ -226,26 +227,28 @@ export default {
|
|||
async getOrgTree () {
|
||||
await orgList({ orgType: this.orgType }).then(res => {
|
||||
this.treeLoading = false
|
||||
this.expandedKeys = []
|
||||
this.selectedKeys = []
|
||||
if (!res.code === 200 || !res.data.length) {
|
||||
this.orgTree = []
|
||||
return
|
||||
}
|
||||
this.defaultExpandedKeys = []
|
||||
this.defaultSelectedKeys = []
|
||||
this.orgTree = listToTree(res.data, [], rootParentId)
|
||||
this.orgId = this.orgTree[0].id
|
||||
this.defaultSelectedKeys.push(this.orgId)
|
||||
for (var item of this.orgTree) {
|
||||
if (item.pid === 0) {
|
||||
this.defaultExpandedKeys.push(item.id)
|
||||
}
|
||||
}
|
||||
this.selectedKeys.push(this.orgId)
|
||||
// 默认展开
|
||||
this.orgTree.forEach(item => {
|
||||
this.expandedKeys.push(item.id)
|
||||
})
|
||||
|
||||
this.handleClick(this.orgId)
|
||||
})
|
||||
},
|
||||
async changeOrgType () {
|
||||
this.orgType = this.orgType === 1 ? 2 : 1
|
||||
await this.getOrgTree()
|
||||
// 此处使用async和await 由于需要等待orgTree的返回 再往下依据结果继续执行
|
||||
this.handleClick(this.orgId)
|
||||
// this.handleClick(this.orgId)
|
||||
},
|
||||
/**
|
||||
* 重置密码
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
:treeData="orgTree"
|
||||
v-if="orgTree.length"
|
||||
@select="onSelect"
|
||||
:defaultExpandAll="true"
|
||||
:defaultExpandedKeys="defaultExpandedKeys"
|
||||
:defaultSelectedKeys="defaultSelectedKeys"
|
||||
:defaultExpandAll="false"
|
||||
:expandedKeys="expandedKeys"
|
||||
:defaultSelectedKeys="selectedKeys"
|
||||
:replaceFields="replaceFields"
|
||||
>
|
||||
<a-icon slot="switcherIcon" type="down" />
|
||||
|
@ -105,8 +105,8 @@ export default {
|
|||
replaceFields: { children: 'children', title: 'name', key: 'id', value: 'id' },
|
||||
expandedKeys: [],
|
||||
autoExpandParent: true,
|
||||
defaultExpandedKeys: [],
|
||||
defaultSelectedKeys: [],
|
||||
expandedKeys: [],
|
||||
selectedKeys: [],
|
||||
orgTree: [],
|
||||
orgId: this.$route.query.orgId,
|
||||
orgType: 2,
|
||||
|
@ -227,16 +227,15 @@ export default {
|
|||
return
|
||||
}
|
||||
var rootParentId = res.data[0].pid
|
||||
this.defaultExpandedKeys = []
|
||||
this.defaultSelectedKeys = []
|
||||
this.expandedKeys = []
|
||||
this.selectedKeys = []
|
||||
this.orgTree = listToTree(res.data, [], rootParentId)
|
||||
this.orgId = this.orgTree[0].id
|
||||
this.defaultSelectedKeys.push(this.orgId)
|
||||
for (var item of this.orgTree) {
|
||||
if (item.pid === 0) {
|
||||
this.defaultExpandedKeys.push(item.id)
|
||||
}
|
||||
}
|
||||
this.selectedKeys.push(this.orgId)
|
||||
// 默认展开
|
||||
this.orgTree.forEach(item => {
|
||||
this.expandedKeys.push(item.id)
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
|
|
|
@ -10,7 +10,13 @@
|
|||
<a-col :span="4" id="tree">
|
||||
<a-page-header title="单位列表" sub-title="" />
|
||||
<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-tree>
|
||||
</div>
|
||||
|
@ -71,12 +77,12 @@ export default {
|
|||
// import引入的组件需要注入到对象中才能使用
|
||||
components: {
|
||||
orgList,
|
||||
STable,
|
||||
STable
|
||||
},
|
||||
props: {
|
||||
projectForm: {
|
||||
type: Object,
|
||||
},
|
||||
type: Object
|
||||
}
|
||||
},
|
||||
data () {
|
||||
// 这里存放数据
|
||||
|
@ -87,7 +93,7 @@ export default {
|
|||
replaceFields: { children: 'children', title: 'name', key: 'id', value: 'id' },
|
||||
expandedKeys: [],
|
||||
autoExpandParent: true,
|
||||
defaultExpandedKeys: [],
|
||||
expandedKeys: [],
|
||||
selectedRowKeys: [],
|
||||
selectedRows: this.projectForm.projectPersonLists || [],
|
||||
orgTree: [],
|
||||
|
@ -96,21 +102,21 @@ export default {
|
|||
columns: [
|
||||
{ title: '序号', key: 'id', dataIndex: 'id', width: 60, scopedSlots: { customRender: 'serial' } },
|
||||
{ title: '姓名', dataIndex: 'name' },
|
||||
{ title: '用户名', dataIndex: 'userName' },
|
||||
{ title: '用户名', dataIndex: 'userName' }
|
||||
],
|
||||
// 人员列表数据
|
||||
loadData: (parameter) => {
|
||||
return personPage(Object.assign(parameter, this.queryParam)).then((res) => {
|
||||
return res
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
// 计算属性 类似于data概念
|
||||
computed: {
|
||||
hasSelected () {
|
||||
return this.selectedRowKeys.length > 0
|
||||
},
|
||||
}
|
||||
},
|
||||
// 监控data中的数据变化
|
||||
watch: {},
|
||||
|
@ -190,7 +196,7 @@ export default {
|
|||
this.selectedRowKeys = [],
|
||||
this.form.projectPersonLists.forEach(element => {
|
||||
this.selectedRowKeys.push(element.id)
|
||||
});
|
||||
})
|
||||
console.log('初始化的值', this.selectedRowKeys)
|
||||
}
|
||||
},
|
||||
|
@ -204,16 +210,15 @@ export default {
|
|||
if (!res.code === 200 || !res.data.length) {
|
||||
return
|
||||
}
|
||||
this.defaultExpandedKeys = []
|
||||
this.expandedKeys = []
|
||||
this.orgTree = listToTree(res.data, [], rootParentId)
|
||||
this.orgId = this.orgTree[0].id
|
||||
for (var item of this.orgTree) {
|
||||
if (item.pid === 0) {
|
||||
this.defaultExpandedKeys.push(item.id)
|
||||
}
|
||||
}
|
||||
// 默认展开
|
||||
this.orgTree.forEach(item => {
|
||||
this.expandedKeys.push(item.id)
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
// 生命周期 - 创建完成(可以访问当前this实例)
|
||||
created () {
|
||||
|
@ -235,7 +240,7 @@ export default {
|
|||
// 生命周期 - 销毁完成
|
||||
destroyed () { },
|
||||
// 如果页面有keep-alive缓存功能,这个函数会触发
|
||||
activated() { },
|
||||
activated () { }
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
|
|
Loading…
Reference in New Issue