Submit.vue 11 KB

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