CheckJobTableWaitDo.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <template>
  2. <a-modal
  3. :title="modalTitle"
  4. :width="1200"
  5. :visible="visible"
  6. :confirmLoading="confirmLoading"
  7. class="ant-modal2"
  8. @cancel="handleCancel"
  9. :footer="false"
  10. >
  11. <div class="table-page-search-wrapper">
  12. <a-form layout="inline">
  13. <a-row :gutter="48">
  14. <!-- <a-col :md="8" :sm="24">
  15. <a-form-item label="计划名称">
  16. <a-input v-model="queryParam.planName" placeholder="请输入计划名称"/>
  17. </a-form-item>
  18. </a-col>
  19. <a-col :md="8" :sm="24">
  20. <a-form-item label="负责人">
  21. <a-input v-model.trim="queryParam.keyword" placeholder="请输入负责人"/>
  22. </a-form-item>
  23. </a-col>
  24. <a-col :md="8" :sm="24">
  25. <a-form-item label="任务状态">
  26. <a-select
  27. v-model="queryParam.status"
  28. placeholder="请选择">
  29. <a-select-option
  30. v-for="(label,value) in statusMap"
  31. :key="value"
  32. :label="label"
  33. :value="parseInt(value)">{{ label }}
  34. </a-select-option>
  35. </a-select>
  36. </a-form-item>
  37. </a-col>-->
  38. <!-- <a-col :md="8 || 24" :sm="24">
  39. <span class="table-page-search-submitButtons">
  40. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  41. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  42. </span>
  43. </a-col>-->
  44. </a-row>
  45. </a-form>
  46. </div>
  47. <div class="table-operator" style="margin-bottom: 8px;">
  48. <!-- <a-button v-if="$auth('check-jobs-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>
  49. <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>-->
  50. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && ($auth('check-spot-jobs-finish') || $auth('check-polling-jobs-finish'))">
  51. <a-menu slot="overlay">
  52. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  53. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  54. </a-popconfirm>
  55. </a-menu>
  56. <a-button style="margin-left: 8px">
  57. 批量操作 <a-icon type="down" />
  58. </a-button>
  59. </a-dropdown>
  60. </div>
  61. <s-table
  62. ref="table"
  63. size="default"
  64. rowKey="id"
  65. :columns="columns"
  66. :data="loadData"
  67. :alert="options.alert"
  68. :rowSelection="options.rowSelection"
  69. showPagination="auto"
  70. >
  71. <span slot="action" slot-scope="record">
  72. <template>
  73. <a @click="handleView(record)">查看</a>
  74. <a-popconfirm v-if="($auth('check-spot-jobs-execute') || $auth('check-polling-jobs-execute')) && record.status === DictCache.VALUE.CHECK_JOB_STATUS.NOT_EXECUTE" title="确定开始执行任务?" @confirm="handleExecute(record)">
  75. <a-divider type="vertical" />
  76. <a>执行</a>
  77. </a-popconfirm>
  78. <template v-if="($auth('check-spot-jobs-finish') || $auth('check-polling-jobs-finish')) && record.status === DictCache.VALUE.CHECK_JOB_STATUS.EXECUTING">
  79. <a-divider type="vertical" />
  80. <a @click="handleFinish(record)">完成</a>
  81. </template>
  82. <!-- <a-divider type="vertical" />-->
  83. <!-- <a-popconfirm v-if="$auth('check-jobs-del')" title="是否要删除该条数据?" @confirm="batchDelete(record.id)">-->
  84. <!-- <a>删除</a>-->
  85. <!-- </a-popconfirm>-->
  86. </template>
  87. </span>
  88. <span slot="status" slot-scope="text">
  89. <badge
  90. :status="DictCache.COLOR.JOB_STATUS[text]"
  91. :text="statusMap[text]" />
  92. </span>
  93. <span slot="stopFlag" slot-scope="text">
  94. <badge
  95. :status="DictCache.COLOR.YES_NO[text]"
  96. :text="sbStatusMap[text]" />
  97. </span>
  98. </s-table>
  99. <base-form :check-type="checkType" ref="baseModal" @ok="handleOk"/>
  100. <detail :check-type="checkType" ref="detailModal"/>
  101. </a-modal>
  102. </template>
  103. <script>
  104. import { STable, Ellipsis } from '@/components'
  105. import BaseForm from './BaseForm'
  106. import Detail from './Detail'
  107. import { getCheckJobPage, deleteCheckJobs, fetchCheckJob, exportCheckJob, executeJob } from '@/api/check/checkjob'
  108. export default {
  109. name: 'CheckJobList',
  110. components: {
  111. STable,
  112. Ellipsis,
  113. BaseForm,
  114. Detail
  115. },
  116. props: {
  117. /**
  118. * 检查类型: 1-负责 2-巡检
  119. */
  120. checkType: {
  121. type: Number,
  122. default: 1
  123. },
  124. type: {
  125. type: Number,
  126. default: 1
  127. },
  128. status: {
  129. type: Number,
  130. default: 1
  131. },
  132. tableParams: {
  133. type: Object,
  134. default: () => ({})
  135. },
  136. modelParams: {
  137. type: Object,
  138. default: () => ({})
  139. }
  140. },
  141. watch: {
  142. tableParams: {
  143. // deep: true, // 深度监听
  144. handler (newVal, oldVal) {
  145. if (newVal.sbId !== oldVal.sbId) {
  146. this.handleOk()
  147. }
  148. }
  149. }
  150. },
  151. data () {
  152. return {
  153. // 查询参数
  154. queryParam: {
  155. type: this.checkType
  156. },
  157. modalTitle: null,
  158. visible: false,
  159. dataParam: {},
  160. confirmLoading: false,
  161. // 表头
  162. columns: [
  163. {
  164. title: '序号',
  165. dataIndex: 'index',
  166. customRender: (text, record, index) => {
  167. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  168. },
  169. checked: true
  170. },
  171. {
  172. title: '标准编码',
  173. dataIndex: 'standardNo',
  174. checked: true,
  175. width: '150px'
  176. },
  177. {
  178. title: '任务名称',
  179. dataIndex: 'name',
  180. checked: true
  181. },
  182. {
  183. title: '负责人',
  184. dataIndex: 'checkUserName',
  185. checked: true
  186. },
  187. {
  188. title: '设备',
  189. dataIndex: 'sbName',
  190. checked: true
  191. },
  192. // {
  193. // title: '点检部位',
  194. // dataIndex: 'partName',
  195. // checked: true
  196. // },
  197. {
  198. title: '执行日期',
  199. dataIndex: 'startTime',
  200. checked: true
  201. },
  202. {
  203. title: '截止日期',
  204. dataIndex: 'endTime',
  205. checked: true
  206. },
  207. {
  208. title: '实际开始时间',
  209. dataIndex: 'actualStartTime'
  210. },
  211. {
  212. title: '实际结束时间',
  213. dataIndex: 'actualEndTime'
  214. },
  215. {
  216. title: '任务状态',
  217. dataIndex: 'status',
  218. checked: true,
  219. scopedSlots: { customRender: 'status' }
  220. },
  221. //{
  222. // title: '计划性维修',
  223. // dataIndex: 'stopFlag',
  224. // checked: true,
  225. // scopedSlots: { customRender: 'stopFlag' }
  226. //},
  227. {
  228. title: '是否延期',
  229. dataIndex: 'receiveOvertime',
  230. checked: true,
  231. fixed: 'right',
  232. width: '100px',
  233. customRender: (text, record, index) => {
  234. return ((text === null || text === 0) ? '否' : '是')
  235. }
  236. },
  237. {
  238. title: '创建时间',
  239. dataIndex: 'createdTime',
  240. checked: true
  241. },
  242. {
  243. title: '操作',
  244. key: 'action',
  245. width: '200px',
  246. align: 'center',
  247. scopedSlots: { customRender: 'action' },
  248. checked: true
  249. }
  250. ],
  251. // 下拉框map
  252. statusMap: {},
  253. sbStatusMap: {},
  254. // 加载数据方法 必须为 Promise 对象
  255. loadData: parameter => {
  256. parameter = {
  257. ...parameter,
  258. ...this.queryParam,
  259. ...this.tableParams,
  260. dataScope: {
  261. }
  262. }
  263. return getCheckJobPage(Object.assign(parameter, this.queryParam))
  264. .then(res => {
  265. return res.data
  266. })
  267. },
  268. selectedRowKeys: [],
  269. selectedRows: [],
  270. options: {
  271. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  272. rowSelection: {
  273. selectedRowKeys: this.selectedRowKeys,
  274. onChange: this.onSelectChange
  275. }
  276. },
  277. optionAlertShow: false
  278. }
  279. },
  280. created () {
  281. // 下拉框map
  282. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_JOB_STATUS)
  283. this.sbStatusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  284. //this.tableOption()
  285. },
  286. methods: {
  287. tableOption () {
  288. if (!this.optionAlertShow) {
  289. this.options = {
  290. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  291. rowSelection: {
  292. selectedRowKeys: this.selectedRowKeys,
  293. onChange: this.onSelectChange,
  294. getCheckboxProps: record => ({
  295. props: {
  296. disabled: false,
  297. name: record.id
  298. }
  299. })
  300. }
  301. }
  302. this.optionAlertShow = true
  303. } else {
  304. this.options = {
  305. alert: false,
  306. rowSelection: null
  307. }
  308. this.optionAlertShow = false
  309. }
  310. },
  311. base (dataParam = {}, queryParam = {}) {
  312. this.visible = true
  313. this.modalTitle = '待执行保养列表'
  314. this.queryParam = queryParam
  315. this.sbId = queryParam.sbId
  316. this.dataParam = dataParam
  317. if (this.isCreated) {
  318. this.$refs.table.clearSelected()
  319. this.handleOk()
  320. } else {
  321. this.tableOption()
  322. this.isCreated = true
  323. }
  324. // this.mySelect(this.selectedRowKeys, this.selectedRows)
  325. },
  326. batchDelete (id) {
  327. let ids = []
  328. if (this.BaseTool.String.isBlank(id)) {
  329. const length = this.selectedRows.length
  330. if (length === 0) {
  331. this.$message.info('请选择要删除的记录')
  332. return
  333. }
  334. ids = this.selectedRows.map(item => item.id)
  335. } else {
  336. ids = [id]
  337. }
  338. deleteCheckJobs(ids).then(res => {
  339. this.$message.info('删除成功')
  340. this.handleOk()
  341. this.$refs.table.clearSelected()
  342. })
  343. },
  344. handleEdit (record) {
  345. fetchCheckJob({ id: record.id }).then(res => {
  346. const modal = this.$refs.baseModal
  347. modal.base(res.data)
  348. })
  349. },
  350. handleFinish (record) {
  351. fetchCheckJob({ id: record.id }).then(res => {
  352. const modal = this.$refs.baseModal
  353. modal.base(res.data)
  354. })
  355. },
  356. handleExecute (record) {
  357. executeJob({ id: record.id }).then(res => {
  358. this.handleOk()
  359. })
  360. },
  361. handleView (record) {
  362. fetchCheckJob({ id: record.id }).then(res => {
  363. const modal = this.$refs.detailModal
  364. modal.base(res.data)
  365. })
  366. },
  367. handleOk () {
  368. this.$refs.table.refresh()
  369. },
  370. onSelectChange (selectedRowKeys, selectedRows) {
  371. this.selectedRowKeys = selectedRowKeys
  372. this.selectedRows = selectedRows
  373. },
  374. resetSearchForm () {
  375. this.queryParam = {
  376. }
  377. this.$refs.table.refresh(true)
  378. },
  379. handleCancel () {
  380. this.visible = false
  381. this.confirmLoading = false
  382. this.$emit('ok')
  383. },
  384. doExport () {
  385. const parameter = {
  386. ...this.queryParam,
  387. ...this.tableParams
  388. }
  389. exportCheckJob(parameter).then(file => {
  390. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  391. })
  392. }
  393. }
  394. }
  395. </script>