| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772 |
- <template>
- <div class="card-container">
- <div class="card-content">
- <div class="ocpp-content">
- <div class="section-title">Selected Stations</div>
- <div class="flex-item">
- <span style="padding-right: 15px;">Site: </span>
- <el-select
- class="flex1"
- filterable
- remote
- v-model="listQuery.pageVo.sitePk"
- :remote-method="filterSite"
- :loading="siteLoading"
- placeholder="Select with search"
- @change="changeSite">
- <el-option
- v-for="(item, index) in siteList"
- :key="index"
- :label="item.siteName"
- :value="item.sitePk"/>
- </el-select>
- <span class="flex1"></span>
- </div>
- <div class="flex-item" style="padding: 20px 0; justify-content: flex-end;">
- <el-button
- type="primary"
- @click="selectNone">
- Select None
- </el-button>
- <el-button
- style="margin-left: 15px;"
- type="primary"
- @click="selectAll">
- Select All
- </el-button>
- </div>
- <el-table
- style="width: 100%;min-height: 50vh;"
- v-loading="listLoading"
- :data="stationList">
- <el-table-column
- :label="item.label"
- align="center"
- class-name="fixed-width"
- v-for="(item, index) in columns"
- :key="index"
- :width="item.width">
- <template slot-scope="{row, $index}">
- <el-checkbox
- v-if="item.action"
- v-model="row[item.key]"
- @change="checked => changeRow($index, checked)"/>
- <span v-else>{{ row[item.key] }}</span>
- </template>
- </el-table-column>
- </el-table>
- <div class="right">
- <pagination
- v-show="total > 0"
- :total="total"
- :page.sync="listQuery.pageNo"
- :limit.sync="listQuery.pageSize"
- @pagination="handlePageChange" />
- </div>
- </div>
- <div class="ocpp-content">
- <el-form
- :model="operationForm"
- :rules="rule"
- ref="operationForm"
- label-width="200px"
- label-position="left">
- <div class="section-title">OCPP Operation</div>
- <el-form-item
- label="Operation:"
- prop="operation">
- <el-select
- class="flex-item"
- v-model="operationForm.operation"
- @change="changeOperation">
- <el-option
- v-for="(item, index) in operationList"
- :key="index"
- :label="item.name"
- :value="index"
- v-if="item.api"/>
- </el-select>
- </el-form-item>
- <div class="section-title" style="padding-top: 20px;" v-loading="paramLoading">Parameters</div>
- <el-form-item
- label="Filter Type:"
- prop="filterType"
- v-if="paramsOption.filterTypeOption.length > 0">
- <el-select
- v-model="operationForm.filterType"
- class="flex-item"
- @change="changeFilterType">
- <el-option
- v-for="(item, index) in paramsOption.filterTypeOption"
- :key="index"
- :label="item.name"
- :value="item.value"/>
- </el-select>
- </el-form-item>
- <el-form-item
- label="Charging Profile ID:"
- prop="chargingProfilePk"
- v-if="paramsOption.needChargingProfile">
- <el-select
- v-model="operationForm.chargingProfilePk"
- class="flex-item">
- <el-option
- v-for="(item, index) in paramsOption.chargingProfileOption"
- :key="index"
- :label="item.value + ' (' + item.name + ')'"
- :value="item.value"/>
- </el-select>
- </el-form-item>
- <el-form-item
- label="Connector ID:"
- prop="connectorId"
- v-if="paramsOption.needConnector">
- <el-select
- v-model="operationForm.connectorId"
- class="flex-item">
- <el-option
- v-for="(item, index) in paramsOption.connectorIds"
- :key="index"
- :label="item"
- :value="item"/>
- </el-select>
- </el-form-item>
- <el-form-item
- label="Transaction ID:"
- prop="transactionId"
- v-if="paramsOption.needActConnector">
- <el-select
- v-model="operationForm.transactionId"
- class="flex-item">
- <el-option
- v-for="(item, index) in paramsOption.connectorActIds"
- :key="index"
- :label="item"
- :value="item"/>
- </el-select>
- </el-form-item>
- <el-form-item
- label="Mobile Number:"
- prop="idTagInfo"
- v-if="paramsOption.idTagAll.length > 0">
- <el-select
- v-model="operationForm.idTagInfo"
- filterable
- remote
- :remote-method="filterMobile"
- class="flex-item"
- :loading="tagLoading">
- <el-option
- v-for="(item, index) in paramsOption.idTags"
- :key="index"
- :label="item.name"
- :value="item.value"/>
- </el-select>
- </el-form-item>
- <el-form-item
- label="Availability Type:"
- prop="availType"
- v-if="paramsOption.availTypeOption.length > 0">
- <el-select
- v-model="operationForm.availType"
- class="flex-item"
- placeholder="Select">
- <el-option
- v-for="(item, index) in paramsOption.availTypeOption"
- :key="index"
- :label="item.name"
- :value="item.value"/>
- </el-select>
- </el-form-item>
- <el-form-item
- label="Charging Profile Purpose:"
- prop="chargingProfilePurpose"
- v-if="paramsOption.needChargingProfilePurpose">
- <el-select
- v-model="operationForm.chargingProfilePurpose"
- class="flex-item">
- <el-option
- v-for="(item, index) in paramsOption.chargingPurposeOption"
- :key="index"
- :label="item.name"
- :value="item.value"/>
- </el-select>
- </el-form-item>
- <el-form-item
- label="Stack Level (integer):"
- v-if="paramsOption.needChargingProfilePurpose">
- <el-input
- v-model="operationForm.stackLevel"
- class="flex-item"/>
- </el-form-item>
- <el-form-item
- label="Key Type:"
- prop="keyType"
- v-if="paramsOption.keyTypeOption.length > 0">
- <el-select
- v-model="operationForm.keyType"
- class="flex-item"
- placeholder="Select"
- @change="changeKeyType">
- <el-option
- v-for="(item, index) in paramsOption.keyTypeOption"
- :key="index"
- :label="item.name"
- :value="item.value"/>
- </el-select>
- </el-form-item>
- <div
- class="multi-select"
- v-if="paramsOption.confKeyOption.length > 0 && paramsOption.selectMultConfig">
- <span class="note-span">Info: If none selected, the charge point returns a list of all configuration settings.</span>
- <el-form-item
- label="Configuration Key:">
- <el-select
- v-model="operationForm.confKeyList"
- class="flex-item"
- style="align-items: flex-start;"
- placeholder="Select multiple"
- :multiple="true">
- <el-option
- v-for="(item, index) in paramsOption.confKeyOption"
- :key="index"
- :label="item.name"
- :value="item.value"/>
- </el-select>
- </el-form-item>
- </div>
- <el-form-item
- label="Configuration Key:"
- prop="confKey"
- v-else-if="paramsOption.confKeyOption.length > 0 && operationForm.keyType == 'PREDEFINED'">
- <el-select
- v-model="operationForm.confKey"
- class="flex-item"
- placeholder="Select">
- <el-option
- v-for="(item, index) in paramsOption.confKeyOption"
- :key="index"
- :label="item.name"
- :value="item.value"/>
- </el-select>
- </el-form-item>
- <el-form-item
- label="Custom Configuration Key:"
- prop="customConfKey"
- label-width="205px"
- v-if="paramsOption.keyTypeOption.length > 0 && operationForm.keyType == 'CUSTOM'">
- <el-input
- v-model="operationForm.customConfKey"
- class="flex-item"/>
- </el-form-item>
- <el-form-item
- label="Value:"
- v-if="paramsOption.keyTypeOption.length > 0">
- <el-input
- v-model="operationForm.value"
- class="flex-item"/>
- </el-form-item>
- <el-form-item
- label="Reset Type:"
- prop="resetType"
- v-if="paramsOption.resetTypeOption.length > 0">
- <el-select
- class="flex-item"
- v-model="operationForm.resetType">
- <el-option
- v-for="(item, index) in paramsOption.resetTypeOption"
- :key="index"
- :label="item.name"
- :value="item.value"/>
- </el-select>
- </el-form-item>
- <template v-if="operationInfo.value == 'UF'">
- <el-form-item
- label="Location(directory URI):"
- prop="location">
- <el-input
- v-model="operationForm.location"
- class="flex-item"/>
- </el-form-item>
- <el-form-item
- label="Retries(integer):">
- <el-input
- v-model="operationForm.retries"
- class="flex-item"/>
- </el-form-item>
- <el-form-item
- label="Retry Interval(integer):">
- <el-input
- v-model="operationForm.retryInterval"
- class="flex-item"/>
- </el-form-item>
- <el-form-item
- label="Retrieve Date/Time:"
- prop="retrieve">
- <el-date-picker
- v-model="operationForm.retrieve"
- type="datetime"
- format="yyyy-MM-dd HH:mm"
- value-format="yyyy-MM-dd HH:mm"
- default-time="12:00:00"
- class="flex-item"/>
- </el-form-item>
- </template>
- <div class="perform">
- <el-button
- style="margin-left: 15px;"
- type="primary"
- native-type="submit"
- :loading="btnLoading"
- @click="perform">
- Perform
- </el-button>
- </div>
- </el-form>
- </div>
- </div>
- </div>
- </template>
- <script>
- import Pagination from '@/components/Pagination'
- import site from '../../http/api/site'
- import ocpp from '../../http/api/ocpp'
- import util from './operationUtil'
- const NOT_SPECIFIC = 'Not for a specific connector'
- export default {
- data() {
- return {
- tagLoading: false,
- listLoading: false,
- siteLoading: false,
- paramLoading: false,
- btnLoading: false,
- siteList: [],
- siteKeyword: '',
- stationList: [],
- total: 0,
- listQuery: {
- pageNo: 1,
- pageSize: 10,
- pageVo: {
- sitePk: '',
- stationId: ''
- }
- },
- operationInfo: {},
- operationList: ocpp.getOperationList(),
- operationForm: {
- value: '',
- confKey: '',
- keyType: '',
- resetType: '',
- operation: '',
- availType: '',
- idTagInfo: '',
- filterType: '',
- location: "",
- retrieve: "",
- retries: "",
- retryInterval: "",
- confKeyList: [],
- stationIds: [],
- stackLevel: '',
- connectorId: '',
- transactionId: '',
- customConfKey: '',
- chargingProfilePk: '',
- chargingProfilePurpose: undefined
- },
- paramsOption: {
- idTags: [],
- idTagAll: [],
- connectorIds: [],
- connectorActIds: [],
- needConnector: false,
- needActConnector: false,
- selectMultConfig: false,
- confKeyOption: [],
- keyTypeOption: [],
- availTypeOption: [],
- resetTypeOption: [],
- filterTypeOption: [],
- needCustomCoinfig: false,
- needChargingProfile: false,
- chargingProfileOption: [],
- chargingPurposeOption: [],
- needChargingProfilePurpose: false
- },
- rule: {
- idTagInfo: {
- required: true,
- trigger: 'change',
- message: 'Please select ID tag'
- },
- operation: {
- required: true,
- trigger: 'change',
- message: 'Please select operation'
- },
- confKey: {
- required: true,
- trigger: 'change',
- message: 'Please select configuration key'
- },
- keyType: {
- required: true,
- trigger: 'change',
- message: 'Please select key type'
- },
- resetType: {
- required: true,
- trigger: 'change',
- message: 'Please select reset type'
- },
- availType: {
- required: true,
- trigger: 'change',
- message: 'Please select availability type'
- },
- filterType: {
- required: true,
- trigger: 'change',
- message: 'Please select filter type'
- },
- connectorId: {
- required: true,
- trigger: 'change',
- message: 'Please select a connector ID'
- },
- confKeyList: {
- required: true,
- trigger: 'change',
- message: 'Please select at last least 1 config key'
- },
- transactionId: {
- required: true,
- trigger: 'change',
- message: 'Please select a active transaction ID'
- },
- customConfKey: {
- required: true,
- trigger: 'blur',
- message: 'Please input custom configuration key'
- },
- chargingProfilePk: {
- required: true,
- trigger: 'change',
- message: 'Please select Charging Profile ID'
- },
- chargingProfilePurpose: {
- required: true,
- trigger: 'change',
- message: 'Please select Charging Profile Purpose'
- },
- location: {
- required: true,
- trigger: 'blur',
- message: 'Please input location'
- },
- retrieve: {
- required: true,
- trigger: 'change',
- message: 'Please select retrieve date time'
- }
- },
- columns: [{
- key: 'siteName',
- label: 'Site Name'
- }, {
- key: 'stationId',
- label: 'Station ID'
- }, {
- key: 'lastHeartbeat',
- label: 'Last Heartbeat'
- }, {
- key: 'checked',
- label: 'Select',
- action: true,
- width: 70
- }],
- searchTag: ""
- }
- },
- components: { Pagination },
- created() {
- this.getAllSite();
- },
- methods: {
- filterSite(word) {
- this.siteKeyword = word;
- this.siteLoading = true;
- this.getAllSite();
- },
- getAllSite() {
- site.getAllSiteList({siteName: this.siteKeyword}).then(res => {
- var list = []
- if (this.siteKeyword == '') {
- list = [{siteName: 'All', sitePk: ''}]
- }
- if (res.data && res.data.length > 0) {
- this.siteList = list.concat(res.data)
- } else {
- this.siteList = []
- }
- this.siteLoading = false;
- this.changeSite();
- }).catch(err => {
- this.siteLoading = false;
- });
- },
- async changeSite() {
- this.listLoading = true;
- const res = await ocpp.getStationPages(this.listQuery);
- if (res.success) {
- this.total = res.total;
- this.stationList = res.data;
- }
- this.listLoading = false;
- },
- async changeOperation(index) {
- this.paramLoading = true;
- this.operationForm = {
- operation: this.operationForm.operation,
- value: '',
- confKey: '',
- keyType: '',
- resetType: '',
- availType: '',
- idTagInfo: '',
- filterType: '',
- location: "",
- retrieve: "",
- retries: "",
- retryInterval: "",
- confKeyList: [],
- stationIds: [],
- stackLevel: '',
- connectorId: '',
- transactionId: '',
- customConfKey: '',
- chargingProfilePk: '',
- chargingProfilePurpose: undefined
- }
- this.operationInfo = this.operationList[index];
- this.selectNone();
- this.paramsOption = await util.getOperationParams(this.operationInfo, /*this.getCheckedStation()*/);
- //console.log('-----', paramsOption);
- this.paramLoading = false;
- this.$refs['operationForm'].clearValidate()
- },
- async changeRow(index, checked) {
- if (checked && this.operationInfo.singleStation) {
- this.selectNone();
- this.stationList[index].checked = true;
- }
- this.operationForm.stationIds = this.getCheckedStation();
- if (this.paramsOption.needConnector) {
- this.operationForm.connectorId = '';
- let list = await util.getConnectorIds(this.operationForm.stationIds);
- if (this.operationInfo.value == 'RSTART') {
- list.unshift(NOT_SPECIFIC)
- }
- this.paramsOption.connectorIds = list
- }
- if (this.paramsOption.needActConnector) {
- this.operationForm.transactionId = '';
- let list = await util.getActiveConnectorIds(this.operationForm.stationIds);
- this.paramsOption.connectorActIds = list;
- }
- },
- changeKeyType() {
- if (this.operationForm.keyType == 'PREDEFINED') {
- this.operationForm.confKey = '';
- } else {
- this.operationForm.customConfKey = '';
- }
- this.$refs['operationForm'].clearValidate()
- },
- changeFilterType() {
- if (this.operationForm.filterType == 'ChargingProfileId') {
- this.operationForm.connectorId = '';
- this.paramsOption.needConnector = false;
- this.paramsOption.needChargingProfile = true;
- this.operationForm.chargingProfilePurpose = undefined;
- this.paramsOption.needChargingProfilePurpose = false;
- } else {
- this.paramsOption.needConnector = true;
- this.operationForm.chargingProfilePk = '';
- this.paramsOption.needChargingProfile = false;
- this.paramsOption.needChargingProfilePurpose = true;
- if (this.paramsOption.connectorIds.length == 0) {
- this.changeRow();
- }
- }
- this.$refs['operationForm'].clearValidate()
- },
- getCheckedStation() {
- let list = [];
- this.stationList.forEach(item => {
- if (item.checked)
- list.push(item.stationId)
- })
- return list;
- },
- selectNone() {
- this.stationList.forEach(item => {
- item.checked = false;
- })
- this.paramsOption.connectorIds = [];
- this.operationForm.connectorId = '';
- this.operationForm.stationIds = [];
- },
- selectAll() {
- if (!this.operationInfo.singleStation) {
- this.stationList.forEach(item => {
- item.checked = true;
- })
- } else {
- this.stationList[0].checked = true;
- }
- this.changeRow();
- },
- handlePageChange() {
- this.changeSite()
- },
- perform() {
- this.$forceUpdate();
- this.$refs['operationForm'].validate(result => {
- if (result) {
- //this.addStation();
- if (this.operationForm.stationIds.length == 0) {
- this.$message({
- type: 'error',
- message: 'Please select at least 1 charge point'
- })
- } else if (this.operationInfo.api) {
- this.btnLoading = true;
- const params = Object.assign({}, this.operationForm)
- //对参数做特殊处理
- if (params.connectorId === NOT_SPECIFIC) {
- params.connectorId = ''
- }
- if (params.idTagInfo !== '') {
- params.idTagInfo = JSON.parse(params.idTagInfo)
- }
- ocpp.sendPerform(this.operationInfo.api, params).then(res => {
- this.btnLoading = false;
- if (res.data.taskId) {
- this.$router.push({path: '/ocpp-operations/result/' + res.data.taskId});
- }
- }).catch(err => {
- this.btnLoading = false;
- this.$message({
- type: 'error',
- message: err
- })
- });
- }
- }
- })
- },
- filterMobile(word) {
- if (word) {
- this.searchTag = word;
- setTimeout(() => {
- this.searchMobile(word)
- }, 300)
- } else {
- this.paramsOption.idTags = []
- this.paramsOption.idTags.push(...this.paramsOption.idTagAll)
- }
- },
- searchMobile(word) {
- console.log(this.searchTag, word);
- if (this.searchTag === word) {
- this.tagLoading = true;
- util.filterMobile(word, tags => {
- this.paramsOption.idTags = tags;
- this.tagLoading = false;
- })
- }
- }
- }
- }
- </script>
- <style scoped="scoped" lang='scss'>
- @import '../../styles/variables.scss';
-
- .card-container {
- width: 100%;
- padding: 20px 40px;
- min-height: $mainAppMinHeight;
- background-color: #F0F5FC;
- }
- .card-content {
- display: flex;
- overflow-x: auto;
- padding: 15px 5px;
- border-radius: 6px;
- flex-direction: row;
- flex-wrap: wrap-reverse;
- background-color: white;
- }
- .ocpp-content {
- flex: 1;
- min-width: 520px;
- padding: 0 35px 0 15px;
- }
- .section-title {
- color: #333;
- margin-top: 20px;
- margin-bottom: 30px;
- font-size: 16px;
- user-select: none;
- line-height: 24px;
- font-weight: 500;
- white-space: nowrap;
- font-family: sans-serif;
- text-transform: uppercase;
- }
- .perform {
- text-align: center;
- padding: 20px 80px 30px 0;
- }
- .multi-select {
- position: relative;
- min-height: 200px;
- }
- .note-span {
- top: 40px;
- left: 0px;
- width: 180px;
- color: #333333;
- padding: 6px 10px;
- font-size: 12px;
- border-radius: 3px;
- position: absolute;
- background-color: #56D905;
- }
- .flex-item {
- width: 100%;
- max-width: 320px;
- }
- @media screen and (max-width: 500px) {
- .card-container {
- padding: 0px;
- }
- .card-content {
- padding: 10px;
- }
- .ocpp-content {
- flex: 1;
- min-width: 320px;
- padding-right: 20px;
- }
- .perform {
- padding: 20px 0;
- }
- }
- </style>
|