CheckJob.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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">
  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. :rowSelection="options.rowSelection"
  61. showPagination="auto"
  62. >
  63. <span slot="action" slot-scope="record">
  64. <template>
  65. <a @click="handleView(record)">查看</a>
  66. <template v-if="record.status === DictCache.VALUE.CHECK_JOB_STATUS.NOT_EXECUTE">
  67. <a-divider type="vertical" />
  68. <a @click="handleFinish(record)">完成</a>
  69. </template>
  70. <template v-if="record.status != DictCache.VALUE.CHECK_JOB_STATUS.NOT_EXECUTE">
  71. <a-divider type="vertical" />
  72. <a @click="handleEdit(record)">修改</a>
  73. </template>
  74. <!-- <a-divider type="vertical" />-->
  75. <!-- <a-popconfirm v-if="$auth('check-jobs-del')" title="是否要删除该条数据?" @confirm="batchDelete(record.id)">-->
  76. <!-- <a>删除</a>-->
  77. <!-- </a-popconfirm>-->
  78. </template>
  79. </span>
  80. <span slot="status" slot-scope="text">
  81. <badge
  82. :status="DictCache.COLOR.JOB_STATUS[text]"
  83. :text="statusMap[text]" />
  84. </span>
  85. <span slot="stopFlag" slot-scope="text">
  86. <badge
  87. :status="DictCache.COLOR.YES_NO[text]"
  88. :text="sbStatusMap[text]" />
  89. </span>
  90. </s-table>
  91. <base-form :check-type="checkType" ref="baseModal" @ok="handleOk"/>
  92. <detail :check-type="checkType" ref="detailModal"/>
  93. </a-card>
  94. </template>
  95. <script>
  96. import { STable, Ellipsis } from '@/components'
  97. import BaseForm from './modules/BaseForm'
  98. import Detail from './modules/Detail'
  99. import { queryNum, getCheckJobPage, deleteCheckJobs, fetchCheckJob, exportCheckJob, executeJob } from '@/api/check/checkjob'
  100. export default {
  101. name: 'CheckJobList',
  102. components: {
  103. STable,
  104. Ellipsis,
  105. BaseForm,
  106. Detail
  107. },
  108. props: {
  109. /**
  110. * 检查类型: 1-负责 2-巡检
  111. */
  112. checkType: {
  113. type: Number,
  114. default: 1
  115. },
  116. filter: {
  117. type: Number,
  118. default: -1
  119. }
  120. },
  121. data () {
  122. this.names = ['负责', '巡检']
  123. return {
  124. // 查询参数
  125. queryParam: {
  126. type: this.checkType,
  127. filter: this.filter
  128. },
  129. // 表头
  130. columns: [
  131. {
  132. title: '序号',
  133. dataIndex: 'index',
  134. customRender: (text, record, index) => {
  135. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  136. },
  137. checked: true
  138. },
  139. //{
  140. // title: '计划单号',
  141. // dataIndex: 'planNo',
  142. // checked: true
  143. //},
  144. {
  145. title: '任务名称',
  146. dataIndex: 'name',
  147. checked: true
  148. },
  149. {
  150. title: '计划名称',
  151. dataIndex: 'planName',
  152. checked: true
  153. },
  154. {
  155. title: '负责人',
  156. dataIndex: 'checkUserName',
  157. checked: true
  158. },
  159. {
  160. title: '设备',
  161. dataIndex: 'sbName',
  162. checked: true
  163. },
  164. //{
  165. // title: '负责部件',
  166. // dataIndex: 'partName',
  167. // checked: true
  168. //},
  169. {
  170. title: '执行日期',
  171. dataIndex: 'startTime',
  172. checked: true
  173. },
  174. {
  175. title: '截至日期',
  176. dataIndex: 'endTime',
  177. checked: true
  178. },
  179. {
  180. title: '标准工时',
  181. dataIndex: 'standardHours'
  182. },
  183. {
  184. title: '实际工时',
  185. dataIndex: 'realHours'
  186. },
  187. {
  188. title: '实际开始时间',
  189. dataIndex: 'actualStartTime'
  190. },
  191. {
  192. title: '实际结束时间',
  193. dataIndex: 'actualEndTime'
  194. },
  195. {
  196. title: '任务状态',
  197. dataIndex: 'status',
  198. checked: true,
  199. scopedSlots: { customRender: 'status' }
  200. },
  201. // {
  202. // title: '是否停机',
  203. // dataIndex: 'stopFlag',
  204. // checked: true,
  205. // scopedSlots: { customRender: 'stopFlag' }
  206. // },
  207. {
  208. title: '创建人名称',
  209. dataIndex: 'createdUserName'
  210. },
  211. {
  212. title: '创建时间',
  213. dataIndex: 'createdTime',
  214. checked: true
  215. },
  216. {
  217. title: '操作',
  218. key: 'action',
  219. width: '200px',
  220. align: 'center',
  221. scopedSlots: { customRender: 'action' },
  222. checked: true
  223. }
  224. ],
  225. // 下拉框map
  226. statusMap: {},
  227. sbStatusMap: {},
  228. // 加载数据方法 必须为 Promise 对象
  229. loadData: parameter => {
  230. parameter = {
  231. ...parameter,
  232. ...this.queryParam,
  233. dataScope: {
  234. sortBy: 'desc',
  235. sortName: 'update_time'
  236. }
  237. }
  238. return getCheckJobPage(Object.assign(parameter, this.queryParam))
  239. .then(res => {
  240. return res.data
  241. })
  242. },
  243. selectedRowKeys: [],
  244. selectedRows: [],
  245. options: {
  246. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  247. rowSelection: {
  248. selectedRowKeys: this.selectedRowKeys,
  249. onChange: this.onSelectChange
  250. }
  251. },
  252. optionAlertShow: false
  253. }
  254. },
  255. created () {
  256. // 下拉框map
  257. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_JOB_STATUS)
  258. this.sbStatusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  259. this.tableOption()
  260. },
  261. methods: {
  262. tableOption () {
  263. if (!this.optionAlertShow) {
  264. this.options = {
  265. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  266. rowSelection: {
  267. selectedRowKeys: this.selectedRowKeys,
  268. onChange: this.onSelectChange,
  269. getCheckboxProps: record => ({
  270. props: {
  271. disabled: false,
  272. name: record.id
  273. }
  274. })
  275. }
  276. }
  277. this.optionAlertShow = true
  278. } else {
  279. this.options = {
  280. alert: false,
  281. rowSelection: null
  282. }
  283. this.optionAlertShow = false
  284. }
  285. },
  286. batchDelete (id) {
  287. let ids = []
  288. if (this.BaseTool.String.isBlank(id)) {
  289. const length = this.selectedRows.length
  290. if (length === 0) {
  291. this.$message.info('请选择要删除的记录')
  292. return
  293. }
  294. ids = this.selectedRows.map(item => item.id)
  295. } else {
  296. ids = [id]
  297. }
  298. deleteCheckJobs(ids).then(res => {
  299. this.$message.info('删除成功')
  300. this.handleOk()
  301. this.$refs.table.clearSelected()
  302. })
  303. },
  304. handleEdit (record) {
  305. fetchCheckJob({ id: record.id }).then(res => {
  306. const modal = this.$refs.baseModal
  307. modal.base(res.data)
  308. })
  309. },
  310. handleFinish (record) {
  311. fetchCheckJob({ id: record.id }).then(res => {
  312. const modal = this.$refs.baseModal
  313. modal.base(res.data)
  314. })
  315. },
  316. handleExecute (record) {
  317. executeJob({ id: record.id }).then(res => {
  318. this.handleOk()
  319. })
  320. },
  321. handleView (record) {
  322. fetchCheckJob({ id: record.id }).then(res => {
  323. const modal = this.$refs.detailModal
  324. modal.base(res.data)
  325. })
  326. },
  327. handleOk () {
  328. this.$refs.table.refresh()
  329. },
  330. onSelectChange (selectedRowKeys, selectedRows) {
  331. this.selectedRowKeys = selectedRowKeys
  332. this.selectedRows = selectedRows
  333. },
  334. resetSearchForm () {
  335. this.queryParam = {
  336. }
  337. this.$refs.table.refresh(true)
  338. },
  339. doExport () {
  340. const parameter = {
  341. ...this.queryParam
  342. }
  343. exportCheckJob(parameter).then(file => {
  344. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  345. })
  346. }
  347. }
  348. }
  349. </script>