added function for trigger in admin
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<template>
|
||||
<a-form :model="form" ref="formRef" layout="vertical" autocomplete="off">
|
||||
<a-form-item label="مشتری" name="customer_id" :rules="inputRules()">
|
||||
<BasicSelect
|
||||
v-model:value="form.customer_id"
|
||||
:items="customerItems"
|
||||
key-name="id"
|
||||
value-name="label"
|
||||
placeholder="انتخاب مشتری"
|
||||
:disabled="Boolean(editId)"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="شرط قیمت" name="price_condition" :rules="inputRules()">
|
||||
<BasicSelect
|
||||
v-model:value="form.price_condition"
|
||||
:items="conditionItems"
|
||||
key-name="key"
|
||||
value-name="value"
|
||||
placeholder="بزرگتر یا کوچکتر"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="قیمت هدف" name="target_price" :rules="inputRulesNumber()">
|
||||
<BasicInput v-model:value="form.target_price" type="price" addon-before="ریال" placeholder="مثلاً ۱۷۸۵۰۰۰۰۰" />
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="روش اطلاعرسانی" name="action" :rules="inputRules()">
|
||||
<a-radio-group v-model:value="form.action" button-style="solid">
|
||||
<a-radio-button value="sms">پیامک</a-radio-button>
|
||||
<a-radio-button value="email">ایمیل</a-radio-button>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="وضعیت" name="is_active">
|
||||
<a-switch v-model:checked="form.is_active" checked-children="فعال" un-checked-children="غیرفعال" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import type { FormInstance } from 'ant-design-vue'
|
||||
import type { Customer } from '@/model/customer'
|
||||
import type { PriceTriggers } from '@/model/priceTriggers'
|
||||
import { inputRules, inputRulesNumber } from '@/utils/inputRules'
|
||||
|
||||
defineProps<{
|
||||
form: Partial<PriceTriggers>
|
||||
customerItems: Array<{ id: number; label: string }>
|
||||
editId?: number
|
||||
}>()
|
||||
|
||||
const conditionItems = [
|
||||
{ value: 'بزرگتر از', key: '>' },
|
||||
{ value: 'کوچکتر از', key: '<' },
|
||||
]
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
defineExpose({
|
||||
validateFields: () => formRef.value?.validateFields(),
|
||||
resetFields: () => formRef.value?.resetFields(),
|
||||
})
|
||||
</script>
|
||||
@@ -1,27 +1,52 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicShowContext title="هشدار قیمت">
|
||||
<AdminFieldHelp :text="priceTriggersPageIntro" root-class="mb-3 px-1" />
|
||||
<BaseTable v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<!-- <template #extraHeader>
|
||||
<BaseButton type="primary" size="small" class="flex" @click="emits('add')">
|
||||
<div>افزودن مدیر</div>
|
||||
<BaseIcon icon="vuesax-linear:user-add" Size="16px" />
|
||||
<template #extra>
|
||||
<div class="flex items-center gap-2">
|
||||
<AdminFieldHelp :text="priceTriggersPageIntro" />
|
||||
<BaseButton type="primary" size="small" @click="emits('add')">
|
||||
<span>افزودن هشدار</span>
|
||||
<BaseIcon icon="vuesax-linear:add" size="16" />
|
||||
</BaseButton>
|
||||
</template>-->
|
||||
<template #action="{ column, record }">
|
||||
<div class="gap-2 flex justify-center">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('info', record)">
|
||||
<template #title>
|
||||
<span>مشخصات</span>
|
||||
</template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<BaseTable v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #extraHeader>
|
||||
<BaseButton type="primary" size="small" class="hidden md:inline-flex" @click="emits('add')">
|
||||
<span>افزودن هشدار</span>
|
||||
<BaseIcon icon="vuesax-linear:add" size="16" />
|
||||
</BaseButton>
|
||||
</template>
|
||||
|
||||
<template #action="{ record }">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom">
|
||||
<template #title>ویرایش</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:edit"
|
||||
color="#4572E9"
|
||||
class="cursor-pointer"
|
||||
@click="emits('edit', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('edit', record)">
|
||||
<template #title>
|
||||
<span>ویرایش</span>
|
||||
</template>
|
||||
<Icon icon="vuesax-linear:edit" color="#4572E9" />
|
||||
<a-tooltip placement="bottom">
|
||||
<template #title>{{ record.is_active ? 'غیرفعال کردن' : 'فعال کردن' }}</template>
|
||||
<Icon
|
||||
:icon="record.is_active ? 'vuesax-linear:eye-slash' : 'vuesax-linear:eye'"
|
||||
:color="record.is_active ? '#C53030' : '#25855A'"
|
||||
class="cursor-pointer"
|
||||
@click="emits('toggle', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom">
|
||||
<template #title>حذف</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:trash"
|
||||
color="#C53030"
|
||||
class="cursor-pointer"
|
||||
@click="emits('delete', record.id)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
@@ -33,67 +58,29 @@
|
||||
<script lang="tsx" setup>
|
||||
import type { TableInput } from '@core/type/baseTable'
|
||||
import useBaseTable from '@core/components/BaseTableOld/hooks/useBaseTable'
|
||||
import { toJalali, toJalaliNoTime } from '@core/utils/useDataTime'
|
||||
import { message, Tag } from 'ant-design-vue'
|
||||
import CustomTag from '@/components/CustomTag.vue'
|
||||
import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import { changeUserActivation, getUserTable } from '@/api/user'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { cols } from '../hooks/priceTriggersColumns'
|
||||
import { changeCustomerActivation } from '@/api/customer'
|
||||
import { getPriceTriggersTable } from '@/api/priceTriggers'
|
||||
import AdminFieldHelp from '@/components/AdminFieldHelp.vue'
|
||||
import { priceTriggersPageIntro } from '@/utils/adminHelpCopy'
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
|
||||
//emits
|
||||
const emits = defineEmits(['delete', 'edit', 'add', 'info'])
|
||||
const emits = defineEmits<{
|
||||
add: []
|
||||
edit: [record: Record<string, unknown>]
|
||||
toggle: [record: Record<string, unknown>]
|
||||
delete: [id: number]
|
||||
}>()
|
||||
|
||||
//define table
|
||||
const table = ref(null)
|
||||
|
||||
//permission
|
||||
function checkPermission(temp: string) {
|
||||
const store = useUserStore()
|
||||
return store.canAccess(temp)
|
||||
}
|
||||
|
||||
const loading = ref<boolean>(false)
|
||||
|
||||
async function changeUserActivationFunction(id: number) {
|
||||
try {
|
||||
loading.value = true
|
||||
await changeUserActivation(id)
|
||||
reload()
|
||||
message.success('تغییر وضعیت با موفقیت انجام شد')
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const tblProps = ref<any>({
|
||||
const tblProps = {
|
||||
columns: cols,
|
||||
api: (params: TableInput) => {
|
||||
return getPriceTriggersTable(params)
|
||||
}
|
||||
//bordered: true
|
||||
})
|
||||
api: (params: TableInput) => getPriceTriggersTable(params),
|
||||
}
|
||||
|
||||
const fetch = () => {
|
||||
// console.log('sss')
|
||||
function fetch() {
|
||||
reload()
|
||||
}
|
||||
// const spinTable = (val: boolean) => {
|
||||
// // console.log('sss')
|
||||
// table?.value?.loading.value = val
|
||||
// }
|
||||
defineExpose({
|
||||
fetch
|
||||
// spinTable
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
defineExpose({ fetch })
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user