DriveMaintainDia.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
  2. <div>
  3. <el-dialog
  4. :title="title"
  5. :close-on-click-modal="false"
  6. draggable
  7. width="1300px"
  8. @close="close"
  9. @keyup.enter.native=""
  10. v-model="visible">
  11. <el-form :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''" :disabled="method === 'view'"
  12. label-width="160px" @submit.native.prevent>
  13. <el-divider content-position="left"><i class="el-icon-document"></i>
  14. 基本信息
  15. </el-divider>
  16. <el-row :gutter="15">
  17. <el-col :span="12">
  18. <el-form-item label="维护车辆" prop="driveNumber"
  19. :rules="[ {required: true, message:'维护车辆不能为空', trigger:'change'}]">
  20. <el-input @focus="openDriveInfo" placeholder="请填写维护车辆" :readonly="true" v-model="inputForm.driveNumber" clearable/>
  21. </el-form-item>
  22. </el-col>
  23. <el-col :span="12">
  24. <el-form-item label="维护起止时间" prop="maintainDates"
  25. :rules="[
  26. {required: true, message:'维护时间不能为空', trigger:'change'}]">
  27. <el-date-picker
  28. v-model="inputForm.maintainDates"
  29. type="daterange"
  30. start-placeholder="请选择开始时间"
  31. end-placeholder="请选择结束时间"
  32. value-format="YYYY-MM-DD"
  33. @change="checkDate"
  34. />
  35. </el-form-item>
  36. </el-col>
  37. <el-col :span="12">
  38. <el-form-item label="维护类型" prop="driveMaintainType"
  39. :rules="[ {required: true, message:'维护类型不能为空', trigger:'blur'}]">
  40. <el-select style="width:100%;" v-model="inputForm.driveMaintainType" placeholder="维护类型" clearable>
  41. <el-option
  42. v-for="item in $dictUtils.getDictList('jy_drive_maintain_type')"
  43. :key="item.value"
  44. :label="item.label"
  45. :value="item.value">
  46. </el-option>
  47. </el-select>
  48. </el-form-item>
  49. </el-col>
  50. <el-col :span="24">
  51. <el-form-item label="备注" prop="remarks"
  52. :rules="[ ]">
  53. <el-input :disabled="status === 'audit' || status === 'taskFormDetail' || method === 'view'" type="textarea" placeholder="请输入说明" maxlength="500" style="width:100%" v-model="inputForm.remarks" show-word-limit></el-input>
  54. </el-form-item>
  55. </el-col>
  56. </el-row>
  57. </el-form>
  58. <UpLoadComponent ref="uploadComponent"></UpLoadComponent>
  59. <DriveInfoDia ref="driveInfoDia" @getDrive="getDrive"></DriveInfoDia>
  60. <template #footer>
  61. <span class="dialog-footer">
  62. <el-button @click="close()" icon="el-icon-circle-close">关闭</el-button>
  63. <el-button type="primary" v-if="method != 'view'" @click="doSubmit()" icon="el-icon-circle-check" v-noMoreClick>确定</el-button>
  64. </span>
  65. </template>
  66. </el-dialog>
  67. </div>
  68. </template>
  69. <script>
  70. import XEUtils from 'xe-utils'
  71. import DriveMaintainService from '@/api/jy/DriveMaintainService'
  72. import { ElDatePicker } from 'element-plus';
  73. import UpLoadComponent from '@/views/common/UpLoadComponent'
  74. import CommonApi from '@/api/cw/common/CommonApi'
  75. import DriveInfoDia from '../driveInfo/DriveInfoDia'
  76. export default {
  77. props: {
  78. businessId: {
  79. type: String,
  80. default: ''
  81. },
  82. formReadOnly: {
  83. type: Boolean,
  84. default: false
  85. },
  86. status: {
  87. type: String,
  88. default: ''
  89. }
  90. },
  91. data () {
  92. return {
  93. title: '',
  94. method: '',
  95. loading: false,
  96. visible: false,
  97. inputForm: {
  98. id: '',
  99. driveNumber:'',
  100. driveInfoId: '',
  101. startTime:'',
  102. endTime:'',
  103. remarks: '',
  104. driveMaintainType:'',
  105. files: [], // 附件信息
  106. procInsId: '',
  107. status:'',
  108. maintainDates:[],
  109. },
  110. baseKey: '',
  111. keyWatch: '',
  112. dateList:[],
  113. programRow:'',
  114. }
  115. },
  116. DriveMaintainService:null,
  117. commonApi: null,
  118. created () {
  119. this.driveMaintainService=new DriveMaintainService()
  120. this.commonApi = new CommonApi()
  121. },
  122. mounted () {
  123. },
  124. activated () {
  125. },
  126. components: {
  127. ElDatePicker,
  128. UpLoadComponent,
  129. DriveInfoDia,
  130. },
  131. computed: {
  132. bus: {
  133. get () {
  134. this.$refs.uploadComponent.setDividerName('附件')
  135. return this.businessId
  136. },
  137. set (val) {
  138. this.businessId = val
  139. }
  140. }
  141. },
  142. watch: {
  143. 'keyWatch': {
  144. handler (newVal) {
  145. console.log('几里路')
  146. if (this.bus) {
  147. if (this.bus !== 'false') {
  148. this.init('', this.bus)
  149. }
  150. } else {
  151. this.$nextTick(() => {
  152. this.$refs.inputForm.resetFields()
  153. })
  154. }
  155. }
  156. },
  157. 'loading': {
  158. handler (newVal) {
  159. this.$emit('changeLoading', newVal)
  160. this.$refs.uploadComponent.changeLoading(newVal)
  161. }
  162. }
  163. },
  164. methods: {
  165. getKeyWatch(keyWatch) {
  166. this.keyWatch = keyWatch
  167. },
  168. init(method, id) {
  169. this.method = method
  170. this.inputForm={
  171. id: '',
  172. driveNumber:'',
  173. driveInfoId: '',
  174. maintainDates:[],
  175. remarks: '',
  176. driveMaintainType:'',
  177. files: [], // 附件信息
  178. procInsId: '',
  179. status:'',
  180. }
  181. this.inputForm.id = id
  182. this.loading = false
  183. this.visible=true
  184. if (method === 'edit') {
  185. this.title = '修改车辆维护信息'
  186. } else if (method === 'view') {
  187. this.title = '查看车辆维护信息'
  188. }
  189. this.$nextTick(() => {
  190. this.$refs.inputForm.resetFields()
  191. this.loading = true
  192. this.$refs.uploadComponent.clearUpload()
  193. if (this.commonJS.isNotEmpty(this.inputForm.id)) {
  194. console.log('this.inputForm.id', this.inputForm.id)
  195. this.driveMaintainService.queryById(this.inputForm.id).then((data)=>{
  196. this.inputForm = this.recover(this.inputForm, data)
  197. this.inputForm.files=data.files
  198. console.log('s',this.inputForm)
  199. if (this.status === 'audit' || this.status === 'taskFormDetail') {
  200. method = 'view'
  201. }
  202. console.log('me',method)
  203. this.$refs.uploadComponent.newUpload(method, this.inputForm.files, 'driveMaintain',null,null,null,null,null)
  204. this.loading = false
  205. })
  206. }
  207. })
  208. },
  209. saveForm(callback) {
  210. this.doSubmit('save', callback)
  211. },
  212. startForm(callback) {
  213. this.loading = true
  214. if (this.commonJS.isNotEmpty(this.inputForm.id)) {
  215. this.driveMaintainService.queryById(this.inputForm.id).then((data) => {
  216. if (data.status !== '0' && data.status !== '1' && data.status !== '3') { // 审核状态不是“未发起”或“暂存”或“撤回”,就弹出提示
  217. this.loading = false
  218. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  219. throw new Error()
  220. } else {
  221. this.doSubmit('start', callback)
  222. }
  223. })
  224. } else {
  225. this.doSubmit('start', callback)
  226. }
  227. },
  228. async agreeForm(callback) {
  229. console.log('进入方法')
  230. this.loading = true
  231. await this.driveMaintainService.queryById(this.inputForm.id).then((data) => {
  232. if (data.status !== '2' ) { // status的值不等于“审核中”,就弹出提示
  233. this.loading = false
  234. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  235. throw new Error()
  236. } else {
  237. this.inputForm.status= '2'
  238. this.commonApi.getTaskNameByProcInsId(this.inputForm.procInsId).then((data)=>{
  239. if (this.commonJS.isNotEmpty(data)) {
  240. if (data === '总经理审核') {
  241. this.inputForm.status = '5'
  242. }
  243. }
  244. let param = {status: this.inputForm.status, id: this.inputForm.id}
  245. this.inputForm=JSON.stringify(this.inputForm)
  246. this.driveMaintainService.updateStatusById(param).then(() => {
  247. callback(data.businessTable, data.businessId, this.inputForm)
  248. this.loading = false
  249. }).catch(() => {
  250. this.loading = false
  251. })
  252. })
  253. }
  254. })
  255. },
  256. reapplyForm(callback) {
  257. this.loading = true
  258. this.driveMaintainService.queryById(this.inputForm.id).then((data) => {
  259. if (data.status !== '4') { // 审核状态不是“驳回”,就弹出提示
  260. this.loading = false
  261. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  262. throw new Error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  263. } else {
  264. this.doSubmit('reapply', callback)
  265. }
  266. })
  267. },
  268. // 表单提交
  269. async doSubmit(status, callback) {
  270. this.loading = true
  271. console.log('5',this.inputForm)
  272. if (status === 'save') {
  273. // 暂存
  274. this.loading = true
  275. this.inputForm.status = '1'
  276. if (this.maintainDates !== undefined ||this.maintainDates !== null || this.maintainDates.length !== 0){
  277. this.inputForm.startTime=this.maintainDates[0]
  278. this.inputForm.endTime=this.maintainDates[1]
  279. }
  280. if (this.$refs.uploadComponent.checkProgress()) {
  281. this.loading = false
  282. return
  283. }
  284. this.inputForm.files = this.$refs.uploadComponent.getDataList()
  285. this.driveMaintainService.saveForm(this.inputForm).then((data) => {
  286. callback(data.businessTable, data.businessId, this.inputForm)
  287. this.loading = false
  288. }).catch(() => {
  289. this.loading = false
  290. })
  291. return
  292. } else if (status === 'start') {
  293. if (this.inputForm.maintainDates == undefined ||this.inputForm.maintainDates == null || this.inputForm.maintainDates.length <= 0 ) {
  294. this.$message.error('请选择维护时间')
  295. this.loading = false
  296. }
  297. if (this.commonJS.isEmpty(this.inputForm.driveNumber)){
  298. this.$message.error('请选择维护车辆')
  299. this.loading = false
  300. }
  301. if (this.commonJS.isEmpty(this.inputForm.driveMaintainType)){
  302. this.$message.error('请选择维护类型')
  303. this.loading = false
  304. }
  305. this.inputForm.startTime=this.inputForm.maintainDates[0]
  306. this.inputForm.endTime=this.inputForm.maintainDates[1]
  307. if (this.$refs.uploadComponent.checkProgress()) {
  308. this.loading = false
  309. return
  310. }
  311. this.inputForm.files = this.$refs.uploadComponent.getDataList()
  312. // 送审 待审核
  313. this.inputForm.status = '2'
  314. } else if (status === 'agree') {
  315. this.inputForm.status= '5'
  316. } else if (status === 'reapply') {
  317. this.inputForm.status = '2'
  318. }
  319. this.$refs['inputForm'].validate((valid) => {
  320. if (valid) {
  321. this.loading = true
  322. console.log('form',this.inputForm)
  323. this.inputForm.startTime=this.inputForm.maintainDates[0]
  324. this.inputForm.endTime=this.inputForm.maintainDates[1]
  325. this.inputForm.files = this.$refs.uploadComponent.getDataList()
  326. this.driveMaintainService.updateInfo(this.inputForm).then((data) => {
  327. this.visible = false
  328. this.$emit('refreshList')
  329. }).catch(() => {
  330. this.$refs.inputForm.resetFields()
  331. this.loading = false
  332. this.visible = false
  333. })
  334. } else {
  335. this.loading = false
  336. }
  337. })
  338. },
  339. close() {
  340. this.inputForm = {
  341. id:'',
  342. projectList:[],
  343. name:'',
  344. no:'',
  345. projectLeader:'',
  346. projectCreateDate:'',
  347. createById:'',
  348. createByName:'',
  349. createDate:'',
  350. remarks:'',
  351. files: [], // 附件信息
  352. types:[], //用印类型
  353. number:'', //用印份数
  354. projectId:'',
  355. }
  356. this.visible = false
  357. },
  358. async updateStatusById(type, callback) {
  359. this.loading = true
  360. if (type === 'reject' || type === 'reback') {
  361. this.driveMaintainService.queryById(this.inputForm.id).then((data) => {
  362. if (data.status !== '2') { // status的值不等于“审核中”,就弹出提示
  363. this.loading = false
  364. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  365. throw new Error()
  366. } else {
  367. // if (type === 'agree') {
  368. // // 同意
  369. // this.inputForm.status = '5'
  370. // }
  371. if (type === 'reject') {
  372. // 驳回
  373. this.inputForm.status = '4'
  374. }
  375. if (type === 'reback') {
  376. // 撤回
  377. this.inputForm.status = '3'
  378. }
  379. if (type === 'reject' || type === 'reback') {
  380. let param = {status: this.inputForm.status, id: this.inputForm.id}
  381. this.driveMaintainService.updateStatusById(param).then(() => {
  382. this.loading = false
  383. callback()
  384. })
  385. }
  386. }
  387. })
  388. } else if (type === 'hold') {
  389. this.driveMaintainService.queryById(this.inputForm.id).then((data) => {
  390. if (data.status !== '4') { // status的值不等于“驳回”就弹出提示
  391. this.loading = false
  392. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  393. throw new Error()
  394. } else {
  395. // 终止
  396. let param = {status: '1', id: this.inputForm.id}
  397. this.driveMaintainService.updateStatusById(param).then(() => {
  398. this.loading = false
  399. callback()
  400. })
  401. }
  402. })
  403. }
  404. },
  405. openDriveInfo() {
  406. console.log('23123123')
  407. this.$refs.driveInfoDia.init()
  408. },
  409. getDrive(rows) {
  410. console.log('1',rows)
  411. this.inputForm.driveInfoId=rows.id
  412. this.inputForm.driveNumber=rows.driveNumber
  413. },
  414. }
  415. }
  416. </script>
  417. <style scoped>
  418. /deep/ .el-input-number .el-input__inner {
  419. text-align: left;
  420. }
  421. /deep/ .vxe-footer--row .vxe-footer--column:nth-child(1) .vxe-cell--item {
  422. font-weight:700;
  423. }
  424. </style>