detail.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094
  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. <audit-view :audit="siteForm.audit"/>
  375. </div>
  376. </el-form>
  377. </div>
  378. </template>
  379. <script>
  380. import settings from '../../settings.js'
  381. import AuditView from "@/components/AuditView"
  382. import Summary from '../site/components/Summary'
  383. import Dashboard from '../site/components/Dashboard'
  384. import ChargeRate from '../site/components/ChargeRate'
  385. import Balancing from '../site/components/Balancing'
  386. import EmailRecipient from '../site/components/EmailRecipient'
  387. import Reservation from '../site/components/Reservations'
  388. import WhiteListFleet from '../site/components/WhiteListFleet'
  389. import WhiteListUser from '../site/components/WhiteListUser'
  390. import SiteTypeWithTime from './components/SiteTypeWithTime'
  391. import waves from '@/directive/waves' // waves directive
  392. import site from '../../http/api/site'
  393. import apiSet from '../../http/api/settings'
  394. import { getRoleName } from '@/utils/auth'
  395. export default {
  396. directives: { waves },
  397. components: {
  398. Balancing,
  399. ChargeRate,
  400. Dashboard,
  401. EmailRecipient,
  402. Reservation,
  403. WhiteListUser,
  404. WhiteListFleet,
  405. SiteTypeWithTime,
  406. Summary,
  407. AuditView
  408. },
  409. data() {
  410. return {
  411. pageLoading: false,
  412. isMCSTUser: false,
  413. countryOptions: [],
  414. featuresOptions: [],
  415. siteForm: {
  416. sitePk: "",
  417. siteName: "",
  418. siteTypes: [],
  419. emails: [],
  420. carParkCode: "",
  421. address: {
  422. city: "",
  423. countryCode: settings.defaultCountry,
  424. street: "",
  425. zipCode: ""
  426. },
  427. ocppSetting: {
  428. expireHours: '',
  429. ocppSettingId: '',
  430. heartbeatIntervalMinutes: ''
  431. },
  432. free: false,
  433. endlessService: false,//24/7
  434. additionalNotes: "",
  435. //罚款部分
  436. enableIdleFee: false,//idle Fee
  437. idleFee: "",//idle Fee
  438. everyMinute: "",//idle Fee
  439. effectiveDate: "",//idle Fee
  440. effectiveFrom: "",//idle Fee
  441. effectiveTo: "",//idle Fee
  442. gracePeriod: "",//idle Fee
  443. //预订部分
  444. enableReservation: false,//预订
  445. timeLimit: null,//预订
  446. parkingFee: "",
  447. whitelistUser: [],
  448. groupWhitelist: [],
  449. operatingHours: "",
  450. locationLatitude: "",
  451. locationLongitude: "",
  452. chargeRates: [],
  453. specialChargeRates: [],
  454. loadBalancing: "",//负载均衡
  455. staticMaxAmpere: "",//负载均衡
  456. siteChargingProfiles: null,//负载均衡
  457. enabledFeatures: []
  458. },
  459. ratesForm: {
  460. chargeRates: [{
  461. rate: '',
  462. rateType: '',
  463. chargeTypePk: ''
  464. }],
  465. specialChargeRates: [{
  466. rate: '',
  467. rateType: '',
  468. chargeTypePk: '',
  469. groupPk: ''
  470. }]
  471. },
  472. balancingForm: {
  473. loadBalancing: 'dynamic',
  474. staticMaxAmpere: 0,
  475. siteChargingProfiles: [{
  476. boxInUse: '',
  477. chargingProfilePk: ''
  478. }],
  479. },
  480. currencyData: {
  481. SG: "S$"
  482. },
  483. autosize: {
  484. minRows: 3,
  485. maxRows: 6,
  486. },
  487. summaryInfo: {},
  488. rules: {
  489. siteName: {
  490. required: true,
  491. trigger: 'blur',
  492. message: 'Site Name is required',
  493. },
  494. locationLatitude: [{
  495. required: true,
  496. trigger: 'blur',
  497. message: 'Latitude is required',
  498. }, {
  499. pattern: /^[\-\+]?((0|([1-8]\d?))(\.\d{1,8})?|90(\.0{1,8})?)$/,
  500. trigger: 'blur',
  501. message: 'Please type a correct latitude',
  502. }],
  503. locationLongitude: [{
  504. required: true,
  505. trigger: 'blur',
  506. message: 'Longitude is required',
  507. }, {
  508. pattern: /^[\-\+]?(0(\.\d{1,8})?|([1-9](\d)?)(\.\d{1,8})?|1[0-7]\d{1}(\.\d{1,8})?|180\.0{1,8})$/,
  509. trigger: 'blur',
  510. message: 'Please type a correct longitude',
  511. }],
  512. address: {
  513. street: {
  514. required: true,
  515. trigger: 'blur',
  516. message: 'Address is required',
  517. },
  518. zipCode: {
  519. required: true,
  520. trigger: 'blur',
  521. message: 'Postal Code is required',
  522. },
  523. city: {
  524. required: true,
  525. trigger: 'blur',
  526. message: 'City is required',
  527. },
  528. countryCode: {
  529. required: true,
  530. trigger: 'blur',
  531. message: 'Country is required',
  532. }
  533. },
  534. idleFee: {
  535. required: true,
  536. trigger: 'blur',
  537. message: 'Idle fee is required'
  538. },
  539. effectiveDate: {
  540. required: true,
  541. trigger: 'change',
  542. message: 'Effective Date is required'
  543. },
  544. effectiveFrom: {
  545. required: true,
  546. trigger: 'change',
  547. message: 'Effective From is required'
  548. },
  549. effectiveTo: {
  550. required: true,
  551. trigger: 'change',
  552. message: 'Effective To is required'
  553. },
  554. gracePeriod: {
  555. required: true,
  556. trigger: 'change',
  557. message: 'Grace Period is required'
  558. },
  559. everyMinute: [{
  560. required: true,
  561. trigger: 'blur',
  562. message: 'Every is required'
  563. }, {
  564. type: 'number',
  565. message: 'Every is a number'
  566. }]
  567. },
  568. enablePublic: false,
  569. enableWhitelistUser: false,
  570. enableWhitelistFleet: false,
  571. isEdit: false
  572. }
  573. },
  574. created() {
  575. this.pageLoading = true;
  576. this.isMCSTUser = getRoleName() === "MCST";
  577. this.getCountryOptions();
  578. this.getFeaturesList();
  579. if (this.$route.params.id) {
  580. this.isEdit = true;
  581. this.getSiteInfo()
  582. } else {
  583. setTimeout(() => {
  584. this.pageLoading = false;
  585. }, 500);
  586. }
  587. },
  588. methods: {
  589. getCountryOptions() {
  590. site.getCountryList().then(res => {
  591. if (res.data) {
  592. this.countryOptions = res.data
  593. const sign = {}
  594. res.data.forEach(item => {
  595. sign[item.value] = item.currencySymbol
  596. })
  597. this.currencyData = sign;
  598. }
  599. }).catch(() => {
  600. this.$message({
  601. message: err,
  602. type: 'error',
  603. duration: 3000,
  604. })
  605. this.pageLoading = false;
  606. })
  607. },
  608. getFeaturesList() {
  609. apiSet.getFeatures().then(res => {
  610. if (res.data) {
  611. this.featuresOptions = res.data;
  612. }
  613. }).catch(() => {
  614. this.$message({
  615. message: err,
  616. type: 'error',
  617. duration: 3000,
  618. })
  619. this.pageLoading = false;
  620. })
  621. },
  622. getSiteInfo() {
  623. site.getSiteInfo({
  624. sitePk: this.$route.params.id,
  625. }).then(res => {
  626. if (res.data) {
  627. if (!res.data.enabledFeatures) {
  628. res.data.enabledFeatures = []
  629. }
  630. this.siteForm = res.data;
  631. this.applySiteInfo();
  632. } else {
  633. this.pageLoading = false;
  634. }
  635. }).catch(() => {
  636. this.$message({
  637. message: err,
  638. type: 'error',
  639. duration: 3000,
  640. })
  641. this.pageLoading = false;
  642. })
  643. },
  644. applySiteInfo() {
  645. setTimeout(() => {
  646. this.pageLoading = false;
  647. }, 500);
  648. if (this.siteForm.chargeRates && this.siteForm.chargeRates.length) {
  649. const rate = [], srate = []
  650. this.siteForm.chargeRates.forEach(item => {
  651. if (item.groupPk) {
  652. srate.push(item)
  653. } else {
  654. rate.push(item)
  655. }
  656. })
  657. if (rate.length > 0) {
  658. this.ratesForm.chargeRates = rate;
  659. }
  660. if (srate.length > 0) {
  661. this.ratesForm.specialChargeRates = srate;
  662. }
  663. }
  664. if (this.siteForm.siteTypes && this.siteForm.siteTypes.length) {
  665. for (let type of this.siteForm.siteTypes) {
  666. if (type.siteType == "PRI_USR_WHI") {
  667. this.enableWhitelistUser = (type.allDay || (type.startTime && type.endTime))
  668. } else if (type.siteType == "PRI_FLE_WHI") {
  669. this.enableWhitelistFleet = (type.allDay || (type.startTime && type.endTime))
  670. } else if (type.siteType == "PUB") {
  671. this.enablePublic = (type.allDay || (type.startTime && type.endTime))
  672. } else {
  673. continue;
  674. }
  675. }
  676. }
  677. if (this.siteForm.siteSummary) {
  678. this.summaryInfo = Object.assign(this.siteForm.siteSummary, {});
  679. delete this.siteForm.siteSummary;
  680. }
  681. this.balancingForm = {
  682. loadBalancing: this.siteForm.loadBalancing || 'dynamic',
  683. staticMaxAmpere: this.siteForm.staticMaxAmpere || 0,
  684. siteChargingProfiles: this.siteForm.siteChargingProfiles || [{
  685. boxInUse: '',
  686. chargingProfilePk: ''
  687. }]
  688. }
  689. },
  690. changeEndless(value) {
  691. if (value) {
  692. this.siteForm.operatingHours = ""
  693. }
  694. },
  695. changeParkingFree(value) {
  696. if (value) {
  697. this.siteForm.parkingFee = ""
  698. }
  699. },
  700. changeSiteTypes(data) {
  701. if (this.isEdit && this.pageLoading) {
  702. console.log("changeSiteTypes", data);
  703. return;
  704. }
  705. this.siteForm.siteTypes = data;
  706. /*for (let type of data) {
  707. if (type.siteType == "PRI_USR_WHI") {
  708. this.enableWhitelistUser = (type.allDay || (type.startTime && type.endTime))
  709. } else if (type.siteType == "PRI_FLE_WHI") {
  710. this.enableWhitelistFleet = (type.allDay || (type.startTime && type.endTime))
  711. } else if (type.siteType == "PUB") {
  712. this.enablePublic = (type.allDay || (type.startTime && type.endTime))
  713. } else {
  714. continue;
  715. }
  716. }*/
  717. },
  718. handleClickCancleButton() {
  719. this.$router.push({
  720. path: "/site-management-v2/site-configuration"
  721. });
  722. },
  723. handleClickSaveButton() {
  724. this.$refs['addForm'].validate(result => {
  725. if (result) {
  726. const rates = [];
  727. /* 启用动态费率配置
  728. this.ratesForm.chargeRates.forEach(item => {
  729. if (item.rate) {
  730. rates.push(item);
  731. }
  732. })
  733. this.ratesForm.specialChargeRates.forEach(item => {
  734. if (item.rate) {
  735. rates.push(item);
  736. }
  737. })
  738. if (rates.length == 0) {
  739. this.$message({
  740. message: "Please add at least one rate",
  741. type: 'error',
  742. duration: 3000,
  743. })
  744. this.scrollToView("idChargeRates", true);
  745. return;
  746. }*/
  747. if (!this.siteForm.enableReservation) {
  748. this.siteForm.timeLimit = "";
  749. }
  750. /*const chargeProfiles = []
  751. this.balancingForm.siteChargingProfiles.forEach(item => {
  752. if (item.boxInUse && item.chargingProfilePk)
  753. chargeProfiles.push(item)
  754. })
  755. this.siteForm.siteChargingProfiles = chargeProfiles
  756. if (this.balancingForm.loadBalancing == 'dynamic') {
  757. this.siteForm.staticMaxAmpere = ""
  758. } else {
  759. this.siteForm.staticMaxAmpere = this.balancingForm.staticMaxAmpere
  760. }
  761. this.siteForm.loadBalancing = this.balancingForm.loadBalancing*/
  762. /*if (!this.enablePublic && !this.enableWhitelistFleet && !this.enableWhitelistUser) {
  763. this.$message({
  764. message: "Please set time configuration",
  765. type: 'error',
  766. duration: 3000,
  767. })
  768. this.scrollToView("idSiteTypes");
  769. return;
  770. }*/
  771. if (this.enableWhitelistUser) {
  772. let _list = []
  773. this.siteForm.whitelistUser.forEach(item => {
  774. if (item.mobileNumber && item.licenceNumber) {
  775. _list.push(item);
  776. }
  777. })
  778. if (_list.length == 0) {
  779. this.$message({
  780. message: "Please add at least one whitelist user",
  781. type: 'error',
  782. duration: 3000,
  783. })
  784. return;
  785. } else {
  786. this.siteForm.whitelistUser = _list;
  787. }
  788. } else {
  789. this.siteForm.whitelistUser = [];
  790. }
  791. if (this.enableWhitelistFleet) {
  792. let _list = []
  793. this.siteForm.groupWhitelist.forEach(item => {
  794. if (item.groupPk) {
  795. _list.push(item);
  796. }
  797. })
  798. if (_list.length == 0) {
  799. this.$message({
  800. message: "Please add at least one whitelist group",
  801. type: 'error',
  802. duration: 3000,
  803. })
  804. return;
  805. } else {
  806. this.siteForm.groupWhitelist = _list;
  807. }
  808. } else {
  809. this.siteForm.groupWhitelist = []
  810. }
  811. if (this.siteForm.enabledFeatures.length > 0 && this.siteForm.emails.length == 0) {
  812. this.$message({
  813. message: "Please add at least one email recipients",
  814. type: 'error',
  815. duration: 3000,
  816. })
  817. return;
  818. }
  819. this.pageLoading = true;
  820. const params = {
  821. ...this.siteForm,
  822. chargeRates: rates
  823. }
  824. console.log("form", params);
  825. if (this.isEdit) {
  826. this.updateSite(params);
  827. } else {
  828. this.addSite(params)
  829. }
  830. //this.editSiteWithForm();
  831. } else {
  832. this.scrollToView("idSiteInfo", true);
  833. }
  834. })
  835. },
  836. scrollToView(id, alignToTop) {
  837. //console.log("scrollToView", !alignToTop);
  838. window.requestAnimationFrame(() => {
  839. document.getElementById(id).scrollIntoView(!alignToTop, {
  840. block: "start",
  841. behavior: "smooth"
  842. })
  843. });
  844. },
  845. isSiteTypeEnable(index, isSwitch) {
  846. for (let i = 0; i < this.siteForm.siteTypes.length; i++) {
  847. let type = this.siteForm.siteTypes[i];
  848. if (type.allDay) {
  849. if (index == i && isSwitch) {
  850. return false;
  851. } else {
  852. return true;
  853. }
  854. } else {
  855. continue;
  856. }
  857. }
  858. return false;
  859. },
  860. addSite(params) {
  861. site.addSite(params).then(res => {
  862. this.$message({
  863. message: "Add site success",
  864. type: 'success',
  865. duration: 3000,
  866. })
  867. this.handleClickCancleButton();
  868. }).catch((error) => {
  869. this.$message({
  870. message: error,
  871. type: "error",
  872. duration: 5000,
  873. })
  874. }).finally(() => {
  875. this.pageLoading = false;
  876. })
  877. },
  878. updateSite(params) {
  879. site.updateSite(params).then(res => {
  880. this.$message({
  881. message: "Update site success",
  882. type: 'success',
  883. duration: 3000,
  884. })
  885. this.handleClickCancleButton();
  886. }).catch((error) => {
  887. this.$message({
  888. message: error,
  889. type: "error",
  890. duration: 5000,
  891. })
  892. }).finally(() => {
  893. this.pageLoading = false;
  894. })
  895. },
  896. configLoadBalance() {
  897. this.$openRoute("/smart-energy-management/site-load-balancing/" + this.siteForm.sitePk);
  898. }
  899. }
  900. }
  901. </script>
  902. <style scoped lang='scss'>
  903. @import '../../styles/element-ui.scss';
  904. @import '../../styles/variables.scss';
  905. .view-container {
  906. width: 100%;
  907. padding: 20px 60px;
  908. min-height: $mainAppMinHeight;
  909. background-color: #F0F5FC;
  910. }
  911. .view-content {
  912. margin: 0 8px 16px;
  913. padding: 15px 50px;
  914. border-radius: 6px;
  915. background-color: white;
  916. }
  917. @media screen and (max-width: 800px) {
  918. .view-container {
  919. padding: 10px 20px;
  920. }
  921. .view-content {
  922. padding: 15px 40px;
  923. }
  924. }
  925. @media screen and (max-width: 500px) {
  926. .view-container {
  927. padding: 0px;
  928. }
  929. .view-content {
  930. padding: 15px 30px;
  931. }
  932. }
  933. .sparator {
  934. margin: 10px -30px;
  935. height: 2px;
  936. background-color: #F0F5FC;
  937. }
  938. .section-title {
  939. color: #333333;
  940. margin-top: 20px;
  941. margin-bottom: 30px;
  942. font-size: 15px;
  943. line-height: 24px;
  944. font-weight: 700;
  945. font-family: sans-serif;
  946. text-transform: uppercase;
  947. }
  948. .section-sub-title {
  949. font-size: 14px;
  950. padding-left: 5px;
  951. font-weight: normal;
  952. }
  953. .site-type-layout {
  954. overflow-x: auto;
  955. }
  956. .site-type-layout::-webkit-scrollbar-track-piece {
  957. background-color:#f8f8f8;
  958. }
  959. .site-type-layout::-webkit-scrollbar {
  960. width: 7px;
  961. height: 10px;
  962. }
  963. .site-type-layout::-webkit-scrollbar-thumb {
  964. transition: all .4s;
  965. border-radius: 30px;
  966. background-color: rgba($--color-primary, 0.3);
  967. background-clip: padding-box;
  968. }
  969. .site-type-layout::-webkit-scrollbar-thumb:hover {
  970. background-color: rgba($--color-primary, 0.6);
  971. }
  972. .input-text {
  973. width: 100% !important;
  974. max-width: 300px;
  975. }
  976. .add-text {
  977. width: 100%;
  978. font-size: 14px;
  979. max-width: 300px;
  980. }
  981. .add-text ::v-deep .el-textarea__inner,
  982. .input-text ::v-deep .el-textarea__inner {
  983. font-family: sans-serif;
  984. }
  985. .value-text {
  986. width: 100%;
  987. min-width: 100px;
  988. max-width: 200px;
  989. }
  990. .value-unit {
  991. padding-left: 10px;
  992. }
  993. .label-unit {
  994. left: 0;
  995. bottom: 0;
  996. width: 125px;
  997. font-size: 12px;
  998. line-height: 1;
  999. position: absolute;
  1000. }
  1001. .cancel-button {
  1002. width: 94px;
  1003. height: 40px;
  1004. }
  1005. .confirm-button {
  1006. width: 94px;
  1007. height: 40px;
  1008. margin-left: 20px;
  1009. background: $--color-primary;
  1010. border: 1px solid $--color-primary;
  1011. box-sizing: border-box;
  1012. border-radius: 4px;
  1013. }
  1014. ::v-deep .el-switch__label.el-switch__label--left span {
  1015. font-size: 14px;
  1016. color: black;
  1017. }
  1018. .idle-switch {
  1019. font-size: 13px;
  1020. text-transform: none;
  1021. }
  1022. .tips {
  1023. color: #999;
  1024. font-size: 12px;
  1025. padding-left: 150px;
  1026. padding-bottom: 20px;
  1027. }
  1028. .tips i {
  1029. color: #333;
  1030. font-weight: 500;
  1031. font-style: normal;
  1032. }
  1033. .new-load-balance {
  1034. position: relative;
  1035. padding-left: 15px;
  1036. padding-bottom: 20px;
  1037. }
  1038. .new-text {
  1039. top: -10px;
  1040. left: 0px;
  1041. color: #FF1122;
  1042. font-size: 12px;
  1043. position: absolute;
  1044. transform: scale(0.8);
  1045. }
  1046. .features-group {
  1047. min-width: 300px;
  1048. display: flex;
  1049. margin-left: 20px;
  1050. flex-direction: column;
  1051. ::v-deep .el-checkbox {
  1052. display: flex;
  1053. align-items: center;
  1054. padding-bottom: 5px;
  1055. }
  1056. ::v-deep .el-checkbox__label {
  1057. color: #000;
  1058. word-break: break-all;
  1059. white-space: normal;
  1060. }
  1061. ::v-deep .el-checkbox__input.is-checked .el-checkbox__inner::after {
  1062. border-color: $buttonText;
  1063. }
  1064. }
  1065. </style>