1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-11 05:11:59 +08:00

changing chat structure and asynchronous methods (#298)

* changing chat structure and asynchronous methods

* changing descending order

* reverse changes

* change constante

* clear notes when new record

* clear notes when new record

* rename change history to activities
This commit is contained in:
elsiosanchez 2020-02-04 10:38:58 -04:00 committed by GitHub
parent ecf2de8b19
commit 94788e0e7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 107 additions and 82 deletions

View File

@ -464,6 +464,7 @@ export function requestListWorkflows({
* @param {string} pageSize
*/
export function requestListRecordChats({ tableName, recordId, pageToken, pageSize }) {
console.log(tableName, recordId, Instance.call(this).requestListRecordChats({ tableName, recordId, pageToken, pageSize }))
return Instance.call(this).requestListRecordChats({
tableName,
recordId,
@ -478,6 +479,7 @@ export function requestListRecordChats({ tableName, recordId, pageToken, pageSiz
* @param {string} pageSize
*/
export function requestListChatEntries({ uuid, pageToken, pageSize }) {
console.log(uuid, Instance.call(this).requestListChatEntries({ uuid, pageToken, pageSize }))
return Instance.call(this).requestListChatEntries({
uuid,
pageToken,

View File

@ -271,7 +271,7 @@ export default {
undoNew: 'Undo New Record',
containerInfo: {
notes: 'Notes',
changeLog: 'Change Log',
changeLog: 'ACtivity',
workflowLog: 'Workflow Log',
changeDetail: 'Change detail',
logWorkflow: {
@ -279,7 +279,7 @@ export default {
responsible: 'Responsible',
workflowName: 'Name of Workflow Status',
timeElapsed: 'Time Elapsed',
addNote: 'Notas'
addNote: 'Add Note'
}
}
},

View File

@ -246,7 +246,7 @@ export default {
undoNew: 'Descartar Nuevo Registro',
containerInfo: {
notes: 'Notas',
changeLog: 'Histórico de Cambios',
changeLog: 'Actividad',
workflowLog: 'Histórico de Flujo de Trabajo',
changeDetail: 'Detalle del cambio',
logWorkflow: {
@ -254,7 +254,7 @@ export default {
responsible: 'Responsable',
workflowName: 'Nombre de estado del flujo de trabajo',
timeElapsed: 'Tiempo transcurrido',
addNote: 'Notas'
addNote: 'Agregar Nota'
}
}
},

View File

@ -8,7 +8,8 @@ const containerInfo = {
listRecordChats: [],
listChatEntries: [],
listWorkflows: [],
note: []
note: [],
isNote: false
},
mutations: {
addListWorkflow(state, payload) {
@ -28,6 +29,9 @@ const containerInfo = {
},
addNote(state, payload) {
state.note = payload
},
isNote(state, payload) {
state.isNote = payload
}
},
actions: {
@ -37,12 +41,16 @@ const containerInfo = {
const comment = params.comment
return requestCreateChatEntry({ tableName, recordId, comment })
.then(response => {
commit('isNote', true)
dispatch('listChatEntries', {
tableName: params.tableName,
recordId: params.recordId
tableName: tableName,
recordId: recordId
})
commit('addNote', response)
})
.catch(error => {
console.warn(`Error getting epale error en guardar: ${error.message}. Code: ${error.code}.`)
})
},
listWorkflowLogs({ commit, state, dispatch }, params) {
const tableName = params.tableName
@ -65,6 +73,9 @@ const containerInfo = {
console.warn(`Error getting List workflow: ${error.message}. Code: ${error.code}.`)
})
},
isNote({ commit }, params) {
commit('isNote', params)
},
listWorkflows({ commit, state }, params) {
const tableName = params.tableName
const pageSize = 0
@ -105,9 +116,9 @@ const containerInfo = {
var listRecord = {
recordChatsList: response.recordChatsList,
recordCount: response.recordCount,
epale: isEmptyValue(response.recordChatsList),
nextPageToken: response.nextPageToken
}
commit('isNote', !isEmptyValue(response.recordChatsList))
dispatch('listRecordChat', {
chatUuid: response.recordChatsList[0].chatUuid
})
@ -143,10 +154,16 @@ const containerInfo = {
return state.listRecordLogs
},
getListRecordChats: (state) => {
return state.listRecordChats
return state.listRecordChats.recordChatsList
},
getChatEntries: (state) => {
return state.listChatEntries
},
getAddNote: (state) => {
return state.note
},
getIsNote: (state) => {
return state.isNote
}
}
}

View File

@ -158,6 +158,51 @@
<p v-if="show">
<el-card class="box-card">
<el-tabs v-model="activeInfo" @tab-click="handleClick">
<el-tab-pane
name="listChatEntries"
>
<span slot="label"><i class="el-icon-s-comment" /> {{ $t('window.containerInfo.notes') }} </span>
<div
v-if="getIsChat"
>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>{{ $t('window.containerInfo.notes') }}</span>
</div>
<el-scrollbar wrap-class="scroll-window-log-chat">
<el-timeline>
<el-timeline-item
v-for="(chats, key) in gettersLischat"
:key="key"
:timestamp="translateDate(chats.logDate)"
placement="top"
>
<el-card shadow="hover">
<div>
<span>{{ chats.userName }}</span>
<span>{{ chats.characterData }}</span>
</div>
</el-card>
</el-timeline-item>
</el-timeline>
</el-scrollbar>
</el-card>
</div>
<div>
<el-card class="box-card">
<div slot="header" class="clearfix">
{{ $t('window.containerInfo.logWorkflow.addNote') }}
</div>
<el-input
v-model="chatNote"
type="textarea"
:rows="2"
placeholder="Please input"
/>
<el-button icon="el-icon-circle-check" type="text" style="float: right" @click="sendComment(chatNote)" />
</el-card>
</div>
</el-tab-pane>
<el-tab-pane
name="listRecordLogs"
>
@ -202,6 +247,7 @@
/>
</el-tab-pane>
<el-tab-pane
v-if="getIsWorkflowLog"
name="listWorkflowLogs"
>
<span slot="label"><i class="el-icon-s-help" /> {{ $t('window.containerInfo.workflowLog') }} </span>
@ -265,51 +311,6 @@
class="loading-window"
/>
</el-tab-pane>
<el-tab-pane
name="listChatEntries"
>
<span slot="label"><i class="el-icon-s-comment" /> {{ $t('window.containerInfo.notes') }} </span>
<div
v-if="!gettersLisRecordChats.epale"
>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>{{ $t('window.containerInfo.notes') }}</span>
</div>
<el-scrollbar wrap-class="scroll-window-log-chat">
<el-timeline>
<el-timeline-item
v-for="(chats, key) in gettersLischat"
:key="key"
:timestamp="translateDate(chats.logDate)"
placement="top"
>
<el-card shadow="hover">
<div>
<span>{{ chats.userName }}</span>
<span>{{ chats.characterData }}</span>
</div>
</el-card>
</el-timeline-item>
</el-timeline>
</el-scrollbar>
</el-card>
</div>
<div>
<el-card class="box-card">
<div slot="header" class="clearfix">
{{ $t('window.containerInfo.logWorkflow.addNote') }}
</div>
<el-input
v-model="chatNote"
type="chatNote"
:rows="2"
placeholder="Please input"
@keyup.enter.native="sendComment(chatNote)"
/>
</el-card>
</div>
</el-tab-pane>
</el-tabs>
</el-card>
</p>
@ -358,7 +359,7 @@ export default {
panelType: 'window',
isLoaded: false,
isPanel: false,
activeInfo: 'listRecordLogs',
activeInfo: 'listChatEntries',
show: false,
chatNote: '',
typeAction: 0,
@ -470,7 +471,16 @@ export default {
return false
},
gettersListRecordLogs() {
return this.$store.getters.getRecordLogs.recorLogs
const changeLog = this.$store.getters.getRecordLogs.recorLogs
if (this.isEmptyValue(changeLog)) {
return changeLog
}
changeLog.sort((a, b) => {
var c = new Date(a.logDate)
var d = new Date(b.logDate)
return d - c
})
return changeLog
},
getIsChangeLog() {
if (this.isEmptyValue(this.gettersListRecordLogs)) {
@ -485,10 +495,7 @@ export default {
return true
},
getIsChat() {
if (this.isEmptyValue(this.gettersLisRecordChats)) {
return false
}
return true
return this.$store.getters.getIsNote
},
getTypeLogs() {
const groupLog = this.gettersListRecordLogs.reduce((groupLog, item) => {
@ -509,8 +516,11 @@ export default {
gettersLischat() {
return this.$store.getters.getChatEntries.chatEntriesList
},
gettersLisRecordChats() {
return this.$store.getters.getListRecordChats
// gettersLisRecordChats() {
// return this.$store.getters.getListRecordChats[0].description
// },
isNote() {
return this.$store.getters.getIsNote
},
gettersListWorkflow() {
return this.$store.getters.getWorkflow
@ -527,10 +537,12 @@ export default {
},
watch: {
$route(value) {
this.$store.dispatch('listChatEntries', {
tableName: value.params.tableName,
recordId: value.params.recordId
})
if (this.show) {
if (value.query.action === 'create-new') {
this.$store.dispatch('isNote', false)
}
this.refres(this.activeInfo)
}
},
'this.$route.params'(newValue, oldValue) {
if (!this.isEmptyValue(newValue)) {
@ -549,6 +561,10 @@ export default {
comment: comment
})
this.chatNote = ''
// this.$store.dispatch('listChatEntries', {
// tableName: this.$route.params.tableName,
// recordId: this.$route.params.recordId
// })
},
showkey(key, index) {
if (key === this.currentKey && index === this.typeAction) {
@ -571,17 +587,15 @@ export default {
},
conteInfo() {
this.show = !this.show
this.$store.dispatch('listWorkflowLogs', {
tableName: this.$route.params.tableName,
recordId: this.$route.params.recordId
})
this.$store.dispatch('listChatEntries', {
tableName: this.$route.params.tableName,
recordId: this.$route.params.recordId
})
this.$store.dispatch('showContainerInfo', !this.getterShowContainerInfo)
if (this.show) {
this.$store.dispatch('listRecordLogs', {
tableName: this.$route.params.tableName,
recordId: this.$route.params.recordId
})
}
},
handleClick(tab, event) {
this.$store.dispatch(tab.name, {
@ -589,16 +603,8 @@ export default {
recordId: this.$route.params.recordId
})
},
refres() {
this.$store.dispatch('listWorkflowLogs', {
tableName: this.$route.params.tableName,
recordId: this.$route.params.recordId
})
this.$store.dispatch('listRecordLogs', {
tableName: this.$route.params.tableName,
recordId: this.$route.params.recordId
})
this.$store.dispatch('listChatEntries', {
refres(tabInfo) {
this.$store.dispatch(tabInfo, {
tableName: this.$route.params.tableName,
recordId: this.$route.params.recordId
})