0e1a6e6fda09d38a50a2222cc57c22661cca85c0.svn-base 3.3 KB

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