Connectors.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container">
  4. <div class="filter-view">
  5. <div
  6. v-if="sitePk"
  7. class="back-icon"
  8. @click="goBack">
  9. <i class="el-icon el-icon-back"></i>
  10. </div>
  11. <el-select
  12. v-model="filter.pageVo.errorCode"
  13. placeholder="Error Code"
  14. @change="handleFilter"
  15. class="filter-view-item"
  16. clearable>
  17. <el-option
  18. v-for="(item,index) in errCodeOptions"
  19. :key="index"
  20. :label="item.name"
  21. :value="item.value"/>
  22. </el-select>
  23. <el-select
  24. v-model="filter.pageVo.status"
  25. placeholder="Status"
  26. @change="handleFilter"
  27. class="filter-view-item"
  28. clearable>
  29. <el-option
  30. v-for="(item,index) in statusOptions"
  31. :key="index"
  32. :label="item.name"
  33. :value="item.value"/>
  34. </el-select>
  35. <div class="flex1" style="max-width: 500px;">
  36. <el-input
  37. class="filter-view-item"
  38. v-model="filter.pageVo.criteria"
  39. prefix-icon="el-icon-search"
  40. placeholder="Search by Station ID, Site Name, Carpark Code, Vendor Error Code"
  41. @keyup.enter.native="handleFilter"
  42. @change="handleFilter"
  43. clearable/>
  44. </div>
  45. <el-button
  46. type="primary"
  47. icon="el-icon-search"
  48. @click="handleFilter">
  49. Search
  50. </el-button>
  51. </div>
  52. </div>
  53. <el-table
  54. v-loading="listLoading"
  55. :data="connectorList"
  56. class="no-border"
  57. style="width: 100%;min-height: 65vh;">
  58. <el-table-column
  59. label="Station ID"
  60. prop="sitePk"
  61. align="center"
  62. min-width="120">
  63. <template slot-scope="{row}">
  64. <span>{{ row.chargeBoxId }}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column
  68. label="Site Name"
  69. prop="sitePk"
  70. align="center"
  71. min-width="120">
  72. <template slot-scope="{row}">
  73. <span>{{ row.siteName }}</span>
  74. </template>
  75. </el-table-column>
  76. <el-table-column
  77. label="Carpark Code"
  78. prop="carParkCode"
  79. align="center"
  80. min-width="120"/>
  81. <!--el-table-column
  82. label="Service Provider"
  83. prop="sitePk"
  84. align="center"
  85. width="180">
  86. <template slot-scope="{row}">
  87. <span>{{ row.providerName }}</span>
  88. </template>
  89. </el-table-column-->
  90. <el-table-column
  91. label="Connector ID"
  92. prop="sitePk"
  93. align="center"
  94. min-width="120">
  95. <template slot-scope="{row}">
  96. <span>{{ row.connectorId }}</span>
  97. </template>
  98. </el-table-column>
  99. <el-table-column
  100. label="Last Status Update"
  101. prop="sitePk"
  102. align="center"
  103. min-width="150">
  104. <template slot-scope="{row}">
  105. <span>{{ row.dateTime }}</span>
  106. </template>
  107. </el-table-column>
  108. <el-table-column
  109. label="Status"
  110. prop="sitePk"
  111. align="center"
  112. min-width="80">
  113. <template slot-scope="{row}">
  114. <span>{{ row.status }}</span>
  115. </template>
  116. </el-table-column>
  117. <el-table-column
  118. label="Error Code"
  119. prop="sitePk"
  120. align="center"
  121. min-width="100">
  122. <template slot-scope="{row}">
  123. <span>{{ row.errorCode }}</span>
  124. </template>
  125. </el-table-column>
  126. <el-table-column
  127. label="Vendor Error Code"
  128. prop="sitePk"
  129. align="center"
  130. min-width="150">
  131. <template slot-scope="{row}">
  132. <span>{{ row.vendorErrorCode }}</span>
  133. </template>
  134. </el-table-column>
  135. <el-table-column
  136. label="Action"
  137. prop="sitePk"
  138. align="center"
  139. width="70">
  140. <template slot-scope="{row}">
  141. <!-- <TableAction /> -->
  142. <el-dropdown
  143. class="action-dropdown"
  144. @command="(v) => handleCommand(v, row)">
  145. <i class="el-icon-more icon-action"></i>
  146. <el-dropdown-menu slot="dropdown">
  147. <el-dropdown-item
  148. command="showConnectorQR">
  149. QRCode
  150. </el-dropdown-item>
  151. <el-dropdown-item
  152. command="showWebPosQR"
  153. v-if="enableWebPos">
  154. WebPosQR
  155. </el-dropdown-item>
  156. <el-dropdown-item
  157. command="changeToAvailable"
  158. v-if='row.status == "Unavailable"'>
  159. Change Availability to Available
  160. </el-dropdown-item>
  161. <el-dropdown-item
  162. command="changeToUnavailable"
  163. v-else>
  164. Change Availability to Unavailable
  165. </el-dropdown-item>
  166. <el-dropdown-item
  167. command="unlockConnector">
  168. Unlock Connector
  169. </el-dropdown-item>
  170. <el-dropdown-item
  171. command="remoteStart"
  172. v-if='row.status == "Preparing"'>
  173. Remote Start Transaction
  174. </el-dropdown-item>
  175. <el-dropdown-item
  176. command="remoteStop"
  177. v-if='row.status == "Charging"'>
  178. Remote Stop Transaction
  179. </el-dropdown-item>
  180. </el-dropdown-menu>
  181. </el-dropdown>
  182. </template>
  183. </el-table-column>
  184. </el-table>
  185. <div class="right">
  186. <pagination
  187. v-show="total > 0"
  188. :total="total"
  189. :page.sync="filter.pageNo"
  190. :limit.sync="filter.pageSize"
  191. @pagination="getConnectorList" />
  192. </div>
  193. <ConnectorTags
  194. :visible="printConnector.visible"
  195. :qrCode="printConnector.qrCode"
  196. @hide="hideConnectorQR"/>
  197. <DialogRemoteOcpp
  198. v-bind="actionDialog"
  199. @hide="hideActionDialog"/>
  200. <WebPosQR
  201. v-bind="webPosDialog"
  202. @hide="hideConnectorQR"/>
  203. </div>
  204. </template>
  205. <script>
  206. import Pagination from '@/components/Pagination'
  207. import TableAction from '@/components/TableAction.vue'
  208. import ConnectorTags from './components/ConnectorTags.vue'
  209. import WebPosQR from './components/WebPosQR.vue'
  210. import DialogRemoteOcpp from './components/DialogRemoteOcpp.vue'
  211. import api from '../../http/api/charge'
  212. import ocpp from '../../http/api/ocpp'
  213. import settings from '../../settings.js'
  214. export default {
  215. components: { Pagination, TableAction, ConnectorTags, DialogRemoteOcpp,WebPosQR },
  216. data() {
  217. return {
  218. filter: {
  219. pageNo: 1,
  220. pageSize: 10,
  221. pageVo: {
  222. criteria: '',
  223. status: '',
  224. errorCode: ''
  225. }
  226. },
  227. listLoading: true,
  228. connectorList: [],
  229. total: 0,
  230. statusOptions: [],
  231. errCodeOptions: [],
  232. printConnector: {
  233. qrCode: "",
  234. visible: false
  235. },
  236. sitePk: "",
  237. actionDialog: {
  238. visible: false,
  239. isStart: true,
  240. item: {}
  241. },
  242. webPosDialog: {
  243. visible: false,
  244. item: {}
  245. },
  246. enableWebPos: settings.enableWebPos
  247. }
  248. },
  249. created() {
  250. if (this.$route.params.id) {
  251. this.filter.sitePk = this.sitePk = this.$route.params.id;
  252. }
  253. this.getStatusOption();
  254. this.getErrorCodeOptions();
  255. },
  256. methods: {
  257. goBack() {
  258. this.$router.push({
  259. path: "/site-management/edit/" + this.sitePk
  260. })
  261. },
  262. handleFilter() {
  263. this.filter.pageNo = 1;
  264. this.getConnectorList();
  265. },
  266. getStatusOption() {
  267. api.getStatusList().then(res => {
  268. if (res.data.length > 0) {
  269. res.data.forEach(item => {
  270. this.statusOptions.push({
  271. name: item,
  272. value: item
  273. })
  274. })
  275. }
  276. this.getConnectorList();
  277. }).catch(err => {
  278. this.$message.error(err)
  279. })
  280. },
  281. getErrorCodeOptions() {
  282. api.getErrorCodeOption().then(res => {
  283. if (res.data.length > 0) {
  284. res.data.forEach(item => {
  285. this.errCodeOptions.push({
  286. name: item,
  287. value: item
  288. })
  289. })
  290. }
  291. this.getConnectorList();
  292. }).catch(err => {
  293. this.$message.error(err)
  294. })
  295. },
  296. getConnectorList() {
  297. this.listLoading = true;
  298. api.getConnectorList(this.filter).then(res => {
  299. this.listLoading = false;
  300. this.total = res.total;
  301. this.connectorList = res.data;
  302. }).catch(err => {
  303. this.$message.error(err)
  304. this.listLoading = false;
  305. })
  306. },
  307. handleCommand(cb, item) {
  308. this[cb](item)
  309. },
  310. showConnectorQR(row) {
  311. this.printConnector.visible = true;
  312. this.printConnector.qrCode = row.chargeBoxId + "::" + row.connectorId
  313. },
  314. showWebPosQR(row) {
  315. this.webPosDialog.item = row;
  316. this.webPosDialog.visible = true;
  317. },
  318. unlockConnector(row) {
  319. this.$confirm("Confirm unlock this connector?", "Unlock Connector", {
  320. confirmButtonText: 'Confirm',
  321. cancelButtonText: 'Cancel',
  322. type: 'warning'
  323. }).then(res => {
  324. const params = {
  325. connectorId: row.connectorId,
  326. stationIds: [row.chargeBoxId]
  327. }
  328. this.sendPerform("ocppOperations/unlockConnector", params);
  329. })
  330. },
  331. changeToAvailable(row) {
  332. this.$confirm("Confirm change to available?", "Change Availability", {
  333. confirmButtonText: 'Confirm',
  334. cancelButtonText: 'Cancel',
  335. type: 'warning'
  336. }).then(res => {
  337. const params = {
  338. availType: "OPERATIVE",
  339. connectorId: row.connectorId,
  340. stationIds: [row.chargeBoxId]
  341. }
  342. this.sendPerform("ocppOperations/changeAvailability", params);
  343. })
  344. },
  345. changeToUnavailable(row) {
  346. this.$confirm("Confirm change to unavailable?", "Change Availability", {
  347. confirmButtonText: 'Confirm',
  348. cancelButtonText: 'Cancel',
  349. type: 'warning'
  350. }).then(res => {
  351. const params = {
  352. availType: "INOPERATIVE",
  353. connectorId: row.connectorId,
  354. stationIds: [row.chargeBoxId]
  355. }
  356. this.sendPerform("ocppOperations/changeAvailability", params);
  357. })
  358. },
  359. sendPerform(api, params) {
  360. this.listLoading = true;
  361. ocpp.sendPerform(api, params).then(res => {
  362. this.listLoading = false;
  363. if (res.data.taskId) {
  364. this.$openRoute("/ocpp-operations/result/" + res.data.taskId);
  365. //this.$router.push({path: '/ocpp-operations/result/' + res.data.taskId});
  366. }
  367. }).catch(err => {
  368. this.listLoading = false;
  369. this.$message({
  370. type: 'error',
  371. message: err
  372. })
  373. });
  374. },
  375. remoteStart(row) {
  376. this.actionDialog.visible = true;
  377. this.actionDialog.item = row;
  378. this.actionDialog.isStart = true;
  379. /*this.$confirm("Confirm remote start?", "Remote", {
  380. confirmButtonText: 'Confirm',
  381. cancelButtonText: 'Cancel',
  382. type: 'warning'
  383. }).then(res => {
  384. const params = {
  385. connectorId: row.connectorId,
  386. stationIds: [row.chargeBoxId],
  387. //mobileNumber: ""
  388. }
  389. //this.sendPerform("ocppOperations/remoteStartTransaction", params);
  390. })*/
  391. },
  392. remoteStop(row) {
  393. this.actionDialog.visible = true;
  394. this.actionDialog.item = row;
  395. this.actionDialog.isStart = false;
  396. /*this.$confirm("Confirm remote stop?", "Remote", {
  397. confirmButtonText: 'Confirm',
  398. cancelButtonText: 'Cancel',
  399. type: 'warning'
  400. }).then(res => {
  401. const params = {
  402. availType: "INOPERATIVE",
  403. connectorId: row.connectorId,
  404. stationIds: [row.chargeBoxId]
  405. }
  406. //this.sendPerform("ocppOperations/remoteStopTransaction", params);
  407. })*/
  408. },
  409. hideConnectorQR() {
  410. this.printConnector.visible = false;
  411. this.webPosDialog.visible = false;
  412. },
  413. hideActionDialog() {
  414. this.actionDialog.visible = false;
  415. }
  416. }
  417. }
  418. </script>
  419. <style lang="scss">
  420. .filter-item {
  421. &.el-input {
  422. width: 100%;
  423. .el-input__inner {
  424. width: 100%;
  425. min-width: 300px;
  426. max-width: 500px;
  427. border-radius: 2px;
  428. }
  429. }
  430. }
  431. .back-icon {
  432. width: 30px;
  433. height: 30px;
  434. padding: 10px;
  435. display: flex;
  436. cursor: pointer;
  437. font-size: 18px;
  438. align-items: center;
  439. }
  440. </style>