1404/11/04- first
This commit is contained in:
@@ -0,0 +1,260 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicMainCard>
|
||||
<div class="flex w-full h-full">
|
||||
<tbl
|
||||
ref="table"
|
||||
class="w-full h-full"
|
||||
@info="info"
|
||||
@edit="edit"
|
||||
@delete="deleteItem"
|
||||
@add="add"
|
||||
/>
|
||||
|
||||
<!-- <BasicMenu :menu="menu" width="13rem" @onChange="tabSelected" />
|
||||
<component :is="selectedComponent" class="mr-5" />-->
|
||||
<!-- <BasicShowContext title="پروژه ها"> <Search /> </BasicShowContext>-->
|
||||
</div>
|
||||
</BasicMainCard>
|
||||
|
||||
<BasicModal
|
||||
v-model:visible="priceConfirmVisible"
|
||||
width="25rem"
|
||||
@ok="ok"
|
||||
:confirm-loading="loading"
|
||||
@close="priceConfirmVisible = false"
|
||||
>
|
||||
<div class="flex items-center gap-2 font-bold">
|
||||
<BaseIcon icon="vuesax-linear:info-circle" color="orange" />
|
||||
<div>آیا مطمئن به تغییر قیمت می باشید؟</div>
|
||||
</div>
|
||||
</BasicModal>
|
||||
<!-- <BasicInfoModal
|
||||
v-model:visible="userInfoVisible"
|
||||
@close="userInfoVisible = false"
|
||||
:title="infoParams.title"
|
||||
:date="infoParams.date"
|
||||
:time="infoParams.time"
|
||||
:type="infoParams.type"
|
||||
:name="infoParams.name"
|
||||
:items="infoParams.items"
|
||||
/>-->
|
||||
</div>
|
||||
<BasicModal
|
||||
v-model:visible="addPriceVisible"
|
||||
width="25rem"
|
||||
title="قیمت گذاری"
|
||||
@ok="confirmPrice"
|
||||
:loading="loading"
|
||||
@close="addPriceVisible = false"
|
||||
>
|
||||
<a-form :model="form" ref="formRef" autocomplete="off">
|
||||
<div class="gap-4">
|
||||
<a-form-item label="قیمت جدید" name="price" :rules="inputRules()">
|
||||
<BasicInput v-model:value="form.price" type="price" addon-before="ریال" />
|
||||
</a-form-item>
|
||||
<div v-show="form.price > 10">معادل {{ usePrice(form.price / 10, true, 'تومان') }}</div>
|
||||
<!-- <a-form-item label="نام چاپی" name="print_name" :rules="inputRules()">
|
||||
<BasicInput v-model:value="form.print_name" />
|
||||
</a-form-item>-->
|
||||
</div>
|
||||
</a-form>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// import BasicInfoModal from '@/components/BasicInfoModal'
|
||||
import { inputLenRules, inputRules } from '@/utils/inputRules'
|
||||
import { useStaticApiListsStore } from '@/store/staticApisStore'
|
||||
import { ref } from 'vue'
|
||||
import tbl from './components/table.vue'
|
||||
import type { FormInstance } from 'ant-design-vue'
|
||||
import BasicInfoModal from '@/components/BasicInfoModal/index.vue'
|
||||
import { message } from 'ant-design-vue/es'
|
||||
import type { Info } from '@/components/BasicInfoModal/model/Info'
|
||||
import { toJalaliNoTime, toTime } from '@core/utils/useDataTime'
|
||||
import { confirmActOnApi, confirmDeleteItem } from '@/utils/confirmModal'
|
||||
import { cloneDeep } from 'lodash'
|
||||
import type { Item } from '@/model/Item'
|
||||
import type { Customer } from '@/model/customer'
|
||||
import { createCustomer, deleteCustomer, updateCustomer } from '@/api/customer'
|
||||
import type { Order } from '@/model/order'
|
||||
import type { Price } from '@/model/price'
|
||||
import { createPrice } from '@/api/price'
|
||||
import { usePrice } from '@core/utils/usePrice'
|
||||
import Icon from '@core/components/BaseIcon'
|
||||
|
||||
//loading
|
||||
const loading = ref<boolean>(false)
|
||||
|
||||
//define store
|
||||
const store = useStaticApiListsStore()
|
||||
|
||||
//define tbl
|
||||
const table = ref(null)
|
||||
const refreshTable = () => table?.value?.fetch()
|
||||
|
||||
let updateKey = ref<number>(0)
|
||||
|
||||
//role confirm items
|
||||
const confirmItems: Array<Item> = [
|
||||
{
|
||||
value: 'بله',
|
||||
key: true
|
||||
},
|
||||
{
|
||||
value: 'خیر',
|
||||
key: false
|
||||
}
|
||||
]
|
||||
|
||||
//form
|
||||
const form = ref<Price>({})
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
//info
|
||||
let infoParams = reactive<Info>({})
|
||||
|
||||
/*
|
||||
function info(val: Order) {
|
||||
infoParams.name = val.customer.name
|
||||
infoParams.type = val.customer.mobile
|
||||
infoParams.date = toJalaliNoTime(val.created_at)
|
||||
infoParams.time = toTime(val.created_at)
|
||||
infoParams.itemsTitle = 'اطلاعات کاربری'
|
||||
infoParams.items = [
|
||||
{
|
||||
key: 'مقدار (گرم)',
|
||||
value: val.amount ?? '-'
|
||||
},
|
||||
{
|
||||
key: 'قیمت هر گرم طلا برای مشتری (ریال)',
|
||||
value: val.price ?? '-'
|
||||
},
|
||||
{
|
||||
key: 'قیمت کل برای مشتری (ریال)',
|
||||
value: val.total_price ?? '-'
|
||||
},
|
||||
{
|
||||
key: '/قیمت هر گرم طلا بدون سود (ریال)',
|
||||
value: val.price_original ?? '-'
|
||||
},
|
||||
{
|
||||
key: 'قیمت کل بدون سود (ریال)',
|
||||
value: val.total_price_original ?? '-'
|
||||
},
|
||||
{
|
||||
key: 'سود هر گرم (ریال)',
|
||||
value: val.fee ?? '-'
|
||||
},
|
||||
{
|
||||
key: 'سود کل (ریال)',
|
||||
value: val.total_fee ?? '-'
|
||||
},
|
||||
{
|
||||
key: 'کد کاربری',
|
||||
value: val.customer.id ?? '-'
|
||||
},
|
||||
{
|
||||
key: 'شماره ملی',
|
||||
value: val.customer.n_code ?? '-'
|
||||
},
|
||||
{
|
||||
key: 'تاریخ تولد',
|
||||
value: toJalaliNoTime(val.customer.birth_date) ?? '-'
|
||||
},
|
||||
/!* {
|
||||
key: 'نام فروشگاه',
|
||||
value: val.customer.shop_name ?? '-'
|
||||
},*!/
|
||||
{
|
||||
key: 'شماره تلفن',
|
||||
value: val.customer.phone_number ?? '-'
|
||||
},
|
||||
{
|
||||
key: 'نام استان',
|
||||
value: val.customer.province ?? '-'
|
||||
},
|
||||
{
|
||||
key: 'نام شهر',
|
||||
value: val.customer.city ?? '-'
|
||||
}
|
||||
/!* {
|
||||
key: 'نام چاپی',
|
||||
value: val.print_name ?? '-'
|
||||
}*!/
|
||||
]
|
||||
userInfoVisible.value = true
|
||||
}
|
||||
*/
|
||||
|
||||
//edit
|
||||
let editId: number | undefined = undefined
|
||||
|
||||
/*
|
||||
async function edit(record: Customer) {
|
||||
addPriceVisible.value = true
|
||||
editId = record.id
|
||||
form.value = cloneDeep(record)
|
||||
}
|
||||
*/
|
||||
|
||||
//add
|
||||
async function add() {
|
||||
loading.value = true
|
||||
editId = undefined
|
||||
// await store.getUsersList()
|
||||
addPriceVisible.value = true
|
||||
updateKey.value++
|
||||
resetData()
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
//reset data
|
||||
const resetData = () => {
|
||||
formRef.value?.resetFields()
|
||||
form.value = {}
|
||||
}
|
||||
|
||||
//delete
|
||||
// const deleteItem = (id: number) => confirmDeleteItem('کاربر', id, deleteCustomer, refreshTable)
|
||||
|
||||
//define selects
|
||||
/*
|
||||
onMounted(async () => {
|
||||
loading.value = true
|
||||
// await getResponsible()
|
||||
// await getQC()
|
||||
// await getManager()
|
||||
loading.value = false
|
||||
})
|
||||
*/
|
||||
|
||||
//add project modal
|
||||
const addPriceVisible = ref<boolean>(false)
|
||||
const priceConfirmVisible = ref<boolean>(false)
|
||||
|
||||
//submit user
|
||||
function confirmPrice() {
|
||||
formRef.value?.validateFields().then(async () => {
|
||||
priceConfirmVisible.value = true
|
||||
})
|
||||
}
|
||||
async function ok() {
|
||||
loading.value = true
|
||||
try {
|
||||
await createPrice(form.value)
|
||||
refreshTable()
|
||||
priceConfirmVisible.value = false
|
||||
addPriceVisible.value = false
|
||||
// await confirmActOnApi('آیا از اعمال قیمت جدید اطمینان دارید؟', form.value, createPrice)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
// message.error('خطا در بارگذاری اطلاعات')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
Reference in New Issue
Block a user