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
+110
View File
@@ -0,0 +1,110 @@
<template>
<user-dashboard-container page-class="guarantee-details ticket-messenger" :panel-title="conversation.title">
<div class="messenger">
<h3 class="messenger-title">پیام ها:</h3>
<div class="messenger-body">
<div class="messages" :class="!conversation.messages.length ? 'no-msg' : null">
<!-- no-msg -->
<p v-if="!conversation.messages.length">هیچ پیامی وجود ندارد.</p>
<div
v-for="item in conversation.messages"
:key="item._id"
class="message user"
:class="[item.isUser ? 'user' : 'asan-admin', !item.read && !item.isUser ? 'unread' : null]"
>
<div class="txt">
<img v-if="item.image" :src="item.image" alt="" />
<p>{{ item.message }}</p>
<p class="date">{{ $jDateTime(item.created_at) }}</p>
</div>
<user-icon />
</div>
</div>
<div class="newMsg">
<div class="relativePos">
<input v-model="message" type="text" placeholder="پیام خود را بنویسید" />
<label for="file"></label>
<input id="file" ref="attachment" type="file" @change="preview" />
<img v-if="attachment" :src="attachment" alt="" />
<i v-if="attachment" id="clearFile" class="fas fa-times-circle" @click="clearFile"></i>
<button class="btn btn-primary" :disabled="!message && !attachment" @click="sendMessage">ارسال</button>
<div class="validationMsg">
<p v-if="validation.message">{{ validation.message.msg }}</p>
<p v-if="validation.image">{{ validation.image.msg }}</p>
</div>
</div>
</div>
</div>
</div>
</user-dashboard-container>
</template>
<script>
import axiosUploadProcess from '@/mixins/axiosUploadProcess'
export default {
name: 'AccountTicketDetails',
mixins: [axiosUploadProcess],
layout: 'user',
async asyncData({ $axios, params, error }) {
try {
const conversation = await $axios.get(`/api/user/getTicket/${params.ticket}`)
return {
conversation: conversation.data
}
} catch (e) {
error({ status: 404, message: 'Page not found' })
}
},
data() {
return {
conversation: null,
message: '',
attachment: '',
validation: {}
}
},
methods: {
preview(event) {
this.attachment = URL.createObjectURL(event.target.files[0])
},
clearFile() {
this.attachment = null
this.$refs.attachment.value = null
},
sendMessage() {
this.validation = {}
const data = new FormData()
data.append('message', this.message)
if (this.$refs.attachment.files[0]) data.append('image', this.$refs.attachment.files[0])
this.$axios
.post(`/api/user/addMessageToTicket/${this.conversation._id}`, data, this.axiosConfig)
.then(res => {
this.$message({
type: 'success',
message: 'پیام با موفقیت ارسال شد.'
})
this.attachment = ''
this.message = ''
this.$refs.attachment.value = null
this.conversation = res.data
setTimeout(() => {
window.scrollTo(0, document.body.scrollHeight)
}, 100)
})
.catch(err => {
if (err.response.data.status === 401) {
return this.$message({
type: 'warning',
message: 'لطفا دوباره وارد حساب خود شوید'
})
}
if (err.response.status === 422) this.validation = err.response.data.validation
else console.log(err)
})
}
}
}
</script>
+78
View File
@@ -0,0 +1,78 @@
<template>
<user-dashboard-container page-class="tickets" panel-title="لیست تیکت ها">
<div class="tableBox">
<table class="tickets">
<thead>
<tr>
<th class="index">ردیف</th>
<th class="title">عنوان</th>
<th class="transactionId">شماره پذیرش</th>
<th class="date">تاریخ ایجاد مکالمه</th>
<th class="details">جزئیات</th>
</tr>
</thead>
<tbody>
<template v-if="conversations.length">
<tr v-for="(item, index) in conversations" :key="item._id" :title="item.title">
<td class="index">
<span>{{ index + 1 }}</span>
</td>
<td class="title">
<span class="singleLineTxt">{{ item.title }}</span>
</td>
<td class="transactionId">
<span>{{ item.transaction_id ? item.transaction_id : '-' }}</span>
</td>
<td class="date">
<span>{{ $jDate(item.created_at) }}</span>
</td>
<td class="rowButtons details">
<nuxt-link
:to="{ name: 'account-tickets-ticket', params: { ticket: item._id } }"
class="btn btn-primary"
>
<span>مشاهده</span>
<i v-if="hasUnread(item._id)">{{ hasUnread(item._id) }}</i>
</nuxt-link>
</td>
</tr>
</template>
<tr v-else>
<td class="noItem">
<span>هیچ اطلاعاتی وجود ندارد</span>
</td>
</tr>
</tbody>
</table>
</div>
<table-notice />
</user-dashboard-container>
</template>
<script>
export default {
name: 'AccountTicketList',
layout: 'user',
async asyncData({ $axios, error }) {
try {
const conversations = await $axios.get('/api/user/ticketConversations')
return {
conversations: conversations.data
}
} catch (e) {
error({ status: 500, message: 'There is a problem here' })
}
},
data() {
return {
conversations: null
}
},
methods: {
hasUnread(id) {
const conversation = this.conversations.filter(item => item._id === id)[0]
return conversation.messages.filter(item => !item.read && !item.isUser).length
}
}
}
</script>