detail.vue 29 KB

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