DriveMaintain.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. <template>
  2. <div class="page">
  3. <el-form :inline="true" v-if="searchVisible" class="query-form m-b-10" ref="searchForm" :model="searchForm" @keyup.enter.native="refreshList()" @submit.native.prevent>
  4. <!-- 搜索框-->
  5. <el-form-item label="维护车辆" prop="driveNumber">
  6. <el-input size="default" v-model="searchForm.driveNumber" placeholder="维护车辆" clearable></el-input>
  7. </el-form-item>
  8. <el-form-item label="维护类型" prop="driveMaintainType">
  9. <el-select size="default" v-model="searchForm.driveMaintainType" placeholder="维护类型" clearable>
  10. <el-option
  11. v-for="item in $dictUtils.getDictList('jy_drive_maintain_type')"
  12. :key="item.value"
  13. :label="item.label"
  14. :value="item.value">
  15. </el-option>
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="维护时间" prop="dates">
  19. <el-date-picker
  20. v-model="searchForm.dates"
  21. type="daterange"
  22. start-placeholder="请选择开始时间"
  23. end-placeholder="请选择结束时间"
  24. value-format="YYYY-MM-DD">
  25. </el-date-picker>
  26. </el-form-item>
  27. <el-form-item>
  28. <!--<el-button type="default" @click="showHide" :icon="showHideIcon">{{showHideName}}</el-button>-->
  29. <el-button type="primary" @click="refreshList()" icon="el-icon-search">查询</el-button>
  30. <el-button @click="resetSearch()" icon="el-icon-refresh-right">重置</el-button>
  31. </el-form-item>
  32. </el-form>
  33. <div class="jp-table top" style="">
  34. <vxe-toolbar ref="toolbarRef" :refresh="{query: refreshList}" export custom>
  35. <template #buttons>
  36. <el-button v-if="hasPermission('drive:info:add')" :disabled="isAdmin" type="primary" icon="el-icon-plus" @click="add()">新建</el-button>
  37. </template>
  38. <template #tools>
  39. <vxe-button
  40. text
  41. type="primary"
  42. :title="searchVisible ? '收起检索' : '展开检索'"
  43. icon="vxe-icon-search"
  44. class="tool-btn"
  45. @click="searchVisible = !searchVisible"
  46. ></vxe-button>
  47. </template>
  48. </vxe-toolbar>
  49. <div style="height: calc(100% - 90px)">
  50. <vxe-table
  51. border="inner"
  52. auto-resize
  53. resizable
  54. height="auto"
  55. :loading="loading"
  56. ref="driveMaintainTable"
  57. show-header-overflow
  58. show-overflow
  59. highlight-hover-row
  60. :menu-config="{}"
  61. :export-config="{
  62. remote: true,
  63. filename: `嘉溢车辆维护数据${moment(new Date()).format('YYYY-MM-DD')}`,
  64. sheetName: `嘉溢车辆维护数据${moment(new Date()).format('YYYY-MM-DD')}`,
  65. exportMethod: exportMethod,
  66. types: ['xls'],
  67. modes: ['current', 'selected', 'all']
  68. }"
  69. @sort-change="sortChangeHandle"
  70. :sort-config="{remote:true}"
  71. :data="dataList"
  72. :checkbox-config="{}">
  73. <vxe-column type="seq" width="60" title="序号"></vxe-column>
  74. <vxe-column min-width="160" align="center" title="维护车辆" field="driveNumber">
  75. <template #default="scope">
  76. <el-link type="primary" :underline="false" @click="view(scope.row)">{{scope.row.driveNumber}}</el-link>
  77. </template>
  78. </vxe-column>
  79. <vxe-column min-width="160" align="center" title="维护类型" field="driveMaintainType">
  80. <template #default="scope">
  81. {{ $dictUtils.getDictLabel("jy_drive_maintain_type", scope.row.driveMaintainType, '-') }}
  82. </template>
  83. </vxe-column>
  84. <vxe-column min-width="160" align="center" title="维护开始时间" field="startTime"></vxe-column>
  85. <vxe-column min-width="160" align="center" title="维护结束时间" field="endTime"></vxe-column>
  86. <vxe-column min-width="160" align="center" title="申请人" field="createName"></vxe-column>
  87. <vxe-column min-width="160" align="center" title="申请时间" field="createTime"></vxe-column>
  88. <vxe-column min-width="150px" align="center" title="申请状态" field="status" fixed="right">
  89. <template #default="scope">
  90. <el-button @click="detail(scope.row)" :type="$dictUtils.getDictLabel('program_project_list_info_status_info', scope.row.status, '')" effect="dark" >{{$dictUtils.getDictLabel("program_project_list_info_status", scope.row.status, '未登记')}} </el-button>
  91. </template>
  92. </vxe-column>
  93. <vxe-column title="操作" width="150px" fixed="right" align="center">
  94. <template #default="scope">
  95. <div v-if="isJyAdmin">
  96. <el-button size="small" text type="primary" v-if="hasPermission('admin:edit') && isJyAdmin" @click="adminEdit(scope.row)">修改</el-button>
  97. <el-button text type="primary" size="small" v-if="hasPermission('admin:del') && isJyAdmin" @click="del(scope.row.id)">删除</el-button>
  98. </div>
  99. <div v-else>
  100. <el-button v-if="hasPermission('drive:info:add')&&(scope.row.status === '0'||scope.row.status === '1'|| scope.row.status === '3') &&scope.row.createById === $store.state.user.id" size="small" text type="primary" @click="edit(scope.row)">修改</el-button>
  101. <el-button text type="primary" size="small" v-if="hasPermission('drive:info:del')&&(scope.row.status==='0' || scope.row.status==='1'|| scope.row.status==='3') &&scope.row.createById === $store.state.user.id" @click="del(scope.row.id)">删除</el-button>
  102. <!-- 当前申请人撤回-->
  103. <el-button v-if="hasPermission('drive:info:add')&&scope.row.createById === $store.state.user.id && scope.row.status==='2'" text type="primary" size="small" @click="reback(scope.row)">撤回</el-button>
  104. <el-button v-if="hasPermission('drive:info:add')&&scope.row.status==='2' && checkIsAudit(scope.row)" text type="primary" size="small" @click="examine(scope.row)">审核</el-button>
  105. <el-button v-if="hasPermission('drive:info:add')&&scope.row.status === '4'&&scope.row.createById === $store.state.user.id" text type="primary" size="small" @click="adjust(scope.row)">驳回调整</el-button>
  106. </div>
  107. </template>
  108. </vxe-column>
  109. </vxe-table>
  110. <vxe-pager
  111. background
  112. :current-page="tablePage.currentPage"
  113. :page-size="tablePage.pageSize"
  114. :total="tablePage.total"
  115. :page-sizes="[10, 20, 100, 1000, {label: '全量数据', value: 1000000}]"
  116. :layouts="['PrevPage', 'JumpNumber', 'NextPage', 'FullJump', 'Sizes', 'Total']"
  117. @page-change="currentChangeHandle">
  118. </vxe-pager>
  119. </div>
  120. </div>
  121. <DriveMaintainDia ref="driveMaintainDia" @refreshList="refreshList"></DriveMaintainDia>
  122. </div>
  123. </template>
  124. <script>
  125. import DriveMaintainService from '@/api/jy/DriveMaintainService'
  126. import taskService from '@/api/flowable/taskService'
  127. import processService from '@/api/flowable/processService'
  128. import userService from '@/api/sys/userService'
  129. import pick from 'lodash.pick'
  130. import DriveMaintainDia from './DriveMaintainDia'
  131. export default {
  132. data () {
  133. return {
  134. dialogTableVisible:false,
  135. searchVisible: true,
  136. showHideItem: false,
  137. showHideIcon: 'el-icon-arrow-down',
  138. showHideName: '展示',
  139. num: 0,
  140. searchForm: {
  141. driveNumber: '',
  142. driveMaintainType: '',
  143. dates:[]
  144. },
  145. dataList: [],
  146. tablePage: {
  147. total: 0,
  148. currentPage: 1,
  149. pageSize: 10,
  150. orders: []
  151. },
  152. tableKey: '',
  153. loading: false,
  154. processDefinitionId: '',
  155. processDefinitionIdAccount:'',
  156. procDefKey: '',
  157. procDefKeyAccount: '',
  158. isAdmin: false,
  159. create: '',
  160. gridData:[],
  161. typeData:[],
  162. isJyAdmin:false
  163. }
  164. },
  165. DriveMaintainService:null,
  166. created () {
  167. this.driveMaintainService=new DriveMaintainService()
  168. },
  169. components: {
  170. DriveMaintainDia
  171. },
  172. computed: {
  173. userName () {
  174. return this.$store.state.user.name
  175. },
  176. user () {
  177. this.createName = this.$store.state.user.name
  178. return this.$store.state.user
  179. }
  180. },
  181. mounted () {
  182. this.$nextTick(() => {
  183. // 将表格和工具栏进行关联
  184. const $table = this.$refs.driveMaintainTable;
  185. const $toolbar = this.$refs.toolbarRef;
  186. $table.connect($toolbar);
  187. });
  188. this.refreshList()
  189. },
  190. activated () {
  191. this.refreshList()
  192. },
  193. methods: {
  194. showHide () {
  195. if (this.showHideItem === false) {
  196. this.showHideItem = true
  197. this.showHideIcon = 'el-icon-arrow-up'
  198. this.showHideName = '隐藏'
  199. } else {
  200. this.showHideItem = false
  201. this.showHideIcon = 'el-icon-arrow-down'
  202. this.showHideName = '展示'
  203. }
  204. },
  205. // 新增
  206. add () {
  207. // 读取流程表单
  208. let tabTitle = `发起流程【嘉溢-车辆维护】`
  209. let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了 [嘉溢-车辆维护]`
  210. taskService.getTaskDef({ procDefId: this.processDefinitionId,
  211. status: 'startAndHold'}).then((data) => {
  212. this.$router.push({
  213. path: '/flowable/task/TaskForm',
  214. query: {
  215. ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
  216. procDefId: this.processDefinitionId,
  217. procDefKey: this.procDefKey,
  218. status: 'startAndHold',
  219. title: tabTitle,
  220. formType: data.formType,
  221. formUrl: data.formUrl,
  222. formTitle: processTitle,
  223. businessId: 'false',
  224. isShow: false,
  225. routePath: '/jy/driveMaintain/DriveMaintain'
  226. }
  227. })
  228. })
  229. },
  230. // 修改
  231. edit (row) {
  232. let tabTitle = `发起流程【嘉溢-车辆维护】`
  233. let processTitle = `${this.userName} 在 ${this.moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了 [嘉溢-车辆维护]`
  234. taskService.getTaskDef({ procDefId: this.processDefinitionId,
  235. businessId: row.id,
  236. businessTable: 'jy_drive_maintain',
  237. status: 'startAndHold'}).then((data) => {
  238. this.$router.push({
  239. path: '/flowable/task/TaskForm',
  240. query: {
  241. ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
  242. procDefId: this.processDefinitionId,
  243. procDefKey: this.procDefKey,
  244. status: 'startAndHold',
  245. title: tabTitle,
  246. formType: data.formType,
  247. formUrl: data.formUrl,
  248. formTitle: processTitle,
  249. businessId: row.id,
  250. businessTable: 'jy_drive_maintain',
  251. isShow: false,
  252. routePath: '/jy/driveMaintain/DriveMaintain'
  253. }
  254. })
  255. })
  256. },
  257. // 查看
  258. view (row) {
  259. this.$refs.driveMaintainDia.init('view',row.id);
  260. },
  261. // 查询当前用户是否是管理员用户
  262. checkIsAdmin () {
  263. userService.is().then((data) => {
  264. this.isAdmin = data
  265. })
  266. },
  267. // 获取数据列表
  268. refreshList () {
  269. this.loading = true
  270. this.driveMaintainService.list({
  271. 'current': this.tablePage.currentPage,
  272. 'size': this.tablePage.pageSize,
  273. 'orders': this.tablePage.orders,
  274. ...this.searchForm
  275. }).then((data) => {
  276. console.log('x',data.records)
  277. this.dataList = data.records
  278. this.tablePage.total = data.total
  279. this.tableKey = Math.random()
  280. this.loading = false
  281. })
  282. this.checkIsAdmin()
  283. this.checkIsJyAdmin()
  284. processService.getByName('嘉溢-车辆维护').then((data) => {
  285. if (!this.commonJS.isEmpty(data.id)) {
  286. this.processDefinitionId = data.id
  287. this.procDefKey = data.key
  288. }
  289. })
  290. },
  291. //判断当前登陆人是否是admin
  292. checkIsJyAdmin(){
  293. userService.checkIsJyAdmin().then((data)=>{
  294. this.isJyAdmin = data
  295. })
  296. },
  297. // 当前页
  298. currentChangeHandle ({ currentPage, pageSize }) {
  299. this.tablePage.currentPage = currentPage
  300. this.tablePage.pageSize = pageSize
  301. this.refreshList()
  302. },
  303. // 排序
  304. sortChangeHandle (column) {
  305. this.tablePage.orders = []
  306. if (column.order != null) {
  307. this.tablePage.orders.push({column: this.$utils.toLine(column.property), asc: column.order === 'asc'})
  308. }
  309. this.refreshList()
  310. },
  311. // 删除
  312. del (id) {
  313. let ids = id || this.$refs.clientTable.getCheckboxRecords().map(item => {
  314. return item.id
  315. }).join(',')
  316. this.$confirm(`确定删除所选项吗?`, '提示', {
  317. confirmButtonText: '确定',
  318. cancelButtonText: '取消',
  319. type: 'warning'
  320. }).then(() => {
  321. this.loading = true
  322. this.driveMaintainService.delete(ids).then((data) => {
  323. this.$message.success(data)
  324. this.refreshList()
  325. this.loading = false
  326. })
  327. })
  328. },
  329. resetSearch () {
  330. this.$refs.searchForm.resetFields()
  331. this.searchForm.driveInfoId = '' // 重置时清空项目id
  332. this.refreshList()
  333. },
  334. // 查看修改流程结果
  335. detail (row) {
  336. if (row.status !== '0' && row.status !== '1') {
  337. this.driveMaintainService.queryById(row.id).then((da)=>{
  338. // eslint-disable-next-line eqeqeq
  339. taskService.getTaskDef({
  340. procInsId: row.procInsId,
  341. procDefId: this.processDefinitionId
  342. }).then((data) => {
  343. this.$router.push({
  344. path: '/flowable/task/TaskFormDetail',
  345. query: {
  346. ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title'),
  347. isShow: 'false',
  348. readOnly: true,
  349. title: '车辆维护' + '流程详情',
  350. formTitle: '车辆维护' + '流程详情',
  351. businessId: row.id,
  352. status: 'reback',
  353. method: 'view'
  354. }
  355. })
  356. })
  357. })
  358. }
  359. },
  360. // 撤回入库修改
  361. reback (row) {
  362. this.$confirm(`确定要撤回该申请吗?`, '提示', {
  363. confirmButtonText: '确定',
  364. cancelButtonText: '取消',
  365. type: 'warning'
  366. }).then(() => {
  367. this.driveMaintainService.queryById(row.id).then((data) => {
  368. if (data.status !== '2') { // status的值不等于“审核中”,就弹出提示
  369. this.$message.error('数据已发生改变或不存在,请刷新数据')
  370. this.refreshList()
  371. } else {
  372. processService.revokeProcIns(row.procInsId).then((data) => {
  373. let form = {status: '3', id: row.id}
  374. this.driveMaintainService.updateStatusById(form)
  375. this.$message.success(data)
  376. this.refreshList()
  377. })
  378. }
  379. })
  380. })
  381. },
  382. // 驳回后调整
  383. adjust (row) {
  384. this.driveMaintainService.queryById(row.id).then((data) => {
  385. if (data.status !== '4') { // status的值不等于“驳回”,就弹出提示
  386. this.$message.error('数据已发生改变或不存在,请刷新数据')
  387. this.refreshList()
  388. } else {
  389. this.todo(row)
  390. }
  391. })
  392. },
  393. // 审核
  394. examine (row) {
  395. this.driveMaintainService.queryById(row.id).then((data) => {
  396. if (data.status !== '2') { // status的值不等于“审核中”,就弹出提示
  397. this.$message.error('数据已发生改变或不存在,请刷新数据')
  398. this.refreshList()
  399. } else {
  400. this.todo(row)
  401. }
  402. })
  403. },
  404. // 审核或重新调整跳转
  405. todo (row) {
  406. let cUser = false
  407. taskService.getTaskDefInfo({
  408. taskId: row.taskId
  409. }).then((data) => {
  410. this.$router.push({
  411. path: '/flowable/task/TaskForm',
  412. query: {
  413. ...pick(data, 'formType', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId'),
  414. isShow: false,
  415. formReadOnly: true,
  416. formTitle: `${data.taskName}`,
  417. cUser: cUser,
  418. title: `审批【${data.taskName || ''}】`,
  419. routePath: '/jy/driveMaintain/DriveMaintain', // 数据处理后需要跳转的页面路径
  420. }
  421. })
  422. })
  423. },
  424. // 查询当前登录人是否是数据的审核人
  425. checkIsAudit (row) {
  426. let loginUserId = this.$store.state.user.id // 获取当前登录用户id
  427. if (this.commonJS.isNotEmpty(row.auditUserIds)) {
  428. for (const userId of row.auditUserIds) {
  429. if (userId === loginUserId) { // 当数据的审核人中包含当前登录人id时,返回true
  430. return true
  431. }
  432. }
  433. }
  434. return false
  435. },
  436. adminEdit(row){
  437. this.$refs.driveMaintainDia.init('edit',row.id);
  438. },
  439. // 自定义服务端导出
  440. exportMethod ({ options }) {
  441. // 传给服务端的参数
  442. const params = {
  443. 'current': this.tablePage.currentPage,
  444. 'size': this.tablePage.pageSize,
  445. 'orders': this.tablePage.orders,
  446. ...this.searchForm,
  447. filename: options.filename,
  448. sheetName: options.sheetName,
  449. isHeader: options.isHeader,
  450. original: options.original,
  451. mode: options.mode,
  452. selectIds: options.mode === 'selected' ? options.map(item => item.id) : [],
  453. exportFields: options.columns.map(column => column.property)
  454. }
  455. return this.driveMaintainService.exportFile(params).then((res) => {
  456. // 将二进制流文件写入excel表,以下为重要步骤
  457. this.$utils.downloadExcel(res, options.filename+ ".xls")
  458. }).catch(function (err) {
  459. if (err.response) {
  460. console.log(err.response)
  461. }
  462. })
  463. },
  464. }
  465. }
  466. </script>