flowDetail.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <script setup lang='ts'>
  2. import { onMounted, reactive, ref } from 'vue'
  3. import { getAccountFlow, getShopList } from '@/api'
  4. import { message } from 'ant-design-vue';
  5. import dayjs, { Dayjs } from 'dayjs';
  6. let time = reactive({
  7. arr: [
  8. dayjs().subtract(7, 'day').format('YYYY-MM-DD'),
  9. dayjs().format('YYYY-MM-DD'),
  10. ]
  11. })
  12. let shopList = reactive({ arr: [{ id: 0, name: '' }] })
  13. interface FormState {
  14. pageNum: Number
  15. pageSize: Number
  16. source: Number
  17. startTime?: String
  18. endTime?: String
  19. orderSn?: String
  20. cityName?: String
  21. shopId?: String
  22. }
  23. const params = reactive<FormState>({
  24. pageNum: 1,
  25. pageSize: 10,
  26. source: 2,
  27. });
  28. const pagination = reactive({
  29. total: 0,
  30. current: params.pageNum,
  31. pageSize: params.pageSize,
  32. })
  33. const columns = reactive([
  34. {
  35. title: '订单号',
  36. dataIndex: 'orderSn',
  37. align: 'center',
  38. key: '1'
  39. },
  40. {
  41. title: '城市',
  42. dataIndex: 'cityName',
  43. align: 'center',
  44. key: '1'
  45. },
  46. {
  47. title: '店铺名称',
  48. dataIndex: 'shopName',
  49. align: 'center',
  50. key: '1'
  51. },
  52. {
  53. title: '时间',
  54. dataIndex: 'createTime',
  55. align: 'center',
  56. key: '1'
  57. },
  58. {
  59. title: '收入(元)',
  60. dataIndex: 'amount',
  61. align: 'center',
  62. key: '1'
  63. },
  64. {
  65. title: '支出(元)',
  66. dataIndex: 'amount',
  67. align: 'center',
  68. key: '2'
  69. }
  70. ])
  71. const data = reactive({ arr: [] })
  72. const handleGetAccountFlow = () => {
  73. params.startTime = time.arr[0]
  74. params.endTime = time.arr[1]
  75. console.log('时间:', time.arr[0]);
  76. getAccountFlow(params).then((res: any) => {
  77. console.log('res', res);
  78. if (res.code === 200) {
  79. data.arr = res.data.data
  80. pagination.total = res.data.totalNums
  81. } else {
  82. message.error(res.msg)
  83. }
  84. })
  85. }
  86. handleGetAccountFlow()
  87. const search = () => {
  88. pagination.current = 1
  89. params.pageNum = 1
  90. handleGetAccountFlow()
  91. }
  92. const handleTableChange = (e: any) => {
  93. pagination.current = e.current
  94. pagination.pageSize = e.pageSize
  95. params.pageNum = e.current
  96. params.pageSize = e.pageSize
  97. handleGetAccountFlow()
  98. }
  99. const handleGetShopList = () => {
  100. getShopList().then((res: any) => {
  101. if (res.code === 200) {
  102. shopList.arr = res.data
  103. } else {
  104. message.error(res.msg)
  105. }
  106. })
  107. }
  108. handleGetShopList()
  109. onMounted(() => {
  110. })
  111. </script>
  112. <template>
  113. <div class="text-20px text-[#222222] font-bold mb-30px">收支明细</div>
  114. <a-form :model="params" name="horizontal_login" layout="inline" autocomplete="off" class="mb-20px">
  115. <a-form-item label="订单号" name="orderSn">
  116. <a-input v-model:value="params.orderSn" placeholder="请输入要查询的订单号">
  117. </a-input>
  118. </a-form-item>
  119. <a-form-item label="城市" name="cityName">
  120. <a-input v-model:value="params.cityName" placeholder="请输入要查询的城市">
  121. </a-input>
  122. </a-form-item>
  123. <a-form-item label="店铺名称" name="shopName">
  124. <a-select v-model:value="params.shopId" style="width: 200px" placeholder="请选择要查询的店铺名称" allowClear>
  125. <a-select-option v-for="(v, i) in shopList.arr" :key="i" :value="v.id">{{ v.name }}</a-select-option>
  126. </a-select>
  127. <!-- <a-input v-model:value="params.shopId" placeholder="请选择要查询的店铺名称"> -->
  128. <!-- </a-input> -->
  129. </a-form-item>
  130. <a-form-item label="日期" name="time">
  131. <a-range-picker v-model:value="time.arr" valueFormat="YYYY-MM-DD" />
  132. </a-form-item>
  133. <a-form-item>
  134. <a-button class="ml-20px" type="primary" @click="search">查 询</a-button>
  135. </a-form-item>
  136. </a-form>
  137. <a-table :columns="columns" :data-source="data.arr" :pagination="pagination" bordered :scroll="true"
  138. @change="handleTableChange">
  139. <template #bodyCell="{ column, text, record }">
  140. <template v-if="column.dataIndex === 'amount' && column.key === '1'">
  141. <div>{{ record.type === 1 ? record.amount : '--' }}</div>
  142. </template>
  143. <template v-if="column.dataIndex === 'amount' && column.key === '2'">
  144. <div>{{ record.type === 2 ? record.amount : '--' }}</div>
  145. </template>
  146. </template>
  147. </a-table>
  148. </template>
  149. <style lang='scss' scoped>
  150. </style>