FillGatherTask.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <a-card :bordered="false">
  3. <div v-show="visible">
  4. <div class="table-page-search-wrapper" @keyup.enter="handleEnter">
  5. <a-form layout="inline">
  6. <a-row :gutter="48">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="关键字">
  9. <a-input v-model="queryParam.keyword" placeholder="请输入名称/类型名称" />
  10. </a-form-item>
  11. </a-col>
  12. <!-- </a-row>
  13. <a-row :gutter="48"> -->
  14. <a-col :md="6" :sm="24" >
  15. <span class="table-page-search-submitButtons">
  16. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  17. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  18. <!-- <a @click="()=>{ this.advanced = !this.advanced}" style="margin-left: 8px">
  19. {{ advanced ? '收起' : '展开' }}
  20. <a-icon :type="advanced ? 'up' : 'down'" />
  21. </a> -->
  22. </span>
  23. </a-col>
  24. </a-row>
  25. </a-form>
  26. </div>
  27. <div class="table-operator" style="margin-bottom: 8px;">
  28. <a-row>
  29. <a-col :md="16">
  30. <a-button v-if="$auth('fill-fills-add')" type="primary" icon="plus" @click="handleAdd()">新增</a-button>
  31. <a-button
  32. style="margin-left: 8px"
  33. v-if="$auth('fill-fills-export')"
  34. type="primary"
  35. icon="download"
  36. @click="doExport">导出
  37. </a-button>
  38. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('fill-fills-del')">
  39. <a-menu slot="overlay">
  40. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  41. <a-menu-item key="1">
  42. <a-icon type="delete" />
  43. <a>删除</a></a-menu-item>
  44. </a-popconfirm>
  45. </a-menu>
  46. <a-button style="margin-left: 8px">
  47. 批量操作
  48. <a-icon type="down" />
  49. </a-button>
  50. </a-dropdown>
  51. </a-col>
  52. </a-row>
  53. </div>
  54. <s-table
  55. ref="table"
  56. size="default"
  57. rowKey="id"
  58. bordered
  59. :columns="columns"
  60. :data="loadData"
  61. :alert="options.alert"
  62. :rowSelection="options.rowSelection"
  63. showPagination="auto"
  64. :scroll="{x: 1800}"
  65. >
  66. <span slot="status" slot-scope="status">
  67. <badge :status="DictCache.COLOR.FILL_GATHER_TASK_STATUS[status]" :text="statusMap[status]" />
  68. </span>
  69. <span slot="action" slot-scope="record">
  70. <template>
  71. <a @click="handleView(record)">查看</a>
  72. <operation-button
  73. v-show="record.status!== 2"
  74. @click="handleEdit(record)"
  75. >填报</operation-button>
  76. <operation-button
  77. v-if="$auth('fill-tasks-dispatch')"
  78. v-show="record.status!== 2"
  79. @click="handleDispatch(record)"
  80. >转派</operation-button>
  81. <operation-button
  82. v-if="$auth('fill-tasks-overtime')"
  83. v-show="record.status!== 2"
  84. @click="handleOvertime(record)"
  85. >延时</operation-button>
  86. <operation-button
  87. v-if="$auth('fill-tasks-pause')"
  88. v-show="record.status!== 2 && record.status===5"
  89. @click="handlePause(record)"
  90. >取消暂停</operation-button>
  91. <operation-button
  92. v-if="$auth('fill-tasks-pause')"
  93. v-show="record.status!== 2 && record.status!==5"
  94. @click="handlePause(record)"
  95. >暂停</operation-button>
  96. <!-- <operation-button
  97. v-if="$auth('fill-fills-del')"
  98. :type="2"
  99. title="是否要删除该条数据?"
  100. @confirm="batchDelete(record.id)">删除</operation-button> -->
  101. </template>
  102. </span>
  103. </s-table>
  104. </div>
  105. <base-form ref="baseModal" @ok="handleOk" />
  106. <dispatch-form ref="dispatchModal" @ok="handleOk" />
  107. <overtime-form ref="overtimeModal" @ok="handleOk" />
  108. <pause-form ref="pauseModal" @ok="handleOk" />
  109. <base-form :editor="false" ref="detailModal" @ok="handleOk" />
  110. </a-card>
  111. </template>
  112. <script>
  113. import { STable, Ellipsis } from '@/components'
  114. import BaseForm from './modules/BaseForm'
  115. import DispatchForm from './modules/DispatchForm'
  116. import OvertimeForm from './modules/OvertimeForm'
  117. import PauseForm from './modules/PauseForm'
  118. import Detail from './modules/Detail'
  119. import {
  120. getFillGatherTaskPage,
  121. deleteFillGatherTasks,
  122. pauseFillGatherTask,
  123. fetchFillGatherTask,
  124. exportFillGatherTask
  125. } from '@/api/fill/task'
  126. export default {
  127. name: 'FillGatherTask',
  128. components: {
  129. STable,
  130. Ellipsis,
  131. BaseForm,
  132. PauseForm,
  133. DispatchForm,
  134. OvertimeForm,
  135. Detail
  136. },
  137. data () {
  138. return {
  139. advanced: false,
  140. visible: true,
  141. // 查询参数
  142. queryParam: {},
  143. statusMap: {},
  144. // 表头
  145. columns: [
  146. {
  147. title: '序号',
  148. width: 65,
  149. dataIndex: 'index',
  150. customRender: (text, record, index) => {
  151. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  152. }
  153. },
  154. {
  155. title: '巡检任务名',
  156. width: 150,
  157. dataIndex: 'name'
  158. },
  159. {
  160. title: '巡检人',
  161. width: 100,
  162. dataIndex: 'checkerName'
  163. },
  164. {
  165. title: '巡检主管',
  166. width: 100,
  167. dataIndex: 'leaderName'
  168. },
  169. {
  170. title: '巡检开始时间',
  171. width: 120,
  172. dataIndex: 'createdTime'
  173. },
  174. {
  175. title: '任务创建人',
  176. width: 120,
  177. dataIndex: 'createdUserName'
  178. },
  179. {
  180. title: '待完成数量',
  181. width: 120,
  182. dataIndex: 'waitNum'
  183. },
  184. {
  185. title: '巡检总数量',
  186. width: 110,
  187. dataIndex: 'totalNum'
  188. },
  189. {
  190. title: '要求时间',
  191. width: 100,
  192. dataIndex: 'requireHour'
  193. },
  194. {
  195. title: '超时预警时间(小时)',
  196. width: 100,
  197. dataIndex: 'warningHour'
  198. },
  199. {
  200. title: '累计延时时间(小时)',
  201. width: 100,
  202. dataIndex: 'lateHistoryHours'
  203. },
  204. {
  205. title: '任务状态',
  206. width: 100,
  207. fixed: 'right',
  208. dataIndex: 'status',
  209. scopedSlots: { customRender: 'status' }
  210. },
  211. {
  212. title: '操作',
  213. key: 'action',
  214. width: 300,
  215. fixed: 'right',
  216. align: 'center',
  217. scopedSlots: { customRender: 'action' }
  218. }
  219. ],
  220. // 下拉框map
  221. // 加载数据方法 必须为 Promise 对象
  222. loadData: parameter => {
  223. parameter = {
  224. ...parameter,
  225. ...this.queryParam,
  226. dataScope: {
  227. sortBy: 'desc',
  228. sortName: 'created_time'
  229. }
  230. }
  231. return getFillGatherTaskPage(Object.assign(parameter, this.queryParam))
  232. .then(res => {
  233. return res.data
  234. })
  235. },
  236. selectedRowKeys: [],
  237. selectedRows: [],
  238. options: {
  239. alert: {
  240. show: true,
  241. clear: () => {
  242. this.selectedRowKeys = []
  243. }
  244. },
  245. rowSelection: {
  246. selectedRowKeys: this.selectedRowKeys,
  247. onChange: this.onSelectChange
  248. }
  249. },
  250. optionAlertShow: false
  251. }
  252. },
  253. created () {
  254. // 下拉框map
  255. this.tableOption()
  256. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.FILL_GATHER_TASK_STATUS)
  257. if (this.$route.query.id) {
  258. fetchFillGatherTask({ id: this.$route.query.id }).then(res => {
  259. this.handleView(res.data)
  260. })
  261. }
  262. },
  263. methods: {
  264. tableOption () {
  265. if (!this.optionAlertShow) {
  266. this.options = {
  267. alert: {
  268. show: true,
  269. clear: () => {
  270. this.selectedRowKeys = []
  271. }
  272. },
  273. rowSelection: {
  274. selectedRowKeys: this.selectedRowKeys,
  275. onChange: this.onSelectChange,
  276. getCheckboxProps: record => ({
  277. props: {
  278. disabled: false,
  279. name: record.id
  280. }
  281. })
  282. }
  283. }
  284. this.optionAlertShow = true
  285. } else {
  286. this.options = {
  287. alert: false,
  288. rowSelection: null
  289. }
  290. this.optionAlertShow = false
  291. }
  292. },
  293. batchDelete (id) {
  294. let ids = []
  295. if (this.BaseTool.String.isBlank(id)) {
  296. const length = this.selectedRows.length
  297. if (length === 0) {
  298. this.$message.info('请选择要删除的记录')
  299. return
  300. }
  301. ids = this.selectedRows.map(item => item.id)
  302. } else {
  303. ids = [id]
  304. }
  305. deleteFillGatherTasks(ids).then(res => {
  306. this.$message.info('删除成功')
  307. this.handleOk()
  308. this.$refs.table.clearSelected()
  309. })
  310. },
  311. handleDispatch (record) {
  312. const modal = this.$refs.dispatchModal
  313. modal.base(record)
  314. },
  315. handleOvertime (record) {
  316. const modal = this.$refs.overtimeModal
  317. modal.base(record)
  318. },
  319. handlePause (record) {
  320. const modal = this.$refs.pauseModal
  321. modal.base(record)
  322. },
  323. handleAdd () {
  324. this.visible = false
  325. const modal = this.$refs.baseModal
  326. modal.base()
  327. },
  328. handleEdit (record) {
  329. this.visible = false
  330. const modal = this.$refs.baseModal
  331. modal.base(record)
  332. },
  333. handleView (record) {
  334. this.visible = false
  335. const modal = this.$refs.detailModal
  336. modal.base(record)
  337. },
  338. handleOk () {
  339. this.visible = true
  340. this.$refs.table.refresh()
  341. },
  342. onSelectChange (selectedRowKeys, selectedRows) {
  343. this.selectedRowKeys = selectedRowKeys
  344. this.selectedRows = selectedRows
  345. },
  346. resetSearchForm () {
  347. this.queryParam = {}
  348. this.$refs.table.refresh(true)
  349. },
  350. doExport () {
  351. const parameter = {
  352. ...this.queryParam
  353. }
  354. exportFillGatherTask(parameter).then(file => {
  355. this.BaseTool.Util.downLoadExportExcel(file)
  356. })
  357. },
  358. handleEnter () {
  359. this.$refs.table.refresh(true)
  360. }
  361. }
  362. }
  363. </script>