form.vue 7.4 KB

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