hexiao_record.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template>
  2. <view class="page-container">
  3. <view class="sticky-header">
  4. <view class="search-wrapper">
  5. <view class="query">
  6. <u-row customStyle="margin-bottom: 10px" gutter="20">
  7. <u-col span="9">
  8. <u--input
  9. @focus="timeShow = true"
  10. v-model="startTimeXd"
  11. placeholder="开始日期 ~ 结束日期"
  12. prefixIcon="calendar"
  13. prefixIconStyle="font-size: 22px;color: #909399"
  14. @clear="handleSearch"
  15. ></u--input>
  16. </u-col>
  17. <u-col span="3">
  18. <view class="query-btn" @click="clearSearch">
  19. <view class="query-btn-text">清空</view>
  20. </view>
  21. </u-col>
  22. </u-row>
  23. </view>
  24. </view>
  25. <view class="tabs-wrapper">
  26. <view
  27. v-for="tab in tabs"
  28. :key="tab.key"
  29. class="tab-item"
  30. :class="{ 'active': currentTab === tab.id }"
  31. @click="changeTab(tab.id)"
  32. >
  33. {{ tab.name }}
  34. </view>
  35. </view>
  36. </view>
  37. <scroll-view class="list-container" scroll-y="true" @scrolltolower="loadMore">
  38. <view v-if="recordList.length === 0 && loadStatus !== 'loading'" class="empty-list">
  39. <text>暂无相关记录</text>
  40. </view>
  41. <view v-for="record in recordList" :key="record.orderNo" class="record-card">
  42. <view class="card-header">
  43. <uni-icons type="paperclip" size="20" color="#3c82f8"></uni-icons>
  44. <text class="record-id" @click="detail(record.orderNo)" style="text-decoration: underline">{{ record.orderNo }}</text>
  45. <view class="status-badge pending" v-if="record.status === 0">
  46. {{ getStatusText(record.status) }}
  47. </view>
  48. <view class="status-badge verifying" v-if="record.status === 1">
  49. {{ getStatusText(record.status) }}
  50. </view>
  51. <view class="status-badge verified" v-if="record.status === 2">
  52. {{ getStatusText(record.status) }}
  53. </view>
  54. </view>
  55. <view class="card-body">
  56. <view class="detail-row">
  57. <text class="detail-label">门店名称</text>
  58. <text class="detail-value">{{ record.storeName }}</text>
  59. </view>
  60. <view class="detail-row">
  61. <text class="detail-label">上传时间</text>
  62. <text class="detail-value">{{ record.uploadTime }}</text>
  63. </view>
  64. <view class="detail-row">
  65. <text class="detail-label">商品总数</text>
  66. <text class="detail-value">{{ record.writeOffNum }}</text>
  67. </view>
  68. <view class="detail-row product-item" v-for="(item, index) in record.writeOffRecordDetailVos" :key="index">
  69. <text class="detail-label">{{ item.categoryName }}</text>
  70. <text class="detail-value">{{ item.num }}</text>
  71. </view>
  72. <view class="detail-row" v-if="record.status === 1 ||record.status === 2">
  73. <text class="detail-label">提交时间</text>
  74. <text class="detail-value">{{ record.applyTime }}</text>
  75. </view>
  76. <view class="detail-row" v-if="record.status === 2">
  77. <text class="detail-label">审核时间</text>
  78. <text class="detail-value">{{ record.writeOffTime }}</text>
  79. </view>
  80. </view>
  81. <view class="card-footer" v-if="record.status === 0">
  82. <button class="verify-btn" @click="verify(record.id,record.orderNo)">一键核销</button>
  83. </view>
  84. </view>
  85. <uni-load-more :status="loadStatus"></uni-load-more>
  86. </scroll-view>
  87. <u-calendar @close="timeShow = false" :show="timeShow" :mode="mode" @confirm="confirm"></u-calendar>
  88. </view>
  89. </template>
  90. <script>
  91. import {queryAddRecord,doCommitToJxs} from "@/api/hexiao";
  92. export default {
  93. data() {
  94. return {
  95. startTime: '',
  96. endTime: '',
  97. timeShow: false,
  98. startTimeXd:"",
  99. mode: 'range',
  100. searchQuery: '',
  101. tabs: [
  102. { name: '待核销', key: 'pending',id: 0 },
  103. { name: '核销中', key: 'verifying', id: 1},
  104. { name: '已核销', key: 'verified' , id :2},
  105. ],
  106. currentTab: 0,
  107. recordList: [],
  108. pagination: { page: 1, limit: 10 },
  109. loadStatus: 'more', // 'more', 'loading', 'noMore'
  110. isLoading: false,
  111. };
  112. },
  113. onLoad() {
  114. this.fetchRecords(true);
  115. },
  116. onPullDownRefresh() {
  117. this.fetchRecords(true);
  118. },
  119. methods: {
  120. confirm(e) {
  121. this.startTime = e[0];
  122. this.endTime = e[e.length-1];
  123. this.startTimeXd = e[0]+' ~ '+e[e.length-1];
  124. if(!this.show){
  125. this.handleSearch()
  126. }
  127. this.timeShow = false;
  128. },
  129. getStatusClass(status){
  130. const statusMap = {
  131. 0: 'pending',
  132. 1: 'verifying',
  133. 2: 'verified'
  134. };
  135. return statusMap[status] || '';
  136. },
  137. getStatusText(status) {
  138. const statusMap = {
  139. 0: '待核销',
  140. 1: '核销中',
  141. 2: '已核销'
  142. };
  143. return statusMap[status] || '未知';
  144. },
  145. changeTab(tabKey) {
  146. if (this.currentTab === tabKey) return;
  147. this.currentTab = tabKey;
  148. this.fetchRecords(true); // 切换tab时重新加载数据
  149. },
  150. async fetchRecords(isRefresh = false) {
  151. if (this.isLoading || (this.loadStatus === 'noMore' && !isRefresh)) {
  152. return;
  153. }
  154. if (isRefresh) {
  155. this.pagination.page = 1;
  156. this.recordList = [];
  157. this.loadStatus = 'more';
  158. }
  159. this.isLoading = true;
  160. this.loadStatus = 'loading';
  161. let data = {};
  162. if(this.currentTab !== -1){
  163. data.status = this.currentTab;
  164. }
  165. data.startTime = this.startTime;
  166. data.endTime = this.endTime;
  167. data.pageIndex = this.pagination.page
  168. data.pageSize = this.pagination.limit
  169. queryAddRecord(data).then(res=>{
  170. let finalData = res.data.records;
  171. if(!finalData){
  172. finalData = [];
  173. }
  174. if (finalData.length > 0) {
  175. this.recordList = [...this.recordList, ...finalData];
  176. this.pagination.page++;
  177. this.loadStatus = 'more';
  178. } else {
  179. this.loadStatus = 'noMore';
  180. }
  181. this.isLoading = false;
  182. uni.stopPullDownRefresh();
  183. });
  184. },
  185. detail(id){
  186. uni.navigateTo({ url: `/pages/hexiao/ywy/hexiao_detail?id=`+id });
  187. },
  188. loadMore() {
  189. this.fetchRecords();
  190. },
  191. clearSearch(){
  192. this.startTime = "";
  193. this.endTime = "";
  194. this.startTimeXd = "";
  195. this.handleSearch()
  196. },
  197. handleSearch() {
  198. this.fetchRecords(true);
  199. },
  200. verify(id,orderNo) {
  201. uni.showModal({
  202. title: '提示',
  203. content: `确认核销订单 ${orderNo} 吗?`,
  204. success: (res) => {
  205. if (res.confirm) {
  206. doCommitToJxs(id).then(res=>{
  207. if(res.code === 0){
  208. this.fetchRecords(true);
  209. uni.showToast({ title: '核销成功' });
  210. }else{
  211. uni.showToast({ title: '核销失败' });
  212. }
  213. });
  214. }
  215. }
  216. });
  217. }
  218. }
  219. }
  220. </script>
  221. <style lang="scss" scoped>
  222. .page-container {
  223. display: flex;
  224. flex-direction: column;
  225. height: 100vh;
  226. background-color: #f5f6fa;
  227. }
  228. .sticky-header {
  229. position: sticky;
  230. top: 0;
  231. z-index: 100;
  232. background-color: #f5f6fa;
  233. }
  234. .search-wrapper {
  235. padding: 20rpx;
  236. background-color: #ffffff;
  237. }
  238. .search-bar {
  239. display: flex;
  240. align-items: center;
  241. background-color: #f5f6fa;
  242. border-radius: 50rpx;
  243. padding: 0 25rpx;
  244. height: 70rpx;
  245. }
  246. .search-input { flex: 1; font-size: 28rpx; margin-left: 15rpx; }
  247. .placeholder { color: #b0b0b0; }
  248. .tabs-wrapper {
  249. display: flex;
  250. background-color: #ffffff;
  251. border-bottom: 1rpx solid #f0f0f0;
  252. .tab-item {
  253. flex: 1;
  254. text-align: center;
  255. padding: 25rpx 0;
  256. font-size: 28rpx;
  257. color: #666;
  258. position: relative;
  259. &.active {
  260. color: #3c82f8;
  261. font-weight: 500;
  262. &::after {
  263. content: '';
  264. position: absolute;
  265. bottom: 0;
  266. left: 50%;
  267. transform: translateX(-50%);
  268. width: 60rpx;
  269. height: 6rpx;
  270. background-color: #3c82f8;
  271. border-radius: 3rpx;
  272. }
  273. }
  274. }
  275. }
  276. .list-container {
  277. flex: 1;
  278. height: 100%;
  279. }
  280. .empty-list { text-align: center; color: #999; padding-top: 150rpx; }
  281. .record-card {
  282. background-color: #ffffff;
  283. border-radius: 16rpx;
  284. margin: 20rpx;
  285. padding: 30rpx;
  286. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
  287. position: relative;
  288. }
  289. .card-header {
  290. display: flex;
  291. align-items: center;
  292. padding-bottom: 20rpx;
  293. border-bottom: 1rpx solid #f5f5f5;
  294. .record-id {
  295. font-size: 30rpx;
  296. font-weight: bold;
  297. color: #333;
  298. margin-left: 15rpx;
  299. }
  300. }
  301. .status-badge {
  302. position: absolute;
  303. top: 0;
  304. right: 0;
  305. padding: 8rpx 20rpx;
  306. font-size: 24rpx;
  307. color: #fff;
  308. border-top-right-radius: 16rpx;
  309. border-bottom-left-radius: 16rpx;
  310. &.pending { background-color: #3c82f8; }
  311. &.verifying { background-color: #ff9900; }
  312. &.verified { background-color: #54CFAB; }
  313. }
  314. .card-body {
  315. padding-top: 10rpx;
  316. }
  317. .detail-row {
  318. display: flex;
  319. justify-content: space-between;
  320. align-items: center;
  321. padding: 12rpx 0;
  322. font-size: 28rpx;
  323. .detail-label { color: #666; }
  324. .detail-value { color: #333; }
  325. &.product-item {
  326. .detail-label { color: #333; }
  327. .detail-value { color: #999; }
  328. }
  329. }
  330. .card-footer {
  331. display: flex;
  332. justify-content: flex-end;
  333. margin-top: 20rpx;
  334. }
  335. .verify-btn {
  336. background-color: #3c82f8;
  337. color: #fff;
  338. font-size: 26rpx;
  339. padding: 0 30rpx;
  340. height: 60rpx;
  341. line-height: 60rpx;
  342. border-radius: 30rpx;
  343. margin: 0;
  344. &::after { border: none; }
  345. }
  346. .query-btn {
  347. background-color: #409eff;
  348. color: #fff;
  349. padding: 20rpx;
  350. border-radius: 10rpx;
  351. height: 34rpx;
  352. display: flex;
  353. justify-content: center;
  354. align-items: center;
  355. }
  356. .query-btn-icon {
  357. height: 32rpx;
  358. width: 32rpx;
  359. background-image:
  360. url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/queryIoc.png");
  361. background-size: cover;
  362. background-position: center;
  363. background-repeat: no-repeat;
  364. }
  365. .query-btn-text {
  366. font-weight: 400;
  367. font-size: 30rpx;
  368. color: #F5F5F5;
  369. }
  370. </style>