submit.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <div class="body">
  3. <uni-forms ref="form" label-position="top" :rules="rules" :model="formData">
  4. <uni-forms-item label="隐患标题" name="desc" required>
  5. <uni-easyinput v-model="formData.hdangerTitle" placeholder="请输入描述"></uni-easyinput>
  6. </uni-forms-item>
  7. <uni-forms-item label="采空区" name="goafId" required>
  8. <uni-data-select
  9. v-model="formData.goafId"
  10. :localdata="goafList"
  11. ></uni-data-select>
  12. </uni-forms-item>
  13. <uni-forms-item label="检查表" name="checklistId" required>
  14. <uni-data-select
  15. v-model="formData.checklistId"
  16. :localdata="checkList"
  17. ></uni-data-select>
  18. </uni-forms-item>
  19. <uni-forms-item label="评审人" name="reviewAccountId" required>
  20. <uni-data-select
  21. v-model="formData.reviewAccountId"
  22. :localdata="userList"
  23. ></uni-data-select>
  24. </uni-forms-item>
  25. <uni-forms-item label="描述" name="hdangerLevel" required>
  26. <uni-data-checkbox v-model="formData.hdangerLevel" :localdata="hdangerLevels"></uni-data-checkbox>
  27. </uni-forms-item>
  28. <uni-forms-item label="发生时间" name="submitTime" required>
  29. <uni-datetime-picker
  30. type="datetime"
  31. v-model="formData.submitTime"
  32. />
  33. </uni-forms-item>
  34. <uni-forms-item label="截止时间" name="dangerDeadline" required>
  35. <uni-datetime-picker
  36. type="datetime"
  37. v-model="formData.dangerDeadline"
  38. />
  39. </uni-forms-item>
  40. <uni-forms-item label="描述" name="hdangerDesc" required>
  41. <uni-easyinput type="textarea" autoHeight v-model="formData.hdangerDesc" placeholder="请输入描述"></uni-easyinput>
  42. </uni-forms-item>
  43. <uni-forms-item label="附件">
  44. <div class="upload-container">
  45. <image @click="upload" class="upload" src="/static/icon/upload.png" mode="widthFix"></image>
  46. <p class="tip">注:单个附件上传不超过10M,附件累计不超过20M</p>
  47. </div>
  48. <view class="preview" v-if="formData.attachList.length>0">
  49. <image class="preview-item" :src="attach.fileUrl" mode="widthFix" v-for="(attach,index) in formData.attachList" :key="index"></image>
  50. </view>
  51. </uni-forms-item>
  52. </uni-forms>
  53. <view class="footer" @click="onSubmit">提交</view>
  54. </div>
  55. </template>
  56. <script>
  57. import {getUserByPage} from '@/api/user.js'
  58. import {upload} from '@/api/index.js'
  59. import { getChecklist } from '@/api/check'
  60. import { getGoafBaseInfo } from '@/api/goaf'
  61. import { startWorkflow, getWorkflowById, handleWorkflow } from '@/api/system/wfApi'
  62. import { handleDanger, getDangerById } from '@/api/dangerApi'
  63. import {parseTime} from '@/libs'
  64. export default {
  65. data() {
  66. return {
  67. formData:{
  68. 'hdangerId': undefined,
  69. 'formCode': 'submit',
  70. 'hdangerTitle': '', // 隐患标题
  71. 'dangerCatId': undefined, // 隐患类别ID
  72. 'hdangerLevel': 1, // 隐患等级
  73. 'hdangerDesc': '', // 描述
  74. 'submitTime': parseTime(new Date()),
  75. 'dangerDeadline': '', // 截止时间
  76. 'goafId': undefined,
  77. 'checklistId': '',
  78. "attachList":[]
  79. },
  80. flowData:{},
  81. userList:[],
  82. checkList:[],
  83. goafList:[],
  84. hdangerLevels:[
  85. {"value": 0,"text": "较低" },
  86. {"value": 1,"text": "一般"},
  87. {"value": 2,"text": "较大"},
  88. {"value": 3,"text": "重大"},
  89. ],
  90. rules:{
  91. reviewAccountId:{
  92. rules:[
  93. {
  94. required: true,
  95. errorMessage: '请选择评审人',
  96. },
  97. ],
  98. },
  99. desc:{
  100. rules:[
  101. {
  102. required: true,
  103. errorMessage: '请填写描述',
  104. },
  105. ]
  106. }
  107. },
  108. }
  109. },
  110. created() {
  111. this.init()
  112. },
  113. methods: {
  114. // 启动流程
  115. async start(wfDefId) {
  116. const { code, data, msg } = await startWorkflow(wfDefId)
  117. if (code === 0) {
  118. this.flowData = data
  119. this.flowData.wfDefId = data.wfDefId
  120. this.flowData.wfInsId = data.wfInsId
  121. this.flowData.activityDefId = data.curActivityIns.activityDefId
  122. this.flowData.activityInsId = data.curActivityIns.activityInsId
  123. this.flowData.activityCode = data.curActivityIns.activityCode
  124. this.formData.hdangerId=data.wfInsId
  125. return data.wfInsId
  126. }
  127. },
  128. // 获取流程
  129. get(wfInsId) {
  130. this.resetFormData()
  131. getWorkflowById(wfInsId).then((resp) => {
  132. const { code, data, msg } = resp
  133. if (code === 0) {
  134. this.flowData = data
  135. this.flowData.wfDefId = data.wfDefId
  136. this.flowData.wfInsId = data.wfInsId
  137. this.flowData.activityDefId = data.curActivityIns.activityDefId
  138. this.flowData.activityInsId = data.curActivityIns.activityInsId
  139. this.flowData.activityCode = data.curActivityIns.activityCode
  140. this.renderAction()
  141. } else {
  142. this.$message.error(msg)
  143. }
  144. }).catch((error) => {
  145. console.log(error)
  146. })
  147. },
  148. init(){
  149. let data=uni.getStorageSync('submit-data')
  150. if(data){
  151. this.formData.checklistId = data.checklistId
  152. this.formData.goafId = data.goafId
  153. this.formData.hdangerDesc = data.checkItemNopass
  154. this.formData.hdangerTitle = data.checkItemNopass
  155. }
  156. this.getUser()
  157. this.getChecklist()
  158. this.getGoafBaseInfo()
  159. //初始化流程
  160. this.start(1)
  161. },
  162. getUser(){
  163. getUserByPage({
  164. page: 1,
  165. limit: 999999
  166. }).then((res)=>{
  167. this.userList=res.data.map(item=>{
  168. return{
  169. ...item,
  170. value:item.accountId,
  171. text:item.accountName
  172. }
  173. })
  174. })
  175. },
  176. getChecklist(){
  177. getChecklist().then((res)=>{
  178. this.checkList=res.data.map(item=>{
  179. return{
  180. ...item,
  181. value:item.checklistId,
  182. text:item.checklistTitle
  183. }
  184. })
  185. })
  186. },
  187. getGoafBaseInfo(){
  188. getGoafBaseInfo().then((res)=>{
  189. this.goafList=res.data.map(item=>{
  190. return{
  191. ...item,
  192. value:item.goafId,
  193. text:item.goafName
  194. }
  195. })
  196. })
  197. },
  198. async onSubmit(){
  199. let user=this.userList.filter(item=>item.accountId===this.formData.reviewAccountId)[0]
  200. if(user){
  201. this.formData.reviewAccountName = user.accountName
  202. this.formData.reviewGroupId = user.groupId
  203. this.formData.reviewGroupName = user.groupName
  204. this.formData.reviewPositionId = user.positionId
  205. this.formData.reviewPositionName = user.positionName
  206. this.formData.ocId=user.ocId
  207. }
  208. if(!this.verify()){
  209. return
  210. }
  211. handleWorkflow({
  212. "wfDefId": this.flowData.wfDefId,
  213. "wfInsId": this.flowData.wfInsId,
  214. "activityDefId": this.flowData.activityDefId,
  215. "activityInsId": this.flowData.activityInsId,
  216. "activityCode": this.flowData.activityCode,
  217. "actionId": 1,
  218. "actionCode": "submit",
  219. "actionRemark": this.flowData.hdangerDesc,
  220. "attachList":this.formData.attachList,
  221. "groupIdTo": user.groupId,
  222. "positionIdTo": user.positionId,
  223. "accountIdTo": user.groupId,
  224. "groupNameTo": user.groupName,
  225. "positionNameTo": user.positionName,
  226. "accountNameTo": user.accountName,
  227. })
  228. //renshengkuduan !
  229. this.formData.status=1
  230. this.formData.submitTime=parseTime(this.formData.submitTime)
  231. this.formData.dangerDeadline=parseTime(this.formData.dangerDeadline)
  232. handleDanger(this.formData).then((resp) => {
  233. uni.switchTab({
  234. url:'/pages/risk/risk'
  235. })
  236. })
  237. },
  238. upload(){
  239. let self=this;
  240. uni.chooseImage({
  241. success:(files)=>{
  242. let filePath = files.tempFilePaths[0]
  243. console.log(self.formData.attachList)
  244. upload({
  245. filePath
  246. }).then((res)=>{
  247. let result=JSON.parse(res);
  248. let attachList=[result.data]
  249. self.$set(self.formData,'attachList',attachList)
  250. })
  251. }
  252. })
  253. },
  254. verify(){
  255. let items={
  256. 'hdangerTitle': '隐患标题', //
  257. "reviewAccountId":'评审人',
  258. 'hdangerLevel': "隐患等级", // 隐患等级
  259. 'hdangerDesc': '描述', //
  260. 'submitTime': "发生时间",
  261. 'dangerDeadline': '截止时间', //
  262. 'goafId': "采空区",
  263. 'checklistId': '检查表',
  264. // 'attachList':"附件"
  265. }
  266. for(let key in items){
  267. if(this.formData[key]===""||this.formData[key]===undefined||this.formData[key]==="undefined"){
  268. uni.showToast({
  269. icon:'none',
  270. title:`请填写${items[key]}`
  271. })
  272. return false;
  273. }
  274. }
  275. return true
  276. }
  277. }
  278. }
  279. </script>
  280. <style lang="scss" scoped>
  281. .body{
  282. min-height: 100vh;
  283. box-sizing: border-box;
  284. padding:21rpx 16rpx;
  285. background-color: #F3F5FB;
  286. padding-bottom: 160rpx;
  287. .status-item{
  288. padding: 22rpx 32rpx;
  289. background-color: #fff;
  290. font-size: 28rpx;
  291. line-height: 1;
  292. display: inline-block;
  293. color: #434343;
  294. margin-right: 20rpx;
  295. border-radius: 2px;
  296. &.active{
  297. background: rgba(22, 141, 236, 0.16);
  298. color:#168DEC ;
  299. }
  300. }
  301. ::v-deep .uni-forms-item__content{
  302. .uni-easyinput,.uni-select{
  303. background-color: #fff;
  304. }
  305. }
  306. .upload-container{
  307. .upload{
  308. width: 216rpx;
  309. display: block;
  310. }
  311. .tip{
  312. font-size: 24rpx;
  313. line-height: 28rpx;
  314. color: #999999;
  315. padding-top: 20rpx;
  316. }
  317. }
  318. .footer{
  319. width: 100%;
  320. height: 136upx;
  321. background: #FFFFFF;
  322. border-radius: 16upx 16upx 0px 0px;
  323. position: fixed;
  324. left: 0;
  325. bottom: 0;
  326. text-align: center;
  327. color: #168DEC;
  328. font-size: 32upx;
  329. padding-top: 20upx;
  330. letter-spacing: 2px;
  331. }
  332. .preview{
  333. padding-top: 50rpx;
  334. .preview-item{
  335. width: 200rpx;
  336. height: 200rpx;
  337. }
  338. }
  339. }
  340. </style>