RemoteOpcLog.vue 9.2 KB

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