CheckJobTable.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <template>
  2. <a-card :bordered="false">
  3. <div class="table-page-search-wrapper">
  4. <a-form layout="inline">
  5. <a-row :gutter="48">
  6. <a-col :md="8" :sm="24">
  7. <a-form-item label="计划名称">
  8. <a-input v-model="queryParam.planName" placeholder="请输入计划名称"/>
  9. </a-form-item>
  10. </a-col>
  11. <a-col :md="8" :sm="24">
  12. <a-form-item label="负责人">
  13. <a-input v-model="queryParam.keyword" placeholder="请输入负责人"/>
  14. </a-form-item>
  15. </a-col>
  16. <a-col :md="8" :sm="24">
  17. <a-form-item label="任务状态">
  18. <a-select
  19. v-model="queryParam.status"
  20. placeholder="请选择">
  21. <a-select-option
  22. v-for="(label,value) in statusMap"
  23. :key="value"
  24. :label="label"
  25. :value="parseInt(value)">{{ label }}
  26. </a-select-option>
  27. </a-select>
  28. </a-form-item>
  29. </a-col>
  30. <a-col :md="8 || 24" :sm="24">
  31. <span class="table-page-search-submitButtons">
  32. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  33. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  34. </span>
  35. </a-col>
  36. </a-row>
  37. </a-form>
  38. </div>
  39. <div class="table-operator" style="margin-bottom: 8px;">
  40. <!-- <a-button v-if="$auth('check-jobs-add')" type="primary" icon="plus" @click="$refs.baseModal.base()">新增</a-button>-->
  41. <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>
  42. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && ($auth('check-spot-jobs-finish') || $auth('check-polling-jobs-finish'))">
  43. <a-menu slot="overlay">
  44. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  45. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  46. </a-popconfirm>
  47. </a-menu>
  48. <a-button style="margin-left: 8px">
  49. 批量操作 <a-icon type="down" />
  50. </a-button>
  51. </a-dropdown>
  52. </div>
  53. <s-table
  54. ref="table"
  55. size="default"
  56. rowKey="id"
  57. :columns="columns"
  58. :data="loadData"
  59. :alert="options.alert"
  60. :scroll="{x: 1500, y: BaseTool.Constant.scrollY }"
  61. :rowSelection="options.rowSelection"
  62. showPagination="auto"
  63. >
  64. <span slot="action" slot-scope="record">
  65. <template>
  66. <a @click="handleView(record)">查看</a>
  67. <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)">
  68. <a-divider type="vertical" />
  69. <a>执行</a>
  70. </a-popconfirm>
  71. <template v-if="($auth('check-spot-jobs-finish') || $auth('check-polling-jobs-finish')) && record.status === DictCache.VALUE.CHECK_JOB_STATUS.EXECUTING">
  72. <a-divider type="vertical" />
  73. <a @click="handleFinish(record)">完成</a>
  74. </template>
  75. <!-- <a-divider type="vertical" />-->
  76. <!-- <a-popconfirm v-if="$auth('check-jobs-del')" title="是否要删除该条数据?" @confirm="batchDelete(record.id)">-->
  77. <!-- <a>删除</a>-->
  78. <!-- </a-popconfirm>-->
  79. </template>
  80. </span>
  81. <span slot="status" slot-scope="text">
  82. <badge
  83. :status="DictCache.COLOR.JOB_STATUS[text]"
  84. :text="statusMap[text]" />
  85. </span>
  86. <span slot="stopFlag" slot-scope="text">
  87. <badge
  88. :status="DictCache.COLOR.YES_NO[text]"
  89. :text="sbStatusMap[text]" />
  90. </span>
  91. </s-table>
  92. <base-form :check-type="checkType" ref="baseModal" @ok="handleOk"/>
  93. <detail :check-type="checkType" ref="detailModal"/>
  94. </a-card>
  95. </template>
  96. <script>
  97. import { STable, Ellipsis } from '@/components'
  98. import BaseForm from './BaseForm'
  99. import Detail from './Detail'
  100. import { getCheckJobPage, deleteCheckJobs, fetchCheckJob, exportCheckJob, executeJob } from '@/api/check/checkjob'
  101. export default {
  102. name: 'CheckJobTable',
  103. components: {
  104. STable,
  105. Ellipsis,
  106. BaseForm,
  107. Detail
  108. },
  109. props: {
  110. /**
  111. * 检查类型: 1-负责 2-巡检
  112. */
  113. checkType: {
  114. type: Number,
  115. default: 1
  116. },
  117. type: {
  118. type: Number,
  119. default: 1
  120. },
  121. status: {
  122. type: Number,
  123. default: null
  124. },
  125. tableParams: {
  126. type: Object,
  127. default: () => ({})
  128. },
  129. modelParams: {
  130. type: Object,
  131. default: () => ({})
  132. }
  133. },
  134. watch: {
  135. tableParams: {
  136. // deep: true, // 深度监听
  137. handler (newVal, oldVal) {
  138. if (newVal.sbId !== oldVal.sbId) {
  139. this.handleOk()
  140. }
  141. }
  142. }
  143. },
  144. data () {
  145. return {
  146. // 查询参数
  147. queryParam: {
  148. type: this.checkType,
  149. status: this.DictCache.VALUE.CHECK_JOB_STATUS.FINISHED
  150. },
  151. // 表头
  152. columns: [
  153. {
  154. title: '序号',
  155. dataIndex: 'index',
  156. width: '100px',
  157. customRender: (text, record, index) => {
  158. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  159. },
  160. checked: true
  161. },
  162. {
  163. title: '标准编码',
  164. dataIndex: 'standardNo',
  165. checked: true,
  166. width: '150px'
  167. },
  168. {
  169. title: '任务要求',
  170. dataIndex: 'requirement',
  171. checked: true,
  172. width: '300px'
  173. },
  174. {
  175. title: '负责人',
  176. dataIndex: 'checkUserName',
  177. checked: true,
  178. width: '100px'
  179. },
  180. {
  181. title: '设备',
  182. dataIndex: 'sbName',
  183. checked: true,
  184. width: '100px'
  185. },
  186. {
  187. title: '部位',
  188. dataIndex: 'partName',
  189. checked: true,
  190. width: '100px'
  191. },
  192. {
  193. title: '维护等级',
  194. dataIndex: 'standardLevel',
  195. width: '100px',
  196. checked: true,
  197. customRender: (text, record, index) => {
  198. return this.BaseTool.Table.getMapText(this.standardLevelMap, text)
  199. }
  200. },
  201. {
  202. title: '执行日期',
  203. dataIndex: 'startTime',
  204. checked: true,
  205. width: '200px'
  206. },
  207. {
  208. title: '截至日期',
  209. dataIndex: 'endTime',
  210. checked: true,
  211. width: '200px'
  212. },
  213. {
  214. title: '开始时间',
  215. dataIndex: 'actualStartTime',
  216. width: '200px'
  217. },
  218. {
  219. title: '完成时间',
  220. dataIndex: 'actualEndTime',
  221. width: '200px'
  222. },
  223. {
  224. title: '是否延期',
  225. dataIndex: 'receiveOvertime',
  226. checked: true,
  227. fixed: 'right',
  228. width: '100px',
  229. customRender: (text, record, index) => {
  230. return ((text === null || text === 0) ? '否' : '是')
  231. }
  232. },
  233. {
  234. title: '任务状态',
  235. dataIndex: 'status',
  236. checked: true,
  237. width: '100px',
  238. fixed: 'right',
  239. scopedSlots: { customRender: 'status' }
  240. },
  241. {
  242. title: '操作',
  243. key: 'action',
  244. width: '250px',
  245. align: 'center',
  246. fixed: 'right',
  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. batchDelete (id) {
  312. let ids = []
  313. if (this.BaseTool.String.isBlank(id)) {
  314. const length = this.selectedRows.length
  315. if (length === 0) {
  316. this.$message.info('请选择要删除的记录')
  317. return
  318. }
  319. ids = this.selectedRows.map(item => item.id)
  320. } else {
  321. ids = [id]
  322. }
  323. deleteCheckJobs(ids).then(res => {
  324. this.$message.info('删除成功')
  325. this.handleOk()
  326. this.$refs.table.clearSelected()
  327. })
  328. },
  329. handleEdit (record) {
  330. fetchCheckJob({ id: record.id }).then(res => {
  331. const modal = this.$refs.baseModal
  332. modal.base(res.data)
  333. })
  334. },
  335. handleFinish (record) {
  336. fetchCheckJob({ id: record.id }).then(res => {
  337. const modal = this.$refs.baseModal
  338. modal.base(res.data)
  339. })
  340. },
  341. handleExecute (record) {
  342. executeJob({ id: record.id }).then(res => {
  343. this.handleOk()
  344. })
  345. },
  346. handleView (record) {
  347. fetchCheckJob({ id: record.id }).then(res => {
  348. const modal = this.$refs.detailModal
  349. modal.base(res.data)
  350. })
  351. },
  352. handleOk () {
  353. this.$refs.table.refresh()
  354. },
  355. onSelectChange (selectedRowKeys, selectedRows) {
  356. this.selectedRowKeys = selectedRowKeys
  357. this.selectedRows = selectedRows
  358. },
  359. resetSearchForm () {
  360. this.queryParam = {
  361. }
  362. this.$refs.table.refresh(true)
  363. },
  364. doExport () {
  365. const parameter = {
  366. ...this.queryParam,
  367. ...this.tableParams
  368. }
  369. exportCheckJob(parameter).then(file => {
  370. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  371. })
  372. }
  373. }
  374. }
  375. </script>