56b2120d4a405f332fb6d2deadf6dccfdcda5b05.svn-base 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div>
  3. <a-input
  4. v-show="!departIds"
  5. @click="openSelect"
  6. placeholder="请点击选择部门"
  7. v-model="departNames"
  8. readOnly
  9. :disabled="componentDisabled"
  10. class="jvxe-select-input">
  11. <a-icon slot="prefix" type="cluster" title="部门选择控件"/>
  12. </a-input>
  13. <j-select-depart-modal
  14. ref="innerDepartSelectModal"
  15. :modal-width="modalWidth"
  16. :multi="multi"
  17. :rootOpened="rootOpened"
  18. :depart-id="departIds"
  19. @ok="handleOK"
  20. @initComp="initComp"/>
  21. <span style="display: inline-block;height:100%;padding-left:14px" v-if="departIds" >
  22. <span @click="openSelect" style="display: inline-block;vertical-align: middle">{{ departNames }}</span>
  23. <a-icon style="margin-left:5px;vertical-align: middle" type="close-circle" @click="handleEmpty" title="清空"/>
  24. </span>
  25. </div>
  26. </template>
  27. <script>
  28. import JVxeCellMixins, { dispatchEvent } from '@/components/jeecg/JVxeTable/mixins/JVxeCellMixins'
  29. import JSelectDepartModal from '@/components/jeecgbiz/modal/JSelectDepartModal'
  30. export default {
  31. name: 'JVxeDepartSelectCell',
  32. mixins: [JVxeCellMixins],
  33. components:{
  34. JSelectDepartModal
  35. },
  36. data() {
  37. return {
  38. departNames: '',
  39. departIds: '',
  40. selectedOptions: [],
  41. customReturnField: 'id'
  42. }
  43. },
  44. computed: {
  45. custProps() {
  46. const {departIds, originColumn: col, caseId, cellProps} = this
  47. return {
  48. ...cellProps,
  49. value: departIds,
  50. field: col.field || col.key,
  51. groupId: caseId,
  52. class: 'jvxe-select'
  53. }
  54. },
  55. componentDisabled(){
  56. if(this.cellProps.disabled==true){
  57. return true
  58. }
  59. return false
  60. },
  61. modalWidth(){
  62. if(this.cellProps.modalWidth){
  63. return this.cellProps.modalWidth
  64. }else{
  65. return 500
  66. }
  67. },
  68. multi(){
  69. if(this.cellProps.multi==false){
  70. return false
  71. }else{
  72. return true
  73. }
  74. },
  75. rootOpened(){
  76. if(this.cellProps.open==false){
  77. return false
  78. }else{
  79. return true
  80. }
  81. }
  82. },
  83. watch: {
  84. innerValue: {
  85. immediate: true,
  86. handler(val) {
  87. if (val == null || val === '') {
  88. this.departIds = ''
  89. } else {
  90. this.departIds = val
  91. }
  92. }
  93. }
  94. },
  95. methods: {
  96. openSelect(){
  97. this.$refs.innerDepartSelectModal.show()
  98. },
  99. handleEmpty(){
  100. this.handleOK('')
  101. },
  102. handleOK(rows, idstr) {
  103. let value = ''
  104. if (!rows && rows.length <= 0) {
  105. this.departNames = ''
  106. this.departIds = ''
  107. } else {
  108. value = rows.map(row => row[this.customReturnField]).join(',')
  109. this.departNames = rows.map(row => row['departName']).join(',')
  110. this.departIds = idstr
  111. }
  112. this.handleChangeCommon(this.departIds)
  113. },
  114. initComp(departNames){
  115. this.departNames = departNames
  116. },
  117. handleChange(value) {
  118. this.handleChangeCommon(value)
  119. }
  120. },
  121. enhanced: {
  122. switches: {
  123. visible: true
  124. },
  125. translate: {
  126. enabled: false
  127. }
  128. }
  129. }
  130. </script>
  131. <style scoped>
  132. /deep/ .jvxe-select-input .ant-input{
  133. border: none !important;
  134. }
  135. </style>