form.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. let actionList=this.flowData.curActivityIns.actionList.map(function(item){
  74. item.value=item.actionId
  75. item.text=item.actionTitle
  76. return item
  77. })
  78. this.actionList=JSON.parse(JSON.stringify(actionList))
  79. this.flowData.actionId=actionList[0].actionId
  80. this.flowData.actionCode=actionList[0].actionCode
  81. }
  82. })
  83. },
  84. init(){
  85. let data=uni.getStorageSync('submit-data')
  86. //初始化流程
  87. let danger_info=uni.getStorageSync('danger-info')
  88. this.formData={...this.formData,...danger_info}
  89. this.get(danger_info.hdangerId)
  90. this.getUser()
  91. if(data){
  92. this.formData.checklistId = data.checklistId
  93. this.formData.goafId = data.goafId
  94. this.formData.rectifyRemark = data.checkItemNopass
  95. this.formData.hdangerTitle = data.checkItemNopass
  96. }
  97. },
  98. async onSubmit(){
  99. let user=this.userList.filter(item=>item.accountId===this.formData.acceptAccountId)[0]
  100. if(!user){
  101. uni.showToast({
  102. icon:'none',
  103. title:"请选择验收人"
  104. })
  105. return
  106. }
  107. this.formData.acceptAccountName = user.accountName
  108. this.formData.acceptGroupId = user.groupId
  109. this.formData.acceptGroupName = user.groupName
  110. this.formData.acceptPositionId = user.positionId
  111. this.formData.acceptPositionName = user.positionName
  112. this.formData.ocId=user.ocId
  113. if(!this.verify()){
  114. return
  115. }
  116. handleWorkflow({
  117. "wfDefId": this.flowData.wfDefId,
  118. "wfInsId": this.flowData.wfInsId,
  119. "activityDefId": this.flowData.activityDefId,
  120. "activityInsId": this.flowData.activityInsId,
  121. "activityCode": this.flowData.activityCode,
  122. "actionId": this.flowData.actionId,
  123. "actionCode": this.flowData.actionCode,
  124. "actionRemark": this.formData.rectifyRemark,
  125. "attachList":this.formData.attachList,
  126. "groupIdTo": user.groupId,
  127. "positionIdTo": user.positionId,
  128. "accountIdTo": user.groupId,
  129. "groupNameTo": user.groupName,
  130. "positionNameTo": user.positionName,
  131. "accountNameTo": user.accountName,
  132. })
  133. //renshengkuduan !
  134. this.formData.status=3
  135. this.formData.submitTime=parseTime(this.formData.submitTime)
  136. this.formData.dangerDeadline=parseTime(this.formData.dangerDeadline)
  137. updateDanger(this.formData).then((resp) => {
  138. uni.switchTab({
  139. url:'/pages/risk/risk'
  140. })
  141. })
  142. },
  143. getUser(){
  144. getUserByPage({
  145. page: 1,
  146. limit: 999999
  147. }).then((res)=>{
  148. this.userList=res.data.map(item=>{
  149. return{
  150. ...item,
  151. value:item.accountId,
  152. text:item.accountName
  153. }
  154. })
  155. })
  156. },
  157. upload(){
  158. let self=this;
  159. uni.chooseImage({
  160. success:(files)=>{
  161. let filePath = files.tempFilePaths[0]
  162. upload({
  163. filePath
  164. }).then((res)=>{
  165. let result=JSON.parse(res);
  166. let attachList=[result.data]
  167. self.$set(self.formData,'attachList',attachList)
  168. })
  169. }
  170. })
  171. },
  172. verify(){
  173. let items={
  174. 'rectifyRemark': '处理说明', //
  175. }
  176. for(let key in items){
  177. if(this.formData[key]===""||this.formData[key]===undefined||this.formData[key]==="undefined"){
  178. uni.showToast({
  179. icon:'none',
  180. title:`请填写${items[key]}`
  181. })
  182. return false;
  183. }
  184. }
  185. return true
  186. },
  187. changeCheck(){
  188. let actionCode=this.actionList.filter(item=>item.actionId===this.flowData.actionId)[0].actionCode
  189. this.flowData.actionCode=actionCode
  190. }
  191. }
  192. }
  193. </script>
  194. <style lang="scss" scoped>
  195. .body{
  196. min-height: 100vh;
  197. box-sizing: border-box;
  198. padding:21rpx 16rpx;
  199. background-color: #F3F5FB;
  200. padding-bottom: 160rpx;
  201. .status-item{
  202. padding: 22rpx 32rpx;
  203. background-color: #fff;
  204. font-size: 28rpx;
  205. line-height: 1;
  206. display: inline-block;
  207. color: #434343;
  208. margin-right: 20rpx;
  209. border-radius: 2px;
  210. &.active{
  211. background: rgba(22, 141, 236, 0.16);
  212. color:#168DEC ;
  213. }
  214. }
  215. ::v-deep .uni-forms-item__content{
  216. .uni-easyinput,.uni-select{
  217. background-color: #fff;
  218. }
  219. }
  220. .upload-container{
  221. .upload{
  222. width: 216rpx;
  223. display: block;
  224. }
  225. .tip{
  226. font-size: 24rpx;
  227. line-height: 28rpx;
  228. color: #999999;
  229. padding-top: 20rpx;
  230. }
  231. }
  232. .footer{
  233. width: 100%;
  234. height: 136upx;
  235. background: #FFFFFF;
  236. border-radius: 16upx 16upx 0px 0px;
  237. position: fixed;
  238. left: 0;
  239. bottom: 0;
  240. text-align: center;
  241. color: #168DEC;
  242. font-size: 32upx;
  243. padding-top: 20upx;
  244. letter-spacing: 2px;
  245. }
  246. .preview{
  247. padding-top: 50rpx;
  248. .preview-item{
  249. width: 200rpx;
  250. height: 200rpx;
  251. }
  252. }
  253. }
  254. </style>