form.vue 7.5 KB

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