taskForm.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. <template>
  2. <view class="">
  3. <view class="sticky-subsection" :style="{ top: `${stickyTop}px` }">
  4. <view class="subsection-wrap">
  5. <u-subsection
  6. fontSize="25"
  7. mode="subsection"
  8. :list="tabList"
  9. :current="curNow"
  10. @change="sectionChange"
  11. activeColor="#157A2C"
  12. ></u-subsection>
  13. </view>
  14. </view>
  15. <view
  16. class="sticky-subsection-placeholder"
  17. :style="{ height: `${stickyPlaceholderHeight}px` }"
  18. ></view>
  19. <!-- Tab 0: 委外单详情 -->
  20. <view v-show="curNow === 0" class="basic_info">
  21. <view class="info_header">
  22. <view class="info_title">委外申请单</view>
  23. <u-gap height="4" bgColor="#1890FF"></u-gap>
  24. </view>
  25. <view class="info_content">
  26. <u-row>
  27. <u-col span="4">
  28. <view class="label">委外单编码:</view>
  29. </u-col>
  30. <u-col span="8">
  31. <view class="value">{{ form.code || "—" }}</view>
  32. </u-col>
  33. </u-row>
  34. <u-row>
  35. <u-col span="4">
  36. <view class="label">委外单名称:</view>
  37. </u-col>
  38. <u-col span="8">
  39. <view class="value">{{ form.name || "—" }}</view>
  40. </u-col>
  41. </u-row>
  42. <u-row>
  43. <u-col span="4">
  44. <view class="label">工单编码:</view>
  45. </u-col>
  46. <u-col span="8">
  47. <view class="value">{{ form.workOrderCode || "—" }}</view>
  48. </u-col>
  49. </u-row>
  50. <u-row>
  51. <u-col span="4">
  52. <view class="label">工序:</view>
  53. </u-col>
  54. <u-col span="8">
  55. <view class="value">{{ form.taskName || "—" }}</view>
  56. </u-col>
  57. </u-row>
  58. <u-row>
  59. <u-col span="4">
  60. <view class="label">委外数量:</view>
  61. </u-col>
  62. <u-col span="8">
  63. <view class="value">{{ form.totalCount || "—" }}</view>
  64. </u-col>
  65. </u-row>
  66. <u-row>
  67. <u-col span="4">
  68. <view class="label">委外重量:</view>
  69. </u-col>
  70. <u-col span="8">
  71. <view class="value">{{ form.totalWeight || "—" }}</view>
  72. </u-col>
  73. </u-row>
  74. <u-row>
  75. <u-col span="4">
  76. <view class="label">委外类型:</view>
  77. </u-col>
  78. <u-col span="8">
  79. <view class="value">{{ typeLabel || "—" }}</view>
  80. </u-col>
  81. </u-row>
  82. <u-row>
  83. <u-col span="4">
  84. <view class="label">状态:</view>
  85. </u-col>
  86. <u-col span="8">
  87. <view class="value">
  88. <text :class="['custom-tag', form.status == 1 ? 'custom-tag--success' : 'custom-tag--info']">{{ form.status == 1 ? '已发布' : '未发布' }}</text>
  89. </view>
  90. </u-col>
  91. </u-row>
  92. <u-row>
  93. <u-col span="4">
  94. <view class="label">备注:</view>
  95. </u-col>
  96. <u-col span="8">
  97. <view class="value">{{ form.remark || "—" }}</view>
  98. </u-col>
  99. </u-row>
  100. <u-row>
  101. <u-col span="4">
  102. <view class="label">预计到货日期:</view>
  103. </u-col>
  104. <u-col span="8">
  105. <view class="value" v-if="form.deliveryMethod == 1">{{ form.requireDeliveryTime || "—" }}</view>
  106. <view class="value" v-else-if="form.deliveryMethod == 2">
  107. <text class="link-text" @click="handleShowTimeList">分批时间</text>
  108. </view>
  109. <view class="value" v-else>—</view>
  110. </u-col>
  111. </u-row>
  112. <u-row>
  113. <u-col span="4">
  114. <view class="label">创建时间:</view>
  115. </u-col>
  116. <u-col span="8">
  117. <view class="value">{{ form.createTime || "—" }}</view>
  118. </u-col>
  119. </u-row>
  120. </view>
  121. <!-- 图片附件 -->
  122. <view v-if="form.technicalDrawings && form.technicalDrawings.length" class="info_content" style="margin-top: 20rpx;">
  123. <view class="label" style="text-align: left; padding-left: 20rpx;">图片附件:</view>
  124. <view v-for="link in form.technicalDrawings" :key="link.id" style="padding: 6rpx 20rpx;">
  125. <text class="link-text">{{ link.name }}</text>
  126. </view>
  127. </view>
  128. <!-- 附件 -->
  129. <view v-if="form.files && form.files.length" class="info_content" style="margin-top: 20rpx;">
  130. <view class="label" style="text-align: left; padding-left: 20rpx;">附件:</view>
  131. <view v-for="link in form.files" :key="link.id" style="padding: 6rpx 20rpx;">
  132. <text class="link-text">{{ link.name }}</text>
  133. </view>
  134. </view>
  135. </view>
  136. <!-- Tab 1: 物品清单详情 -->
  137. <view v-show="curNow === 1" class="basic_info">
  138. <view class="info_header">
  139. <view class="info_title">物品清单</view>
  140. <u-gap height="4" bgColor="#1890FF"></u-gap>
  141. </view>
  142. <view v-if="!detailList.length" class="empty_text">暂无物品清单</view>
  143. <view v-for="(row, idx) in detailList" :key="idx" class="card_box">
  144. <view class="card_title">物品 {{ idx + 1 }}</view>
  145. <u-row>
  146. <u-col span="3">
  147. <view class="label">编码:</view>
  148. </u-col>
  149. <u-col span="9">
  150. <view class="value">{{ row.categoryCode || "—" }}</view>
  151. </u-col>
  152. </u-row>
  153. <u-row>
  154. <u-col span="3">
  155. <view class="label">名称:</view>
  156. </u-col>
  157. <u-col span="9">
  158. <view class="value">{{ row.categoryName || "—" }}</view>
  159. </u-col>
  160. </u-row>
  161. <u-row>
  162. <u-col span="3">
  163. <view class="label">类型:</view>
  164. </u-col>
  165. <u-col span="9">
  166. <view class="value">
  167. <text v-if="row.sourceType == 1" class="custom-tag custom-tag--success">物品清单</text>
  168. <text v-else-if="row.sourceType == 2" class="custom-tag custom-tag--warning">带料清单</text>
  169. <text v-else-if="row.sourceType == 3" class="custom-tag custom-tag--error">产出清单</text>
  170. <text v-else>—</text>
  171. </view>
  172. </u-col>
  173. </u-row>
  174. <u-row>
  175. <u-col span="3">
  176. <view class="label">牌号:</view>
  177. </u-col>
  178. <u-col span="9">
  179. <view class="value">{{ row.brandNum || "—" }}</view>
  180. </u-col>
  181. </u-row>
  182. <u-row>
  183. <u-col span="3">
  184. <view class="label">型号:</view>
  185. </u-col>
  186. <u-col span="9">
  187. <view class="value">{{ row.modelType || "—" }}</view>
  188. </u-col>
  189. </u-row>
  190. <u-row>
  191. <u-col span="3">
  192. <view class="label">规格:</view>
  193. </u-col>
  194. <u-col span="9">
  195. <view class="value">{{ row.specification || "—" }}</view>
  196. </u-col>
  197. </u-row>
  198. <u-row>
  199. <u-col span="3">
  200. <view class="label">数量:</view>
  201. </u-col>
  202. <u-col span="9">
  203. <view class="value">{{ row.totalCount || "—" }}{{ row.measuringUnit || "" }}</view>
  204. </u-col>
  205. </u-row>
  206. <!-- detailType==2 额外字段 -->
  207. <template v-if="form.detailType == 2">
  208. <u-row>
  209. <u-col span="3">
  210. <view class="label">物料代号:</view>
  211. </u-col>
  212. <u-col span="9">
  213. <view class="value">{{ (row.extInfo && row.extInfo.materielCode) || "—" }}</view>
  214. </u-col>
  215. </u-row>
  216. <u-row>
  217. <u-col span="3">
  218. <view class="label">客户代号:</view>
  219. </u-col>
  220. <u-col span="9">
  221. <view class="value">{{ (row.extInfo && row.extInfo.clientCode) || "—" }}</view>
  222. </u-col>
  223. </u-row>
  224. <u-row>
  225. <u-col span="3">
  226. <view class="label">刻码:</view>
  227. </u-col>
  228. <u-col span="9">
  229. <view class="value">{{ (row.extInfo && row.extInfo.engrave) || "—" }}</view>
  230. </u-col>
  231. </u-row>
  232. </template>
  233. </view>
  234. </view>
  235. <!-- 分批时间弹窗 -->
  236. <u-popup :show="showTimePopup" mode="bottom" round="20" @close="showTimePopup = false">
  237. <view class="time-popup">
  238. <view class="time-popup-title">分批时间</view>
  239. <view class="time-popup-total">委外总数:{{ form.totalCount || 0 }}</view>
  240. <view v-if="!timeList.length" class="empty_text">暂无分批时间</view>
  241. <view v-for="(item, idx) in timeList" :key="idx" class="card_box">
  242. <u-row>
  243. <u-col span="4">
  244. <view class="label">数量:</view>
  245. </u-col>
  246. <u-col span="8">
  247. <view class="value">{{ item.purchaseQuantity || "—" }}</view>
  248. </u-col>
  249. </u-row>
  250. <u-row>
  251. <u-col span="4">
  252. <view class="label">到货时间:</view>
  253. </u-col>
  254. <u-col span="8">
  255. <view class="value">{{ formatTime(item.requireDeliveryTime) || "—" }}</view>
  256. </u-col>
  257. </u-row>
  258. </view>
  259. <view style="padding: 20rpx;">
  260. <u-button type="primary" text="关闭" @click="showTimePopup = false"></u-button>
  261. </view>
  262. </view>
  263. </u-popup>
  264. </view>
  265. </template>
  266. <script>
  267. import { getById } from "@/api/wt/outsourcedWarehousing.js";
  268. const TYPE_MAP = {
  269. 1: "采购委外",
  270. 2: "直接发货委外",
  271. 3: "无采购委外",
  272. 4: "带料委外",
  273. 5: "不带料委外",
  274. };
  275. export default {
  276. props: {
  277. businessId: {
  278. default: "",
  279. },
  280. taskDefinitionKey: {
  281. default: "",
  282. },
  283. },
  284. data() {
  285. return {
  286. form: {},
  287. detailList: [],
  288. timeList: [],
  289. showTimePopup: false,
  290. tabList: ["委外单详情", "物品清单"],
  291. curNow: 0,
  292. stickyPlaceholderHeight: 0,
  293. stickyTop: 44,
  294. };
  295. },
  296. computed: {
  297. typeLabel() {
  298. return TYPE_MAP[this.form.type] || "";
  299. },
  300. },
  301. async mounted() {
  302. this.initStickyTop();
  303. await this.getDetailData(this.businessId);
  304. this.updateStickyPlaceholderHeight();
  305. },
  306. methods: {
  307. initStickyTop() {
  308. try {
  309. const systemInfo = uni.getSystemInfoSync();
  310. const statusBarHeight = Number(systemInfo.statusBarHeight || 0);
  311. this.stickyTop = statusBarHeight + 44;
  312. } catch (error) {
  313. this.stickyTop = 50;
  314. }
  315. },
  316. updateStickyPlaceholderHeight() {
  317. this.$nextTick(() => {
  318. const query = uni.createSelectorQuery().in(this);
  319. query
  320. .select(".sticky-subsection")
  321. .boundingClientRect((rect) => {
  322. if (rect && rect.height) {
  323. this.stickyPlaceholderHeight = rect.height;
  324. }
  325. })
  326. .exec();
  327. });
  328. },
  329. sectionChange(index) {
  330. this.curNow = index;
  331. },
  332. async getDetailData(id) {
  333. if (!id) return;
  334. try {
  335. const res = await getById(id);
  336. if (res) {
  337. this.form = res;
  338. this.detailList = res.detailList || [];
  339. this.timeList = res.timeList || [];
  340. }
  341. } catch (e) {
  342. console.warn("获取委外申请单详情失败", e);
  343. }
  344. },
  345. handleShowTimeList() {
  346. this.showTimePopup = true;
  347. },
  348. formatTime(timestamp) {
  349. if (!timestamp) return "";
  350. if (typeof timestamp === "string") return timestamp;
  351. const date = new Date(timestamp);
  352. const pad = (n) => String(n).padStart(2, "0");
  353. return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
  354. },
  355. getTableValue() {
  356. return {
  357. form: this.form,
  358. };
  359. },
  360. },
  361. };
  362. </script>
  363. <style lang="scss">
  364. .sticky-subsection {
  365. position: fixed;
  366. left: 0;
  367. right: 0;
  368. z-index: 99;
  369. width: 100%;
  370. box-sizing: border-box;
  371. background: #f5f7fa;
  372. }
  373. .sticky-subsection-placeholder {
  374. width: 100%;
  375. }
  376. .subsection-wrap {
  377. background: #f5f7fa;
  378. padding: 0 16rpx 12rpx;
  379. width: 100%;
  380. box-sizing: border-box;
  381. }
  382. .basic_info {
  383. box-sizing: border-box;
  384. padding: 0 20rpx;
  385. }
  386. .info_header {
  387. margin-top: 10rpx;
  388. }
  389. .info_title {
  390. position: relative;
  391. padding: 16rpx 50rpx;
  392. font-size: 36rpx;
  393. color: #606266;
  394. }
  395. .info_title::after {
  396. content: "";
  397. position: absolute;
  398. top: 16rpx;
  399. left: 0px;
  400. width: 16rpx;
  401. height: 50rpx;
  402. background: #1890ff;
  403. }
  404. .info_content {
  405. .label {
  406. padding: 20rpx 0;
  407. text-align: right;
  408. font-size: 28rpx;
  409. font-weight: 700;
  410. color: #6e6e6e;
  411. }
  412. .value {
  413. padding: 20rpx 0;
  414. font-size: 28rpx;
  415. color: #606266;
  416. }
  417. }
  418. .card_box {
  419. box-sizing: border-box;
  420. padding: 20rpx;
  421. margin: 20rpx;
  422. width: calc(100% - 40rpx);
  423. border-radius: 20rpx;
  424. box-shadow: 0 0 12rpx -6rpx #000;
  425. .card_title {
  426. font-size: 32rpx;
  427. font-weight: 700;
  428. color: #666;
  429. margin-bottom: 10rpx;
  430. }
  431. .label {
  432. padding: 18rpx 0;
  433. text-align: right;
  434. font-size: 28rpx;
  435. font-weight: 700;
  436. color: #6e6e6e;
  437. }
  438. .value {
  439. padding: 18rpx 0;
  440. font-size: 28rpx;
  441. color: #606266;
  442. }
  443. }
  444. .empty_text {
  445. text-align: center;
  446. color: #909399;
  447. font-size: 28rpx;
  448. padding: 80rpx 0;
  449. }
  450. .tag-inline {
  451. display: flex;
  452. flex-direction: row;
  453. align-items: center;
  454. flex-wrap: wrap;
  455. }
  456. .tag-inline .u-tag {
  457. flex-shrink: 0;
  458. }
  459. .custom-tag {
  460. display: inline-block;
  461. padding: 4rpx 16rpx;
  462. font-size: 24rpx;
  463. border-radius: 8rpx;
  464. line-height: 1.5;
  465. }
  466. .custom-tag--success {
  467. color: #19be6b;
  468. background-color: #dbf1e1;
  469. border: 1px solid #d0f0d8;
  470. }
  471. .custom-tag--info {
  472. color: #909399;
  473. background-color: #f4f4f5;
  474. border: 1px solid #e9e9eb;
  475. }
  476. .custom-tag--warning {
  477. color: #f29100;
  478. background-color: #fdf6ec;
  479. border: 1px solid #faecd8;
  480. }
  481. .custom-tag--error {
  482. color: #fa3534;
  483. background-color: #fef0f0;
  484. border: 1px solid #fde2e2;
  485. }
  486. .link-text {
  487. color: #1890ff;
  488. font-size: 28rpx;
  489. }
  490. .time-popup {
  491. padding: 30rpx;
  492. max-height: 70vh;
  493. overflow-y: auto;
  494. .time-popup-title {
  495. font-size: 34rpx;
  496. font-weight: 700;
  497. text-align: center;
  498. margin-bottom: 20rpx;
  499. }
  500. .time-popup-total {
  501. font-size: 28rpx;
  502. color: #606266;
  503. margin-bottom: 20rpx;
  504. padding-left: 20rpx;
  505. }
  506. }
  507. </style>