order.vue 11 KB

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