Assign.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <view class="assign-container">
  3. <u-popup :show="popShow" @close="close">
  4. <view class="select-container">
  5. <view class="title">
  6. <text class="btn cancel" @tap="close">取消</text>
  7. 工单转派
  8. <text class="btn confirm" @tap="submit">确定</text>
  9. </view>
  10. <view class="select-wrapper">
  11. <view class="col deptInp">
  12. <text class="label">部门:</text>
  13. <input type="text" disabled :value="formData.executorDeptName" @tap="openPicker" placeholder="请选择" />
  14. </view>
  15. <view class="col userInp">
  16. <text class="label">接收人:</text>
  17. <!-- multiple -->
  18. <zxz-uni-data-select :localdata="userList" v-model="formData.executorId" @change="handleUserChange"></zxz-uni-data-select>
  19. </view>
  20. <view class="col userInp">
  21. <text class="label">转派原因:</text>
  22. <textarea v-model="formData.reassignExplain" cols="20" rows="5"></textarea>
  23. </view>
  24. </view>
  25. </view>
  26. </u-popup>
  27. <ba-tree-picker ref="treePicker" :multiple="false" @select-change="confirm" title="选择部门" :localdata="listData" valueKey="id" textKey="name" childrenKey="children" />
  28. </view>
  29. </template>
  30. <script>
  31. import { listOrganizations, getUserPage, workOrderRotate } from '@/api/myTicket/index.js'
  32. import { post, get, postJ } from '@/utils/api.js'
  33. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  34. export default {
  35. components: {
  36. baTreePicker
  37. },
  38. data() {
  39. return {
  40. popShow: false,
  41. deptPickerShow: false,
  42. listData: [],
  43. userList: [],
  44. formData: {
  45. executorDeptName: '',
  46. executorName: '',
  47. executorId: '',
  48. reassignExplain: '',
  49. workOrderId: ''
  50. },
  51. selectList: [],
  52. newArr: []
  53. }
  54. },
  55. created() {
  56. this.getDept()
  57. },
  58. methods: {
  59. //工单id
  60. open(id) {
  61. console.log(id)
  62. this.formData.workOrderId = id
  63. this.popShow = true
  64. },
  65. openPicker() {
  66. console.log('---------openPicker--------')
  67. this.$refs.treePicker._show()
  68. // this.deptPickerShow = true
  69. // console.log(1111);
  70. },
  71. deWeight(arr4) {
  72. var obj = {}
  73. arr4 = arr4.reduce(function (a, b) {
  74. obj[b.userId] ? '' : (obj[b.userId] = true && a.push(b))
  75. return a
  76. }, [])
  77. return arr4
  78. },
  79. handleUserChange(obj) {
  80. this.formData.executorName = obj.text
  81. // const obj = this.userList.find(i => i.value === id)
  82. // this.formData.executorName = (obj && obj.text) || ''
  83. },
  84. close() {
  85. this.formData = {
  86. executorDeptName: '',
  87. executorName: '',
  88. executorId: '',
  89. reassignExplain: '',
  90. workOrderId: ''
  91. }
  92. this.popShow = false
  93. },
  94. submit() {
  95. if (!this.formData.executorId) {
  96. uni.showToast({
  97. icon: 'error',
  98. title: '请选择接收人'
  99. })
  100. return
  101. }
  102. if (!this.formData.reassignExplain) {
  103. uni.showToast({
  104. icon: 'error',
  105. title: '请输入转派原因'
  106. })
  107. return
  108. }
  109. // let param = {
  110. // executorDeptName: this.formData.executorDeptName,
  111. // executorName: this.formData.executorName,
  112. // executorId: this.formData.executorId,
  113. // reassignExplain: this.formData.reassignExplain,
  114. // workOrderId: this.formData.workOrderId
  115. // }
  116. let param = {
  117. acceptUserId: this.formData.executorId,
  118. workOrderId: this.formData.workOrderId
  119. }
  120. console.log(param)
  121. workOrderRotate(param).then(() => {
  122. this.close()
  123. const _this = this
  124. uni.showModal({
  125. title: `此工单已转派成功`,
  126. content: '',
  127. confirmText: '确认',
  128. showCancel: false, // 是否显示取消按钮,默认为 true
  129. success: function (res) {
  130. if (res.confirm) {
  131. _this.$emit('success', _this.formData)
  132. }
  133. }
  134. })
  135. })
  136. // postJ(this.apiUrl + '/workOrder/anewSendOrders', [param]).then(res => {
  137. // if (res?.success) {
  138. // this.close()
  139. // const _this = this
  140. // uni.showModal({
  141. // title: `此工单已转派成功`,
  142. // content: '',
  143. // confirmText: '确认',
  144. // showCancel: false, // 是否显示取消按钮,默认为 true
  145. // success: function (res) {
  146. // if (res.confirm) {
  147. // _this.$emit('success', _this.formData)
  148. // }
  149. // }
  150. // })
  151. // // uni.showToast({
  152. // // icon: 'success',
  153. // // title: '转派成功!',
  154. // // mask: true
  155. // // })
  156. // // setTimeout(() => {
  157. // // }, 1500)
  158. // }
  159. // })
  160. },
  161. confirm(data, name) {
  162. console.log(data)
  163. console.log(name)
  164. this.formData.executorDeptName = name
  165. this.formData.executorDeptCode = data[0]
  166. this.formData.executorName = ''
  167. this.formData.executorId = ''
  168. this.getUser(data[0])
  169. },
  170. getDept() {
  171. listOrganizations(1).then(data => {
  172. console.log('listOrganizations-----------------------')
  173. console.log(data)
  174. this.listData = data
  175. })
  176. // get(this.apiUrl + '/main/org/dept/effectiveTree').then(res => {
  177. // if (res?.success) {
  178. // this.listData = res.data
  179. // }
  180. // })
  181. },
  182. getUser(deptCode) {
  183. getUserPage({ pageNum: 1, size: -1, groupId: deptCode }).then(data => {
  184. this.userList = data.list.map(item => {
  185. item.text = item.name
  186. item.value = item.id
  187. return item
  188. })
  189. })
  190. // post(this.apiUrl + '/main/user/list', {
  191. // deptCode,
  192. // page: 1,
  193. // size: 9999
  194. // }).then(res => {
  195. // if (res?.success) {
  196. // this.userList = res.data.items.map(item => {
  197. // item.text = item.trueName
  198. // item.value = item.userId
  199. // return item
  200. // })
  201. // }
  202. // })
  203. }
  204. }
  205. }
  206. </script>
  207. <style lang="scss" scoped>
  208. .select-container {
  209. min-height: 60vh;
  210. .title {
  211. display: flex;
  212. justify-content: space-between;
  213. align-items: center;
  214. height: 100rpx;
  215. line-height: 100rpx;
  216. text-align: center;
  217. background-color: $j-primary-border-green;
  218. font-weight: bold;
  219. position: relative;
  220. font-size: 32rpx;
  221. color: #fff;
  222. // .btn-box {
  223. // position: absolute;
  224. // top: 50%;
  225. // right: 10rpx;
  226. // transform: translateY(-50%);
  227. // }
  228. .btn {
  229. width: 80rpx;
  230. height: 32rpx;
  231. display: inline-block;
  232. font-size: 32rpx;
  233. border: 1px solid #fff;
  234. text-align: center;
  235. line-height: 30rpx;
  236. }
  237. }
  238. .select-wrapper {
  239. .col {
  240. display: flex;
  241. // min-height: 0rpx;
  242. margin-top: 22rpx;
  243. align-items: center;
  244. padding-right: 14rpx;
  245. .label {
  246. display: inline-block;
  247. width: 200rpx;
  248. text-align: right;
  249. }
  250. input {
  251. flex: 1;
  252. border: 1rpx solid #e5e5e5;
  253. height: 66rpx;
  254. border-radius: 8rpx;
  255. font-size: 28rpx;
  256. padding: 8rpx 16rpx;
  257. box-sizing: border-box;
  258. color: #6a6a6a;
  259. }
  260. textarea {
  261. border: 1rpx solid #e5e5e5;
  262. flex: 1;
  263. height: 100rpx;
  264. }
  265. .tab_box {
  266. display: flex;
  267. flex-direction: row;
  268. flex-wrap: wrap;
  269. width: 520rpx;
  270. .tab {
  271. display: flex;
  272. flex-direction: row;
  273. border: 2rpx solid #d9ecff;
  274. background-color: #f4f4f5;
  275. border-color: #e9e9eb;
  276. color: #909399;
  277. margin-left: 8rpx;
  278. margin-bottom: 8rpx;
  279. padding: 2rpx 8rpx;
  280. font-size: 28rpx;
  281. }
  282. .icon {
  283. margin-left: 6rpx;
  284. }
  285. }
  286. }
  287. }
  288. }
  289. </style>