detail.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100
  1. <template>
  2. <div class="view-container" v-loading="pageLoading">
  3. <el-form
  4. ref="addForm"
  5. :rules="rules"
  6. :model="siteForm"
  7. label-position="right"
  8. label-width="120px"
  9. style="width: 100%;">
  10. <div class="flexr">
  11. <div class="flexl flex1">
  12. <div class="view-content flex1">
  13. <div class="section-title" id="idSiteInfo">Site Information</div>
  14. <el-form-item
  15. label="Site Name:"
  16. prop="siteName">
  17. <el-input
  18. :disabled="isMCSTUser"
  19. v-model="siteForm.siteName"
  20. class="input-text" />
  21. </el-form-item>
  22. <el-form-item
  23. prop="locationLatitude"
  24. label="Latitude:">
  25. <el-input
  26. :disabled="isMCSTUser"
  27. v-model="siteForm.locationLatitude"
  28. class="input-text" />
  29. </el-form-item>
  30. <el-form-item
  31. prop="locationLongitude"
  32. label="Longitude:">
  33. <el-input
  34. :disabled="isMCSTUser"
  35. v-model="siteForm.locationLongitude"
  36. class="input-text"/>
  37. </el-form-item>
  38. <el-form-item
  39. prop="address.countryCode"
  40. label="Country:">
  41. <el-select
  42. v-model="siteForm.address.countryCode"
  43. class="input-text"
  44. :disabled="isMCSTUser">
  45. <el-option
  46. v-for="item in countryOptions"
  47. :key="item.name"
  48. :label="item.name"
  49. :value="item.value" />
  50. </el-select>
  51. </el-form-item>
  52. <el-form-item
  53. prop="address.city"
  54. label="City:">
  55. <el-input
  56. v-model="siteForm.address.city"
  57. class="input-text"
  58. :disabled="isMCSTUser"/>
  59. </el-form-item>
  60. <el-form-item
  61. prop="address.street"
  62. label="Street:">
  63. <el-input
  64. v-model="siteForm.address.street"
  65. class="input-text"
  66. :disabled="isMCSTUser"/>
  67. </el-form-item>
  68. <el-form-item
  69. prop="address.zipCode"
  70. label="Postal Code:">
  71. <el-input
  72. v-model="siteForm.address.zipCode"
  73. class="input-text"
  74. :disabled="isMCSTUser"/>
  75. </el-form-item>
  76. </div>
  77. <div class="view-content">
  78. <div class="section-title">Additional Information</div>
  79. <el-form-item
  80. label-width="130px"
  81. label="Operating Hours:"
  82. class="flex-item">
  83. <div class="flexc">
  84. <el-input
  85. v-model="siteForm.operatingHours"
  86. :disabled="isMCSTUser || !!siteForm.endlessService"
  87. class="input-text" />
  88. <el-switch
  89. :disabled="isMCSTUser"
  90. @change="changeEndless"
  91. style="margin-left: 10px"
  92. inactive-text="24/7"
  93. v-model="siteForm.endlessService">
  94. </el-switch>
  95. </div>
  96. </el-form-item>
  97. <el-form-item
  98. label-width="130px"
  99. label="Parking Fee:"
  100. class="flex-item">
  101. <div class="flexc">
  102. <el-input
  103. :disabled="isMCSTUser || !!siteForm.free"
  104. v-model="siteForm.parkingFee"
  105. class="input-text" />
  106. <el-switch
  107. :disabled="isMCSTUser"
  108. @change="changeParkingFree"
  109. style="margin-left: 10px"
  110. inactive-text="Free"
  111. v-model="siteForm.free">
  112. </el-switch>
  113. </div>
  114. </el-form-item>
  115. <el-form-item
  116. label-width="130px"
  117. label="Additional Notes:">
  118. <el-input
  119. :disabled="isMCSTUser"
  120. v-model="siteForm.additionalNotes"
  121. type="textarea"
  122. :autosize="autosize"
  123. class="input-text" />
  124. </el-form-item>
  125. <el-form-item
  126. label-width="130px"
  127. label="Carpark Code:">
  128. <el-input
  129. v-model="siteForm.carParkCode"
  130. class="input-text" />
  131. </el-form-item>
  132. </div>
  133. </div>
  134. <div class="flexl flex1">
  135. <div class="view-content" style="padding: 15px;">
  136. <dashboard
  137. v2
  138. :enable="isEdit"
  139. :info="summaryInfo"
  140. :siteId="siteForm.sitePk"/>
  141. </div>
  142. <div class="view-content flex1">
  143. <div class="section-title flexcr">
  144. Site Summary
  145. <div class="section-sub-title">(Currency Used: {{currencyData[siteForm.address.countryCode]}})</div>
  146. </div>
  147. <Summary
  148. :info="summaryInfo"
  149. :currency="currencyData[siteForm.address.countryCode]"/>
  150. </div>
  151. <div class="view-content" id="idSiteTypes" v-if="false">
  152. <div class="section-title">Site EMAIL Configuration</div>
  153. <email-recipient v-model="siteForm.emails"/>
  154. </div>
  155. </div>
  156. </div>
  157. <div class="view-content">
  158. <div class="section-title">TIME CONFIGURATION</div>
  159. <div class="site-type-layout">
  160. <site-type-with-time
  161. :siteTypes="siteForm.siteTypes"
  162. :sitePk="siteForm.sitePk"
  163. @change="changeSiteTypes"/>
  164. </div>
  165. </div>
  166. <div class="view-content">
  167. <div class="section-title">OCPP SETTINGS</div>
  168. <div class="flexr">
  169. <div class="flex2">
  170. <el-form-item
  171. label-width="150px"
  172. label="Heartbeat Interval:"
  173. prop="heartbeat"
  174. class="flex1">
  175. <div class="flexc">
  176. <el-input
  177. class="value-text"
  178. v-model="siteForm.ocppSetting.heartbeatIntervalMinutes"
  179. placeholder=""
  180. maxlength="5"/>
  181. <span class="value-unit">Minutes</span>
  182. </div>
  183. </el-form-item>
  184. <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>
  185. </div>
  186. <div class="flex1">
  187. <p></p>
  188. </div>
  189. <div class="flex2">
  190. <el-form-item
  191. label="Expiration:"
  192. prop="expiration"
  193. label-width="95px"
  194. class="flex1">
  195. <div class="flexc">
  196. <el-input
  197. class="value-text"
  198. v-model="siteForm.ocppSetting.expireHours"
  199. placeholder=""
  200. maxlength="5"/>
  201. <span class="value-unit">Hours</span>
  202. </div>
  203. </el-form-item>
  204. <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.
  205. The value 0 disables this functionality
  206. (i.e.no expiry date will be set).</div>
  207. </div>
  208. </div>
  209. </div>
  210. <div class="view-content" id="idChargeRates">
  211. <!--div class="section-title flexcr">
  212. CHARGE SITE RATE
  213. <div class="section-sub-title">(Currency Used: {{currencyData[siteForm.address.countryCode]}})</div>
  214. </div>
  215. <charge-rate
  216. v-model="ratesForm.chargeRates"/>
  217. <div class="sparator"></div>
  218. <div class="section-title flexcr">
  219. SPECIAL CHARGE RATE
  220. <div class="section-sub-title">(Currency Used: {{currencyData[siteForm.address.countryCode]}})</div>
  221. </div>
  222. <charge-rate
  223. isSpecial
  224. v-model="ratesForm.specialChargeRates"/>
  225. <div class="sparator"></div>-->
  226. <div class="section-title">Reservations</div>
  227. <reservation
  228. :enabled.sync="siteForm.enableReservation"
  229. :limit.sync="siteForm.timeLimit"
  230. />
  231. <div class="sparator" v-if="isEdit"></div>
  232. <div class="section-title" v-if="isEdit">LOAD BALANCING</div>
  233. <!-- <Balancing v-model="balancingForm"/> -->
  234. <div class="new-load-balance" v-if="isEdit" style="padding-bottom: 20px;">
  235. <span class="new-text">NEW!</span>
  236. <span class="link-type" @click="configLoadBalance">Configure load balancing in a new window</span>
  237. </div>
  238. <template v-if="enableWhitelistFleet">
  239. <div class="sparator"></div>
  240. <div class="section-title">WHITELIST GROUP</div>
  241. <white-list-fleet v-model="siteForm.groupWhitelist"/>
  242. </template>
  243. <template v-if="enableWhitelistUser">
  244. <div class="sparator"></div>
  245. <div class="section-title">WHITELIST USERS</div>
  246. <white-list-user v-model="siteForm.whitelistUser"/>
  247. </template>
  248. <div class="sparator"></div>
  249. <div class="section-title flexcwr">
  250. Idle Fee SETTINGS
  251. <div class="idle-switch">
  252. <el-switch
  253. inactive-text="Enable Idle Fee"
  254. v-model="siteForm.enableIdleFee"/>
  255. </div>
  256. </div>
  257. <el-row :gutter="20" v-if="siteForm.enableIdleFee">
  258. <el-col :xs="24" :md="12" :lg="8">
  259. <el-form-item
  260. label="Effective From:"
  261. label-width="140px"
  262. prop="effectiveFrom">
  263. <el-time-picker
  264. v-model="siteForm.effectiveFrom"
  265. class="input-text"
  266. format="HH:mm"
  267. value-format="HH:mm"/>
  268. </el-form-item>
  269. </el-col>
  270. <el-col :xs="24" :md="12" :lg="8">
  271. <el-form-item
  272. label="Effective To:"
  273. label-width="140px"
  274. prop="effectiveTo">
  275. <el-time-picker
  276. v-model="siteForm.effectiveTo"
  277. class="input-text"
  278. format="HH:mm"
  279. value-format="HH:mm"/>
  280. </el-form-item>
  281. </el-col>
  282. <el-col :xs="24" :md="12" :lg="8">
  283. <el-form-item
  284. label="Grace Period:"
  285. label-width="140px"
  286. prop="gracePeriod"
  287. style="position: relative;">
  288. <template slot="label">
  289. <span>Grace Period:</span>
  290. <span class="label-unit">(minutes)</span>
  291. </template>
  292. <el-input
  293. maxlength="4"
  294. v-model.number="siteForm.gracePeriod"
  295. type="number"
  296. class="input-text"/>
  297. </el-form-item>
  298. </el-col>
  299. <el-col :xs="24" :md="12" :lg="8">
  300. <el-form-item
  301. label="Idle Fee:"
  302. label-width="140px"
  303. prop="idleFee">
  304. <el-input
  305. v-model="siteForm.idleFee"
  306. class="input-text"
  307. oninput="value=value.replace(/[^\d.]/g, '').replace(/\.{2,}/g, '.').replace('.', '$#$').replace(/\./g, '').replace('$#$', '.').replace(/^(\-)*(\d+)\.(\d\d\d).*$/, '$1$2.$3').replace(/^\./g, '')"
  308. maxlength="8"/>
  309. </el-form-item>
  310. </el-col>
  311. <el-col :xs="24" :md="12" :lg="8">
  312. <el-form-item
  313. label="Idle Fee Interval"
  314. label-width="140px"
  315. prop="everyMinute"
  316. style="position: relative;">
  317. <template slot="label">
  318. <span>Idle Fee Interval:</span>
  319. <span class="label-unit">(minute)</span>
  320. </template>
  321. <el-input
  322. maxlength="4"
  323. type="number"
  324. v-model.number="siteForm.everyMinute"
  325. class="input-text"/>
  326. </el-form-item>
  327. </el-col>
  328. <el-col :xs="24" :md="12" :lg="8">
  329. <el-form-item
  330. label="Effective Date:"
  331. label-width="140px"
  332. prop="effectiveDate">
  333. <el-date-picker
  334. v-model="siteForm.effectiveDate"
  335. class="input-text"
  336. format="yyyy-MM-dd"
  337. value-format="yyyy-MM-dd"/>
  338. </el-form-item>
  339. </el-col>
  340. </el-row>
  341. </div>
  342. <div class="view-content">
  343. <div class="section-title">SITE EMAIL CONFIGURATION</div>
  344. <div class="flexcr">
  345. <email-recipient v-model="siteForm.emails"/>
  346. <div class="flex1">
  347. <el-checkbox-group
  348. class="features-group"
  349. v-model="siteForm.enabledFeatures">
  350. <template v-for="(item, index) in featuresOptions">
  351. <el-checkbox
  352. :key="index"
  353. :label="item.value">{{item.name}}</el-checkbox>
  354. </template>
  355. </el-checkbox-group>
  356. </div>
  357. </div>
  358. </div>
  359. <div class="view-content flexcr">
  360. <div class="buttons">
  361. <el-button
  362. class="cancel-button"
  363. type="primary"
  364. @click="handleClickCancleButton">
  365. Cancel
  366. </el-button>
  367. <el-button
  368. class="confirm-button"
  369. type="primary"
  370. @click="handleClickSaveButton">
  371. Save
  372. </el-button>
  373. </div>
  374. <div
  375. class="update-by"
  376. v-if="isEdit">
  377. <span
  378. class="add-text"
  379. :title='"CREATED BY " + siteForm.createdBy + " ON " + siteForm.createdOn'>
  380. LAST UPDATED BY {{siteForm.updatedBy}} TIMESTAMP: {{siteForm.updatedOn}}
  381. </span>
  382. </div>
  383. </div>
  384. </el-form>
  385. </div>
  386. </template>
  387. <script>
  388. import settings from '../../settings.js'
  389. import Summary from '../site/components/Summary'
  390. import Dashboard from '../site/components/Dashboard'
  391. import ChargeRate from '../site/components/ChargeRate'
  392. import Balancing from '../site/components/Balancing'
  393. import EmailRecipient from '../site/components/EmailRecipient'
  394. import Reservation from '../site/components/Reservations'
  395. import WhiteListFleet from '../site/components/WhiteListFleet'
  396. import WhiteListUser from '../site/components/WhiteListUser'
  397. import SiteTypeWithTime from './components/SiteTypeWithTime'
  398. import waves from '@/directive/waves' // waves directive
  399. import site from '../../http/api/site'
  400. import apiSet from '../../http/api/settings'
  401. import { getRoleName } from '@/utils/auth'
  402. export default {
  403. directives: { waves },
  404. components: {
  405. Balancing,
  406. ChargeRate,
  407. Dashboard,
  408. EmailRecipient,
  409. Reservation,
  410. WhiteListUser,
  411. WhiteListFleet,
  412. SiteTypeWithTime,
  413. Summary
  414. },
  415. data() {
  416. return {
  417. pageLoading: false,
  418. isMCSTUser: false,
  419. countryOptions: [],
  420. featuresOptions: [],
  421. siteForm: {
  422. sitePk: "",
  423. siteName: "",
  424. siteTypes: [],
  425. emails: [],
  426. carParkCode: "",
  427. address: {
  428. city: "",
  429. countryCode: settings.defaultCountry,
  430. street: "",
  431. zipCode: ""
  432. },
  433. ocppSetting: {
  434. expireHours: '',
  435. ocppSettingId: '',
  436. heartbeatIntervalMinutes: ''
  437. },
  438. free: false,
  439. endlessService: false,//24/7
  440. additionalNotes: "",
  441. //罚款部分
  442. enableIdleFee: false,//idle Fee
  443. idleFee: "",//idle Fee
  444. everyMinute: "",//idle Fee
  445. effectiveDate: "",//idle Fee
  446. effectiveFrom: "",//idle Fee
  447. effectiveTo: "",//idle Fee
  448. gracePeriod: "",//idle Fee
  449. //预订部分
  450. enableReservation: false,//预订
  451. timeLimit: null,//预订
  452. parkingFee: "",
  453. whitelistUser: [],
  454. groupWhitelist: [],
  455. operatingHours: "",
  456. locationLatitude: "",
  457. locationLongitude: "",
  458. chargeRates: [],
  459. specialChargeRates: [],
  460. loadBalancing: "",//负载均衡
  461. staticMaxAmpere: "",//负载均衡
  462. siteChargingProfiles: null,//负载均衡
  463. enabledFeatures: []
  464. },
  465. ratesForm: {
  466. chargeRates: [{
  467. rate: '',
  468. rateType: '',
  469. chargeTypePk: ''
  470. }],
  471. specialChargeRates: [{
  472. rate: '',
  473. rateType: '',
  474. chargeTypePk: '',
  475. groupPk: ''
  476. }]
  477. },
  478. balancingForm: {
  479. loadBalancing: 'dynamic',
  480. staticMaxAmpere: 0,
  481. siteChargingProfiles: [{
  482. boxInUse: '',
  483. chargingProfilePk: ''
  484. }],
  485. },
  486. currencyData: {
  487. SG: "S$"
  488. },
  489. autosize: {
  490. minRows: 3,
  491. maxRows: 6,
  492. },
  493. summaryInfo: {},
  494. rules: {
  495. siteName: {
  496. required: true,
  497. trigger: 'blur',
  498. message: 'Site Name is required',
  499. },
  500. locationLatitude: [{
  501. required: true,
  502. trigger: 'blur',
  503. message: 'Latitude is required',
  504. }, {
  505. pattern: /^[\-\+]?((0|([1-8]\d?))(\.\d{1,8})?|90(\.0{1,8})?)$/,
  506. trigger: 'blur',
  507. message: 'Please type a correct latitude',
  508. }],
  509. locationLongitude: [{
  510. required: true,
  511. trigger: 'blur',
  512. message: 'Longitude is required',
  513. }, {
  514. pattern: /^[\-\+]?(0(\.\d{1,8})?|([1-9](\d)?)(\.\d{1,8})?|1[0-7]\d{1}(\.\d{1,8})?|180\.0{1,8})$/,
  515. trigger: 'blur',
  516. message: 'Please type a correct longitude',
  517. }],
  518. address: {
  519. street: {
  520. required: true,
  521. trigger: 'blur',
  522. message: 'Address is required',
  523. },
  524. zipCode: {
  525. required: true,
  526. trigger: 'blur',
  527. message: 'Postal Code is required',
  528. },
  529. city: {
  530. required: true,
  531. trigger: 'blur',
  532. message: 'City is required',
  533. },
  534. countryCode: {
  535. required: true,
  536. trigger: 'blur',
  537. message: 'Country is required',
  538. }
  539. },
  540. idleFee: {
  541. required: true,
  542. trigger: 'blur',
  543. message: 'Idle fee is required'
  544. },
  545. effectiveDate: {
  546. required: true,
  547. trigger: 'change',
  548. message: 'Effective Date is required'
  549. },
  550. effectiveFrom: {
  551. required: true,
  552. trigger: 'change',
  553. message: 'Effective From is required'
  554. },
  555. effectiveTo: {
  556. required: true,
  557. trigger: 'change',
  558. message: 'Effective To is required'
  559. },
  560. gracePeriod: {
  561. required: true,
  562. trigger: 'change',
  563. message: 'Grace Period is required'
  564. },
  565. everyMinute: [{
  566. required: true,
  567. trigger: 'blur',
  568. message: 'Every is required'
  569. }, {
  570. type: 'number',
  571. message: 'Every is a number'
  572. }]
  573. },
  574. enablePublic: false,
  575. enableWhitelistUser: false,
  576. enableWhitelistFleet: false,
  577. isEdit: false
  578. }
  579. },
  580. created() {
  581. this.pageLoading = true;
  582. this.isMCSTUser = getRoleName() === "MCST";
  583. this.getCountryOptions();
  584. this.getFeaturesList();
  585. if (this.$route.params.id) {
  586. this.isEdit = true;
  587. this.getSiteInfo()
  588. } else {
  589. setTimeout(() => {
  590. this.pageLoading = false;
  591. }, 500);
  592. }
  593. },
  594. methods: {
  595. getCountryOptions() {
  596. site.getCountryList().then(res => {
  597. if (res.data) {
  598. this.countryOptions = res.data
  599. const sign = {}
  600. res.data.forEach(item => {
  601. sign[item.value] = item.currencySymbol
  602. })
  603. this.currencyData = sign;
  604. }
  605. }).catch(() => {
  606. this.$message({
  607. message: err,
  608. type: 'error',
  609. duration: 3000,
  610. })
  611. this.pageLoading = false;
  612. })
  613. },
  614. getFeaturesList() {
  615. apiSet.getFeatures().then(res => {
  616. if (res.data) {
  617. this.featuresOptions = res.data;
  618. }
  619. }).catch(() => {
  620. this.$message({
  621. message: err,
  622. type: 'error',
  623. duration: 3000,
  624. })
  625. this.pageLoading = false;
  626. })
  627. },
  628. getSiteInfo() {
  629. site.getSiteInfo({
  630. sitePk: this.$route.params.id,
  631. }).then(res => {
  632. if (res.data) {
  633. if (!res.data.enabledFeatures) {
  634. res.data.enabledFeatures = []
  635. }
  636. this.siteForm = res.data;
  637. this.applySiteInfo();
  638. } else {
  639. this.pageLoading = false;
  640. }
  641. }).catch(() => {
  642. this.$message({
  643. message: err,
  644. type: 'error',
  645. duration: 3000,
  646. })
  647. this.pageLoading = false;
  648. })
  649. },
  650. applySiteInfo() {
  651. setTimeout(() => {
  652. this.pageLoading = false;
  653. }, 500);
  654. if (this.siteForm.chargeRates && this.siteForm.chargeRates.length) {
  655. const rate = [], srate = []
  656. this.siteForm.chargeRates.forEach(item => {
  657. if (item.groupPk) {
  658. srate.push(item)
  659. } else {
  660. rate.push(item)
  661. }
  662. })
  663. if (rate.length > 0) {
  664. this.ratesForm.chargeRates = rate;
  665. }
  666. if (srate.length > 0) {
  667. this.ratesForm.specialChargeRates = srate;
  668. }
  669. }
  670. if (this.siteForm.siteTypes && this.siteForm.siteTypes.length) {
  671. for (let type of this.siteForm.siteTypes) {
  672. if (type.siteType == "PRI_USR_WHI") {
  673. this.enableWhitelistUser = (type.allDay || (type.startTime && type.endTime))
  674. } else if (type.siteType == "PRI_FLE_WHI") {
  675. this.enableWhitelistFleet = (type.allDay || (type.startTime && type.endTime))
  676. } else if (type.siteType == "PUB") {
  677. this.enablePublic = (type.allDay || (type.startTime && type.endTime))
  678. } else {
  679. continue;
  680. }
  681. }
  682. }
  683. if (this.siteForm.siteSummary) {
  684. this.summaryInfo = Object.assign(this.siteForm.siteSummary, {});
  685. delete this.siteForm.siteSummary;
  686. }
  687. this.balancingForm = {
  688. loadBalancing: this.siteForm.loadBalancing || 'dynamic',
  689. staticMaxAmpere: this.siteForm.staticMaxAmpere || 0,
  690. siteChargingProfiles: this.siteForm.siteChargingProfiles || [{
  691. boxInUse: '',
  692. chargingProfilePk: ''
  693. }]
  694. }
  695. },
  696. changeEndless(value) {
  697. if (value) {
  698. this.siteForm.operatingHours = ""
  699. }
  700. },
  701. changeParkingFree(value) {
  702. if (value) {
  703. this.siteForm.parkingFee = ""
  704. }
  705. },
  706. changeSiteTypes(data) {
  707. if (this.isEdit && this.pageLoading) {
  708. console.log("changeSiteTypes", data);
  709. return;
  710. }
  711. this.siteForm.siteTypes = data;
  712. /*for (let type of data) {
  713. if (type.siteType == "PRI_USR_WHI") {
  714. this.enableWhitelistUser = (type.allDay || (type.startTime && type.endTime))
  715. } else if (type.siteType == "PRI_FLE_WHI") {
  716. this.enableWhitelistFleet = (type.allDay || (type.startTime && type.endTime))
  717. } else if (type.siteType == "PUB") {
  718. this.enablePublic = (type.allDay || (type.startTime && type.endTime))
  719. } else {
  720. continue;
  721. }
  722. }*/
  723. },
  724. handleClickCancleButton() {
  725. this.$router.push({
  726. path: "/site-management-v2/site-configuration"
  727. });
  728. },
  729. handleClickSaveButton() {
  730. this.$refs['addForm'].validate(result => {
  731. if (result) {
  732. const rates = [];
  733. /* 启用动态费率配置
  734. this.ratesForm.chargeRates.forEach(item => {
  735. if (item.rate) {
  736. rates.push(item);
  737. }
  738. })
  739. this.ratesForm.specialChargeRates.forEach(item => {
  740. if (item.rate) {
  741. rates.push(item);
  742. }
  743. })
  744. if (rates.length == 0) {
  745. this.$message({
  746. message: "Please add at least one rate",
  747. type: 'error',
  748. duration: 3000,
  749. })
  750. this.scrollToView("idChargeRates", true);
  751. return;
  752. }*/
  753. if (!this.siteForm.enableReservation) {
  754. this.siteForm.timeLimit = "";
  755. }
  756. /*const chargeProfiles = []
  757. this.balancingForm.siteChargingProfiles.forEach(item => {
  758. if (item.boxInUse && item.chargingProfilePk)
  759. chargeProfiles.push(item)
  760. })
  761. this.siteForm.siteChargingProfiles = chargeProfiles
  762. if (this.balancingForm.loadBalancing == 'dynamic') {
  763. this.siteForm.staticMaxAmpere = ""
  764. } else {
  765. this.siteForm.staticMaxAmpere = this.balancingForm.staticMaxAmpere
  766. }
  767. this.siteForm.loadBalancing = this.balancingForm.loadBalancing*/
  768. /*if (!this.enablePublic && !this.enableWhitelistFleet && !this.enableWhitelistUser) {
  769. this.$message({
  770. message: "Please set time configuration",
  771. type: 'error',
  772. duration: 3000,
  773. })
  774. this.scrollToView("idSiteTypes");
  775. return;
  776. }*/
  777. if (this.enableWhitelistUser) {
  778. let _list = []
  779. this.siteForm.whitelistUser.forEach(item => {
  780. if (item.mobileNumber && item.licenceNumber) {
  781. _list.push(item);
  782. }
  783. })
  784. if (_list.length == 0) {
  785. this.$message({
  786. message: "Please add at least one whitelist user",
  787. type: 'error',
  788. duration: 3000,
  789. })
  790. return;
  791. } else {
  792. this.siteForm.whitelistUser = _list;
  793. }
  794. } else {
  795. this.siteForm.whitelistUser = [];
  796. }
  797. if (this.enableWhitelistFleet) {
  798. let _list = []
  799. this.siteForm.groupWhitelist.forEach(item => {
  800. if (item.groupPk) {
  801. _list.push(item);
  802. }
  803. })
  804. if (_list.length == 0) {
  805. this.$message({
  806. message: "Please add at least one whitelist group",
  807. type: 'error',
  808. duration: 3000,
  809. })
  810. return;
  811. } else {
  812. this.siteForm.groupWhitelist = _list;
  813. }
  814. } else {
  815. this.siteForm.groupWhitelist = []
  816. }
  817. if (this.siteForm.enabledFeatures.length > 0 && this.siteForm.emails.length == 0) {
  818. this.$message({
  819. message: "Please add at least one email recipients",
  820. type: 'error',
  821. duration: 3000,
  822. })
  823. return;
  824. }
  825. this.pageLoading = true;
  826. const params = {
  827. ...this.siteForm,
  828. chargeRates: rates
  829. }
  830. console.log("form", params);
  831. if (this.isEdit) {
  832. this.updateSite(params);
  833. } else {
  834. this.addSite(params)
  835. }
  836. //this.editSiteWithForm();
  837. } else {
  838. this.scrollToView("idSiteInfo", true);
  839. }
  840. })
  841. },
  842. scrollToView(id, alignToTop) {
  843. //console.log("scrollToView", !alignToTop);
  844. window.requestAnimationFrame(() => {
  845. document.getElementById(id).scrollIntoView(!alignToTop, {
  846. block: "start",
  847. behavior: "smooth"
  848. })
  849. });
  850. },
  851. isSiteTypeEnable(index, isSwitch) {
  852. for (let i = 0; i < this.siteForm.siteTypes.length; i++) {
  853. let type = this.siteForm.siteTypes[i];
  854. if (type.allDay) {
  855. if (index == i && isSwitch) {
  856. return false;
  857. } else {
  858. return true;
  859. }
  860. } else {
  861. continue;
  862. }
  863. }
  864. return false;
  865. },
  866. addSite(params) {
  867. site.addSite(params).then(res => {
  868. this.$message({
  869. message: "Add site success",
  870. type: 'success',
  871. duration: 3000,
  872. })
  873. this.handleClickCancleButton();
  874. }).catch((error) => {
  875. this.$message({
  876. message: error,
  877. type: "error",
  878. duration: 5000,
  879. })
  880. }).finally(() => {
  881. this.pageLoading = false;
  882. })
  883. },
  884. updateSite(params) {
  885. site.updateSite(params).then(res => {
  886. this.$message({
  887. message: "Update site success",
  888. type: 'success',
  889. duration: 3000,
  890. })
  891. this.handleClickCancleButton();
  892. }).catch((error) => {
  893. this.$message({
  894. message: error,
  895. type: "error",
  896. duration: 5000,
  897. })
  898. }).finally(() => {
  899. this.pageLoading = false;
  900. })
  901. },
  902. configLoadBalance() {
  903. this.$openRoute("/smart-energy-management/site-load-balancing/" + this.siteForm.sitePk);
  904. }
  905. }
  906. }
  907. </script>
  908. <style scoped lang='scss'>
  909. @import '../../styles/element-ui.scss';
  910. @import '../../styles/variables.scss';
  911. .view-container {
  912. width: 100%;
  913. padding: 20px 60px;
  914. min-height: $mainAppMinHeight;
  915. background-color: #F0F5FC;
  916. }
  917. .view-content {
  918. margin: 0 8px 16px;
  919. padding: 15px 50px;
  920. border-radius: 6px;
  921. background-color: white;
  922. }
  923. @media screen and (max-width: 800px) {
  924. .view-container {
  925. padding: 10px 20px;
  926. }
  927. .view-content {
  928. padding: 15px 40px;
  929. }
  930. }
  931. @media screen and (max-width: 500px) {
  932. .view-container {
  933. padding: 0px;
  934. }
  935. .view-content {
  936. padding: 15px 30px;
  937. }
  938. }
  939. .sparator {
  940. margin: 10px -30px;
  941. height: 2px;
  942. background-color: #F0F5FC;
  943. }
  944. .section-title {
  945. color: #333333;
  946. margin-top: 20px;
  947. margin-bottom: 30px;
  948. font-size: 15px;
  949. line-height: 24px;
  950. font-weight: 700;
  951. font-family: sans-serif;
  952. text-transform: uppercase;
  953. }
  954. .section-sub-title {
  955. font-size: 14px;
  956. padding-left: 5px;
  957. font-weight: normal;
  958. }
  959. .site-type-layout {
  960. overflow-x: auto;
  961. }
  962. .site-type-layout::-webkit-scrollbar-track-piece {
  963. background-color:#f8f8f8;
  964. }
  965. .site-type-layout::-webkit-scrollbar {
  966. width: 7px;
  967. height: 10px;
  968. }
  969. .site-type-layout::-webkit-scrollbar-thumb {
  970. transition: all .4s;
  971. border-radius: 30px;
  972. background-color: rgba($--color-primary, 0.3);
  973. background-clip: padding-box;
  974. }
  975. .site-type-layout::-webkit-scrollbar-thumb:hover {
  976. background-color: rgba($--color-primary, 0.6);
  977. }
  978. .input-text {
  979. width: 100% !important;
  980. max-width: 300px;
  981. }
  982. .add-text {
  983. width: 100%;
  984. font-size: 14px;
  985. max-width: 300px;
  986. }
  987. .add-text ::v-deep .el-textarea__inner,
  988. .input-text ::v-deep .el-textarea__inner {
  989. font-family: sans-serif;
  990. }
  991. .value-text {
  992. width: 100%;
  993. min-width: 100px;
  994. max-width: 200px;
  995. }
  996. .value-unit {
  997. padding-left: 10px;
  998. }
  999. .label-unit {
  1000. left: 0;
  1001. bottom: 0;
  1002. width: 125px;
  1003. font-size: 12px;
  1004. line-height: 1;
  1005. position: absolute;
  1006. }
  1007. .cancel-button {
  1008. width: 94px;
  1009. height: 40px;
  1010. }
  1011. .confirm-button {
  1012. width: 94px;
  1013. height: 40px;
  1014. margin-left: 20px;
  1015. background: $--color-primary;
  1016. border: 1px solid $--color-primary;
  1017. box-sizing: border-box;
  1018. border-radius: 4px;
  1019. }
  1020. ::v-deep .el-switch__label.el-switch__label--left span {
  1021. font-size: 14px;
  1022. color: black;
  1023. }
  1024. .idle-switch {
  1025. font-size: 13px;
  1026. text-transform: none;
  1027. }
  1028. .tips {
  1029. color: #999;
  1030. font-size: 12px;
  1031. padding-left: 150px;
  1032. padding-bottom: 20px;
  1033. }
  1034. .tips i {
  1035. color: #333;
  1036. font-weight: 500;
  1037. font-style: normal;
  1038. }
  1039. .new-load-balance {
  1040. position: relative;
  1041. padding-left: 15px;
  1042. padding-bottom: 20px;
  1043. }
  1044. .new-text {
  1045. top: -10px;
  1046. left: 0px;
  1047. color: #FF1122;
  1048. font-size: 12px;
  1049. position: absolute;
  1050. transform: scale(0.8);
  1051. }
  1052. .features-group {
  1053. min-width: 300px;
  1054. display: flex;
  1055. margin-left: 20px;
  1056. flex-direction: column;
  1057. ::v-deep .el-checkbox {
  1058. display: flex;
  1059. align-items: center;
  1060. padding-bottom: 5px;
  1061. }
  1062. ::v-deep .el-checkbox__label {
  1063. color: #000;
  1064. word-break: break-all;
  1065. white-space: normal;
  1066. }
  1067. ::v-deep .el-checkbox__input.is-checked .el-checkbox__inner::after {
  1068. border-color: $buttonText;
  1069. }
  1070. }
  1071. </style>