| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100 |
- <template>
- <div class="view-container" v-loading="pageLoading">
- <el-form
- ref="addForm"
- :rules="rules"
- :model="siteForm"
- label-position="right"
- label-width="120px"
- style="width: 100%;">
- <div class="flexr">
- <div class="flexl flex1">
- <div class="view-content flex1">
- <div class="section-title" id="idSiteInfo">Site Information</div>
- <el-form-item
- label="Site Name:"
- prop="siteName">
- <el-input
- :disabled="isMCSTUser"
- v-model="siteForm.siteName"
- class="input-text" />
- </el-form-item>
- <el-form-item
- prop="locationLatitude"
- label="Latitude:">
- <el-input
- :disabled="isMCSTUser"
- v-model="siteForm.locationLatitude"
- class="input-text" />
- </el-form-item>
- <el-form-item
- prop="locationLongitude"
- label="Longitude:">
- <el-input
- :disabled="isMCSTUser"
- v-model="siteForm.locationLongitude"
- class="input-text"/>
- </el-form-item>
- <el-form-item
- prop="address.countryCode"
- label="Country:">
- <el-select
- v-model="siteForm.address.countryCode"
- class="input-text"
- :disabled="isMCSTUser">
- <el-option
- v-for="item in countryOptions"
- :key="item.name"
- :label="item.name"
- :value="item.value" />
- </el-select>
- </el-form-item>
- <el-form-item
- prop="address.city"
- label="City:">
- <el-input
- v-model="siteForm.address.city"
- class="input-text"
- :disabled="isMCSTUser"/>
- </el-form-item>
- <el-form-item
- prop="address.street"
- label="Street:">
- <el-input
- v-model="siteForm.address.street"
- class="input-text"
- :disabled="isMCSTUser"/>
- </el-form-item>
- <el-form-item
- prop="address.zipCode"
- label="Postal Code:">
- <el-input
- v-model="siteForm.address.zipCode"
- class="input-text"
- :disabled="isMCSTUser"/>
- </el-form-item>
- </div>
- <div class="view-content">
- <div class="section-title">Additional Information</div>
- <el-form-item
- label-width="130px"
- label="Operating Hours:"
- class="flex-item">
- <div class="flexc">
- <el-input
- v-model="siteForm.operatingHours"
- :disabled="isMCSTUser || !!siteForm.endlessService"
- class="input-text" />
- <el-switch
- :disabled="isMCSTUser"
- @change="changeEndless"
- style="margin-left: 10px"
- inactive-text="24/7"
- v-model="siteForm.endlessService">
- </el-switch>
- </div>
- </el-form-item>
- <el-form-item
- label-width="130px"
- label="Parking Fee:"
- class="flex-item">
- <div class="flexc">
- <el-input
- :disabled="isMCSTUser || !!siteForm.free"
- v-model="siteForm.parkingFee"
- class="input-text" />
- <el-switch
- :disabled="isMCSTUser"
- @change="changeParkingFree"
- style="margin-left: 10px"
- inactive-text="Free"
- v-model="siteForm.free">
- </el-switch>
- </div>
- </el-form-item>
- <el-form-item
- label-width="130px"
- label="Additional Notes:">
- <el-input
- :disabled="isMCSTUser"
- v-model="siteForm.additionalNotes"
- type="textarea"
- :autosize="autosize"
- class="input-text" />
- </el-form-item>
- <el-form-item
- label-width="130px"
- label="Carpark Code:">
- <el-input
- v-model="siteForm.carParkCode"
- class="input-text" />
- </el-form-item>
- </div>
- </div>
- <div class="flexl flex1">
- <div class="view-content" style="padding: 15px;">
- <dashboard
- v2
- :enable="isEdit"
- :info="summaryInfo"
- :siteId="siteForm.sitePk"/>
- </div>
-
- <div class="view-content flex1">
- <div class="section-title flexcr">
- Site Summary
- <div class="section-sub-title">(Currency Used: {{currencyData[siteForm.address.countryCode]}})</div>
- </div>
- <Summary
- :info="summaryInfo"
- :currency="currencyData[siteForm.address.countryCode]"/>
- </div>
-
- <div class="view-content" id="idSiteTypes" v-if="false">
- <div class="section-title">Site EMAIL Configuration</div>
- <email-recipient v-model="siteForm.emails"/>
- </div>
- </div>
- </div>
-
- <div class="view-content">
- <div class="section-title">TIME CONFIGURATION</div>
- <div class="site-type-layout">
- <site-type-with-time
- :siteTypes="siteForm.siteTypes"
- :sitePk="siteForm.sitePk"
- @change="changeSiteTypes"/>
- </div>
- </div>
-
- <div class="view-content">
- <div class="section-title">OCPP SETTINGS</div>
- <div class="flexr">
- <div class="flex2">
- <el-form-item
- label-width="150px"
- label="Heartbeat Interval:"
- prop="heartbeat"
- class="flex1">
- <div class="flexc">
- <el-input
- class="value-text"
- v-model="siteForm.ocppSetting.heartbeatIntervalMinutes"
- placeholder=""
- maxlength="5"/>
- <span class="value-unit">Minutes</span>
- </div>
- </el-form-item>
- <div class="tips">The time interval in <i>minutes</i> for how often a charge point should request the current time from the CSMS.</div>
- </div>
- <div class="flex1">
- <p></p>
- </div>
- <div class="flex2">
- <el-form-item
- label="Expiration:"
- prop="expiration"
- label-width="95px"
- class="flex1">
- <div class="flexc">
- <el-input
- class="value-text"
- v-model="siteForm.ocppSetting.expireHours"
- placeholder=""
- maxlength="5"/>
- <span class="value-unit">Hours</span>
- </div>
- </el-form-item>
- <div class="tips" style="padding-left: 95px;">The amount of time in <i>hours</i> for how long a charge point should cache the authorization info of an idTag in its local white list, if an expiry date is not explicitly set.
- The value 0 disables this functionality
- (i.e.no expiry date will be set).</div>
- </div>
- </div>
- </div>
-
- <div class="view-content" id="idChargeRates">
- <!--div class="section-title flexcr">
- CHARGE SITE RATE
- <div class="section-sub-title">(Currency Used: {{currencyData[siteForm.address.countryCode]}})</div>
- </div>
- <charge-rate
- v-model="ratesForm.chargeRates"/>
- <div class="sparator"></div>
- <div class="section-title flexcr">
- SPECIAL CHARGE RATE
- <div class="section-sub-title">(Currency Used: {{currencyData[siteForm.address.countryCode]}})</div>
- </div>
- <charge-rate
- isSpecial
- v-model="ratesForm.specialChargeRates"/>
- <div class="sparator"></div>-->
- <div class="section-title">Reservations</div>
- <reservation
- :enabled.sync="siteForm.enableReservation"
- :limit.sync="siteForm.timeLimit"
- />
- <div class="sparator" v-if="isEdit"></div>
- <div class="section-title" v-if="isEdit">LOAD BALANCING</div>
- <!-- <Balancing v-model="balancingForm"/> -->
- <div class="new-load-balance" v-if="isEdit" style="padding-bottom: 20px;">
- <span class="new-text">NEW!</span>
- <span class="link-type" @click="configLoadBalance">Configure load balancing in a new window</span>
- </div>
- <template v-if="enableWhitelistFleet">
- <div class="sparator"></div>
- <div class="section-title">WHITELIST GROUP</div>
- <white-list-fleet v-model="siteForm.groupWhitelist"/>
- </template>
-
- <template v-if="enableWhitelistUser">
- <div class="sparator"></div>
- <div class="section-title">WHITELIST USERS</div>
- <white-list-user v-model="siteForm.whitelistUser"/>
- </template>
- <div class="sparator"></div>
- <div class="section-title flexcwr">
- Idle Fee SETTINGS
- <div class="idle-switch">
- <el-switch
- inactive-text="Enable Idle Fee"
- v-model="siteForm.enableIdleFee"/>
- </div>
- </div>
- <el-row :gutter="20" v-if="siteForm.enableIdleFee">
- <el-col :xs="24" :md="12" :lg="8">
- <el-form-item
- label="Effective From:"
- label-width="140px"
- prop="effectiveFrom">
- <el-time-picker
- v-model="siteForm.effectiveFrom"
- class="input-text"
- format="HH:mm"
- value-format="HH:mm"/>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :md="12" :lg="8">
- <el-form-item
- label="Effective To:"
- label-width="140px"
- prop="effectiveTo">
- <el-time-picker
- v-model="siteForm.effectiveTo"
- class="input-text"
- format="HH:mm"
- value-format="HH:mm"/>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :md="12" :lg="8">
- <el-form-item
- label="Grace Period:"
- label-width="140px"
- prop="gracePeriod"
- style="position: relative;">
- <template slot="label">
- <span>Grace Period:</span>
- <span class="label-unit">(minutes)</span>
- </template>
- <el-input
- maxlength="4"
- v-model.number="siteForm.gracePeriod"
- type="number"
- class="input-text"/>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :md="12" :lg="8">
- <el-form-item
- label="Idle Fee:"
- label-width="140px"
- prop="idleFee">
- <el-input
- v-model="siteForm.idleFee"
- class="input-text"
- oninput="value=value.replace(/[^\d.]/g, '').replace(/\.{2,}/g, '.').replace('.', '$#$').replace(/\./g, '').replace('$#$', '.').replace(/^(\-)*(\d+)\.(\d\d\d).*$/, '$1$2.$3').replace(/^\./g, '')"
- maxlength="8"/>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :md="12" :lg="8">
- <el-form-item
- label="Idle Fee Interval"
- label-width="140px"
- prop="everyMinute"
- style="position: relative;">
- <template slot="label">
- <span>Idle Fee Interval:</span>
- <span class="label-unit">(minute)</span>
- </template>
- <el-input
- maxlength="4"
- type="number"
- v-model.number="siteForm.everyMinute"
- class="input-text"/>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :md="12" :lg="8">
- <el-form-item
- label="Effective Date:"
- label-width="140px"
- prop="effectiveDate">
- <el-date-picker
- v-model="siteForm.effectiveDate"
- class="input-text"
- format="yyyy-MM-dd"
- value-format="yyyy-MM-dd"/>
- </el-form-item>
- </el-col>
- </el-row>
- </div>
- <div class="view-content">
- <div class="section-title">SITE EMAIL CONFIGURATION</div>
- <div class="flexcr">
- <email-recipient v-model="siteForm.emails"/>
- <div class="flex1">
- <el-checkbox-group
- class="features-group"
- v-model="siteForm.enabledFeatures">
- <template v-for="(item, index) in featuresOptions">
- <el-checkbox
- :key="index"
- :label="item.value">{{item.name}}</el-checkbox>
- </template>
- </el-checkbox-group>
- </div>
- </div>
- </div>
- <div class="view-content flexcr">
- <div class="buttons">
- <el-button
- class="cancel-button"
- type="primary"
- @click="handleClickCancleButton">
- Cancel
- </el-button>
- <el-button
- class="confirm-button"
- type="primary"
- @click="handleClickSaveButton">
- Save
- </el-button>
- </div>
- <div
- class="update-by"
- v-if="isEdit">
- <span
- class="add-text"
- :title='"CREATED BY " + siteForm.createdBy + " ON " + siteForm.createdOn'>
- LAST UPDATED BY {{siteForm.updatedBy}} TIMESTAMP: {{siteForm.updatedOn}}
- </span>
- </div>
- </div>
- </el-form>
- </div>
- </template>
- <script>
- import settings from '../../settings.js'
- import Summary from '../site/components/Summary'
- import Dashboard from '../site/components/Dashboard'
- import ChargeRate from '../site/components/ChargeRate'
- import Balancing from '../site/components/Balancing'
- import EmailRecipient from '../site/components/EmailRecipient'
- import Reservation from '../site/components/Reservations'
- import WhiteListFleet from '../site/components/WhiteListFleet'
- import WhiteListUser from '../site/components/WhiteListUser'
- import SiteTypeWithTime from './components/SiteTypeWithTime'
- import waves from '@/directive/waves' // waves directive
- import site from '../../http/api/site'
- import apiSet from '../../http/api/settings'
- import { getRoleName } from '@/utils/auth'
- export default {
- directives: { waves },
- components: {
- Balancing,
- ChargeRate,
- Dashboard,
- EmailRecipient,
- Reservation,
- WhiteListUser,
- WhiteListFleet,
- SiteTypeWithTime,
- Summary
- },
- data() {
- return {
- pageLoading: false,
- isMCSTUser: false,
- countryOptions: [],
- featuresOptions: [],
- siteForm: {
- sitePk: "",
- siteName: "",
- siteTypes: [],
- emails: [],
- carParkCode: "",
- address: {
- city: "",
- countryCode: settings.defaultCountry,
- street: "",
- zipCode: ""
- },
- ocppSetting: {
- expireHours: '',
- ocppSettingId: '',
- heartbeatIntervalMinutes: ''
- },
- free: false,
- endlessService: false,//24/7
- additionalNotes: "",
- //罚款部分
- enableIdleFee: false,//idle Fee
- idleFee: "",//idle Fee
- everyMinute: "",//idle Fee
- effectiveDate: "",//idle Fee
- effectiveFrom: "",//idle Fee
- effectiveTo: "",//idle Fee
- gracePeriod: "",//idle Fee
- //预订部分
- enableReservation: false,//预订
- timeLimit: null,//预订
-
- parkingFee: "",
- whitelistUser: [],
- groupWhitelist: [],
- operatingHours: "",
- locationLatitude: "",
- locationLongitude: "",
- chargeRates: [],
- specialChargeRates: [],
- loadBalancing: "",//负载均衡
- staticMaxAmpere: "",//负载均衡
- siteChargingProfiles: null,//负载均衡
- enabledFeatures: []
- },
- ratesForm: {
- chargeRates: [{
- rate: '',
- rateType: '',
- chargeTypePk: ''
- }],
- specialChargeRates: [{
- rate: '',
- rateType: '',
- chargeTypePk: '',
- groupPk: ''
- }]
- },
- balancingForm: {
- loadBalancing: 'dynamic',
- staticMaxAmpere: 0,
- siteChargingProfiles: [{
- boxInUse: '',
- chargingProfilePk: ''
- }],
- },
- currencyData: {
- SG: "S$"
- },
- autosize: {
- minRows: 3,
- maxRows: 6,
- },
- summaryInfo: {},
- rules: {
- siteName: {
- required: true,
- trigger: 'blur',
- message: 'Site Name is required',
- },
- locationLatitude: [{
- required: true,
- trigger: 'blur',
- message: 'Latitude is required',
- }, {
- pattern: /^[\-\+]?((0|([1-8]\d?))(\.\d{1,8})?|90(\.0{1,8})?)$/,
- trigger: 'blur',
- message: 'Please type a correct latitude',
- }],
- locationLongitude: [{
- required: true,
- trigger: 'blur',
- message: 'Longitude is required',
- }, {
- pattern: /^[\-\+]?(0(\.\d{1,8})?|([1-9](\d)?)(\.\d{1,8})?|1[0-7]\d{1}(\.\d{1,8})?|180\.0{1,8})$/,
- trigger: 'blur',
- message: 'Please type a correct longitude',
- }],
- address: {
- street: {
- required: true,
- trigger: 'blur',
- message: 'Address is required',
- },
- zipCode: {
- required: true,
- trigger: 'blur',
- message: 'Postal Code is required',
- },
- city: {
- required: true,
- trigger: 'blur',
- message: 'City is required',
- },
- countryCode: {
- required: true,
- trigger: 'blur',
- message: 'Country is required',
- }
- },
- idleFee: {
- required: true,
- trigger: 'blur',
- message: 'Idle fee is required'
- },
- effectiveDate: {
- required: true,
- trigger: 'change',
- message: 'Effective Date is required'
- },
- effectiveFrom: {
- required: true,
- trigger: 'change',
- message: 'Effective From is required'
- },
- effectiveTo: {
- required: true,
- trigger: 'change',
- message: 'Effective To is required'
- },
- gracePeriod: {
- required: true,
- trigger: 'change',
- message: 'Grace Period is required'
- },
- everyMinute: [{
- required: true,
- trigger: 'blur',
- message: 'Every is required'
- }, {
- type: 'number',
- message: 'Every is a number'
- }]
- },
- enablePublic: false,
- enableWhitelistUser: false,
- enableWhitelistFleet: false,
- isEdit: false
- }
- },
- created() {
- this.pageLoading = true;
- this.isMCSTUser = getRoleName() === "MCST";
- this.getCountryOptions();
- this.getFeaturesList();
- if (this.$route.params.id) {
- this.isEdit = true;
- this.getSiteInfo()
- } else {
- setTimeout(() => {
- this.pageLoading = false;
- }, 500);
- }
- },
- methods: {
- getCountryOptions() {
- site.getCountryList().then(res => {
- if (res.data) {
- this.countryOptions = res.data
- const sign = {}
- res.data.forEach(item => {
- sign[item.value] = item.currencySymbol
- })
- this.currencyData = sign;
- }
- }).catch(() => {
- this.$message({
- message: err,
- type: 'error',
- duration: 3000,
- })
- this.pageLoading = false;
- })
- },
- getFeaturesList() {
- apiSet.getFeatures().then(res => {
- if (res.data) {
- this.featuresOptions = res.data;
- }
- }).catch(() => {
- this.$message({
- message: err,
- type: 'error',
- duration: 3000,
- })
- this.pageLoading = false;
- })
- },
- getSiteInfo() {
- site.getSiteInfo({
- sitePk: this.$route.params.id,
- }).then(res => {
- if (res.data) {
- if (!res.data.enabledFeatures) {
- res.data.enabledFeatures = []
- }
- this.siteForm = res.data;
- this.applySiteInfo();
- } else {
- this.pageLoading = false;
- }
- }).catch(() => {
- this.$message({
- message: err,
- type: 'error',
- duration: 3000,
- })
- this.pageLoading = false;
- })
- },
- applySiteInfo() {
- setTimeout(() => {
- this.pageLoading = false;
- }, 500);
- if (this.siteForm.chargeRates && this.siteForm.chargeRates.length) {
- const rate = [], srate = []
- this.siteForm.chargeRates.forEach(item => {
- if (item.groupPk) {
- srate.push(item)
- } else {
- rate.push(item)
- }
- })
- if (rate.length > 0) {
- this.ratesForm.chargeRates = rate;
- }
- if (srate.length > 0) {
- this.ratesForm.specialChargeRates = srate;
- }
- }
- if (this.siteForm.siteTypes && this.siteForm.siteTypes.length) {
- for (let type of this.siteForm.siteTypes) {
- if (type.siteType == "PRI_USR_WHI") {
- this.enableWhitelistUser = (type.allDay || (type.startTime && type.endTime))
- } else if (type.siteType == "PRI_FLE_WHI") {
- this.enableWhitelistFleet = (type.allDay || (type.startTime && type.endTime))
- } else if (type.siteType == "PUB") {
- this.enablePublic = (type.allDay || (type.startTime && type.endTime))
- } else {
- continue;
- }
- }
- }
- if (this.siteForm.siteSummary) {
- this.summaryInfo = Object.assign(this.siteForm.siteSummary, {});
- delete this.siteForm.siteSummary;
- }
- this.balancingForm = {
- loadBalancing: this.siteForm.loadBalancing || 'dynamic',
- staticMaxAmpere: this.siteForm.staticMaxAmpere || 0,
- siteChargingProfiles: this.siteForm.siteChargingProfiles || [{
- boxInUse: '',
- chargingProfilePk: ''
- }]
- }
- },
- changeEndless(value) {
- if (value) {
- this.siteForm.operatingHours = ""
- }
- },
- changeParkingFree(value) {
- if (value) {
- this.siteForm.parkingFee = ""
- }
- },
- changeSiteTypes(data) {
- if (this.isEdit && this.pageLoading) {
- console.log("changeSiteTypes", data);
- return;
- }
- this.siteForm.siteTypes = data;
- /*for (let type of data) {
- if (type.siteType == "PRI_USR_WHI") {
- this.enableWhitelistUser = (type.allDay || (type.startTime && type.endTime))
- } else if (type.siteType == "PRI_FLE_WHI") {
- this.enableWhitelistFleet = (type.allDay || (type.startTime && type.endTime))
- } else if (type.siteType == "PUB") {
- this.enablePublic = (type.allDay || (type.startTime && type.endTime))
- } else {
- continue;
- }
- }*/
- },
- handleClickCancleButton() {
- this.$router.push({
- path: "/site-management-v2/site-configuration"
- });
- },
- handleClickSaveButton() {
- this.$refs['addForm'].validate(result => {
- if (result) {
- const rates = [];
- /* 启用动态费率配置
- this.ratesForm.chargeRates.forEach(item => {
- if (item.rate) {
- rates.push(item);
- }
- })
- this.ratesForm.specialChargeRates.forEach(item => {
- if (item.rate) {
- rates.push(item);
- }
- })
- if (rates.length == 0) {
- this.$message({
- message: "Please add at least one rate",
- type: 'error',
- duration: 3000,
- })
- this.scrollToView("idChargeRates", true);
- return;
- }*/
- if (!this.siteForm.enableReservation) {
- this.siteForm.timeLimit = "";
- }
- /*const chargeProfiles = []
- this.balancingForm.siteChargingProfiles.forEach(item => {
- if (item.boxInUse && item.chargingProfilePk)
- chargeProfiles.push(item)
- })
- this.siteForm.siteChargingProfiles = chargeProfiles
- if (this.balancingForm.loadBalancing == 'dynamic') {
- this.siteForm.staticMaxAmpere = ""
- } else {
- this.siteForm.staticMaxAmpere = this.balancingForm.staticMaxAmpere
- }
- this.siteForm.loadBalancing = this.balancingForm.loadBalancing*/
- /*if (!this.enablePublic && !this.enableWhitelistFleet && !this.enableWhitelistUser) {
- this.$message({
- message: "Please set time configuration",
- type: 'error',
- duration: 3000,
- })
- this.scrollToView("idSiteTypes");
- return;
- }*/
- if (this.enableWhitelistUser) {
- let _list = []
- this.siteForm.whitelistUser.forEach(item => {
- if (item.mobileNumber && item.licenceNumber) {
- _list.push(item);
- }
- })
- if (_list.length == 0) {
- this.$message({
- message: "Please add at least one whitelist user",
- type: 'error',
- duration: 3000,
- })
- return;
- } else {
- this.siteForm.whitelistUser = _list;
- }
- } else {
- this.siteForm.whitelistUser = [];
- }
- if (this.enableWhitelistFleet) {
- let _list = []
- this.siteForm.groupWhitelist.forEach(item => {
- if (item.groupPk) {
- _list.push(item);
- }
- })
- if (_list.length == 0) {
- this.$message({
- message: "Please add at least one whitelist group",
- type: 'error',
- duration: 3000,
- })
- return;
- } else {
- this.siteForm.groupWhitelist = _list;
- }
- } else {
- this.siteForm.groupWhitelist = []
- }
- if (this.siteForm.enabledFeatures.length > 0 && this.siteForm.emails.length == 0) {
- this.$message({
- message: "Please add at least one email recipients",
- type: 'error',
- duration: 3000,
- })
- return;
- }
- this.pageLoading = true;
- const params = {
- ...this.siteForm,
- chargeRates: rates
- }
- console.log("form", params);
- if (this.isEdit) {
- this.updateSite(params);
- } else {
- this.addSite(params)
- }
- //this.editSiteWithForm();
- } else {
- this.scrollToView("idSiteInfo", true);
- }
- })
- },
- scrollToView(id, alignToTop) {
- //console.log("scrollToView", !alignToTop);
- window.requestAnimationFrame(() => {
- document.getElementById(id).scrollIntoView(!alignToTop, {
- block: "start",
- behavior: "smooth"
- })
- });
- },
- isSiteTypeEnable(index, isSwitch) {
- for (let i = 0; i < this.siteForm.siteTypes.length; i++) {
- let type = this.siteForm.siteTypes[i];
- if (type.allDay) {
- if (index == i && isSwitch) {
- return false;
- } else {
- return true;
- }
- } else {
- continue;
- }
- }
- return false;
- },
- addSite(params) {
- site.addSite(params).then(res => {
- this.$message({
- message: "Add site success",
- type: 'success',
- duration: 3000,
- })
- this.handleClickCancleButton();
- }).catch((error) => {
- this.$message({
- message: error,
- type: "error",
- duration: 5000,
- })
- }).finally(() => {
- this.pageLoading = false;
- })
- },
- updateSite(params) {
- site.updateSite(params).then(res => {
- this.$message({
- message: "Update site success",
- type: 'success',
- duration: 3000,
- })
- this.handleClickCancleButton();
- }).catch((error) => {
- this.$message({
- message: error,
- type: "error",
- duration: 5000,
- })
- }).finally(() => {
- this.pageLoading = false;
- })
- },
- configLoadBalance() {
- this.$openRoute("/smart-energy-management/site-load-balancing/" + this.siteForm.sitePk);
- }
- }
- }
- </script>
- <style scoped lang='scss'>
- @import '../../styles/element-ui.scss';
- @import '../../styles/variables.scss';
-
- .view-container {
- width: 100%;
- padding: 20px 60px;
- min-height: $mainAppMinHeight;
- background-color: #F0F5FC;
- }
-
- .view-content {
- margin: 0 8px 16px;
- padding: 15px 50px;
- border-radius: 6px;
- background-color: white;
- }
-
- @media screen and (max-width: 800px) {
- .view-container {
- padding: 10px 20px;
- }
- .view-content {
- padding: 15px 40px;
- }
- }
-
- @media screen and (max-width: 500px) {
- .view-container {
- padding: 0px;
- }
- .view-content {
- padding: 15px 30px;
- }
- }
-
- .sparator {
- margin: 10px -30px;
- height: 2px;
- background-color: #F0F5FC;
- }
-
- .section-title {
- color: #333333;
- margin-top: 20px;
- margin-bottom: 30px;
- font-size: 15px;
- line-height: 24px;
- font-weight: 700;
- font-family: sans-serif;
- text-transform: uppercase;
- }
-
- .section-sub-title {
- font-size: 14px;
- padding-left: 5px;
- font-weight: normal;
- }
-
- .site-type-layout {
- overflow-x: auto;
- }
-
- .site-type-layout::-webkit-scrollbar-track-piece {
- background-color:#f8f8f8;
- }
-
- .site-type-layout::-webkit-scrollbar {
- width: 7px;
- height: 10px;
- }
- .site-type-layout::-webkit-scrollbar-thumb {
- transition: all .4s;
- border-radius: 30px;
- background-color: rgba($--color-primary, 0.3);
- background-clip: padding-box;
- }
- .site-type-layout::-webkit-scrollbar-thumb:hover {
- background-color: rgba($--color-primary, 0.6);
- }
-
- .input-text {
- width: 100% !important;
- max-width: 300px;
- }
-
- .add-text {
- width: 100%;
- font-size: 14px;
- max-width: 300px;
- }
-
- .add-text ::v-deep .el-textarea__inner,
- .input-text ::v-deep .el-textarea__inner {
- font-family: sans-serif;
- }
-
- .value-text {
- width: 100%;
- min-width: 100px;
- max-width: 200px;
- }
-
- .value-unit {
- padding-left: 10px;
- }
-
- .label-unit {
- left: 0;
- bottom: 0;
- width: 125px;
- font-size: 12px;
- line-height: 1;
- position: absolute;
- }
-
- .cancel-button {
- width: 94px;
- height: 40px;
- }
-
- .confirm-button {
- width: 94px;
- height: 40px;
- margin-left: 20px;
- background: $--color-primary;
- border: 1px solid $--color-primary;
- box-sizing: border-box;
- border-radius: 4px;
- }
-
- ::v-deep .el-switch__label.el-switch__label--left span {
- font-size: 14px;
- color: black;
- }
- .idle-switch {
- font-size: 13px;
- text-transform: none;
- }
- .tips {
- color: #999;
- font-size: 12px;
- padding-left: 150px;
- padding-bottom: 20px;
- }
- .tips i {
- color: #333;
- font-weight: 500;
- font-style: normal;
- }
- .new-load-balance {
- position: relative;
- padding-left: 15px;
- padding-bottom: 20px;
- }
- .new-text {
- top: -10px;
- left: 0px;
- color: #FF1122;
- font-size: 12px;
- position: absolute;
- transform: scale(0.8);
- }
- .features-group {
- min-width: 300px;
- display: flex;
- margin-left: 20px;
- flex-direction: column;
- ::v-deep .el-checkbox {
- display: flex;
- align-items: center;
- padding-bottom: 5px;
- }
- ::v-deep .el-checkbox__label {
- color: #000;
- word-break: break-all;
- white-space: normal;
- }
- ::v-deep .el-checkbox__input.is-checked .el-checkbox__inner::after {
- border-color: $buttonText;
- }
- }
-
- </style>
|