|
|
@@ -0,0 +1,568 @@
|
|
|
+<template>
|
|
|
+ <div class="container" v-loading="loading">
|
|
|
+ <el-form
|
|
|
+ ref="form"
|
|
|
+ :model="form"
|
|
|
+ :rules="rules"
|
|
|
+ label-width="150px"
|
|
|
+ label-position="top">
|
|
|
+ <div class="content">
|
|
|
+ <div class="section-title">Idle Fee Config</div>
|
|
|
+ <div class="flexcr">
|
|
|
+ <el-form-item
|
|
|
+ label="Idle Fee Name:"
|
|
|
+ prop="idleFeeName"
|
|
|
+ class="add-input">
|
|
|
+ <el-input
|
|
|
+ v-model="form.idleFeeName"
|
|
|
+ maxlength="100"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ label="Country:"
|
|
|
+ prop="countryCode"
|
|
|
+ class="add-input">
|
|
|
+ <el-select
|
|
|
+ v-model="form.countryCode">
|
|
|
+ <el-option
|
|
|
+ v-for="item in options.country"
|
|
|
+ :key="item.name"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.value" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ label="Service Provider:"
|
|
|
+ prop="tenantId"
|
|
|
+ class="add-input"
|
|
|
+ v-if="false">
|
|
|
+ <el-select
|
|
|
+ v-model="form.tenantId">
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in options.provider"
|
|
|
+ :key="index"
|
|
|
+ :label="item.key"
|
|
|
+ :value="item.tenantId"/>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ <div class="flexcr">
|
|
|
+ <label class="el-form-item__label">Repeat:</label>
|
|
|
+ <div class="repeat-view">
|
|
|
+ (
|
|
|
+ <div
|
|
|
+ class="link-type"
|
|
|
+ v-for="(item, index) in options.shortcut"
|
|
|
+ :key="index"
|
|
|
+ @click="handleShortcut(item)">
|
|
|
+ <span>{{item.name}}</span>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ <el-tooltip
|
|
|
+ effect="dark"
|
|
|
+ content="This is an items for quickly selecting the repeats"
|
|
|
+ placement="right">
|
|
|
+ <i class="el-icon-question icon-help"></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div style="margin-bottom: 10px;">
|
|
|
+ <el-checkbox-group
|
|
|
+ v-model="form.repeatDays">
|
|
|
+ <el-checkbox-button
|
|
|
+ v-for="(item, index) in options.repeat"
|
|
|
+ :label="item.value"
|
|
|
+ :key="index">
|
|
|
+ {{item.name}}
|
|
|
+ </el-checkbox-button>
|
|
|
+ </el-checkbox-group>
|
|
|
+ </div>
|
|
|
+ <div class="flexcr">
|
|
|
+ <el-form-item
|
|
|
+ label="All Day:"
|
|
|
+ class="add-input">
|
|
|
+ <el-switch
|
|
|
+ v-model="form.allDay"
|
|
|
+ @change="changeAllday"/>
|
|
|
+ </el-form-item>
|
|
|
+ <template v-if="form.allDay">
|
|
|
+ <el-form-item
|
|
|
+ label="Start Time:"
|
|
|
+ class="add-input">
|
|
|
+ <el-input disabled/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ label="End Time:"
|
|
|
+ class="add-input">
|
|
|
+ <el-input disabled/>
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <el-form-item
|
|
|
+ label="Start Time:"
|
|
|
+ class="add-input"
|
|
|
+ prop="startTime">
|
|
|
+ <el-time-picker
|
|
|
+ v-model="form.startTime"
|
|
|
+ format="HH:mm"
|
|
|
+ value-format="HH:mm"
|
|
|
+ clearable/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ label="End Time:"
|
|
|
+ class="add-input"
|
|
|
+ prop="endTime">
|
|
|
+ <el-time-picker
|
|
|
+ v-model="form.endTime"
|
|
|
+ format="HH:mm"
|
|
|
+ value-format="HH:mm"
|
|
|
+ clearable/>
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+ <div class="flexcr">
|
|
|
+ <el-form-item
|
|
|
+ label="Grace Period (Minutes):"
|
|
|
+ class="add-input"
|
|
|
+ prop="idleGracePeriod">
|
|
|
+ <el-input
|
|
|
+ v-model="form.idleGracePeriod"
|
|
|
+ maxlength="5"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ :label="'Idle Fee (' + currencyData[form.countryCode] + '):'"
|
|
|
+ class="add-input"
|
|
|
+ prop="idleFee">
|
|
|
+ <el-input
|
|
|
+ v-model="form.idleFee"
|
|
|
+ maxlength="10"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ label="Interval (Minutes):"
|
|
|
+ class="add-input"
|
|
|
+ prop="idleInterval">
|
|
|
+ <el-input
|
|
|
+ v-model="form.idleInterval"
|
|
|
+ maxlength="5"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ label="Set Cap:"
|
|
|
+ class="add-input"
|
|
|
+ prop="idleFeeCap">
|
|
|
+ <el-input
|
|
|
+ v-model="form.idleFeeCap"
|
|
|
+ maxlength="10"/>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="content flexcr">
|
|
|
+ <div class="buttons">
|
|
|
+ <el-button
|
|
|
+ @click="onBack"
|
|
|
+ type="primary"
|
|
|
+ class="cancel-button">
|
|
|
+ Cancel
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ @click="onClickSave"
|
|
|
+ type="primary"
|
|
|
+ :loading="loadingSave">
|
|
|
+ Save
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ <audit-view :audit="form.audit"/>
|
|
|
+ </div>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import site from '../../http/api/site'
|
|
|
+import api from '@/api/apiIdle.js';
|
|
|
+//import apiBase from "@/api/apiBase.js";
|
|
|
+import apiRate from '@/http/api/rates'
|
|
|
+import settings from '../../settings.js'
|
|
|
+import AuditView from "@/components/AuditView"
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ loading: false,
|
|
|
+ loadingSave: false,
|
|
|
+ isEdit: false,
|
|
|
+ form: {
|
|
|
+ dynamicIdleFeeId: "",
|
|
|
+ tenantId: "",
|
|
|
+ idleFeeName: "",
|
|
|
+ countryCode: settings.defaultCountry,
|
|
|
+ repeatDays: [],
|
|
|
+ allDay: false,
|
|
|
+ startTime: "",
|
|
|
+ endTime: "",
|
|
|
+ idleGracePeriod: "",
|
|
|
+ idleInterval: "",
|
|
|
+ idleFee: "",
|
|
|
+ idleFeeCap: "",
|
|
|
+ audit: {}
|
|
|
+ },
|
|
|
+ options: {
|
|
|
+ provider: [],
|
|
|
+ country: [],
|
|
|
+ repeat: [],
|
|
|
+ shortcut: [{
|
|
|
+ name: "Daily",
|
|
|
+ value: [],
|
|
|
+ all: true
|
|
|
+ },{
|
|
|
+ name: "Weekday",
|
|
|
+ value: ["Mon","Tue","Wed","Thu","Fri"]
|
|
|
+ },{
|
|
|
+ name: "Weekend",
|
|
|
+ value: ["Sat","Sun"]
|
|
|
+ }, {
|
|
|
+ name: "None",
|
|
|
+ value: []
|
|
|
+ }]
|
|
|
+ },
|
|
|
+ currencyData: {
|
|
|
+ SG: "S$"
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ idleFeeName: {
|
|
|
+ required: true,
|
|
|
+ trigger: "blur",
|
|
|
+ message: "Please input rate name"
|
|
|
+ },
|
|
|
+ tenantId: {
|
|
|
+ required: true,
|
|
|
+ trigger: "blur",
|
|
|
+ message: "Provider is required"
|
|
|
+ },
|
|
|
+ idleGracePeriod: [{
|
|
|
+ required: true,
|
|
|
+ trigger: 'blur',
|
|
|
+ message: 'Grace period is required',
|
|
|
+ }, {
|
|
|
+ pattern: /^\d+$/,
|
|
|
+ trigger: 'blur',
|
|
|
+ message: 'Please type a correct number',
|
|
|
+ }],
|
|
|
+ idleFee: [{
|
|
|
+ required: true,
|
|
|
+ trigger: 'blur',
|
|
|
+ message: 'Idle fee is required',
|
|
|
+ }, {
|
|
|
+ pattern: /^\d+(\.\d+)?$/,
|
|
|
+ trigger: 'blur',
|
|
|
+ message: 'Please type a correct fee',
|
|
|
+ }],
|
|
|
+ idleInterval: [{
|
|
|
+ required: true,
|
|
|
+ trigger: 'blur',
|
|
|
+ message: 'Interval is required',
|
|
|
+ }, {
|
|
|
+ pattern: /^\d+$/,
|
|
|
+ trigger: 'blur',
|
|
|
+ message: 'Please type a correct number',
|
|
|
+ }],
|
|
|
+ idleFeeCap: [{
|
|
|
+ required: true,
|
|
|
+ trigger: 'blur',
|
|
|
+ message: 'Cap is required',
|
|
|
+ }, {
|
|
|
+ pattern: /^\d+(\.\d+)?$/,
|
|
|
+ trigger: 'blur',
|
|
|
+ message: 'Please type a correct fee',
|
|
|
+ }],
|
|
|
+ startTime: {
|
|
|
+ required: true,
|
|
|
+ trigger: "change",
|
|
|
+ message: "Please select start time"
|
|
|
+ },
|
|
|
+ endTime: {
|
|
|
+ required: true,
|
|
|
+ trigger: "change",
|
|
|
+ message: "Please select end time"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ components: {AuditView},
|
|
|
+ created() {
|
|
|
+ this.loading = true;
|
|
|
+ this.getCountryOptions();
|
|
|
+ this.getProviderOptions();
|
|
|
+ if (this.$route.params.id) {
|
|
|
+ this.isEdit = true;
|
|
|
+ this.getIdleFeeDetail();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ onBack() {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$router.replace({
|
|
|
+ path: "/site-management/idle-fee-configuration"
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getCountryOptions() {
|
|
|
+ site.getCountryList().then(res => {
|
|
|
+ if (res.data) {
|
|
|
+ this.options.country = res.data
|
|
|
+ const sign = {}
|
|
|
+ res.data.forEach(item => {
|
|
|
+ sign[item.value] = item.currencySymbol
|
|
|
+ })
|
|
|
+ this.currencyData = sign;
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ message: err
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /*getProviderOptions() {
|
|
|
+ apiBase.getProviderList().then(res => {
|
|
|
+ if (res.data && res.data.length > 0) {
|
|
|
+ this.options.provider = res.data
|
|
|
+ this.form.tenantId = this.options.provider[0].tenantId;
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ message: err
|
|
|
+ })
|
|
|
+ }).finally(() => {
|
|
|
+ this.getRepeatOptions();
|
|
|
+ })
|
|
|
+ },*/
|
|
|
+ getRepeatOptions() {
|
|
|
+ apiRate.getRepeatOptions().then(res => {
|
|
|
+ if (res.data) {
|
|
|
+ this.options.repeat = res.data
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ message: err
|
|
|
+ })
|
|
|
+ }).finally(() => {
|
|
|
+ this.loading = false;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getIdleFeeDetail() {
|
|
|
+ this.loading = true;
|
|
|
+ api.getIdleFeeById(this.$route.params.id).then(res => {
|
|
|
+ if (res.data) {
|
|
|
+ this.form = res.data;
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ message: err
|
|
|
+ })
|
|
|
+ }).finally(() => {
|
|
|
+ this.loading = false;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleShortcut(shortcut) {
|
|
|
+ const select = []
|
|
|
+ if (shortcut.all) {
|
|
|
+ this.options.repeat.forEach(item => {
|
|
|
+ select.push(item.value)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ select.push(...shortcut.value)
|
|
|
+ }
|
|
|
+ this.form.repeatDays = select;
|
|
|
+ },
|
|
|
+ changeAllday(all) {
|
|
|
+ if (all) {
|
|
|
+ this.form.startTime = "";
|
|
|
+ this.form.endTime = "";
|
|
|
+ this.$refs.form.clearValidate()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onClickSave() {
|
|
|
+ this.$refs.form.validate(result => {
|
|
|
+ if (result) {
|
|
|
+ if (this.form.repeatDays.length == 0) {
|
|
|
+ this.$message({
|
|
|
+ message: "Please select at least one repeat day",
|
|
|
+ type: 'error',
|
|
|
+ duration: 3000,
|
|
|
+ })
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.loadingSave = true;
|
|
|
+ this.isEdit ? this.updateIdleFee() : this.addIdleFee();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ addIdleFee() {
|
|
|
+ api.saveIdleFee(this.form).then(res => {
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: "Successfully added"
|
|
|
+ });
|
|
|
+ this.onBack();
|
|
|
+ }).catch(err => {
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ message: err
|
|
|
+ });
|
|
|
+ }).finally(() => {
|
|
|
+ this.loadingSave = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ updateIdleFee() {
|
|
|
+ api.updateIdleFee(this.form).then(res => {
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: "Successfully updated"
|
|
|
+ });
|
|
|
+ this.onBack();
|
|
|
+ }).catch(err => {
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ message: err
|
|
|
+ });
|
|
|
+ }).finally(() => {
|
|
|
+ this.loadingSave = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+ @import '../../styles/variables.scss';
|
|
|
+ .container {
|
|
|
+ width: 100%;
|
|
|
+ padding: 20px 60px;
|
|
|
+ min-height: $mainAppMinHeight;
|
|
|
+ background-color: #F0F5FC;
|
|
|
+ }
|
|
|
+ .content {
|
|
|
+ margin: 0 8px 16px;
|
|
|
+ padding: 15px 80px;
|
|
|
+ border-radius: 6px;
|
|
|
+ background-color: white;
|
|
|
+ }
|
|
|
+
|
|
|
+ .section-title {
|
|
|
+ color: #333;
|
|
|
+ margin-top: 20px;
|
|
|
+ margin-bottom: 30px;
|
|
|
+ font-size: 15px;
|
|
|
+ user-select: none;
|
|
|
+ line-height: 24px;
|
|
|
+ font-weight: bold;
|
|
|
+ font-family: sans-serif;
|
|
|
+ text-transform: uppercase;
|
|
|
+ }
|
|
|
+
|
|
|
+ .section-sub-title {
|
|
|
+ font-size: 14px;
|
|
|
+ padding-left: 5px;
|
|
|
+ font-weight: normal;
|
|
|
+ }
|
|
|
+
|
|
|
+ .add-text {
|
|
|
+ width: 100%;
|
|
|
+ min-width: 100px;
|
|
|
+ max-width: 300px;
|
|
|
+ }
|
|
|
+ .add-text ::v-deep .el-textarea__inner {
|
|
|
+ font-family: sans-serif;
|
|
|
+ }
|
|
|
+ .add-input {
|
|
|
+ width: 100%;
|
|
|
+ min-width: 100px;
|
|
|
+ max-width: 250px;
|
|
|
+ margin-right: 15px;
|
|
|
+ ::v-deep .el-input,
|
|
|
+ ::v-deep .el-select {
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .icon-help {
|
|
|
+ color: #999;
|
|
|
+ font-size: 15px;
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+
|
|
|
+ .form-photo {
|
|
|
+ flex: 1;
|
|
|
+ ::v-deep .el-form-item__label {
|
|
|
+ padding: 12px;
|
|
|
+ line-height: 16px;
|
|
|
+ }
|
|
|
+ .photo-uploader {
|
|
|
+ margin-right: 10px;
|
|
|
+ .uploader-image {
|
|
|
+ width: 180px;
|
|
|
+ height: 120px;
|
|
|
+ text-align: left;
|
|
|
+ }
|
|
|
+ ::v-deep img {
|
|
|
+ object-fit: cover;
|
|
|
+ }
|
|
|
+ .avatar-uploader-icon {
|
|
|
+ border: 1px dashed #d9d9d9;
|
|
|
+ border-radius: 6px;
|
|
|
+ cursor: pointer;
|
|
|
+ font-size: 28px;
|
|
|
+ color: #8c939d;
|
|
|
+ width: 120px;
|
|
|
+ height: 120px;
|
|
|
+ line-height: 120px;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .repeat-view {
|
|
|
+ display: flex;
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: bold;
|
|
|
+ align-items: center;
|
|
|
+ padding: 0 10px 10px;
|
|
|
+ .link-type + .link-type {
|
|
|
+ margin-left: 10px;
|
|
|
+ &::after {
|
|
|
+ left: -7px;
|
|
|
+ color: #333;
|
|
|
+ content: "|";
|
|
|
+ font-weight: normal;
|
|
|
+ position: absolute;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .hr {
|
|
|
+ height: 2px;
|
|
|
+ margin: 10px -40px;
|
|
|
+ background-color: #F0F5FC;
|
|
|
+ }
|
|
|
+ .buttons {
|
|
|
+ padding-top: 15px;
|
|
|
+ padding-bottom: 15px;
|
|
|
+ }
|
|
|
+ @media screen and (max-width: 1200px) {
|
|
|
+ .add-input {
|
|
|
+ min-width: 80px;
|
|
|
+ max-width: 200px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @media screen and (max-width: 500px) {
|
|
|
+ .container {
|
|
|
+ padding: 0px;
|
|
|
+ }
|
|
|
+ .content {
|
|
|
+ padding: 15px 30px;
|
|
|
+ }
|
|
|
+ .add-input {
|
|
|
+ max-width: unset;
|
|
|
+ margin-right: 0px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|