changes of giftCard page

This commit is contained in:
2026-10-20 12:11:46 +03:30
parent 2927d64c64
commit e5b3d0c931
55 changed files with 1495 additions and 140 deletions
+45 -5
View File
@@ -18,7 +18,7 @@
<!-- </BasicMainCard>-->
<BasicModal
v-model:visible="addUserVisible"
width="40rem"
width="min(52rem, 96vw)"
:title="`${editId ? 'ویرایش' : 'افزودن'} کاربر`"
@ok="ok"
:loading="loading"
@@ -48,6 +48,19 @@
</a-switch>
</a-form-item>
</div>
<div v-if="canAssignAccess" class="mt-1 flex flex-col gap-2">
<div>
<div class="text-sm font-medium">دسترسی صفحات</div>
<p class="mt-0.5 text-xs leading-5 opacity-70">
هر صفحه را باز کنید و مشاهده و عملیات جدول همان صفحه را مشخص کنید. بسته می‌ماند تا وقتی لازم است.
</p>
</div>
<div class="flex items-center justify-between gap-2">
<span class="text-sm">دسترسی کامل به همهٔ صفحات</span>
<a-switch v-model:checked="fullAccess" />
</div>
<ManagerPageAccessTree v-if="!fullAccess" v-model="form.page_access" />
</div>
</a-form>
</BasicModal>
<!-- <BasicInfoModal
@@ -81,12 +94,18 @@ import { toJalaliNoTime, toTime } from '@core/utils/useDataTime'
import { confirmDeleteItem } from '@/utils/confirmModal'
import { cloneDeep } from 'lodash'
import type { Item } from '@/model/Item'
import ManagerPageAccessTree from './components/ManagerPageAccessTree.vue'
import { allGrantedMap, hasAnyView, parsePageAccess } from '@/utils/adminPageAccess'
import { useUserStore } from '@/store/userStore'
//loading
const loading = ref<boolean>(false)
//define store
const store = useStaticApiListsStore()
const userStore = useUserStore()
const canAssignAccess = computed(() => userStore.hasFullPageAccess)
const fullAccess = ref(true)
//define tbl
const table = ref(null)
@@ -112,6 +131,11 @@ const form = ref<User>({
})
const formRef = ref<FormInstance>()
watch(fullAccess, (on) => {
if (on) return
if (form.value.page_access == null) form.value.page_access = allGrantedMap()
})
//info
let infoParams = reactive<Info>({})
@@ -141,6 +165,8 @@ async function edit(record: User) {
addUserVisible.value = true
editId = record.id
form.value = cloneDeep(record)
form.value.page_access = parsePageAccess(record.page_access)
fullAccess.value = form.value.page_access == null
}
//add
@@ -164,8 +190,10 @@ const resetData = () => {
avatar_id: undefined,
sts: undefined,
id: undefined,
mobile: undefined
mobile: undefined,
page_access: null
}
fullAccess.value = true
}
//delete — DELETE /admin/user/:id
@@ -226,21 +254,33 @@ async function ok() {
formRef.value?.validateFields().then(async () => {
// console.log('salam', form.value)
// return
const payload = cloneDeep(form.value)
delete payload.repassword
if (canAssignAccess.value) {
payload.page_access = fullAccess.value ? null : payload.page_access ?? allGrantedMap()
if (!fullAccess.value && !hasAnyView(payload.page_access)) {
message.error('حداقل مشاهدهٔ یک صفحه را انتخاب کنید')
return
}
} else {
delete payload.page_access
}
loading.value = true
try {
if (editId) {
if (form.value.password) {
if (form.value.password === form.value.repassword) {
await updateUser(editId, form.value)
await updateUser(editId, payload)
} else {
message.error('پسورد وارد شده با تکرار پسورد وارد شده یکسان نیست')
return
}
} else {
await updateUser(editId, form.value)
delete payload.password
await updateUser(editId, payload)
}
} else {
await createUser(form.value)
await createUser(payload)
}
addUserVisible.value = false
refreshTable()