index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  1. <template>
  2. <view class="page-container">
  3. <uni-nav-bar
  4. statusBar="true"
  5. left-icon="back"
  6. title="工单交接"
  7. background-color="#157A2C"
  8. color="#fff"
  9. @clickLeft="back"
  10. ></uni-nav-bar>
  11. <!-- 搜索栏 -->
  12. <view class="search-wrapper">
  13. <view class="search-bar">
  14. <view class="search-input-box">
  15. <uni-icons type="search" size="18" color="#999"></uni-icons>
  16. <input
  17. v-model="searchForm.code"
  18. placeholder="请输入生产工单号搜索"
  19. placeholder-class="search-placeholder"
  20. class="search-input"
  21. confirm-type="search"
  22. @confirm="doSearch"
  23. />
  24. </view>
  25. <view class="search-actions">
  26. <view class="filter-btn" @click="showFilter = true">
  27. <uni-icons type="settings" size="20" color="#666"></uni-icons>
  28. </view>
  29. <view class="search-btn" @click="doSearch">
  30. <text class="search-btn-text">搜索</text>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <!-- Tab状态筛选 -->
  36. <view class="tab-bar">
  37. <view
  38. v-for="tab in tabList"
  39. :key="tab.value"
  40. class="tab-item"
  41. :class="{ 'tab-item--active': activeTab === tab.value }"
  42. @click="switchTab(tab.value)"
  43. >
  44. <text class="tab-text">{{ tab.label }}</text>
  45. <view v-if="activeTab === tab.value" class="tab-line"></view>
  46. </view>
  47. </view>
  48. <!-- 列表区域 -->
  49. <view class="list-container">
  50. <u-list @scrolltolower="loadMore">
  51. <view v-for="(item, index) in list" :key="item.id" class="order-card">
  52. <!-- 卡片头部 -->
  53. <view class="card-header" @click="handleDetail(item)">
  54. <view class="header-left">
  55. <view class="serial-num">{{ index + 1 }}</view>
  56. <text class="order-code">{{ item.code || "暂无编码" }}</text>
  57. </view>
  58. <view class="status-tag" :class="'status-tag--' + item.status">
  59. <text class="status-text">{{ getStatusText(item.status) }}</text>
  60. </view>
  61. </view>
  62. <!-- 卡片内容 -->
  63. <view class="card-body" @click="handleDetail(item)">
  64. <view class="info-row">
  65. <view class="info-item">
  66. <text class="info-label">交接类型</text>
  67. <text class="info-value">{{ getTypeName(item.type) }}</text>
  68. </view>
  69. <view class="info-item">
  70. <text class="info-label">交接时间</text>
  71. <text class="info-value">{{ item.initiateTime || "-" }}</text>
  72. </view>
  73. </view>
  74. <view class="info-row">
  75. <view class="info-item">
  76. <text class="info-label">生产工单号</text>
  77. <text class="info-value">{{ item.workOrderCode || "-" }}</text>
  78. </view>
  79. <view class="info-item">
  80. <text class="info-label">产品名称</text>
  81. <text class="info-value">{{ item.categoryName || "-" }}</text>
  82. </view>
  83. </view>
  84. <view class="info-row">
  85. <view class="info-item">
  86. <text class="info-label">批次号</text>
  87. <text class="info-value">{{ item.batchNo || "-" }}</text>
  88. </view>
  89. <view class="info-item">
  90. <text class="info-label">工序名称</text>
  91. <text class="info-value">{{
  92. item.initiateTaskName || "-"
  93. }}</text>
  94. </view>
  95. </view>
  96. <view class="info-row">
  97. <view class="info-item">
  98. <text class="info-label">交接数量</text>
  99. <text class="info-value highlight">{{
  100. item.handoverNuM || 0
  101. }}</text>
  102. </view>
  103. <view class="info-item">
  104. <text class="info-label">交接重量</text>
  105. <text class="info-value highlight">{{
  106. item.handoverWeight || 0
  107. }}</text>
  108. </view>
  109. </view>
  110. <view class="info-row">
  111. <view class="info-item">
  112. <text class="info-label">交接班组</text>
  113. <text class="info-value">{{ item.acceptTeamName || "-" }}</text>
  114. </view>
  115. <view class="info-item">
  116. <text class="info-label">交接人</text>
  117. <text class="info-value">{{ item.acceptName || "-" }}</text>
  118. </view>
  119. </view>
  120. </view>
  121. <!-- 卡片底部操作 -->
  122. <view class="card-footer" v-if="showActions(item)" @click.stop>
  123. <view
  124. v-if="item.status == 1"
  125. class="action-btn action-btn--primary"
  126. @click="handleAccept(item)"
  127. >
  128. 接收
  129. </view>
  130. <view
  131. v-if="isEditable(item.status)"
  132. class="action-btn action-btn--primary"
  133. @click="handleEdit(item)"
  134. >
  135. 编辑
  136. </view>
  137. <view
  138. v-if="isEditable(item.status)"
  139. class="action-btn action-btn--danger"
  140. @click="handleDelete(item)"
  141. >
  142. 删除
  143. </view>
  144. </view>
  145. </view>
  146. <!-- 加载状态 -->
  147. <view v-if="loading && list.length > 0" class="loading-more">
  148. <u-loading-icon size="24"></u-loading-icon>
  149. <text class="loading-text">加载中...</text>
  150. </view>
  151. <view v-if="isEnd && list.length > 0" class="loading-more">
  152. <text class="loading-text">没有更多了</text>
  153. </view>
  154. <view v-if="!loading && list.length === 0" class="empty-state">
  155. <u-empty iconSize="150" textSize="32" text="暂无交接单数据"></u-empty>
  156. </view>
  157. <view style="height: 20rpx"></view>
  158. </u-list>
  159. </view>
  160. <!-- 筛选弹窗 -->
  161. <u-popup :show="showFilter" mode="top" @close="showFilter = false">
  162. <view class="filter-popup">
  163. <view class="filter-title">筛选条件</view>
  164. <view class="filter-form">
  165. <view class="filter-item">
  166. <text class="filter-label">交接类型</text>
  167. <view class="filter-select">
  168. <view
  169. v-for="opt in handoverTypeOptions"
  170. :key="opt.value"
  171. class="select-tag"
  172. :class="{ 'select-tag--active': searchForm.type === opt.value }"
  173. @click="
  174. searchForm.type =
  175. searchForm.type === opt.value ? '' : opt.value
  176. "
  177. >
  178. {{ opt.label }}
  179. </view>
  180. </view>
  181. </view>
  182. </view>
  183. <view class="filter-actions">
  184. <view class="filter-btn-reset" @click="resetFilter">重置</view>
  185. <view class="filter-btn-confirm" @click="confirmFilter">确定</view>
  186. </view>
  187. </view>
  188. </u-popup>
  189. </view>
  190. </template>
  191. <script>
  192. import { handoverPage, deleteHandover } from "@/api/pda/workOrderHandover.js";
  193. const STATUS_TEXT = {
  194. 0: "待提交",
  195. 1: "待接收",
  196. 2: "已接收",
  197. 3: "已驳回",
  198. };
  199. const TYPE_MAP = {
  200. 1: "物品移交",
  201. 2: "班次交接",
  202. };
  203. const EDITABLE_STATUS = [0, 3];
  204. export default {
  205. data() {
  206. return {
  207. list: [],
  208. loading: false,
  209. refreshing: false,
  210. isEnd: false,
  211. page: 1,
  212. pageSize: 20,
  213. activeTab: "",
  214. showFilter: false,
  215. searchForm: {
  216. code: "",
  217. type: "",
  218. },
  219. tabList: [
  220. { label: "全部", value: "" },
  221. { label: "待提交", value: 0 },
  222. { label: "待接收", value: 1 },
  223. { label: "已接收", value: 2 },
  224. { label: "已驳回", value: 3 },
  225. ],
  226. handoverTypeOptions: [
  227. { label: "物品移交", value: 1 },
  228. { label: "班次交接", value: 2 },
  229. ],
  230. };
  231. },
  232. onLoad() {
  233. this.loadData();
  234. },
  235. onShow() {
  236. // 从详情页返回时刷新列表
  237. if (this._hasShown) {
  238. this.refreshList();
  239. }
  240. this._hasShown = true;
  241. },
  242. methods: {
  243. back() {
  244. uni.navigateBack();
  245. },
  246. getStatusText(status) {
  247. return STATUS_TEXT[status] || "未知";
  248. },
  249. getTypeName(type) {
  250. return TYPE_MAP[type] || "-";
  251. },
  252. isEditable(status) {
  253. return EDITABLE_STATUS.includes(Number(status));
  254. },
  255. showActions(item) {
  256. return item.status == 1 || this.isEditable(item.status);
  257. },
  258. switchTab(value) {
  259. if (this.activeTab === value) return;
  260. this.activeTab = value;
  261. this.refreshList();
  262. },
  263. doSearch() {
  264. this.refreshList();
  265. },
  266. resetFilter() {
  267. this.searchForm.type = "";
  268. },
  269. confirmFilter() {
  270. this.showFilter = false;
  271. this.refreshList();
  272. },
  273. refreshList() {
  274. this.page = 1;
  275. this.list = [];
  276. this.isEnd = false;
  277. this.loadData();
  278. },
  279. onRefresh() {
  280. this.refreshing = true;
  281. this.page = 1;
  282. this.list = [];
  283. this.isEnd = false;
  284. this.loadData().finally(() => {
  285. this.refreshing = false;
  286. });
  287. },
  288. loadMore() {
  289. if (this.loading || this.isEnd) return;
  290. this.page++;
  291. this.loadData();
  292. },
  293. async loadData() {
  294. if (this.loading) return;
  295. this.loading = true;
  296. try {
  297. const params = {
  298. pageNum: this.page,
  299. size: this.pageSize,
  300. };
  301. if (this.searchForm.code) {
  302. params.code = this.searchForm.code;
  303. }
  304. if (this.searchForm.type !== "" && this.searchForm.type !== null) {
  305. params.type = this.searchForm.type;
  306. }
  307. if (this.activeTab !== "" && this.activeTab !== null) {
  308. params.status = this.activeTab;
  309. }
  310. const res = await handoverPage(params);
  311. const newList = res.list || res.records || [];
  312. if (this.page === 1) {
  313. this.list = newList;
  314. } else {
  315. this.list = [...this.list, ...newList];
  316. }
  317. const total = res.count || res.total || 0;
  318. this.isEnd = this.list.length >= total;
  319. } catch (e) {
  320. console.error("加载交接单列表失败", e);
  321. if (this.page > 1) this.page--;
  322. } finally {
  323. this.loading = false;
  324. }
  325. },
  326. handleDetail(item) {
  327. uni.navigateTo({
  328. url: `/pages/pda/work_order_handover/detail/detail?id=${item.id}&status=${item.status}&mode=detail`,
  329. });
  330. },
  331. handleEdit(item) {
  332. uni.navigateTo({
  333. url: `/pages/pda/work_order_handover/detail/detail?id=${item.id}&status=${item.status}&mode=edit`,
  334. });
  335. },
  336. handleAccept(item) {
  337. uni.navigateTo({
  338. url: `/pages/pda/work_order_handover/detail/detail?id=${item.id}&status=${item.status}&mode=accept`,
  339. });
  340. },
  341. handleDelete(item) {
  342. uni.showModal({
  343. title: "提示",
  344. content: "确定删除该交接单?",
  345. success: async (res) => {
  346. if (res.confirm) {
  347. try {
  348. await deleteHandover([item.id]);
  349. uni.showToast({ title: "删除成功", icon: "success" });
  350. this.refreshList();
  351. } catch (e) {
  352. uni.showToast({
  353. title: (e && e.message) || "删除失败",
  354. icon: "none",
  355. });
  356. }
  357. }
  358. },
  359. });
  360. },
  361. },
  362. };
  363. </script>
  364. <style lang="scss" scoped>
  365. .page-container {
  366. height: 100vh;
  367. display: flex;
  368. flex-direction: column;
  369. background-color: #f5f6f7;
  370. overflow: hidden;
  371. }
  372. /* 搜索栏 */
  373. .search-wrapper {
  374. padding: 16rpx 24rpx;
  375. background-color: #fff;
  376. }
  377. .search-bar {
  378. display: flex;
  379. align-items: center;
  380. gap: 16rpx;
  381. }
  382. .search-input-box {
  383. flex: 1;
  384. display: flex;
  385. align-items: center;
  386. height: 72rpx;
  387. background-color: #f5f6f7;
  388. border-radius: 36rpx;
  389. padding: 0 24rpx;
  390. gap: 12rpx;
  391. }
  392. .search-input {
  393. flex: 1;
  394. height: 72rpx;
  395. font-size: 28rpx;
  396. color: #333;
  397. }
  398. .search-placeholder {
  399. color: #c0c0c0;
  400. font-size: 26rpx;
  401. }
  402. .search-actions {
  403. display: flex;
  404. align-items: center;
  405. flex-shrink: 0;
  406. gap: 12rpx;
  407. }
  408. .filter-btn {
  409. width: 64rpx;
  410. height: 64rpx;
  411. display: flex;
  412. align-items: center;
  413. justify-content: center;
  414. background-color: #f5f6f7;
  415. border-radius: 50%;
  416. &:active {
  417. opacity: 0.7;
  418. }
  419. }
  420. .search-btn {
  421. height: 64rpx;
  422. padding: 0 32rpx;
  423. display: flex;
  424. align-items: center;
  425. justify-content: center;
  426. background-color: #157a2c;
  427. border-radius: 32rpx;
  428. &:active {
  429. opacity: 0.85;
  430. }
  431. }
  432. .search-btn-text {
  433. color: #fff;
  434. font-size: 26rpx;
  435. white-space: nowrap;
  436. }
  437. /* Tab栏 */
  438. .tab-bar {
  439. display: flex;
  440. align-items: center;
  441. background: #fff;
  442. padding: 0 24rpx;
  443. border-bottom: 1rpx solid #f0f0f0;
  444. flex-shrink: 0;
  445. }
  446. .tab-item {
  447. flex: 1;
  448. display: flex;
  449. flex-direction: column;
  450. align-items: center;
  451. padding: 20rpx 0 16rpx;
  452. position: relative;
  453. }
  454. .tab-text {
  455. font-size: 26rpx;
  456. color: #666;
  457. }
  458. .tab-item--active .tab-text {
  459. color: #157a2c;
  460. font-weight: 600;
  461. }
  462. .tab-line {
  463. position: absolute;
  464. bottom: 0;
  465. left: 50%;
  466. transform: translateX(-50%);
  467. width: 48rpx;
  468. height: 4rpx;
  469. background: #157a2c;
  470. border-radius: 2rpx;
  471. }
  472. /* 列表容器 */
  473. .list-container {
  474. overflow: hidden;
  475. /deep/ .u-list {
  476. height: 100% !important;
  477. }
  478. }
  479. /* 工单卡片 */
  480. .order-card {
  481. margin: 20rpx 24rpx 0;
  482. background: #fff;
  483. border-radius: 16rpx;
  484. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
  485. overflow: hidden;
  486. }
  487. /* 卡片头部 */
  488. .card-header {
  489. display: flex;
  490. align-items: center;
  491. justify-content: space-between;
  492. padding: 24rpx 24rpx 16rpx;
  493. border-bottom: 1rpx solid #f0f0f0;
  494. }
  495. .header-left {
  496. display: flex;
  497. align-items: center;
  498. flex: 1;
  499. min-width: 0;
  500. }
  501. .serial-num {
  502. width: 40rpx;
  503. height: 40rpx;
  504. line-height: 40rpx;
  505. border-radius: 50%;
  506. background: #157a2c;
  507. color: #fff;
  508. text-align: center;
  509. font-size: 24rpx;
  510. flex-shrink: 0;
  511. }
  512. .order-code {
  513. margin-left: 16rpx;
  514. font-size: 32rpx;
  515. font-weight: 500;
  516. color: #157a2c;
  517. overflow: hidden;
  518. text-overflow: ellipsis;
  519. white-space: nowrap;
  520. }
  521. .status-tag {
  522. flex-shrink: 0;
  523. margin-left: 16rpx;
  524. padding: 6rpx 16rpx;
  525. border-radius: 20rpx;
  526. font-size: 22rpx;
  527. &--0 {
  528. background: #fff7e6;
  529. .status-text {
  530. color: #fa8c16;
  531. }
  532. }
  533. &--1 {
  534. background: #e6f7ff;
  535. .status-text {
  536. color: #1890ff;
  537. }
  538. }
  539. &--2 {
  540. background: #f6ffed;
  541. .status-text {
  542. color: #52c41a;
  543. }
  544. }
  545. &--3 {
  546. background: #fff1f0;
  547. .status-text {
  548. color: #f5222d;
  549. }
  550. }
  551. }
  552. .status-text {
  553. font-size: 26rpx;
  554. }
  555. /* 卡片内容 */
  556. .card-body {
  557. padding: 16rpx 24rpx;
  558. }
  559. .info-row {
  560. display: flex;
  561. margin-bottom: 8rpx;
  562. }
  563. .info-item {
  564. flex: 1;
  565. display: flex;
  566. flex-direction: column;
  567. padding: 8rpx 0;
  568. min-width: 0;
  569. }
  570. .info-label {
  571. font-size: 26rpx;
  572. color: #999;
  573. margin-bottom: 4rpx;
  574. line-height: 1.4;
  575. }
  576. .info-value {
  577. font-size: 30rpx;
  578. color: #333;
  579. word-break: break-all;
  580. line-height: 1.5;
  581. overflow: hidden;
  582. text-overflow: ellipsis;
  583. white-space: nowrap;
  584. &.highlight {
  585. color: #157a2c;
  586. font-weight: 600;
  587. }
  588. }
  589. /* 卡片底部操作 */
  590. .card-footer {
  591. display: flex;
  592. align-items: center;
  593. justify-content: flex-end;
  594. padding: 16rpx 24rpx;
  595. border-top: 1rpx solid #f0f0f0;
  596. gap: 16rpx;
  597. }
  598. .action-btn {
  599. padding: 12rpx 36rpx;
  600. border-radius: 32rpx;
  601. font-size: 28rpx;
  602. line-height: 1.4;
  603. &--primary {
  604. background: #157a2c;
  605. color: #fff;
  606. &:active {
  607. opacity: 0.85;
  608. }
  609. }
  610. &--danger {
  611. background: #fff;
  612. color: #f5222d;
  613. border: 1rpx solid #f5222d;
  614. &:active {
  615. opacity: 0.85;
  616. }
  617. }
  618. }
  619. /* 加载状态 */
  620. .loading-more {
  621. display: flex;
  622. align-items: center;
  623. justify-content: center;
  624. padding: 30rpx 0 40rpx;
  625. gap: 10rpx;
  626. }
  627. .loading-text {
  628. font-size: 24rpx;
  629. color: #999;
  630. }
  631. .empty-state {
  632. margin-top: 20vh;
  633. }
  634. /* 筛选弹窗 */
  635. .filter-popup {
  636. padding: 32rpx 32rpx 48rpx;
  637. padding-top: calc(var(--status-bar-height, 44px) + 88rpx + 32rpx);
  638. background: #fff;
  639. }
  640. .filter-title {
  641. font-size: 32rpx;
  642. font-weight: 600;
  643. color: #333;
  644. margin-bottom: 32rpx;
  645. }
  646. .filter-form {
  647. margin-bottom: 40rpx;
  648. }
  649. .filter-item {
  650. margin-bottom: 24rpx;
  651. }
  652. .filter-label {
  653. font-size: 26rpx;
  654. color: #666;
  655. margin-bottom: 16rpx;
  656. display: block;
  657. }
  658. .filter-select {
  659. display: flex;
  660. flex-wrap: wrap;
  661. gap: 16rpx;
  662. }
  663. .select-tag {
  664. padding: 12rpx 32rpx;
  665. border-radius: 32rpx;
  666. font-size: 26rpx;
  667. color: #666;
  668. background: #f5f6f7;
  669. &--active {
  670. color: #157a2c;
  671. background: rgba(21, 122, 44, 0.1);
  672. border: 1rpx solid #157a2c;
  673. }
  674. &:active {
  675. opacity: 0.85;
  676. }
  677. }
  678. .filter-actions {
  679. display: flex;
  680. gap: 24rpx;
  681. }
  682. .filter-btn-reset {
  683. flex: 1;
  684. height: 80rpx;
  685. line-height: 80rpx;
  686. text-align: center;
  687. border-radius: 40rpx;
  688. font-size: 28rpx;
  689. color: #666;
  690. background: #f5f6f7;
  691. &:active {
  692. opacity: 0.85;
  693. }
  694. }
  695. .filter-btn-confirm {
  696. flex: 1;
  697. height: 80rpx;
  698. line-height: 80rpx;
  699. text-align: center;
  700. border-radius: 40rpx;
  701. font-size: 28rpx;
  702. color: #fff;
  703. background: #157a2c;
  704. &:active {
  705. opacity: 0.85;
  706. }
  707. }
  708. </style>