form.vue 5.8 KB

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