2019-11-16 10:21:14 +03:00
|
|
|
<template>
|
2022-06-01 10:15:55 +03:00
|
|
|
<div class="sm:col-span-6 space-y-8 sm:space-y-2">
|
|
|
|
<div class="flex items-center" :class="{ 'justify-between sm:justify-start': frequency == 'custom' }">
|
|
|
|
<div class="w-60 px-2 text-sm">
|
|
|
|
{{ frequencyText }}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<el-select class="w-36" v-model="frequency" @input="change">
|
|
|
|
<el-option
|
|
|
|
v-for="(label, value) in frequencies"
|
|
|
|
:key="value"
|
2019-11-16 10:21:14 +03:00
|
|
|
:label="label"
|
|
|
|
:value="value">
|
|
|
|
</el-option>
|
|
|
|
</el-select>
|
2022-06-01 10:15:55 +03:00
|
|
|
|
|
|
|
<div class="w-20 px-2 text-sm text-center" v-if="frequency == 'custom'">
|
|
|
|
{{ frequencyEveryText }}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<input type="text" class="w-20 form-element" v-model="interval" @input="change" v-if="frequency == 'custom'">
|
|
|
|
|
|
|
|
<el-select class="w-36 ml-2" v-model="customFrequency" @input="change" v-if="frequency == 'custom'">
|
|
|
|
<el-option
|
|
|
|
v-for="(label, value) in customFrequencies"
|
|
|
|
:key="value"
|
|
|
|
:label="label"
|
|
|
|
:value="value">
|
|
|
|
</el-option>
|
|
|
|
</el-select>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="flex items-center" :class="{ 'justify-between sm:justify-start': limit !== 'never' }">
|
|
|
|
<div class="w-60 px-2 text-sm">
|
|
|
|
{{ startText }}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<el-date-picker
|
|
|
|
class="w-36 recurring-invoice-data"
|
|
|
|
v-model="started_at"
|
|
|
|
@input="change"
|
|
|
|
type="date"
|
|
|
|
align="right"
|
|
|
|
:format="formatDate"
|
|
|
|
value-format="yyyy-MM-dd"
|
|
|
|
:picker-options="{
|
|
|
|
disabledDate(time) {
|
|
|
|
return time.getTime() < Date.now();
|
|
|
|
},
|
|
|
|
shortcuts: [
|
|
|
|
{
|
|
|
|
text: dateRangeText['today'],
|
|
|
|
onClick(picker) {
|
|
|
|
picker.$emit('pick', new Date());
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: dateRangeText['yesterday'],
|
|
|
|
onClick(picker) {
|
|
|
|
const date = new Date();
|
|
|
|
date.setTime(date.getTime() - 3600 * 1000 * 24);
|
|
|
|
|
|
|
|
picker.$emit('pick', date);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: dateRangeText['week_ago'],
|
|
|
|
onClick(picker) {
|
|
|
|
const date = new Date();
|
|
|
|
date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
|
|
|
|
|
|
|
|
picker.$emit('pick', date);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}">
|
|
|
|
</el-date-picker>
|
|
|
|
|
|
|
|
<div class="w-20 px-2 text-sm text-center">
|
|
|
|
{{ middleText }}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<el-select class="w-20" v-model="limit" @input="change">
|
|
|
|
<el-option
|
|
|
|
v-for="(label, value) in limits"
|
|
|
|
:key="value"
|
2019-11-16 10:21:14 +03:00
|
|
|
:label="label"
|
|
|
|
:value="value">
|
|
|
|
</el-option>
|
|
|
|
</el-select>
|
2022-06-01 10:15:55 +03:00
|
|
|
|
2022-06-03 20:02:54 +03:00
|
|
|
<input type="text" class="w-20 form-element ml-2" v-model="limitCount" v-if="limit == 'after'" @input="change">
|
2022-06-01 10:15:55 +03:00
|
|
|
|
|
|
|
<div class="pl-2 text-sm" v-if="limit == 'after'">
|
|
|
|
{{ endText }}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<el-date-picker
|
2022-06-03 20:02:54 +03:00
|
|
|
class="w-36 ml-2 recurring-invoice-data"
|
2022-06-01 10:15:55 +03:00
|
|
|
v-model="limitDate"
|
|
|
|
type="date"
|
|
|
|
align="right"
|
|
|
|
:format="formatDate"
|
|
|
|
value-format="yyyy-MM-dd"
|
|
|
|
v-if="limit == 'on'"
|
|
|
|
@input="change"
|
|
|
|
>
|
|
|
|
</el-date-picker>
|
|
|
|
</div>
|
2019-11-16 10:21:14 +03:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-06-01 10:15:55 +03:00
|
|
|
import { Select, Option, DatePicker } from 'element-ui';
|
2019-11-16 10:21:14 +03:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'akaunting-recurring',
|
|
|
|
|
|
|
|
components: {
|
|
|
|
[Select.name]: Select,
|
|
|
|
[Option.name]: Option,
|
2022-06-01 10:15:55 +03:00
|
|
|
[DatePicker.name]: DatePicker,
|
2019-11-16 10:21:14 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
2022-06-01 10:15:55 +03:00
|
|
|
startText: {
|
2019-11-16 10:21:14 +03:00
|
|
|
type: String,
|
2022-06-01 10:15:55 +03:00
|
|
|
default: 'Create first invoice on',
|
|
|
|
description: "Default reccuring text"
|
2019-11-16 10:21:14 +03:00
|
|
|
},
|
2022-06-01 10:15:55 +03:00
|
|
|
dateRangeText: {
|
|
|
|
type: Object,
|
|
|
|
default: {
|
|
|
|
today : 'Today',
|
|
|
|
yesterday : 'Yesterday',
|
|
|
|
week_ago : 'A week ago',
|
|
|
|
},
|
|
|
|
description: "Default reccuring text"
|
2021-11-11 12:02:47 +03:00
|
|
|
},
|
2022-06-01 10:15:55 +03:00
|
|
|
middleText: {
|
2021-11-11 12:02:47 +03:00
|
|
|
type: String,
|
2022-06-01 10:15:55 +03:00
|
|
|
default: 'and end',
|
|
|
|
description: "Default reccuring text"
|
2021-11-11 12:02:47 +03:00
|
|
|
},
|
2022-06-01 10:15:55 +03:00
|
|
|
endText: {
|
2021-11-11 12:02:47 +03:00
|
|
|
type: String,
|
2022-06-01 10:15:55 +03:00
|
|
|
default: 'invoices',
|
|
|
|
description: "Default reccuring text"
|
2021-11-11 12:02:47 +03:00
|
|
|
},
|
2022-06-01 10:15:55 +03:00
|
|
|
frequencies: null,
|
|
|
|
frequencyText: {
|
2021-11-11 12:02:47 +03:00
|
|
|
type: String,
|
2022-06-01 10:15:55 +03:00
|
|
|
default: 'Repeat this invoice',
|
|
|
|
description: "Default reccuring text"
|
2021-11-11 12:02:47 +03:00
|
|
|
},
|
2022-06-01 10:15:55 +03:00
|
|
|
frequencyEveryText: {
|
2019-11-16 10:21:14 +03:00
|
|
|
type: String,
|
2022-06-01 10:15:55 +03:00
|
|
|
default: 'every',
|
|
|
|
description: "Default reccuring text"
|
2019-11-16 10:21:14 +03:00
|
|
|
},
|
2022-06-01 10:15:55 +03:00
|
|
|
frequencyValue: {
|
|
|
|
type: String,
|
|
|
|
default: 'monthly',
|
|
|
|
description: "Default reccuring type"
|
2021-01-01 15:45:43 +03:00
|
|
|
},
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
customFrequencies: null,
|
|
|
|
customFrequencyValue: {
|
|
|
|
type: String,
|
|
|
|
default: 'monthly',
|
|
|
|
description: "Default reccuring type"
|
|
|
|
},
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
startedValue: {
|
|
|
|
type: String,
|
|
|
|
default: 'never',
|
|
|
|
description: "Default reccuring limit"
|
2020-04-22 14:50:30 +03:00
|
|
|
},
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
limits: null,
|
|
|
|
|
|
|
|
limitValue: {
|
|
|
|
type: String,
|
|
|
|
default: 'never',
|
|
|
|
description: "Default reccuring limit"
|
|
|
|
},
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
limitCountValue: {
|
2022-06-03 20:02:54 +03:00
|
|
|
type: [Number, String],
|
|
|
|
default: 0,
|
2022-06-01 10:15:55 +03:00
|
|
|
description: "Default reccuring limit"
|
2020-04-22 14:50:30 +03:00
|
|
|
},
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
limitDateValue: {
|
2019-11-16 10:21:14 +03:00
|
|
|
type: String,
|
2022-06-01 10:15:55 +03:00
|
|
|
default: '',
|
|
|
|
description: "Default reccuring limit"
|
2021-11-11 12:02:47 +03:00
|
|
|
},
|
2022-06-01 10:15:55 +03:00
|
|
|
|
|
|
|
dateFormat: {
|
2021-11-11 12:02:47 +03:00
|
|
|
type: String,
|
2022-06-01 10:15:55 +03:00
|
|
|
default: 'dd MM yyyy',
|
|
|
|
description: "Default date format"
|
2021-11-11 12:02:47 +03:00
|
|
|
},
|
2019-11-16 10:21:14 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2022-06-01 10:15:55 +03:00
|
|
|
frequency: '',
|
|
|
|
interval: '',
|
|
|
|
customFrequency: '',
|
|
|
|
started_at: '',
|
|
|
|
limit: '',
|
2022-06-03 20:02:54 +03:00
|
|
|
limitCount: 0,
|
2022-06-01 10:15:55 +03:00
|
|
|
limitDate: '',
|
|
|
|
formatDate: 'dd MM YYYY',
|
2019-11-16 10:21:14 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
created() {
|
|
|
|
this.formatDate = this.convertToDarteFormat(this.dateFormat);
|
2020-04-22 14:50:30 +03:00
|
|
|
},
|
|
|
|
|
2019-11-16 10:21:14 +03:00
|
|
|
mounted() {
|
2022-06-01 10:15:55 +03:00
|
|
|
this.frequency = this.frequencyValue;
|
|
|
|
this.customFrequency = this.customFrequencyValue;
|
|
|
|
this.started_at = this.startedValue;
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
this.limit = this.limitValue;
|
|
|
|
this.limitCount = this.limitCountValue;
|
|
|
|
this.limitDate = this.limitDateValue;
|
2021-01-19 23:24:06 +03:00
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
if (this.limit == 'count') {
|
2022-06-03 20:02:54 +03:00
|
|
|
if (this.limitCount > 0) {
|
2022-06-01 10:15:55 +03:00
|
|
|
this.limit = 'after';
|
2022-06-03 20:02:54 +03:00
|
|
|
} else {
|
|
|
|
this.limit = 'never';
|
2022-06-01 10:15:55 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.limit = 'on';
|
|
|
|
}
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
setTimeout(function() {
|
|
|
|
this.change();
|
|
|
|
}.bind(this), 800);
|
2019-11-16 10:21:14 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
change() {
|
2022-06-01 10:15:55 +03:00
|
|
|
this.$emit('change', this.frequency);
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
this.$emit('frequency', this.frequency);
|
|
|
|
this.$emit('interval', this.interval);
|
|
|
|
this.$emit('custom_frequency', this.customFrequency);
|
|
|
|
this.$emit('started', this.started_at);
|
2019-11-16 10:21:14 +03:00
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
switch (this.limit) {
|
|
|
|
case 'after':
|
|
|
|
this.$emit('limit', 'count');
|
|
|
|
this.$emit('limit_count', this.limitCount);
|
2022-06-03 20:02:54 +03:00
|
|
|
this.$emit('limit_date', null);
|
2022-06-01 10:15:55 +03:00
|
|
|
break;
|
|
|
|
case 'on':
|
|
|
|
this.$emit('limit', 'date');
|
|
|
|
this.$emit('limit_date', this.limitDate);
|
2022-06-03 20:02:54 +03:00
|
|
|
this.$emit('limit_count', 0);
|
2022-06-01 10:15:55 +03:00
|
|
|
break;
|
|
|
|
case 'never':
|
|
|
|
default:
|
|
|
|
this.$emit('limit', 'count');
|
|
|
|
this.$emit('limit_count', 0);
|
|
|
|
break;
|
|
|
|
}
|
2019-11-16 10:21:14 +03:00
|
|
|
},
|
|
|
|
|
2022-06-01 10:15:55 +03:00
|
|
|
convertToDarteFormat(format) {
|
|
|
|
return format.replace('d', 'dd')
|
|
|
|
.replace('M', 'MMM')
|
|
|
|
.replace('m', 'MM')
|
|
|
|
.replace('F', 'MMMM')
|
|
|
|
.replace('y', 'yyyy')
|
|
|
|
.replace('Y', 'yyyy');
|
|
|
|
},
|
2019-11-16 10:21:14 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
2022-06-01 10:15:55 +03:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.el-input__inner {
|
|
|
|
height: 42px;
|
|
|
|
}
|
2022-06-03 20:02:54 +03:00
|
|
|
</style>
|