2026-04-29 11:20:59 +03:30
|
|
|
<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=" 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 " >
|
|
|
|
|
<BaseIcon
|
|
|
|
|
icon="vuesax-linear:tick-circle"
|
|
|
|
|
class="mr-2 items-center cursor-pointer"
|
|
|
|
|
color="green"
|
|
|
|
|
size="24"
|
|
|
|
|
@click="ok()"
|
|
|
|
|
/>
|
|
|
|
|
<BaseIcon
|
|
|
|
|
icon="vuesax-linear:close-circle"
|
|
|
|
|
class="mr-2 items-center cursor-pointer"
|
|
|
|
|
color="red"
|
|
|
|
|
@click="canselFn"
|
|
|
|
|
size="24"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</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";
|
|
|
|
|
|
|
|
|
|
interface Prop {
|
|
|
|
|
item: itemConfig
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const props = defineProps<Prop>()
|
|
|
|
|
const value = ref<string>('')
|
|
|
|
|
const isChanged=ref<boolean>(false)
|
|
|
|
|
const itemListLocal = computed(() => {
|
|
|
|
|
if (!props.item.list) return []
|
|
|
|
|
return props.item.list.map((x) => ({
|
|
|
|
|
lable: x,
|
|
|
|
|
value: x
|
|
|
|
|
}))
|
|
|
|
|
})
|
|
|
|
|
const canselFn=()=>{
|
|
|
|
|
value.value = props.item.value
|
|
|
|
|
isChanged.value=false
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
async function ok() {
|
|
|
|
|
let obj = {
|
|
|
|
|
id: props.item.id,
|
|
|
|
|
key: props.item.key,
|
|
|
|
|
value: value.value,
|
2026-04-29 16:24:50 +03:30
|
|
|
title_fa:props.item.name,
|
|
|
|
|
type:props.item.type,
|
|
|
|
|
description: props.item.description,
|
|
|
|
|
is_active: props.item.is_active
|
2026-04-29 11:20:59 +03:30
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
loading.value = true
|
|
|
|
|
await setConfiguration(obj)
|
|
|
|
|
message.success('تغییر با موفقیت انجام شد')
|
|
|
|
|
isChanged.value=false
|
|
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error(e)
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
console.log(props.item)
|
|
|
|
|
return value.value = props.item.value
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
</script>
|