zs 1 年之前
父节点
当前提交
b90198cc32

+ 61 - 0
src/stores/order/orderDetail.ts

@@ -0,0 +1,61 @@
+import { ref, computed } from 'vue';
+import { defineStore } from 'pinia';
+import { AxiosWrapper } from '@/util/axios-wrapper';
+import _ from 'lodash';
+
+import type { IQueryType, IQueryResult, IQueryParams } from '@/util/types.util';
+const axios = new AxiosWrapper();
+const api = {
+  url: `/material/v1/api/OrderDetail`
+};
+export const OrderDetailStore = defineStore('orderDetail', () => {
+  const count = ref(0);
+  const doubleCount = computed(() => count.value * 2);
+  function increment() {
+    count.value++;
+  }
+  const query = async ({ skip = 0, limit = undefined, ...info }: IQueryParams = {}): Promise<IQueryResult> => {
+    let cond: IQueryType = {};
+    if (skip) cond.skip = skip;
+    if (limit) cond.limit = limit;
+    cond = { ...cond, ...info };
+    const res = await axios.$get(`${api.url}`, cond);
+    return res;
+  };
+  const queryInfo = async ({ skip = 0, limit = undefined, ...info }: IQueryParams = {}): Promise<IQueryResult> => {
+    let cond: IQueryType = {};
+    if (skip) cond.skip = skip;
+    if (limit) cond.limit = limit;
+    cond = { ...cond, ...info };
+    const res = await axios.$get(`${api.url}/queryInfo`, cond);
+    return res;
+  };
+  const fetch = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$get(`${api.url}/${payload}`);
+    return res;
+  };
+  const create = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$post(`${api.url}`, payload);
+    return res;
+  };
+  const update = async (payload: any): Promise<IQueryResult> => {
+    const id = _.get(payload, 'id', _.get(payload, '_id'));
+    const res = await axios.$post(`${api.url}/${id}`, payload);
+    return res;
+  };
+  const del = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$delete(`${api.url}/${payload}`);
+    return res;
+  };
+  return {
+    count,
+    doubleCount,
+    increment,
+    query,
+    queryInfo,
+    fetch,
+    create,
+    update,
+    del
+  };
+});

+ 113 - 16
src/views/order/index.vue

@@ -2,37 +2,134 @@
   <div id="index">
     <el-row>
       <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
-        <el-col :span="24" class="one">系统首页</el-col>
+        <el-col :span="24" class="one">
+          <cSearch :is_title="false" :is_search="true" :fields="fields" @search="toSearch"> </cSearch>
+        </el-col>
+        <el-col :span="24" class="two">
+          <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @exam="toExam"> </cTable>
+        </el-col>
       </el-col>
     </el-row>
+    <cDialog :dialog="dialog" @toClose="toClose">
+      <template v-slot:info>
+        <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
+          <cForm :span="24" :fields="formFields" :form="form" :rules="{}" @save="toSave" label-width="auto">
+            <template #status>
+              <el-option v-for="i in statusList" :key="i.value" :label="i.label" :value="i.value"></el-option>
+            </template>
+          </cForm>
+        </el-col>
+      </template>
+    </cDialog>
   </div>
 </template>
 
 <script setup lang="ts">
 // 基础
+import _ from 'lodash';
 import type { Ref } from 'vue';
-// reactive,
-import { onMounted, ref, getCurrentInstance } from 'vue';
+import { ref, onMounted, getCurrentInstance } from 'vue';
+import { ElMessage } from 'element-plus';
 // 接口
-//import { TestStore } from '@common/src/stores/test';
-//import type { IQueryResult } from '@/util/types.util';
-//const testAxios = TestStore();
+import { OrderDetailStore } from '@/stores/order/orderDetail';
+import { DictDataStore } from '@/stores/dict/dictData';
+import type { IQueryResult } from '@/util/types.util';
+const dictData = DictDataStore();
+const orderDetailAxios = OrderDetailStore();
 const { proxy } = getCurrentInstance() as any;
 // 加载中
 const loading: Ref<any> = ref(false);
-// 分页数据
-//  const skip = 0;
-//  const limit = proxy.limit;;
+// 列表数据
+let list: Ref<any> = ref([]);
+let total: Ref<number> = ref(0);
+let skip = 0;
+let limit: number = proxy.$limit;
+let fields: Ref<any[]> = ref([
+  { label: '总订单id', model: 'order_id', isSearch: true },
+  { label: '用户', model: 'user_name' },
+  { label: '商品', model: 'good_name' },
+  { label: '规格', model: 'spec_name' },
+  { label: '收货地址', model: 'address' },
+  { label: '下单时间', model: 'buy_time' },
+  { label: '状态', model: 'status', format: (i: any) => getDict(i, 'status') }
+]);
+// 操作
+let opera: Ref<any[]> = ref([{ label: '审核', method: 'exam', type: 'warning', display: (i) => i.status == '0' }]);
+// 弹框
+const dialog: Ref<any> = ref({ title: '审核管理', show: false, type: '1' });
+const form: Ref<any> = ref({ file: [] });
+const formFields: Ref<any> = ref([{ label: '状态', model: 'status', type: 'select' }]);
+// 查询数据
+let searchForm: Ref<any> = ref({});
+// 字典表
+let statusList: Ref<any> = ref([]);
+
 // 请求
 onMounted(async () => {
   loading.value = true;
-  //  await search({ skip, limit });
+  await searchOther();
+  await search({ skip, limit });
   loading.value = false;
 });
-//const search = async (e: { skip: number; limit: number }) => {
-//  const info = { skip: e.skip, limit: e.limit, ...searchInfo.value  };
-//  const res: IQueryResult = await testAxios.query(info);
-//  console.log(res);
-//};
+const search = async (e: { skip: number; limit: number }) => {
+  const { skip, limit } = e;
+  const condition = _.cloneDeep(searchForm.value);
+  let info = { limit: limit, skip: skip, ...condition };
+  let res: IQueryResult = await orderDetailAxios.queryInfo(info);
+  if (res.errcode == 0) {
+    list.value = res.data;
+    total.value = res.total;
+  }
+};
+const toSearch = (query: any) => {
+  searchForm.value = query;
+  search({ skip, limit });
+};
+const getDict = (value: any, model: any) => {
+  if (model == 'status') {
+    if (value) {
+      let data = statusList.value.find((i: any) => i.value == value);
+      if (data) return data.label;
+      else return '暂无';
+    }
+  }
+};
+// 审核
+const toExam = async (data) => {
+  let res: IQueryResult = await orderDetailAxios.fetch(data._id);
+  if (res.errcode == '0') {
+    form.value = res.data;
+    dialog.value = { title: '审核管理', show: true, type: '1' };
+  }
+};
+// 提交保存
+const toSave = async (data: any) => {
+  let res: IQueryResult;
+  if (data._id) res = await orderDetailAxios.update(data);
+  else res = await orderDetailAxios.create(data);
+  if (res.errcode == 0) {
+    ElMessage({ type: `success`, message: `维护信息成功` });
+    toClose();
+  }
+};
+// 弹框关闭
+const toClose = () => {
+  form.value = {};
+  dialog.value = { title: '信息管理', show: false, type: '1' };
+  search({ skip, limit });
+};
+// 查询其他信息
+const searchOther = async () => {
+  let res: IQueryResult;
+  // 状态
+  res = await dictData.query({ type: 'order_status' });
+  if (res.errcode == '0') statusList.value = res.data;
+};
 </script>
-<style scoped lang="scss"></style>
+<style scoped lang="scss">
+.main {
+  .two {
+    margin: 0 0 10px 0;
+  }
+}
+</style>

+ 3 - 3
src/views/users/five/index.vue

@@ -55,8 +55,8 @@ let fields: Ref<any[]> = ref([
   { label: '姓名', model: 'name', isSearch: true },
   { label: '性别', model: 'gender', format: (i: any) => getDict(i, genderList.value, 'dict') },
   { label: '角色', model: 'role', format: (i: any) => getDict(i, roleList.value, 'role') },
-  { label: '所属街道', model: 'street', format: (i: any) => getDict(i, belongList.value) },
-  { label: '所属社区', model: 'community', format: (i: any) => getDict(i, belongList.value) },
+  { label: '所属街道', model: 'street', format: (i: any) => getDict(i, belongList.value, 'office') },
+  { label: '所属社区', model: 'community', format: (i: any) => getDict(i, belongList.value, 'office') },
   { label: '状态', model: 'status', format: (i: any) => getDict(i, statusList.value, 'dict') }
 ]);
 // 操作
@@ -104,7 +104,7 @@ const getDict = (e, model, type) => {
     let data: any = model.find((i: any) => i.code == e);
     if (data) return data.name;
     else return '暂无';
-  } else {
+  } else if (type == 'office') {
     let data: any = model.find((i: any) => i._id == e);
     if (data) return data.name;
     else return '暂无';

+ 3 - 3
src/views/users/four/index.vue

@@ -55,8 +55,8 @@ let fields: Ref<any[]> = ref([
   { label: '姓名', model: 'name', isSearch: true },
   { label: '性别', model: 'gender', format: (i: any) => getDict(i, genderList.value, 'dict') },
   { label: '角色', model: 'role', format: (i: any) => getDict(i, roleList.value, 'role') },
-  { label: '所属街道', model: 'street', format: (i: any) => getDict(i, belongList.value) },
-  { label: '所属社区', model: 'community', format: (i: any) => getDict(i, belongList.value) },
+  { label: '所属街道', model: 'street', format: (i: any) => getDict(i, belongList.value, 'office') },
+  { label: '所属社区', model: 'community', format: (i: any) => getDict(i, belongList.value, 'office') },
   { label: '状态', model: 'status', format: (i: any) => getDict(i, statusList.value, 'dict') }
 ]);
 // 操作
@@ -104,7 +104,7 @@ const getDict = (e, model, type) => {
     let data: any = model.find((i: any) => i.code == e);
     if (data) return data.name;
     else return '暂无';
-  } else {
+  } else if (type == 'office') {
     let data: any = model.find((i: any) => i._id == e);
     if (data) return data.name;
     else return '暂无';

+ 3 - 3
src/views/users/one/index.vue

@@ -55,8 +55,8 @@ let fields: Ref<any[]> = ref([
   { label: '姓名', model: 'name', isSearch: true },
   { label: '性别', model: 'gender', format: (i: any) => getDict(i, genderList.value, 'dict') },
   { label: '角色', model: 'role', format: (i: any) => getDict(i, roleList.value, 'role') },
-  { label: '所属街道', model: 'street', format: (i: any) => getDict(i, belongList.value) },
-  { label: '所属社区', model: 'community', format: (i: any) => getDict(i, belongList.value) },
+  { label: '所属街道', model: 'street', format: (i: any) => getDict(i, belongList.value, 'office') },
+  { label: '所属社区', model: 'community', format: (i: any) => getDict(i, belongList.value, 'office') },
   { label: '状态', model: 'status', format: (i: any) => getDict(i, statusList.value, 'dict') }
 ]);
 // 操作
@@ -104,7 +104,7 @@ const getDict = (e, model, type) => {
     let data: any = model.find((i: any) => i.code == e);
     if (data) return data.name;
     else return '暂无';
-  } else {
+  } else if (type == 'office') {
     let data: any = model.find((i: any) => i._id == e);
     if (data) return data.name;
     else return '暂无';

+ 3 - 3
src/views/users/six/index.vue

@@ -55,8 +55,8 @@ let fields: Ref<any[]> = ref([
   { label: '姓名', model: 'name', isSearch: true },
   { label: '性别', model: 'gender', format: (i: any) => getDict(i, genderList.value, 'dict') },
   { label: '角色', model: 'role', format: (i: any) => getDict(i, roleList.value, 'role') },
-  { label: '所属街道', model: 'street', format: (i: any) => getDict(i, belongList.value) },
-  { label: '所属社区', model: 'community', format: (i: any) => getDict(i, belongList.value) },
+ { label: '所属街道', model: 'street', format: (i: any) => getDict(i, belongList.value, 'office') },
+  { label: '所属社区', model: 'community', format: (i: any) => getDict(i, belongList.value, 'office') },
   { label: '状态', model: 'status', format: (i: any) => getDict(i, statusList.value, 'dict') }
 ]);
 // 操作
@@ -104,7 +104,7 @@ const getDict = (e, model, type) => {
     let data: any = model.find((i: any) => i.code == e);
     if (data) return data.name;
     else return '暂无';
-  } else {
+  } else if (type == 'office') {
     let data: any = model.find((i: any) => i._id == e);
     if (data) return data.name;
     else return '暂无';

+ 3 - 3
src/views/users/thr/index.vue

@@ -55,8 +55,8 @@ let fields: Ref<any[]> = ref([
   { label: '姓名', model: 'name', isSearch: true },
   { label: '性别', model: 'gender', format: (i: any) => getDict(i, genderList.value, 'dict') },
   { label: '角色', model: 'role', format: (i: any) => getDict(i, roleList.value, 'role') },
-  { label: '所属街道', model: 'street', format: (i: any) => getDict(i, belongList.value) },
-  { label: '所属社区', model: 'community', format: (i: any) => getDict(i, belongList.value) },
+  { label: '所属街道', model: 'street', format: (i: any) => getDict(i, belongList.value, 'office') },
+  { label: '所属社区', model: 'community', format: (i: any) => getDict(i, belongList.value, 'office') },
   { label: '状态', model: 'status', format: (i: any) => getDict(i, statusList.value, 'dict') }
 ]);
 // 操作
@@ -104,7 +104,7 @@ const getDict = (e, model, type) => {
     let data: any = model.find((i: any) => i.code == e);
     if (data) return data.name;
     else return '暂无';
-  } else {
+  } else if (type == 'office') {
     let data: any = model.find((i: any) => i._id == e);
     if (data) return data.name;
     else return '暂无';

+ 1 - 3
src/views/users/two/index.vue

@@ -32,13 +32,11 @@ import { ElMessage } from 'element-plus';
 import { useRouter } from 'vue-router';
 // 接口
 import { UserStore } from '@/stores/users/user';
-import { OfficeStore } from '@/stores/office/office';
 import { RoleStore } from '@/stores/role/role'; // 角色
 import { DictDataStore } from '@/stores/dict/dictData'; // 字典表
 import type { IQueryResult } from '@/util/types.util';
 const userAxios = UserStore();
 const dictAxios = DictDataStore();
-const officeAxios = OfficeStore();
 const roleAxios = RoleStore();
 const { proxy } = getCurrentInstance() as any;
 // 路由
@@ -101,7 +99,7 @@ const getDict = (e, model, type) => {
     let data: any = model.find((i: any) => i.code == e);
     if (data) return data.name;
     else return '暂无';
-  } else {
+  } else if (type == 'office') {
     let data: any = model.find((i: any) => i._id == e);
     if (data) return data.name;
     else return '暂无';