OrderListDialog.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <!-- OrderListDialog.vue - 订单选择弹窗(UniApp版本) -->
  2. <template>
  3. <u-popup :show="visible" :round="0" :closeOnClickOverlay="false" :zIndex="99999" @close="handleClose"
  4. class="order-popup">
  5. <view class="popup-content">
  6. <view class="popup-header">
  7. <text class="popup-title">选择订单</text>
  8. <view class="close-btn" @click="handleClose">×</view>
  9. </view>
  10. <!-- 搜索区域 -->
  11. <view class="search-wrapper">
  12. <uni-easyinput prefixIcon="search" style="flex: 1" v-model="keyword" placeholder="订单编码/名称/合同名称">
  13. </uni-easyinput>
  14. <button class="search_btn" @click="handleSearch">搜索</button>
  15. </view>
  16. <!-- 订单列表 -->
  17. <scroll-view class="popup-body" scroll-y @scrolltolower="loadMore">
  18. <view v-for="(item, index) in orderList" :key="item.id" style="position: relative">
  19. <myCard :item="item" :index="index + 1" :columns="cardColumns" :title="item.orderNo"
  20. :showRadio="true" :radioValue="selectedId" @radioChange="onRadioChange">
  21. </myCard>
  22. </view>
  23. <view style="width: 100%; height: 40rpx"></view>
  24. <view style="margin-top: 60rpx" v-if="loading && orderList.length === 0">
  25. <u-empty iconSize="150" textSize="32" text="加载中..."></u-empty>
  26. </view>
  27. <view style="margin-top: 60rpx" v-if="!loading && orderList.length === 0">
  28. <u-empty iconSize="150" textSize="32" text="暂无订单数据"></u-empty>
  29. </view>
  30. <view class="loadmore-text" v-if="!isEnd && orderList.length > 0">加载更多...</view>
  31. <view class="loadmore-text" v-if="isEnd && orderList.length > 0">没有更多了</view>
  32. </scroll-view>
  33. <view class="popup-footer">
  34. <u-button type="default" @click="handleClose">关闭</u-button>
  35. <u-button type="primary" @click="confirmSelect">选择</u-button>
  36. </view>
  37. </view>
  38. <u-toast ref="uToast"></u-toast>
  39. </u-popup>
  40. </template>
  41. <script>
  42. import myCard from './myCard.vue';
  43. import {
  44. getPurchaseOrderList
  45. } from '@/api/purchasingManage/index.js'
  46. export default {
  47. components: {
  48. myCard
  49. },
  50. props: {
  51. searchParams: {
  52. type: Object,
  53. default: () => ({})
  54. },
  55. isOutsourcing: {
  56. type: String,
  57. default: ''
  58. }
  59. },
  60. data() {
  61. return {
  62. visible: false,
  63. keyword: '',
  64. orderList: [],
  65. selectedId: null,
  66. selectedOrder: null,
  67. page: 1,
  68. size: 10,
  69. isEnd: false,
  70. loading: false,
  71. partbId: '',
  72. sourceType: '',
  73. // 卡片展示列配置
  74. cardColumns: [
  75. [{
  76. label: "订单编码",
  77. prop: "orderNo",
  78. className: "perce100"
  79. }],
  80. [{
  81. label: "订单类型",
  82. prop: "sourceTypeName",
  83. className: "perce50"
  84. }, {
  85. label: "金额(元)",
  86. prop: "payAmount",
  87. className: "perce50"
  88. }],
  89. [{
  90. label: "名称",
  91. prop: "productNames",
  92. className: "perce100"
  93. }],
  94. [{
  95. label: "编码",
  96. prop: "productCodes",
  97. className: "perce100"
  98. }],
  99. [{
  100. label: "合同名称",
  101. prop: "contractName",
  102. className: "perce100"
  103. }],
  104. [{
  105. label: "供应商",
  106. prop: "partbName",
  107. className: "perce50"
  108. }, {
  109. label: "采购方",
  110. prop: "partaName",
  111. className: "perce50"
  112. }],
  113. [{
  114. label: "创建时间",
  115. prop: "createTime",
  116. className: "perce100"
  117. }]
  118. ]
  119. };
  120. },
  121. methods: {
  122. // 打开弹窗
  123. open(partbId, sourceType) {
  124. this.partbId = partbId;
  125. this.sourceType = sourceType || '';
  126. this.selectedId = null;
  127. this.selectedOrder = null;
  128. this.orderList = [];
  129. this.page = 1;
  130. this.isEnd = false;
  131. this.keyword = '';
  132. this.visible = true;
  133. this.loadOrders();
  134. },
  135. // 搜索
  136. handleSearch() {
  137. this.page = 1;
  138. this.orderList = [];
  139. this.isEnd = false;
  140. this.loadOrders();
  141. },
  142. // 加载订单列表
  143. async loadOrders() {
  144. if (this.loading || this.isEnd) return;
  145. this.loading = true;
  146. try {
  147. const where = {};
  148. if (this.keyword) {
  149. // 支持订单编码、名称模糊查询
  150. where.orderNo = this.keyword;
  151. where.productNames = this.keyword;
  152. where.contractName = this.keyword;
  153. }
  154. if (this.sourceType) {
  155. where.sourceType = this.sourceType;
  156. }
  157. const res = await getPurchaseOrderList({
  158. pageNum: this.page,
  159. size: this.size,
  160. ...where,
  161. orderStatus: 2,
  162. partbId: this.partbId,
  163. ...this.searchParams
  164. });
  165. const list = res.list || [];
  166. if (this.page === 1) {
  167. this.orderList = list;
  168. } else {
  169. this.orderList.push(...list);
  170. }
  171. this.isEnd = list.length < this.size || (this.orderList.length >= res.count);
  172. this.page += 1;
  173. } catch (error) {
  174. console.error('获取订单列表失败', error);
  175. this.$refs.uToast.show({
  176. type: 'error',
  177. message: '加载订单失败'
  178. });
  179. } finally {
  180. this.loading = false;
  181. }
  182. },
  183. // 滚动加载更多
  184. loadMore() {
  185. if (!this.isEnd && !this.loading) {
  186. this.loadOrders();
  187. }
  188. },
  189. // 单选变化
  190. onRadioChange(item) {
  191. this.selectedId = item.id;
  192. this.selectedOrder = item;
  193. },
  194. // 确认选择
  195. confirmSelect() {
  196. if (!this.selectedOrder) {
  197. this.$refs.uToast.show({
  198. type: 'warning',
  199. message: '请至少选择一条数据'
  200. });
  201. return;
  202. }
  203. this.$emit('changeParent', this.selectedOrder);
  204. this.handleClose();
  205. },
  206. // 关闭弹窗
  207. handleClose() {
  208. this.visible = false;
  209. this.selectedId = null;
  210. this.selectedOrder = null;
  211. }
  212. }
  213. };
  214. </script>
  215. <style lang="scss" scoped>
  216. .order-popup {
  217. .popup-content {
  218. width: 100vw;
  219. height: 85vh;
  220. background: #fff;
  221. border-radius: 32rpx 32rpx 0 0;
  222. display: flex;
  223. flex-direction: column;
  224. background-color: #f5f7fb;
  225. }
  226. .popup-header {
  227. display: flex;
  228. justify-content: space-between;
  229. align-items: center;
  230. padding: 30rpx;
  231. border-bottom: 2rpx solid #eef2f6;
  232. background: #fff;
  233. .popup-title {
  234. font-size: 36rpx;
  235. font-weight: bold;
  236. color: #1f2b3c;
  237. }
  238. .close-btn {
  239. width: 60rpx;
  240. height: 60rpx;
  241. display: flex;
  242. align-items: center;
  243. justify-content: center;
  244. font-size: 60rpx;
  245. color: #8e9aae;
  246. line-height: 1;
  247. }
  248. }
  249. .search-wrapper {
  250. display: flex;
  251. align-items: center;
  252. padding: 20rpx 30rpx;
  253. background: #fff;
  254. border-bottom: 2rpx solid #eef2f6;
  255. gap: 20rpx;
  256. .search_btn {
  257. width: 140rpx;
  258. height: 70rpx;
  259. line-height: 70rpx;
  260. padding: 0;
  261. background: $theme-color;
  262. font-size: 28rpx;
  263. color: #fff;
  264. margin: 0;
  265. border-radius: 48rpx;
  266. }
  267. }
  268. .popup-body {
  269. flex: 1;
  270. overflow-y: auto;
  271. padding: 20rpx 24rpx;
  272. box-sizing: border-box;
  273. }
  274. .loadmore-text {
  275. text-align: center;
  276. font-size: 26rpx;
  277. color: #aaa;
  278. padding: 24rpx 0 40rpx;
  279. }
  280. .popup-footer {
  281. display: flex;
  282. padding: 20rpx 30rpx 30rpx;
  283. border-top: 2rpx solid #eef2f6;
  284. gap: 20rpx;
  285. background: #fff;
  286. .u-button {
  287. flex: 1;
  288. border-radius: 48rpx;
  289. }
  290. }
  291. }
  292. </style>