Bladeren bron

Merge branch 'master' of http://git.cc-lotus.info/pointToNetwork/web-admin

YY 2 jaren geleden
bovenliggende
commit
ca0dcfafe2

+ 15 - 1
src/components/usual/c-form.vue

@@ -47,7 +47,7 @@
                   </el-radio-group>
                 </template>
                 <template v-else-if="item.type === 'checkbox'">
-                  <el-checkbox-group v-model="form[item.model]" @change="dataChange(item.model)" v-bind="item.options">
+                  <el-checkbox-group v-model="form[item.model]" v-bind="item.options">
                     <slot :name="item.model" v-bind="{ item }"></slot>
                   </el-checkbox-group>
                 </template>
@@ -64,6 +64,20 @@
                     <slot :name="item.model" v-bind="{ item }"></slot>
                   </el-select>
                 </template>
+                <template v-else-if="item.type === 'selectMany'">
+                  <el-select
+                    v-model="form[item.model]"
+                    v-bind="item.options"
+                    multiple
+                    filterable
+                    clearable
+                    @change="dataChange(item.model)"
+                    style="width: 100%"
+                    :disabled="item.readonly"
+                  >
+                    <slot :name="item.model" v-bind="{ item }"></slot>
+                  </el-select>
+                </template>
                 <template v-else-if="item.type === 'textarea'">
                   <el-input
                     clearable

+ 4 - 3
src/components/usual/c-upload.vue

@@ -7,7 +7,7 @@
       :limit="limit"
       :accept="accept"
       :list-type="listType"
-      :file-list="fileList"
+      :file-list="list"
       :on-exceed="outLimit"
       :on-preview="filePreview"
       :on-success="onSuccess"
@@ -26,7 +26,6 @@
 
 <script>
 import _ from 'lodash';
-import { createLogger } from 'vuex';
 export default {
   name: 'c-upload',
   props: {
@@ -82,8 +81,10 @@ export default {
     },
     // 删除图片
     onRemove(file, fileList) {
+      console.log(file);
       let list = _.cloneDeep(this.list);
-      list = list.filter((f) => f.uri !== _.get(file, 'response.uri'));
+      console.log(list);
+      list = list.filter((f) => f.uri !== _.get(file, 'uri'));
       this.$emit('change', list);
       return true;
     },

+ 0 - 116
src/layout/header/activitys.vue

@@ -1,116 +0,0 @@
-<template>
-  <div id="activitys">
-    <template v-if="view === 'lab'">
-      <div class="view">
-        当前处于:
-        <el-tooltip class="item" effect="dark" placement="bottom">
-          <template #content> {{ getProp('start_time') }} 至 {{ getProp('end_time') }} </template>
-          <el-link>{{ getProp('year') }}年度-{{ getProp('name') }}</el-link>
-        </el-tooltip>
-        时间内
-      </div>
-    </template>
-    <template v-else-if="view === 'admin'">
-      <el-row class="rows">
-        <el-col :span="24">当前处于:</el-col>
-        <el-col :span="24" v-if="preparing._id">
-          筹建期:
-          <el-tooltip class="item" effect="dark" placement="bottom">
-            <template #content> {{ getProp('start_time', preparing) }} 至 {{ getProp('end_time', preparing) }} </template>
-            <el-link>{{ getProp('year', preparing) }}年度-{{ getProp('name', preparing) }}</el-link>
-          </el-tooltip>
-          时间内
-          <el-divider direction="vertical"></el-divider>
-        </el-col>
-        <el-col :span="24" v-if="working._id">
-          正常运营期:
-          <el-tooltip class="item" effect="dark" placement="bottom">
-            <template #content> {{ getProp('start_time', working) }} 至 {{ getProp('end_time', working) }} </template>
-            <el-link>{{ getProp('year', working) }}年度-{{ getProp('name', working) }}</el-link>
-          </el-tooltip>
-          时间内
-        </el-col>
-      </el-row>
-    </template>
-  </div>
-</template>
-
-<script>
-const _ = require('lodash');
-const moment = require('moment');
-import { mapState, createNamespacedHelpers } from 'vuex';
-const { mapActions } = createNamespacedHelpers('activitys');
-export default {
-  name: 'activitys',
-  props: {},
-  components: {},
-  data: function() {
-    return {
-      view: '',
-      preparing: {},
-      working: {},
-    };
-  },
-  computed: {
-    ...mapState(['user', 'isInAct']),
-  },
-  created() {
-    if (this.user.role_id === 'admin' || this.user.role_type === '1') {
-      // 管理员/超级管理员: 显示当前正处于哪个活动时间段,显示标题;
-      this.view = 'admin';
-      this.getActingTime();
-    } else {
-      // 显示自己处于哪个时间段即可
-      this.view = 'lab';
-    }
-  },
-  methods: {
-    ...mapActions(['query']),
-    getProp(prop, data = {}) {
-      if (this.view === 'lab') data = this.isInAct;
-      return _.get(data, prop);
-    },
-    async getActingTime() {
-      const res = await this.query({ is_use: '0' });
-      if (this.$checkRes(res)) {
-        const data = res.data;
-        const working = data.find(f => f.type === '1');
-        if (working) {
-          const { start_time, end_time } = working;
-          const is_in = moment().isBetween(start_time, end_time, null, '[]');
-          console.log(is_in);
-          if (is_in) this.$set(this, `working`, working);
-        }
-        const preparing = data.find(f => f.type === '-1');
-        if (preparing) {
-          const { start_time, end_time } = preparing;
-          const is_in = moment().isBetween(start_time, end_time, null, '[]');
-          console.log(is_in);
-          if (is_in) this.$set(this, `preparing`, preparing);
-        }
-      }
-    },
-  },
-};
-</script>
-
-<style lang="less" scoped>
-.view {
-  color: white;
-  font-weight: 700;
-  padding: 15px 0;
-  font-size: 14px;
-  .el-link {
-    font-size: 16px;
-    color: red;
-  }
-}
-.rows {
-  color: white;
-  font-size: 14px;
-  .el-link {
-    font-size: 16px;
-    color: red;
-  }
-}
-</style>

+ 6 - 2
src/store/index.js

@@ -3,14 +3,17 @@ import Vuex from 'vuex';
 import * as ustate from './module/user/state';
 import * as umutations from './module/user/mutations';
 import admin from './module/user/action';
-import selfShop from './module/shop/selfShop';
-import goods from './module/shop/goods';
+
 import dictIndex from './module/dev/dictIndex';
 import dictData from './module/dev/dictData';
+
 import goodsTags from './module/system/goodsTags';
 import banner from './module/system/banner';
 import indexModule from './module/system/indexModule';
 
+import selfShop from './module/shop/selfShop';
+import goods from './module/shop/goods';
+import goodsSpec from './module/shop/goodsSpec';
 Vue.use(Vuex);
 
 export default new Vuex.Store({
@@ -26,5 +29,6 @@ export default new Vuex.Store({
     goodsTags,
     banner,
     indexModule,
+    goodsSpec,
   },
 });

+ 44 - 0
src/store/module/shop/goodsSpec.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/goodsSpec',
+};
+
+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,
+};

+ 4 - 0
src/store/module/system/goodsTags.js

@@ -35,6 +35,10 @@ const actions = {
     const res = await this.$axios.$delete(`${api.url}/${payload}`);
     return res;
   },
+  async tree({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.url}/tree`);
+    return res;
+  },
 };
 export default {
   namespaced: true,

+ 86 - 10
src/views/selfShop/goods/index.vue

@@ -1,9 +1,24 @@
 <template>
   <div id="goods">
     <template v-if="view === 'list'">
-      <data-search :fields="searchFields" v-model="searchInfo" @query="search"></data-search>
+      <data-search :fields="searchFields" v-model="searchInfo" @query="search">
+        <template #status>
+          <el-option v-for="i in goodsStatusList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+        </template>
+      </data-search>
       <data-btn :fields="btnList" @add="toAdd"></data-btn>
-      <data-table ref="dataTable" :fields="fields" :opera="opera" :data="list" :total="total" :limit="limit" @query="search"></data-table>
+      <data-table
+        ref="dataTable"
+        :fields="fields"
+        :opera="opera"
+        :data="list"
+        :total="total"
+        :limit="limit"
+        @query="search"
+        @edit="toEdit"
+        @delete="toDelete"
+        @spec="toSpec"
+      ></data-table>
     </template>
     <template v-else>
       <el-row>
@@ -11,7 +26,14 @@
           <el-button icon="el-icon-back" size="mini" @click="toBack()">返回</el-button>
         </el-col>
         <el-col :span="24">
-          <data-form :fields="infoFields" :rules="rules" v-model="form" labelWidth="150px"></data-form>
+          <data-form :fields="infoFields" :rules="rules" v-model="form" labelWidth="150px" @save="toSave">
+            <template #tags="{ item }">
+              <el-cascader v-model="form[item.model]" :options="tagsList" :props="props" clearable filterable :show-all-levels="false"></el-cascader>
+            </template>
+            <template #status>
+              <el-option v-for="i in goodsStatusList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+            </template>
+          </data-form>
         </el-col>
       </el-row>
     </template>
@@ -19,30 +41,35 @@
 </template>
 
 <script>
+const _ = require('lodash');
 import methodsUtil from '@/util/opera';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: selfShop } = createNamespacedHelpers('selfShop');
 const { mapActions: goods } = createNamespacedHelpers('goods');
+const { mapActions: goodsTags } = createNamespacedHelpers('goodsTags');
+const { mapActions: dictData } = createNamespacedHelpers('dictData');
 export default {
   name: 'index',
   props: {},
-  // components: { cbtn, ctable, csearch, cform },
+  components: {},
   data: function () {
     return {
       view: 'list',
       fields: [
         { label: '商品名称', model: 'name' },
         { label: '店铺名称', model: 'shop.name' },
-        { label: '商品状态', model: 'status_label' },
+        { label: '商品标签', model: 'tags', format: (i) => this.getTags(i) },
+        { label: '商品状态', model: 'status', format: (i) => this.getStatus(i) },
       ],
       opera: [
         { label: '修改', method: 'edit' },
+        { label: '库存管理', method: 'spec' },
         { label: '删除', method: 'delete', confirm: true, type: 'danger' },
       ],
       btnList: [{ label: '添加', method: 'add' }],
       searchFields: [
         { label: '商品名称', model: 'name' },
-        { label: '商品状态', model: 'status' },
+        { label: '商品状态', model: 'status', type: 'select' },
       ],
       searchInfo: {},
       list: [],
@@ -51,23 +78,33 @@ export default {
       // info部分
       infoFields: [
         { label: '商品名称', model: 'name' },
+        { label: '商品标签', model: 'tags', custom: true },
         { label: '简短简介', model: 'shot_brief', maxLength: 50 },
-        { label: '规格', model: 'specs', custom: true },
         { label: '预计发货时间', model: 'send_time' },
         { label: '商品图片', model: 'file', type: 'upload', url: '/files/point/goods/upload' },
-        { label: '商品介绍', model: 'brief' },
+        { label: '商品介绍', model: 'brief', type: 'textarea' },
         { label: '商品状态', model: 'status', type: 'select' },
       ],
       rules: {},
       form: {},
+
+      tagsList: [],
+      goodsStatusList: [],
+      props: { multiple: true, label: 'label', value: 'code' },
+
+      shop: {},
     };
   },
   created() {
+    this.searchOthers();
     this.search();
   },
   methods: {
+    ...dictData({ getDict: 'query' }),
+    ...goodsTags(['tree']),
     ...selfShop(['getInfo', 'getGoods', 'goodsCreate']),
-    ...goods(['delete', 'fetch', 'update']),
+    ...goods(['delete', 'fetch', 'update', 'create']),
+    ...methodsUtil,
     async search({ skip = 0, limit = this.limit, ...others } = {}) {
       let query = { skip, limit, ...others };
       if (Object.keys(this.searchInfo).length > 0) query = { ...query, ...this.searchInfo };
@@ -77,7 +114,46 @@ export default {
         this.$set(this, `total`, res.total);
       }
     },
-    ...methodsUtil,
+    initAddData() {
+      const obj = {
+        // tags: [],
+        status: '1',
+        shop: _.get(this.shop, '_id'),
+      };
+      this.$set(this, 'form', obj);
+    },
+    async searchOthers() {
+      let res = await this.tree();
+      if (this.$checkRes(res)) this.$set(this, `tagsList`, res.data);
+      res = await this.getDict({ code: 'goods_status' });
+      if (this.$checkRes(res)) this.$set(this, `goodsStatusList`, res.data);
+      res = await this.getInfo();
+      if (this.$checkRes(res)) this.$set(this, `shop`, res.data);
+    },
+    getStatus(data) {
+      const res = this.goodsStatusList.find((f) => f.value === data);
+      if (res) return res.label;
+      return '';
+    },
+    getTags(data) {
+      let list = this.tagsList;
+      const getChildren = (list) =>
+        list.map((i) => {
+          if (i.children) return getChildren(i.children);
+          return i;
+        });
+      list = _.flattenDeep(getChildren(list));
+      const arr = [];
+      for (const ts of data) {
+        const last = _.last(ts);
+        const r = list.find((f) => f.code === last);
+        if (r) arr.push(r.label);
+      }
+      return arr.join(';');
+    },
+    toSpec({ data }) {
+      console.log(data);
+    },
   },
 };
 </script>

+ 2 - 0
src/views/system/goodsTags/index.vue

@@ -109,7 +109,9 @@ export default {
     },
     initAddData() {
       const pid = _.last(this.levelList);
+      const level = this.levelList.length + 1;
       if (pid) this.form.pid = pid;
+      this.form.level = level;
     },
     toData(row) {
       const id = _.get(row, '_id');