Assign.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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. console.log('---------openPicker--------')
  68. this.$refs.treePicker._show()
  69. // this.deptPickerShow = true
  70. // console.log(1111);
  71. },
  72. deWeight(arr4) {
  73. var obj = {}
  74. arr4 = arr4.reduce(function (a, b) {
  75. obj[b.userId] ? '' : (obj[b.userId] = true && a.push(b))
  76. return a
  77. }, [])
  78. return arr4
  79. },
  80. handleUserChange(obj) {
  81. this.formData.executorName = obj.text
  82. // const obj = this.userList.find(i => i.value === id)
  83. // this.formData.executorName = (obj && obj.text) || ''
  84. },
  85. close() {
  86. this.formData = {
  87. executorDeptName: '',
  88. executorName: '',
  89. executorId: '',
  90. reassignExplain: '',
  91. workOrderId: ''
  92. }
  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. if (!this.formData.reassignExplain) {
  104. uni.showToast({
  105. icon: 'error',
  106. title: '请输入转派原因'
  107. })
  108. return
  109. }
  110. // let param = {
  111. // executorDeptName: this.formData.executorDeptName,
  112. // executorName: this.formData.executorName,
  113. // executorId: this.formData.executorId,
  114. // reassignExplain: this.formData.reassignExplain,
  115. // workOrderId: this.formData.workOrderId
  116. // }
  117. let param = {
  118. acceptUserId: this.formData.executorId,
  119. workOrderId: this.formData.workOrderId
  120. }
  121. console.log(param)
  122. workOrderRotate(param).then(() => {
  123. this.close()
  124. const _this = this
  125. uni.showModal({
  126. title: `此工单已转派成功`,
  127. content: '',
  128. confirmText: '确认',
  129. showCancel: false, // 是否显示取消按钮,默认为 true
  130. success: function (res) {
  131. if (res.confirm) {
  132. _this.$emit('success', _this.formData)
  133. }
  134. }
  135. })
  136. })
  137. // postJ(this.apiUrl + '/workOrder/anewSendOrders', [param]).then(res => {
  138. // if (res?.success) {
  139. // this.close()
  140. // const _this = this
  141. // uni.showModal({
  142. // title: `此工单已转派成功`,
  143. // content: '',
  144. // confirmText: '确认',
  145. // showCancel: false, // 是否显示取消按钮,默认为 true
  146. // success: function (res) {
  147. // if (res.confirm) {
  148. // _this.$emit('success', _this.formData)
  149. // }
  150. // }
  151. // })
  152. // // uni.showToast({
  153. // // icon: 'success',
  154. // // title: '转派成功!',
  155. // // mask: true
  156. // // })
  157. // // setTimeout(() => {
  158. // // }, 1500)
  159. // }
  160. // })
  161. },
  162. confirm(data, name) {
  163. console.log(data)
  164. console.log(name)
  165. this.formData.executorDeptName = name
  166. this.formData.executorDeptCode = data[0]
  167. this.formData.executorName = ''
  168. this.formData.executorId = ''
  169. this.getUser(data[0])
  170. },
  171. getDept() {
  172. listOrganizations(1).then(data => {
  173. console.log('listOrganizations-----------------------')
  174. console.log(data)
  175. this.listData = data
  176. })
  177. // get(this.apiUrl + '/main/org/dept/effectiveTree').then(res => {
  178. // if (res?.success) {
  179. // this.listData = res.data
  180. // }
  181. // })
  182. },
  183. getUser(deptCode) {
  184. getUserPage({ pageNum: 1, size: -1, groupId: deptCode }).then(data => {
  185. this.userList = data.list.map(item => {
  186. item.text = item.name
  187. item.value = item.id
  188. return item
  189. })
  190. })
  191. // post(this.apiUrl + '/main/user/list', {
  192. // deptCode,
  193. // page: 1,
  194. // size: 9999
  195. // }).then(res => {
  196. // if (res?.success) {
  197. // this.userList = res.data.items.map(item => {
  198. // item.text = item.trueName
  199. // item.value = item.userId
  200. // return item
  201. // })
  202. // }
  203. // })
  204. }
  205. }
  206. }
  207. </script>
  208. <style lang="scss" scoped>
  209. .select-container {
  210. min-height: 60vh;
  211. .title {
  212. display: flex;
  213. justify-content: space-between;
  214. align-items: center;
  215. height: 100rpx;
  216. line-height: 100rpx;
  217. text-align: center;
  218. background-color: $j-primary-border-green;
  219. font-weight: bold;
  220. position: relative;
  221. font-size: 32rpx;
  222. color: #fff;
  223. // .btn-box {
  224. // position: absolute;
  225. // top: 50%;
  226. // right: 10rpx;
  227. // transform: translateY(-50%);
  228. // }
  229. .btn {
  230. width: 80rpx;
  231. height: 32rpx;
  232. display: inline-block;
  233. font-size: 32rpx;
  234. border: 1px solid #fff;
  235. text-align: center;
  236. line-height: 30rpx;
  237. }
  238. }
  239. .select-wrapper {
  240. .col {
  241. display: flex;
  242. // min-height: 0rpx;
  243. margin-top: 22rpx;
  244. align-items: center;
  245. padding-right: 14rpx;
  246. .label {
  247. display: inline-block;
  248. width: 200rpx;
  249. text-align: right;
  250. }
  251. .input_text {
  252. flex: 1;
  253. height: 66rpx;
  254. line-height: 66rpx;
  255. padding: 0rpx 16rpx;
  256. box-sizing: border-box;
  257. font-size: 28rpx;
  258. border: 1px solid #eceeec;
  259. border-radius: 8rpx;
  260. }
  261. input {
  262. flex: 1;
  263. border: 1rpx solid #e5e5e5;
  264. height: 66rpx;
  265. border-radius: 8rpx;
  266. font-size: 28rpx;
  267. padding: 0rpx 16rpx;
  268. color: #6a6a6a;
  269. }
  270. textarea {
  271. border: 1rpx solid #e5e5e5;
  272. flex: 1;
  273. height: 100rpx;
  274. }
  275. .tab_box {
  276. display: flex;
  277. flex-direction: row;
  278. flex-wrap: wrap;
  279. width: 520rpx;
  280. .tab {
  281. display: flex;
  282. flex-direction: row;
  283. border: 2rpx solid #d9ecff;
  284. background-color: #f4f4f5;
  285. border-color: #e9e9eb;
  286. color: #909399;
  287. margin-left: 8rpx;
  288. margin-bottom: 8rpx;
  289. padding: 2rpx 8rpx;
  290. font-size: 28rpx;
  291. }
  292. .icon {
  293. margin-left: 6rpx;
  294. }
  295. }
  296. }
  297. }
  298. }
  299. </style>