<template>
|
<a-modal
|
:title='title'
|
:width='1200'
|
:visible='visible'
|
:confirmLoading='confirmLoading'
|
@ok='handleOk'
|
@cancel='handleCancel'
|
>
|
<a-spin :spinning='confirmLoading'>
|
<div>
|
<a-transfer
|
:data-source='dataSource'
|
:target-keys='targetKeys'
|
:disabled='disabled'
|
:show-search='showSearch'
|
:filter-option='(inputValue, item) => item.title.indexOf(inputValue) !== -1'
|
:show-select-all='false'
|
@change='onChange'
|
>
|
<template
|
slot='children'
|
slot-scope='{
|
props: { direction, filteredItems, selectedKeys, disabled: listDisabled },
|
on: { itemSelectAll, itemSelect },
|
}'
|
>
|
<a-table
|
:row-selection='
|
getRowSelection({ disabled: listDisabled, selectedKeys, itemSelectAll, itemSelect })
|
'
|
:columns="direction === 'left' ? leftColumns : rightColumns"
|
: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>
|
|
</a-spin>
|
|
<!-- 选择用户 -->
|
</a-modal>
|
</template>
|
|
<script>
|
import JSelectUserByDepModal from '@/components/jeecgbiz/modal/JSelectUserByDepModal'
|
import { getAction, putAction } from '@/api/manage'
|
|
import difference from 'lodash/difference'
|
|
|
const leftTableColumns = [
|
{
|
dataIndex: 'title',
|
title: '项目名称'
|
},
|
{
|
dataIndex: 'description',
|
title: '项目编号'
|
}
|
]
|
const rightTableColumns = [
|
{
|
dataIndex: 'title',
|
title: '项目名称'
|
}
|
]
|
|
|
export default {
|
name: 'ProGroupSelectModal',
|
components: {
|
JSelectUserByDepModal
|
},
|
data() {
|
return {
|
title: '选择项目',
|
visible: false,
|
model: {},
|
|
confirmLoading: false,
|
validatorRules: {},
|
|
dataSource: [],
|
targetKeys: [],
|
disabled: false,
|
showSearch: true,
|
leftColumns: leftTableColumns,
|
rightColumns: rightTableColumns,
|
url: {
|
list: '/pro/project/list',
|
editBatch: '/pro/project/editBatch',
|
}
|
}
|
},
|
watch: {},
|
methods: {
|
edit(record) {
|
this.visible = true
|
this.model = Object.assign({}, record)
|
this.loadData()
|
},
|
|
handleCancel() {
|
this.close()
|
},
|
onChange(nextTargetKeys) {
|
this.targetKeys = nextTargetKeys
|
},
|
|
|
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
|
}
|
},
|
handleOk() {
|
let params = {id:this.targetKeys.join(","),groupCode:this.model.groupCode }
|
this.confirmLoading = true
|
putAction(this.url.editBatch,params).then(res=>{
|
if(res.success){
|
this.$message.success(res.message)
|
this.$emit('ok')
|
this.close()
|
|
}
|
}).finally(() => {
|
this.confirmLoading = false
|
})
|
|
},
|
loadData() {
|
let params = { pageNo: 1, pageSize: 100000 }
|
this.confirmLoading = true
|
//拉取所有项目
|
getAction(this.url.list, params).then((res) => {
|
this.confirmLoading = false
|
if (res.success) {
|
let data = res.result.records
|
//筛选未分配的项目和 当前项目集(groupCode)的项目
|
this.dataSource = data.filter(item => item.id && (item.groupCode == null || item.groupCode == this.model.groupCode)).map(item => {
|
return { key: item.id, title: item.xmmc, description: item.xmbh}
|
})
|
//当前项目集已分配项目
|
this.targetKeys = data.filter(item => item.id && item.groupCode == this.model.groupCode).map(item=>item.id);
|
}
|
}).finally(() => {
|
this.confirmLoading = false
|
})
|
},
|
|
/*handleOk() {
|
let that = this
|
this.$refs.form.validate((valid) => {
|
if (valid) {
|
that.confirmLoading = true
|
//add
|
|
putAction(this.url.edit, that.model)
|
.then((res) => {
|
that.confirmLoading = false
|
if (res.success) {
|
that.close()
|
that.$message.success(res.message)
|
that.$emit('ok', res.result)
|
that.close()
|
} else {
|
that.$message.warning(res.message)
|
}
|
})
|
.finally(() => {
|
that.confirmLoading = false
|
})
|
}
|
})
|
},*/
|
close() {
|
this.$emit('close')
|
this.visible = false
|
},
|
|
handleChangeUserCommon(v) {
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
</style>
|