transferCheckTask.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <view class="wrap">
  3. <uni-section :title="title" type="line">
  4. <uni-forms ref="form" :modelValue="formData" :rules="rules" :label-width="300" label-position="top">
  5. <uni-forms-item label="执行人" name="accountId" required>
  6. <uni-data-select v-model="accountId" :localdata="userList"></uni-data-select>
  7. </uni-forms-item>
  8. <uni-forms-item label="备注" name="remark">
  9. <uni-easyinput v-model="formData.taskDesc" type="textarea" :maxlength="-1" autoHeight placeholder="备注" />
  10. </uni-forms-item>
  11. </uni-forms>
  12. </uni-section>
  13. <button type="primary" @click="onSubmit" class="submit-BT">提交</button>
  14. </view>
  15. </template>
  16. <script>
  17. import {transferCheckTask} from '@/api/aqpt/task.js'
  18. import {getUserList,} from '@/api/system/user.js'
  19. export default {
  20. data() {
  21. return {
  22. userList:[],
  23. accountId:undefined,
  24. formData:{
  25. taskId: undefined,
  26. groupIdTo: undefined,
  27. positionIdTo: undefined,
  28. accountIdTo: undefined, // 执行人
  29. groupNameTo: undefined,
  30. positionNameTo: undefined,
  31. accountNameTo: undefined,
  32. taskDesc:""
  33. },
  34. rules:{},
  35. title:"任务转交"
  36. }
  37. },
  38. onBackPress() {
  39. },
  40. onLoad({tid,title}) {
  41. this.formData.taskId=tid;
  42. this.title=title;
  43. this.getUserList()
  44. },
  45. methods: {
  46. getUserList(){
  47. getUserList().then((res)=>{
  48. var userList=[]
  49. for (var i = 0; i < res.data.length; i++) {
  50. userList.push({
  51. value: -i,
  52. text: res.data[i].name,
  53. disable:true
  54. })
  55. for(let j = 0; j < res.data[i].children.length; j++){
  56. userList.push({
  57. ...res.data[i].children[j],
  58. value: res.data[i].children[j].accountId,
  59. text: res.data[i].children[j].accountName
  60. })
  61. }
  62. }
  63. this.userList=userList
  64. })
  65. },
  66. async onSubmit() {
  67. let user=this.userList.filter(item=>this.accountId===item.accountId)[0]
  68. this.handleUser(user)
  69. if(!this.accountId){
  70. uni.showToast({
  71. icon:'none',
  72. title:"请选择转交人员"
  73. })
  74. return
  75. }
  76. await transferCheckTask(this.formData).then(()=>{
  77. uni.showToast({
  78. icon:'none',
  79. title:"转交成功!",
  80. complete() {
  81. uni.switchTab({
  82. url:'/pages/index/index'
  83. })
  84. }
  85. })
  86. })
  87. .catch(()=>{
  88. uni.showToast({
  89. icon:'none',
  90. title:"提交失败!"
  91. })
  92. })
  93. },
  94. handleUser(user){
  95. this.formData.groupIdTo=user.groupId,
  96. this.formData.positionIdTo=user.positionId
  97. this.formData.accountIdTo=user.accountId
  98. this.formData.groupNameTo=user.groupName
  99. this.formData.positionNameTo=user.positionName
  100. this.formData.accountNameTo=user.accountName
  101. }
  102. }
  103. }
  104. </script>
  105. <style lang="scss" scoped>
  106. .wrap{
  107. padding: 20rpx;
  108. .submit-BT {
  109. width: 750rpx;
  110. color: #4D73FF;
  111. text-align: center;
  112. font-size: 32rpx;
  113. padding-bottom: 68rpx;
  114. background-color: #fff;
  115. position: fixed;
  116. left: 0;
  117. bottom: 0;
  118. z-index: 99;
  119. box-shadow: 0px 0px 12px 0px #0000000A;
  120. border-radius: 8px 8px 0px 0px
  121. }
  122. ::v-deep .uni-forms-item{
  123. .uni-forms-item__content{
  124. .uni-data-checkbox-wrap{
  125. height: 100%;
  126. display: flex;
  127. align-items: center;
  128. }
  129. }
  130. }
  131. }
  132. </style>