Assign.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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">
  12. <text class="label">类型:</text>
  13. <!-- multiple -->
  14. <zxz-uni-data-select :localdata="[{text:'执行人',value:'0'},{text:'班组',value:'1'}]"
  15. v-model="Usertype" @change="changeUserType"></zxz-uni-data-select>
  16. </view>
  17. <!-- fromValue Transfer -->
  18. <view class="col deptInp" v-if="Usertype=='0'">
  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" v-if="Usertype=='0'">
  25. <text class="label">接收人:</text>
  26. <!-- multiple -->
  27. <zxz-uni-data-select :localdata="userList" v-model="formData.executorId"
  28. @change="handleUserChange" :multiple="true"></zxz-uni-data-select>
  29. </view>
  30. <view class="col userInp" v-if="Usertype=='1'">
  31. <text class="label">班组:</text>
  32. <!-- multiple -->
  33. <zxz-uni-data-select :localdata="teamAllList" v-model="formData.teamId"
  34. @change="handleTeamId"></zxz-uni-data-select>
  35. </view>
  36. </view>
  37. </view>
  38. </u-popup>
  39. <ba-tree-picker ref="treePicker" :multiple="false" @select-change="confirm" title="选择部门" :localdata="listData"
  40. valueKey="id" textKey="name" childrenKey="children" />
  41. </view>
  42. </template>
  43. <script>
  44. import {
  45. listOrganizations,
  46. getUserPage,
  47. } from '@/api/myTicket/index.js'
  48. import {
  49. getTeamPage
  50. } from '@/api/pda/workOrderHandover.js'
  51. import {
  52. recordrulesplanReManualDispatchOrder,
  53. } from "@/api/recordRules/index";
  54. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  55. export default {
  56. components: {
  57. baTreePicker
  58. },
  59. data() {
  60. return {
  61. popShow: false,
  62. deptPickerShow: false,
  63. listData: [],
  64. userList: [],
  65. formData: {
  66. executorDeptName: '',
  67. executorName: '',
  68. executorId: '',
  69. reassignExplain: '',
  70. workOrderId: '',
  71. teamId: ''
  72. },
  73. selectList: [],
  74. teamAllList: [],
  75. Usertype: '0',
  76. }
  77. },
  78. created() {
  79. this.getDept()
  80. this.getAllTeamList()
  81. },
  82. methods: {
  83. async getAllTeamList() {
  84. const {
  85. list
  86. } = await getTeamPage({
  87. pageNum: 1,
  88. size: -1
  89. });
  90. this.teamAllList = list.map(item => {
  91. item.text = item.name
  92. item.value = item.id
  93. return item
  94. });
  95. },
  96. //工单id
  97. open(row) {
  98. this.formData.workOrderId = row.id
  99. this.popShow = true
  100. },
  101. openPicker() {
  102. this.$refs.treePicker._show()
  103. },
  104. changeUserType() {
  105. this.formData.executorId = ''
  106. this.executeUsers = []
  107. },
  108. handleUserChange(obj) {
  109. this.executeUsers = obj
  110. },
  111. close() {
  112. this.formData = {
  113. executorDeptName: '',
  114. executorId: '',
  115. teamId: '',
  116. workOrderId: ''
  117. }
  118. this.executeUsers = []
  119. this.popShow = false
  120. },
  121. handleTeamId(data) {
  122. this.formData.teamId = data.id
  123. this.formData.teamName = data.name
  124. },
  125. submit() {
  126. if (this.Usertype == '0' && this.formData.executorId.length == 0) {
  127. uni.showToast({
  128. icon: 'error',
  129. title: '请选择转派人员'
  130. })
  131. return
  132. }
  133. if (this.Usertype == '1' && !this.formData.teamId) {
  134. uni.showToast({
  135. icon: 'error',
  136. title: '请选择班组'
  137. })
  138. return
  139. }
  140. let executeUsers = null;
  141. if (this.Usertype == '0') {
  142. executeUsers = this.executeUsers.map((i) => {
  143. return {
  144. groupId: i.groupId,
  145. groupName: i.groupName,
  146. userId: i.id,
  147. userName: i.name
  148. };
  149. });
  150. }
  151. this.btnLoading = true;
  152. let params = {
  153. executeUsers,
  154. teamName: this.formData.teamName,
  155. teamId: this.formData.teamId,
  156. id: this.formData.workOrderId,
  157. type: this.Usertype
  158. };
  159. // 0个人 1班组
  160. if (this.Usertype == 1) {
  161. params = {
  162. executeUsers: [],
  163. teamName: this.formData.teamName,
  164. teamId: this.formData.teamId,
  165. id: this.formData.workOrderId,
  166. type: this.Usertype
  167. };
  168. } else {
  169. params = {
  170. executeUsers,
  171. teamName: '',
  172. teamId: '',
  173. id: this.formData.workOrderId,
  174. type: this.Usertype
  175. };
  176. }
  177. // if (this.Usertype == 1) {
  178. recordrulesplanReManualDispatchOrder(params).then(() => {
  179. this.$emit("refresh");
  180. this.close()
  181. })
  182. },
  183. confirm(data, name) {
  184. console.log(data)
  185. console.log(name)
  186. this.formData.executorDeptName = name
  187. this.formData.executorDeptCode = data[0]
  188. this.formData.executorName = ''
  189. this.formData.executorId = ''
  190. this.getUser(data[0])
  191. },
  192. getDept() {
  193. listOrganizations(1).then(data => {
  194. this.listData = data
  195. })
  196. },
  197. getUser(deptCode) {
  198. getUserPage({
  199. pageNum: 1,
  200. size: -1,
  201. groupId: deptCode
  202. }).then(data => {
  203. this.userList = data.list.map(item => {
  204. item.text = item.name
  205. item.value = item.id
  206. return item
  207. })
  208. })
  209. }
  210. }
  211. }
  212. </script>
  213. <style lang="scss" scoped>
  214. .select-container {
  215. min-height: 60vh;
  216. .title {
  217. display: flex;
  218. justify-content: space-between;
  219. align-items: center;
  220. height: 100rpx;
  221. line-height: 100rpx;
  222. text-align: center;
  223. background-color: $j-primary-border-green;
  224. font-weight: bold;
  225. padding: 0 20rpx;
  226. position: relative;
  227. font-size: 32rpx;
  228. color: #fff;
  229. .btn {
  230. padding: 10rpx 20rpx;
  231. display: inline-block;
  232. font-size: 32rpx;
  233. border: 1px solid #fff;
  234. text-align: center;
  235. line-height: 30rpx;
  236. margin: 0;
  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>