CheckJobCalendar.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <a-calendar class="custom" @select="onSelect" @panelChange="onPanelChange">
  3. <ul slot="dateCellRender" slot-scope="value" class="events">
  4. <li v-for="item in getListData(value)" :key="item.id">
  5. <a-badge :status="item.status" :text="item.name" />
  6. </li>
  7. </ul>
  8. <template slot="monthCellRender" slot-scope="value">
  9. <div v-if="getMonthData(value)" class="notes-month">
  10. <section>{{ getMonthData(value) }}</section>
  11. <span>Backlog number</span>
  12. </div>
  13. </template>
  14. </a-calendar>
  15. </template>
  16. <script>
  17. import { STable, Ellipsis } from '@/components'
  18. import BaseForm from './modules/BaseForm'
  19. import Detail from './modules/Detail'
  20. import { queryCheckJob, getCheckJobPage, deleteCheckJobs, fetchCheckJob, exportCheckJob, executeJob } from '@/api/check/checkjob'
  21. import BaseTool from '@/utils/tool'
  22. export default {
  23. name: 'CheckJobList',
  24. components: {
  25. STable,
  26. Ellipsis,
  27. BaseForm,
  28. Detail
  29. },
  30. props: {
  31. /**
  32. * 检查类型: 1-负责 2-巡检
  33. */
  34. checkType: {
  35. type: Number,
  36. default: 2
  37. },
  38. filter: {
  39. type: Number,
  40. default: -1
  41. }
  42. },
  43. data () {
  44. return {
  45. panelChange: true,
  46. // 查询参数
  47. queryParam: {
  48. type: this.checkType,
  49. filter: this.filter
  50. },
  51. data: [],
  52. // 下拉框map
  53. statusMap: {},
  54. sbStatusMap: {},
  55. // 加载数据方法 必须为 Promise 对象
  56. loadData: parameter => {
  57. parameter = {
  58. ...parameter,
  59. ...this.queryParam,
  60. dataScope: {
  61. sortBy: 'desc',
  62. sortName: 'update_time'
  63. }
  64. }
  65. return getCheckJobPage(Object.assign(parameter, this.queryParam))
  66. .then(res => {
  67. return res.data
  68. })
  69. },
  70. selectedRowKeys: [],
  71. selectedRows: [],
  72. preListData: [],
  73. options: {
  74. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  75. rowSelection: {
  76. selectedRowKeys: this.selectedRowKeys,
  77. onChange: this.onSelectChange
  78. }
  79. },
  80. optionAlertShow: false
  81. }
  82. },
  83. created () {
  84. // 下拉框map
  85. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_JOB_STATUS)
  86. this.sbStatusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  87. // this.tableOption()
  88. queryCheckJob(this.queryParam)
  89. .then(res => {
  90. this.data = res.data
  91. for (var i = 0; i < this.data.length; i++) {
  92. if (this.data[i].status === 1) {
  93. this.data[i].status = 'warning'
  94. } else if (this.data[i].status === 2) {
  95. this.data[i].status = 'processing'
  96. } else if (this.data[i].status === 3) {
  97. this.data[i].status = 'success'
  98. } else {
  99. this.data[i].status = 'error'
  100. }
  101. }
  102. })
  103. },
  104. methods: {
  105. onSelect (value) {
  106. this.panelChange = false
  107. console.log('onSelect: ' + BaseTool.Date.formatter(value, BaseTool.Date.PICKER_NORM_DATE_PATTERN))
  108. this.value = value
  109. this.selectedValue = value
  110. // this.queryParam.searchDay = BaseTool.Date.formatter(value, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  111. },
  112. onPanelChange (value) {
  113. this.panelChange = true
  114. console.log('onPanelChange: ' + BaseTool.Date.formatter(value, BaseTool.Date.PICKER_NORM_DATE_PATTERN))
  115. this.value = value
  116. this.queryParam.searchMonth = BaseTool.Date.formatter(value, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  117. queryCheckJob(this.queryParam)
  118. .then(res => {
  119. this.data = res.data
  120. for (var i = 0; i < this.data.length; i++) {
  121. if (this.data[i].status === 1) {
  122. this.data[i].status = 'warning'
  123. } else if (this.data[i].status === 2) {
  124. this.data[i].status = 'processing'
  125. } else if (this.data[i].status === 3) {
  126. this.data[i].status = 'success'
  127. } else {
  128. this.data[i].status = 'error'
  129. }
  130. }
  131. })
  132. },
  133. getListData (value) {
  134. console.log('getListData: ' + BaseTool.Date.formatter(value, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN))
  135. const listData = []
  136. for (var i = 0; i < this.data.length; i++) {
  137. console.log('value: ' + BaseTool.Date.formatter(value, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN))
  138. console.log('this.data[i]: ' + BaseTool.Date.formatter(this.data[i].startTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN))
  139. if (BaseTool.Date.formatter(value, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN) === BaseTool.Date.formatter(this.data[i].startTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)) {
  140. console.log('this.data[i].name: ' + this.data[i].name)
  141. listData.push(this.data[i])
  142. }
  143. }
  144. this.preListData = listData
  145. return listData || []
  146. },
  147. getMonthData (value) {
  148. if (value.month() === 8) {
  149. return 1394
  150. }
  151. },
  152. tableOption () {
  153. if (!this.optionAlertShow) {
  154. this.options = {
  155. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  156. rowSelection: {
  157. selectedRowKeys: this.selectedRowKeys,
  158. onChange: this.onSelectChange,
  159. getCheckboxProps: record => ({
  160. props: {
  161. disabled: false,
  162. name: record.id
  163. }
  164. })
  165. }
  166. }
  167. this.optionAlertShow = true
  168. } else {
  169. this.options = {
  170. alert: false,
  171. rowSelection: null
  172. }
  173. this.optionAlertShow = false
  174. }
  175. },
  176. batchDelete (id) {
  177. let ids = []
  178. if (this.BaseTool.String.isBlank(id)) {
  179. const length = this.selectedRows.length
  180. if (length === 0) {
  181. this.$message.info('请选择要删除的记录')
  182. return
  183. }
  184. ids = this.selectedRows.map(item => item.id)
  185. } else {
  186. ids = [id]
  187. }
  188. deleteCheckJobs(ids).then(res => {
  189. this.$message.info('删除成功')
  190. this.handleOk()
  191. this.$refs.table.clearSelected()
  192. })
  193. },
  194. handleEdit (record) {
  195. fetchCheckJob({ id: record.id }).then(res => {
  196. const modal = this.$refs.baseModal
  197. modal.base(res.data)
  198. })
  199. },
  200. handleFinish (record) {
  201. fetchCheckJob({ id: record.id }).then(res => {
  202. const modal = this.$refs.baseModal
  203. modal.base(res.data)
  204. })
  205. },
  206. handleExecute (record) {
  207. executeJob({ id: record.id }).then(res => {
  208. this.handleOk()
  209. })
  210. },
  211. handleView (record) {
  212. fetchCheckJob({ id: record.id }).then(res => {
  213. const modal = this.$refs.detailModal
  214. modal.base(res.data)
  215. })
  216. },
  217. handleOk () {
  218. this.$refs.table.refresh()
  219. },
  220. onSelectChange (selectedRowKeys, selectedRows) {
  221. this.selectedRowKeys = selectedRowKeys
  222. this.selectedRows = selectedRows
  223. },
  224. resetSearchForm () {
  225. this.queryParam = {
  226. }
  227. this.$refs.table.refresh(true)
  228. },
  229. doExport () {
  230. const parameter = {
  231. ...this.queryParam
  232. }
  233. exportCheckJob(parameter).then(file => {
  234. this.BaseTool.UPLOAD.downLoadExportExcel(file)
  235. })
  236. }
  237. }
  238. }
  239. </script>
  240. <style scoped>
  241. .events {
  242. list-style: none;
  243. margin: 0;
  244. padding: 0;
  245. }
  246. .events .ant-badge-status {
  247. overflow: hidden;
  248. white-space: nowrap;
  249. width: 100%;
  250. text-overflow: ellipsis;
  251. font-size: 12px;
  252. }
  253. .notes-month {
  254. text-align: center;
  255. font-size: 28px;
  256. }
  257. .notes-month section {
  258. font-size: 28px;
  259. }
  260. .ant-fullcalendar-header .ant-radio-group-default {
  261. display:none !important
  262. }
  263. .custom .ant-fullcalendar-header .ant-radio-group-default {
  264. display:none !important
  265. }
  266. </style>