deploy v-1

This commit is contained in:
HAM!DREZA
2024-07-03 21:25:34 +03:30
parent 2b399d3bb1
commit ad7a4b839d
49 changed files with 1636 additions and 953 deletions
+62 -35
View File
@@ -8,11 +8,11 @@
<label>{{ $t("تاریخ شروع") }}</label>
</FloatLabel>
<date-picker
type="datetime"
format="YYYY-MM-DD HH:mm"
display-format="jYYYY-jMM-jDD HH:mm"
:timezone="true"
color="dimgray"
type="datetime"
format="YYYY-MM-DD HH:mm"
display-format="jYYYY-jMM-jDD HH:mm"
:timezone="true"
color="dimgray"
v-model="coupon.startDate"
simple
custom-input=".custom-input"
@@ -25,15 +25,15 @@
<label>{{ $t("تاریخ پایان") }}</label>
</FloatLabel>
<date-picker
type="datetime"
format="YYYY-MM-DD HH:mm"
display-format="jYYYY-jMM-jDD HH:mm"
:timezone="true"
color="dimgray"
v-model="coupon.endDate"
simple
custom-input=".custom-input2"
></date-picker>
type="datetime"
format="YYYY-MM-DD HH:mm"
display-format="jYYYY-jMM-jDD HH:mm"
:timezone="true"
color="dimgray"
v-model="coupon.endDate"
simple
custom-input=".custom-input2"
></date-picker>
</div>
<div class="flex flex-col gap-1">
<FloatLabel>
@@ -45,8 +45,8 @@
<div class="flex flex-col gap-1">
<FloatLabel>
<Dropdown
v-model="type"
@change="setType"
v-model="type"
@change="setType"
:options="['مبلغ', 'درصد']"
:optionLabel="levels"
:optionValue="levels"
@@ -55,16 +55,16 @@
<label>{{ $t("نوع تخفیف") }}</label>
</FloatLabel>
</div>
<div v-if="noe === 'مبلغ'" class="flex flex-col gap-1">
<div v-if="type === 'مبلغ'" class="flex flex-col gap-1">
<FloatLabel>
<InputText class="w-full" v-model="coupon.price"/>
<InputText class="w-full" v-model="coupon.price" />
<label>{{ $t("مبلغ تخفیف") }}</label>
</FloatLabel>
</div>
<div v-if="noe === 'درصد'" class="flex flex-col gap-1">
<div v-if="type === 'درصد'" class="flex flex-col gap-1">
<FloatLabel>
<InputText class="w-full" v-model="coupon.percent"/>
<InputText class="w-full" v-model="coupon.percent" />
<label>{{ $t("درصد تخفیف") }}</label>
</FloatLabel>
</div>
@@ -92,23 +92,29 @@
<script setup>
import { useProductsStore } from "@/stores/products";
import { useDiscountStore } from "@/stores/discounts"
import { ref, watchEffect, reactive } from "vue";
import moment from 'moment-jalaali'
const date= ref(null)
const date2= ref(null)
const noe = ref('مبلغ')
import { useDiscountStore } from "@/stores/discounts";
import { ref, watchEffect, reactive, inject } from "vue";
import moment from "moment-jalaali";
import { useRouter } from "vue-router";
const { dialog, confirm, toast, t } = inject("service");
const date = ref(null);
const date2 = ref(null);
const noe = ref("مبلغ");
const store = useProductsStore();
const discount = useDiscountStore();
const data = ref(null);
const type = ref(null);
const router = useRouter()
const setType = (val) => {
if (val.value === 'درصد') {
coupon.discountType = 'percent'
}else{
coupon.discountType = 'price'
if (val.value === "درصد") {
coupon.discountType = "percent";
} else {
coupon.discountType = "price";
}
}
};
//const { dialog, confirm, toast, t } = inject("service");
const coupon = reactive({
startDate: "",
endDate: "",
@@ -116,11 +122,32 @@ const coupon = reactive({
discountType: type.value,
price: "",
percent: null,
allUsers: true
allUsers: true,
});
const create = async(coupon) => {
const datas = await discount.add(coupon)
}
const saving = ref(false);
const create = async (coupon) => {
saving.value = true
const datas = await discount.add(coupon);
saving.value = false;
if (datas === true) {
toast.add({
life: 2000,
severity: "success",
summary: t("successful"),
detail: t("کد تخفیف ایجاد شد"),
});
router.push('/Coupons')
} else{
return toast.add({
life: 2000,
severity: "error",
summary: t("error"),
detail: "خطا رخ داد، مجدد تلاش کنید",
});
}
};
</script>
<style scoped>