form.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <div class="body">
  3. <uni-forms ref="form" label-position="top" :model="formData">
  4. <uni-forms-item label="处理动作" name="actionId" required>
  5. <uni-data-checkbox v-model="flowData.actionId" :localdata="actionList" @change="changeCheck"/>
  6. </uni-forms-item>
  7. <uni-forms-item label="处理说明" name="rectifyRemark" required>
  8. <uni-easyinput type="textarea" autoHeight v-model="formData.rectifyRemark" placeholder="请输入描述"></uni-easyinput>
  9. </uni-forms-item>
  10. <uni-forms-item label="验收人" name="acceptAccountId" required>
  11. <uni-data-select
  12. v-model="formData.acceptAccountId"
  13. :localdata="userList"
  14. ></uni-data-select>
  15. </uni-forms-item>
  16. <uni-forms-item label="附件">
  17. <div class="upload-container">
  18. <image @click="upload" class="upload" src="/static/icon/upload.png" mode="widthFix"></image>
  19. <p class="tip">注:单个附件上传不超过10M,附件累计不超过20M</p>
  20. </div>
  21. <view class="preview" v-if="formData.attachList.length>0">
  22. <image class="preview-item" :src="attach.fileUrl" mode="widthFix" v-for="(attach,index) in formData.attachList" :key="index"></image>
  23. </view>
  24. </uni-forms-item>
  25. </uni-forms>
  26. <view class="footer" @click="onSubmit">提交</view>
  27. </div>
  28. </template>
  29. <script>
  30. import {getUserByPage} from '@/api/user.js'
  31. import {upload} from '@/api/index.js'
  32. import { startWorkflow, getWorkflowById, handleWorkflow } from '@/api/system/wfApi'
  33. import { updateDanger, getDangerById } from '@/api/dangerApi'
  34. import {parseTime} from '@/libs'
  35. export default {
  36. data() {
  37. return {
  38. formData:{
  39. 'hdangerId': undefined,
  40. 'formCode': 'submit',
  41. 'hdangerTitle': '', // 预警标题
  42. 'dangerCatId': undefined, // 预警类别ID
  43. 'hdangerLevel': 1, // 预警等级
  44. 'rectifyRemark': '', // 描述
  45. 'submitTime': parseTime(new Date()),
  46. 'dangerDeadline': '', // 截止时间
  47. 'goafId': undefined,
  48. 'checklistId': '',
  49. "attachList":[]
  50. },
  51. flowData:{
  52. },
  53. actionList:[],
  54. userList:[]
  55. }
  56. },
  57. created() {
  58. this.init()
  59. },
  60. methods: {
  61. // 获取流程
  62. get(wfInsId) {
  63. // this.resetFormData()
  64. getWorkflowById(wfInsId).then((resp) => {
  65. const { code, data, msg } = resp
  66. if (code === 0) {
  67. this.flowData = data
  68. this.flowData.wfDefId = data.wfDefId
  69. this.flowData.wfInsId = data.wfInsId
  70. this.flowData.activityDefId = data.curActivityIns.activityDefId
  71. this.flowData.activityInsId = data.curActivityIns.activityInsId
  72. this.flowData.activityCode = data.curActivityIns.activityCode
  73. if(data.curActivityIns.actionList){
  74. let actionList=data.curActivityIns.actionList.map(function(item){
  75. item.value=item.actionId
  76. item.text=item.actionTitle
  77. return item
  78. })
  79. this.actionList=JSON.parse(JSON.stringify(actionList))
  80. this.flowData.actionId=actionList[0].actionId
  81. this.flowData.actionCode=actionList[0].actionCode
  82. }
  83. }
  84. })
  85. },
  86. init(){
  87. let data=uni.getStorageSync('submit-data')
  88. //初始化流程
  89. let danger_info=uni.getStorageSync('danger-info')
  90. this.formData={...this.formData,...danger_info}
  91. this.get(danger_info.hdangerId)
  92. this.getUser()
  93. if(data){
  94. this.formData.checklistId = data.checklistId
  95. this.formData.goafId = data.goafId
  96. this.formData.rectifyRemark = data.checkItemNopass
  97. this.formData.hdangerTitle = data.checkItemNopass
  98. }
  99. },
  100. async onSubmit(){
  101. let user=this.userList.filter(item=>item.accountId===this.formData.acceptAccountId)[0]
  102. if(!user){
  103. uni.showToast({
  104. icon:'none',
  105. title:"请选择验收人"
  106. })
  107. return
  108. }
  109. this.formData.acceptAccountName = user.accountName
  110. this.formData.acceptGroupId = user.groupId
  111. this.formData.acceptGroupName = user.groupName
  112. this.formData.acceptPositionId = user.positionId
  113. this.formData.acceptPositionName = user.positionName
  114. this.formData.ocId=user.ocId
  115. if(!this.verify()){
  116. return
  117. }
  118. handleWorkflow({
  119. "wfDefId": this.flowData.wfDefId,
  120. "wfInsId": this.flowData.wfInsId,
  121. "activityDefId": this.flowData.activityDefId,
  122. "activityInsId": this.flowData.activityInsId,
  123. "activityCode": this.flowData.activityCode,
  124. "actionId": this.flowData.actionId,
  125. "actionCode": this.flowData.actionCode,
  126. "actionRemark": this.formData.rectifyRemark,
  127. "attachList":this.formData.attachList,
  128. "groupIdTo": user.groupId,
  129. "positionIdTo": user.positionId,
  130. "accountIdTo": user.groupId,
  131. "groupNameTo": user.groupName,
  132. "positionNameTo": user.positionName,
  133. "accountNameTo": user.accountName,
  134. })
  135. //renshengkuduan !
  136. this.formData.status=3
  137. this.formData.submitTime=parseTime(this.formData.submitTime)
  138. this.formData.dangerDeadline=parseTime(this.formData.dangerDeadline)
  139. updateDanger(this.formData).then((resp) => {
  140. uni.switchTab({
  141. url:'/pages/risk/risk'
  142. })
  143. })
  144. },
  145. getUser(){
  146. getUserByPage({
  147. page: 1,
  148. limit: 999999
  149. }).then((res)=>{
  150. this.userList=res.data.map(item=>{
  151. return{
  152. ...item,
  153. value:item.accountId,
  154. text:item.accountName
  155. }
  156. })
  157. })
  158. },
  159. upload(){
  160. let self=this;
  161. uni.chooseImage({
  162. success:(files)=>{
  163. let filePath = files.tempFilePaths[0]
  164. upload({
  165. filePath
  166. }).then((res)=>{
  167. let result=JSON.parse(res);
  168. let attachList=[result.data]
  169. self.$set(self.formData,'attachList',attachList)
  170. })
  171. }
  172. })
  173. },
  174. verify(){
  175. let items={
  176. 'rectifyRemark': '处理说明', //
  177. }
  178. for(let key in items){
  179. if(this.formData[key]===""||this.formData[key]===undefined||this.formData[key]==="undefined"){
  180. uni.showToast({
  181. icon:'none',
  182. title:`请填写${items[key]}`
  183. })
  184. return false;
  185. }
  186. }
  187. return true
  188. },
  189. changeCheck(){
  190. let actionCode=this.actionList.filter(item=>item.actionId===this.flowData.actionId)[0].actionCode
  191. this.flowData.actionCode=actionCode
  192. }
  193. }
  194. }
  195. </script>
  196. <style lang="scss" scoped>
  197. .body{
  198. min-height: 100vh;
  199. box-sizing: border-box;
  200. padding:21rpx 16rpx;
  201. background-color: #F3F5FB;
  202. padding-bottom: 160rpx;
  203. .status-item{
  204. padding: 22rpx 32rpx;
  205. background-color: #fff;
  206. font-size: 28rpx;
  207. line-height: 1;
  208. display: inline-block;
  209. color: #434343;
  210. margin-right: 20rpx;
  211. border-radius: 2px;
  212. &.active{
  213. background: rgba(22, 141, 236, 0.16);
  214. color:#168DEC ;
  215. }
  216. }
  217. ::v-deep .uni-forms-item__content{
  218. .uni-easyinput,.uni-select{
  219. background-color: #fff;
  220. }
  221. }
  222. .upload-container{
  223. .upload{
  224. width: 216rpx;
  225. display: block;
  226. }
  227. .tip{
  228. font-size: 24rpx;
  229. line-height: 28rpx;
  230. color: #999999;
  231. padding-top: 20rpx;
  232. }
  233. }
  234. .footer{
  235. width: 100%;
  236. height: 136upx;
  237. background: #FFFFFF;
  238. border-radius: 16upx 16upx 0px 0px;
  239. position: fixed;
  240. left: 0;
  241. bottom: 0;
  242. text-align: center;
  243. color: #168DEC;
  244. font-size: 32upx;
  245. padding-top: 20upx;
  246. letter-spacing: 2px;
  247. }
  248. .preview{
  249. padding-top: 50rpx;
  250. .preview-item{
  251. width: 200rpx;
  252. height: 200rpx;
  253. }
  254. }
  255. }
  256. </style>