| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434 |
- <template>
- <div class="AdminTicketShow"
- :style="localOptions.style">
- <div class="title">
- <div class="static-title">
- مشاهده پیام
- </div>
- <div class="dynamic-title">
- <template v-if="entityLoading">
- <q-skeleton type="text"
- class="q-ml-lg"
- width="100px" />
- </template>
- <template v-else>
- {{ packageTitle }}
- </template>
- </div>
- <div class="back-action">
- <q-btn flat
- color="grey"
- @click="$router.go(-1)">
- بازگشت
- >
- </q-btn>
- </div>
- </div>
- <q-card class="form"
- flat>
- <entity-edit v-if="mounted"
- ref="entityEdit"
- v-model:value="inputs"
- title="اطلاعات کاربری"
- :api="api"
- :entity-id-key="entityIdKey"
- :entity-param-key="entityParamKey"
- :show-route-name="showRouteName"
- :show-close-button="false"
- :show-edit-button="false"
- :show-expand-button="false"
- :show-save-button="false"
- :show-reload-button="false"
- :default-layout="false"
- :redirect-after-edit="false"
- :before-load-input-data="beforeLoadInputData"
- :after-load-input-data="afterLoadInputData" />
- <div class="row q-mt-lg justify-end">
- <div class="col-md-4 col-12">
- <q-btn color="primary"
- class="full-width"
- :loading="entityLoading"
- @click="edit">
- ثبت تغییرات
- </q-btn>
- </div>
- </div>
- <q-card v-if="mounted"
- class="q-mt-md">
- <q-card-section>
- <div class="row justify-center">
- <div class="full-width">
- <q-skeleton v-if="entityLoading"
- type="rect"
- width="100%"
- height="200px" />
- <template v-else>
- <q-chat-message v-for="message in repliesInfo"
- :key="message.id"
- :avatar="message.creator_info.picture ? message.creator_info.picture : 'assets/images/web/sample-avatar.svg'"
- :name="message.creator_info.firstname + ' ' + message.creator_info.lastname"
- text-html
- :text="[message.body]"
- :sent="!isUserMessage(authenticatedUser, message)">
- <template v-slot:stamp>
- <div>
- {{ miladiToShamsi(message.creation_time) }}
- </div>
- <q-btn icon="clear"
- round
- color="red"
- flat
- size="xs"
- @click="removeMessage(message.id)" />
- <q-icon v-if="isUserMessage(authenticatedUser, message)"
- :name="message.read ? 'done_all' : 'done'" />
- </template>
- </q-chat-message>
- <div>
- <q-input v-model="replyText"
- bottom-slots
- autogrow
- :loading="entityLoading">
- <template v-slot:after>
- <q-btn round
- dense
- flat
- icon="send"
- :loading="entityLoading"
- @click="sendReply" />
- </template>
- </q-input>
- </div>
- <div class="q-mt-md">
- <q-btn outline
- color="red"
- @click="closeTicket">
- بستن تیکت
- </q-btn>
- </div>
- </template>
- </div>
- </div>
- </q-card-section>
- </q-card>
- </q-card>
- <!-- <show-source :source-type="ticket.source_type"-->
- <!-- :source-id="ticket.source_id"-->
- <!-- :source="ticket.source" />-->
- <admin-invoice-show v-if="ticket.source_type === 'INVOICE' && ticket.source_id"
- :options="{invoiceId: ticket.source_id, showBackBtn: false}"
- class="q-mt-lg" />
- <q-card v-if="ticket.source_type === 'INVOICE' && ticket.source_id"
- class="q-mt-lg">
- <q-card-section>
- اقساط
- </q-card-section>
- <q-separator />
- <q-card-section>
- <installment-offers :installment-offers="instalmentOffers"
- :loading="entityLoading"
- :can-accept="false"
- :can-reject="false"
- @onReject="onReject"
- @onAccept="onAccept" />
- </q-card-section>
- <q-separator />
- <q-card-section>
- <create-installment :invoice-id="ticket.source_id"
- @onCreated="onCreateInstallmentOffer" />
- </q-card-section>
- </q-card>
- </div>
- </template>
- <script>
- import { shallowRef } from 'vue'
- import { EntityEdit } from 'quasar-crud'
- import { User } from 'src/models/User.js'
- import Assist from 'src/assets/js/Assist.js'
- import { Ticket } from 'src/models/Ticket.js'
- import { mixinWidget } from 'src/mixin/Mixins.js'
- import { APIGateway } from 'src/api/APIGateway.js'
- import { FormBuilderAssist } from 'quasar-form-builder'
- import BtnControl from 'src/components/Control/btn.vue'
- import { InstalmentOfferList } from 'src/models/InstalmentOffer.js'
- import { TicketCategory, TicketCategoryList } from 'src/models/TicketCategory.js'
- // import ShowSource from 'src/components/Widgets/Ticket/AdminTicketShow/ShowSource.vue'
- import AdminInvoiceShow from 'src/components/Widgets/Invoice/AdminInvoiceShow/AdminInvoiceShow.vue'
- import InstallmentOffers from 'src/components/Widgets/Ticket/AdminTicketShow/InstallmentOffers.vue'
- import CreateInstallment from 'src/components/Widgets/Ticket/AdminTicketShow/CreateInstallment.vue'
- const BtnControlComp = shallowRef(BtnControl)
- export default {
- name: 'AdminTicketShow',
- components: {
- EntityEdit,
- // ShowSource,
- AdminInvoiceShow,
- CreateInstallment,
- InstallmentOffers
- },
- mixins: [mixinWidget],
- data () {
- const ticketId = this.$route.params.id
- return {
- replyText: null,
- mounted: false,
- entityLoading: true,
- packageTitle: '',
- ticket: new Ticket(),
- authenticatedUser: new User(),
- api: APIGateway.ticket.APIAdresses.byId(ticketId),
- ticketCategoryList: new TicketCategoryList(),
- entityIdKey: 'id',
- entityParamKey: 'id',
- showRouteName: 'Admin.Ticket.Show',
- indexRouteName: 'Admin.Ticket.List',
- inputs: [
- { type: 'separator', name: 'space', label: 'مشخصات کاربر', className: 'custom-separator', col: 'col-12' },
- { type: 'hidden', name: 'userId', responseKey: 'creator_info.id', disable: true },
- { type: 'input', name: 'creator_info.firstname', responseKey: 'creator_info.firstname', label: 'نام', placeholder: ' ', disable: true, col: 'col-md-2 col-12' },
- { type: 'input', name: 'creator_info.lastname', responseKey: 'creator_info.lastname', label: 'نام خانوادگی', placeholder: ' ', disable: true, col: 'col-md-2 col-12' },
- { type: 'input', name: 'creator_info.mobile_number', responseKey: 'creator_info.mobile_number', label: 'شماره موبایل', placeholder: ' ', disable: true, col: 'col-md-3 col-12' },
- { type: 'input', name: 'creator_info.email', responseKey: 'creator_info.email', label: 'ایمیل', placeholder: ' ', disable: true, col: 'col-md-3 col-12' },
- { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'مشخصات کاربر', placeholder: ' ', atClick: () => {}, col: 'col-md-2 col-12' },
- { type: 'separator', name: 'space', label: 'مشخصات تیکت', className: 'custom-separator', col: 'col-12' },
- {
- type: 'select',
- name: 'category_info__type',
- responseKey: 'category_info.type',
- options: (new TicketCategory()).typeEnums,
- label: 'معاونت',
- placeholder: ' ',
- col: 'col-md-4 col-12'
- },
- { type: 'select', name: 'category', responseKey: 'category', placeholder: ' ', options: [], label: 'دسته', col: 'col-md-4 col-12' },
- { type: 'select', name: 'status', responseKey: 'status', options: (new Ticket()).statusEnums, multiple: false, label: 'وضعیت', placeholder: ' ', readonly: true, col: 'col-md-4 col-12' },
- { type: 'file', name: 'attachment', responseKey: 'attachment', placeholder: ' ', label: 'ضمیمه', readonly: true, col: 'col-md-6 col-12' },
- { type: 'dateTime', name: 'creation_time', responseKey: 'creation_time', outsideLabel: 'تاریخ ایجاد', readonly: true, col: 'col-md-6 col-12' },
- { type: 'input', name: 'title', responseKey: 'title', label: 'عنوان', placeholder: ' ', readonly: true, col: 'col-md-12 col-12' },
- { type: 'inputEditor', name: 'body', responseKey: 'body', label: 'متن', placeholder: ' ', readonly: true, col: 'col-md-12 col-12' },
- { type: 'hidden', name: 'source_type', responseKey: 'source_type', value: null },
- { type: 'hidden', name: 'source_id', responseKey: 'source_id', value: null },
- { type: 'hidden', name: 'id', responseKey: 'id' },
- { type: 'hidden', name: 'owner', responseKey: 'owner' },
- { type: 'hidden', name: 'replies_info', responseKey: 'replies_info' }
- ]
- }
- },
- computed: {
- selectedCategoryInfoType () {
- return FormBuilderAssist.getInputsByName(this.inputs, 'category_info__type')?.value
- },
- instalmentOffers () {
- return new InstalmentOfferList(this.ticket.source?.instalment_offers_info)
- },
- repliesInfo () {
- return this.inputs.find(input => input.name === 'replies_info').value
- }
- },
- watch: {
- selectedCategoryInfoType () {
- FormBuilderAssist.setAttributeByName(this.inputs, 'category', 'value', null)
- this.loadCategories()
- }
- },
- created() {
- FormBuilderAssist.setAttributeByName(this.inputs, 'btn', 'atClick', () => {
- const userId = FormBuilderAssist.getInputsByName(this.inputs, 'userId').value
- this.$router.push({ name: 'Admin.User.Show', params: { id: userId } })
- })
- },
- mounted() {
- this.loadAuthData()
- this.checkSource()
- this.loadOptions()
- .then(() => {
- this.$nextTick(() => {
- this.mounted = true
- })
- })
- .catch(() => {
- this.mounted = true
- })
- },
- methods: {
- closeTicket () {
- this.$q.dialog({
- title: 'توجه',
- message: 'آیا از بستن تیکت اطمینان دارید؟',
- cancel: true,
- persistent: true
- }).onOk(() => {
- this.entityLoading = true
- APIGateway.ticket.close(this.$route.params.id)
- .then(() => {
- this.$refs.entityEdit.getData()
- })
- .catch(() => {
- this.entityLoading = false
- })
- })
- },
- miladiToShamsi (miladi) {
- return Assist.miladiToShamsi(miladi)
- },
- isUserMessage (authenticatedUser, message) {
- return authenticatedUser.id === message.creator_info.id
- },
- removeMessage (replyMessageId) {
- this.$q.dialog({
- title: 'توجه',
- message: 'آیا از حذف پیام اطمینان دارید؟',
- cancel: true,
- persistent: true
- }).onOk(() => {
- this.entityLoading = true
- APIGateway.ticket.deleteReplyMessage(replyMessageId)
- .then(() => {
- this.$refs.entityEdit.getData()
- })
- .catch(() => {
- this.entityLoading = false
- })
- })
- },
- onReject (offer) {
- this.entityLoading = true
- APIGateway.instalmentOffer.reject(offer.id)
- .then(() => {
- this.$refs.entityEdit.getData()
- })
- .catch(() => {
- this.$refs.entityEdit.getData()
- })
- },
- onAccept (offer) {
- this.entityLoading = true
- APIGateway.instalmentOffer.accept(offer.id)
- .then(() => {
- this.$refs.entityEdit.getData()
- })
- .catch(() => {
- this.$refs.entityEdit.getData()
- })
- },
- onCreateInstallmentOffer () {
- this.$refs.entityEdit.getData()
- },
- checkSource () {
- if (this.localOptions.defaultSourceType) {
- FormBuilderAssist.setAttributeByName(this.inputs, 'source_type', 'value', this.localOptions.defaultSourceType)
- }
- },
- loadAuthData () {
- this.authenticatedUser = this.$store.getters['Auth/user']
- },
- beforeLoadInputData (data) {
- this.entityLoading = false
- this.ticket = new Ticket(data)
- },
- afterLoadInputData () {
- this.$nextTick(() => {
- FormBuilderAssist.setAttributeByName(this.inputs, 'category', 'value', this.ticket.category)
- })
- },
- edit() {
- this.entityLoading = true
- this.$refs.entityEdit.editEntity()
- .then(() => {
- this.$refs.entityEdit.getData()
- })
- .catch(() => {
- this.$refs.entityEdit.getData()
- })
- },
- loadOptions () {
- return this.loadCategories()
- },
- loadCategories () {
- return new Promise((resolve, reject) => {
- const type = this.selectedCategoryInfoType
- // if (!type) {
- // return
- // }
- this.categoriesLoading = true
- APIGateway.ticketCategory.index({ type })
- .then(({ list }) => {
- const ticketCategoryList = list
- FormBuilderAssist.setAttributeByName(this.inputs, 'category', 'options', ticketCategoryList.list.map(item => {
- return {
- value: item.id,
- label: item.title
- }
- }))
- this.categoriesLoading = false
- this.$nextTick(() => {
- resolve()
- })
- })
- .catch(() => {
- this.categoriesLoading = false
- this.$nextTick(() => {
- reject()
- })
- })
- })
- },
- sendReply() {
- this.entityLoading = true
- const body = this.replyText.replace(/\n/g, '<br>\n')
- APIGateway.ticket.reply({
- id: this.$route.params.id,
- body
- })
- .then(() => {
- this.$refs.entityEdit.getData()
- })
- .catch(() => {
- this.$refs.entityEdit.getData()
- })
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .AdminTicketShow {
- .title {
- font-style: normal;
- font-weight: 700;
- font-size: 24px;
- line-height: 140%;
- color: #424242;
- margin-bottom: 27px;
- display: flex;
- flex-flow: row;
- position: relative;
- .static-title {
- }
- .dynamic-title {
- }
- .back-action {
- position: absolute;
- right: 0;
- top: 0;
- }
- }
- :deep(.form) {
- padding: 24px;
- }
- }
- </style>
|