form.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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="acceptRemark" required>
  8. <uni-easyinput type="textarea" autoHeight v-model="formData.acceptRemark" 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. 'acceptRemark': '', // 描述
  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. let actionList=this.flowData.curActivityIns.actionList.map(function(item){
  66. item.value=item.actionId
  67. item.text=item.actionTitle
  68. return item
  69. })
  70. this.actionList=JSON.parse(JSON.stringify(actionList))
  71. this.flowData.actionId=actionList[0].actionId
  72. }
  73. })
  74. },
  75. init(){
  76. let data=uni.getStorageSync('submit-data')
  77. //初始化流程
  78. let danger_info=uni.getStorageSync('danger-info')
  79. this.get(danger_info.hdangerId)
  80. this.formData={...this.formData,...danger_info}
  81. if(data){
  82. this.formData.checklistId = data.checklistId
  83. this.formData.goafId = data.goafId
  84. this.formData.acceptRemark = data.checkItemNopass
  85. this.formData.hdangerTitle = data.checkItemNopass
  86. }
  87. },
  88. async onSubmit(){
  89. if(!this.verify()){
  90. return
  91. }
  92. handleWorkflow({
  93. "wfDefId": this.flowData.wfDefId,
  94. "wfInsId": this.flowData.wfInsId,
  95. "activityDefId": this.flowData.activityDefId,
  96. "activityInsId": this.flowData.activityInsId,
  97. "activityCode": this.flowData.activityCode,
  98. "actionId": this.flowData.actionId,
  99. "actionCode": this.flowData.actionCode,
  100. "actionRemark": this.formData.acceptRemark,
  101. "attachList":this.formData.attachList
  102. })
  103. //renshengkuduan !
  104. this.formData.status=4
  105. this.formData.submitTime=parseTime(this.formData.submitTime)
  106. this.formData.dangerDeadline=parseTime(this.formData.dangerDeadline)
  107. updateDanger(this.formData).then((resp) => {
  108. uni.switchTab({
  109. url:'/pages/risk/risk'
  110. })
  111. })
  112. },
  113. upload(){
  114. let self=this;
  115. uni.chooseImage({
  116. success:(files)=>{
  117. let filePath = files.tempFilePaths[0]
  118. upload({
  119. filePath
  120. }).then((res)=>{
  121. let result=JSON.parse(res);
  122. let attachList=[result.data]
  123. self.$set(self.formData,'attachList',attachList)
  124. })
  125. }
  126. })
  127. },
  128. verify(){
  129. let items={
  130. 'acceptRemark': '处理说明', //
  131. }
  132. for(let key in items){
  133. if(this.formData[key]===""||this.formData[key]===undefined||this.formData[key]==="undefined"){
  134. uni.showToast({
  135. icon:'none',
  136. title:`请填写${items[key]}`
  137. })
  138. return false;
  139. }
  140. }
  141. return true
  142. },
  143. changeCheck(){
  144. let actionCode=this.actionList.filter(item=>item.actionId===this.flowData.actionId)[0].actionCode
  145. this.flowData.actionCode=actionCode
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang="scss" scoped>
  151. .body{
  152. min-height: 100vh;
  153. box-sizing: border-box;
  154. padding:21rpx 16rpx;
  155. background-color: #F3F5FB;
  156. padding-bottom: 160rpx;
  157. .status-item{
  158. padding: 22rpx 32rpx;
  159. background-color: #fff;
  160. font-size: 28rpx;
  161. line-height: 1;
  162. display: inline-block;
  163. color: #434343;
  164. margin-right: 20rpx;
  165. border-radius: 2px;
  166. &.active{
  167. background: rgba(22, 141, 236, 0.16);
  168. color:#168DEC ;
  169. }
  170. }
  171. ::v-deep .uni-forms-item__content{
  172. .uni-easyinput,.uni-select{
  173. background-color: #fff;
  174. }
  175. }
  176. .upload-container{
  177. .upload{
  178. width: 216rpx;
  179. display: block;
  180. }
  181. .tip{
  182. font-size: 24rpx;
  183. line-height: 28rpx;
  184. color: #999999;
  185. padding-top: 20rpx;
  186. }
  187. }
  188. .footer{
  189. width: 100%;
  190. height: 136upx;
  191. background: #FFFFFF;
  192. border-radius: 16upx 16upx 0px 0px;
  193. position: fixed;
  194. left: 0;
  195. bottom: 0;
  196. text-align: center;
  197. color: #168DEC;
  198. font-size: 32upx;
  199. padding-top: 20upx;
  200. letter-spacing: 2px;
  201. }
  202. .preview{
  203. padding-top: 50rpx;
  204. .preview-item{
  205. width: 200rpx;
  206. height: 200rpx;
  207. }
  208. }
  209. }
  210. </style>