YY před 2 roky
rodič
revize
6811f2e86f

+ 4 - 0
src/store/index.js

@@ -15,6 +15,8 @@ import shop from './module/shop/shop';
 import selfShop from './module/shop/selfShop';
 import goods from './module/shop/goods';
 import goodsSpec from './module/shop/goodsSpec';
+import order from './module/shop/order';
+import orderDetail from './module/shop/orderDetail';
 Vue.use(Vuex);
 
 export default new Vuex.Store({
@@ -32,5 +34,7 @@ export default new Vuex.Store({
     banner,
     indexModule,
     goodsSpec,
+    order,
+    orderDetail,
   },
 });

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

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

+ 151 - 7
src/views/selfShop/order/index.vue

@@ -1,27 +1,171 @@
 <template>
   <div id="index">
-    <p>order</p>
+    <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" :statusList="statusList" @onSubmit="search" @toReset="toClose" :total="total"></search-1>
+        </el-col>
+        <el-col :span="24" class="thr">
+          <el-button type="primary" size="mini" @click="toAdd()">新增</el-button>
+        </el-col>
+        <el-col :span="24" class="four">
+          <el-tabs v-model="activeName" type="border-card" @tab-click="handleClick">
+            <el-tab-pane label="待付款" name="1">
+              <card-1 :list="list" :toEdit="toEdit" :toDel="toDel" :total="total" :statusList="statusList"></card-1>
+            </el-tab-pane>
+            <el-tab-pane label="待发货" name="2">
+              <card-2 :list="list" :toEdit="toEdit" :toDel="toDel" :total="total" :statusList="statusList"></card-2>
+            </el-tab-pane>
+            <el-tab-pane label="待收货" name="3">
+              <card-3 :list="list" :toEdit="toEdit" :toDel="toDel" :total="total" :statusList="statusList"></card-3>
+            </el-tab-pane>
+            <el-tab-pane label="已收货" name="4">
+              <card-4 :list="list" :toEdit="toEdit" :toDel="toDel" :total="total" :statusList="statusList"></card-4>
+            </el-tab-pane>
+          </el-tabs>
+        </el-col>
+      </el-col>
+    </el-row>
   </div>
 </template>
 
 <script>
-import { mapState, createNamespacedHelpers } from 'vuex';
+const _ = require('lodash');
+import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('order');
+const { mapActions: orderDetail } = createNamespacedHelpers('orderDetail');
+const { mapActions: dictData } = createNamespacedHelpers('dictData');
+
 export default {
   name: 'index',
   props: {},
-  components: {},
+  components: {
+    search1: () => import('./parts/search-1.vue'),
+    card1: () => import('./parts/card-1.vue'),
+    card2: () => import('./parts/card-2.vue'),
+    card3: () => import('./parts/card-3.vue'),
+    card4: () => import('./parts/card-4.vue'),
+  },
   data: function () {
-    return {};
+    const that = this;
+    return {
+      activeName: '2',
+      list: [],
+      total: 0,
+      // 查询
+      searchForm: {},
+      // 多选值
+      selected: [],
+      // 类型列表
+      statusList: [],
+    };
+  },
+  async created() {
+    await this.searchOther();
+    await this.search();
+  },
+  methods: {
+    ...dictData({ dictQuery: 'query' }),
+    ...mapActions(['query', 'fetch', 'create', 'update', 'delete']),
+    ...orderDetail({ orderQuery: 'query', orderFetch: 'fetch', orderCreate: 'create', orderUpdate: 'update', orderDelete: 'delete' }),
+    // 查询
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const condition = _.cloneDeep(this.searchForm);
+      if (this.activeName == '1') {
+        info.status = '0';
+        let res = await this.query({ skip, limit, ...condition, ...info });
+        if (this.$checkRes(res)) {
+          this.$set(this, 'list', res.data);
+          this.$set(this, 'total', res.total);
+        }
+      } else if (this.activeName == '2') {
+        info.status = '1';
+        let res = await this.orderQuery({ skip, limit, ...condition, ...info });
+        if (this.$checkRes(res)) {
+          this.$set(this, 'list', res.data);
+          this.$set(this, 'total', res.total);
+        }
+      } else if (this.activeName == '3') {
+        info.status = '2';
+        let res = await this.orderQuery({ skip, limit, ...condition, ...info });
+        if (this.$checkRes(res)) {
+          this.$set(this, 'list', res.data);
+          this.$set(this, 'total', res.total);
+        }
+      } else if (this.activeName == '4') {
+        info.status = '3';
+        let res = await this.orderQuery({ skip, limit, ...condition, ...info });
+        if (this.$checkRes(res)) {
+          this.$set(this, 'list', res.data);
+          this.$set(this, 'total', res.total);
+        }
+      }
+    },
+    handleClick(tab, event) {
+      this.search();
+    },
+    // 新增
+    toAdd() {},
+    // 修改
+    async toEdit({ data }) {},
+    async toDel({ data }) {
+      let res = await this.delete(data._id);
+      if (this.$checkRes(res)) {
+        this.$message({ type: `success`, message: `刪除信息成功` });
+        this.search();
+      }
+    },
+    toClose() {
+      this.searchForm = {};
+      this.search();
+    },
+    // 多选
+    handleSelect(data) {
+      this.$set(this, `selected`, data);
+    },
+    // 查询其他信息
+    async searchOther() {
+      let res;
+      // 类型
+      res = await this.dictQuery({ code: 'order_process' });
+      if (this.$checkRes(res)) {
+        this.$set(this, `statusList`, res.data);
+      }
+    },
   },
   computed: {
     ...mapState(['user']),
   },
-  created() {},
-  methods: {},
   metaInfo() {
     return { title: this.$route.meta.title };
   },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
 };
 </script>
 
-<style lang="less" scoped></style>
+<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>

+ 84 - 0
src/views/selfShop/order/parts/card-1.vue

@@ -0,0 +1,84 @@
+<template>
+  <div id="card-1">
+    <el-row>
+      <el-col :span="24" class="main">
+        <data-table
+          :select="true"
+          :selected="selected"
+          @handleSelect="handleSelect"
+          :fields="fields"
+          :opera="opera"
+          @query="search"
+          :data="list"
+          :total="total"
+          @edit="toEdit"
+          @del="toDel"
+        >
+        </data-table>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+export default {
+  name: 'card-1',
+  props: { list: { type: Array }, total: { type: Number }, statusList: { type: Array } },
+  components: {},
+  data: function () {
+    return {
+      opera: [
+        { label: '修改', method: 'edit' },
+        { label: '删除', method: 'del', confirm: true, type: 'danger' },
+      ],
+      fields: [
+        { label: '店铺名称', model: 'goods[0].shop_name' },
+        { label: '支付金额', model: 'pay.pay_money' },
+        {
+          label: '订单状态',
+          model: 'status',
+          format: (i) => {
+            let data = this.statusList.find((f) => f.value == i);
+            if (data) return data.label;
+            else return '暂无';
+          },
+        },
+      ],
+      // 多选值
+      selected: [],
+    };
+  },
+  async created() {},
+  methods: {
+    search() {
+      this.$emit('search');
+    },
+    toEdit() {
+      this.$emit('toEdit');
+    },
+    toDel() {
+      this.$emit('toDel');
+    },
+    // 多选
+    handleSelect(data) {
+      this.$emit('handleSelect');
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 84 - 0
src/views/selfShop/order/parts/card-2.vue

@@ -0,0 +1,84 @@
+<template>
+  <div id="card-1">
+    <el-row>
+      <el-col :span="24" class="main">
+        <data-table
+          :select="true"
+          :selected="selected"
+          @handleSelect="handleSelect"
+          :fields="fields"
+          :opera="opera"
+          @query="search"
+          :data="list"
+          :total="total"
+          @edit="toEdit"
+          @del="toDel"
+        >
+        </data-table>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+export default {
+  name: 'card-1',
+  props: { list: { type: Array }, total: { type: Number }, statusList: { type: Array } },
+  components: {},
+  data: function () {
+    return {
+      opera: [
+        { label: '修改', method: 'edit' },
+        { label: '删除', method: 'del', confirm: true, type: 'danger' },
+      ],
+      fields: [
+        { label: '店铺名称', model: 'shop.name' },
+        { label: '支付金额', model: 'pay.pay_money' },
+        {
+          label: '订单状态',
+          model: 'status',
+          format: (i) => {
+            let data = this.statusList.find((f) => f.value == i);
+            if (data) return data.label;
+            else return '暂无';
+          },
+        },
+      ],
+      // 多选值
+      selected: [],
+    };
+  },
+  async created() {},
+  methods: {
+    search() {
+      this.$emit('search');
+    },
+    toEdit() {
+      this.$emit('toEdit');
+    },
+    toDel() {
+      this.$emit('toDel');
+    },
+    // 多选
+    handleSelect(data) {
+      this.$emit('handleSelect');
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 84 - 0
src/views/selfShop/order/parts/card-3.vue

@@ -0,0 +1,84 @@
+<template>
+  <div id="card-1">
+    <el-row>
+      <el-col :span="24" class="main">
+        <data-table
+          :select="true"
+          :selected="selected"
+          @handleSelect="handleSelect"
+          :fields="fields"
+          :opera="opera"
+          @query="search"
+          :data="list"
+          :total="total"
+          @edit="toEdit"
+          @del="toDel"
+        >
+        </data-table>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+export default {
+  name: 'card-1',
+  props: { list: { type: Array }, total: { type: Number }, statusList: { type: Array } },
+  components: {},
+  data: function () {
+    return {
+      opera: [
+        { label: '修改', method: 'edit' },
+        { label: '删除', method: 'del', confirm: true, type: 'danger' },
+      ],
+      fields: [
+        { label: '店铺名称', model: 'shop.name' },
+        { label: '支付金额', model: 'pay.pay_money' },
+        {
+          label: '订单状态',
+          model: 'status',
+          format: (i) => {
+            let data = this.statusList.find((f) => f.value == i);
+            if (data) return data.label;
+            else return '暂无';
+          },
+        },
+      ],
+      // 多选值
+      selected: [],
+    };
+  },
+  async created() {},
+  methods: {
+    search() {
+      this.$emit('search');
+    },
+    toEdit() {
+      this.$emit('toEdit');
+    },
+    toDel() {
+      this.$emit('toDel');
+    },
+    // 多选
+    handleSelect(data) {
+      this.$emit('handleSelect');
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 84 - 0
src/views/selfShop/order/parts/card-4.vue

@@ -0,0 +1,84 @@
+<template>
+  <div id="card-1">
+    <el-row>
+      <el-col :span="24" class="main">
+        <data-table
+          :select="true"
+          :selected="selected"
+          @handleSelect="handleSelect"
+          :fields="fields"
+          :opera="opera"
+          @query="search"
+          :data="list"
+          :total="total"
+          @edit="toEdit"
+          @del="toDel"
+        >
+        </data-table>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+export default {
+  name: 'card-1',
+  props: { list: { type: Array }, total: { type: Number }, statusList: { type: Array } },
+  components: {},
+  data: function () {
+    return {
+      opera: [
+        { label: '修改', method: 'edit' },
+        { label: '删除', method: 'del', confirm: true, type: 'danger' },
+      ],
+      fields: [
+        { label: '店铺名称', model: 'shop.name' },
+        { label: '支付金额', model: 'pay.pay_money' },
+        {
+          label: '订单状态',
+          model: 'status',
+          format: (i) => {
+            let data = this.statusList.find((f) => f.value == i);
+            if (data) return data.label;
+            else return '暂无';
+          },
+        },
+      ],
+      // 多选值
+      selected: [],
+    };
+  },
+  async created() {},
+  methods: {
+    search() {
+      this.$emit('search');
+    },
+    toEdit() {
+      this.$emit('toEdit');
+    },
+    toDel() {
+      this.$emit('toDel');
+    },
+    // 多选
+    handleSelect(data) {
+      this.$emit('handleSelect');
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 73 - 0
src/views/selfShop/order/parts/search-1.vue

@@ -0,0 +1,73 @@
+<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="6">
+            <el-form-item label="订单状态" prop="type">
+              <el-select v-model="form.type" clearable filterable placeholder="请选择" style="width: 100%" size="small">
+                <el-option v-for="i in statusList" :key="i.label" :label="i.label" :value="i.value"></el-option>
+              </el-select>
+            </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 }, statusList: { 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>