Selaa lähdekoodia

feat 代码优化

Funny 3 vuotta sitten
vanhempi
commit
798376fdb6

+ 14 - 3
src/api/index.ts

@@ -55,7 +55,7 @@ export const deleteShop = (params: any) => {
 
 // 获取订单列表
 export const orderList = (params: any) => {
-  return get('app/order/listNew', params)
+  return get('app/order/list', params)
 }
 
 // 获取钱包余额
@@ -84,10 +84,21 @@ export const getExplain = (params: any) => {
 
 // 充值记录
 export const rechargeRecord = (params: any) => {
-  return get('app/member/balance/logs', params)
+  return get('app/member/rechargeList', params)
 }
 
 // 消费明细
 export const getAccountFlow = (params: any) => {
   return get('app/member/accountFlow', params)
-}
+}
+
+// 获取门店列表
+export const getShopList = () => {
+  return get('app/shop/listSelect')
+}
+
+// 获取运力列表
+export const getDeliveryList = () => {
+  return get('app/deliveryBind/list')
+}
+

+ 3 - 4
src/components/qrCode.vue

@@ -3,17 +3,16 @@ import { onMounted, ref, defineExpose, nextTick, reactive } from 'vue'
 import QRCode from "qrcodejs2-fixes";
 let visible = ref<boolean>(false)
 let amount = ref<Number>(0)
+let paymentType = ref<Number>(1)
 let qrcode: { makeCode: (arg0: string) => void; clear: () => void; } | null = null
 let payInfo = reactive({
   data: '',
   amount: 0
 })
-const props = defineProps({
-  paymentType: Number
-})
-const qrinit = (v: string) => {
+const qrinit = (v: string, payType: Number) => {
   visible.value = true
   payInfo = JSON.parse(v)
+  paymentType.value = payType
   amount.value = payInfo.amount
   if (qrcode) {
     qrcode.makeCode(payInfo.data)

+ 27 - 8
src/views/management/account/flowDetail.vue

@@ -1,6 +1,6 @@
 <script setup lang='ts'>
 import { onMounted, reactive, ref } from 'vue'
-import { getAccountFlow } from '@/api'
+import { getAccountFlow, getShopList } from '@/api'
 import { message } from 'ant-design-vue';
 import dayjs, { Dayjs } from 'dayjs';
 let time = reactive({
@@ -9,6 +9,7 @@ let time = reactive({
     dayjs().format('YYYY-MM-DD'),
   ]
 })
+let shopList = reactive({ arr: [{ id: 0, name: '' }] })
 interface FormState {
   pageNum: Number
   pageSize: Number
@@ -17,7 +18,7 @@ interface FormState {
   endTime?: String
   orderSn?: String
   cityName?: String
-  shopName?: String
+  shopId?: String
 }
 const params = reactive<FormState>({
   pageNum: 1,
@@ -67,7 +68,7 @@ const columns = reactive([
     key: '2'
   }
 ])
-const data = reactive([])
+const data = reactive({ arr: [] })
 const handleGetAccountFlow = () => {
   params.startTime = time.arr[0]
   params.endTime = time.arr[1]
@@ -75,7 +76,7 @@ const handleGetAccountFlow = () => {
   getAccountFlow(params).then((res: any) => {
     console.log('res', res);
     if (res.code === 200) {
-      Object.assign(data, res.data.data)
+      data.arr = res.data.data
       pagination.total = res.data.totalNums
     } else {
       message.error(res.msg)
@@ -83,6 +84,11 @@ const handleGetAccountFlow = () => {
   })
 }
 handleGetAccountFlow()
+const search = () => {
+  pagination.current = 1
+  params.pageNum = 1
+  handleGetAccountFlow()
+}
 const handleTableChange = (e: any) => {
   pagination.current = e.current
   pagination.pageSize = e.pageSize
@@ -90,6 +96,16 @@ const handleTableChange = (e: any) => {
   params.pageSize = e.pageSize
   handleGetAccountFlow()
 }
+const handleGetShopList = () => {
+  getShopList().then((res: any) => {
+    if (res.code === 200) {
+      shopList.arr = res.data
+    } else {
+      message.error(res.msg)
+    }
+  })
+}
+handleGetShopList()
 onMounted(() => {
 
 })
@@ -106,17 +122,20 @@ onMounted(() => {
       </a-input>
     </a-form-item>
     <a-form-item label="店铺名称" name="shopName">
-      <a-input v-model:value="params.shopName" placeholder="请选择要查询的店铺名称">
-      </a-input>
+      <a-select v-model:value="params.shopId" style="width: 200px" placeholder="请选择要查询的店铺名称" allowClear>
+        <a-select-option v-for="(v, i) in shopList.arr" :key="i" :value="v.id">{{ v.name }}</a-select-option>
+      </a-select>
+      <!-- <a-input v-model:value="params.shopId" placeholder="请选择要查询的店铺名称"> -->
+      <!-- </a-input> -->
     </a-form-item>
     <a-form-item label="日期" name="time">
       <a-range-picker v-model:value="time.arr" valueFormat="YYYY-MM-DD" />
     </a-form-item>
     <a-form-item>
-      <a-button class="ml-20px" type="primary" @click="handleGetAccountFlow">查 询</a-button>
+      <a-button class="ml-20px" type="primary" @click="search">查 询</a-button>
     </a-form-item>
   </a-form>
-  <a-table :columns="columns" :data-source="data" :pagination="pagination" bordered :scroll="true"
+  <a-table :columns="columns" :data-source="data.arr" :pagination="pagination" bordered :scroll="true"
     @change="handleTableChange">
     <template #bodyCell="{ column, text, record }">
       <template v-if="column.dataIndex === 'amount' && column.key === '1'">

+ 1 - 1
src/views/management/account/myWallet.vue

@@ -67,7 +67,7 @@ const handleRecharge = () => {
     if (res.code === 200) {
       orderSn.value = res.data.orderSn
       if (QrCodeRef) {
-        QrCodeRef.value.qrinit(JSON.stringify(res.data))
+        QrCodeRef.value.qrinit(JSON.stringify(res.data), params.paymentType)
         timer.value = window.setInterval(() => {
           handleGetPayResult()
         }, 4000)

+ 32 - 15
src/views/management/account/rechargeRecord.vue

@@ -3,23 +3,23 @@ import { onMounted, reactive, ref } from 'vue'
 import { rechargeRecord } from '@/api'
 import { message } from 'ant-design-vue';
 import dayjs, { Dayjs } from 'dayjs';
-let time = ref<[Dayjs, Dayjs]>([
-  dayjs().subtract(7, 'day'),
-  dayjs(),
-])
+let time = reactive({
+  arr: [
+    dayjs().subtract(7, 'day').format('YYYY-MM-DD'),
+    dayjs().format('YYYY-MM-DD'),
+  ]
+})
 interface FormState {
   pageNum: Number
   pageSize: Number
-  source: Number
-  minAmount?: Number
-  maxAmount?: Number
+  // minAmount?: Number
+  // maxAmount?: Number
   startTime?: String
   endTime?: String
 }
 const params = reactive<FormState>({
   pageNum: 1,
   pageSize: 10,
-  source: 1,
 });
 const pagination = reactive({
   total: 0,
@@ -29,7 +29,7 @@ const pagination = reactive({
 const columns = reactive([
   {
     title: '流水号',
-    dataIndex: 'id',
+    dataIndex: 'rechargeSn',
     align: 'center',
   },
   {
@@ -44,13 +44,14 @@ const columns = reactive([
   },
   {
     title: '支付方式',
-    dataIndex: 'remark',
+    dataIndex: 'paymentType',
     align: 'center',
   }
 ])
 const data = reactive([])
 const handleRechargeRecord = () => {
-
+  params.startTime = time.arr[0]
+  params.endTime = time.arr[1]
   rechargeRecord(params).then((res: any) => {
     console.log('res', res);
     if (res.code === 200) {
@@ -62,6 +63,11 @@ const handleRechargeRecord = () => {
   })
 }
 handleRechargeRecord()
+const search = () => {
+  pagination.current = 1
+  params.pageNum = 1
+  handleRechargeRecord()
+}
 const handleTableChange = (e: any) => {
   pagination.current = e.current
   pagination.pageSize = e.pageSize
@@ -69,6 +75,14 @@ const handleTableChange = (e: any) => {
   params.pageSize = e.pageSize
   handleRechargeRecord()
 }
+
+const showPayType = (v: Number) => {
+  if (v === 1) {
+    return '支付宝'
+  } else {
+    return '微信'
+  }
+}
 onMounted(() => {
 
 })
@@ -77,9 +91,9 @@ onMounted(() => {
   <div class="text-20px text-[#222222] font-bold mb-30px">充值记录</div>
   <a-form :model="params" name="horizontal_login" layout="inline" autocomplete="off" class="mb-20px">
     <a-form-item label="日期" name="mobile">
-      <a-range-picker v-model:value="time" format="YYYY/MM/DD" />
+      <a-range-picker v-model:value="time.arr" valueFormat="YYYY/MM/DD" />
     </a-form-item>
-    <a-form-item label="金额范围">
+    <!-- <a-form-item label="金额范围">
       <custom-com>
         <div class="flex items-center h-32px border-1px bg-[#ffffff]">
           <a-input v-model:value="params.minAmount" :bordered="false" class="w-120px text-center"
@@ -89,14 +103,17 @@ onMounted(() => {
             placeholder="查询最大金额" />
         </div>
       </custom-com>
-    </a-form-item>
+    </a-form-item> -->
     <a-form-item>
-      <a-button class="ml-20px" type="primary" @click="handleRechargeRecord">查 询</a-button>
+      <a-button class="ml-20px" type="primary" @click="search">查 询</a-button>
     </a-form-item>
   </a-form>
   <a-table :columns="columns" :data-source="data" :pagination="pagination" bordered :scroll="true"
     @change="handleTableChange">
     <template #bodyCell="{ column, text, record }">
+      <template v-if="column.dataIndex === 'paymentType'">
+        <div>{{ showPayType(record.paymentType) }}</div>
+      </template>
     </template>
   </a-table>
 

+ 41 - 17
src/views/management/order/order.vue

@@ -1,6 +1,6 @@
 <script setup lang='ts'>
 import { onMounted, reactive, ref } from 'vue'
-import { orderList } from '@/api'
+import { orderList, getShopList, getDeliveryList } from '@/api'
 import { message } from 'ant-design-vue';
 import dayjs, { Dayjs } from 'dayjs';
 let time = reactive({
@@ -9,26 +9,23 @@ let time = reactive({
     dayjs().format('YYYY-MM-DD'),
   ]
 })
+let shopList = reactive({ arr: [{ id: 0, name: '' }] })
+let deliveryList = reactive({ arr: [{ id: 0, name: '' }] })
 interface FormState {
-  searchType: number;
-  cityName: string;
+  city: string;
   shopId?: number;
   deliveryId?: number;
-  status: number;
+  status?: number;
   startDate?: string;
   endDate?: string;
   searchKey: string;
-  searchKeyType: number;
   pageNum: number;
   pageSize: number;
 
 }
 const formState = reactive<FormState>({
-  searchType: 1,
-  cityName: '',
-  status: 99,
+  city: '',
   searchKey: '',
-  searchKeyType: 5,
   pageNum: 1,
   pageSize: 10,
 });
@@ -103,6 +100,31 @@ const getOrderList = () => {
   })
 }
 getOrderList()
+const handleGetShopList = () => {
+  getShopList().then((res: any) => {
+    if (res.code === 200) {
+      shopList.arr = res.data
+    } else {
+      message.error(res.msg)
+    }
+  })
+}
+handleGetShopList()
+const handleGetDeliveryList = () => {
+  getDeliveryList().then((res: any) => {
+    if (res.code === 200) {
+      deliveryList.arr = res.data
+    } else {
+      message.error(res.msg)
+    }
+  })
+}
+handleGetDeliveryList()
+const search = () => {
+  pagination.current = 1
+  formState.pageNum = 1
+  getOrderList()
+}
 const handleTableChange = (e: any) => {
   pagination.current = e.current
   pagination.pageSize = e.pageSize
@@ -117,17 +139,19 @@ onMounted(() => {
 <template>
   <div class="text-20px text-[#222222] font-bold mb-30px">订单管理</div>
   <a-form :model="formState" name="horizontal_login" layout="inline" autocomplete="off" class="mb-20px">
-    <a-form-item label="城市" name="cityName">
-      <a-input v-model:value="formState.cityName" placeholder="请输入要查询的城市">
+    <a-form-item label="城市" name="city">
+      <a-input v-model:value="formState.city" placeholder="请输入要查询的城市">
       </a-input>
     </a-form-item>
     <a-form-item label="店铺" name="shopId">
-      <a-input v-model:value="formState.shopId" placeholder="请选择要查询的店铺">
-      </a-input>
+      <a-select v-model:value="formState.shopId" style="width: 200px" placeholder="请选择要查询的店铺名称" allowClear>
+        <a-select-option v-for="(v, i) in shopList.arr" :key="i" :value="v.id">{{ v.name }}</a-select-option>
+      </a-select>
     </a-form-item>
     <a-form-item label="配送平台" name="deliveryId">
-      <a-input v-model:value="formState.deliveryId" placeholder="请选择要查询的配送平台">
-      </a-input>
+      <a-select v-model:value="formState.deliveryId" style="width: 200px" placeholder="请选择要查询的配送平台" allowClear>
+        <a-select-option v-for="(v, i) in deliveryList.arr" :key="i" :value="v.id">{{ v.name }}</a-select-option>
+      </a-select>
     </a-form-item>
     <a-form-item label="订单状态" name="status">
       <a-input v-model:value="formState.status" placeholder="请选择要查询的订单状态">
@@ -137,11 +161,11 @@ onMounted(() => {
       <a-input v-model:value="formState.searchKey" placeholder="请输入要查询的订单号">
       </a-input>
     </a-form-item>
-    <a-form-item label="日期" name="mobile">
+    <a-form-item label="日期" name="time">
       <a-range-picker v-model:value="time.arr" valueFormat="YYYY/MM/DD" />
     </a-form-item>
     <a-form-item>
-      <a-button class="ml-20px" type="primary" @click="getOrderList">查 询</a-button>
+      <a-button class="ml-20px" type="primary" @click="search">查 询</a-button>
       <a-button class="ml-20px" type="primary" ghost html-type="submit">导 出</a-button>
     </a-form-item>
   </a-form>

+ 30 - 13
src/views/management/shop/shop.vue

@@ -1,10 +1,12 @@
 <script setup lang='ts'>
 import { onMounted, reactive, ref } from 'vue'
-import { shopList, deleteShop } from '@/api'
+import { shopList, deleteShop, getShopList } from '@/api'
 import { message } from 'ant-design-vue';
+let shopListSearch = reactive({ arr: [{ id: 0, name: '' }] })
 interface FormState {
   cityName: string;
   name: string;
+  shopId?: Number;
   mobile?: number;
 }
 const formState = reactive<FormState>({
@@ -45,6 +47,7 @@ const columns = reactive([
   {
     title: '已获运力',
     dataIndex: 'deliveries',
+    width: '25%',
     align: 'center',
   },
   {
@@ -55,21 +58,34 @@ const columns = reactive([
     align: 'center',
   }
 ])
-const data = reactive([])
-const getShopList = () => {
+const data = reactive({ arr: [] })
+const handleShopList = () => {
   shopList(formState).then((res: any) => {
     console.log('res', res);
     if (res.code) {
-      Object.assign(data, res.data)
+      data.arr = res.data
+    } else {
+      message.error(res.msg)
+    }
+  })
+}
+handleShopList()
+const handleGetShopList = () => {
+  getShopList().then((res: any) => {
+    console.log('res', res);
+    if (res.code) {
+      shopListSearch.arr = res.data
+    } else {
+      message.error(res.msg)
     }
   })
 }
-getShopList()
+handleGetShopList()
 const onDelete = (shopId: number) => {
   deleteShop({ shopId }).then((res: any) => {
     if (res.code === 200) {
       message.success('已经成功删除!')
-      getShopList()
+      handleShopList()
     } else {
       message.error(res.msg)
     }
@@ -87,29 +103,30 @@ onMounted(() => {
       </a-input>
     </a-form-item>
     <a-form-item label="店铺名称" name="name">
-      <a-input v-model:value="formState.name" placeholder="请选择要查询的店铺">
-      </a-input>
+      <a-select v-model:value="formState.shopId" style="width: 200px" placeholder="请选择要查询的店铺名称" allowClear>
+        <a-select-option v-for="(v, i) in shopListSearch.arr" :key="i" :value="v.id">{{ v.name }}</a-select-option>
+      </a-select>
     </a-form-item>
     <a-form-item label="联系人电话" name="mobile">
       <a-input v-model:value="formState.mobile" placeholder="请输入要查询的联系人电话">
       </a-input>
     </a-form-item>
     <a-form-item>
-      <a-button class="ml-20px" type="primary" @click="getShopList">查 询</a-button>
+      <a-button class="ml-20px" type="primary" @click="handleShopList">查 询</a-button>
       <a-button class="ml-20px" type="primary" ghost html-type="submit">导 出</a-button>
       <a-button class="ml-20px" type="primary" ghost html-type="submit">+新建门店</a-button>
     </a-form-item>
   </a-form>
-  <a-table :columns="columns" :data-source="data" :pagination="false" bordered :scroll="true">
-    <template #bodyCell="{ column, text,record  }">
+  <a-table :columns="columns" :data-source="data.arr" :pagination="false" bordered :scroll="true">
+    <template #bodyCell="{ column, text, record }">
       <template v-if="column.dataIndex === 'deliveries'">
-        <div class="flex justify-center">
+        <div class="flex flex-wrap justify-center">
           <img :src="v.logo" alt="" v-for="(v, i) in text" :key="i" class="w-20px h-20px mr-10px">
         </div>
       </template>
       <template v-if="column.dataIndex === 'operation'">
         <a class="text-blue-500">编辑</a>
-        <a-popconfirm v-if="data.length" title="确定删除该店铺?" ok-text="确定" cancel-text="取消" @confirm="onDelete(record.id)">
+        <a-popconfirm v-if="data.arr.length" title="确定删除该店铺?" ok-text="确定" cancel-text="取消" @confirm="onDelete(record.id)">
           <a class="text-blue-500 ml-20px">删除</a>
         </a-popconfirm>
       </template>