index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  1. <template>
  2. <view class="content-box">
  3. <uni-nav-bar
  4. fixed="true"
  5. statusBar="true"
  6. left-icon="back"
  7. title="受托列表"
  8. background-color="#157A2C"
  9. color="#fff"
  10. @clickLeft="back"
  11. ></uni-nav-bar>
  12. <view class="top-wrapper">
  13. <uni-section>
  14. <uni-easyinput
  15. prefixIcon="search"
  16. v-model="searchForm.name"
  17. placeholder="请输入名称"
  18. ></uni-easyinput>
  19. </uni-section>
  20. <image
  21. class="menu_icon"
  22. src="~@/static/pda/menu.svg"
  23. @click="showFilter = true"
  24. ></image>
  25. <button class="search_btn" @click="handleSearch">搜索</button>
  26. </view>
  27. <view class="tab-bar">
  28. <view
  29. class="tab-item"
  30. :class="{ active: tabValue === '1' }"
  31. @click="handleTabClick('1')"
  32. >
  33. 受托任务
  34. </view>
  35. <view
  36. class="tab-item"
  37. :class="{ active: tabValue === '2' }"
  38. @click="handleTabClick('2')"
  39. >
  40. 预处理任务
  41. </view>
  42. </view>
  43. <view class="list_box">
  44. <u-list @scrolltolower="loadMore">
  45. <u-list-item v-for="item in list" :key="item.id">
  46. <view class="list-item" @click="goDetail(item)">
  47. <view class="item-header">
  48. <view class="item-code">{{ item.code }}</view>
  49. <view class="item-status">
  50. <text class="status-tag" :class="getStatusClass(item.status)">{{
  51. getStatusText(item.status)
  52. }}</text>
  53. </view>
  54. </view>
  55. <view class="item-row">
  56. <text class="label">类型:</text>
  57. <text class="value">{{ getTypeText(item.type) }}</text>
  58. </view>
  59. <view class="item-row">
  60. <text class="label">名称:</text>
  61. <text class="value">{{ item.name }}</text>
  62. </view>
  63. <view class="item-row">
  64. <text class="label">紧急程度:</text>
  65. <text class="value">{{
  66. item.priority == 1 ? "一般" : "紧急"
  67. }}</text>
  68. </view>
  69. <view class="item-row">
  70. <text class="label">请托数量:</text>
  71. <text class="value"
  72. >{{ item.totalCount }}{{ item.measuringUnit }}</text
  73. >
  74. </view>
  75. <view class="item-row">
  76. <text class="label">接收数量:</text>
  77. <text class="value"
  78. >{{ item.receiveQuantity || 0 }}{{ item.measuringUnit }}</text
  79. >
  80. </view>
  81. <view class="item-row">
  82. <text class="label">请托工厂:</text>
  83. <text class="value">{{ item.applyFactoriesName }}</text>
  84. </view>
  85. <view class="item-row">
  86. <text class="label">收货状态:</text>
  87. <text class="value">
  88. <text
  89. class="status-tag"
  90. :class="getSendStatusClass(item.sendStatus)"
  91. >{{ getSendStatusText(item.sendStatus) }}</text
  92. >
  93. </text>
  94. </view>
  95. <view class="item-row">
  96. <text class="label">审批状态:</text>
  97. <text class="value">
  98. <text
  99. class="status-tag"
  100. :class="getApprovalStatusClass(item.approvalStatus)"
  101. >{{ getApprovalStatusText(item.approvalStatus) }}</text
  102. >
  103. </text>
  104. </view>
  105. <view class="item-row">
  106. <text class="label">转换状态:</text>
  107. <text class="value">
  108. <text
  109. class="status-tag"
  110. :class="getChangeTypeClass(item.changeType)"
  111. >{{ getChangeTypeText(item.changeType) }}</text
  112. >
  113. </text>
  114. </view>
  115. <view class="item-footer">
  116. <text class="time">{{ item.createTime }}</text>
  117. </view>
  118. <view
  119. class="item-actions"
  120. v-if="
  121. canReceive(item) ||
  122. canViewReceiveDetail(item) ||
  123. canViewSendDetail(item) ||
  124. canViewReceiveOrder(item)
  125. "
  126. >
  127. <button
  128. v-if="canReceive(item)"
  129. class="action-btn btn-success"
  130. @click.stop="handleReceive(item)"
  131. >
  132. 收货
  133. </button>
  134. <button
  135. v-if="canViewSendDetail(item)"
  136. class="action-btn btn-order"
  137. @click.stop="handleSendDetail(item)"
  138. >
  139. 发货详情
  140. </button>
  141. <button
  142. v-if="canViewReceiveDetail(item)"
  143. class="action-btn btn-info"
  144. @click.stop="handleReceiveDetail(item)"
  145. >
  146. 收货详情
  147. </button>
  148. <button
  149. v-if="canViewReceiveOrder(item)"
  150. class="action-btn btn-primary"
  151. @click.stop="handleConvertOrder(item)"
  152. >
  153. 转生产订单
  154. </button>
  155. </view>
  156. </view>
  157. </u-list-item>
  158. <u-list-item v-if="list.length === 0">
  159. <view class="empty-wrapper">
  160. <u-empty iconSize="150" textSize="32" text="暂无数据"></u-empty>
  161. </view>
  162. </u-list-item>
  163. </u-list>
  164. </view>
  165. <SearchPopup mode="top" v-if="showFilter">
  166. <template v-slot:list>
  167. <view class="search_list">
  168. <u-form
  169. labelPosition="left"
  170. :model="searchForm"
  171. labelWidth="180"
  172. labelAlign="left"
  173. >
  174. <u-form-item label="类型:" borderBottom>
  175. <picker
  176. mode="selector"
  177. :range="typeList"
  178. range-key="label"
  179. @change="typeChange"
  180. >
  181. <view class="picker-value">{{ currentType || "全部" }}</view>
  182. </picker>
  183. </u-form-item>
  184. </u-form>
  185. </view>
  186. </template>
  187. <template v-slot:operate>
  188. <view class="operate_box">
  189. <u-button
  190. size="small"
  191. class="u-reset-button reset-btn"
  192. @click="filterCancel"
  193. >重置</u-button
  194. >
  195. <u-button
  196. type="success"
  197. size="small"
  198. class="u-reset-button confirm-btn"
  199. @click="filterConfirm"
  200. >确定</u-button
  201. >
  202. </view>
  203. </template>
  204. </SearchPopup>
  205. </view>
  206. </template>
  207. <script>
  208. import { getList } from "@/api/beEntrust/index.js";
  209. import SearchPopup from "../../components/searchPopup.vue";
  210. let isEnd = false;
  211. export default {
  212. components: {
  213. SearchPopup,
  214. },
  215. data() {
  216. return {
  217. searchForm: {
  218. type: "",
  219. name: "",
  220. applyFactoriesId: "",
  221. },
  222. currentType: "",
  223. typeList: [],
  224. list: [],
  225. pageNum: 1,
  226. pageSize: 20,
  227. total: 0,
  228. loading: false,
  229. hasMore: true,
  230. showFilter: false,
  231. tabValue: "1",
  232. };
  233. },
  234. onLoad() {
  235. this.getTypeList();
  236. },
  237. onShow() {
  238. this.loadData(true);
  239. },
  240. methods: {
  241. back() {
  242. uni.navigateBack();
  243. },
  244. async getTypeList() {
  245. this.typeList = [
  246. { label: "全部", value: "" },
  247. { label: "加工", value: "1" },
  248. { label: "装配", value: "2" },
  249. ];
  250. },
  251. typeChange(e) {
  252. const index = e.detail.value;
  253. this.searchForm.type = this.typeList[index].value;
  254. this.currentType = this.typeList[index].label;
  255. },
  256. async loadData(isRefresh = false) {
  257. if (this.loading) return;
  258. if (isRefresh) {
  259. this.pageNum = 1;
  260. this.list = [];
  261. this.hasMore = true;
  262. }
  263. if (!this.hasMore) return;
  264. this.loading = true;
  265. isEnd = false;
  266. try {
  267. const params = {
  268. pageNum: this.pageNum,
  269. size: this.pageSize,
  270. ...this.searchForm,
  271. };
  272. if (this.tabValue === "2") {
  273. params.preStatus = 1;
  274. }
  275. const res = await getList(params);
  276. if (this.pageNum === 1) {
  277. this.list = [];
  278. }
  279. if (res.list && res.list.length > 0) {
  280. this.list.push(...res.list);
  281. this.total = res.total;
  282. isEnd = this.list.length >= this.total;
  283. this.hasMore = !isEnd;
  284. } else {
  285. isEnd = true;
  286. this.hasMore = false;
  287. }
  288. } catch (error) {
  289. uni.showToast({
  290. title: "加载失败",
  291. icon: "none",
  292. });
  293. } finally {
  294. this.loading = false;
  295. }
  296. },
  297. handleTabClick(tab) {
  298. this.tabValue = tab;
  299. this.loadData(true);
  300. },
  301. handleConvertOrder(item) {
  302. if (item.sendStatus != 2) {
  303. uni.showToast({
  304. title: "请先收货再转生产订单",
  305. icon: "none",
  306. });
  307. return;
  308. }
  309. if (item.changeType == 1 || item.changeType == 2) {
  310. uni.showToast({
  311. title: "该工单已转换,不能重复转换",
  312. icon: "none",
  313. });
  314. return;
  315. }
  316. uni.navigateTo({
  317. url: `/pages/pda/beEntrust/createOrder/createOrder?id=${item.id}`,
  318. });
  319. },
  320. loadMore() {
  321. if (isEnd) return;
  322. this.pageNum++;
  323. this.loadData();
  324. },
  325. handleSearch() {
  326. this.loadData(true);
  327. },
  328. filterConfirm() {
  329. this.showFilter = false;
  330. this.loadData(true);
  331. },
  332. filterCancel() {
  333. this.searchForm.type = "";
  334. this.currentType = "";
  335. this.showFilter = false;
  336. this.loadData(true);
  337. },
  338. goDetail(item) {
  339. uni.navigateTo({
  340. url: `/pages/pda/beEntrust/detail/detail?id=${item.id}`,
  341. });
  342. },
  343. handleReceive(item) {
  344. uni.navigateTo({
  345. url: `/pages/pda/beEntrust/goods/goods?id=${item.id}&type=add`,
  346. });
  347. },
  348. handleReceiveDetail(item) {
  349. uni.navigateTo({
  350. url: `/pages/pda/beEntrust/goods/goods?id=${item.id}&type=detail`,
  351. });
  352. },
  353. handleSendDetail(item) {
  354. uni.navigateTo({
  355. url: `/pages/pda/beEntrust/goods/goods?id=${item.id}&type=send`,
  356. });
  357. },
  358. canReceive(item) {
  359. return item.approvalStatus == 2 && item.sendStatus == 1;
  360. },
  361. canViewReceiveDetail(item) {
  362. return (
  363. item.approvalStatus == 2 && item.sendStatus != 1 && item.sendStatus != 5
  364. );
  365. },
  366. canViewReceiveOrder(item) {
  367. console.log("canViewReceiveOrder", item.changeType);
  368. return (
  369. item.approvalStatus == 2 &&
  370. item.sendStatus == 2 &&
  371. item.sendStatus != 5 &&
  372. item.changeType != 1 &&
  373. item.changeType != 2
  374. );
  375. },
  376. canViewSendDetail(item) {
  377. return (
  378. item.approvalStatus == 2 &&
  379. (item.sendStatus == 3 || item.sendStatus == 4)
  380. );
  381. },
  382. getTypeText(type) {
  383. const typeMap = {
  384. 1: "加工",
  385. 2: "装配",
  386. };
  387. return typeMap[type] || "";
  388. },
  389. getStatusText(status) {
  390. const statusMap = {
  391. 0: "未提交",
  392. 1: "已提交",
  393. 2: "已发布",
  394. 4: "待生产",
  395. 5: "生产中",
  396. 6: "已完成",
  397. 7: "已延期",
  398. 8: "待下达",
  399. };
  400. return statusMap[status] || "";
  401. },
  402. getStatusClass(status) {
  403. if (!status || status == 0) return "status-default";
  404. return "status-success";
  405. },
  406. getSendStatusText(sendStatus) {
  407. const statusMap = {
  408. 0: "未收货",
  409. 1: "已发货",
  410. 2: "已收货",
  411. 3: "受托已发",
  412. 4: "请托已收",
  413. 5: "受托拒收",
  414. 6: "请托拒收",
  415. };
  416. return statusMap[sendStatus] || "未收货";
  417. },
  418. getSendStatusClass(sendStatus) {
  419. if (!sendStatus || sendStatus == 0) return "status-default";
  420. if (sendStatus == 5 || sendStatus == 6) return "status-danger";
  421. return "status-success";
  422. },
  423. getApprovalStatusText(approvalStatus) {
  424. const statusMap = {
  425. 0: "未提交",
  426. 1: "审核中",
  427. 2: "审核通过",
  428. 3: "审核不通过",
  429. };
  430. return statusMap[approvalStatus] || "未提交";
  431. },
  432. getApprovalStatusClass(approvalStatus) {
  433. const classMap = {
  434. 0: "status-default",
  435. 1: "status-warning",
  436. 2: "status-success",
  437. 3: "status-danger",
  438. };
  439. return classMap[approvalStatus] || "status-default";
  440. },
  441. getChangeTypeText(changeType) {
  442. const typeMap = {
  443. 0: "未转换",
  444. 1: "已转生产订单",
  445. 2: "已转生产订单",
  446. };
  447. return typeMap[changeType] || "未转换";
  448. },
  449. getChangeTypeClass(changeType) {
  450. if (changeType == 1 || changeType == 2) return "status-success";
  451. return "status-default";
  452. },
  453. },
  454. };
  455. </script>
  456. <style lang="scss">
  457. page {
  458. height: 100vh;
  459. overflow: hidden;
  460. }
  461. </style>
  462. <style lang="scss" scoped>
  463. .content-box {
  464. height: 100vh;
  465. overflow: hidden;
  466. display: flex;
  467. flex-direction: column;
  468. background-color: $page-bg;
  469. }
  470. .top-wrapper {
  471. background-color: #fff;
  472. display: flex;
  473. width: 750rpx;
  474. padding: 16rpx 32rpx;
  475. align-items: center;
  476. gap: 16rpx;
  477. flex-shrink: 0;
  478. position: sticky;
  479. top: 88rpx;
  480. z-index: 99;
  481. /deep/.uni-section {
  482. margin-top: 0px;
  483. flex: 1;
  484. }
  485. /deep/.uni-section-header {
  486. padding: 0px;
  487. }
  488. .search_btn {
  489. width: 120rpx;
  490. height: 70rpx;
  491. line-height: 70rpx;
  492. padding: 0 24rpx;
  493. background: $theme-color;
  494. font-size: 32rpx;
  495. color: #fff;
  496. margin: 0;
  497. }
  498. .menu_icon {
  499. width: 44rpx;
  500. height: 44rpx;
  501. }
  502. }
  503. .action-bar {
  504. background-color: #fff;
  505. padding: 16rpx 32rpx;
  506. border-bottom: 1rpx solid #f0f0f0;
  507. .action-btn {
  508. width: 200rpx;
  509. height: 64rpx;
  510. line-height: 64rpx;
  511. padding: 0;
  512. background: $theme-color;
  513. font-size: 28rpx;
  514. color: #fff;
  515. border-radius: 8rpx;
  516. margin: 0;
  517. }
  518. }
  519. .tab-bar {
  520. display: flex;
  521. background-color: #fff;
  522. border-bottom: 1rpx solid #f0f0f0;
  523. .tab-item {
  524. flex: 1;
  525. text-align: center;
  526. padding: 24rpx 0;
  527. font-size: 28rpx;
  528. color: #666;
  529. position: relative;
  530. &.active {
  531. color: $theme-color;
  532. font-weight: bold;
  533. &::after {
  534. content: "";
  535. position: absolute;
  536. bottom: 0;
  537. left: 50%;
  538. transform: translateX(-50%);
  539. width: 60rpx;
  540. height: 4rpx;
  541. background-color: $theme-color;
  542. border-radius: 2rpx;
  543. }
  544. }
  545. }
  546. }
  547. .list_box {
  548. flex: 1;
  549. overflow: hidden;
  550. padding: 16rpx 0;
  551. .u-list {
  552. height: 100% !important;
  553. }
  554. }
  555. .list-item {
  556. background-color: #fff;
  557. border-radius: 12rpx;
  558. padding: 24rpx;
  559. margin: 0 24rpx 20rpx;
  560. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
  561. .item-header {
  562. display: flex;
  563. justify-content: space-between;
  564. align-items: center;
  565. margin-bottom: 20rpx;
  566. padding-bottom: 20rpx;
  567. border-bottom: 1rpx solid #f0f0f0;
  568. gap: 16rpx;
  569. .item-code {
  570. flex: 1;
  571. font-size: 32rpx;
  572. font-weight: bold;
  573. color: $theme-color;
  574. }
  575. }
  576. .item-row {
  577. display: flex;
  578. margin-bottom: 16rpx;
  579. font-size: 28rpx;
  580. .label {
  581. color: #999;
  582. min-width: 160rpx;
  583. }
  584. .value {
  585. flex: 1;
  586. color: #333;
  587. word-break: break-all;
  588. }
  589. }
  590. .item-footer {
  591. margin-top: 20rpx;
  592. padding-top: 20rpx;
  593. border-top: 1rpx solid #f0f0f0;
  594. .time {
  595. font-size: 24rpx;
  596. color: #999;
  597. }
  598. }
  599. .item-actions {
  600. display: flex !important;
  601. justify-content: flex-end !important;
  602. gap: 12rpx;
  603. margin-top: 20rpx;
  604. overflow-x: auto;
  605. .action-btn {
  606. flex: 0 0 auto !important;
  607. width: auto !important;
  608. border-radius: 32rpx !important;
  609. height: 56rpx !important;
  610. line-height: 56rpx !important;
  611. font-size: 26rpx !important;
  612. padding: 0 24rpx !important;
  613. margin: 0 !important;
  614. border: none !important;
  615. color: #fff !important;
  616. &.btn-success {
  617. background-color: $theme-color !important;
  618. }
  619. &.btn-info {
  620. background-color: #ff8c00 !important;
  621. }
  622. &.btn-order {
  623. background-color: #b23aee !important;
  624. }
  625. &.btn-primary {
  626. background-color: #1a52c3 !important;
  627. }
  628. }
  629. }
  630. }
  631. .status-tag {
  632. display: inline-block;
  633. padding: 4rpx 16rpx;
  634. border-radius: 4rpx;
  635. font-size: 24rpx;
  636. &.status-default {
  637. background-color: #f0f0f0;
  638. color: #666;
  639. }
  640. &.status-warning {
  641. background-color: #fff7e6;
  642. color: #faad14;
  643. }
  644. &.status-success {
  645. background-color: rgba(21, 122, 44, 0.1);
  646. color: $theme-color;
  647. }
  648. &.status-danger {
  649. background-color: #fff1f0;
  650. color: #ff4d4f;
  651. }
  652. }
  653. .empty-wrapper {
  654. display: flex;
  655. align-items: center;
  656. justify-content: center;
  657. padding-top: 25vh;
  658. }
  659. .search_list {
  660. min-height: 100rpx;
  661. padding: 24rpx 32rpx;
  662. .picker-value {
  663. padding: 12rpx 16rpx;
  664. border: 1rpx solid #e0e0e0;
  665. border-radius: 6rpx;
  666. font-size: 28rpx;
  667. }
  668. }
  669. .operate_box {
  670. display: flex;
  671. flex-direction: row;
  672. align-items: center;
  673. justify-content: space-between;
  674. padding: 24rpx 32rpx 32rpx;
  675. gap: 24rpx;
  676. .reset-btn {
  677. flex: 1;
  678. height: 72rpx;
  679. border-radius: 36rpx;
  680. font-size: $uni-font-size-sm;
  681. }
  682. .confirm-btn {
  683. flex: 1;
  684. height: 72rpx;
  685. border-radius: 36rpx;
  686. font-size: $uni-font-size-sm;
  687. }
  688. }
  689. </style>