2026-01-18 13:01:46 +03:30
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<div class="bg-white py-3 px-3 text-primary font-bold drop-shadow wrap-fix flex z-10">
|
|
|
|
|
<div @click="router.back()">
|
|
|
|
|
<BasicIcon icon="vuesax-linear:arrow-right-1" />
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mr-2">هشدارهای فعلی</div>
|
|
|
|
|
</div>
|
|
|
|
|
<!-- <a-spin :spinning="loading">-->
|
|
|
|
|
<div ref="el" :class="loading? 'h-screen': ''" class="px-3 pt-16 pb-2 overflow-y-scroll"
|
|
|
|
|
style="max-height: calc(100vh - 50px)">
|
|
|
|
|
|
2026-05-23 16:34:15 +03:30
|
|
|
<list-anim v-if="!loading" class="pb-[calc(var(--app-bottom-chrome-height)+var(--app-add-card-height)+1rem)]">
|
2026-01-18 13:01:46 +03:30
|
|
|
<Item v-for="item in items" :key="item.id" :item="item" @edit="openEdit" @refresh="initItems" />
|
|
|
|
|
<!-- <TransactionSkeleton v-if="loadingMore" class="mt-1 mb-8" />-->
|
|
|
|
|
</list-anim>
|
|
|
|
|
<div v-if="loading">
|
|
|
|
|
<TransactionSkeleton v-for="i in 13" :key="i" class="mt-1" />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
<!-- </a-spin>-->
|
|
|
|
|
<BasicActionSheet v-model:show="addTriggerVisible" teleport="body">
|
2026-05-23 10:07:37 +03:30
|
|
|
<a-form ref="formRef" :model="form" class="!mt-5 " name="basic"
|
2026-01-18 13:01:46 +03:30
|
|
|
@finish="ok()">
|
|
|
|
|
<div class="flex flex-col gap-4 pb-12 w-full">
|
|
|
|
|
<div class="font-bold text-lg">هشدار قیمت</div>
|
|
|
|
|
<a-form-item :rules="[required()]" class="home_appear_fade_in_down" label="جهت قیمت" name="price_condition">
|
|
|
|
|
<BasicSelect :items="typeItems" v-model:value="form.price_condition" :show-search="false" value-name="value"
|
|
|
|
|
key-name="key"
|
|
|
|
|
placeholder="انتخاب نوع جهت قیمت"
|
|
|
|
|
size="large"></BasicSelect>
|
|
|
|
|
</a-form-item>
|
|
|
|
|
<a-form-item :rules="[required()]" class="home_appear_fade_in_down" label="قیمت" name="target_price">
|
|
|
|
|
<BasicInput v-model:value="form.target_price" place-holder="وارد کردن قیمت" type="price" size="large"
|
|
|
|
|
addon-before="ریال" />
|
|
|
|
|
</a-form-item>
|
|
|
|
|
<a-form-item :rules="[required()]" class="home_appear_fade_in_down" name="action"
|
|
|
|
|
label="نوع هشدار را انتخاب کنید">
|
|
|
|
|
<a-radio-group v-model:value="form.action">
|
|
|
|
|
<a-radio :style="radioStyle" value="sms">ارسال پیامک</a-radio>
|
|
|
|
|
<a-radio :style="radioStyle" value="email">ارسال ایمیل</a-radio>
|
|
|
|
|
</a-radio-group>
|
|
|
|
|
</a-form-item>
|
|
|
|
|
<a-form-item>
|
|
|
|
|
<a-spin :spinning="loading">
|
2026-05-23 10:07:37 +03:30
|
|
|
<BasicButton class="w-full mb-2rem" type="primary" html-type="submit">
|
2026-01-18 13:01:46 +03:30
|
|
|
{{ editId ? 'ویرایش هشدار' : 'ثبت هشدار' }}
|
|
|
|
|
</BasicButton>
|
|
|
|
|
</a-spin>
|
|
|
|
|
</a-form-item>
|
|
|
|
|
</div>
|
|
|
|
|
</a-form>
|
|
|
|
|
</BasicActionSheet>
|
|
|
|
|
<!-- <div class="bg-primary w-3rem h-3rem flex items-center justify-center rounded-lg fixed bottom-12vh left-8vw"
|
|
|
|
|
@click="openAdd()">
|
|
|
|
|
<BasicIcon icon="vuesax-linear:add" color="white" />
|
|
|
|
|
</div>-->
|
2026-05-23 16:34:15 +03:30
|
|
|
<Teleport to="body">
|
2026-01-18 13:01:46 +03:30
|
|
|
<div
|
2026-05-23 16:34:15 +03:30
|
|
|
v-if="!addTriggerVisible"
|
|
|
|
|
class="add-trigger app-dock-add-bar"
|
|
|
|
|
@click="openAdd()"
|
|
|
|
|
>
|
2026-01-18 13:01:46 +03:30
|
|
|
<div>افزودن هشدار جدید</div>
|
2026-05-23 16:34:15 +03:30
|
|
|
<BasicIcon icon="vuesax-linear:add" />
|
2026-01-18 13:01:46 +03:30
|
|
|
</div>
|
2026-05-23 16:34:15 +03:30
|
|
|
</Teleport>
|
2026-01-18 13:01:46 +03:30
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { createPriceTrigger, getPriceTriggers, updatePriceTrigger } from '@/api/triggerPrice'
|
|
|
|
|
|
|
|
|
|
const radioStyle = reactive({
|
|
|
|
|
display: '',
|
|
|
|
|
height: '30px',
|
|
|
|
|
lineHeight: '30px'
|
|
|
|
|
})
|
|
|
|
|
import type { SelectItem } from '@/models/SelectItem'
|
|
|
|
|
|
|
|
|
|
// import Item from "./components/Item.vue";
|
|
|
|
|
/*import {lengthValidation, required} from "@/utils/inputRules";
|
|
|
|
|
import {loading} from "@/utils";
|
|
|
|
|
import BasicButton from "@/components/BasicPacks/BasicButton.vue";
|
|
|
|
|
import BasicActionSheet from "@/components/BasicPacks/BasicActionSheet.vue";
|
|
|
|
|
import BasicInput from "@/components/BasicPacks/BasicInput.vue";*/
|
|
|
|
|
import { onMounted, reactive, ref } from 'vue'
|
|
|
|
|
import type { TableEngineInput, TableOutput } from '@/models/table'
|
|
|
|
|
import { loading, loadingMore } from '@/utils'
|
|
|
|
|
// import {getOrders} from "@/api/order";
|
|
|
|
|
import { getTransactionTable } from '@/api/transaction'
|
|
|
|
|
import type { Transaction } from '@/models/transaction'
|
|
|
|
|
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
|
|
|
|
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
|
|
|
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
|
|
|
|
import BaseDatePicker from '@/components/BasicPacks/BaseDatePicker/src/BaseDatePicker.vue'
|
|
|
|
|
import { useInfiniteScroll, useScroll } from '@vueuse/core'
|
|
|
|
|
import ListAnim from '@/components/ListAnim.vue'
|
|
|
|
|
import TransactionSkeleton from '@/components/TransactionSkeleton.vue'
|
|
|
|
|
import { DotLottieVue } from '@lottiefiles/dotlottie-vue'
|
|
|
|
|
import { mobileValidation, required } from '@/utils/inputRules'
|
|
|
|
|
import BasicInput from '@/components/BasicPacks/BasicInput.vue'
|
|
|
|
|
import type { User } from '@/models/login'
|
|
|
|
|
import { type FormInstance, message } from 'ant-design-vue'
|
|
|
|
|
import type { PriceTrigger } from '@/models/PriceTrigger'
|
|
|
|
|
import BasicSelect from '@/components/BasicPacks/BasicSelect.vue'
|
|
|
|
|
import Item from './components/Item.vue'
|
|
|
|
|
import { cloneDeep } from 'lodash'
|
|
|
|
|
import router from '@/router'
|
|
|
|
|
|
|
|
|
|
const items = ref<PriceTrigger[]>([])
|
|
|
|
|
const addTriggerVisible = ref<boolean>(false)
|
|
|
|
|
const editId = ref<number | undefined>(undefined)
|
|
|
|
|
const el = ref()
|
|
|
|
|
|
|
|
|
|
const form = ref<PriceTrigger>({
|
|
|
|
|
price_condition: '',
|
|
|
|
|
is_active: true,
|
|
|
|
|
action: '',
|
|
|
|
|
target_price: ''
|
|
|
|
|
})
|
|
|
|
|
const formRef = ref<FormInstance>()
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
initItems()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function resetFields() {
|
|
|
|
|
form.value = {
|
|
|
|
|
price_condition: '',
|
|
|
|
|
is_active: true,
|
|
|
|
|
action: '',
|
|
|
|
|
target_price: ''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function openAdd() {
|
|
|
|
|
resetFields()
|
|
|
|
|
editId.value = undefined
|
|
|
|
|
addTriggerVisible.value = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function initItems() {
|
|
|
|
|
try {
|
|
|
|
|
items.value = []
|
|
|
|
|
items.value = await getPriceTriggers()
|
|
|
|
|
// console.log(items.value)
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log(e)
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
loadingMore.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function openEdit(val: PriceTrigger) {
|
|
|
|
|
form.value = cloneDeep(val)
|
|
|
|
|
editId.value = form.value.id
|
|
|
|
|
addTriggerVisible.value = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function ok() {
|
|
|
|
|
formRef.value?.validateFields().then(async () => {
|
|
|
|
|
try {
|
|
|
|
|
loading.value = true
|
|
|
|
|
editId.value ? await updatePriceTrigger(editId.value, form.value) : await createPriceTrigger(form.value)
|
|
|
|
|
message.success('هشدار با موفقیت ایجاد شد')
|
|
|
|
|
await initItems()
|
|
|
|
|
addTriggerVisible.value = false
|
|
|
|
|
//
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log(e)
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const typeItems: SelectItem[] = [
|
|
|
|
|
{
|
|
|
|
|
value: 'بزرگتر',
|
|
|
|
|
key: '>'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 'کوچکتر',
|
|
|
|
|
key: '<'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 'مساوی',
|
|
|
|
|
key: '=='
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
|
|
</style>
|