hexiao_record.vue 9.9 KB

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