1404/11/04- first
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
import { Modal } from 'ant-design-vue'
|
||||
import { createVNode } from 'vue'
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'
|
||||
import { deleteUser } from '@/api/user'
|
||||
import { message } from 'ant-design-vue/es'
|
||||
|
||||
//todo
|
||||
export async function confirmDeleteItem(
|
||||
type: string,
|
||||
id: number,
|
||||
functionDelete: (id: number) => Promise<any>,
|
||||
refreshTable: () => void
|
||||
) {
|
||||
Modal.confirm({
|
||||
title: `آیا از حذف ${type} اطمینان دارید؟`,
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
okText: 'تایید',
|
||||
okType: 'danger',
|
||||
centered: true,
|
||||
cancelText: 'انصراف',
|
||||
async onOk() {
|
||||
// console.log('OK');
|
||||
// await deleteItem(id)
|
||||
|
||||
// loading.value = true
|
||||
// table?.value?.spinTable(true)
|
||||
// @ts-ignore
|
||||
try {
|
||||
await functionDelete(id)
|
||||
refreshTable()
|
||||
console.log('finall')
|
||||
message.success('با موفقیت حذف شد')
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
// message.error('خطا در حذف')
|
||||
}
|
||||
|
||||
// setTimeout(Math.random() > 0.5 ? resolve : reject, 1000)
|
||||
// table?.value?.fetch()
|
||||
|
||||
// loading.value = false
|
||||
// table?.value?.spinTable(false)
|
||||
},
|
||||
onCancel() {
|
||||
console.log('Cancel')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export async function confirmActOnApi(
|
||||
title: string,
|
||||
item: any,
|
||||
functionApi: (item: any) => Promise<any>,
|
||||
refreshTable?: () => void
|
||||
) {
|
||||
Modal.confirm({
|
||||
title: title,
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
okText: 'تایید',
|
||||
okType: 'danger',
|
||||
centered: true,
|
||||
cancelText: 'انصراف',
|
||||
async onOk() {
|
||||
// console.log('OK');
|
||||
// await deleteItem(id)
|
||||
|
||||
// loading.value = true
|
||||
// table?.value?.spinTable(true)
|
||||
// @ts-ignore
|
||||
try {
|
||||
console.log('sasas')
|
||||
await functionApi(item)
|
||||
if (refreshTable) {
|
||||
refreshTable()
|
||||
}
|
||||
// console.log('finall')
|
||||
message.success('با موفقیت انجام شد')
|
||||
Modal.destroyAll()
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
// message.error('خطا در حذف')
|
||||
}
|
||||
|
||||
// setTimeout(Math.random() > 0.5 ? resolve : reject, 1000)
|
||||
// table?.value?.fetch()
|
||||
|
||||
// loading.value = false
|
||||
// table?.value?.spinTable(false)
|
||||
},
|
||||
onCancel() {
|
||||
console.log('Cancel')
|
||||
Modal.destroyAll()
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user