YY 2 年之前
父節點
當前提交
44a2d839c2

+ 6 - 0
src/layout/data/menu.js

@@ -94,6 +94,12 @@ export const adminMenu = [
         name: '订单管理',
         index: '3-3',
       },
+      {
+        icon: 'icon-rencai',
+        path: '/selfShop/goodsRate',
+        name: '商品评价',
+        index: '3-4',
+      },
       {
         icon: 'icon-rencai',
         path: '/selfShop/sales',

+ 12 - 0
src/router/module/selfShop.js

@@ -47,4 +47,16 @@ export default [
     meta: { title: '自营店铺-售后管理-审核' },
     component: () => import(/* webpackChunkName: "selfShop_sales_detail" */ '@/views/selfShop/sales/detail.vue'),
   },
+  {
+    path: '/selfShop/goodsRate',
+    name: 'selfShop_goodsRate',
+    meta: { title: '自营店铺-商品评价' },
+    component: () => import(/* webpackChunkName: "selfShop_goodsRate" */ '@/views/selfShop/goodsRate/index.vue'),
+  },
+  {
+    path: '/selfShop/goodsRate/detail',
+    name: 'selfShop_goodsRate_details',
+    meta: { title: '自营店铺-商品评价' },
+    component: () => import(/* webpackChunkName: "selfShop_goodsRate_detail" */ '@/views/selfShop/goodsRate/detail.vue'),
+  },
 ];

+ 3 - 0
src/store/index.js

@@ -22,6 +22,8 @@ import goods from './module/shop/goods';
 import serviceContact from './module/shop/serviceContact';
 import goodsSpec from './module/shop/goodsSpec';
 import afterSale from './module/shop/afterSale';
+import goodsRate from './module/shop/goodsRate';
+
 import order from './module/trade/order';
 import orderDetail from './module/trade/orderDetail';
 import sot from './module/trade/sot';
@@ -54,5 +56,6 @@ export default new Vuex.Store({
     sellTotal,
     actTags,
     config,
+    goodsRate,
   },
 });

+ 44 - 0
src/store/module/shop/goodsRate.js

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

+ 200 - 0
src/views/selfShop/goodsRate/detail.vue

@@ -0,0 +1,200 @@
+<template>
+  <div id="form-1">
+    <el-row>
+      <el-col :span="24" class="main animate__animated animate__backInRight">
+        <el-col class="top-btn">
+          <el-button type="primary" size="mini" @click="toBack()">返回</el-button>
+        </el-col>
+        <el-col :span="24" v-if="total == 0">
+          <el-empty description="该商品暂无评价"></el-empty>
+        </el-col>
+        <el-col :span="24" class="one" v-else-if="!total == 0">
+          <el-col :span="24" class="one_2">
+            <el-col :span="24" class="cont" v-for="(item, index) in list" :key="index">
+              <el-col :span="3" class="name">
+                <el-image class="icon" :src="item.customer.icon[0].url"></el-image>
+                <el-col>{{ item.customer.name }}</el-col>
+              </el-col>
+              <el-col :span="21">
+                <el-col>
+                  <el-rate v-model="item.goods_score" disabled score-template="{item.goods_score}" :colors="colors"> </el-rate>
+                </el-col>
+                <el-col>已购规格:{{ item.goodsSpec.name }}</el-col>
+                <el-col v-for="(replys, index) in item.reply" :key="index">
+                  <el-col :span="22" style="color: #f00">买家评价: {{ replys.content }}</el-col>
+                  <el-col v-for="(file, index) in replys.file" :key="index" :span="3">
+                    <el-image :src="file.url" class="image" :preview-src-list="replys.url"></el-image>
+                  </el-col>
+                  <el-col :span="22">商家回复:{{ replys.reply }}</el-col>
+                  <el-col style="color: #999">{{ replys.time }}</el-col>
+                  <el-col :span="12">
+                    <el-col :span="20">
+                      <el-input v-model="replys.reply" type="textarea" placeholder="请输入" size="small"></el-input>
+                    </el-col>
+                    <el-col :span="4">
+                      <el-button class="btn" type="primary" size="mini" @click="toSend(replys, item)">发送</el-button>
+                    </el-col>
+                  </el-col>
+                </el-col>
+              </el-col>
+            </el-col>
+          </el-col>
+          <el-col :span="24" class="pag">
+            <el-pagination
+              @current-change="currentChange"
+              :current-page.sync="skip"
+              :page-size="limit"
+              background
+              layout="total, prev, pager, next"
+              :total="total"
+            >
+            </el-pagination>
+          </el-col>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+const _ = require('lodash');
+const moment = require('moment');
+import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('goodsRate');
+const { mapActions: goods } = createNamespacedHelpers('goods');
+
+export default {
+  name: 'form-1',
+  props: {},
+  components: {},
+  data: function () {
+    return {
+      list: [],
+      goods: {},
+      skip: 1,
+      total: 0,
+      limit: 5,
+      // 评分
+      value: 4.0,
+      // 评分颜色
+      colors: ['#99A9BF', '#F7BA2A', '#FF0000'],
+      // 回复输入框
+      reply: '',
+      num: '0',
+    };
+  },
+  async created() {
+    await this.searchOther();
+    await this.search();
+  },
+  methods: {
+    ...mapActions(['query', 'fetch', 'create', 'update']),
+    ...goods({ goodsFetch: 'fetch' }),
+    // 查询
+    async search({ skip = 0, limit = 5, ...info } = {}) {
+      info.goods = this.id;
+      let res;
+      res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        for (const p1 of res.data) {
+          for (const p2 of p1.reply) {
+            let url = [];
+            if (p2.file) {
+              for (const p3 of p2.file) {
+                url.push(p3.url);
+              }
+              p2.url = url;
+            }
+          }
+        }
+        this.$set(this, 'list', res.data);
+        this.$set(this, 'total', res.total);
+      }
+      res = await this.goodsFetch(this.id);
+      if (this.$checkRes(res)) {
+        this.$set(this, `goods`, res.data);
+      }
+    },
+    // 分页
+    currentChange(val) {
+      this.search({ skip: (val - 1) * this.limit });
+    },
+    toReply() {
+      this.$set(this, 'num', '1');
+    },
+    async toSend(item, data) {
+      let res;
+      if (data.id) res = await this.update(data);
+      if (this.$checkRes(res)) {
+        this.$message({ type: `success`, message: `回复成功` });
+      }
+      this.search();
+    },
+    // 查询其他信息
+    async searchOther() {
+      let res;
+    },
+    // 返回
+    toBack() {
+      window.history.go('-1');
+    },
+  },
+  computed: {
+    id() {
+      return this.$route.query.id;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.el-col {
+  margin: 2px 0;
+}
+.one {
+  margin: 20px 0 0 0;
+  .one_1 {
+    margin: 15px 0;
+    padding: 10px;
+  }
+  .one_2 {
+    border: 1px solid #ccc;
+    padding: 10px;
+    .cont {
+      border-bottom: 1px solid rgb(238, 237, 237);
+      margin: 10px 0;
+      padding: 0 10px 10px 10px;
+      .name {
+        text-align: center;
+        .icon {
+          border-radius: 50%;
+          width: 100px;
+          height: 100px;
+        }
+      }
+      .image {
+        width: 100px;
+        height: 100px;
+        border: 1px solid #ccc;
+      }
+      .btn {
+        margin: 8px 15px;
+      }
+    }
+  }
+  .pag {
+    text-align: right;
+    margin: 10px 0;
+  }
+}
+</style>

+ 123 - 0
src/views/selfShop/goodsRate/index.vue

@@ -0,0 +1,123 @@
+<template>
+  <div id="index">
+    <el-row>
+      <el-col :span="24" class="main animate__animated animate__backInRight">
+        <el-col :span="24" class="one"> <span>商品评价</span> </el-col>
+        <el-col :span="24" class="two">
+          <search-1 :form="searchForm" @onSubmit="search" @toReset="toClose"></search-1>
+        </el-col>
+        <el-col :span="24" class="four">
+          <data-table
+            :select="true"
+            :selected="selected"
+            @handleSelect="handleSelect"
+            :fields="fields"
+            :opera="opera"
+            @query="search"
+            :data="list"
+            :total="total"
+            @edit="toEdit"
+          >
+          </data-table>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+const _ = require('lodash');
+import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
+const { mapActions: selfShop } = createNamespacedHelpers('selfShop');
+const { mapActions: goods } = createNamespacedHelpers('goods');
+const { mapActions: dictData } = createNamespacedHelpers('dictData');
+export default {
+  name: 'index',
+  props: {},
+  components: {
+    search1: () => import('./parts/search-1.vue'),
+  },
+  data: function () {
+    const that = this;
+    return {
+      // 列表
+      opera: [{ label: '查看评价', method: 'edit' }],
+      fields: [
+        { label: '商品名称', model: 'name' },
+        { label: '店铺名称', model: 'shop.name' },
+      ],
+      list: [],
+      total: 0,
+      // 查询
+      searchForm: {},
+      // 多选值
+      selected: [],
+      shop: {},
+    };
+  },
+  async created() {
+    await this.searchOther();
+    await this.search();
+  },
+  methods: {
+    ...dictData({ getDict: 'query' }),
+    ...selfShop(['getInfo', 'getGoods', 'goodsCreate']),
+    ...goods(['delete', 'fetch', 'update', 'create']),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      let condition = _.cloneDeep(this.searchForm);
+      let res = await this.getGoods({ skip, limit, ...condition, ...info, shop: _.get(this.shop, '_id') });
+      if (this.$checkRes(res)) {
+        this.$set(this, 'list', res.data);
+        this.$set(this, 'total', res.total);
+      }
+    },
+    // 修改
+    async toEdit({ data }) {
+      this.$router.push({ path: '/selfShop/goodsRate/detail', query: { id: data.id } });
+    },
+    // 重置
+    toClose() {
+      this.searchForm = {};
+      this.search();
+    },
+    // 多选
+    handleSelect(data) {
+      this.$set(this, `selected`, data);
+    },
+    async searchOther() {},
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.main {
+  .one {
+    margin: 0 0 10px 0;
+
+    span:nth-child(1) {
+      font-size: 20px;
+      font-weight: 700;
+      margin-right: 10px;
+    }
+  }
+  .two {
+    margin: 0 0 10px 0;
+  }
+  .thr {
+    margin: 0 0 10px 0;
+  }
+}
+</style>

+ 65 - 0
src/views/selfShop/goodsRate/parts/search-1.vue

@@ -0,0 +1,65 @@
+<template>
+  <div id="search-1">
+    <el-row>
+      <el-col :span="24" class="main">
+        <el-form :model="form" ref="form" label-width="130px">
+          <el-col :span="6">
+            <el-form-item label="名称" prop="name">
+              <el-input v-model="form.name" placeholder="请输入名称" size="small"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="24" class="btn">
+            <el-button type="primary" icon="el-icon-search" size="mini" @click="onSubmit('form')">搜索</el-button>
+            <el-button icon="el-icon-refresh" size="mini" @click="toReset('form')">重置</el-button>
+          </el-col>
+        </el-form>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+export default {
+  name: 'search-1',
+  props: { form: { type: Object }, typeList: { type: Array } },
+  components: {},
+  data: function () {
+    return {};
+  },
+  created() {},
+  methods: {
+    onSubmit() {
+      this.$emit('onSubmit');
+    },
+    toReset(formName) {
+      this.$refs[formName].resetFields();
+      this.$emit('toReset');
+    },
+  },
+  computed: {},
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.main {
+  .btn {
+    text-align: right;
+  }
+  /deep/.el-form-item {
+    float: left;
+    width: 100%;
+    margin: 0 0 10px 0;
+  }
+}
+</style>