guhongwei 3 gadi atpakaļ
vecāks
revīzija
957ad021ae
3 mainītis faili ar 50 papildinājumiem un 1 dzēšanām
  1. 6 0
      src/components/chat.vue
  2. 42 0
      src/store/chatRecord.js
  3. 2 1
      src/store/index.js

+ 6 - 0
src/components/chat.vue

@@ -49,6 +49,7 @@
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: clientApply } = createNamespacedHelpers('clientApply');
 const { mapActions: mapChat } = createNamespacedHelpers('chat');
+const { mapActions: chatRecord } = createNamespacedHelpers('chatRecord');
 export default {
   name: 'chat',
   props: {
@@ -73,12 +74,17 @@ export default {
   methods: {
     ...clientApply(['query']),
     ...mapChat(['create']),
+    ...chatRecord({ chatQuery: 'query' }),
     async search() {
       let res = await this.query({ ...this.userInfo });
       if (this.$checkRes(res)) {
         this.$set(this, `customer`, res.data);
         this.channel();
       }
+      let arr = await this.chatQuery({ client_id: this.customer.client_id, customer_id: this.customer.customer_id });
+      if (this.$checkRes(arr)) {
+        this.$set(this, `list`, arr.data);
+      }
     },
     // 区分发言人
     isSender(data) {

+ 42 - 0
src/store/chatRecord.js

@@ -0,0 +1,42 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  chatRecord: `/capi/chatRecord`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.chatRecord}`, {
+      skip,
+      limit,
+      ...info,
+    });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.chatRecord}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.chatRecord}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...data }) {
+    const res = await this.$axios.$post(`${api.chatRecord}/update/${id}`, data);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.chatRecord}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 2 - 1
src/store/index.js

@@ -2,6 +2,7 @@ import Vue from 'vue';
 import Vuex from 'vuex';
 import clientApply from './clientApply';
 import chat from './chat';
+import chatRecord from './chatRecord';
 
 Vue.use(Vuex);
 
@@ -9,5 +10,5 @@ export default new Vuex.Store({
   state: {},
   mutations: {},
   actions: {},
-  modules: { clientApply, chat },
+  modules: { clientApply, chat, chatRecord },
 });