index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view class="assign-container">
  3. <u-popup :show="popShow" @close="close">
  4. <view class="select-container">
  5. <view class="title">
  6. <view class="btn-box">
  7. <text class="btn cancel" @tap="close">取消</text>
  8. <text class="btn confirm" @tap="submit">确定</text>
  9. </view>
  10. </view>
  11. <view class="select-wrapper">
  12. <view class="col deptInp">
  13. <text class="label">部门:</text>
  14. <input
  15. type="text"
  16. disabled
  17. :value="formData.deptVal"
  18. @tap="openPicker"
  19. placeholder="请选择"
  20. />
  21. </view>
  22. <view class="col userInp">
  23. <text class="label">接收人:</text>
  24. <uni-data-select
  25. :localdata="userList"
  26. @change="handleUserChange"
  27. v-model="formData.executorId"
  28. />
  29. </view>
  30. </view>
  31. </view>
  32. </u-popup>
  33. <ba-tree-picker
  34. ref="treePicker"
  35. :multiple="false"
  36. @select-change="confirm"
  37. title="选择部门"
  38. :localdata="listData"
  39. valueKey="code"
  40. textKey="name"
  41. childrenKey="children"
  42. />
  43. </view>
  44. </template>
  45. <script>
  46. import { post, get, postJ } from '@/utils/api.js'
  47. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  48. export default {
  49. components: {
  50. baTreePicker
  51. },
  52. data () {
  53. return {
  54. popShow: false,
  55. deptPickerShow: false,
  56. listData: [],
  57. userList: [],
  58. formData: {
  59. deptVal: '',
  60. executorName: '',
  61. executorId: ''
  62. }
  63. }
  64. },
  65. created () {
  66. this.getDept()
  67. },
  68. methods: {
  69. //工单id
  70. open (id) {
  71. this.popShow = true
  72. },
  73. openPicker () {
  74. this.$refs.treePicker._show()
  75. // this.deptPickerShow = true
  76. // console.log(1111);
  77. },
  78. handleUserChange (id) {
  79. console.log(id)
  80. const obj = this.userList.find(n => {
  81. return n.userId == id
  82. })
  83. this.formData.executorName = obj.trueName || ''
  84. },
  85. close () {
  86. this.formData = {
  87. deptVal: '',
  88. executorName: '',
  89. executorId: '',
  90. reassignExplain: ''
  91. }
  92. this.userList = []
  93. this.popShow = false
  94. },
  95. submit () {
  96. if (!this.formData.executorId) {
  97. uni.showToast({
  98. icon: 'error',
  99. title: '请选择接收人'
  100. })
  101. return
  102. }
  103. let currentUser = this.userList.find(n => {
  104. return n.userId == this.formData.executorId
  105. })
  106. this.$emit('submit', currentUser)
  107. },
  108. confirm (data, name) {
  109. this.formData.deptVal = name
  110. this.formData.executorName = ''
  111. this.formData.executorId = ''
  112. this.getUser(data[0])
  113. },
  114. getDept () {
  115. get(this.apiUrl + '/main/org/dept/effectiveTree').then(res => {
  116. if (res?.success) {
  117. this.listData = res.data
  118. }
  119. })
  120. },
  121. getUser (deptCode) {
  122. post(this.apiUrl + '/main/user/list', {
  123. deptCode,
  124. page: 1,
  125. size: 9999
  126. }).then(res => {
  127. if (res?.success) {
  128. this.userList = res.data.items.map(item => {
  129. item.text = item.trueName
  130. item.value = item.userId
  131. return item
  132. })
  133. }
  134. })
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .select-container {
  141. min-height: 60vh;
  142. .title {
  143. height: 70rpx;
  144. line-height: 70rpx;
  145. text-align: center;
  146. background-color: $j-primary-border-green;
  147. font-weight: bold;
  148. position: relative;
  149. font-size: 28rpx;
  150. color: #fff;
  151. .btn-box {
  152. position: absolute;
  153. top: 50%;
  154. right: 10rpx;
  155. transform: translateY(-50%);
  156. }
  157. .btn {
  158. width: 60rpx;
  159. height: 32rpx;
  160. display: inline-block;
  161. font-size: 28rpx;
  162. border: 1px solid #fff;
  163. text-align: center;
  164. line-height: 30rpx;
  165. }
  166. }
  167. .select-wrapper {
  168. .col {
  169. display: flex;
  170. // min-height: 0rpx;
  171. margin-top: 22rpx;
  172. align-items: center;
  173. padding-right: 14rpx;
  174. .label {
  175. display: inline-block;
  176. width: 200rpx;
  177. text-align: right;
  178. }
  179. input {
  180. flex: 1;
  181. border: 1rpx solid #e5e5e5;
  182. height: 66rpx;
  183. border-radius: 8rpx;
  184. font-size: 28rpx;
  185. padding: 8rpx 16rpx;
  186. box-sizing: border-box;
  187. color: #6a6a6a;
  188. }
  189. textarea {
  190. border: 1rpx solid #e5e5e5;
  191. flex: 1;
  192. height: 100rpx;
  193. }
  194. }
  195. }
  196. }
  197. </style>