form.vue 5.8 KB

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