form.vue 9.8 KB

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