CheckJobTableWaitDo.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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="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">
  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: 'createdUserName'
  230. },
  231. {
  232. title: '创建时间',
  233. dataIndex: 'createdTime',
  234. checked: true
  235. },
  236. {
  237. title: '操作',
  238. key: 'action',
  239. width: '200px',
  240. align: 'center',
  241. scopedSlots: { customRender: 'action' },
  242. checked: true
  243. }
  244. ],
  245. // 下拉框map
  246. statusMap: {},
  247. sbStatusMap: {},
  248. // 加载数据方法 必须为 Promise 对象
  249. loadData: parameter => {
  250. parameter = {
  251. ...parameter,
  252. ...this.queryParam,
  253. ...this.tableParams,
  254. dataScope: {
  255. }
  256. }
  257. return getCheckJobPage(Object.assign(parameter, this.queryParam))
  258. .then(res => {
  259. return res.data
  260. })
  261. },
  262. selectedRowKeys: [],
  263. selectedRows: [],
  264. options: {
  265. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  266. rowSelection: {
  267. selectedRowKeys: this.selectedRowKeys,
  268. onChange: this.onSelectChange
  269. }
  270. },
  271. optionAlertShow: false
  272. }
  273. },
  274. created () {
  275. // 下拉框map
  276. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_JOB_STATUS)
  277. this.sbStatusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  278. //this.tableOption()
  279. },
  280. methods: {
  281. tableOption () {
  282. if (!this.optionAlertShow) {
  283. this.options = {
  284. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  285. rowSelection: {
  286. selectedRowKeys: this.selectedRowKeys,
  287. onChange: this.onSelectChange,
  288. getCheckboxProps: record => ({
  289. props: {
  290. disabled: false,
  291. name: record.id
  292. }
  293. })
  294. }
  295. }
  296. this.optionAlertShow = true
  297. } else {
  298. this.options = {
  299. alert: false,
  300. rowSelection: null
  301. }
  302. this.optionAlertShow = false
  303. }
  304. },
  305. base (dataParam = {}, queryParam = {}) {
  306. this.visible = true
  307. this.modalTitle = '待执行保养列表'
  308. this.queryParam = queryParam
  309. this.sbId = queryParam.sbId
  310. this.dataParam = dataParam
  311. if (this.isCreated) {
  312. this.$refs.table.clearSelected()
  313. this.handleOk()
  314. } else {
  315. this.tableOption()
  316. this.isCreated = true
  317. }
  318. // this.mySelect(this.selectedRowKeys, this.selectedRows)
  319. },
  320. batchDelete (id) {
  321. let ids = []
  322. if (this.BaseTool.String.isBlank(id)) {
  323. const length = this.selectedRows.length
  324. if (length === 0) {
  325. this.$message.info('请选择要删除的记录')
  326. return
  327. }
  328. ids = this.selectedRows.map(item => item.id)
  329. } else {
  330. ids = [id]
  331. }
  332. deleteCheckJobs(ids).then(res => {
  333. this.$message.info('删除成功')
  334. this.handleOk()
  335. this.$refs.table.clearSelected()
  336. })
  337. },
  338. handleEdit (record) {
  339. fetchCheckJob({ id: record.id }).then(res => {
  340. const modal = this.$refs.baseModal
  341. modal.base(res.data)
  342. })
  343. },
  344. handleFinish (record) {
  345. fetchCheckJob({ id: record.id }).then(res => {
  346. const modal = this.$refs.baseModal
  347. modal.base(res.data)
  348. })
  349. },
  350. handleExecute (record) {
  351. executeJob({ id: record.id }).then(res => {
  352. this.handleOk()
  353. })
  354. },
  355. handleView (record) {
  356. fetchCheckJob({ id: record.id }).then(res => {
  357. const modal = this.$refs.detailModal
  358. modal.base(res.data)
  359. })
  360. },
  361. handleOk () {
  362. this.$refs.table.refresh()
  363. },
  364. onSelectChange (selectedRowKeys, selectedRows) {
  365. this.selectedRowKeys = selectedRowKeys
  366. this.selectedRows = selectedRows
  367. },
  368. resetSearchForm () {
  369. this.queryParam = {
  370. }
  371. this.$refs.table.refresh(true)
  372. },
  373. handleCancel () {
  374. this.visible = false
  375. this.confirmLoading = false
  376. this.$emit('ok')
  377. },
  378. doExport () {
  379. const parameter = {
  380. ...this.queryParam,
  381. ...this.tableParams
  382. }
  383. exportCheckJob(parameter).then(file => {
  384. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  385. })
  386. }
  387. }
  388. }
  389. </script>