CheckJob.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. <template>
  2. <a-card :bordered="false">
  3. <div v-show="visible">
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline">
  6. <a-row :gutter="48">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="编码/名称">
  9. <a-input v-model="queryParam.keyword" placeholder="编码/名称"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="设备旧号">
  14. <a-input v-model="queryParam.zbh" placeholder="请输入设备旧号"/>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="设备等级">
  19. <a-select v-model="queryParam.sblevel" placeholder="请选择">
  20. <a-select-option
  21. v-for="(label,value) in levelMap"
  22. :key="value"
  23. :label="label"
  24. :value="parseInt(value)">{{ label }}
  25. </a-select-option>
  26. </a-select>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24">
  30. <a-form-item label="设备类型">
  31. <a-tree-select
  32. style="width: 100%"
  33. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  34. :treeData="treeData"
  35. :treeNodeFilterProp="'title'"
  36. :showSearch="true"
  37. v-model="queryParam.typeId"
  38. placeholder="请选择"
  39. >
  40. </a-tree-select>
  41. </a-form-item>
  42. </a-col>
  43. <a-col :md="6" :sm="24">
  44. <a-form-item label="维护等级">
  45. <a-select v-model="queryParam.standardLevel" placeholder="请选择">
  46. <a-select-option
  47. v-for="(label,value) in standardLevelMap"
  48. :key="value"
  49. :label="label"
  50. :value="parseInt(value)">{{ label }}
  51. </a-select-option>
  52. </a-select>
  53. </a-form-item>
  54. </a-col>
  55. <a-col :md="6" :sm="24">
  56. <a-form-item label="周期类型">
  57. <a-select v-model="queryParam.periodType" placeholder="请选择">
  58. <a-select-option
  59. v-for="(label,value) in periodTypeMap"
  60. :key="value"
  61. :label="label"
  62. :value="parseInt(value)">{{ label }}
  63. </a-select-option>
  64. </a-select>
  65. </a-form-item>
  66. </a-col>
  67. <a-col :md="6" :sm="24">
  68. <a-form-item label="执行人姓名">
  69. <a-input v-model="queryParam.checkUserName" placeholder="请输入执行人姓名"/>
  70. </a-form-item>
  71. </a-col>
  72. <a-col :md="6" :sm="24">
  73. <a-form-item label="任务状态">
  74. <a-select
  75. v-model="queryParam.status"
  76. placeholder="请选择">
  77. <a-select-option
  78. v-for="(label,value) in statusMap"
  79. :key="value"
  80. :label="label"
  81. :value="parseInt(value)">{{ label }}
  82. </a-select-option>
  83. </a-select>
  84. </a-form-item>
  85. </a-col>
  86. <a-col :md="6" :sm="24">
  87. <a-form-item label="起始日期">
  88. <a-date-picker
  89. v-model="queryParam.searchStartTime"
  90. style="width: 100%"
  91. :format="BaseTool.Date.PICKER_NORM_DATETIME_PATTERN"
  92. />
  93. </a-form-item>
  94. </a-col>
  95. <a-col :md="6" :sm="24">
  96. <a-form-item label="结束日期">
  97. <a-date-picker
  98. v-model="queryParam.searchEndTime"
  99. style="width: 100%"
  100. :format="BaseTool.Date.PICKER_NORM_DATETIME_PATTERN"
  101. />
  102. </a-form-item>
  103. </a-col>
  104. <a-col :md="24" :sm="24">
  105. <span class="table-page-search-submitButtons">
  106. <a-button type="primary" @click="handleOk">查询</a-button>
  107. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  108. </span>
  109. </a-col>
  110. </a-row>
  111. </a-form>
  112. </div>
  113. <div class="table-operator">
  114. <a-button v-if="$auth('check-polling-jobs-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>
  115. <a-button style="margin-left: 8px" v-if="($auth('check-spot-jobs-export') || $auth('check-polling-jobs-export'))" type="primary" icon="download" @click="doExport">导出</a-button>
  116. <a-button style="margin-left: 8px" type="success" @click="handleSeven">本周</a-button>
  117. <a-button style="margin-left: 8px" type="success" @click="handleMonth">本月</a-button>
  118. <a-button style="margin-left: 8px" type="success" @click="handleTuiCalendar">日历图</a-button>
  119. <a-button style="margin-left: 8px" type="primary" @click="handleExecuteBatch" v-if="selectedRowKeys.length > 0">
  120. <a-icon style="margin-left: 8px" type="plus"/>
  121. 批量接收
  122. </a-button>
  123. <a-button style="margin-left: 8px" type="primary" v-if="selectedRowKeys.length > 0" @click="handleFinishBatch">
  124. <a-icon type="plus"/>
  125. 批量完成
  126. </a-button>
  127. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && ($auth('check-spot-jobs-edit') || $auth('check-polling-jobs-edit'))">
  128. <a-menu slot="overlay">
  129. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  130. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  131. </a-popconfirm>
  132. </a-menu>
  133. <a-button style="margin-left: 8px">
  134. 批量操作 <a-icon type="down" />
  135. </a-button>
  136. </a-dropdown>
  137. </div>
  138. <s-table
  139. ref="table"
  140. size="default"
  141. rowKey="id"
  142. :columns="columns"
  143. :scroll="{x: 1, y: BaseTool.Constant.scrollY }"
  144. :data="loadData"
  145. :alert="options.alert"
  146. :rowSelection="options.rowSelection"
  147. showPagination="auto"
  148. >
  149. <span slot="action" slot-scope="record">
  150. <template>
  151. <a @click="handleView(record)">查看</a>
  152. <template v-if="record.status == DictCache.VALUE.CHECK_JOB_STATUS.NOT_EXECUTE">
  153. <a-divider type="vertical" />
  154. <a @click="handleExecute(record)">接收</a>
  155. </template>
  156. <template v-if="record.status === DictCache.VALUE.CHECK_JOB_STATUS.EXECUTING">
  157. <a-divider type="vertical" />
  158. <a @click="handleFinish(record)">完成</a>
  159. </template>
  160. <template v-if="record.status == DictCache.VALUE.CHECK_JOB_STATUS.NOT_EXECUTE || record.status === DictCache.VALUE.CHECK_JOB_STATUS.EXECUTING">
  161. <a-divider type="vertical" />
  162. <a @click="handleEdit(record)">修改</a>
  163. </template>
  164. <!-- <a-divider type="vertical" />-->
  165. <!-- <a-popconfirm v-if="$auth('check-jobs-del')" title="是否要删除该条数据?" @confirm="batchDelete(record.id)">-->
  166. <!-- <a>删除</a>-->
  167. <!-- </a-popconfirm>-->
  168. </template>
  169. </span>
  170. <span slot="status" slot-scope="text">
  171. <badge
  172. :status="DictCache.COLOR.JOB_STATUS[text]"
  173. :text="statusMap[text]" />
  174. </span>
  175. <span slot="stopFlag" slot-scope="text">
  176. <badge
  177. :status="DictCache.COLOR.YES_NO[text]"
  178. :text="sbStatusMap[text]" />
  179. </span>
  180. </s-table>
  181. </div>
  182. <base-form :check-type="checkType" ref="baseModal" @ok="handleOk"/>
  183. <detail :check-type="checkType" ref="detailModal" @ok="handleOk"/>
  184. </a-card>
  185. </template>
  186. <script>
  187. import { STable, Ellipsis } from '@/components'
  188. import BaseForm from './modules/BaseForm'
  189. import Detail from './modules/Detail'
  190. import { getCheckJobPage, deleteCheckJobs, fetchCheckJob, exportCheckJob, executeJob, executeJobBatch, finishJobBatch, queryTuiCalendarIgnores } from '@/api/check/checkjob'
  191. import { fetchSbTypeTree } from '@/api/sb/type'
  192. import DictCache from '@/utils/dict'
  193. export default {
  194. name: 'CheckJobList',
  195. components: {
  196. STable,
  197. Ellipsis,
  198. BaseForm,
  199. Detail
  200. },
  201. props: {
  202. /**
  203. * 检查类型: 1-负责 2-巡检
  204. */
  205. checkType: {
  206. type: Number,
  207. default: 1
  208. },
  209. filter: {
  210. type: Number,
  211. default: -1
  212. },
  213. status: {
  214. type: Number,
  215. default: null
  216. },
  217. receiveOvertime: {
  218. type: Boolean,
  219. default: null
  220. },
  221. statusList: {
  222. type: Array,
  223. default: () => {
  224. return [DictCache.VALUE.CHECK_JOB_STATUS.NOT_EXECUTE, DictCache.VALUE.CHECK_JOB_STATUS.EXECUTING]
  225. }
  226. }
  227. },
  228. data () {
  229. this.names = ['负责', '巡检']
  230. return {
  231. visible: true,
  232. // 查询参数
  233. queryParam: {
  234. type: this.checkType,
  235. searchStartTime: null,
  236. searchEndTime: null,
  237. filter: this.filter,
  238. status: this.status,
  239. receiveOvertime: this.receiveOvertime,
  240. statusList: this.statusList
  241. },
  242. treeData: [],
  243. // 表头
  244. columns: [
  245. {
  246. title: '序号',
  247. dataIndex: 'index',
  248. customRender: (text, record, index) => {
  249. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  250. },
  251. checked: true,
  252. width: '100px'
  253. },
  254. {
  255. title: '标准编码',
  256. dataIndex: 'standardNo',
  257. checked: true,
  258. width: '150px'
  259. },
  260. {
  261. title: '设备新号',
  262. dataIndex: 'sbNo',
  263. checked: true,
  264. width: '150px'
  265. },
  266. {
  267. title: '设备名称',
  268. dataIndex: 'sbName',
  269. checked: true,
  270. width: '200px'
  271. },
  272. {
  273. title: '设备部位',
  274. dataIndex: 'partName',
  275. checked: true,
  276. width: '150px'
  277. },
  278. {
  279. title: '维护等级',
  280. dataIndex: 'standardLevel',
  281. width: '100px',
  282. checked: true,
  283. customRender: (text, record, index) => {
  284. return this.BaseTool.Table.getMapText(this.standardLevelMap, text)
  285. }
  286. },
  287. {
  288. title: '任务要求',
  289. dataIndex: 'requirement',
  290. checked: true,
  291. width: '200px'
  292. },
  293. {
  294. title: '计划周期',
  295. dataIndex: 'period',
  296. checked: true,
  297. width: '150px',
  298. customRender: (text, record, index) => {
  299. return text + this.BaseTool.Table.getMapText(this.periodTypeMap, record.periodType)
  300. }
  301. },
  302. /* {
  303. title: '计划名称',
  304. dataIndex: 'planName',
  305. checked: true
  306. }, */
  307. {
  308. title: '负责人',
  309. dataIndex: 'checkUserName',
  310. checked: true,
  311. width: '150px'
  312. },
  313. // {
  314. // title: '负责部件',
  315. // dataIndex: 'partName',
  316. // checked: true
  317. // },
  318. /* {
  319. title: '截至日期',
  320. dataIndex: 'endTime',
  321. checked: true,
  322. width: '200px'
  323. }, */
  324. {
  325. title: '标准工时',
  326. dataIndex: 'standardHours',
  327. checked: true,
  328. width: '200px'
  329. },
  330. {
  331. title: '实际工时',
  332. dataIndex: 'realHours',
  333. checked: true,
  334. width: '200px'
  335. },
  336. {
  337. title: '实际结束时间',
  338. dataIndex: 'actualEndTime',
  339. checked: true,
  340. width: '200px'
  341. },
  342. {
  343. title: '执行日期',
  344. dataIndex: 'startTime',
  345. checked: true,
  346. fixed: 'right',
  347. width: '200px'
  348. },
  349. {
  350. title: '实际执行日期',
  351. dataIndex: 'actualStartTime',
  352. checked: true,
  353. fixed: 'right',
  354. width: '200px',
  355. customRender: (text, record, index) => {
  356. return (text == null ? '暂无' : this.BaseTool.Date.formatter(text, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN))
  357. }
  358. },
  359. {
  360. title: '是否延期',
  361. dataIndex: 'receiveOvertime',
  362. checked: true,
  363. fixed: 'right',
  364. width: '100px',
  365. customRender: (text, record, index) => {
  366. return ((text === null || text === 0) ? '否' : '是')
  367. }
  368. },
  369. {
  370. title: '任务状态',
  371. dataIndex: 'status',
  372. width: '100px',
  373. fixed: 'right',
  374. checked: true,
  375. scopedSlots: { customRender: 'status' }
  376. },
  377. {
  378. title: '操作',
  379. key: 'action',
  380. width: '150px',
  381. fixed: 'right',
  382. align: 'center',
  383. scopedSlots: { customRender: 'action' },
  384. checked: true
  385. }
  386. ],
  387. // 下拉框map
  388. levelMap: {},
  389. standardLevelMap: {},
  390. statusMap: {},
  391. sbStatusMap: {},
  392. periodTypeMap: {},
  393. // 加载数据方法 必须为 Promise 对象
  394. loadData: parameter => {
  395. parameter = {
  396. ...parameter,
  397. ...this.queryParam,
  398. dataScope: {
  399. }
  400. }
  401. return getCheckJobPage(Object.assign(parameter, this.queryParam))
  402. .then(res => {
  403. return res.data
  404. })
  405. },
  406. selectedRowKeys: [],
  407. selectedRows: [],
  408. options: {
  409. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  410. rowSelection: {
  411. selectedRowKeys: this.selectedRowKeys,
  412. onChange: this.onSelectChange
  413. }
  414. },
  415. optionAlertShow: false
  416. }
  417. },
  418. created () {
  419. // 下拉框map
  420. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_JOB_STATUS)
  421. this.sbStatusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  422. this.periodTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_PERIOD_TYPE)
  423. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_LEVEL)
  424. this.standardLevelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_LEVEL)
  425. fetchSbTypeTree().then(res => {
  426. this.treeData = res.data
  427. })
  428. this.tableOption()
  429. },
  430. methods: {
  431. tableOption () {
  432. if (!this.optionAlertShow) {
  433. this.options = {
  434. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  435. rowSelection: {
  436. selectedRowKeys: this.selectedRowKeys,
  437. onChange: this.onSelectChange,
  438. getCheckboxProps: record => ({
  439. props: {
  440. disabled: false,
  441. name: record.id
  442. }
  443. })
  444. }
  445. }
  446. this.optionAlertShow = true
  447. } else {
  448. this.options = {
  449. alert: false,
  450. rowSelection: null
  451. }
  452. this.optionAlertShow = false
  453. }
  454. },
  455. batchDelete (id) {
  456. let ids = []
  457. if (this.BaseTool.String.isBlank(id)) {
  458. const length = this.selectedRows.length
  459. if (length === 0) {
  460. this.$message.info('请选择要删除的记录')
  461. return
  462. }
  463. ids = this.selectedRows.map(item => item.id)
  464. } else {
  465. ids = [id]
  466. }
  467. deleteCheckJobs(ids).then(res => {
  468. this.$message.info('删除成功')
  469. this.handleOk()
  470. this.$refs.table.clearSelected()
  471. })
  472. },
  473. handleEdit (record) {
  474. fetchCheckJob({ id: record.id }).then(res => {
  475. const modal = this.$refs.baseModal
  476. modal.base(res.data)
  477. })
  478. },
  479. handleFinish (record) {
  480. fetchCheckJob({ id: record.id }).then(res => {
  481. const modal = this.$refs.baseModal
  482. modal.base(res.data)
  483. })
  484. },
  485. handleExecute (record) {
  486. executeJob({ id: record.id }).then(res => {
  487. this.handleOk()
  488. })
  489. },
  490. handleView (record) {
  491. fetchCheckJob({ id: record.id }).then(res => {
  492. const modal = this.$refs.detailModal
  493. modal.base(res.data)
  494. })
  495. },
  496. handleOk () {
  497. this.visible = true
  498. this.queryParam.searchStartTime = this.queryParam.searchStartTime ? this.BaseTool.Date.formatter(this.queryParam.searchStartTime, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN) : null
  499. this.queryParam.searchEndTime = this.queryParam.searchEndTime ? this.BaseTool.Date.formatter(this.queryParam.searchEndTime, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN) : null
  500. this.$refs.table.refresh()
  501. },
  502. onSelectChange (selectedRowKeys, selectedRows) {
  503. this.selectedRowKeys = selectedRowKeys
  504. this.selectedRows = selectedRows
  505. },
  506. resetSearchForm () {
  507. this.queryParam = {
  508. type: this.checkType,
  509. searchStartTime: null,
  510. searchEndTime: null,
  511. filter: this.filter,
  512. status: this.status,
  513. statusList: this.statusList
  514. }
  515. this.$refs.table.refresh(true)
  516. },
  517. handleSeven () {
  518. var now = new Date()
  519. var nowTime = now.getTime()
  520. var day = now.getDay()
  521. var oneDayTime = 24 * 60 * 60 * 1000
  522. // 显示周一
  523. var MondayTime = nowTime - (day - 1) * oneDayTime
  524. // 显示周日
  525. var SundayTime = nowTime + (7 - day) * oneDayTime
  526. // 初始化日期时间
  527. var monday = new Date(MondayTime)
  528. var sunday = new Date(SundayTime)
  529. this.queryParam.searchStartTime = this.BaseTool.Date.formatter(monday, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  530. this.queryParam.searchEndTime = this.BaseTool.Date.formatter(sunday, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  531. this.$refs.table.refresh()
  532. },
  533. handleMonth () {
  534. var now = new Date() // 当前日期
  535. var nowMonth = now.getMonth() // 当前月
  536. var nowYear = now.getFullYear() // 当前年
  537. // 本月的开始时间
  538. var monthStartDate = new Date(nowYear, nowMonth, 1)
  539. // 本月的结束时间
  540. var monthEndDate = new Date(nowYear, nowMonth + 1, 0)
  541. this.queryParam.searchStartTime = this.BaseTool.Date.formatter(monthStartDate, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  542. this.queryParam.searchEndTime = this.BaseTool.Date.formatter(monthEndDate, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  543. this.$refs.table.refresh()
  544. },
  545. getBeforeDate (num, time) {
  546. const n = num
  547. let d = ''
  548. if (time) {
  549. d = new Date(time)
  550. } else {
  551. d = new Date()
  552. }
  553. let year = d.getFullYear()
  554. let mon = d.getMonth() + 1
  555. let day = d.getDate()
  556. if (day <= n) {
  557. if (mon > 1) {
  558. mon = mon - 1
  559. } else {
  560. year = year - 1
  561. mon = 12
  562. }
  563. }
  564. d.setDate(d.getDate() - n)
  565. year = d.getFullYear()
  566. mon = d.getMonth() + 1
  567. day = d.getDate()
  568. const s = year + '-' + (mon < 10 ? ('0' + mon) : mon) + '-' + (day < 10 ? ('0' + day) : day)
  569. return s
  570. },
  571. handleExecuteBatch () {
  572. let ids = []
  573. const length = this.selectedRowKeys.length
  574. if (length === 0) {
  575. this.$message.info('请选择记录')
  576. return
  577. }
  578. console.log(this.selectedRowKeys)
  579. ids = this.selectedRowKeys
  580. executeJobBatch(ids).then(res => {
  581. this.$message.info('接收成功')
  582. this.handleOk()
  583. })
  584. },
  585. handleFinishBatch () {
  586. let ids = []
  587. const length = this.selectedRowKeys.length
  588. if (length === 0) {
  589. this.$message.info('请选择记录')
  590. return
  591. }
  592. ids = this.selectedRowKeys
  593. finishJobBatch(ids).then(res => {
  594. this.$message.info('完成成功')
  595. this.handleOk()
  596. })
  597. },
  598. handleTuiCalendar () {
  599. const that = this
  600. queryTuiCalendarIgnores({ type: 2 }).then(res => {
  601. const a = document.createElement('a')
  602. a.target = '_blank'
  603. a.href = '/tui-calendar/checkJobCalendar.html?'
  604. localStorage.setItem('calendarList', JSON.stringify(res.data.calendarList))
  605. var scheduleList = res.data.scheduleList
  606. scheduleList.forEach((item) => {
  607. item.start = that.BaseTool.Moment(item.start, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  608. item.end = that.BaseTool.Moment(item.end, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  609. })
  610. localStorage.setItem('scheduleList', JSON.stringify(scheduleList))
  611. a.click()
  612. })
  613. },
  614. doExport () {
  615. const parameter = {
  616. ...this.queryParam,
  617. searchStartTime: this.queryParam.searchStartTime,
  618. searchEndTime: this.queryParam.searchEndTime
  619. }
  620. exportCheckJob(parameter).then(file => {
  621. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  622. })
  623. }
  624. }
  625. }
  626. </script>