submit.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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. onLoad() {
  114. let scanCode_info=uni.getStorageSync('scanCode-info')
  115. if(scanCode_info){
  116. console.log('扫码登记')
  117. }
  118. },
  119. methods: {
  120. // 启动流程
  121. async start(wfDefId) {
  122. const { code, data, msg } = await startWorkflow(wfDefId)
  123. if (code === 0) {
  124. this.flowData = data
  125. this.flowData.wfDefId = data.wfDefId
  126. this.flowData.wfInsId = data.wfInsId
  127. this.flowData.activityDefId = data.curActivityIns.activityDefId
  128. this.flowData.activityInsId = data.curActivityIns.activityInsId
  129. this.flowData.activityCode = data.curActivityIns.activityCode
  130. this.formData.hdangerId=data.wfInsId
  131. return data.wfInsId
  132. }
  133. },
  134. // 获取流程
  135. get(wfInsId) {
  136. this.resetFormData()
  137. getWorkflowById(wfInsId).then((resp) => {
  138. const { code, data, msg } = resp
  139. if (code === 0) {
  140. this.flowData = data
  141. this.flowData.wfDefId = data.wfDefId
  142. this.flowData.wfInsId = data.wfInsId
  143. this.flowData.activityDefId = data.curActivityIns.activityDefId
  144. this.flowData.activityInsId = data.curActivityIns.activityInsId
  145. this.flowData.activityCode = data.curActivityIns.activityCode
  146. this.renderAction()
  147. } else {
  148. this.$message.error(msg)
  149. }
  150. }).catch((error) => {
  151. console.log(error)
  152. })
  153. },
  154. init(){
  155. let data=uni.getStorageSync('submit-data')
  156. if(data){
  157. this.formData.checklistId = data.checklistId
  158. this.formData.goafId = data.goafId
  159. this.formData.hdangerDesc = data.checkItemNopass
  160. this.formData.hdangerTitle = data.checkItemNopass
  161. }
  162. this.getUser()
  163. this.getChecklist()
  164. this.getGoafBaseInfo()
  165. //初始化流程
  166. this.start(1)
  167. },
  168. getUser(){
  169. getUserByPage({
  170. page: 1,
  171. limit: 999999
  172. }).then((res)=>{
  173. this.userList=res.data.map(item=>{
  174. return{
  175. ...item,
  176. value:item.accountId,
  177. text:item.accountName
  178. }
  179. })
  180. })
  181. },
  182. getChecklist(){
  183. getChecklist().then((res)=>{
  184. this.checkList=res.data.map(item=>{
  185. return{
  186. ...item,
  187. value:item.checklistId,
  188. text:item.checklistTitle
  189. }
  190. })
  191. })
  192. },
  193. getGoafBaseInfo(){
  194. getGoafBaseInfo().then((res)=>{
  195. this.goafList=res.data.map(item=>{
  196. return{
  197. ...item,
  198. value:item.goafId,
  199. text:item.goafName
  200. }
  201. })
  202. })
  203. },
  204. async onSubmit(){
  205. let user=this.userList.filter(item=>item.accountId===this.formData.reviewAccountId)[0]
  206. if(user){
  207. this.formData.reviewAccountName = user.accountName
  208. this.formData.reviewGroupId = user.groupId
  209. this.formData.reviewGroupName = user.groupName
  210. this.formData.reviewPositionId = user.positionId
  211. this.formData.reviewPositionName = user.positionName
  212. this.formData.ocId=user.ocId
  213. }
  214. if(!this.verify()){
  215. return
  216. }
  217. handleWorkflow({
  218. "wfDefId": this.flowData.wfDefId,
  219. "wfInsId": this.flowData.wfInsId,
  220. "activityDefId": this.flowData.activityDefId,
  221. "activityInsId": this.flowData.activityInsId,
  222. "activityCode": this.flowData.activityCode,
  223. "actionId": 1,
  224. "actionCode": "submit",
  225. "actionRemark": this.flowData.hdangerDesc,
  226. "attachList":this.formData.attachList,
  227. "groupIdTo": user.groupId,
  228. "positionIdTo": user.positionId,
  229. "accountIdTo": user.groupId,
  230. "groupNameTo": user.groupName,
  231. "positionNameTo": user.positionName,
  232. "accountNameTo": user.accountName,
  233. })
  234. //renshengkuduan !
  235. this.formData.status=1
  236. this.formData.submitTime=parseTime(this.formData.submitTime)
  237. this.formData.dangerDeadline=parseTime(this.formData.dangerDeadline)
  238. handleDanger(this.formData).then((resp) => {
  239. uni.switchTab({
  240. url:'/pages/risk/risk'
  241. })
  242. })
  243. },
  244. upload(){
  245. let self=this;
  246. uni.chooseImage({
  247. success:(files)=>{
  248. let filePath = files.tempFilePaths[0]
  249. console.log(self.formData.attachList)
  250. upload({
  251. filePath
  252. }).then((res)=>{
  253. let result=JSON.parse(res);
  254. let attachList=[result.data]
  255. self.$set(self.formData,'attachList',attachList)
  256. })
  257. }
  258. })
  259. },
  260. verify(){
  261. let items={
  262. 'hdangerTitle': '隐患标题', //
  263. "reviewAccountId":'评审人',
  264. 'hdangerLevel': "隐患等级", // 隐患等级
  265. // 'hdangerDesc': '描述', //
  266. 'submitTime': "发生时间",
  267. 'dangerDeadline': '截止时间', //
  268. 'goafId': "采空区",
  269. 'checklistId': '检查表',
  270. // 'attachList':"附件"
  271. }
  272. for(let key in items){
  273. if(this.formData[key]===""||this.formData[key]===undefined||this.formData[key]==="undefined"){
  274. uni.showToast({
  275. icon:'none',
  276. title:`请填写${items[key]}`
  277. })
  278. return false;
  279. }
  280. }
  281. return true
  282. }
  283. }
  284. }
  285. </script>
  286. <style lang="scss" scoped>
  287. .body{
  288. min-height: 100vh;
  289. box-sizing: border-box;
  290. padding:21rpx 16rpx;
  291. background-color: #F3F5FB;
  292. padding-bottom: 160rpx;
  293. .status-item{
  294. padding: 22rpx 32rpx;
  295. background-color: #fff;
  296. font-size: 28rpx;
  297. line-height: 1;
  298. display: inline-block;
  299. color: #434343;
  300. margin-right: 20rpx;
  301. border-radius: 2px;
  302. &.active{
  303. background: rgba(22, 141, 236, 0.16);
  304. color:#168DEC ;
  305. }
  306. }
  307. ::v-deep .uni-forms-item__content{
  308. .uni-easyinput,.uni-select{
  309. background-color: #fff;
  310. }
  311. }
  312. .upload-container{
  313. .upload{
  314. width: 216rpx;
  315. display: block;
  316. }
  317. .tip{
  318. font-size: 24rpx;
  319. line-height: 28rpx;
  320. color: #999999;
  321. padding-top: 20rpx;
  322. }
  323. }
  324. .footer{
  325. width: 100%;
  326. height: 136upx;
  327. background: #FFFFFF;
  328. border-radius: 16upx 16upx 0px 0px;
  329. position: fixed;
  330. left: 0;
  331. bottom: 0;
  332. text-align: center;
  333. color: #168DEC;
  334. font-size: 32upx;
  335. padding-top: 20upx;
  336. letter-spacing: 2px;
  337. }
  338. .preview{
  339. padding-top: 50rpx;
  340. .preview-item{
  341. width: 200rpx;
  342. height: 200rpx;
  343. }
  344. }
  345. }
  346. </style>