浏览代码

团购--商品设置、团设置

YY 2 年之前
父节点
当前提交
5e70d243cd

+ 59 - 5
src/views/platGroup/goods/index.vue

@@ -9,7 +9,38 @@
         element-loading-spinner="el-icon-loading"
       >
         <span 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 #goods>
+              <el-select
+                v-model="searchInfo.goods"
+                filterable
+                clearable
+                remote
+                :remote-method="querySearch"
+                placeholder="请选择商品名称"
+                :loading="loading"
+                size="small"
+                style="width: 100%"
+              >
+                <el-option v-for="item in goodsList" :key="item._id" :label="item.name" :value="item._id"> </el-option>
+              </el-select>
+            </template>
+            <template #spec>
+              <el-select
+                v-model="searchInfo.spec"
+                filterable
+                clearable
+                remote
+                :remote-method="specSearch"
+                placeholder="请选择规格名称"
+                :loading="loading"
+                size="small"
+                style="width: 100%"
+              >
+                <el-option v-for="item in specList" :key="item._id" :label="item.name" :value="item._id"> </el-option>
+              </el-select>
+            </template>
+          </data-search>
           <data-btn :fields="btnList" @add="toAdd"></data-btn>
           <data-table
             ref="dataTable"
@@ -32,6 +63,8 @@
 const _ = require('lodash');
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: goodsConfig } = createNamespacedHelpers('goodsConfig');
+const { mapActions: goods } = createNamespacedHelpers('goods'); // 商品
+const { mapActions: goodsSpec } = createNamespacedHelpers('goodsSpec'); // 商品规格
 export default {
   name: 'index',
   props: {},
@@ -41,10 +74,11 @@ export default {
   data: function () {
     return {
       loadings: true,
+      loading: false,
       view: 'list',
       fields: [
-        { label: '商品名称', model: 'goods', showTip: false },
-        { label: '规格名称', model: 'spec' },
+        { label: '商品名称', model: 'goods.name', showTip: false },
+        { label: '规格名称', model: 'spec.name' },
         { label: '团长价', model: 'leader_price' },
         { label: '团购价', model: 'price' },
         { label: '团长提成金额', model: 'leader_get' },
@@ -55,19 +89,25 @@ export default {
       ],
       btnList: [{ label: '添加', method: 'add' }],
       searchFields: [
-        { label: '商品名称', model: 'goods' },
-        { label: '规格名称', model: 'spec' },
+        { label: '商品名称', model: 'goods', custom: true },
+        { label: '规格名称', model: 'spec', custom: true },
       ],
       searchInfo: {},
       list: [],
       total: 0,
       id: '',
+      // 商品列表
+      goodsList: [],
+      // 规格列表
+      specList: [],
     };
   },
   created() {
     this.search();
   },
   methods: {
+    ...goods({ goodsQuery: 'query' }),
+    ...goodsSpec({ specQuery: 'query' }),
     ...goodsConfig(['query', 'delete', 'fetch', 'update', 'create']),
     // 查询
     async search({ skip = 0, limit = this.$limit, ...others } = {}) {
@@ -80,6 +120,19 @@ export default {
       }
       this.loadings = false;
     },
+    // 远程查询
+    async querySearch(value) {
+      this.loading = true;
+      let res = await this.goodsQuery({ name: value });
+      if (this.$checkRes(res)) this.$set(this, 'goodsList', res.data);
+      this.loading = false;
+    },
+    async specSearch(value) {
+      this.loading = true;
+      let res = await this.specQuery({ name: value });
+      if (this.$checkRes(res)) this.$set(this, 'specList', res.data);
+      this.loading = false;
+    },
     // 新增
     toAdd() {
       let id = '';
@@ -99,6 +152,7 @@ export default {
         this.search();
       }
     },
+
     // 执行返回
     toBack() {
       this.view = 'list';

+ 12 - 33
src/views/platGroup/group/detail.vue

@@ -50,7 +50,8 @@
               <el-table :data="form.group_config" border size="mini">
                 <el-table-column label="规格名称" prop="spec" align="center">
                   <template #default="{ row }">
-                    <el-input v-model="row.spec" type="text" placeholder="请输入规格名称"></el-input>
+                    <p>{{ row.spec.name }}</p>
+                    <!-- <el-input v-model="row.spec.name" disabled type="text" placeholder="请输入规格名称"></el-input> -->
                   </template>
                 </el-table-column>
                 <el-table-column label="团长价" prop="leader_price" align="center">
@@ -116,8 +117,7 @@ export default {
         status: [{ required: true, message: '团状态', trigger: 'change' }],
       },
       form: {
-        // 团购设置
-        group_config: [],
+        group_config: [], // 团购设置
       },
       // 商品列表
       goodsList: [],
@@ -165,34 +165,27 @@ export default {
       this.loading = true;
       let res = await this.goodsQuery({ name: value });
       if (this.$checkRes(res)) {
-        // let list = [];
-        // for (const p1 of res.data) {
-        //   let arr = await this.goodsConfigQuery({ goods: p1._id });
-        //   if (this.$checkRes(arr)) {
-        //     if (arr.total > 0) list.push(p1);
-        //   }
-        // }
-        // console.log(list);
-        // this.$set(this, 'goodsList', list);
-        this.$set(this, 'goodsList', res.data);
+        let list = [];
+        for (const p1 of res.data) {
+          let arr = await this.goodsConfigQuery({ goods: p1._id });
+          if (this.$checkRes(arr)) if (arr.total > 0) list.push(p1);
+        }
+        this.$set(this, 'goodsList', list);
+        // this.$set(this, 'goodsList', res.data);
       }
       this.loading = false;
     },
     // 选择-查询商品
     async handleSelect(value) {
       let res = await this.goodsConfigQuery({ goods: value });
-      if (this.$checkRes(res)) {
-        this.$set(this.form, 'group_config', res.data);
-      }
+      if (this.$checkRes(res)) this.$set(this.form, 'group_config', res.data);
     },
     // 重置
     async toReset() {
       if (this.form.goods) {
         let res = await this.goodsConfigQuery({ goods: this.form.goods });
         if (this.$checkRes(res)) this.$set(this.form, 'group_config', res.data);
-      } else {
-        this.$message({ type: `warning`, message: `请选择商品` });
-      }
+      } else this.$message({ type: `warning`, message: `请选择商品` });
     },
     // 删除
     toDel(index, type) {
@@ -207,7 +200,6 @@ export default {
       if (this.$checkRes(res)) {
         this.$message({ type: `success`, message: `维护信息成功` });
         this.toBack();
-        this.search();
       }
     },
     // 返回
@@ -217,19 +209,6 @@ export default {
     // 查询其他信息
     async searchOthers() {
       let res;
-      // res = await this.goodsConfigQuery();
-      // if (this.$checkRes(res)) {
-      //   for (const p1 of res.data) {
-      //     let arr = await this.goodsFetch(p1.goods);
-      //     if (this.$checkRes(arr)) p1.goods_name = arr.data.name;
-      //     let aee = await this.specFetch(p1.spec);
-      //     if (this.$checkRes(aee)) p1.spec_name = aee.data.name;
-      //     p1.name = p1.goods_name + '---' + p1.spec_name;
-      //     delete p1.goods_name;
-      //     delete p1.spec_name;
-      //   }
-      //   this.$set(this, 'goodsList', res.data);
-      // }
       res = await this.getDict({ code: 'group_status' });
       if (this.$checkRes(res)) this.$set(this, `statusList`, res.data);
       // 团长列表

+ 59 - 5
src/views/platGroup/group/index.vue

@@ -9,7 +9,38 @@
         element-loading-spinner="el-icon-loading"
       >
         <span 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 #goods>
+              <el-select
+                v-model="searchInfo.goods"
+                filterable
+                clearable
+                remote
+                :remote-method="querySearch"
+                placeholder="请选择商品名称"
+                :loading="loading"
+                size="small"
+                style="width: 100%"
+              >
+                <el-option v-for="item in goodsList" :key="item._id" :label="item.name" :value="item._id"> </el-option>
+              </el-select>
+            </template>
+            <template #leader>
+              <el-select
+                v-model="searchInfo.leader"
+                filterable
+                clearable
+                remote
+                :remote-method="leaderSearch"
+                placeholder="请选择团长名称"
+                :loading="loading"
+                size="small"
+                style="width: 100%"
+              >
+                <el-option v-for="item in leaderList" :key="item._id" :label="item.name" :value="item._id"> </el-option>
+              </el-select>
+            </template>
+          </data-search>
           <data-btn :fields="btnList" @add="toAdd"></data-btn>
           <data-table
             ref="dataTable"
@@ -33,6 +64,8 @@ const _ = require('lodash');
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: group } = createNamespacedHelpers('group'); // 团表
 const { mapActions: dictData } = createNamespacedHelpers('dictData'); // 字典
+const { mapActions: goods } = createNamespacedHelpers('goods'); // 商品
+const { mapActions: users } = createNamespacedHelpers('users'); // 团长
 export default {
   name: 'index',
   props: {},
@@ -42,10 +75,12 @@ export default {
   data: function () {
     return {
       loadings: true,
+      loading: false,
       view: 'list',
       fields: [
-        { label: '商品名称', model: 'goods', showTip: false },
-        { label: '团长', model: 'leader' },
+        { label: '商品名称', model: 'goods.name', showTip: false },
+        { label: '团长', model: 'leader.name' },
+        { label: '人数限制', model: 'person_limit' },
         { label: '开始时间', model: 'start_time' },
         { label: '结束时间', model: 'end_time' },
         {
@@ -64,8 +99,8 @@ export default {
       ],
       btnList: [{ label: '添加', method: 'add' }],
       searchFields: [
-        { label: '商品名称', model: 'goods' },
-        { label: '规格名称', model: 'spec' },
+        { label: '商品名称', model: 'goods', custom: true },
+        { label: '团长', model: 'leader', custom: true },
       ],
       searchInfo: {},
       list: [],
@@ -73,6 +108,10 @@ export default {
       // 团状态
       statusList: [],
       id: '',
+      // 商品列表
+      goodsList: [],
+      // 团长列表
+      leaderList: [],
     };
   },
   created() {
@@ -80,6 +119,8 @@ export default {
     this.search();
   },
   methods: {
+    ...goods({ goodsQuery: 'query' }),
+    ...users({ userQuery: 'query' }),
     ...dictData({ getDict: 'query' }),
     ...group(['query', 'delete', 'fetch', 'update', 'create']),
     // 查询
@@ -93,6 +134,19 @@ export default {
       }
       this.loadings = false;
     },
+    // 远程查询
+    async querySearch(value) {
+      this.loading = true;
+      let res = await this.goodsQuery({ name: value });
+      if (this.$checkRes(res)) this.$set(this, 'goodsList', res.data);
+      this.loading = false;
+    },
+    async leaderSearch(value) {
+      this.loading = true;
+      let res = await this.userQuery({ name: value, is_leader: '0' });
+      if (this.$checkRes(res)) this.$set(this, 'leaderList', res.data);
+      this.loading = false;
+    },
     // 新增
     toAdd() {
       let id = '';

+ 1 - 48
src/views/platGroup/order/index.vue

@@ -25,21 +25,11 @@
                 <el-col :span="24" class="one">
                   <search-1 :form="searchForm" @onSubmit="search" @querySearch="querySearch" @toReset="toClose" :shopList="shopList"> </search-1>
                 </el-col>
-                <data-table :fields="fields" :opera="opera" @query="search" :data="list" :total="total" @detail="toDetails" @sales="toSaless">
-                  <!-- <template #is_afterSale="{ row }">
-                    <span :style="{ color: row.is_afterSale === true ? 'red' : '' }">
-                      {{ row.is_afterSale === true ? '该订单有商品申请售后' : '未申请售后' }}
-                    </span>
-                  </template> -->
-                </data-table>
+                <data-table :fields="fields" :opera="opera" @query="search" :data="list" :total="total" @> </data-table>
               </el-col>
             </el-tabs>
           </el-col>
         </span>
-        <!-- <detail_order v-if="view === 'card1_detail'" :id="order_id" @toBack="toBack"></detail_order>
-        <detail_sales_order v-else-if="view === 'card1_sales'" :id="sales_id" @toBack="toBack"></detail_sales_order>
-        <detail_orderDetail v-else-if="view === 'card_detail'" :id="order_id" @toBack="toBack"></detail_orderDetail>
-        <detail_sales_orderDetail v-else-if="view === 'card_sales'" :id="sales_id" :status="status" @toBack="toBack"></detail_sales_orderDetail> -->
       </el-col>
     </el-row>
   </div>
@@ -55,12 +45,6 @@ export default {
   name: 'index',
   props: {},
   components: {
-    // card1: () => import('@/components/orderParts/card-2.vue'),
-    // card2: () => import('@/components/orderParts/card-3.vue'),
-    // detail_order: () => import('@/components/orderParts/detail/detail_order.vue'),
-    // detail_orderDetail: () => import('@/components/orderParts/detail/detail_orderDetail.vue'),
-    // detail_sales_order: () => import('@/components/orderParts/detail/detail_sales_order.vue'),
-    // detail_sales_orderDetail: () => import('@/components/orderParts/detail/detail_sales_orderDetail.vue'),
     search1: () => import('@/components/orderParts/search-2.vue'),
   },
   data: function () {
@@ -117,36 +101,6 @@ export default {
       }
       this.loadings = false;
     },
-
-    // 未付款
-    toDetail(val) {
-      this.$set(this, `order_id`, val);
-      this.$set(this, `view`, 'card1_detail');
-    },
-    toSales(val) {
-      this.$set(this, `sales_id`, val);
-      this.$set(this, `view`, 'card1_sales');
-    },
-    // 待收货,已收货
-    toDetails({ data }) {
-      this.$set(this, `order_id`, data._id);
-      this.$set(this, `view`, 'card_detail');
-    },
-    toSaless({ data }) {
-      this.$set(this, `sales_id`, data._id);
-      this.$set(this, `status`, data.status);
-      this.$set(this, `view`, 'card_sales');
-    },
-    // 待发货
-    toDetail_t(data) {
-      this.$set(this, `order_id`, data);
-      this.$set(this, `view`, 'card_detail');
-    },
-    toSales_t(data) {
-      this.$set(this, `sales_id`, data.id);
-      this.$set(this, `status`, data.status);
-      this.$set(this, `view`, 'card_sales');
-    },
     handleClick(tab) {
       this.loadings = true;
       this.search();
@@ -156,7 +110,6 @@ export default {
     },
     getAddress(i) {
       let name = i.name + ',' + i.phone;
-      // let name = i.name + ',' + i.phone + ',' + i.province;
       return name;
     },
     // 店铺名称