somewhere

This commit is contained in:
Swift
2023-08-17 13:05:51 +03:30
parent 30c7eb0e7b
commit 53843207cc
429 changed files with 117489 additions and 1 deletions
+225
View File
@@ -0,0 +1,225 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
<el-tag v-if="bufferRequest._openedBy && bufferRequest._openedBy.first_name" type="primary" class="ml-1">
<span>اولین مشاهده توسط: </span>
<span> {{ bufferRequest._openedBy.first_name + ' ' + bufferRequest._openedBy.last_name }} </span>
</el-tag>
<el-tag v-if="bufferRequest._updatedBy && bufferRequest._updatedBy.first_name" type="primary" class="ml-1">
<span>تغییر وضعیت توسط: </span>
<span> {{ bufferRequest._updatedBy.first_name + ' ' + bufferRequest._updatedBy.last_name }} </span>
</el-tag>
<CButton size="sm" color="primary" class="mr-auto" @click="$router.go(-1)">برگشت به صفحه قبل</CButton>
</CustomSubHeader>
<CRow>
<CCol v-if="!bufferRequest.archived && bufferRequest.status !== 'rejected'" lg="12">
<CCard>
<CCardBody>
<CRow>
<CCol lg="6">
<h6>تغییر وضعیت فرم</h6>
<el-divider></el-divider>
<CButtonGroup>
<!-- <CButton
:color="bufferRequest.status === 'ongoing' ? 'warning' : 'light'"
@click="updateStatus('ongoing')"
>
در دست اقدام
</CButton> -->
<CButton
:color="bufferRequest.status === 'waiting' ? 'warning' : 'light'"
@click="updateStatus('waiting')"
>
در انتظار قطعه
</CButton>
<el-popover
v-model="deliverPopover"
placement="bottom"
width="160"
:disabled="bufferRequest.status === 'delivered'"
@click="deliveryPopover = true"
>
<el-input v-model="deliveryCode" placeholder="کد ارسال مرسوله"></el-input>
<div class="mt-1" style="text-align: center">
<el-button
size="mini"
type="text"
class="agentsStatus-popover-insideBtn"
@click="updateStatus('delivered')"
>ارسال</el-button
>
</div>
<CButton slot="reference" :color="bufferRequest.status === 'delivered' ? 'success' : 'light'">
تحویل شده
</CButton>
</el-popover>
</CButtonGroup>
<div v-if="bufferRequest.status === 'delivered'" class="mt-3">
<p>
<span>کد ارسال مرسوله: </span>
<b>{{ bufferRequest.deliveryCode || '-' }} </b>
</p>
</div>
</CCol>
<CCol lg="6">
<h6>تاریخچه وضعیت های فرم</h6>
<el-divider></el-divider>
<el-table :data="bufferRequest.statusHistory" style="width: 100%">
<el-table-column prop="name" label="وضعیت">
<template slot-scope="scope">
<span v-if="scope.row.status === 'temp'">پیشنویس</span>
<span v-if="scope.row.status === 'sent'">ارسال</span>
<span v-if="scope.row.status === 'ongoing'">در دست اقدام</span>
<span v-if="scope.row.status === 'waiting'">در انتظار قطعه</span>
<span v-if="scope.row.status === 'delivered'">تحویل شده</span>
</template>
</el-table-column>
<el-table-column prop="date" label="تاریخ">
<template slot-scope="scope">
<span style="display: inline-block; direction: ltr">{{ $jDateTime(scope.row.date) }}</span>
</template>
</el-table-column>
</el-table>
</CCol>
</CRow>
</CCardBody>
</CCard>
</CCol>
<CCol lg="12">
<CCard>
<CCardBody>
<el-collapse>
<el-collapse-item title="مشخصات نماینده">
<CForm>
<CInput label="نام و نام خانوادگی" horizontal disabled :value="bufferRequest.agent_id.full_name" />
<CInput label="کد ملی" horizontal disabled :value="bufferRequest.agent_id.national_code" />
<CInput label="تلفن همراه" horizontal disabled :value="bufferRequest.agent_id.mobile_number" />
<CInput label="تلفن شرکت/تعمیرگاه" horizontal disabled :value="bufferRequest.agent_id.tel_number" />
<CInput label="فکس شرکت/تعمیرگاه" horizontal disabled :value="bufferRequest.agent_id.fax_number" />
<CInput label="استان" horizontal disabled :value="bufferRequest.agent_id.province_name" />
<CInput label="شهر" horizontal disabled :value="bufferRequest.agent_id.city_name" />
<CInput label="آدرس" horizontal disabled :value="bufferRequest.agent_id.address" />
<CInput label="کد پستی" horizontal disabled :value="bufferRequest.agent_id.postal_code" />
<CInput label="نام شرکت/تعمیرگاه" horizontal disabled :value="bufferRequest.agent_id.store_name" />
</CForm>
<el-divider></el-divider>
<div style="text-align: center">
<nuxt-link :to="{ name: 'admin-agents-agent', params: { agent: bufferRequest.user_id } }"
>مشاهده اکانت نماینده</nuxt-link
>
</div>
</el-collapse-item>
</el-collapse>
</CCardBody>
</CCard>
</CCol>
<CCol lg="12">
<CCard>
<CCardBody>
<CRow>
<CCol>
<CForm>
<CTextarea label="توضیحات فرم" horizontal disabled rows="5" :value="bufferRequest.description" />
</CForm>
<h6>لیست کالاهای بافر درخواستی:</h6>
<el-divider></el-divider>
<el-table :data="bufferRequest.items" style="width: 100%">
<el-table-column type="index" label="#"> </el-table-column>
<el-table-column prop="ItemName" label="نام کالا" width=""></el-table-column>
<el-table-column prop="bufferQuantity" label="تعداد" width=""></el-table-column>
</el-table>
</CCol>
</CRow>
</CCardBody>
</CCard>
</CCol>
</CRow>
</div>
</template>
<script>
export default {
name: 'AdminBufferRequestDetails',
layout: 'admin',
async asyncData({ $axios, params, error }) {
try {
const bufferRequest = await $axios.get(`/api/admin/br/${params.brId}`)
return {
bufferRequest: bufferRequest.data
}
} catch (e) {
error({ status: 404, message: 'Page not found' })
}
},
data() {
return {
title: 'مشاهده درخواست کالای بافر',
bufferRequest: null,
deliverPopover: false,
deliveryCode: '',
validation: {}
}
},
head() {
return {
title: this.title
}
},
methods: {
updateStatus(status) {
if (status === this.bufferRequest.status) return
if (this.bufferRequest.status === 'delivered') return
const title = 'هشدار'
function getMsg() {
const msg1 = 'با تغییر وضعیت فرم به در انتظار قطعه بلافاصله پیامک اطلاع رسانی برای نماینده ارسال خواهد شد'
const msg2 =
'با تغییر وضعیت فرم به تحویل شده بلافاصله پیامک اطلاع رسانی برای نماینده ارسال خواهد شد. توجه داشته باشید بعدا نمیتوانید کد ارسال مرسوله را تغییر دهید.'
if (status === 'ongoing') return msg1
else return msg2
}
this.$confirm(getMsg(), title, {
confirmButtonText: 'ادامه',
cancelButtonText: 'لغو',
type: 'warning'
})
.then(() => {
this.$axios
.put(`/api/admin/brStatus/${this.bufferRequest._id}`, { status, deliveryCode: this.deliveryCode })
.then(response => {
this.$message({
type: 'success',
message: response.data.message
})
this.deliveryCode = ''
this.$nuxt.refresh()
})
.catch(err => {
this.$message({
type: 'error',
message: err.response.data.message
})
})
})
.catch(() => {
this.$message({
type: 'warning',
message: 'عملیات لغو شد'
})
})
}
}
}
</script>