1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-14 07:41:57 +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 * @param {string} pageSize
*/ */
export function requestListRecordChats({ tableName, recordId, pageToken, 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({ return Instance.call(this).requestListRecordChats({
tableName, tableName,
recordId, recordId,
@ -478,6 +479,7 @@ export function requestListRecordChats({ tableName, recordId, pageToken, pageSiz
* @param {string} pageSize * @param {string} pageSize
*/ */
export function requestListChatEntries({ uuid, pageToken, pageSize }) { export function requestListChatEntries({ uuid, pageToken, pageSize }) {
console.log(uuid, Instance.call(this).requestListChatEntries({ uuid, pageToken, pageSize }))
return Instance.call(this).requestListChatEntries({ return Instance.call(this).requestListChatEntries({
uuid, uuid,
pageToken, pageToken,

View File

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

View File

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

View File

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

View File

@ -158,6 +158,51 @@
<p v-if="show"> <p v-if="show">
<el-card class="box-card"> <el-card class="box-card">
<el-tabs v-model="activeInfo" @tab-click="handleClick"> <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 <el-tab-pane
name="listRecordLogs" name="listRecordLogs"
> >
@ -202,6 +247,7 @@
/> />
</el-tab-pane> </el-tab-pane>
<el-tab-pane <el-tab-pane
v-if="getIsWorkflowLog"
name="listWorkflowLogs" name="listWorkflowLogs"
> >
<span slot="label"><i class="el-icon-s-help" /> {{ $t('window.containerInfo.workflowLog') }} </span> <span slot="label"><i class="el-icon-s-help" /> {{ $t('window.containerInfo.workflowLog') }} </span>
@ -265,51 +311,6 @@
class="loading-window" class="loading-window"
/> />
</el-tab-pane> </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-tabs>
</el-card> </el-card>
</p> </p>
@ -358,7 +359,7 @@ export default {
panelType: 'window', panelType: 'window',
isLoaded: false, isLoaded: false,
isPanel: false, isPanel: false,
activeInfo: 'listRecordLogs', activeInfo: 'listChatEntries',
show: false, show: false,
chatNote: '', chatNote: '',
typeAction: 0, typeAction: 0,
@ -470,7 +471,16 @@ export default {
return false return false
}, },
gettersListRecordLogs() { 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() { getIsChangeLog() {
if (this.isEmptyValue(this.gettersListRecordLogs)) { if (this.isEmptyValue(this.gettersListRecordLogs)) {
@ -485,10 +495,7 @@ export default {
return true return true
}, },
getIsChat() { getIsChat() {
if (this.isEmptyValue(this.gettersLisRecordChats)) { return this.$store.getters.getIsNote
return false
}
return true
}, },
getTypeLogs() { getTypeLogs() {
const groupLog = this.gettersListRecordLogs.reduce((groupLog, item) => { const groupLog = this.gettersListRecordLogs.reduce((groupLog, item) => {
@ -509,8 +516,11 @@ export default {
gettersLischat() { gettersLischat() {
return this.$store.getters.getChatEntries.chatEntriesList return this.$store.getters.getChatEntries.chatEntriesList
}, },
gettersLisRecordChats() { // gettersLisRecordChats() {
return this.$store.getters.getListRecordChats // return this.$store.getters.getListRecordChats[0].description
// },
isNote() {
return this.$store.getters.getIsNote
}, },
gettersListWorkflow() { gettersListWorkflow() {
return this.$store.getters.getWorkflow return this.$store.getters.getWorkflow
@ -527,10 +537,12 @@ export default {
}, },
watch: { watch: {
$route(value) { $route(value) {
this.$store.dispatch('listChatEntries', { if (this.show) {
tableName: value.params.tableName, if (value.query.action === 'create-new') {
recordId: value.params.recordId this.$store.dispatch('isNote', false)
}) }
this.refres(this.activeInfo)
}
}, },
'this.$route.params'(newValue, oldValue) { 'this.$route.params'(newValue, oldValue) {
if (!this.isEmptyValue(newValue)) { if (!this.isEmptyValue(newValue)) {
@ -549,6 +561,10 @@ export default {
comment: comment comment: comment
}) })
this.chatNote = '' this.chatNote = ''
// this.$store.dispatch('listChatEntries', {
// tableName: this.$route.params.tableName,
// recordId: this.$route.params.recordId
// })
}, },
showkey(key, index) { showkey(key, index) {
if (key === this.currentKey && index === this.typeAction) { if (key === this.currentKey && index === this.typeAction) {
@ -571,17 +587,15 @@ export default {
}, },
conteInfo() { conteInfo() {
this.show = !this.show this.show = !this.show
this.$store.dispatch('listWorkflowLogs', {
tableName: this.$route.params.tableName,
recordId: this.$route.params.recordId
})
this.$store.dispatch('listChatEntries', { this.$store.dispatch('listChatEntries', {
tableName: this.$route.params.tableName, tableName: this.$route.params.tableName,
recordId: this.$route.params.recordId recordId: this.$route.params.recordId
}) })
this.$store.dispatch('showContainerInfo', !this.getterShowContainerInfo) 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) { handleClick(tab, event) {
this.$store.dispatch(tab.name, { this.$store.dispatch(tab.name, {
@ -589,16 +603,8 @@ export default {
recordId: this.$route.params.recordId recordId: this.$route.params.recordId
}) })
}, },
refres() { refres(tabInfo) {
this.$store.dispatch('listWorkflowLogs', { this.$store.dispatch(tabInfo, {
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', {
tableName: this.$route.params.tableName, tableName: this.$route.params.tableName,
recordId: this.$route.params.recordId recordId: this.$route.params.recordId
}) })