RemoteDegreeLog.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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-col :md="6 || 24" :sm="24" >
  13. <span class="table-page-search-submitButtons">
  14. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  15. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  16. </span>
  17. </a-col>
  18. </a-row>
  19. </a-form>
  20. </div>
  21. <div class="table-operator" style="margin-bottom: 8px;">
  22. <a-row>
  23. <a-col :md="16">
  24. <a-button v-if="$auth('remote-degree-logs-add')" type="primary" icon="plus" @click="handleAdd()">新增
  25. </a-button>
  26. <a-button
  27. style="margin-left: 8px"
  28. v-if="$auth('remote-degree-logs-export')"
  29. type="primary"
  30. icon="download"
  31. @click="doExport">导出
  32. </a-button>
  33. <!-- <a-button
  34. style="margin-left: 8px"
  35. type="primary"
  36. icon="download"
  37. @click="testDay(0)">电度月报表
  38. </a-button>
  39. <a-button
  40. style="margin-left: 8px"
  41. type="primary"
  42. icon="download"
  43. @click="testDay(1)">电度日报表
  44. </a-button>-->
  45. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('remote-degree-logs-del')">
  46. <a-menu slot="overlay">
  47. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  48. <a-menu-item key="1">
  49. <a-icon type="delete" />
  50. <a>删除</a></a-menu-item>
  51. </a-popconfirm>
  52. </a-menu>
  53. <a-button style="margin-left: 8px">
  54. 批量操作
  55. <a-icon type="down" />
  56. </a-button>
  57. </a-dropdown>
  58. </a-col>
  59. </a-row>
  60. </div>
  61. <s-table
  62. ref="table"
  63. size="default"
  64. rowKey="id"
  65. :columns="columns"
  66. :data="loadData"
  67. :alert="options.alert"
  68. :rowSelection="options.rowSelection"
  69. showPagination="auto"
  70. >
  71. <span slot="action" slot-scope="record">
  72. <template>
  73. <a @click="handleView(record)">查看</a>
  74. <operation-button
  75. v-if="$auth('remote-degree-logs-edit')"
  76. @click="handleEdit(record)"
  77. >修改</operation-button>
  78. <operation-button
  79. v-if="$auth('remote-degree-logs-del')"
  80. :type="2"
  81. title="是否要删除该条数据?"
  82. @confirm="batchDelete(record.id)">删除</operation-button>
  83. </template>
  84. </span>
  85. </s-table>
  86. </div>
  87. <base-form ref="baseModal" @ok="handleOk" />
  88. <detail ref="detailModal" @ok="handleOk" />
  89. </a-card>
  90. </template>
  91. <script>
  92. import { STable, Ellipsis } from '@/components'
  93. import BaseForm from './modules/BaseForm'
  94. import Detail from './modules/Detail'
  95. import {
  96. getRemoteDegreeLogPage,
  97. deleteRemoteDegreeLogs,
  98. fetchRemoteDegreeLog,
  99. exportRemoteDegreeLog,
  100. queryRemoteDegreeLogMonthOrDayReport
  101. } from '@/api/remote/degree-log'
  102. export default {
  103. name: 'RemoteDegreeLogList',
  104. components: {
  105. STable,
  106. Ellipsis,
  107. BaseForm,
  108. Detail
  109. },
  110. data () {
  111. return {
  112. advanced: false,
  113. visible: true,
  114. map: {},
  115. // 查询参数
  116. queryParam: {
  117. sbId: this.$route.query.sbId
  118. },
  119. // 表头
  120. columns: [
  121. {
  122. title: '序号',
  123. dataIndex: 'index',
  124. customRender: (text, record, index) => {
  125. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  126. }
  127. },
  128. {
  129. title: '设备名称',
  130. dataIndex: 'sbName'
  131. },
  132. {
  133. title: '点位',
  134. dataIndex: 'positionNum'
  135. },
  136. {
  137. title: '类型',
  138. dataIndex: 'type',
  139. customRender: (text, record, index) => {
  140. return this.BaseTool.Object.getField(this.map, text)
  141. }
  142. },
  143. {
  144. title: '单位',
  145. dataIndex: 'unit'
  146. },
  147. {
  148. title: '系数',
  149. dataIndex: 'ratio'
  150. },
  151. {
  152. title: '描述',
  153. dataIndex: 'description'
  154. },
  155. {
  156. title: '年',
  157. dataIndex: 'year'
  158. },
  159. {
  160. title: '月',
  161. dataIndex: 'month'
  162. },
  163. {
  164. title: '日',
  165. dataIndex: 'day'
  166. },
  167. {
  168. title: '时',
  169. dataIndex: 'hour'
  170. },
  171. {
  172. title: '实时数值',
  173. dataIndex: 'result'
  174. },
  175. {
  176. title: '备注',
  177. dataIndex: 'remark'
  178. },
  179. {
  180. title: '创建日期',
  181. dataIndex: 'createdTime'
  182. },
  183. {
  184. title: '操作',
  185. key: 'action',
  186. width: '200px',
  187. align: 'center',
  188. scopedSlots: { customRender: 'action' }
  189. }
  190. ],
  191. // 下拉框map
  192. // 加载数据方法 必须为 Promise 对象
  193. loadData: parameter => {
  194. parameter = {
  195. ...parameter,
  196. ...this.queryParam,
  197. dataScope: {
  198. sortBy: 'desc',
  199. sortName: 'update_time'
  200. }
  201. }
  202. return getRemoteDegreeLogPage(Object.assign(parameter, this.queryParam))
  203. .then(res => {
  204. return res.data
  205. })
  206. },
  207. selectedRowKeys: [],
  208. selectedRows: [],
  209. options: {
  210. alert: {
  211. show: true,
  212. clear: () => {
  213. this.selectedRowKeys = []
  214. }
  215. },
  216. rowSelection: {
  217. selectedRowKeys: this.selectedRowKeys,
  218. onChange: this.onSelectChange
  219. }
  220. },
  221. optionAlertShow: false
  222. }
  223. },
  224. created () {
  225. // 下拉框map
  226. this.map = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REMOTE_DEGREE)
  227. this.tableOption()
  228. },
  229. methods: {
  230. tableOption () {
  231. if (!this.optionAlertShow) {
  232. this.options = {
  233. alert: {
  234. show: true,
  235. clear: () => {
  236. this.selectedRowKeys = []
  237. }
  238. },
  239. rowSelection: {
  240. selectedRowKeys: this.selectedRowKeys,
  241. onChange: this.onSelectChange,
  242. getCheckboxProps: record => ({
  243. props: {
  244. disabled: false,
  245. name: record.id
  246. }
  247. })
  248. }
  249. }
  250. this.optionAlertShow = true
  251. } else {
  252. this.options = {
  253. alert: false,
  254. rowSelection: null
  255. }
  256. this.optionAlertShow = false
  257. }
  258. },
  259. batchDelete (id) {
  260. let ids = []
  261. if (this.BaseTool.String.isBlank(id)) {
  262. const length = this.selectedRows.length
  263. if (length === 0) {
  264. this.$message.info('请选择要删除的记录')
  265. return
  266. }
  267. ids = this.selectedRows.map(item => item.id)
  268. } else {
  269. ids = [id]
  270. }
  271. deleteRemoteDegreeLogs(ids).then(res => {
  272. this.$message.info('删除成功')
  273. this.handleOk()
  274. this.$refs.table.clearSelected()
  275. })
  276. },
  277. handleAdd () {
  278. this.visible = false
  279. const modal = this.$refs.baseModal
  280. modal.base()
  281. },
  282. handleEdit (record) {
  283. this.visible = false
  284. fetchRemoteDegreeLog({ id: record.id }).then(res => {
  285. const modal = this.$refs.baseModal
  286. modal.base(res.data)
  287. })
  288. },
  289. handleView (record) {
  290. this.visible = false
  291. fetchRemoteDegreeLog({ id: record.id }).then(res => {
  292. const modal = this.$refs.detailModal
  293. modal.base(res.data)
  294. })
  295. },
  296. testDay (isDay) {
  297. queryRemoteDegreeLogMonthOrDayReport({ isDay: isDay, year: 2022, month: 10, day: 1 }).then(res => {
  298. console.log(res.data)
  299. })
  300. },
  301. handleOk (values) {
  302. this.visible = true
  303. this.$refs.table.refresh()
  304. },
  305. onSelectChange (selectedRowKeys, selectedRows) {
  306. this.selectedRowKeys = selectedRowKeys
  307. this.selectedRows = selectedRows
  308. },
  309. resetSearchForm () {
  310. this.queryParam = {
  311. sbId: this.$route.query.sbId
  312. }
  313. this.$refs.table.refresh(true)
  314. },
  315. doExport () {
  316. const parameter = {
  317. ...this.queryParam
  318. }
  319. exportRemoteDegreeLog(parameter).then(file => {
  320. this.BaseTool.Util.downLoadExportExcel(file)
  321. })
  322. },
  323. handleEnter () {
  324. this.$refs.table.refresh(true)
  325. }
  326. }
  327. }
  328. </script>