index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786
  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" scoped>
  457. page {
  458. height: 100vh;
  459. overflow: hidden;
  460. }
  461. .content-box {
  462. height: 100vh;
  463. overflow: hidden;
  464. display: flex;
  465. flex-direction: column;
  466. background-color: $page-bg;
  467. }
  468. .top-wrapper {
  469. background-color: #fff;
  470. display: flex;
  471. width: 750rpx;
  472. padding: 16rpx 32rpx;
  473. align-items: center;
  474. gap: 16rpx;
  475. flex-shrink: 0;
  476. position: sticky;
  477. top: 88rpx;
  478. z-index: 99;
  479. /deep/.uni-section {
  480. margin-top: 0px;
  481. flex: 1;
  482. }
  483. /deep/.uni-section-header {
  484. padding: 0px;
  485. }
  486. .search_btn {
  487. width: 120rpx;
  488. height: 70rpx;
  489. line-height: 70rpx;
  490. padding: 0 24rpx;
  491. background: $theme-color;
  492. font-size: 32rpx;
  493. color: #fff;
  494. margin: 0;
  495. }
  496. .menu_icon {
  497. width: 44rpx;
  498. height: 44rpx;
  499. }
  500. }
  501. .action-bar {
  502. background-color: #fff;
  503. padding: 16rpx 32rpx;
  504. border-bottom: 1rpx solid #f0f0f0;
  505. .action-btn {
  506. width: 200rpx;
  507. height: 64rpx;
  508. line-height: 64rpx;
  509. padding: 0;
  510. background: $theme-color;
  511. font-size: 28rpx;
  512. color: #fff;
  513. border-radius: 8rpx;
  514. margin: 0;
  515. }
  516. }
  517. .tab-bar {
  518. display: flex;
  519. background-color: #fff;
  520. border-bottom: 1rpx solid #f0f0f0;
  521. .tab-item {
  522. flex: 1;
  523. text-align: center;
  524. padding: 24rpx 0;
  525. font-size: 28rpx;
  526. color: #666;
  527. position: relative;
  528. &.active {
  529. color: $theme-color;
  530. font-weight: bold;
  531. &::after {
  532. content: "";
  533. position: absolute;
  534. bottom: 0;
  535. left: 50%;
  536. transform: translateX(-50%);
  537. width: 60rpx;
  538. height: 4rpx;
  539. background-color: $theme-color;
  540. border-radius: 2rpx;
  541. }
  542. }
  543. }
  544. }
  545. .list_box {
  546. flex: 1;
  547. overflow: hidden;
  548. padding: 16rpx 0;
  549. .u-list {
  550. height: 100% !important;
  551. }
  552. }
  553. .list-item {
  554. background-color: #fff;
  555. border-radius: 12rpx;
  556. padding: 24rpx;
  557. margin: 0 24rpx 20rpx;
  558. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
  559. .item-header {
  560. display: flex;
  561. justify-content: space-between;
  562. align-items: center;
  563. margin-bottom: 20rpx;
  564. padding-bottom: 20rpx;
  565. border-bottom: 1rpx solid #f0f0f0;
  566. gap: 16rpx;
  567. .item-code {
  568. flex: 1;
  569. font-size: 32rpx;
  570. font-weight: bold;
  571. color: $theme-color;
  572. }
  573. }
  574. .item-row {
  575. display: flex;
  576. margin-bottom: 16rpx;
  577. font-size: 28rpx;
  578. .label {
  579. color: #999;
  580. min-width: 160rpx;
  581. }
  582. .value {
  583. flex: 1;
  584. color: #333;
  585. word-break: break-all;
  586. }
  587. }
  588. .item-footer {
  589. margin-top: 20rpx;
  590. padding-top: 20rpx;
  591. border-top: 1rpx solid #f0f0f0;
  592. .time {
  593. font-size: 24rpx;
  594. color: #999;
  595. }
  596. }
  597. .item-actions {
  598. display: flex !important;
  599. justify-content: flex-end !important;
  600. gap: 12rpx;
  601. margin-top: 20rpx;
  602. overflow-x: auto;
  603. .action-btn {
  604. flex: 0 0 auto !important;
  605. width: auto !important;
  606. border-radius: 32rpx !important;
  607. height: 56rpx !important;
  608. line-height: 56rpx !important;
  609. font-size: 26rpx !important;
  610. padding: 0 24rpx !important;
  611. margin: 0 !important;
  612. border: none !important;
  613. color: #fff !important;
  614. &.btn-success {
  615. background-color: $theme-color !important;
  616. }
  617. &.btn-info {
  618. background-color: #ff8c00 !important;
  619. }
  620. &.btn-order {
  621. background-color: #b23aee !important;
  622. }
  623. &.btn-primary {
  624. background-color: #1a52c3 !important;
  625. }
  626. }
  627. }
  628. }
  629. .status-tag {
  630. display: inline-block;
  631. padding: 4rpx 16rpx;
  632. border-radius: 4rpx;
  633. font-size: 24rpx;
  634. &.status-default {
  635. background-color: #f0f0f0;
  636. color: #666;
  637. }
  638. &.status-warning {
  639. background-color: #fff7e6;
  640. color: #faad14;
  641. }
  642. &.status-success {
  643. background-color: rgba(21, 122, 44, 0.1);
  644. color: $theme-color;
  645. }
  646. &.status-danger {
  647. background-color: #fff1f0;
  648. color: #ff4d4f;
  649. }
  650. }
  651. .empty-wrapper {
  652. display: flex;
  653. align-items: center;
  654. justify-content: center;
  655. padding-top: 25vh;
  656. }
  657. .search_list {
  658. min-height: 100rpx;
  659. padding: 24rpx 32rpx;
  660. .picker-value {
  661. padding: 12rpx 16rpx;
  662. border: 1rpx solid #e0e0e0;
  663. border-radius: 6rpx;
  664. font-size: 28rpx;
  665. }
  666. }
  667. .operate_box {
  668. display: flex;
  669. flex-direction: row;
  670. align-items: center;
  671. justify-content: space-between;
  672. padding: 24rpx 32rpx 32rpx;
  673. gap: 24rpx;
  674. .reset-btn {
  675. flex: 1;
  676. height: 72rpx;
  677. border-radius: 36rpx;
  678. font-size: $uni-font-size-sm;
  679. }
  680. .confirm-btn {
  681. flex: 1;
  682. height: 72rpx;
  683. border-radius: 36rpx;
  684. font-size: $uni-font-size-sm;
  685. }
  686. }
  687. </style>