Files
asan-service/pages/admin/download-categories/new.vue
T
2023-08-17 13:05:51 +03:30

80 lines
2.0 KiB
Vue

<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{ name: 'admin-download-categories' }"
>برگشت به صفحه قبل</CButton
>
<CButton size="sm" color="success" style="margin-right: 10px" @click="upload">ایجاد</CButton>
</CustomSubHeader>
<CRow>
<CCol xl="6">
<CCard>
<CCardBody>
<CForm>
<CInput
v-model="formData.name"
label="نام"
horizontal
:description="validation.name ? validation.name.msg : null"
:class="validation.name ? 'err' : null"
/>
</CForm>
</CCardBody>
</CCard>
</CCol>
</CRow>
</div>
</template>
<script>
export default {
name: 'AddminAddNewDownloadCategory',
layout: 'admin',
data() {
return {
title: 'افزودن دسته بندی دانلود',
formData: {
name: ''
},
validation: {}
}
},
head() {
return {
title: this.title
}
},
methods: {
upload() {
this.validation = {}
this.$axios
.post(`/api/admin/dCategory`, this.formData)
.then(response => {
if (response.data) {
this.$message({
message: 'آیتم با موفقیت ثبت شد.',
type: 'success'
})
this.$router.push({ name: 'admin-download-categories' })
}
})
.catch(error => {
if (error.response.status === 422) {
this.validation = error.response.data.validation
this.$message({
type: 'error',
message: 'اطلاعات رو بررسی و دوباره تلاش کنید'
})
} else {
this.$alert(error.response.data.message, 'خطا', {
confirmButtonText: 'باشه'
})
}
})
}
}
}
</script>