office-user-select.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <view style="width: 100%;" @tap="open">
  3. <u--input v-model="labels" suffixIcon="arrow-right" suffixIconStyle="color: #17a2f8" disabled
  4. disabledColor="#ffffff" :placeholder="placeholder" border="none"></u--input>
  5. <u-action-sheet :show="show" @close="show = false">
  6. <view class="cu-bar bg-white">
  7. <view class="action text-blue" @tap="show=false">取消</view>
  8. <view>{{title}}</view>
  9. <view class="action text-green" @tap="selectUser">确定</view>
  10. </view>
  11. <view class="allsrc">
  12. <scroll-view scroll-y class="src1">
  13. <view v-for="item in tab1" class="tab1" @click="tab1click(item)">
  14. <text :class="item.id==index1?'tab1_seltext':'tab1_text '"
  15. class="tab1_text">{{ item.name }}</text>
  16. <u-badge :absolute="true" :offset="[0,0]" type="primary" :value="getSelect(item.id)"></u-badge>
  17. </view>
  18. </scroll-view>
  19. <scroll-view scroll-y class="src2">
  20. <view class="tab2">
  21. <view class="tab2_text" v-for="item in tab2" @click="tab1click2(item)"
  22. :class="item.check?'current':''">
  23. {{item.name}}
  24. </view>
  25. </view>
  26. </scroll-view>
  27. </view>
  28. </u-action-sheet>
  29. </view>
  30. </template>
  31. <script>
  32. import officeService from "@/api/sys/officeService"
  33. import userService from "@/api/sys/userService"
  34. export default {
  35. data() {
  36. return {
  37. index1: "",
  38. tab1: [],
  39. tab2: [],
  40. labels: '',
  41. show: false,
  42. data: [],
  43. selectList: [],
  44. userList: [],
  45. }
  46. },
  47. props: {
  48. limit: Number,
  49. value: String,
  50. size: String,
  51. placeholder: String,
  52. title: String,
  53. readonly: {
  54. type: Boolean,
  55. default: () => {
  56. return false
  57. }
  58. },
  59. checkOnlyLeaf: {
  60. type: Boolean,
  61. default: () => {
  62. return false
  63. }
  64. },
  65. showRadio: {
  66. type: Boolean,
  67. default: () => {
  68. return true
  69. }
  70. },
  71. showCheckBox: {
  72. type: Boolean,
  73. default: () => {
  74. return false
  75. }
  76. },
  77. disabled: {
  78. type: Boolean,
  79. default: () => {
  80. return false
  81. }
  82. },
  83. props: {
  84. type: Object,
  85. default: () => {
  86. return {
  87. children: 'children',
  88. label: 'name'
  89. }
  90. }
  91. }
  92. },
  93. mounted() {
  94. officeService.treeData({
  95. parentId:"1770354728635834369"
  96. }).then((data) => {
  97. data = data.filter(item => item.type == '3')
  98. this.tab1 = data
  99. this.index1 = data[0].id
  100. userService.officeList().then(res => {
  101. this.userList = res
  102. this.userList = this.userList.map(item => ({
  103. ...item,
  104. check: false
  105. }));
  106. this.tab1click(this.tab1[0])
  107. })
  108. })
  109. },
  110. methods: {
  111. open() {
  112. this.show = true;
  113. if (this.value) {
  114. let u = this.value.split(",")
  115. this.$nextTick(() => {
  116. for (let i = 0; i < this.userList.length; i++) {
  117. let b = u.filter(t => t==this.userList[i].id)
  118. if(b.length>0) {
  119. this.$set(this.userList[i], "check", true);
  120. this.selectList.push(this.userList[i])
  121. }
  122. }
  123. })
  124. }
  125. },
  126. selectUser() {
  127. let ids = this.selectList.map((item) => {
  128. return item.loginName
  129. }).join(",");
  130. let names = this.selectList.map((item) => {
  131. return item.name
  132. }).join(",");
  133. this.labels = names
  134. this.$emit('input', ids)
  135. this.show = false
  136. },
  137. tab1click(e) {
  138. this.index1 = e.id;
  139. this.tab2 = this.userList.filter(item => item.officeDTO.id == e.id)
  140. },
  141. tab1click2(item) {
  142. item.check = !item.check
  143. if (item.check) {
  144. this.selectList.push(item)
  145. } else {
  146. this.selectList = this.selectList.filter(e => item.id != e.id)
  147. }
  148. },
  149. getSelect(id) {
  150. let s = this.selectList.filter(item => item.officeDTO.id == id)
  151. return s.length
  152. }
  153. }
  154. }
  155. </script>
  156. <style>
  157. .allsrc {
  158. display: flex;
  159. height: 60vh;
  160. }
  161. .src1 {
  162. flex: 1;
  163. background: #f5f5f5;
  164. }
  165. .tab1 {
  166. height: 80rpx;
  167. color: black;
  168. text-align: center;
  169. justify-content: center;
  170. align-items: center;
  171. display: flex;
  172. position: relative;
  173. }
  174. .tab1_seltext {
  175. background: #fff;
  176. padding: 16rpx 40rpx;
  177. width: 100%;
  178. }
  179. .src2 {
  180. flex: 2;
  181. background: #fff;
  182. margin-left: 3rpx;
  183. margin-right: 3rpx;
  184. height: 100%;
  185. }
  186. .tab2 .u-button {
  187. width: 40% !important;
  188. float: left;
  189. margin: 20rpx;
  190. }
  191. .describle {
  192. text-align: center;
  193. font-size: 22rpx;
  194. color: #5ac775;
  195. height: 40px;
  196. line-height: 40px;
  197. }
  198. .tab2_text {
  199. height: 40px;
  200. font-size: 14px;
  201. line-height: 40px;
  202. }
  203. .tab2 .current {
  204. color: #36a7f3;
  205. }
  206. </style>