pull/60/head
saeid 4 years ago
parent e84f9ad207
commit 5aaf2caa86

@ -30,10 +30,10 @@
</div> </div>
</template> </template>
<script> <script>
import VuePersianDatetimePicker from 'vue-persian-datetime-picker' import VuePersianDatetimePicker from 'vue-persian-datetime-picker'
import moment from 'jalali-moment'; import {convertToJalali, convertNowToJalali} from '@Global/utils/date/jalali-date'
export default { export default {
components: { components: {
datePicker: VuePersianDatetimePicker datePicker: VuePersianDatetimePicker
}, },
@ -75,15 +75,14 @@ export default {
dateShow: { dateShow: {
get() { get() {
if (this.value) { if (this.value) {
return moment(new Date(this.value)).format(this.defaultDisplayFormat); return convertToJalali(this.value, this.defaultDisplayFormat);
} else if (!this.disabled) { } else if (!this.disabled) {
if (this.defaultDate === 'now') { if (this.defaultDate === 'now') {
this.$emit('input', moment(new Date()).format(this.defaultFormat)); this.$emit('input', convertNowToJalali(null, this.defaultFormat));
return moment(new Date()).format(this.defaultDisplayFormat); return convertNowToJalali(null, this.defaultDisplayFormat);
} else { } else {
return ''; return '';
} }
} }
}, },
set(value) { set(value) {
@ -100,7 +99,8 @@ export default {
} }
} }
return this.displayFormat return this.displayFormat
}, }
,
defaultInputFormat() { defaultInputFormat() {
if (!this.inputFormat) { if (!this.inputFormat) {
if (this.type === 'datetime') { if (this.type === 'datetime') {
@ -112,7 +112,8 @@ export default {
} }
} }
return this.inputFormat return this.inputFormat
}, }
,
defaultFormat() { defaultFormat() {
if (!this.format) { if (!this.format) {
if (this.type === 'datetime') { if (this.type === 'datetime') {
@ -124,29 +125,34 @@ export default {
} }
} }
return this.format return this.format
}, }
,
minimum() { minimum() {
if (this.min === 'now') { if (this.min === 'now') {
return moment(new Date()).format(this.defaultInputFormat); return convertNowToJalali(null, this.defaultInputFormat);
} else { } else {
return this.min; return this.min;
} }
}, }
,
maximum() { maximum() {
if (this.max === 'now') { if (this.max === 'now') {
return moment(new Date()).format(this.defaultInputFormat); return convertNowToJalali(null, this.defaultInputFormat);
} else { } else {
return this.max; return this.max;
} }
}, }
}, ,
}
,
methods: { methods: {
changeDatePicker(event) { changeDatePicker(event) {
if (!this.disabled) { if (!this.disabled) {
this.$emit('input', event.format(this.defaultFormat)) this.$emit('input', event.format(this.defaultFormat));
} }
} }
}, }
,
watch: { watch: {
disabled(value) { disabled(value) {
if (value) { if (value) {
@ -154,5 +160,5 @@ export default {
} }
} }
} }
} }
</script> </script>

@ -1,11 +1,11 @@
import chart from "../chart"; import chart from "../chart";
import {seperator, price} from '@Global/utils/common/format'
export default class extends chart { export default class extends chart {
constructor(options) { constructor(options) {
super(options); super(options);
this.type = options.type ? options.type : 'daily'; this.type = options.type ? options.type : 'daily';
this.formatCount = 'number';
this.options = { this.options = {
fill: { fill: {
colors: ["#e6e6e6"] colors: ["#e6e6e6"]
@ -15,16 +15,35 @@ export default class extends chart {
fontFamily: '"iranyekan-regular-en-num", "Montserrat-Regular"' fontFamily: '"iranyekan-regular-en-num", "Montserrat-Regular"'
}, },
xaxis: { xaxis: {
categories: [] categories: [],
},
yaxis: {
labels: {
formatter: (val) => {
if (this.formatCount === 'number') {
return seperator(val)
} else if(this.formatCount === 'price') {
return price(val)
}
}
},
}, },
dataLabels: { dataLabels: {
style: { style: {
colors: ["#000", "#000", "#000"] colors: ["#000", "#000", "#000"]
},
enabled: true,
formatter: (val, opt) => {
if (this.formatCount === 'number') {
return seperator(val)
} else if(this.formatCount === 'price') {
return price(val)
} }
}, },
},
series: [ series: [
{ {
name: "bar chart", name: this.formatCount === 'number' ? "تعداد" : "قیمت",
data: [] data: []
} }
] ]
@ -41,13 +60,22 @@ export default class extends chart {
setOptions() { setOptions() {
switch (this.type) { switch (this.type) {
case 'weekly': case 'weekly':
this.formatCount = 'number';
return this.setWeekly();
case 'cost-weekly': case 'cost-weekly':
this.formatCount = 'price';
return this.setWeekly(); return this.setWeekly();
case 'monthly': case 'monthly':
this.formatCount = 'number';
return this.setMonthly();
case 'cost-monthly': case 'cost-monthly':
this.formatCount = 'price';
return this.setMonthly(); return this.setMonthly();
case 'daily': case 'daily':
this.formatCount = 'number';
return this.setDaily();
case 'cost-daily': case 'cost-daily':
this.formatCount = 'price';
return this.setDaily(); return this.setDaily();
} }
} }

@ -41,7 +41,7 @@ export default class extends chart {
this.options.fill.label = this.responseChart.map(x => x.category.name); this.options.fill.label = this.responseChart.map(x => x.category.name);
this.options['colors'] = this.responseChart.map( x =>{ this.options['colors'] = this.responseChart.map( x =>{
let colorText = x.category.color ? x.category.color : color[parseInt((Math.random() * 100) % 14)].color; let colorText = x.category.color ? x.category.color : color[parseInt((Math.random() * 100) % 14)].color;
return color.find(x => x.color == colorText).hex; return color.find(x => x.color === colorText).hex;
} ); } );
} }
} }

@ -40,3 +40,4 @@ Array.prototype.matchItems = function (array) {
} }
// Hide method from for-in loops // Hide method from for-in loops
Object.defineProperty(Array.prototype, "matchItems", {enumerable: false}); Object.defineProperty(Array.prototype, "matchItems", {enumerable: false});

@ -0,0 +1,6 @@
export const price = (number, currency = 'تومان') => {
return Intl.NumberFormat().format(number) + ' ' + currency;
}
export const seperator = (number) => {
return new Intl.NumberFormat().format(number);
}
Loading…
Cancel
Save