Submit.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <el-drawer
  3. :title="title"
  4. :modal-append-to-body="false"
  5. :modal="false"
  6. :wrapper-closable="false"
  7. size="99%"
  8. :visible.sync="dialogVisible"
  9. >
  10. <template slot="title">
  11. <div class="el-drawer-title">
  12. <span class="name">{{ title }}</span>
  13. </div>
  14. </template>
  15. <div class="content-container">
  16. <el-row class="content-body">
  17. <div v-show="tabType==='form'">
  18. <vuescroll :ops="ops" style="height: calc(100vh - 300px)">
  19. <el-form ref="ruleForm" :model="formData" :rules="rules" label-width="130px">
  20. <el-form-item label="隐患标题" prop="hdangerTitle">
  21. <el-input v-model="formData.hdangerTitle" />
  22. </el-form-item>
  23. <el-form-item label="采空区" prop="goafId">
  24. <el-select v-model="formData.goafId" filterable placeholder="采空区名称" style="width: 100%">
  25. <el-option value="" label="请选择采空区" disabled />
  26. <el-option v-for="item in goafs" :key="item.goafId" :value="item.goafId" :label="item.goafName" />
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item label="检查表" prop="checklistId">
  30. <el-select v-model="formData.checklistId" style="width: 100%" filterable placeholder="检查表">
  31. <el-option
  32. v-for="item in checklist"
  33. :key="item.checklistId"
  34. :label="item.checklistTitle"
  35. :value="item.checklistId"
  36. />
  37. </el-select>
  38. </el-form-item>
  39. <el-form-item label="隐患等级" prop="hdangerLevel">
  40. <el-radio-group v-model="formData.hdangerLevel">
  41. <el-radio :label="0">较低</el-radio>
  42. <el-radio :label="1">一般</el-radio>
  43. <el-radio :label="2">较大</el-radio>
  44. <el-radio :label="3">重大</el-radio>
  45. </el-radio-group>
  46. </el-form-item>
  47. <el-form-item label="发生时间" prop="submitTime">
  48. <el-date-picker
  49. v-model="formData.submitTime"
  50. type="date"
  51. placeholder="设置发生时间"
  52. format="yyyy-MM-dd HH:mm:ss"
  53. value-format="yyyy-MM-dd HH:mm:ss"
  54. clearable
  55. style="width: 100%"
  56. />
  57. </el-form-item>
  58. <el-form-item label="整改截止时间" prop="dangerDeadline">
  59. <el-date-picker
  60. v-model="formData.dangerDeadline"
  61. type="date"
  62. placeholder="设置截止时间"
  63. format="yyyy-MM-dd HH:mm:ss"
  64. value-format="yyyy-MM-dd HH:mm:ss"
  65. clearable
  66. style="width: 100%"
  67. />
  68. </el-form-item>
  69. <el-form-item label="描述" prop="hdangerDesc">
  70. <el-input v-model="formData.hdangerDesc" type="textarea" :rows="5" placeholder="隐患描述" />
  71. </el-form-item>
  72. </el-form>
  73. <work-flow ref="WFlow" handle-user="评审人" />
  74. <div class="btn-group">
  75. <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
  76. <el-button @click="dialogVisible = false">取消</el-button>
  77. </div>
  78. </vuescroll>
  79. </div>
  80. </el-row>
  81. </div>
  82. </el-drawer>
  83. </template>
  84. <script>
  85. import { getChecklist } from '@/api/goaf/check'
  86. import { handleDanger, getDangerById } from '@/api/goaf/dangerApi'
  87. import { getGoafBaseInfo } from '@/api/goaf/info'
  88. import Vuescroll from 'vuescroll'
  89. import { mapGetters } from 'vuex'
  90. import { WorkFlow } from '@/components'
  91. export default {
  92. name: 'SubmitTask',
  93. components: {
  94. Vuescroll,
  95. WorkFlow
  96. },
  97. props: {
  98. title: {
  99. type: String,
  100. default: ''
  101. }
  102. },
  103. data() {
  104. return {
  105. ops: {
  106. bar: {
  107. keepShow: false,
  108. background: 'rgba(144, 147, 153, 0.4)',
  109. onlyShowBarOnScroll: false
  110. }
  111. },
  112. dialogVisible: false,
  113. tabType: 'form',
  114. formData: {
  115. 'formCode': 'submit',
  116. 'hdangerId': 1,
  117. 'dangerId': undefined,
  118. 'hdangerTitle': '', // 隐患标题
  119. 'dangerCatId': undefined, // 隐患类别ID
  120. 'hdangerLevel': 1, // 隐患等级
  121. 'hdangerDesc': '', // 描述
  122. 'submitTime': new Date(),
  123. 'dangerDeadline': '', // 截止时间
  124. 'goafId': undefined,
  125. 'submitGroupId': '',
  126. 'submitGroupName': '',
  127. 'submitPositionId': '',
  128. 'submitPositionName': '',
  129. 'submitAccountId': '',
  130. 'submitAccountName': '',
  131. 'checklistId': ''
  132. },
  133. goafs: [],
  134. checklist: [],
  135. rules: {
  136. hdangerTitle: [
  137. { required: true, message: '请输入隐患标题', trigger: 'blur' }
  138. ],
  139. goafId: [
  140. { required: true, message: '请选择采空区', trigger: 'change' }
  141. ],
  142. checklistId: [
  143. { required: true, message: '请选择检查表', trigger: 'change' }
  144. ],
  145. hdangerLevel: [
  146. { required: true, message: '请输选择隐患等级', trigger: 'blur' }
  147. ],
  148. submitTime: [
  149. { required: true, message: '发生时间', trigger: 'blur' }
  150. ],
  151. dangerDeadline: [
  152. { required: true, message: '截止时间', trigger: 'blur' }
  153. ],
  154. accountIdTo: [
  155. { required: true, message: '请选择执行人', trigger: 'blur' }
  156. ]
  157. }
  158. }
  159. },
  160. computed: {
  161. ...mapGetters([
  162. 'userData'
  163. ])
  164. },
  165. methods: {
  166. // 启动
  167. start(params) {
  168. const wfDefId = 1
  169. this.dialogVisible = true
  170. const userData = JSON.parse(JSON.stringify(this.userData))
  171. this.formData.ocId = userData.ocId
  172. getChecklist().then((res) => {
  173. this.checklist = res.data
  174. })
  175. getGoafBaseInfo().then((res) => {
  176. this.goafs = res.data
  177. })
  178. this.$nextTick(() => {
  179. this.$refs.WFlow.start(wfDefId).then((res) => {
  180. if (res > 0) {
  181. this.formData.hdangerId = res
  182. } else {
  183. this.$message.error('流程初始化失败')
  184. }
  185. })
  186. })
  187. if (params) {
  188. this.formData.checklistId = params.checklistId
  189. this.formData.goafId = params.goafId
  190. this.formData.hdangerDesc = params.checkItemNopass
  191. this.formData.hdangerTitle = params.checkItemNopass
  192. }
  193. },
  194. // 显示窗口
  195. showModel(dangerId) {
  196. this.resetFormData()
  197. this.dialogVisible = true
  198. getDangerById(dangerId).then((resp) => {
  199. const { code, data, msg } = resp
  200. if (code === 0) {
  201. this.formData = data
  202. this.$refs.WFlow.get(dangerId)
  203. } else {
  204. this.$message.error(msg)
  205. }
  206. }).catch((error) => {
  207. console.log(error)
  208. })
  209. },
  210. resetFormData() {
  211. this.formData = {
  212. 'formCode': 'submit',
  213. 'hdangerId': 1,
  214. 'dangerId': undefined,
  215. 'hdangerTitle': '', // 隐患标题
  216. 'dangerCatId': undefined, // 隐患类别ID
  217. 'hdangerLevel': 1, // 隐患等级
  218. 'hdangerDesc': '', // 描述
  219. 'submitTime': new Date(),
  220. 'dangerDeadline': '', // 截止时间
  221. 'goafId': undefined,
  222. 'submitGroupId': '',
  223. 'submitGroupName': '',
  224. 'submitPositionId': '',
  225. 'submitPositionName': '',
  226. 'submitAccountId': '',
  227. 'submitAccountName': '',
  228. 'checklistId': ''
  229. }
  230. },
  231. // 保存
  232. submitForm() {
  233. this.$refs['ruleForm'].validate((valid) => {
  234. if (valid) {
  235. this.$nextTick(() => {
  236. this.$refs.WFlow.handle({}).then((res) => {
  237. this.handleCommand(res)
  238. }).catch((error) => {
  239. console.log(error)
  240. })
  241. })
  242. } else {
  243. this.$message.error('提交失败请检查')
  244. }
  245. })
  246. },
  247. // 提交
  248. handleCommand(flow) {
  249. const attachList = flow.data.attachList
  250. this.formData.submitRemark = flow.data.actionRemark
  251. this.formData.attachList = attachList
  252. if (Array.isArray(attachList) && attachList.length > 0) {
  253. const attach = attachList[0]
  254. this.formData.scenePhoto = attach.fileUrl
  255. this.formData.sceneIcon = attach.fileIcon
  256. }
  257. // this.formData.submitGroupId = this.userData.groupId
  258. // this.formData.submitGroupName = this.userData.groupName
  259. // this.formData.submitPositionId = this.userData.positionId
  260. // this.formData.submitPositionName = this.userData.positionName
  261. // this.formData.submitAccountId = this.userData.userId
  262. // this.formData.submitAccountName = this.userData.userName
  263. this.formData.reviewAccountId = flow.user.accountIdTo
  264. this.formData.reviewAccountName = flow.user.accountNameTo
  265. this.formData.reviewGroupId = flow.user.groupIdTo
  266. this.formData.reviewGroupName = flow.user.groupNameTo
  267. this.formData.reviewPositionId = flow.user.positionIdTo
  268. this.formData.reviewPositionName = flow.user.positionNameTo
  269. if (flow.curActivityCode === 'review') {
  270. this.formData.status = 1
  271. }
  272. if (flow.curActivityCode === 'rectify') {
  273. this.formData.status = 2
  274. }
  275. if (flow.curActivityCode === 'accept') {
  276. this.formData.status = 3
  277. }
  278. handleDanger(this.formData).then((resp) => {
  279. const { code, msg } = resp
  280. if (code === 0) {
  281. this.$emit('formSuccess')
  282. this.dialogVisible = false
  283. this.$message.success(msg)
  284. } else {
  285. this.$message.error(msg)
  286. }
  287. })
  288. },
  289. formSuccess() {
  290. this.$emit('formSuccess')
  291. },
  292. resetForm(formName) {
  293. this.$refs[formName].resetFields()
  294. }
  295. }
  296. }
  297. </script>
  298. <style lang="scss">
  299. </style>
  300. <style lang="scss" scoped>
  301. .content-container {
  302. position: relative;
  303. height: calc(100% - 15px);
  304. .ruleForm {
  305. margin: 0 100px;
  306. }
  307. .btn-group {
  308. width: 100%;
  309. text-align: center;
  310. .el-button {
  311. margin: 0 15px;
  312. }
  313. .cancel-btn {
  314. background: #004F7B;
  315. border-color: #004F7B;
  316. color: #FFF;
  317. &:hover {
  318. background: #026197;
  319. border-color: #026197;
  320. }
  321. }
  322. }
  323. }
  324. </style>