warning.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <view class="warning-handle-page">
  3. <uni-forms ref="form" :modelValue="formData" :rules="rules" :label-width="300" label-position="top">
  4. <uni-forms-item label="处理动作" required >
  5. <div class="uni-data-checkbox-wrap">
  6. <view class="action":class="action===1?'active':''" @click="changeAction(1)">
  7. <text>完成处理</text>
  8. </view>
  9. <view class="action":class="action===2?'active':''" @click="changeAction(2)">
  10. <text>转交</text>
  11. </view>
  12. </div>
  13. </uni-forms-item>
  14. <uni-forms-item v-if="handleRemarkVisible" label="原因分析" prop="actionRemark">
  15. <uni-easyinput v-model="formData.warnReason" type="textarea" :maxlength="-1" autoHeight placeholder="原因分析" />
  16. </uni-forms-item>
  17. <uni-forms-item v-if="handleRemarkVisible" label="处理措施" prop="actionRemark">
  18. <uni-easyinput v-model="formData.handleMeasure" type="textarea" :maxlength="-1" autoHeight placeholder="处理说明" />
  19. </uni-forms-item>
  20. <uni-forms-item v-if="handlerVisible" label="执行人" prop="accountIdTo">
  21. <uni-data-select v-model="formData.accountId" :localdata="userList"></uni-data-select>
  22. </uni-forms-item>
  23. <uni-forms-item v-if="handlerVisible" label="备注" prop="remark">
  24. <uni-easyinput v-model="transferData.remark" type="textarea" :maxlength="-1" autoHeight placeholder="请输入备注" />
  25. </uni-forms-item>
  26. <uni-file-picker v-model="formData.attachList"
  27. fileMediatype="image"
  28. title="请上传附件"
  29. limit="1"
  30. @select="uploadSuccess"
  31. @delete="deleteFile">
  32. </uni-file-picker>
  33. <view class="btn-group">
  34. <uni-button type="primary" @click="handleSubmit">提交</uni-button>
  35. </view>
  36. </uni-forms>
  37. </view>
  38. </template>
  39. <script>
  40. import {getUserList} from '@/api/system/user.js'
  41. import { getWarningById, completeWarning, transferWarning } from '@/api/aqpt/warningApi'
  42. export default {
  43. data() {
  44. return {
  45. formData:{
  46. warnId: undefined,
  47. attachList: []
  48. },
  49. transferData:{
  50. },
  51. viewData:{},
  52. rules:{},
  53. userList:[],
  54. action:1,
  55. warnId:undefined,
  56. handleRemarkVisible:false,
  57. handlerVisible:false
  58. }
  59. },
  60. created() {
  61. this.changeAction(1)
  62. this.getUserList()
  63. },
  64. onLoad({id}) {
  65. this.warnId=id
  66. this.getData()
  67. },
  68. methods: {
  69. // Fetch Data
  70. getData() {
  71. const warnId = this.warnId
  72. getWarningById(warnId).then((resp) => {
  73. const { data } = resp
  74. this.viewData = data
  75. })
  76. },
  77. changeAction(iMode){
  78. this.action=iMode;
  79. if (iMode === 1) {
  80. this.handleRemarkVisible = true
  81. this.handlerVisible = false
  82. } else if (iMode === 2) {
  83. this.handleRemarkVisible = false
  84. this.handlerVisible = true
  85. }
  86. },
  87. getUserList(){
  88. getUserList().then((res)=>{
  89. var userList=[]
  90. for (var i = 0; i < res.data.length; i++) {
  91. userList.push({
  92. value: -i,
  93. text: res.data[i].name,
  94. disable:true
  95. })
  96. for(let j = 0; j < res.data[i].children.length; j++){
  97. userList.push({
  98. ...res.data[i].children[j],
  99. value: res.data[i].children[j].accountId,
  100. text: res.data[i].children[j].accountName
  101. })
  102. }
  103. }
  104. this.userList=userList
  105. })
  106. },
  107. // 提交
  108. handleSubmit() {
  109. const action = this.action
  110. if (action === 1) {
  111. completeWarning(this.formData).then((resp) => {
  112. const { msg } = resp
  113. uni.showToast({
  114. icon:"none",
  115. title:msg||'处理成功!'
  116. })
  117. setTimeout(()=>{
  118. uni.navigateBack()
  119. },1000)
  120. })
  121. } else {
  122. let user=this.userList.filter(item=>this.formData.accountId===item.accountId)[0]
  123. this.handleSelectUser(user)
  124. transferWarning(this.warnId, this.transferData).then((resp) => {
  125. const { msg } = resp
  126. uni.showToast({
  127. icon:"none",
  128. title:msg||'处理成功!'
  129. })
  130. setTimeout(()=>{
  131. uni.navigateBack()
  132. },1000)
  133. })
  134. }
  135. },
  136. handleSelectUser(obj) {
  137. this.transferData.accountIdTo = obj.accountId
  138. this.transferData.groupIdTo = obj.groupId
  139. this.transferData.positionIdTo = obj.positionId
  140. this.transferData.accountNameTo = obj.accountName
  141. this.transferData.groupNameTo = obj.groupName
  142. this.transferData.positionNameTo = obj.positionName
  143. },
  144. }
  145. }
  146. </script>
  147. <style lang="scss" scoped>
  148. .warning-handle-page{
  149. padding: 32rpx;
  150. ::v-deep .uni-forms-item{
  151. .uni-forms-item__content{
  152. .uni-data-checkbox-wrap{
  153. height: 100%;
  154. display: flex;
  155. align-items: center;
  156. .action{
  157. padding: 22rpx 32rpx;
  158. background-color: #fff;
  159. border-radius: 2px;
  160. margin-right: 20rpx;
  161. font-size: 28rpx;
  162. line-height: 1;
  163. &.active{
  164. background: rgba(77, 115, 255, 0.16);
  165. color: #4D73FF;
  166. }
  167. }
  168. }
  169. }
  170. }
  171. .btn-group{
  172. margin-top: 100rpx;
  173. }
  174. }
  175. </style>