taskForm.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  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">{{ typeLabel || "—" }}</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">{{ priorityLabel || "—" }}</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.name || "—" }}</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.pleaseEntrustDeptName || "—" }}</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.pleaseEntrustUserName || "—" }}</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.factoriesName || "—" }}</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">{{
  80. form.beEntrustedFactoriesName || "—"
  81. }}</view>
  82. </u-col>
  83. </u-row>
  84. <u-row>
  85. <u-col span="4">
  86. <view class="label">受托部门:</view>
  87. </u-col>
  88. <u-col span="8">
  89. <view class="value">{{ form.beEntrustedDeptName || "—" }}</view>
  90. </u-col>
  91. </u-row>
  92. </view>
  93. </view>
  94. <!-- Tab 1: 产品信息 -->
  95. <view v-show="curNow === 1" class="basic_info">
  96. <view class="info_header">
  97. <view class="info_title">产品信息</view>
  98. <u-gap height="4" bgColor="#1890FF"></u-gap>
  99. </view>
  100. <view v-if="!orderList.length" class="empty_text">暂无产品信息</view>
  101. <view v-for="(row, idx) in orderList" :key="idx" class="card_box">
  102. <view class="card_title">产品 {{ idx + 1 }}</view>
  103. <u-row>
  104. <u-col span="4">
  105. <view class="label">产品名称:</view>
  106. </u-col>
  107. <u-col span="8">
  108. <view class="value">{{ row.categoryName || "—" }}</view>
  109. </u-col>
  110. </u-row>
  111. <u-row>
  112. <u-col span="4">
  113. <view class="label">计划编号:</view>
  114. </u-col>
  115. <u-col span="8">
  116. <view class="value">{{ row.productionPlanCode || "—" }}</view>
  117. </u-col>
  118. </u-row>
  119. <u-row>
  120. <u-col span="4">
  121. <view class="label">牌号:</view>
  122. </u-col>
  123. <u-col span="8">
  124. <view class="value">{{ row.brandNum || "—" }}</view>
  125. </u-col>
  126. </u-row>
  127. <u-row>
  128. <u-col span="4">
  129. <view class="label">批次号:</view>
  130. </u-col>
  131. <u-col span="8">
  132. <view class="value">{{ row.batchNo || "—" }}</view>
  133. </u-col>
  134. </u-row>
  135. <u-row>
  136. <u-col span="4">
  137. <view class="label">需求描述:</view>
  138. </u-col>
  139. <u-col span="8">
  140. <view class="value">{{ row.describes || "—" }}</view>
  141. </u-col>
  142. </u-row>
  143. <u-row>
  144. <u-col span="4">
  145. <view class="label">请托数量:</view>
  146. </u-col>
  147. <u-col span="8">
  148. <view class="value"
  149. >{{ row.totalCount || "—" }}{{ row.measuringUnit || "" }}</view
  150. >
  151. </u-col>
  152. </u-row>
  153. <u-row>
  154. <u-col span="4">
  155. <view class="label">计划类型:</view>
  156. </u-col>
  157. <u-col span="8">
  158. <view class="value">{{
  159. getPlanTypeLabel(row.planType) || "—"
  160. }}</view>
  161. </u-col>
  162. </u-row>
  163. <u-row>
  164. <u-col span="4">
  165. <view class="label">生产工单号:</view>
  166. </u-col>
  167. <u-col span="8">
  168. <view class="value">{{ row.code || "—" }}</view>
  169. </u-col>
  170. </u-row>
  171. <u-row>
  172. <u-col span="4">
  173. <view class="label">规格:</view>
  174. </u-col>
  175. <u-col span="8">
  176. <view class="value">{{ row.specification || "—" }}</view>
  177. </u-col>
  178. </u-row>
  179. <u-row>
  180. <u-col span="4">
  181. <view class="label">名称:</view>
  182. </u-col>
  183. <u-col span="8">
  184. <view class="value">{{ row.name || "—" }}</view>
  185. </u-col>
  186. </u-row>
  187. <u-row>
  188. <u-col span="4">
  189. <view class="label">型号:</view>
  190. </u-col>
  191. <u-col span="8">
  192. <view class="value">{{ row.modelType || "—" }}</view>
  193. </u-col>
  194. </u-row>
  195. <u-row>
  196. <u-col span="4">
  197. <view class="label">工艺路线:</view>
  198. </u-col>
  199. <u-col span="8">
  200. <view class="value">{{ row.produceRoutingName || "—" }}</view>
  201. </u-col>
  202. </u-row>
  203. <u-row>
  204. <u-col span="4">
  205. <view class="label">BOM分类:</view>
  206. </u-col>
  207. <u-col span="8">
  208. <view class="value">{{ getBomTypeLabel(row.bomType) || "—" }}</view>
  209. </u-col>
  210. </u-row>
  211. <u-row>
  212. <u-col span="4">
  213. <view class="label">BOM版本:</view>
  214. </u-col>
  215. <u-col span="8">
  216. <view class="value">{{ getBomVersionLabel(row) || "—" }}</view>
  217. </u-col>
  218. </u-row>
  219. <u-row>
  220. <u-col span="4">
  221. <view class="label">工序:</view>
  222. </u-col>
  223. <u-col span="8">
  224. <view class="value">{{ row.taskName || "—" }}</view>
  225. </u-col>
  226. </u-row>
  227. <u-row>
  228. <u-col span="4">
  229. <view class="label">编码:</view>
  230. </u-col>
  231. <u-col span="8">
  232. <view class="value">{{ row.categoryCode || "—" }}</view>
  233. </u-col>
  234. </u-row>
  235. <u-row>
  236. <u-col span="4">
  237. <view class="label">完成日期:</view>
  238. </u-col>
  239. <u-col span="8">
  240. <view class="value">{{ row.planDeliveryTime || "—" }}</view>
  241. </u-col>
  242. </u-row>
  243. <u-row>
  244. <u-col span="4">
  245. <view class="label">计划开始时间:</view>
  246. </u-col>
  247. <u-col span="8">
  248. <view class="value">{{ row.planStartTime || "—" }}</view>
  249. </u-col>
  250. </u-row>
  251. <u-row>
  252. <u-col span="4">
  253. <view class="label">计划结束时间:</view>
  254. </u-col>
  255. <u-col span="8">
  256. <view class="value">{{ row.planCompleteTime || "—" }}</view>
  257. </u-col>
  258. </u-row>
  259. <u-row>
  260. <u-col span="4">
  261. <view class="label">工单开始时间:</view>
  262. </u-col>
  263. <u-col span="8">
  264. <view class="value">{{ row.startTime || "—" }}</view>
  265. </u-col>
  266. </u-row>
  267. <u-row>
  268. <u-col span="4">
  269. <view class="label">工单结束时间:</view>
  270. </u-col>
  271. <u-col span="8">
  272. <view class="value">{{ row.completeTime || "—" }}</view>
  273. </u-col>
  274. </u-row>
  275. </view>
  276. </view>
  277. </view>
  278. </template>
  279. <script>
  280. import {
  281. pleaseEntrustDetail,
  282. getProduceTaskList,
  283. } from "@/api/entrust/index.js";
  284. import { getDictByCode } from "@/api/common";
  285. const PLAN_TYPE_MAP = {
  286. 1: "内销计划",
  287. 2: "外销计划",
  288. 3: "预制计划",
  289. };
  290. const BOM_TYPE_MAP = {
  291. 1: "产品(PBOM)",
  292. 2: "加工(MBOM)",
  293. 3: "装配(ABOM)",
  294. };
  295. export default {
  296. props: {
  297. businessId: {
  298. default: "",
  299. },
  300. taskDefinitionKey: {
  301. default: "",
  302. },
  303. },
  304. data() {
  305. return {
  306. form: {
  307. name: "",
  308. type: "",
  309. priority: "",
  310. pleaseEntrustDeptName: "",
  311. pleaseEntrustUserName: "",
  312. factoriesName: "",
  313. beEntrustedFactoriesName: "",
  314. beEntrustedDeptName: "",
  315. },
  316. orderList: [],
  317. typeList: [],
  318. tabList: ["基本信息", "产品信息"],
  319. curNow: 0,
  320. stickyPlaceholderHeight: 0,
  321. stickyTop: 44,
  322. options: [
  323. { name: "一般", value: 1 },
  324. { name: "紧急", value: 2 },
  325. ],
  326. };
  327. },
  328. computed: {
  329. typeLabel() {
  330. if (!this.form.type && this.form.type !== 0) return "";
  331. const item = this.typeList.find((i) => i.value == this.form.type);
  332. return item ? item.label : "";
  333. },
  334. priorityLabel() {
  335. const item = this.options.find((i) => i.value == this.form.priority);
  336. return item ? item.name : "";
  337. },
  338. },
  339. async mounted() {
  340. await this.getTypeList();
  341. this.initStickyTop();
  342. await this.init();
  343. this.updateStickyPlaceholderHeight();
  344. },
  345. methods: {
  346. initStickyTop() {
  347. try {
  348. const systemInfo = uni.getSystemInfoSync();
  349. const statusBarHeight = Number(systemInfo.statusBarHeight || 0);
  350. this.stickyTop = statusBarHeight + 44;
  351. } catch (error) {
  352. this.stickyTop = 50;
  353. }
  354. },
  355. async getTypeList() {
  356. try {
  357. const res = await getDictByCode("entrust_type");
  358. if (res?.length != 0) {
  359. let list = res.map((item) => {
  360. let key = Object.keys(item)[0];
  361. return { value: Number(key), label: item[key] };
  362. });
  363. this.typeList = list;
  364. }
  365. } catch (error) {
  366. console.error("获取类型列表失败", error);
  367. }
  368. },
  369. updateStickyPlaceholderHeight() {
  370. this.$nextTick(() => {
  371. const query = uni.createSelectorQuery().in(this);
  372. query
  373. .select(".sticky-subsection")
  374. .boundingClientRect((rect) => {
  375. if (rect && rect.height) {
  376. this.stickyPlaceholderHeight = rect.height;
  377. }
  378. })
  379. .exec();
  380. });
  381. },
  382. sectionChange(index) {
  383. this.curNow = index;
  384. },
  385. async init() {
  386. if (!this.businessId) return;
  387. try {
  388. const data = await pleaseEntrustDetail(this.businessId);
  389. const {
  390. applyDeptName,
  391. applyDeptId,
  392. createUserName,
  393. createUserId,
  394. applyFactoriesId,
  395. applyFactoriesName,
  396. beEntrustedDeptId,
  397. beEntrustedDeptName,
  398. beEntrustedFactoriesName,
  399. beEntrustedFactoriesId,
  400. name,
  401. type,
  402. priority,
  403. id: dataId,
  404. } = data;
  405. Object.assign(this.form, {
  406. pleaseEntrustDeptName: applyDeptName,
  407. pleaseEntrustDeptId: applyDeptId,
  408. pleaseEntrustUserName: createUserName,
  409. pleaseEntrustUserId: createUserId,
  410. factoriesId: applyFactoriesId,
  411. factoriesName: applyFactoriesName,
  412. beEntrustedDeptId,
  413. beEntrustedDeptName,
  414. beEntrustedFactoriesName,
  415. beEntrustedFactoriesId,
  416. name,
  417. type,
  418. priority,
  419. id: dataId,
  420. });
  421. const newData = {
  422. ...this.deepCopy(data),
  423. taskList: [],
  424. };
  425. this.orderList.push(newData);
  426. this.getOrderTaskList();
  427. this.form.type = this.form.type + "";
  428. } catch (e) {
  429. console.warn("获取请托详情失败", e);
  430. }
  431. },
  432. deepCopy(obj, hash = new WeakMap()) {
  433. if (obj === null) return null;
  434. if (obj instanceof Date) return new Date(obj);
  435. if (obj instanceof RegExp) return new RegExp(obj);
  436. if (typeof obj !== "object" && typeof obj !== "function") return obj;
  437. if (hash.has(obj)) return hash.get(obj);
  438. const result = Array.isArray(obj) ? [] : {};
  439. hash.set(obj, result);
  440. return Object.keys(obj).reduce((acc, key) => {
  441. acc[key] = this.deepCopy(obj[key], hash);
  442. return acc;
  443. }, result);
  444. },
  445. async getOrderTaskList() {
  446. for (const item of this.orderList) {
  447. try {
  448. const res = await getProduceTaskList({
  449. isDetail: true,
  450. pageNum: 1,
  451. routingId: item.produceRoutingId,
  452. size: -1,
  453. });
  454. item.taskList = res.list || [];
  455. if (item.taskId && item.taskList.length) {
  456. const matched = item.taskList.find((t) => t.id === item.taskId);
  457. if (matched) {
  458. this.$set(item, "taskName", matched.name);
  459. }
  460. }
  461. } catch (e) {
  462. console.warn("获取工序列表失败", e);
  463. }
  464. }
  465. },
  466. getPlanTypeLabel(val) {
  467. return PLAN_TYPE_MAP[val] || "";
  468. },
  469. getBomTypeLabel(val) {
  470. return BOM_TYPE_MAP[val] || "";
  471. },
  472. getBomVersionLabel(row) {
  473. if (row.bomCategoryName) {
  474. return `${row.bomCategoryName} (V${row.bomCategoryVersions}.0)`;
  475. }
  476. return "";
  477. },
  478. getTableValue() {
  479. return {
  480. form: this.form,
  481. orderList: this.orderList,
  482. };
  483. },
  484. },
  485. };
  486. </script>
  487. <style lang="scss">
  488. .sticky-subsection {
  489. position: fixed;
  490. left: 0;
  491. right: 0;
  492. z-index: 99;
  493. width: 100%;
  494. box-sizing: border-box;
  495. background: #f5f7fa;
  496. }
  497. .sticky-subsection-placeholder {
  498. width: 100%;
  499. }
  500. .subsection-wrap {
  501. background: #f5f7fa;
  502. padding: 0 16rpx 12rpx;
  503. width: 100%;
  504. box-sizing: border-box;
  505. }
  506. .basic_info {
  507. box-sizing: border-box;
  508. padding: 0 20rpx;
  509. }
  510. .info_header {
  511. margin-top: 10rpx;
  512. }
  513. .info_title {
  514. position: relative;
  515. padding: 16rpx 50rpx;
  516. font-size: 36rpx;
  517. color: #606266;
  518. }
  519. .info_title::after {
  520. content: "";
  521. position: absolute;
  522. top: 16rpx;
  523. left: 0px;
  524. width: 16rpx;
  525. height: 50rpx;
  526. background: #1890ff;
  527. }
  528. .info_content {
  529. .label {
  530. padding: 20rpx 0;
  531. text-align: right;
  532. font-size: 28rpx;
  533. font-weight: 700;
  534. color: #6e6e6e;
  535. }
  536. .value {
  537. padding: 20rpx 0;
  538. font-size: 28rpx;
  539. color: #606266;
  540. }
  541. }
  542. .card_box {
  543. box-sizing: border-box;
  544. padding: 20rpx;
  545. margin: 20rpx;
  546. width: calc(100% - 40rpx);
  547. border-radius: 20rpx;
  548. box-shadow: 0 0 12rpx -6rpx #000;
  549. .card_title {
  550. font-size: 32rpx;
  551. font-weight: 700;
  552. color: #666;
  553. margin-bottom: 10rpx;
  554. }
  555. .label {
  556. padding: 18rpx 0;
  557. text-align: right;
  558. font-size: 28rpx;
  559. font-weight: 700;
  560. color: #6e6e6e;
  561. }
  562. .value {
  563. padding: 18rpx 0;
  564. font-size: 28rpx;
  565. color: #606266;
  566. }
  567. }
  568. .empty_text {
  569. text-align: center;
  570. color: #909399;
  571. font-size: 28rpx;
  572. padding: 80rpx 0;
  573. }
  574. </style>