Assign.vue 8.5 KB

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