1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<template>
<div class="app-content">
<a-transfer :data-source="mockData" :target-keys="targetKeys" :show-search="showSearch" :list-style="{ width: '60%', height: '60%' }" @change="handleChange" :titles="transferTitles">
<template slot="children" slot-scope="{ props: { filteredItems, selectedKeys, disabled: listDisabled }, on: { itemSelectAll, itemSelect }, }">
<a-table
:row-selection="getRowSelection({ disabled: listDisabled, selectedKeys, itemSelectAll, itemSelect })"
:pagination="false"
:scroll="{ y: 400 }"
:columns="columns"
:data-source="filteredItems"
size="small"
:style="{ pointerEvents: listDisabled ? 'none' : null }"
:custom-row="
({ key, disabled: itemDisabled }) => ({
on: {
click: () => {
if (itemDisabled || listDisabled) return;
itemSelect(key, !selectedKeys.includes(key));
},
},
})
"
/>
</template>
</a-transfer>
</div>
</template>
<script>
import difference from 'lodash/difference';
import { isEmptyParams } from '@/views/utils/common'
export default {
name: "projectGroupAdjust",
props: {
groupInfo1: {
type: Object,
default: {}
},
groupInfo2: {
type: Object,
default: {}
}
},
data() {
return {
mockData: [],
targetKeys: [],
showSearch: false,
disabled: false,
columns: [
{ dataIndex: 'projNo', title: '项目编号' },
{ dataIndex: 'projName', title: '项目名称' },
],
searchForm: { groupId: null },
transferTitles: ['Source', 'Target'],
}
},
created () {
if (this.groupInfo1.expertCount > 0 || this.groupInfo2.expertCount > 0) {
this.$message.error('项目组已经分配有专家,不能进行项目调整!')
this.$emit('close')
}
this.getProjectListByGroupIds()
this.transferTitles = [ this.groupInfo1.groupName, this.groupInfo2.groupName ]
},
methods: {
getProjectListByGroupIds () {
let groupIds = this.groupInfo1.id + ',' + this.groupInfo2.id
this.$api.projectGroupAssign.getProjectListByGroupIds({ groupIds: groupIds }).then(({ data = {} }) => {
if (data) {
this.mockData = data
this.targetKeys = this.mockData.filter(e => e.groupId === this.groupInfo2.id).map(e => e.id)
}
}).catch(() => {})
},
handleChange (targetKeys, direction, moveKeys) {
let gourpId = this.groupInfo1.id
if (direction === 'right')
gourpId = this.groupInfo2.id
let Ids = moveKeys.join(",")
this.$api.projectGroupAssign.updataProjectGroupAdjust({ Ids: Ids, groupId: gourpId }).then(({ data = {} }) => {
if (data === '数据保存成功!') {
//this.targetKeys = targetKeys
this.getProjectListByGroupIds()
} else {
this.$message.info(data)
}
}).catch(() => {})
},
getRowSelection({ disabled, selectedKeys, itemSelectAll, itemSelect }) {
return {
getCheckboxProps: item => ({ props: { disabled: disabled || item.disabled } }),
onSelectAll(selected, selectedRows) {
const treeSelectedKeys = selectedRows
.filter(item => !item.disabled)
.map(({ key }) => key);
const diffKeys = selected
? difference(treeSelectedKeys, selectedKeys)
: difference(selectedKeys, treeSelectedKeys);
itemSelectAll(diffKeys, selected);
},
onSelect({ key }, selected) {
itemSelect(key, selected);
},
selectedRowKeys: selectedKeys,
};
},
},
};
</script>