zs il y a 2 ans
Parent
commit
f6e464206e

+ 6 - 1
src/store/index.js

@@ -5,6 +5,11 @@ import * as umutations from '@common/src/store/user/mutations';
 // 管理员
 import admin from '@common/src/store/admin';
 import program from '@common/src/store/program';
+import shop from '@common/src/store/shop';
+import table from '@common/src/store/table';
+import goodsTags from '@common/src/store/goodsTags';
+import goods from '@common/src/store/goods';
+import order from '@common/src/store/order';
 
 Vue.use(Vuex);
 
@@ -13,5 +18,5 @@ export default new Vuex.Store({
   getters: {},
   mutations: { ...umutations },
   actions: {},
-  modules: { admin, program },
+  modules: { admin, program, shop, table, goodsTags, goods, order },
 });

+ 23 - 13
src/views/goods/add.vue

@@ -8,7 +8,7 @@
         <el-col :span="24" class="two">
           <data-form :fields="fields" :form="form" :rules="rules" @save="toSave">
             <template #type>
-              <el-option v-for="i in typeList" :key="i.dict_value" :label="i.dict_label" :value="i.dict_value"></el-option>
+              <el-option v-for="i in typeList" :key="i.code" :label="i.name" :value="i.code"></el-option>
             </template>
             <template #is_use>
               <el-option v-for="i in is_useList" :key="i.dict_value" :label="i.dict_label" :value="i.dict_value"></el-option>
@@ -26,7 +26,8 @@
 <script>
 import { is_use } from '@common/src/layout/site';
 import { mapState, createNamespacedHelpers } from 'vuex';
-// const { mapActions } = createNamespacedHelpers('program');
+const { mapActions } = createNamespacedHelpers('goods');
+const { mapActions: goodsTags } = createNamespacedHelpers('goodsTags');
 export default {
   name: 'add',
   props: {},
@@ -56,28 +57,37 @@ export default {
       typeList: [],
     };
   },
-  created() {
-    this.search();
+  async created() {
+    await this.searchOther();
+    await this.search();
   },
   methods: {
     ...mapActions(['fetch', 'create', 'update']),
+    ...goodsTags({ gQuery: 'query' }),
     async search() {
       if (this.id) {
-        // let res = await this.fetch(this.id);
-        // if (this.$checkRes(res)) {
-        //   this.$set(this, `form`, res.data);
-        // }
+        let res = await this.fetch(this.id);
+        if (this.$checkRes(res)) {
+          this.$set(this, `form`, res.data);
+        }
+      }
+    },
+    // 其他
+    async searchOther() {
+      let res;
+      // 类型
+      res = await this.gQuery();
+      if (this.$checkRes(res)) {
+        this.$set(this, `typeList`, res.data);
       }
     },
-
     // 保存信息
     async toSave({ data }) {
       let res;
-      // if (data.id) res = await this.update(data);
-      // else res = await this.create(data);
-      // if (this.$checkRes(res, `维护信息成功`, res.errmsg)) this.toBack();
+      if (data.id) res = await this.update(data);
+      else res = await this.create(data);
+      if (this.$checkRes(res, `维护信息成功`, res.errmsg)) this.toBack();
     },
-
     // 返回
     toBack() {
       window.history.go('-1');

+ 27 - 16
src/views/goods/index.vue

@@ -5,7 +5,7 @@
         <el-col :span="24" class="one">
           <c-search :is_search="true" :fields="fields" @search="btSearch">
             <template #type>
-              <el-option v-for="i in typeList" :key="i.dict_value" :label="i.dict_label" :value="i.dict_value"></el-option>
+              <el-option v-for="i in typeList" :key="i.code" :label="i.name" :value="i.code"></el-option>
             </template>
             <template #is_use>
               <el-option v-for="i in is_useList" :key="i.dict_value" :label="i.dict_label" :value="i.dict_value"></el-option>
@@ -24,9 +24,10 @@
 </template>
 
 <script>
-import { is_use, goods_type } from '@common/src/layout/site';
+import { is_use } from '@common/src/layout/site';
 import { mapState, createNamespacedHelpers } from 'vuex';
-// const { mapActions } = createNamespacedHelpers('program');
+const { mapActions } = createNamespacedHelpers('goods');
+const { mapActions: goodsTags } = createNamespacedHelpers('goodsTags');
 export default {
   name: 'index',
   props: {},
@@ -45,8 +46,8 @@ export default {
           model: 'type',
           type: 'select',
           format: (i) => {
-            let data = this.typeList.find((r) => r.dict_value == i);
-            if (data) return data.dict_label;
+            let data = this.typeList.find((r) => r.code == i);
+            if (data) return data.name;
             else return '暂无';
           },
           isSearch: true,
@@ -73,21 +74,31 @@ export default {
       ],
       is_useList: is_use,
       // 商品类型
-      typeList: goods_type,
+      typeList: [],
     };
   },
-  created() {
-    this.search();
+  async created() {
+    await this.searchOther();
+    await this.search();
   },
   mounted() {},
   methods: {
-    // ...mapActions(['query', 'fetch', 'delete']),
+    ...mapActions(['query', 'fetch', 'delete']),
+    ...goodsTags({ gQuery: 'query' }),
     async search({ skip = 0, limit = 10, ...info } = {}) {
-      // let res = await this.query({ skip, limit, ...info, ...this.searchInfo });
-      // if (this.$checkRes(res)) {
-      //   this.$set(this, `list`, res.data);
-      //   this.$set(this, `total`, res.total);
-      // }
+      let res = await this.query({ skip, limit, ...info, ...this.searchInfo });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
+    },
+    async searchOther() {
+      let res;
+      // 类型
+      res = await this.gQuery();
+      if (this.$checkRes(res)) {
+        this.$set(this, `typeList`, res.data);
+      }
     },
     btSearch(query) {
       this.$set(this, `searchInfo`, query);
@@ -107,8 +118,8 @@ export default {
     },
     // 删除信息
     async toDel({ data }) {
-      // let res = await this.delete(data.id);
-      // if (this.$checkRes(res, `刪除信息成功`, `${res.errmsg}`)) this.search();
+      let res = await this.delete(data.id);
+      if (this.$checkRes(res, `刪除信息成功`, `${res.errmsg}`)) this.search();
     },
   },
   computed: {

+ 9 - 9
src/views/goodsTags/add.vue

@@ -20,7 +20,7 @@
 <script>
 import { is_use } from '@common/src/layout/site';
 import { mapState, createNamespacedHelpers } from 'vuex';
-// const { mapActions } = createNamespacedHelpers('program');
+const { mapActions } = createNamespacedHelpers('goodsTags');
 export default {
   name: 'add',
   props: {},
@@ -50,18 +50,18 @@ export default {
     ...mapActions(['fetch', 'create', 'update']),
     async search() {
       if (this.id) {
-        // let res = await this.fetch(this.id);
-        // if (this.$checkRes(res)) {
-        //   this.$set(this, `form`, res.data);
-        // }
+        let res = await this.fetch(this.id);
+        if (this.$checkRes(res)) {
+          this.$set(this, `form`, res.data);
+        }
       }
     },
     // 保存信息
     async toSave({ data }) {
-      // let res;
-      // if (data.id) res = await this.update(data);
-      // else res = await this.create(data);
-      // if (this.$checkRes(res, `维护信息成功`, res.errmsg)) this.toBack();
+      let res;
+      if (data.id) res = await this.update(data);
+      else res = await this.create(data);
+      if (this.$checkRes(res, `维护信息成功`, res.errmsg)) this.toBack();
     },
     // 返回
     toBack() {

+ 9 - 9
src/views/goodsTags/index.vue

@@ -26,7 +26,7 @@
 <script>
 import { is_use } from '@common/src/layout/site';
 import { mapState, createNamespacedHelpers } from 'vuex';
-// const { mapActions } = createNamespacedHelpers('program');
+const { mapActions } = createNamespacedHelpers('goodsTags');
 export default {
   name: 'index',
   props: {},
@@ -66,13 +66,13 @@ export default {
   },
   mounted() {},
   methods: {
-    // ...mapActions(['query', 'fetch', 'delete']),
+    ...mapActions(['query', 'fetch', 'delete']),
     async search({ skip = 0, limit = 10, ...info } = {}) {
-      // let res = await this.query({ skip, limit, ...info, ...this.searchInfo });
-      // if (this.$checkRes(res)) {
-      //   this.$set(this, `list`, res.data);
-      //   this.$set(this, `total`, res.total);
-      // }
+      let res = await this.query({ skip, limit, ...info, ...this.searchInfo });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
     },
     btSearch(query) {
       this.$set(this, `searchInfo`, query);
@@ -88,8 +88,8 @@ export default {
     },
     // 删除信息
     async toDel({ data }) {
-      // let res = await this.delete(data.id);
-      // if (this.$checkRes(res, `刪除信息成功`, `${res.errmsg}`)) this.search();
+      let res = await this.delete(data.id);
+      if (this.$checkRes(res, `刪除信息成功`, `${res.errmsg}`)) this.search();
     },
   },
   computed: {

+ 1 - 1
src/views/order/add.vue

@@ -23,7 +23,7 @@
 <script>
 import { is_use, order_type } from '@common/src/layout/site';
 import { mapState, createNamespacedHelpers } from 'vuex';
-const { mapActions } = createNamespacedHelpers('program');
+const { mapActions } = createNamespacedHelpers('order');
 export default {
   name: 'add',
   props: {},

+ 5 - 5
src/views/order/index.vue

@@ -16,7 +16,7 @@
 <script>
 import { order_type } from '@common/src/layout/site';
 import { mapState, createNamespacedHelpers } from 'vuex';
-const { mapActions } = createNamespacedHelpers('program');
+const { mapActions } = createNamespacedHelpers('order');
 export default {
   name: 'index',
   props: {},
@@ -29,11 +29,11 @@ export default {
       total: 0,
       fields: [
         { label: '序号', options: { type: 'index' } },
-        { label: '订单号', model: 'order', isSearch: true },
+        { label: '订单号', model: '_id', isSearch: true },
         { label: '下单时间', model: 'time' },
         { label: '下单桌号', model: 'code' },
         { label: '支付金额', model: 'money' },
-        { label: '商品数量', model: 'num' },
+        { label: '用餐人数', model: 'num' },
         {
           label: '订单类型',
           model: 'type',
@@ -64,8 +64,8 @@ export default {
     async search({ skip = 0, limit = 10, ...info } = {}) {
       let res = await this.query({ skip, limit, ...info, ...this.searchInfo });
       if (this.$checkRes(res)) {
-        // this.$set(this, `list`, res.data);
-        // this.$set(this, `total`, res.total);
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
       }
     },
     btSearch(query) {

+ 22 - 3
src/views/shop/index.vue

@@ -14,6 +14,8 @@
 
 <script>
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('admin');
+const { mapActions: shop } = createNamespacedHelpers('shop');
 export default {
   name: 'index',
   props: {},
@@ -29,6 +31,7 @@ export default {
       fields: [
         { label: '店铺名称', model: 'name' },
         { label: '公告内容', model: 'notice' },
+        { label: '餐位费', model: 'money', type: 'number' },
         { label: '首页图片', model: 'logo', custom: true },
       ],
     };
@@ -37,11 +40,27 @@ export default {
     this.search();
   },
   methods: {
-    search() {
-      console.log('1');
+    ...mapActions(['query', 'fetch', 'delete', 'update']),
+    ...shop({ sFetch: 'fetch', sUpdate: 'update', sCeate: 'create' }),
+    async search() {
+      if (this.user && this.user.shop) {
+        let res = await this.sFetch(this.user.shop);
+        if (this.$checkRes(res)) {
+          this.$set(this, `form`, res.data);
+        }
+      }
     },
     // 提交保存
-    onSubmit() {},
+    async onSubmit({ data }) {
+      let res;
+      if (data.id) res = await this.sUpdate(data);
+      else res = await this.sCeate(data);
+      if (this.$checkRes(res)) {
+        let form = { _id: this.user._id, shop: res.data._id };
+        let arr = await this.update(form);
+        if (this.$checkRes(arr)) this.$message({ type: `success`, message: `维护信息成功` });
+      }
+    },
   },
   computed: {
     ...mapState(['user']),

+ 8 - 8
src/views/table/add.vue

@@ -23,7 +23,7 @@
 <script>
 import { is_use, table_type } from '@common/src/layout/site';
 import { mapState, createNamespacedHelpers } from 'vuex';
-// const { mapActions } = createNamespacedHelpers('program');
+const { mapActions } = createNamespacedHelpers('table');
 export default {
   name: 'add',
   props: {},
@@ -54,18 +54,18 @@ export default {
     ...mapActions(['fetch', 'create', 'update']),
     async search() {
       if (this.id) {
-        // let res = await this.fetch(this.id);
-        // if (this.$checkRes(res)) {
-        //   this.$set(this, `form`, res.data);
-        // }
+        let res = await this.fetch(this.id);
+        if (this.$checkRes(res)) {
+          this.$set(this, `form`, res.data);
+        }
       }
     },
     // 保存信息
     async toSave({ data }) {
       let res;
-      // if (data.id) res = await this.update(data);
-      // else res = await this.create(data);
-      // if (this.$checkRes(res, `维护信息成功`, res.errmsg)) this.toBack();
+      if (data.id) res = await this.update(data);
+      else res = await this.create(data);
+      if (this.$checkRes(res, `维护信息成功`, res.errmsg)) this.toBack();
     },
     // 返回
     toBack() {

+ 9 - 9
src/views/table/index.vue

@@ -26,7 +26,7 @@
 <script>
 import { is_use, table_type } from '@common/src/layout/site';
 import { mapState, createNamespacedHelpers } from 'vuex';
-// const { mapActions } = createNamespacedHelpers('program');
+const { mapActions } = createNamespacedHelpers('table');
 export default {
   name: 'index',
   props: {},
@@ -79,13 +79,13 @@ export default {
   },
   mounted() {},
   methods: {
-    // ...mapActions(['query', 'fetch', 'delete']),
+    ...mapActions(['query', 'fetch', 'delete']),
     async search({ skip = 0, limit = 10, ...info } = {}) {
-      // let res = await this.query({ skip, limit, ...info, ...this.searchInfo });
-      // if (this.$checkRes(res)) {
-      //   this.$set(this, `list`, res.data);
-      //   this.$set(this, `total`, res.total);
-      // }
+      let res = await this.query({ skip, limit, ...info, ...this.searchInfo });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
     },
     btSearch(query) {
       this.$set(this, `searchInfo`, query);
@@ -105,8 +105,8 @@ export default {
     },
     // 删除信息
     async toDel({ data }) {
-      // let res = await this.delete(data.id);
-      // if (this.$checkRes(res, `刪除信息成功`, `${res.errmsg}`)) this.search();
+      let res = await this.delete(data.id);
+      if (this.$checkRes(res, `刪除信息成功`, `${res.errmsg}`)) this.search();
     },
   },
   computed: {

+ 1 - 1
vue.config.js

@@ -23,7 +23,7 @@ module.exports = {
         target: 'http://broadcast.waityou24.cn',
       },
       '/projectadmin/api': {
-        target: 'http://broadcast.waityou24.cn', //http://127.0.0.1:10102  http://www.freeskyghw.cn
+        target: 'http://127.0.0.1:10102', //http://127.0.0.1:10102  http://www.freeskyghw.cn
         changeOrigin: true,
         ws: false,
       },