58 lines
1.4 KiB
Vue
58 lines
1.4 KiB
Vue
<template>
|
|
<CRow>
|
|
<CCol sm="12" class="err">
|
|
<el-select v-model="branch" filterable style="width: 100%">
|
|
<el-option v-for="item in branches" :key="item._id" :value="item._id" :label="item.title || 'شعبه اراک'"/>
|
|
</el-select>
|
|
</CCol>
|
|
</CRow>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: "Branches",
|
|
data () {
|
|
return {
|
|
branches: [],
|
|
branch: null
|
|
}
|
|
},
|
|
mounted() {
|
|
// this.branch = this.branches[0]._id
|
|
},
|
|
async fetch() {
|
|
try {
|
|
this.branches = await this.$axios.$get(`/api/admin/store/getAll`)
|
|
this.branch = this.branches[0]._id
|
|
this.$store.commit('admin/set' , ['branchId' , this.branch])
|
|
} catch (e) {
|
|
if (e?.response?.status === 401) {
|
|
this.$nuxt.error({
|
|
status: 401,
|
|
message: "لطفا دوباره وارد سیستم شوید.",
|
|
});
|
|
}
|
|
if (e?.response?.status === 403) {
|
|
this.$nuxt.error({
|
|
status: 403,
|
|
message: e?.response?.data?.message,
|
|
});
|
|
}
|
|
if (e?.response?.status === 500) {
|
|
this.$nuxt.error({
|
|
status: 500,
|
|
message: "مشکلی در گرفتن اطلاعات پیش آمده",
|
|
});
|
|
} else
|
|
this.$nuxt.error({
|
|
status: 404,
|
|
message: "اطلاعات مورد نظر پیدا نشد",
|
|
});
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
|
|
</style> |