change configuration & add talabBedehi
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
export interface TagItem {
|
||||
id: number | undefined
|
||||
name: string | undefined
|
||||
title_fa?: string
|
||||
key?: string
|
||||
value?: string
|
||||
type?: string
|
||||
description?: string
|
||||
is_active: boolean
|
||||
}
|
||||
|
||||
@@ -19,8 +19,11 @@ export interface SupportLink {
|
||||
export interface itemConfig {
|
||||
id: number | string
|
||||
name: string
|
||||
title_fa?: string
|
||||
value: string
|
||||
key: string
|
||||
type: string
|
||||
list: []
|
||||
description?: string
|
||||
is_active?: boolean
|
||||
list: string[]
|
||||
}
|
||||
@@ -28,6 +28,7 @@ export interface Charge {
|
||||
value?: number
|
||||
note?: string
|
||||
customer_id?: number
|
||||
talabBedehi?: boolean
|
||||
}
|
||||
|
||||
export interface WithdrawStatus {
|
||||
|
||||
@@ -1,59 +1,80 @@
|
||||
<template>
|
||||
<div class="flex mb-2">
|
||||
<div class="flex flex-col justify-between ">
|
||||
<div class=" font-bold">{{ item.name }}</div>
|
||||
<div class=" text-xs ">کلید: {{ item.key }}</div>
|
||||
</div>
|
||||
<div class="mb-2 border-1 border-gray-300 border-solid rounded-lg p-3">
|
||||
<div>
|
||||
<div class="flex justify-between">
|
||||
<div class="flex items-center font-bold">
|
||||
<div>{{ item.title_fa ?? item.name ?? '-' }}</div>
|
||||
<BaseIcon
|
||||
@click="ok()"
|
||||
icon="vuesax-linear:tick-circle"
|
||||
class="mr-2 items-center"
|
||||
class="mr-2 items-center cursor-pointer"
|
||||
color="green"
|
||||
size="24"
|
||||
/>
|
||||
</div>
|
||||
<a-switch
|
||||
checked-children="فعال"
|
||||
un-checked-children="غیرفعال"
|
||||
v-model:checked="isActive"
|
||||
@change="ok"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center mt-2">
|
||||
<div class="text-xs">کلید: {{ item.key }}</div>
|
||||
<a-switch
|
||||
checked-children="نمایش"
|
||||
un-checked-children="عدم نمایش"
|
||||
v-model:checked="isVisible"
|
||||
@change="ok"
|
||||
/>
|
||||
</div>
|
||||
<QuillEditor
|
||||
placeholder="متن"
|
||||
v-model:content="content"
|
||||
toolbar="full"
|
||||
theme="snow"
|
||||
content-type="html"
|
||||
class="editor-box"
|
||||
class="editor-box mt-2"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { loading } from '@/utils'
|
||||
import { QuillEditor } from '@vueup/vue-quill'
|
||||
import '@vueup/vue-quill/dist/vue-quill.snow.css'
|
||||
import {getConfiguration, setConfiguration} from '@/api/configuration'
|
||||
import { setConfiguration } from '@/api/configuration'
|
||||
import { message } from 'ant-design-vue'
|
||||
import type { TagItem } from '@/components/BasicTags/model'
|
||||
import BasicTextArea from "@/components/BasicTextArea.vue";
|
||||
import type { itemConfig } from '@/model/configuration'
|
||||
|
||||
interface Prop {
|
||||
item: TagItem
|
||||
item: itemConfig
|
||||
}
|
||||
|
||||
const props = defineProps<Prop>()
|
||||
|
||||
const emits = defineEmits(['setVal'])
|
||||
|
||||
const isActive = ref<boolean>(false)
|
||||
const isVisible = ref<boolean>(false)
|
||||
|
||||
function isTruthyFlag(val?: string) {
|
||||
return val === 'true' || val === '1'
|
||||
}
|
||||
|
||||
async function ok() {
|
||||
let obj = {
|
||||
const obj = {
|
||||
id: props.item.id,
|
||||
key: props.item.key,
|
||||
value: content.value,
|
||||
title_fa:props.item.name,
|
||||
title_fa: props.item.title_fa ?? props.item.name,
|
||||
type: props.item.type,
|
||||
description: props.item.description,
|
||||
is_active: props.item.is_active
|
||||
|
||||
description: isVisible.value ? 'true' : 'false',
|
||||
is_active: isActive.value
|
||||
}
|
||||
try {
|
||||
loading.value = true
|
||||
await setConfiguration(obj)
|
||||
await getConfiguration()
|
||||
message.success('تغییر با موفقیت انجام شد')
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
@@ -68,7 +89,13 @@ const content = computed({
|
||||
emits('setVal', val)
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
isActive.value = props.item.is_active === true
|
||||
isVisible.value = isTruthyFlag(props.item.description) || props.item.description == null
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.editor-box {
|
||||
max-height: 40vh;
|
||||
|
||||
@@ -1,19 +1,31 @@
|
||||
<template>
|
||||
<div class="flex-wrap mb-2 flex justify-between items-center border-1 border-gray-300 border-solid rounded-lg p-3">
|
||||
<div class="flex flex-col justify-between ">
|
||||
<div class=" font-bold">{{ item.name }}</div>
|
||||
<div class=" text-xs ">کلید: {{ item.key }}</div>
|
||||
</div>
|
||||
|
||||
<div class="flex">
|
||||
<div class="mb-2 justify-between items-center border-1 border-gray-300 border-solid rounded-lg p-3">
|
||||
<div>
|
||||
<div class="flex justify-between">
|
||||
<div>{{ item.title_fa ?? item.name ?? '-' }}</div>
|
||||
<div>
|
||||
<a-switch
|
||||
checked-children="فعال"
|
||||
un-checked-children="غیرفعال"
|
||||
v-model:checked="isActive"
|
||||
@change="ok"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between items-center mt-2">
|
||||
<div class="text-xs items-center">کلید: {{ item.key }}</div>
|
||||
<div class="flex">
|
||||
<a-switch
|
||||
checked-children="نمایش"
|
||||
un-checked-children="عدم نمایش"
|
||||
v-model:checked="value"
|
||||
@change="ok"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -21,24 +33,25 @@ import {loading} from '@/utils'
|
||||
import { setConfiguration } from '@/api/configuration'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { onMounted } from 'vue'
|
||||
import type {TagItem} from "@/components/BasicTags/model";
|
||||
import type { TagItem } from '@/components/BasicTags/model'
|
||||
|
||||
interface Prop {
|
||||
item: TagItem
|
||||
}
|
||||
|
||||
const props = defineProps<Prop>()
|
||||
const value = ref<string>('false')
|
||||
const value = ref<boolean>(false)
|
||||
const isActive = ref<boolean>(false)
|
||||
|
||||
async function ok() {
|
||||
let obj = {
|
||||
id: props.item.id,
|
||||
key: props.item.key,
|
||||
value: `${value.value}`,
|
||||
value: value.value ? 'true' : 'false',
|
||||
type: props.item.type,
|
||||
title_fa:props.item.name,
|
||||
title_fa: props.item.title_fa ?? props.item.name,
|
||||
description: props.item.description,
|
||||
is_active: props.item.is_active,
|
||||
is_active: isActive.value
|
||||
}
|
||||
try {
|
||||
loading.value = true
|
||||
@@ -53,5 +66,6 @@ async function ok() {
|
||||
|
||||
onMounted(() => {
|
||||
value.value = props.item.value === 'true'
|
||||
isActive.value = props.item.is_active === true
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -1,12 +1,49 @@
|
||||
<template>
|
||||
<div class="mb-2 justify-between border-1 border-gray-300 border-solid rounded-lg p-3">
|
||||
<div class="flex mb-2 flex-col justify-between ">
|
||||
<div class=" font-bold">{{ item.name }}</div>
|
||||
<div class="mb-2 justify-between items-center border-1 border-gray-300 border-solid rounded-lg p-3">
|
||||
<div>
|
||||
<div class="flex justify-between">
|
||||
<div>{{ item.title_fa ?? item.name ?? '-' }}</div>
|
||||
<div>
|
||||
<a-switch
|
||||
checked-children="فعال"
|
||||
un-checked-children="غیرفعال"
|
||||
v-model:checked="isActive"
|
||||
@change="ok"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!item.list?.length" class="flex justify-between items-center mt-2">
|
||||
<div class="text-xs">کلید: {{ item.key }}</div>
|
||||
</div> <div class="flex justify-between gap-1">
|
||||
<BasicSelect class="w-full" v-if="item.list && item.list.length > 0" @change="ok" value-name="value" key-name="lable" v-model:value="value" :items="itemListLocal"/>
|
||||
<BasicInput v-else class="flex-1" type="text" place-holder="مقدار" v-model:value="value" @input="isChanged=true" />
|
||||
<div v-if="item.list && item.list.length==0 && isChanged" class="flex items-center " >
|
||||
<div class="flex">
|
||||
<a-switch
|
||||
checked-children="نمایش"
|
||||
un-checked-children="عدم نمایش"
|
||||
v-model:checked="isVisible"
|
||||
@change="ok"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="text-xs mt-2">کلید: {{ item.key }}</div>
|
||||
<div class="flex justify-between gap-1 mt-2">
|
||||
<BasicSelect
|
||||
v-if="item.list && item.list.length > 0"
|
||||
class="w-full"
|
||||
value-name="value"
|
||||
key-name="lable"
|
||||
v-model:value="configValue"
|
||||
:items="itemListLocal"
|
||||
@change="ok"
|
||||
/>
|
||||
<BasicInput
|
||||
v-else
|
||||
class="flex-1"
|
||||
type="text"
|
||||
place-holder="مقدار"
|
||||
v-model:value="configValue"
|
||||
@input="isChanged = true"
|
||||
/>
|
||||
<div v-if="item.list && item.list.length === 0 && isChanged" class="flex items-center">
|
||||
<BaseIcon
|
||||
icon="vuesax-linear:tick-circle"
|
||||
class="mr-2 items-center cursor-pointer"
|
||||
@@ -18,7 +55,7 @@
|
||||
icon="vuesax-linear:close-circle"
|
||||
class="mr-2 items-center cursor-pointer"
|
||||
color="red"
|
||||
@click="canselFn"
|
||||
@click="cancelFn"
|
||||
size="24"
|
||||
/>
|
||||
</div>
|
||||
@@ -27,19 +64,21 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { Order } from '@/model/order'
|
||||
import { loading } from '@/utils'
|
||||
import { setConfiguration } from '@/api/configuration'
|
||||
import { message } from 'ant-design-vue'
|
||||
import type {itemConfig} from "@/model/configuration";
|
||||
import type { itemConfig } from '@/model/configuration'
|
||||
|
||||
interface Prop {
|
||||
item: itemConfig
|
||||
}
|
||||
|
||||
const props = defineProps<Prop>()
|
||||
const value = ref<string>('')
|
||||
const configValue = ref<string>('')
|
||||
const isActive = ref<boolean>(false)
|
||||
const isVisible = ref<boolean>(false)
|
||||
const isChanged = ref<boolean>(false)
|
||||
|
||||
const itemListLocal = computed(() => {
|
||||
if (!props.item.list) return []
|
||||
return props.item.list.map((x) => ({
|
||||
@@ -47,27 +86,39 @@ const itemListLocal = computed(() => {
|
||||
value: x
|
||||
}))
|
||||
})
|
||||
const canselFn=()=>{
|
||||
value.value = props.item.value
|
||||
isChanged.value=false
|
||||
|
||||
function isTruthyFlag(val?: string) {
|
||||
return val === 'true' || val === '1'
|
||||
}
|
||||
async function ok() {
|
||||
let obj = {
|
||||
|
||||
function cancelFn() {
|
||||
configValue.value = props.item.value
|
||||
isChanged.value = false
|
||||
}
|
||||
|
||||
function buildPayload() {
|
||||
const hasSelectOptions = props.item.list && props.item.list.length > 0
|
||||
return {
|
||||
id: props.item.id,
|
||||
key: props.item.key,
|
||||
value: value.value,
|
||||
title_fa:props.item.name,
|
||||
value: configValue.value,
|
||||
title_fa: props.item.title_fa ?? props.item.name,
|
||||
type: props.item.type,
|
||||
description: props.item.description,
|
||||
is_active: props.item.is_active
|
||||
description: hasSelectOptions
|
||||
? props.item.description
|
||||
: isVisible.value
|
||||
? 'true'
|
||||
: 'false',
|
||||
is_active: isActive.value
|
||||
}
|
||||
}
|
||||
|
||||
async function ok() {
|
||||
try {
|
||||
loading.value = true
|
||||
await setConfiguration(obj)
|
||||
await setConfiguration(buildPayload())
|
||||
message.success('تغییر با موفقیت انجام شد')
|
||||
isChanged.value = false
|
||||
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
} finally {
|
||||
@@ -76,8 +127,8 @@ async function ok() {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
console.log(props.item)
|
||||
return value.value = props.item.value
|
||||
configValue.value = props.item.value
|
||||
isActive.value = props.item.is_active === true
|
||||
isVisible.value = isTruthyFlag(props.item.description) || props.item.description == null
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
@@ -99,6 +99,7 @@ const form = ref<Const>({
|
||||
description: '',
|
||||
is_active: true
|
||||
})
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
const typeItems = [
|
||||
@@ -116,9 +117,6 @@ const typeItems = [
|
||||
}
|
||||
]
|
||||
|
||||
onMounted(() => {
|
||||
initConfig()
|
||||
})
|
||||
const settingsConfig = {
|
||||
// اطلاعات پایه
|
||||
'name_fa': {
|
||||
@@ -261,18 +259,18 @@ async function initConfig() {
|
||||
loading.value = true
|
||||
baseData.value = await getConfiguration()
|
||||
items.value = baseData.value?.map((x: Const) => {
|
||||
const title = x?.title_fa ?? (settingsConfig[x.key]?.title ?? x?.key)
|
||||
const title_fa = x?.title_fa || settingsConfig[x.key]?.title || x?.key
|
||||
|
||||
return {
|
||||
id: x.id,
|
||||
name: `${title}`,
|
||||
name: title_fa,
|
||||
title_fa,
|
||||
value: x.value,
|
||||
key: x.key,
|
||||
type: x.type || 'text',
|
||||
description: x.description,
|
||||
is_active: x.is_active,
|
||||
list: settingsConfig[x.key]?.list ?? []
|
||||
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
@@ -288,7 +286,7 @@ const groupedItems = computed(() => {
|
||||
const type = item.type && result[item.type] ? item.type : 'text'
|
||||
result[type].push(item)
|
||||
})
|
||||
console.log(result)
|
||||
// console.log(result)
|
||||
return result
|
||||
})
|
||||
|
||||
@@ -318,7 +316,6 @@ async function ok() {
|
||||
formRef.value?.validateFields().then(async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
|
||||
console.log(form.value)
|
||||
await setConfiguration(form.value)
|
||||
await resetData()
|
||||
@@ -331,6 +328,11 @@ async function ok() {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
initConfig()
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less"></style>
|
||||
@@ -216,6 +216,9 @@
|
||||
@close="showMoneyWalletCharge = false"
|
||||
>
|
||||
<a-form :model="formCharge" ref="formChargeRef" autocomplete="off">
|
||||
<a-form-item name="talabBedehi">
|
||||
<a-checkbox v-model:checked="formCharge.talabBedehi">طلب/بدهی</a-checkbox>
|
||||
</a-form-item>
|
||||
<a-form-item label="مقدار شارژ " name="value" :rules="inputRules()">
|
||||
<BasicInput addon-before="ریال" v-model:value="formCharge.value" type="price" />
|
||||
<div v-show="formCharge.value > 10">
|
||||
@@ -237,6 +240,9 @@
|
||||
@close="showGoldWalletCharge = false"
|
||||
>
|
||||
<a-form :model="formCharge" ref="formChargeRef" autocomplete="off">
|
||||
<a-form-item name="talabBedehi">
|
||||
<a-checkbox v-model:checked="formCharge.talabBedehi">طلب/بدهی</a-checkbox>
|
||||
</a-form-item>
|
||||
<a-form-item label="مقدار شارژ " name="value" :rules="inputRules()">
|
||||
<BasicInput addon-before="گرم" v-model:value="formCharge.value" type="number" />
|
||||
<!-- <div v-show="formCharge.value > 10">
|
||||
@@ -469,22 +475,39 @@ async function add() {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
function resetFormCharge(customerId: number) {
|
||||
formCharge.value = {
|
||||
customer_id: customerId,
|
||||
value: undefined,
|
||||
note: undefined,
|
||||
talabBedehi: false
|
||||
}
|
||||
}
|
||||
|
||||
function buildChargePayload(): Charge {
|
||||
return {
|
||||
value: formCharge.value.value,
|
||||
note: formCharge.value.note,
|
||||
customer_id: formCharge.value.customer_id,
|
||||
talabBedehi: formCharge.value.talabBedehi === true
|
||||
}
|
||||
}
|
||||
|
||||
async function walletMoneyCharge(val: Customer) {
|
||||
resetFormCharge(val.id)
|
||||
showMoneyWalletCharge.value = true
|
||||
formCharge.value.customer_id = val.id
|
||||
}
|
||||
|
||||
async function walletGoldCharge(val: Customer) {
|
||||
resetFormCharge(val.id)
|
||||
showGoldWalletCharge.value = true
|
||||
formCharge.value.customer_id = val.id
|
||||
}
|
||||
|
||||
async function chargeMoneyWallet() {
|
||||
formChargeRef.value?.validateFields().then(async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
await chargeWallet(formCharge.value, 'money')
|
||||
formCharge.value.value = undefined
|
||||
await chargeWallet(buildChargePayload(), 'money')
|
||||
message.success('افزایش اعتبار با موفقیت انجام شد')
|
||||
showMoneyWalletCharge.value = false
|
||||
} catch (e) {
|
||||
@@ -499,10 +522,9 @@ async function chargeGoldWallet() {
|
||||
formChargeRef.value?.validateFields().then(async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
await chargeWallet(formCharge.value, 'gold')
|
||||
formCharge.value.value = undefined
|
||||
await chargeWallet(buildChargePayload(), 'gold')
|
||||
message.success('افزایش اعتبار با موفقیت انجام شد')
|
||||
showMoneyWalletCharge.value = false
|
||||
showGoldWalletCharge.value = false
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<component :is="selectedComponent" class="mr-5" />-->
|
||||
<!-- <BasicShowContext title="پروژه ها"> <Search /> </BasicShowContext>-->
|
||||
</div>
|
||||
<!-- </BasicMainCard>-->n
|
||||
<!-- </BasicMainCard>-->
|
||||
<BasicModal
|
||||
v-model:visible="addUserVisible"
|
||||
width="50rem"
|
||||
@@ -366,6 +366,9 @@
|
||||
@close="showMoneyWalletCharge = false"
|
||||
>
|
||||
<a-form :model="formCharge" ref="formChargeRef" autocomplete="off">
|
||||
<a-form-item name="talabBedehi">
|
||||
<a-checkbox v-model:checked="formCharge.talabBedehi">طلب/بدهی</a-checkbox>
|
||||
</a-form-item>
|
||||
<a-form-item label="مقدار شارژ " name="value" :rules="inputRules()">
|
||||
<BasicInput addon-before="ریال" v-model:value="formCharge.value" type="price"/>
|
||||
<div v-show="formCharge.value > 10">
|
||||
@@ -386,6 +389,9 @@
|
||||
@close="showGoldWalletCharge = false"
|
||||
>
|
||||
<a-form :model="formCharge" ref="formChargeRef" autocomplete="off">
|
||||
<a-form-item name="talabBedehi">
|
||||
<a-checkbox v-model:checked="formCharge.talabBedehi">طلب/بدهی</a-checkbox>
|
||||
</a-form-item>
|
||||
<a-form-item label="مقدار شارژ " name="value" :rules="inputRules()">
|
||||
<BasicInput addon-before="گرم" v-model:value="formCharge.value" type="number"/>
|
||||
<!-- <div v-show="formCharge.value > 10">
|
||||
@@ -734,22 +740,39 @@ async function add() {
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
function resetFormCharge(customerId: number) {
|
||||
formCharge.value = {
|
||||
customer_id: customerId,
|
||||
value: undefined,
|
||||
note: undefined,
|
||||
talabBedehi: false
|
||||
};
|
||||
}
|
||||
|
||||
function buildChargePayload(): Charge {
|
||||
return {
|
||||
value: formCharge.value.value,
|
||||
note: formCharge.value.note,
|
||||
customer_id: formCharge.value.customer_id,
|
||||
talabBedehi: formCharge.value.talabBedehi === true
|
||||
};
|
||||
}
|
||||
|
||||
async function walletMoneyCharge(val: Customer) {
|
||||
resetFormCharge(val.id);
|
||||
showMoneyWalletCharge.value = true;
|
||||
formCharge.value.customer_id = val.id;
|
||||
}
|
||||
|
||||
async function walletGoldCharge(val: Customer) {
|
||||
resetFormCharge(val.id);
|
||||
showGoldWalletCharge.value = true;
|
||||
formCharge.value.customer_id = val.id;
|
||||
}
|
||||
|
||||
async function chargeMoneyWallet() {
|
||||
formChargeRef.value?.validateFields().then(async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
await chargeWallet(formCharge.value, "money");
|
||||
formCharge.value.value = undefined;
|
||||
await chargeWallet(buildChargePayload(), "money");
|
||||
message.success("افزایش اعتبار با موفقیت انجام شد");
|
||||
showMoneyWalletCharge.value = false;
|
||||
} catch (e) {
|
||||
@@ -764,10 +787,9 @@ async function chargeGoldWallet() {
|
||||
formChargeRef.value?.validateFields().then(async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
await chargeWallet(formCharge.value, "gold");
|
||||
formCharge.value.value = undefined;
|
||||
await chargeWallet(buildChargePayload(), "gold");
|
||||
message.success("افزایش اعتبار با موفقیت انجام شد");
|
||||
showMoneyWalletCharge.value = false;
|
||||
showGoldWalletCharge.value = false;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user