项目列表选择人员更新

This commit is contained in:
Yuanjianghong 2021-11-19 14:46:30 +08:00
parent c55c81c701
commit 4f2c3b0b11
2 changed files with 181 additions and 24 deletions

View File

@ -11,11 +11,11 @@
<a-step title="完成" /> <a-step title="完成" />
</a-steps> </a-steps>
<div class="content"> <div class="content">
<step1 v-bind:form="form" v-if="currentTab === 0" @nextStep="nextStep" /> <step1 v-if="currentTab === 0" @nextStep="nextStep" />
<step2 v-bind:form="form" v-if="currentTab === 1" @nextStep="nextStep" @prevStep="prevStep" /> <step2 v-if="currentTab === 1" @nextStep="nextStep" @prevStep="prevStep" />
<step3 v-bind:form="form" v-if="currentTab === 2" @nextStep="nextStep" @prevStep="prevStep" /> <step3 v-if="currentTab === 2" @nextStep="nextStep" @prevStep="prevStep" />
<step4 v-bind:form="form" v-if="currentTab === 3" @nextStep="nextStep" @prevStep="prevStep" /> <step4 v-if="currentTab === 3" @nextStep="nextStep" @prevStep="prevStep" />
<step5 v-bind:form="form" v-if="currentTab === 4" @prevStep="prevStep" @finish="finish" /> <step5 v-if="currentTab === 4" @prevStep="prevStep" @finish="finish" />
</div> </div>
</a-card> </a-card>
</template> </template>

View File

@ -1,36 +1,119 @@
<template> <template>
<a-form-model :model="form" :label-col="labelCol" :wrapper-col="wrapperCol" layout="horizontal">
<div> <div>
<a-row type="flex" justify="center" align="top"> <a-row type="flex" justify="center" align="top">
<a-col :span="4" id="tree"> <a-col :span="4" id="tree">
<a-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-icon slot="switcherIcon" type="down" />
</a-tree> </a-tree>
</div>
</a-col> </a-col>
<a-col :span="20" id="content"> <a-col :span="20" id="content">
<h1>人员选择</h1> <a-page-header title="人员选择" sub-title="" />
<a-col :span="18" id="table">
<a-form layout="inline">
<a-row>
<a-form-item label="姓名">
<a-input v-model="queryParam.name" placeholder="请输入姓名" />
</a-form-item>
<a-form-item label="人员类型">
<a-select default-value="0" style="width: 120px">
<a-select-option value="0"> - - </a-select-option>
<a-select-option value="1"> </a-select-option>
<a-select-option value="2"> </a-select-option>
<a-select-option value="3"> </a-select-option>
</a-select>
</a-form-item>
<a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
<a-button style="margin-left: 8px" @click="() => (queryParam = {})">重置</a-button>
</a-row>
</a-form>
<s-table
ref="table"
:columns="columns"
:data="loadData"
:rowKey="(record) => record.id"
:rowSelection="{ selectedRowKeys: selectedRowKeys, selectedRows: selectedRows, onChange: onSelectChange }"
>
<span slot="serial" slot-scope="text, record, index">
{{ index + 1 }}
</span>
</s-table>
</a-col>
<a-col :span="6" id="select">
<p>点击列表项取消选择或<a @click="removeAllSelece">清空所有</a></p>
<a-list size="small" :data-source="selectedRows" :rowKey="(item) => item.id">
<a-list-item slot="renderItem" slot-scope="item" @click="changeList({ item })">
{{ item.name + '' + item.userName + '' }}
</a-list-item>
</a-list>
</a-col>
</a-col> </a-col>
</a-row> </a-row>
<a-button type="primary" @click="toNext">下一步</a-button> <a-button type="primary" @click="toNext">下一步</a-button>
<a-button type="primary" @click="toPrev">上一步</a-button> <a-button type="primary" @click="toPrev">上一步</a-button>
</div> </div>
</a-form-model>
</template> </template>
<script> <script>
// jsjsjson // jsjsjson
// import from '' // import from ''
import { orgList } from '@/api/org/org'
import { listToTree } from '@/utils/util'
import { personPage } from '@/api/person/person'
import { STable } from '@/components'
const rootParentId = 0
export default { export default {
// import使 // import使
components: {}, components: {
orgList,
STable,
},
props: {}, props: {},
data() { data() {
// //
return {} return {
//
queryParam: { orgType: 1 },
replaceFields: { children: 'children', title: 'name', key: 'id', value: 'id' },
expandedKeys: [],
autoExpandParent: true,
defaultExpandedKeys: [],
selectedRowKeys: [],
selectedRows: [],
keyData: [], //key
rowsData: [], //
orgTree: [],
orgId: '',
orgType: 1,
columns: [
{ title: '序号', key: 'id', dataIndex: 'id', width: 60, scopedSlots: { customRender: 'serial' } },
{ title: '姓名', dataIndex: 'name' },
{ title: '用户名', dataIndex: 'userName' },
],
//
loadData: (parameter) => {
return personPage(Object.assign(parameter, this.queryParam)).then((res) => {
return res
})
},
}
}, },
// data // data
computed: {}, computed: {
hasSelected() {
return this.selectedRowKeys.length > 0
},
},
// data // data
watch: {}, watch: {},
// //
@ -39,12 +122,86 @@ export default {
toNext() { toNext() {
this.$emit('nextStep') this.$emit('nextStep')
}, },
//
toPrev() { toPrev() {
this.$emit('prevStep') this.$emit('prevStep')
}, },
/** 表格行选中后触发 */
onSelectChange(selectedRowKeys, selectedRows) {
console.log('selectedRowKeys changed: ', selectedRowKeys)
console.log('选择的表格数据 : ', selectedRows)
this.selectedRowKeys = this.uniqueKeys([...this.selectedRowKeys, ...selectedRowKeys])
this.selectedRows = this.unique([...this.selectedRows, ...selectedRows])
},
//
unique(arr) {
const res = new Map()
return arr.filter((arr) => !res.has(arr.id) && res.set(arr.id, 1))
},
//key
uniqueKeys(arr) {
const res = new Map()
return arr.filter((arr) => !res.has(arr) && res.set(arr, 1))
},
//
changeList(item) {
console.log('列表点击删除列表项 : ', item)
this.selectedRows = this.selectedRows.filter(function (i) {
return i.id != item.item.id
})
this.selectedRowKeys = this.selectedRowKeys.filter(function (i) {
return i != item.item.id
})
},
//
removeAllSelece() {
this.selectedRowKeys = []
this.selectedRows = []
},
//
onSelect(selectedKey, info) {
console.log('selected', selectedKey, info)
this.queryParam.orgId = selectedKey.toString()
this.orgId = selectedKey.toString()
this.$refs.table.refresh(true)
},
//使
onExpand(expandedKeys) {
this.expandedKeys = expandedKeys
this.autoExpandParent = false
},
/**
* 获取到机构树展开顶级下树节点考虑到后期数据量变大不建议全部展开
*/
async getOrgTree() {
await orgList({ orgType: this.orgType }).then((res) => {
this.treeLoading = false
if (!res.code === 200 || !res.data.length) {
return
}
this.defaultExpandedKeys = []
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 // - 访this
created() {}, created() {
this.getOrgTree()
},
// - 访DOM // - 访DOM
mounted() {}, mounted() {},
// - // -
@ -64,7 +221,7 @@ export default {
} }
</script> </script>
<style scoped> <style scoped>
#tree { /* #tree {
height: 750px; height: 750px;
background-color: beige; background-color: beige;
} }
@ -72,6 +229,6 @@ export default {
#content { #content {
height: 750px; height: 750px;
background-color: bisque; background-color: bisque;
} } */
/* /project/form/ProjectPersonForm.vue */ /* /project/form/ProjectPersonForm.vue */
</style> </style>