lrf 2 年之前
父节点
当前提交
f37bddf69b

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

@@ -88,7 +88,7 @@
                   ></el-input>
                 </template>
                 <template v-else-if="item.type === 'upload'">
-                  <c-upload :url="item.url" v-model="form[item.model]"></c-upload>
+                  <c-upload :url="item.url" v-model="form[item.model]" :limit="item.limit"></c-upload>
                 </template>
                 <template v-else>
                   <el-input

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

@@ -23,4 +23,10 @@ export default [
     meta: { title: '自营店铺-优惠券管理' },
     component: () => import(/* webpackChunkName: "selfShop_coupon" */ '@/views/selfShop/coupon/index.vue'),
   },
+  {
+    path: '/selfShop/spec/:id',
+    name: 'selfShop_spec',
+    meta: { title: '自营店铺-商品库存管理' },
+    component: () => import(/* webpackChunkName: "selfShop_spec" */ '@/views/selfShop/goods/spec.vue'),
+  },
 ];

+ 2 - 0
src/store/index.js

@@ -11,6 +11,7 @@ import goodsTags from './module/system/goodsTags';
 import banner from './module/system/banner';
 import indexModule from './module/system/indexModule';
 
+import shop from './module/shop/shop';
 import selfShop from './module/shop/selfShop';
 import goods from './module/shop/goods';
 import goodsSpec from './module/shop/goodsSpec';
@@ -22,6 +23,7 @@ export default new Vuex.Store({
   actions: {},
   modules: {
     admin,
+    shop,
     selfShop,
     goods,
     dictIndex,

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

+ 1 - 2
src/views/selfShop/goods/index.vue

@@ -116,7 +116,6 @@ export default {
     },
     initAddData() {
       const obj = {
-        // tags: [],
         status: '1',
         shop: _.get(this.shop, '_id'),
       };
@@ -152,7 +151,7 @@ export default {
       return arr.join(';');
     },
     toSpec({ data }) {
-      console.log(data);
+      this.$router.push({ path: `/selfShop/spec/${data._id}` });
     },
   },
 };

+ 122 - 0
src/views/selfShop/goods/spec.vue

@@ -0,0 +1,122 @@
+<template>
+  <div id="spec">
+    <template v-if="view === 'list'">
+      <el-row>
+        <el-col :span="24" style="padding: 10px">
+          <el-button icon="el-icon-back" size="mini" @click="toBack()">返回</el-button>
+        </el-col>
+      </el-row>
+      <data-search :fields="searchFields" v-model="searchInfo" @query="search">
+        <template #status>
+          <el-option v-for="i in statusList" :key="i.model" :label="i.label" :value="i.value"></el-option>
+        </template>
+      </data-search>
+      <data-btn :fields="btnFields" @add="toAdd" />
+      <data-table ref="dataTable" :fields="fields" :opera="opera" :data="list" :total="total" @edit="toEdit" @delete="toDelete">
+        <template #code="{ row, item }">
+          <el-link type="primary" @click="toData(row)">{{ row[item.model] }}</el-link>
+        </template>
+      </data-table>
+    </template>
+    <template v-else>
+      <el-row>
+        <el-col :span="24">
+          <el-button icon="el-icon-back" size="mini" @click="toBack()">返回</el-button>
+        </el-col>
+        <el-col :span="24">
+          <data-form :span="12" :fields="infoFields" :rules="rules" v-model="form" labelWidth="150px" @save="toSave">
+            <template #status>
+              <el-option v-for="i in statusList" :key="i.model" :label="i.label" :value="i.value"></el-option>
+            </template>
+          </data-form>
+        </el-col>
+      </el-row>
+    </template>
+  </div>
+</template>
+
+<script>
+// 找到该商品下的规格定义
+const _ = require('lodash');
+import methodUtil from '@/util/opera';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('goodsSpec');
+const { mapActions: dictData } = createNamespacedHelpers('dictData');
+export default {
+  name: 'spec',
+  props: {},
+  components: {},
+  data: function () {
+    return {
+      view: 'list',
+      fields: [
+        { label: '规格名称', model: 'name' },
+        { label: '库存', model: 'num' },
+        { label: '实际销售价格', model: 'sell_money' },
+        { label: '划掉销售价格', model: 'flow_money' },
+        { label: '运费', model: 'freight' },
+        { label: '状态', model: 'status', format: (i) => (i === '0' ? '使用中' : '已禁用') },
+      ],
+      opera: [
+        { label: '修改', method: 'edit' },
+        { label: '删除', method: 'delete', confirm: true, type: 'danger' },
+      ],
+      list: [],
+      total: 0,
+      limit: 10,
+      btnFields: [{ label: '添加', method: 'add' }],
+      defaultSearch: {},
+      searchInfo: {},
+      searchFields: [
+        { label: '规格名称', model: 'name' },
+        { label: '状态', model: 'status', type: 'select' },
+      ],
+      infoFields: [
+        { label: '规格名称', model: 'name' },
+        { label: '库存', model: 'num', type: 'number' },
+        { label: '实际销售价格', model: 'sell_money', type: 'number' },
+        { label: '划掉销售价格', model: 'flow_money', type: 'number' },
+        { label: '运费', model: 'freight', type: 'number' },
+        { label: '状态', model: 'status', type: 'select' },
+      ],
+      rules: {},
+      form: {},
+
+      statusList: [],
+    };
+  },
+  computed: {
+    ...mapState(['user']),
+    goods() {
+      return this.$route.params.id;
+    },
+  },
+  created() {
+    this.defaultSearch.goods = this.goods;
+    this.searchOthers();
+    this.search();
+  },
+  methods: {
+    ...dictData({ getDict: 'query' }),
+    ...mapActions(['query', 'fetch', 'update', 'delete', 'create']),
+    ...methodUtil,
+    initAddData() {
+      const obj = { goods: this.goods, status: '0' };
+      this.$set(this, 'form', obj);
+    },
+
+    toBack() {
+      this.$router.push('/selfShop/goods');
+    },
+    async searchOthers() {
+      let res = await this.getDict({ code: 'status' });
+      if (this.$checkRes(res)) this.$set(this, 'statusList', res.data);
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 37 - 4
src/views/selfShop/info/index.vue

@@ -1,23 +1,56 @@
 <template>
   <div id="index">
-    <p>info</p>
+    <data-form :span="12" :fields="fields" :rules="rules" v-model="form" labelWidth="150px" @save="toSave">
+      <template #status>
+        <el-option v-for="i in statusList" :key="i.model" :label="i.label" :value="i.value"></el-option>
+      </template>
+    </data-form>
   </div>
 </template>
 
 <script>
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: selfShop } = createNamespacedHelpers('selfShop');
+const { mapActions: shop } = createNamespacedHelpers('shop');
 export default {
   name: 'index',
   props: {},
   components: {},
   data: function () {
-    return {};
+    return {
+      fields: [
+        { label: '店铺logo', model: 'logo', type: 'upload', limit: 1, url: '/files/point/shopLogo/upload' },
+        { label: '商店名称', model: 'name' },
+        { label: '店主', model: 'person' },
+        { label: '联系电话', model: 'phone' },
+        { label: '地址', model: 'address' },
+        { label: '证件照片', model: 'file', type: 'upload', url: '/files/point/shopFile/upload' },
+      ],
+      rules: {},
+      form: {},
+    };
   },
   computed: {
     ...mapState(['user']),
   },
-  created() {},
-  methods: {},
+  created() {
+    this.search();
+  },
+  methods: {
+    ...selfShop(['getInfo']),
+    ...shop(['update']),
+    //执行查询
+    async search() {
+      const res = await this.getInfo();
+      if (this.$checkRes(res)) {
+        this.$set(this, `form`, res.data);
+      }
+    },
+    async toSave({ data }) {
+      const res = await this.update(data);
+      this.$checkRes(res, '操作成功', '操作失败');
+    },
+  },
   metaInfo() {
     return { title: this.$route.meta.title };
   },