| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446 |
- <template>
- <div class="view-container">
- <div class="view-content" v-loading="pageLoading">
- <el-form
- ref="addSiteForm"
- :rules="rules"
- :model="siteForm"
- label-position="left"
- label-width="100px"
- style="width: 100%;">
- <el-row :gutter="20">
- <el-col :span="12">
- <div class="section-title">
- Site Information
- </div>
- <el-form-item
- label="Site Name:"
- prop="siteInformation.siteName">
- <el-input
- v-model="siteForm.siteInformation.siteName"
- class="input-text" />
- </el-form-item>
- <el-form-item
- prop="siteInformation.latitude"
- label="Latitude:">
- <el-input
- v-model="siteForm.siteInformation.latitude"
- class="input-text" />
- </el-form-item>
- <el-form-item
- prop="siteInformation.longitude"
- label="Longitude:">
- <el-input
- v-model="siteForm.siteInformation.longitude"
- class="input-text" />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <div class="section-title">
- Additional Information
- </div>
- <div style="display: flex; ">
- <el-form-item
- label-width="130px"
- label="Operating Hours:"
- class="flex-item">
- <el-input
- :disabled="siteForm.additionalInformation.endlessService"
- v-model="siteForm.additionalInformation.operatingHours"
- class="input-text" />
- </el-form-item>
- <el-switch
- style="margin-left: 10px"
- inactive-text="24/7"
- @change="endlessServiceSwitchChange"
- v-model="siteForm.additionalInformation.endlessService">
- </el-switch>
- </div>
- <div style="display: flex; ">
- <el-form-item
- label-width="130px"
- label="Parking Fee:"
- class="flex-item">
- <el-input
- :disabled="siteForm.additionalInformation.free"
- v-model="siteForm.additionalInformation.parkingFee"
- class="input-text" />
- </el-form-item>
- <el-switch
- style="margin-left: 10px"
- inactive-text="Free"
- @change="freeSwitchChange"
- v-model="siteForm.additionalInformation.free">
- </el-switch>
- </div>
- <div class="flex">
- <el-form-item
- label-width="130px"
- label="Additional Notes:"
- class="flex-item flex">
- <el-input
- v-model="siteForm.additionalInformation.additionalNotes"
- type="textarea"
- :autosize="additionalNotesAutosize"
- class="input-text" />
- </el-form-item>
- <div class="flexl" style="font-size: 13px; margin-left: 10px;">
- <span>Enable</span>
- <span>Idle Fee</span>
- </div>
- <el-switch
- style="margin-left: 5px;"
- v-model="siteForm.idle.enableIdleFee"/>
- </div>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :span="12">
- <el-form-item
- prop="siteInformation.type"
- label="Type:">
- <div class="type-row" v-for="(item, index) in siteTypeTable">
- <el-time-picker
- v-model="item.startTime"
- format="HH:mm"
- value-format="HH:mm"
- :placeholder="item.label"
- :disabled="isSiteTypeEnable(index)"/>
- <el-time-picker
- v-model="item.endTime"
- format="HH:mm"
- value-format="HH:mm"
- placeholder="End Time"
- :disabled="isSiteTypeEnable(index)"/>
- </div>
- </el-form-item>
- </el-col>
- </el-row>
- <div class="sparator"></div>
- <div class="section-title">
- EMAIL
- </div>
- <el-form
- :model="this"
- :rules="rule"
- ref="recipForm"
- label-position="left"
- label-width="150px">
- <el-row :gutter="20">
- <el-col :xs="24" :sm="16" :md="10" :lg="9">
- <el-form-item
- label="Recipients:"
- prop="recipient">
- <el-input
- class="add-text"
- v-model="recipient"
- placeholder="Add text"
- maxlength="50"/>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-button
- type="primary"
- icon="el-icon-plus"
- @click="addRecipient">
- Add
- </el-button>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :span="24">
- <el-form-item
- label="Added Recipients:">
- <div class="receip-item" v-for="(item, index) in recipients" :key="index">
- <span>{{item}}</span>
- <i class="el-icon-close" @click="deleteRecipient(index)"></i>
- </div>
- <div
- class="link-button"
- v-if="recipients.length > 0"
- @click="clearAllRecipient">Clear All</div>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <!-- <div class="sparator"></div>
- <div class="section-title">
- TIME CONFIGURATION
- </div>
- <el-table
- :data="siteTypeTable"
- fit
- style="width: 100%; max-width: 1000px;">
- <el-table-column
- label="Site Type With Schedule"
- prop="label"/>
- <el-table-column
- label="All Day"
- width="150px">
- <template slot-scope="{row, $index}">
- <el-switch v-model="row.allDay" :disabled="isSiteTypeEnable($index, true)"></el-switch>
- </template>
- </el-table-column>
- <el-table-column
- label="Start Time">
- <template slot-scope="{row, $index}">
- <el-time-picker
- v-model="row.startTime"
- format="HH:mm"
- value-format="HH:mm"
- placeholder="Start Time"
- :disabled="isSiteTypeEnable($index)">
- </el-time-picker>
- </template>
- </el-table-column>
- <el-table-column
- label="End Time">
- <template slot-scope="{row, $index}">
- <el-time-picker
- v-model="row.endTime"
- format="HH:mm"
- value-format="HH:mm"
- placeholder="End Time"
- :disabled="isSiteTypeEnable($index)">
- </el-time-picker>
- </template>
- </el-table-column>
- </el-table> -->
- <!-- prop="siteInformation.type"
- label="Type">
- <el-select
- v-model="siteForm.siteInformation.type"
- class="input-text">
- <el-option
- v-for="item in siteTypeOptions"
- :key="item.name"
- :label="item.name"
- :value="item.value" />
- </el-select>
- </el-form-item> -->
- <div class="sparator"></div>
- <div class="section-title">
- ADDRESS
- </div>
- <el-row :gutter="20">
- <el-col :span="12">
- <el-form-item
- prop="address.country"
- label="Country:">
- <el-select
- v-model="siteForm.address.country"
- class="input-text">
- <el-option
- v-for="item in countryOptions"
- :key="item.name"
- :label="item.name"
- :value="item.value" />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item
- prop="address.street"
- label-width="130px"
- label="Street:">
- <el-input
- v-model="siteForm.address.street"
- class="input-text" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :span="12">
- <el-form-item
- prop="address.city"
- label="City:">
- <el-input
- v-model="siteForm.address.city"
- class="input-text"
- @keyup.enter.native="handleFilter" />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item
- prop="address.postalCode"
- label-width="130px"
- label="Postal Code:">
- <el-input
- v-model="siteForm.address.postalCode"
- class="input-text"
- @keyup.enter.native="handleFilter" />
- </el-form-item>
- </el-col>
- </el-row>
- <div class="sparator"></div>
- <div class="section-title">
- CHARGE RATE
- </div>
- <div
- class="rate-list-view"
- v-for="(item, index) in siteForm.chargeRates"
- :key="item.ratePk">
- <el-form-item
- label="Type"
- label-width="60px"
- :prop="'chargeRates.' + index + '.chargeTypePk'"
- :rules="rules.chargeRate.chargeTypePk">
- <el-select
- v-model="item.chargeTypePk"
- class="rate-text">
- <el-option
- v-for="item in chargeTypeOptions"
- :key="item.chargeTypePk"
- :label="item.chargeType"
- :value="item.chargeTypePk" />
- </el-select>
- </el-form-item>
- <el-form-item
- label="Rate"
- label-width="60px"
- :prop="'chargeRates.' + index + '.rate'"
- :rules="rules.chargeRate.rate">
- <el-input
- v-model="item.rate"
- class="rate-text" />
- </el-form-item>
- <div class="ratePunit">/</div>
- <el-form-item
- label-width="0px"
- prop="type">
- <el-select
- v-model="item.rateType"
- class="rate-type">
- <el-option
- v-for="item in rateTypeOptions"
- :key="item.name"
- :label="item.value"
- :value="item.value" />
- </el-select>
- </el-form-item>
- <img
- class="list-item-icon"
- @click="handleClickSubChargeRateButton(item, index)"
- src="../../assets/form-list-sub.png"/>
- </div>
- <div class="rate-list-view">
- <el-form-item
- label="Type"
- label-width="50px"
- prop="tempChargeRate.chargeTypePk"
- :rules="rules.chargeRate.chargeTypePk">
- <el-select
- v-model="siteForm.tempChargeRate.chargeTypePk"
- class="rate-text">
- <el-option
- v-for="item in chargeTypeOptions"
- :key="item.chargeTypePk"
- :label="item.chargeType"
- :value="item.chargeTypePk" />
- </el-select>
- </el-form-item>
- <el-form-item
- label="Rate"
- label-width="50px"
- prop="tempChargeRate.rate"
- :rules="rules.chargeRate.rate">
- <el-input
- v-model="siteForm.tempChargeRate.rate"
- class="rate-text" />
- </el-form-item>
- <div class="ratePunit">/</div>
- <el-form-item
- label-width="0px">
- <el-select
- v-model="siteForm.tempChargeRate.rateType"
- class="rate-type">
- <el-option
- v-for="item in rateTypeOptions"
- :key="item.name"
- :label="item.value"
- :value="item.value" />
- </el-select>
- </el-form-item>
- <img
- class="list-item-icon"
- @click="handleClickSubTempChargeRateButton"
- src="../../assets/form-list-sub.png"/>
- <img
- class="list-item-icon"
- @click="handleClickAddChargeRateButton"
- src="../../assets/form-list-add.png"/>
- </div>
- <div class="sparator" ></div>
- <div class="specialChangeRate">
- <div class="section-title">
- SPECIAL CHARGE RATE
- <el-switch v-model="swtSpecialRate"/>
- </div>
- <div
- v-for="(item, index) in siteForm.specialChargeRates"
- :key="index"
- v-if="swtSpecialRate"
- class="rate-list-view">
- <el-form-item
- label="Company:"
- label-width="90px"
- :prop="'specialChargeRates.' + index + '.fleetCompanyId'"
- :rules="rules.specialChargeRates.fleetCompanyId">
- <el-select
- v-model="item.fleetCompanyId"
- class="rate-text-max">
- <el-option
- v-for="item in companyOptions"
- :key="item.fleetCompanyId"
- :label="item.fleetCompanyName"
- :value="item.fleetCompanyId">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item
- label="Type:"
- label-width="55px"
- :prop="'specialChargeRates.' + index + '.chargeTypePk'"
- :rules="rules.specialChargeRates.chargeTypePk">
- <el-select v-model="item.chargeTypePk" class="rate-text">
- <el-option
- v-for="item in chargeTypeOptions"
- :key="item.chargeTypePk"
- :label="item.chargeType"
- :value="item.chargeTypePk">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item
- label="Rate:"
- label-width="55px"
- :prop="'specialChargeRates.' + index + '.rate'"
- :rules="rules.specialChargeRates.rate">
- <el-input v-model="item.rate" class="rate-text"></el-input>
- </el-form-item>
- <div class="ratePunit">/</div>
- <el-form-item
- label=""
- label-width="0px"
- :prop="'specialChargeRates.' + index + '.rateType'"
- :rules="rules.specialChargeRates.rateType">
- <el-select v-model="item.rateType" class="rate-type">
- <el-option
- v-for="item in rateTypeOptions"
- :key="item.name"
- :label="item.value"
- :value="item.value"/>
- </el-select>
- </el-form-item>
- <img
- class="list-item-icon"
- @click="handleClickSubSpecialRateButton(item, index)"
- src="../../assets/form-list-sub.png"/>
- <img
- v-if="siteForm.specialChargeRates.length - 1 === index"
- class="list-item-icon"
- @click="handleClickAddSpecialRateButton"
- src="../../assets/form-list-add.png"/>
- </div>
- </div>
- <reservation
- :enable="siteForm.reservation.enable"
- :timeLimit="siteForm.reservation.timeLimit"
- @enable="reservationTimeLimitEnable"
- @time-limit-change="reservationTimeLimitChange"
- />
-
- <div class="sparator" ></div>
- <div class="specialChangeRate">
- <div class="section-title">
- LOAD BALANCING
- </div>
- <Balancing v-model="balancingForm" title="Add"/>
- <!-- <el-row
- :gutter="20"
- v-for="(item, index) in balancingForm.siteChargingProfiles"
- :key="index">
- <el-col :span="6" :offset="0">
- <el-form-item
- label="Chargers In-Use:"
- label-width="150px">
- <el-select v-model="item.boxInUse">
- <el-option
- v-for="(item,index) in [1,2]"
- :key="index"
- :label="item"
- :value="item"
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8" :offset="1">
- <el-form-item
- label="Charging Profile:"
- label-width="150px">
- <el-select v-model="item.chargingProfilePk" filterable>
- <el-option
- v-for="(item,index) in chargingProfileOPtions"
- :key="index"
- :label="item.description"
- :value="item.chargingProfilePk"
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="4" :offset="0">
- <img
- class="list-item-icon"
- @click="handelSubSiteChargingProfiles(index)"
- src="../../assets/form-list-sub.png"
- />
- <img
- v-if="balancingForm.siteChargingProfiles.length - 1 === index"
- class="list-item-icon"
- @click="handleAddSiteChargingProfiles"
- src="../../assets/form-list-add.png"
- />
- </el-col>
- </el-row> -->
- </div>
- <div v-if="enableFleetWhiteList()">
- <div class="sparator"></div>
- <div class="section-title">
- WHITELIST FLEET
- </div>
- <div
- class="rate-list-view"
- v-for="(item, index) in siteForm.fleetWhitelist"
- :key="index">
- <el-form-item
- label-width="50px"
- label="Fleet">
- <el-select
- v-model="item.fleetCompanyId"
- style="margin-right: 10px;">
- <el-option
- v-for="item in companyOptions"
- :key="item.fleetCompanyId"
- :label="item.fleetCompanyName"
- :value="item.fleetCompanyId">
- </el-option>
- </el-select>
- </el-form-item>
- <img
- class="list-item-icon"
- @click="handleClickSubWhiteFleetButton(item, index)"
- src="../../assets/form-list-sub.png"/>
- <img
- v-if="index === siteForm.fleetWhitelist.length - 1"
- class="list-item-icon"
- @click="handleClickAddWhiteFleetButton"
- src="../../assets/form-list-add.png"/>
- </div>
- </div>
- <div v-if="enableUserWhiteList()">
- <div class="sparator"></div>
- <div class="section-title">
- WHITELIST USERS
- </div>
- <div
- class="rate-list-view"
- v-for="(item, index) in siteForm.whitelistUser"
- :key="index">
- <el-form-item
- label-width="130px"
- label="Mobile Number"
- :rules="rules.whitelistUser.mobileNumber"
- :prop="'whitelistUser.' + index + '.mobileNumber'">
- <el-input
- v-model="item.mobileNumber"
- class="rate-text" />
- </el-form-item>
- <el-form-item
- label-width="140px"
- label="Licence Number"
- :rules="rules.whitelistUser.licenceNumber"
- :prop="'whitelistUser.' + index + '.licenceNumber'">
- <el-input
- v-model="item.licenceNumber"
- class="rate-text" />
- </el-form-item>
- <img
- class="list-item-icon"
- @click="handleClickSubWhiteUserButton(item, index)"
- src="../../assets/form-list-sub.png"/>
- <img
- v-if="index === siteForm.whitelistUser.length - 1"
- class="list-item-icon"
- @click="handleClickAddWhiteUserButton"
- src="../../assets/form-list-add.png"/>
- </div>
- </div>
-
- <div v-if="siteForm.idle.enableIdleFee">
- <div class="sparator"></div>
- <div class="section-title">Idle Fee SETTINGS</div>
- <el-row :gutter="20">
- <el-col :span="12">
- <el-form-item
- label="Effective From:"
- label-width="130px"
- prop="idle.effectiveFrom">
- <el-time-picker
- v-model="siteForm.idle.effectiveFrom"
- class="input-text"
- format="HH:mm"
- value-format="HH:mm"/>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item
- label="Effective To:"
- label-width="130px"
- prop="idle.effectiveTo">
- <el-time-picker
- v-model="siteForm.idle.effectiveTo"
- class="input-text"
- format="HH:mm"
- value-format="HH:mm"/>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item
- label="Idle Fee:"
- label-width="130px"
- prop="idle.idleFee">
- <el-input
- v-model="siteForm.idle.idleFee"
- class="input-text"
- oninput="value=value.replace(/[^\d.]/g, '').replace(/\.{2,}/g, '.').replace('.', '$#$').replace(/\./g, '').replace('$#$', '.').replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3').replace(/^\./g, '')"
- maxlength="6"/>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item
- label="Every (minute):"
- label-width="130px"
- prop="idle.everyMinute">
- <el-input
- maxlength="4"
- v-model.number="siteForm.idle.everyMinute"
- class="input-text"/>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item
- label="Effective Date:"
- label-width="130px"
- prop="idle.effectiveDate">
- <el-date-picker
- v-model="siteForm.idle.effectiveDate"
- class="input-text"
- format="yyyy-MM-dd"
- value-format="yyyy-MM-dd"/>
- </el-form-item>
- </el-col>
- </el-row>
- </div>
- <div class="sparator" style="margin: 10px -80px;"></div>
- <div class="buttons">
- <el-button
- class="cancel-button"
- type="primary"
- @click="handleClickCancleButton">
- Cancel
- </el-button>
- <el-button
- class="confirm-button"
- type="primary"
- @click="handleClickConfigUpateButton">
- Save
- </el-button>
- </div>
- </el-form>
- </div>
- </div>
- </template>
- <script>
- import Balancing from './components/Balancing'
- import Reservation from './components/Reservation'
- import waves from '@/directive/waves' // waves directive
- import site from '../../http/api/site'
- import { fetchFleetCompanyOptions } from '@/http/api/driver'
- export default {
- name: 'AddSite',
- directives: { waves },
- components: { Balancing, Reservation },
- async created() {
- this.pageLoading = true;
- this.getChargeTypeOptions()
- this.getRateTypeOptions()
- this.getSiteTypeOptions()
- this.getCountryOptions()
- await this.getCompanyOptions()
- //this.getChargingProfileOPtions()
- this.pageLoading = false;
- },
- data() {
- return {
- pageLoading: false,
- rateTypeOptions: [],
- chargeTypeOptions: [],
- siteTypeOptions: [],
- countryOptions: [],
- companyOptions: [],
- chargingProfileOPtions: [],
-
- recipient: '',
- recipients: [],
- siteTypeTable: [{
- siteType: "",
- allDay: false,
- startTime: "",
- endTime: ""
- }],
- additionalNotesAutosize: {
- minRows: 3,
- maxRows: 6,
- },
- balancingForm: {
- loadBalancing: 'dynamic',
- staticMaxAmpere: 0,
- siteChargingProfiles: [{
- boxInUse: '',
- chargingProfilePk: ''
- }],
- },
- siteForm: {
- specialChargeRates: [
- {
- fleetCompanyId: '',
- chargeTypePk: '',
- rate: '',
- rateType: '',
- }
- ],
- siteInformation: {
- siteName: '',
- latitude: '',
- longitude: '',
- type: 'PUBLIC',
- },
- additionalInformation: {
- operatingHours: '',
- parkingFee: '',
- additionalNotes: '',
- endlessService: false,
- free: false,
- },
- address: {
- street: '',
- postalCode: '',
- city: '',
- country: '',
- },
- tempChargeRate: {
- chargeTypePk: '',
- rate: '',
- rateType: '',
- },
- chargeRates: [],
- whitelistUser: [{
- licenceNumber: '',
- mobileNumber: '',
- }],
- fleetWhitelist: [{
- //siteFleetId: "",
- fleetCompanyId: ''
- }],
- reservation: {
- enable: false,
- timeLimit: 15,
- },
- idle: {
- enableIdleFee: false,
- idleFee: '',
- effectiveDate: '',
- effectiveFrom: '',
- effectiveTo: '',
- everyMinute: ''
- }
- },
- rule: {
- "recipient": {
- pattern: /^[a-zA-Z0-9]+[\S]+@[a-zA-Z0-9_-]+[\.][\Sa-zA-Z]+$/,
- trigger: 'blur',
- message: 'Please type a correct recipient'
- }
- },
- rules: {
- siteInformation: {
- siteName: {
- required: true,
- trigger: 'blur',
- message: 'Site Name is required',
- },
- latitude: [{
- 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',
- }],
- longitude: [{
- 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',
- }],
- type: {
- required: true,
- trigger: 'change',
- message: 'Site Type is required',
- },
- },
- siteChargingProfiles: {
- boxInUse: [{
- required: true,
- trigger: 'change',
- message: 'Chargers In-Use is required',
- }, {
- type: 'number',
- message: 'Chargers In-Use is a number',
- }],
- chargingProfilePk: {
- required: true,
- trigger: 'change',
- message: 'Charging Profileis required',
- },
- },
- address: {
- street: {
- required: true,
- trigger: 'blur',
- message: 'Address is required',
- },
- postalCode: {
- required: true,
- trigger: 'blur',
- message: 'Postal Code is required',
- },
- city: {
- required: true,
- trigger: 'blur',
- message: 'City is required',
- },
- country: {
- required: true,
- trigger: 'blur',
- message: 'Country is required',
- },
- },
- chargeRate: {
- chargeTypePk: {
- required: true,
- trigger: 'change',
- message: 'Charge Type is required',
- },
- rate: [{
- required: true,
- trigger: 'blur',
- message: 'Rate is required',
- }, {
- pattern: /^\d+(\.\d+)?$/,
- trigger: 'blur',
- message: 'Please type a correct rate',
- }],
- rateType: {
- required: true,
- trigger: 'change',
- message: 'Rate Type is required',
- }
- },
- specialChargeRates: {
- fleetCompanyId: {
- required: true,
- trigger: 'change',
- message: 'Fleet Company is required',
- },
- chargeTypePk: {
- required: true,
- trigger: 'change',
- message: 'Charge Type is required',
- },
- rate: [{
- required: true,
- trigger: 'blur',
- message: 'Rate is required',
- }, {
- pattern: /^\d+(\.\d+)?$/,
- trigger: 'blur',
- message: 'Please type a correct rate',
- }],
- rateType: {
- required: true,
- trigger: 'change',
- message: 'Rate Type is required',
- }
- },
- whitelistUser: {
- licenceNumber: {
- required: true,
- trigger: 'blur',
- message: 'Licence Number is required',
- },
- mobileNumber: {
- required: true,
- trigger: 'blur',
- message: 'Mobile Number is required',
- },
- },
- idle: {
- 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'
- },
- everyMinute: [{
- required: true,
- trigger: 'blur',
- message: 'Every is required'
- }, {
- type: 'number',
- message: 'Every is a number'
- }]
- }
- },
- swtSpecialRate: false
- }
- },
- methods: {
- handleClickAddSpecialRateButton() {
- this.siteForm.specialChargeRates.push(
- {
- fleetCompanyId: this.companyOptions[0].fleetCompanyId,
- chargeTypePk: this.chargeTypeOptions[0].chargeTypePk,
- rate: '',
- rateType: this.rateTypeOptions[0].value,
- }
- )
- },
- handleClickSubSpecialRateButton(specialRate, index) {
- this.siteForm.specialChargeRates.splice(index, 1)
- if (this.siteForm.specialChargeRates.length === 0) {
- this.siteForm.specialChargeRates.push(
- {
- fleetCompanyId: this.companyOptions[0].fleetCompanyId,
- chargeTypePk: this.chargeTypeOptions[0].chargeTypePk,
- rate: '',
- rateType: this.rateTypeOptions[0].value,
- }
- )
- }
- },
- reservationTimeLimitEnable(enable) {
- this.siteForm.reservation.enable = enable
- },
- reservationTimeLimitChange(timeLimit) {
- this.siteForm.reservation.timeLimit = timeLimit
- },
- endlessServiceSwitchChange(value) {
- if (value) {
- this.siteForm.additionalInformation.operatingHours = ""
- }
- },
- freeSwitchChange(value) {
- if (value) {
- this.siteForm.additionalInformation.parkingFee = ""
- }
- },
- getChargeTypeOptions() {
- site.getChargeTypeList().then((response) => {
- const { data = [] } = response
- this.chargeTypeOptions = data
- this.setTempChargeTypeDefaultValue()
- this.siteForm.specialChargeRates[0].chargeTypePk = data[0].chargeTypePk
- });
- },
- setTempChargeTypeDefaultValue() {
- if (this.chargeTypeOptions.length > 0) {
- const defaultValue = this.chargeTypeOptions[0].chargeTypePk
- this.siteForm.tempChargeRate.chargeTypePk = defaultValue
- }
- },
- getRateTypeOptions() {
- site.getRateTypeList().then((response) => {
- const { data = [] } = response
- this.rateTypeOptions = data
- this.setTempRateTypeDefaultValue()
- this.siteForm.specialChargeRates[0].rateType = data[0].value
- });
- },
- setTempRateTypeDefaultValue() {
- if (this.rateTypeOptions.length > 0) {
- const defaultValue = this.rateTypeOptions[0].value
- this.siteForm.tempChargeRate.rateType = defaultValue
- }
- },
- getSiteTypeOptions() {
- site.getSiteTypeList().then((response) => {
- this.siteTypeOptions = response.data
- const { data } = response;
- if (data && data.length > 0) {
- this.siteTypeTable = [];
- data.forEach(item => {
- this.siteTypeTable.push({
- label: item.name,
- siteType: item.value,
- allDay: false,
- startTime: "",
- endTime: ""
- })
- })
- //this.siteForm.siteInformation.type = data[0].value
- }
- });
- },
- getCompanyOptions() {
- fetchFleetCompanyOptions().then((response) => {
- const { data, success } = response
- if (success) {
- this.companyOptions = data
- if (data && data.length > 0) {
- this.siteForm.specialChargeRates[0].fleetCompanyId = data[0].fleetCompanyId
- }
- }
- })
- },
- getCountryOptions() {
- site.getCountryList().then(({ data }) => {
- this.countryOptions = data
- if (data && data.length > 0) {
- this.siteForm.address.country = data[0].value
- }
- })
- },
- getChargingProfileOPtions() {
- site.getChargingProfiles().then(({ data }) => {
- this.chargingProfileOPtions = data
- })
- },
- handleClickSubChargeRateButton(chargeRate, index) {
- this.siteForm.chargeRates.splice(index, 1)
- },
- handleClickSubTempChargeRateButton() {
- if (this.siteForm.chargeRates.length > 0) {
- const {
- rate,
- rateType,
- chargeTypePk,
- } = this.siteForm.chargeRates.pop()
- this.siteForm.tempChargeRate.chargeTypePk = chargeTypePk
- this.siteForm.tempChargeRate.rateType = rateType
- this.siteForm.tempChargeRate.rate = rate
- } else {
- this.resetTempChargeRate()
- }
- },
- handleClickAddChargeRateButton() {
- this.siteForm.chargeRates.push({
- ...this.siteForm.tempChargeRate
- })
- this.resetTempChargeRate()
- },
- resetTempChargeRate() {
- this.setTempRateTypeDefaultValue()
- this.siteForm.tempChargeRate.rate = ''
- this.setTempChargeTypeDefaultValue()
- },
- handleClickAddWhiteUserButton() {
- this.siteForm.whitelistUser.push({
- mobileNumber: '',
- licenceNumber: '',
- })
- },
- handleClickSubWhiteUserButton(user, index) {
- this.siteForm.whitelistUser.splice(index, 1)
- if (this.siteForm.whitelistUser.length === 0) {
- this.siteForm.whitelistUser.push({
- mobileNumber: '',
- licenceNumber: '',
- })
- }
- },
- handleClickAddWhiteFleetButton() {
- this.siteForm.fleetWhitelist.push({
- fleetCompanyId: ''
- })
- },
- handleClickSubWhiteFleetButton(fleet, index) {
- this.siteForm.fleetWhitelist.splice(index, 1)
- if (this.siteForm.fleetWhitelist.length === 0) {
- this.siteForm.fleetWhitelist.push({
- fleetCompanyId: ''
- })
- }
- },
- handleClickCancleButton() {
- this.$router.go(-1)
- },
- handleClickConfigUpateButton() {
- this.$refs['addSiteForm'].validate(result => {
- if (result) {
- this.addSiteWithForm();
- }
- })
- },
- addRecipient() {
- if (this.recipient) {
- this.$refs["recipForm"].validate(result => {
- if (result) {
- this.recipients.push(this.recipient);
- this.recipient = "";
- }
- });
- }
- },
- deleteRecipient(index) {
- this.recipients.splice(index, 1);
- },
- clearAllRecipient() {
- this.$confirm('Clear all recipients?', 'Prompt', {
- confirmButtonText: 'Confirm',
- cancelButtonText: 'Cancel',
- type: 'warning'
- }).then(res => {
- this.recipients = [];
- })
- },
- addSiteWithForm() {
- const {
- siteName,
- //type: siteType,
- latitude: locationLatitude,
- longitude: locationLongitude,
- } = this.siteForm.siteInformation
- const {
- street,
- postalCode,
- city,
- country,
- } = this.siteForm.address;
- const chargeRates = [...this.siteForm.chargeRates]
- const chargeProfiles = []
- const {
- chargeTypePk,
- rate,
- rateType,
- } = this.siteForm.tempChargeRate
- if (chargeTypePk && rate && rateType) {
- chargeRates.push({
- chargeTypePk,
- rate,
- rateType,
- })
- }
- if (this.swtSpecialRate) {
- this.siteForm.specialChargeRates.forEach(({
- fleetCompanyId,
- chargeTypePk,
- rate,
- rateType,
- }) => {
- if (chargeTypePk && fleetCompanyId && rate && rateType) {
- chargeRates.push({
- fleetCompanyId,
- chargeTypePk,
- rate,
- rateType,
- })
- }
- })
- }
- this.balancingForm.siteChargingProfiles.forEach(item => {
- if (item.boxInUse && item.chargingProfilePk)
- chargeProfiles.push(item)
- })
- const {
- free,
- parkingFee,
- endlessService,
- additionalNotes,
- operatingHours,
- } = this.siteForm.additionalInformation
- const { whitelistUser, fleetWhitelist, siteChargingProfiles } = this.siteForm
- const siteTypes = [];
- if (this.isSiteTypeEnable(0, false)) {
- this.siteTypeTable.forEach(item => {
- siteTypes.push({
- siteType: item.siteType,
- allDay: item.allDay,
- startTime: "",
- endTime: ""
- })
- })
- } else {
- siteTypes.push(...this.siteTypeTable);
- }
- const data = {
- siteName,
- siteTypes,
- locationLatitude,
- locationLongitude,
- enableReservation: this.siteForm.reservation.enable,
- timeLimit: this.siteForm.reservation.timeLimit,
- address: {
- street,
- city,
- country,
- countryCode: country,
- zipCode: postalCode
- },
- chargeRates,
- whitelistUser,
- fleetWhitelist,
- siteChargingProfiles: chargeProfiles,
- free,
- endlessService,
- operatingHours,
- parkingFee,
- additionalNotes,
- loadBalancing: this.balancingForm.loadBalancing,
- staticMaxAmpere: this.balancingForm.staticMaxAmpere,
- ...this.siteForm.idle,
- emails: this.recipients
- };
- site.addSite(data)
- .then(() => {
- this.$router.go(-1)
- this.$notify({
- title: "add site success",
- type: 'success',
- duration: 5000,
- })
- })
- .catch((error) => {
- this.$message({
- message: error,
- type: "error",
- duration: 5 * 1000,
- })
- this.pageLoading = false;
- })
- },
- siteTypeSpanMethod({ row, column, rowIndex, columnIndex }) {
- if (columnIndex == 2) {
- return [1,2]
- } else if (columnIndex == 3) {
- return [0,0]
- }
- },
- enableUserWhiteList() {
- for (let type of this.siteTypeTable) {
- if (type.siteType == "PRI_USR_WHI") {
- return (type.allDay || (type.startTime && type.endTime))
- } else {
- continue;
- }
- }
- return false;
- },
- enableFleetWhiteList() {
- for (let type of this.siteTypeTable) {
- if (type.siteType == "PRI_FLE_WHI") {
- return (type.allDay || (type.startTime && type.endTime))
- } else {
- continue;
- }
- }
- return false;
- },
- isSiteTypeEnable(index, isSwitch) {
- for (let i = 0; i < this.siteTypeTable.length; i++) {
- let type = this.siteTypeTable[i];
- if (type.allDay) {
- if (index == i && isSwitch) {
- return false;
- } else {
- return true;
- }
- } else {
- continue;
- }
- }
- return false;
- }
- }
- }
- </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 {
- padding: 15px 60px;
- border-radius: 6px;
- background-color: white;
- }
- .sparator {
- margin: 10px -40px;
- height: 2px;
- background-color: #F0F5FC;
- }
- .section-title {
- color: #333333;
- margin-top: 20px;
- margin-bottom: 30px;
- font-size: 16px;
- line-height: 24px;
- font-weight: 500;
- font-family: sans-serif;
- text-transform: uppercase;
- }
- .input-text {
- width: 100%;
- max-width: 300px;
- }
- .input-text .el-textarea__inner {
- font-family: sans-serif;
- }
- .rate-list-view {
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- }
-
- .rate-text-max {
- max-width: 200px;
- padding-right: 14px;
- }
- .rate-text {
- max-width: 150px;
- padding-right: 14px;
- }
-
- .rate-type {
- max-width: 100px;
- padding-right: 14px;
- }
- .list-item-icon {
- width: 30px;
- height: 30px;
- cursor: pointer;
- margin: 5px 10px 22px;
- }
- .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;
- }
- .ratePunit {
- height: 39px;
- font-size: 20px;
- margin-left: -5px;
- padding-right: 10px;
- }
- .type-row {
- display: flex;
- align-items: center;
- padding-bottom: 10px;
- }
- .type-row > div {
- margin-right: 10px;
- }
- .link-button {
- color: #3179E4;
- font-size: 14px;
- cursor: pointer;
- margin: 0 -10px;
- padding: 0 10px;
- display: inline-block;
- white-space: nowrap;
- text-decoration: underline;
- }
- .receip-item {
- display: flex;
- align-items: center;
- font-size: 14px;
- line-height: 1em;
- padding-top: 10px;
- }
- .receip-item i {
- color: #666;
- padding: 0 10px;
- cursor: pointer;
- }
- .receip-item i:hover,
- .receip-item i:active,
- .link-button:hover {
- color: #ff5500;
- }
- </style>
|