CheckJob.vue 10 KB

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