form.vue 6.5 KB

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