JVxeDepartSelectCell.vue
4.18 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<template>
<div>
<a-input
v-show="!departIds"
@click="openSelect"
placeholder="请点击选择部门"
v-model="departNames"
readOnly
:disabled="componentDisabled"
class="jvxe-select-input">
<a-icon slot="prefix" type="cluster" title="部门选择控件"/>
</a-input>
<j-select-depart-modal
ref="innerDepartSelectModal"
:modal-width="modalWidth"
:multi="multi"
:rootOpened="rootOpened"
:depart-id="departIds"
:store="storeField()"
:text="textField()"
@ok="handleOK"
@initComp="initComp"/>
<span style="display: inline-block;height:100%;padding-left:14px" v-if="departIds">
<span @click="openSelect" style="display: inline-block;vertical-align: middle">{{ departNames }}</span>
<a-icon v-if="!componentDisabled" style="margin-left:5px;vertical-align: middle" type="close-circle"
@click="handleEmpty" title="清空"/>
</span>
</div>
</template>
<script>
import JVxeCellMixins, {dispatchEvent} from '@/components/jeecg/JVxeTable/mixins/JVxeCellMixins'
import JSelectDepartModal from '@/components/jeecgbiz/modal/JSelectDepartModal'
export default {
name: 'JVxeDepartSelectCell',
mixins: [JVxeCellMixins],
components: {
JSelectDepartModal
},
data() {
return {
departNames: '',
departIds: '',
selectedOptions: [],
customReturnField: 'id'
}
},
computed: {
custProps() {
const {departIds, originColumn: col, caseId, cellProps} = this
return {
...cellProps,
value: departIds,
field: col.field || col.key,
groupId: caseId,
class: 'jvxe-select'
}
},
componentDisabled() {
if (this.cellProps.disabled == true) {
return true
}
return false
},
modalWidth() {
if (this.cellProps.modalWidth) {
return this.cellProps.modalWidth
} else {
return 500
}
},
multi() {
if (this.cellProps.multi == false || this.originColumn.multi === false) {
return false
} else {
return true
}
},
rootOpened() {
if (this.cellProps.open == false) {
return false
} else {
return true
}
}
},
watch: {
innerValue: {
immediate: true,
handler(val) {
if (val == null || val === '') {
this.departIds = ''
} else {
this.departIds = val
}
}
}
},
methods: {
openSelect() {
// disabled 不弹窗
if (this.componentDisabled) {
return
}
this.$refs.innerDepartSelectModal.show()
},
handleEmpty() {
this.handleOK('')
},
handleOK(rows) {
let value = ''
if (!rows && rows.length <= 0) {
this.departNames = ''
this.departIds = ''
} else {
let storeField = this.storeField();
let textField = this.textField();
value = rows.map(row => row[storeField]).join(',')
this.departNames = rows.map(row => row[textField]).join(',')
this.departIds = value
}
this.handleChangeCommon(this.departIds)
},
initComp(departNames) {
this.departNames = departNames
},
handleChange(value) {
this.handleChangeCommon(value)
},
storeField() {
if (this.originColumn) {
const str = this.originColumn.fieldExtendJson
if (str) {
let json = JSON.parse(str)
if (json && json.store) {
return json.store
}
} else if (this.originColumn.store) {
return this.originColumn.store
}
}
return 'id'
},
textField() {
if (this.originColumn) {
const str = this.originColumn.fieldExtendJson
if (str) {
let json = JSON.parse(str)
if (json && json.text) {
return json.text
}
} else if (this.originColumn.text) {
return this.originColumn.text
}
}
return 'departName'
}
},
enhanced: {
switches: {
visible: true
},
translate: {
enabled: false
}
}
}
</script>
<style scoped>
/deep/ .jvxe-select-input .ant-input {
border: none !important;
}
</style>