form.vue 6.9 KB

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