Assign.vue 7.4 KB

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