accessories.vue 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922
  1. <template>
  2. <block v-if="!isBom">
  3. <view class="search-box">
  4. <up-search placeholder="搜索关键词" v-model="keyword" height="35" @blur="onSearch" :clearabled="false"
  5. :showAction="false" />
  6. <view v-if="content.where.condition" class="clear" @click.stop="onSearch('')">
  7. <up-icon name="close-circle-fill" size="20" />
  8. </view>
  9. </view>
  10. <view style="height: 20rpx;" />
  11. </block>
  12. <My_listbox v-if="!isBom" ref="listBox" :empty="!list.length" :pullDown="!isBom" @getlist="getList">
  13. <showList :result="resultIds" :list='list' @onClick="onSelect" />
  14. <view style="height: 200rpx;" />
  15. </My_listbox>
  16. <view v-else class="bom">
  17. <view class="left">
  18. <view class="class1" :class="active.class1 == index ? 'class1active' : ''" @click="changeClass1(index)"
  19. v-for="(item, index) in bomList" :key="item.plm_bomid" hover-class="navigator-hover">
  20. {{ item.bomname }}
  21. </view>
  22. </view>
  23. <view class="right">
  24. <My_listbox v-if="isBom" ref="listBox" :pullDown="false">
  25. <up-collapse :value="collapse1" @change="changeCollapse1($event)">
  26. <up-collapse-item :ref="el => {
  27. if (el) {
  28. collapseRefs['collapse' + item.plm_bomid] = el
  29. }
  30. }" :cellCustomStyle="{
  31. backgroundColor: '#fff',
  32. }" v-for="item in bomList[active.class1].subdep" :key="item.plm_bomid" :title="item.bomname"
  33. :name="item.plm_bomid">
  34. <up-collapse @change="changeCollapse($event, item.plm_bomid)" v-if="item.subdep.length"
  35. :name="item.plm_bomid">
  36. <up-collapse-item :cellCustomStyle="{
  37. backgroundColor: '#fff',
  38. }" :ref="el => {
  39. if (el) {
  40. collapseRefs['collapse' + item.plm_bomid] = el
  41. }
  42. }" v-for="item1 in bomList[active.class1].subdep[active.class2].subdep"
  43. :key="item1.plm_bomid" :title="item1.bomname" :name="item1.plm_bomid">
  44. <showList v-if="item1.items.length" size="small" :result="resultIds" :list='item1.items'
  45. @onClick="onSelect" />
  46. </up-collapse-item>
  47. </up-collapse>
  48. <showList v-if="item.items.length" size="small" :result="resultIds" :list='item.items'
  49. @onClick="onSelect" />
  50. </up-collapse-item>
  51. </up-collapse>
  52. <view style="height: 200rpx;" />
  53. </My_listbox>
  54. </view>
  55. </view>
  56. <view class="footer">
  57. <My-button :text="`确定添加(${resultIds.length})`" @onClick="onAdd" />
  58. </view>
  59. </template>
  60. <script setup>
  61. import { ref, reactive, getCurrentInstance, nextTick } from 'vue';
  62. import { onLoad } from '@dcloudio/uni-app';
  63. import showList from "./accessoriesList.vue";
  64. const collapseRefs = ref({})
  65. const collapse1 = ref([])
  66. function changeCollapse1(e) {
  67. collapse1.value = e.filter(v => v.status == 'open').map(v => v.name)
  68. }
  69. function changeCollapse(e, id) {
  70. setTimeout(() => {
  71. nextTick(() => {
  72. collapseRefs.value['collapse' + id].init()
  73. });
  74. }, 300);
  75. }
  76. const { $Http } = getCurrentInstance().proxy;
  77. const listBox = ref(null);
  78. const isBom = ref(false);
  79. let result = reactive([]);
  80. const resultIds = ref([]);
  81. const content = reactive({
  82. loading: false,
  83. "pageNumber": 1,
  84. "pageSize": 20,
  85. "where": {
  86. "condition": ""
  87. }
  88. })
  89. function onAdd() {
  90. $Http.selectAcc(result)
  91. }
  92. function onSelect(e) {
  93. if (result.some(item => item.itemid == e.itemid)) {
  94. result = result.filter(item => item.itemid != e.itemid);
  95. } else {
  96. result.push(e);
  97. }
  98. resultIds.value = result.map(item => item.itemid);
  99. }
  100. const list = ref([]);
  101. onLoad((options) => {
  102. console.log("options", options)
  103. console.log("$Http", $Http)
  104. result = result.concat(JSON.parse(options.list || '[]'));
  105. resultIds.value = result.map(item => item.itemid);
  106. console.log("初始选中", result, resultIds.value)
  107. let content1 = $Http.content1;
  108. content.sys_enterpriseid = content1.sys_enterpriseid;
  109. content.sa_workorderid = content1.sa_workorderid;
  110. if (content1.sku) $Http.basic({
  111. "id": 2025080610424703,
  112. "content": content1
  113. }).then(res => {
  114. console.log("查询产品是否存在BOM", res)
  115. if (res.data == 0) {
  116. // 不存在BOM
  117. getList(true);
  118. } else {
  119. // 存在BOM
  120. isBom.value = true;
  121. getBomList();
  122. }
  123. })
  124. })
  125. const bomList = ref([
  126. {
  127. "bom": [
  128. {
  129. "plm_bomid": 1,
  130. "bomfullname": "集成灶",
  131. "subdep": [
  132. {
  133. "plm_bomid": 11,
  134. "bomfullname": "集成灶/排油烟模块",
  135. "subdep": [
  136. {
  137. "plm_bomid": 16,
  138. "bomfullname": "集成灶/排油烟模块/烟管连接件",
  139. "subdep": [
  140. {
  141. "plm_bomid": 30,
  142. "bomfullname": "集成灶/排油烟模块/烟管连接件/风门转接板",
  143. "subdep": [],
  144. "isdeep": 1,
  145. "num": "1",
  146. "bomname": "风门转接板",
  147. "rowindex": 29,
  148. "items": [
  149. {
  150. "begindate": "2025-07-18 00:00:00",
  151. "itemname": "600无缝板摩卡单色C(2米)",
  152. "module": "排油烟模块",
  153. "itemno": "LSAQPT00404",
  154. "spec": "",
  155. "sa_aftersalesbom_pjsid": 92,
  156. "itemid": 117810,
  157. "component": "烟管连接件",
  158. "enddate": "2025-08-15 00:00:00",
  159. "sa_aftersalesbomid": 2,
  160. "attinfos": [],
  161. "price": 0,
  162. "siteid": "lsa",
  163. "accessorie": "风门转接板",
  164. "model": "GB6201",
  165. "rowindex": 10,
  166. "brand": [],
  167. "typename": "风门转接板",
  168. "status": "",
  169. "tradefield": [
  170. {
  171. "itemid": 117810,
  172. "rowindex": 10,
  173. "tradefield": "建材家居"
  174. }
  175. ]
  176. }
  177. ],
  178. "parentid": 16
  179. },
  180. {
  181. "plm_bomid": 29,
  182. "bomfullname": "集成灶/排油烟模块/烟管连接件/烟管接头",
  183. "subdep": [],
  184. "isdeep": 1,
  185. "num": "1",
  186. "bomname": "烟管接头",
  187. "rowindex": 28,
  188. "parentid": 16
  189. },
  190. {
  191. "plm_bomid": 28,
  192. "bomfullname": "集成灶/排油烟模块/烟管连接件/烟管延长接头",
  193. "subdep": [],
  194. "isdeep": 1,
  195. "num": "1",
  196. "bomname": "烟管延长接头",
  197. "rowindex": 27,
  198. "parentid": 16
  199. },
  200. {
  201. "plm_bomid": 27,
  202. "bomfullname": "集成灶/排油烟模块/烟管连接件/烟管堵盖",
  203. "subdep": [],
  204. "isdeep": 1,
  205. "num": "1",
  206. "bomname": "烟管堵盖",
  207. "rowindex": 26,
  208. "parentid": 16
  209. }
  210. ],
  211. "isdeep": 0,
  212. "num": "1",
  213. "bomname": "烟管连接件",
  214. "rowindex": 15,
  215. "parentid": 11
  216. },
  217. {
  218. "plm_bomid": 15,
  219. "bomfullname": "集成灶/排油烟模块/风道过渡面板",
  220. "subdep": [],
  221. "isdeep": 1,
  222. "num": "1",
  223. "bomname": "风道过渡面板",
  224. "rowindex": 14,
  225. "items": [
  226. {
  227. "begindate": "2025-07-15 00:00:00",
  228. "itemname": "600无缝板顺理成章",
  229. "module": "排油烟模块",
  230. "itemno": "LSAQPT00904",
  231. "spec": "",
  232. "sa_aftersalesbom_pjsid": 46,
  233. "itemid": 117714,
  234. "component": "风道过渡面板",
  235. "enddate": "2025-08-15 00:00:00",
  236. "sa_aftersalesbomid": 2,
  237. "attinfos": [],
  238. "price": 0,
  239. "siteid": "lsa",
  240. "accessorie": "",
  241. "model": "GB6281",
  242. "rowindex": 1,
  243. "brand": [],
  244. "typename": "风道过渡面板",
  245. "status": "",
  246. "tradefield": [
  247. {
  248. "itemid": 117714,
  249. "rowindex": 1,
  250. "tradefield": "建材家居"
  251. }
  252. ]
  253. }
  254. ],
  255. "parentid": 11
  256. },
  257. {
  258. "plm_bomid": 14,
  259. "bomfullname": "集成灶/排油烟模块/风道组件",
  260. "subdep": [
  261. {
  262. "plm_bomid": 26,
  263. "bomfullname": "集成灶/排油烟模块/风道组件/集油弯头密封圈",
  264. "subdep": [],
  265. "isdeep": 1,
  266. "num": "1",
  267. "bomname": "集油弯头密封圈",
  268. "rowindex": 25,
  269. "items": [
  270. {
  271. "begindate": "2025-07-15 00:00:00",
  272. "itemname": "600无缝板爵士白",
  273. "module": "排油烟模块",
  274. "itemno": "LSAQTS00074",
  275. "spec": "",
  276. "sa_aftersalesbom_pjsid": 60,
  277. "itemid": 117720,
  278. "component": "风道组件",
  279. "enddate": "2025-08-15 00:00:00",
  280. "sa_aftersalesbomid": 2,
  281. "attinfos": [],
  282. "price": 0,
  283. "siteid": "lsa",
  284. "accessorie": "集油弯头密封圈",
  285. "model": "GB6281",
  286. "rowindex": 2,
  287. "brand": [],
  288. "typename": "集油弯头密封圈",
  289. "status": "",
  290. "tradefield": [
  291. {
  292. "itemid": 117720,
  293. "rowindex": 2,
  294. "tradefield": "建材家居"
  295. }
  296. ]
  297. },
  298. {
  299. "begindate": "2025-07-15 00:00:00",
  300. "itemname": "600v双层蜂香板慈宫金碧(2.6米)",
  301. "module": "排油烟模块",
  302. "itemno": "LSAFZZ00214",
  303. "spec": "",
  304. "sa_aftersalesbom_pjsid": 61,
  305. "itemid": 117746,
  306. "component": "风道组件",
  307. "enddate": "2025-08-15 00:00:00",
  308. "sa_aftersalesbomid": 2,
  309. "attinfos": [],
  310. "price": 0,
  311. "siteid": "lsa",
  312. "accessorie": "集油弯头密封圈",
  313. "model": "GB626FV",
  314. "rowindex": 3,
  315. "brand": [],
  316. "typename": "集油弯头密封圈",
  317. "status": "",
  318. "tradefield": [
  319. {
  320. "itemid": 117746,
  321. "rowindex": 7,
  322. "tradefield": "建材家居"
  323. }
  324. ]
  325. },
  326. {
  327. "begindate": "2025-07-15 00:00:00",
  328. "itemname": "68套色门框线白橡木",
  329. "module": "排油烟模块",
  330. "itemno": "LSAFZZ00083",
  331. "spec": "",
  332. "sa_aftersalesbom_pjsid": 62,
  333. "itemid": 117733,
  334. "component": "风道组件",
  335. "enddate": "2025-08-15 00:00:00",
  336. "sa_aftersalesbomid": 2,
  337. "attinfos": [],
  338. "price": 0,
  339. "siteid": "lsa",
  340. "accessorie": "集油弯头密封圈",
  341. "model": "LSA.EM-TL-004",
  342. "rowindex": 4,
  343. "brand": [],
  344. "typename": "集油弯头密封圈",
  345. "status": "",
  346. "tradefield": [
  347. {
  348. "itemid": 117733,
  349. "rowindex": 5,
  350. "tradefield": "建材家居"
  351. }
  352. ]
  353. }
  354. ],
  355. "parentid": 14
  356. },
  357. {
  358. "plm_bomid": 25,
  359. "bomfullname": "集成灶/排油烟模块/风道组件/集油弯头",
  360. "subdep": [],
  361. "isdeep": 1,
  362. "num": "1",
  363. "bomname": "集油弯头",
  364. "rowindex": 24,
  365. "items": [
  366. {
  367. "begindate": "2025-07-15 00:00:00",
  368. "itemname": "600V双层蜂香板星辰-伽马2(3米)",
  369. "module": "排油烟模块",
  370. "itemno": "LSAQSX00127",
  371. "spec": "",
  372. "sa_aftersalesbom_pjsid": 64,
  373. "itemid": 117747,
  374. "component": "风道组件",
  375. "enddate": "2025-08-15 00:00:00",
  376. "sa_aftersalesbomid": 2,
  377. "attinfos": [],
  378. "price": 0,
  379. "siteid": "lsa",
  380. "accessorie": "集油弯头",
  381. "model": "LSA.XB-201012",
  382. "rowindex": 5,
  383. "brand": [],
  384. "typename": "集油弯头",
  385. "status": "",
  386. "tradefield": [
  387. {
  388. "itemid": 117747,
  389. "rowindex": 8,
  390. "tradefield": "建材家居"
  391. }
  392. ]
  393. }
  394. ],
  395. "parentid": 14
  396. },
  397. {
  398. "plm_bomid": 24,
  399. "bomfullname": "集成灶/排油烟模块/风道组件/卡箍φ16-25",
  400. "subdep": [],
  401. "isdeep": 1,
  402. "num": "1",
  403. "bomname": "卡箍φ16-25",
  404. "rowindex": 23,
  405. "parentid": 14
  406. },
  407. {
  408. "plm_bomid": 23,
  409. "bomfullname": "集成灶/排油烟模块/风道组件/下油管φ19",
  410. "subdep": [],
  411. "isdeep": 1,
  412. "num": "1",
  413. "bomname": "下油管φ19",
  414. "rowindex": 22,
  415. "parentid": 14
  416. }
  417. ],
  418. "isdeep": 0,
  419. "num": "1",
  420. "bomname": "风道组件",
  421. "rowindex": 13,
  422. "parentid": 11
  423. },
  424. {
  425. "plm_bomid": 13,
  426. "bomfullname": "集成灶/排油烟模块/蜗壳上盖板",
  427. "subdep": [],
  428. "isdeep": 1,
  429. "num": "1",
  430. "bomname": "蜗壳上盖板",
  431. "rowindex": 12,
  432. "parentid": 11
  433. },
  434. {
  435. "plm_bomid": 12,
  436. "bomfullname": "集成灶/排油烟模块/蜗壳组件",
  437. "subdep": [
  438. {
  439. "plm_bomid": 22,
  440. "bomfullname": "集成灶/排油烟模块/蜗壳组件/清洗加热垫",
  441. "subdep": [],
  442. "isdeep": 1,
  443. "num": "1",
  444. "bomname": "清洗加热垫",
  445. "rowindex": 21,
  446. "items": [
  447. {
  448. "begindate": "2025-07-15 00:00:00",
  449. "itemname": "600无缝板竹节拉丝(2.6米)",
  450. "module": "排油烟模块",
  451. "itemno": "LSAQQM00023",
  452. "spec": "",
  453. "sa_aftersalesbom_pjsid": 73,
  454. "itemid": 117750,
  455. "component": "蜗壳组件",
  456. "enddate": "2025-08-15 00:00:00",
  457. "sa_aftersalesbomid": 2,
  458. "attinfos": [],
  459. "price": 0,
  460. "siteid": "lsa",
  461. "accessorie": "清洗加热垫",
  462. "model": "LSA-BJ-QB03",
  463. "rowindex": 6,
  464. "brand": [],
  465. "typename": "清洗加热垫",
  466. "status": "",
  467. "tradefield": [
  468. {
  469. "itemid": 117750,
  470. "rowindex": 9,
  471. "tradefield": "建材家居"
  472. }
  473. ]
  474. },
  475. {
  476. "begindate": "2025-07-15 00:00:00",
  477. "itemname": "600无缝板风中骑士(2米)",
  478. "module": "排油烟模块",
  479. "itemno": "LSAQTS00016",
  480. "spec": "",
  481. "sa_aftersalesbom_pjsid": 74,
  482. "itemid": 117737,
  483. "component": "蜗壳组件",
  484. "enddate": "2025-08-15 00:00:00",
  485. "sa_aftersalesbomid": 2,
  486. "attinfos": [],
  487. "price": 0,
  488. "siteid": "lsa",
  489. "accessorie": "清洗加热垫",
  490. "model": "",
  491. "rowindex": 7,
  492. "brand": [],
  493. "typename": "清洗加热垫",
  494. "status": "",
  495. "tradefield": [
  496. {
  497. "itemid": 117737,
  498. "rowindex": 6,
  499. "tradefield": "建材家居"
  500. }
  501. ]
  502. }
  503. ],
  504. "parentid": 12
  505. },
  506. {
  507. "plm_bomid": 21,
  508. "bomfullname": "集成灶/排油烟模块/蜗壳组件/法兰盘密封圈",
  509. "subdep": [],
  510. "isdeep": 1,
  511. "num": "1",
  512. "bomname": "法兰盘密封圈",
  513. "rowindex": 20,
  514. "items": [
  515. {
  516. "begindate": "2025-07-15 00:00:00",
  517. "itemname": "450V双层蜂香板波斯蓝(2.6米)",
  518. "module": "排油烟模块",
  519. "itemno": "LSAFZZ00106",
  520. "spec": "",
  521. "sa_aftersalesbom_pjsid": 75,
  522. "itemid": 117725,
  523. "component": "蜗壳组件",
  524. "enddate": "2025-08-15 00:00:00",
  525. "sa_aftersalesbomid": 2,
  526. "attinfos": [],
  527. "price": 0,
  528. "siteid": "lsa",
  529. "accessorie": "法兰盘密封圈",
  530. "model": "GB426FV",
  531. "rowindex": 8,
  532. "brand": [],
  533. "typename": "法兰盘密封圈",
  534. "status": "",
  535. "tradefield": [
  536. {
  537. "itemid": 117725,
  538. "rowindex": 3,
  539. "tradefield": "建材家居"
  540. }
  541. ]
  542. }
  543. ],
  544. "parentid": 12
  545. },
  546. {
  547. "plm_bomid": 20,
  548. "bomfullname": "集成灶/排油烟模块/蜗壳组件/电机法兰盘",
  549. "subdep": [],
  550. "isdeep": 1,
  551. "num": "1",
  552. "bomname": "电机法兰盘",
  553. "rowindex": 19,
  554. "parentid": 12
  555. },
  556. {
  557. "plm_bomid": 19,
  558. "bomfullname": "集成灶/排油烟模块/蜗壳组件/风帽",
  559. "subdep": [],
  560. "isdeep": 1,
  561. "num": "1",
  562. "bomname": "风帽",
  563. "rowindex": 18,
  564. "items": [
  565. {
  566. "begindate": "2025-07-15 00:00:00",
  567. "itemname": "120V缝板摩卡单色A",
  568. "module": "排油烟模块",
  569. "itemno": "LSAFZZ00991",
  570. "spec": "",
  571. "sa_aftersalesbom_pjsid": 79,
  572. "itemid": 117727,
  573. "component": "蜗壳组件",
  574. "enddate": "2025-08-15 00:00:00",
  575. "sa_aftersalesbomid": 2,
  576. "attinfos": [],
  577. "price": 0,
  578. "siteid": "lsa",
  579. "accessorie": "风帽",
  580. "model": "GXC-120V",
  581. "rowindex": 9,
  582. "brand": [],
  583. "typename": "风帽",
  584. "status": "",
  585. "tradefield": [
  586. {
  587. "itemid": 117727,
  588. "rowindex": 4,
  589. "tradefield": "建材家居"
  590. }
  591. ]
  592. }
  593. ],
  594. "parentid": 12
  595. },
  596. {
  597. "plm_bomid": 18,
  598. "bomfullname": "集成灶/排油烟模块/蜗壳组件/排烟电机插头",
  599. "subdep": [],
  600. "isdeep": 1,
  601. "num": "1",
  602. "bomname": "排烟电机插头",
  603. "rowindex": 17,
  604. "parentid": 12
  605. },
  606. {
  607. "plm_bomid": 17,
  608. "bomfullname": "集成灶/排油烟模块/蜗壳组件/排烟电机",
  609. "subdep": [],
  610. "isdeep": 1,
  611. "num": "1",
  612. "bomname": "排烟电机",
  613. "rowindex": 16,
  614. "parentid": 12
  615. }
  616. ],
  617. "isdeep": 0,
  618. "num": "1",
  619. "bomname": "蜗壳组件",
  620. "rowindex": 11,
  621. "parentid": 11
  622. }
  623. ],
  624. "isdeep": 0,
  625. "num": "1",
  626. "bomname": "排油烟模块",
  627. "rowindex": 10,
  628. "parentid": 1
  629. },
  630. {
  631. "plm_bomid": 3,
  632. "bomfullname": "集成灶/顶板组件",
  633. "subdep": [
  634. {
  635. "plm_bomid": 4,
  636. "bomfullname": "集成灶/顶板组件/顶板玻璃",
  637. "subdep": [],
  638. "isdeep": 1,
  639. "num": "1",
  640. "bomname": "顶板玻璃",
  641. "rowindex": 4,
  642. "parentid": 3
  643. },
  644. {
  645. "plm_bomid": 5,
  646. "bomfullname": "集成灶/顶板组件/照明玻璃",
  647. "subdep": [],
  648. "isdeep": 1,
  649. "num": "2",
  650. "bomname": "照明玻璃",
  651. "rowindex": 5,
  652. "parentid": 3
  653. },
  654. {
  655. "plm_bomid": 6,
  656. "bomfullname": "集成灶/顶板组件/前端玻璃",
  657. "subdep": [],
  658. "isdeep": 1,
  659. "num": "3",
  660. "bomname": "前端玻璃",
  661. "rowindex": 6,
  662. "parentid": 3
  663. },
  664. {
  665. "plm_bomid": 7,
  666. "bomfullname": "集成灶/顶板组件/内衬玻璃",
  667. "subdep": [],
  668. "isdeep": 1,
  669. "num": "4",
  670. "bomname": "内衬玻璃",
  671. "rowindex": 7,
  672. "parentid": 3
  673. },
  674. {
  675. "plm_bomid": 8,
  676. "bomfullname": "集成灶/顶板组件/照明灯",
  677. "subdep": [],
  678. "isdeep": 1,
  679. "num": "5",
  680. "bomname": "照明灯",
  681. "rowindex": 8,
  682. "parentid": 3
  683. },
  684. {
  685. "plm_bomid": 9,
  686. "bomfullname": "集成灶/顶板组件/氛围灯",
  687. "subdep": [],
  688. "isdeep": 1,
  689. "num": "7",
  690. "bomname": "氛围灯",
  691. "rowindex": 9,
  692. "parentid": 3
  693. }
  694. ],
  695. "isdeep": 1,
  696. "num": "1",
  697. "bomname": "顶板组件",
  698. "rowindex": 3,
  699. "parentid": 1
  700. },
  701. {
  702. "plm_bomid": 2,
  703. "bomfullname": "集成灶/吸烟腔组件",
  704. "subdep": [],
  705. "isdeep": 1,
  706. "num": "1",
  707. "bomname": "吸烟腔组件",
  708. "rowindex": 2,
  709. "parentid": 1
  710. }
  711. ],
  712. "isdeep": 0,
  713. "num": "2",
  714. "bomname": "集成灶",
  715. "rowindex": 1,
  716. "parentid": 0
  717. }
  718. ]
  719. }
  720. ]);
  721. let active = reactive({
  722. class1: 0,
  723. class2: 0,
  724. class3: 0,
  725. });
  726. function changeClass1(index) {
  727. active.class1 = index;
  728. active.class2 = 0;
  729. active.class3 = 0;
  730. }
  731. // 有bom
  732. function getBomList() {
  733. $Http.basic({
  734. "id": "2025080610425503",
  735. content: {
  736. "sa_aftersalesbomid": content.sa_workorderid,
  737. "sys_enterpriseid": content.sys_enterpriseid,
  738. }
  739. }).then(res => {
  740. console.log("获取bom配件列表", res)
  741. if (res.code == 1) {
  742. // bomList.value = res.data;
  743. bomList.value = processBomData(bomList.value)
  744. console.log("bomList", bomList.value);
  745. } else {
  746. if (res.msg) uni.showToast({
  747. title: res.msg,
  748. icon: 'none'
  749. });
  750. }
  751. })
  752. }
  753. function processBomData(originalData) {
  754. // 1. 提取所有一级分类节点
  755. const topLevelNodes = [];
  756. // 遍历原始数据
  757. originalData.forEach(dataSet => {
  758. dataSet.bom?.forEach(rootNode => {
  759. // 提取根节点下的一级分类
  760. if (rootNode.subdep && rootNode.subdep.length > 0) {
  761. topLevelNodes.push(...rootNode.subdep);
  762. }
  763. });
  764. });
  765. // 2. 递归处理节点
  766. const processNode = (node) => {
  767. node.items = node.items || [];
  768. node.subdep = node.subdep || [];
  769. if (node.items.length == 0 && node.subdep.length == 0) return null;
  770. // 创建新节点副本
  771. const newNode = { ...node };
  772. // 处理子节点
  773. if (node.subdep.length) newNode.subdep = node.subdep.map(subNode => processNode(subNode)).filter(subNode => subNode !== null);
  774. return newNode;
  775. };
  776. // 3. 处理所有一级分类节点
  777. return topLevelNodes.map(node => processNode(node)).filter(node => node !== null);
  778. }
  779. // 无BOM
  780. const keyword = ref('');
  781. function onSearch(e) {
  782. if (content.where.condition == e) return;
  783. content.where.condition = e;
  784. keyword.value = e;
  785. getList(true);
  786. }
  787. function getList(init = false) {
  788. if (isBom.value) return;
  789. if (content.loading) return;
  790. if (init) content.pageNumber = 1;
  791. content.loading = true;
  792. $Http.basic({
  793. "id": "2025080610425103",
  794. content
  795. }).then(res => {
  796. console.log("获取配件列表", res)
  797. content.loading = false;
  798. listBox.value.refreshToComplete();
  799. listBox.value.setHeight();
  800. res.data = res.data.map(item => {
  801. item.imageUrl = item.attinfos.length ? $Http.getSpecifiedImage(item.attinfos[0]) : ''
  802. return item;
  803. });
  804. if (res.code == 1) {
  805. list.value = reactive(res.firstPage ? res.data : list.value.concat(res.data));
  806. content.pageTotal = res.pageTotal;
  807. content.pageNumber = res.pageNumber;
  808. } else {
  809. if (res.msg) uni.showToast({
  810. title: res.msg,
  811. icon: 'none'
  812. });
  813. }
  814. })
  815. }
  816. </script>
  817. <style lang="scss" scoped>
  818. .bom {
  819. width: 100vw;
  820. display: flex;
  821. min-height: 100vh;
  822. .left {
  823. width: 250rpx;
  824. background: #fff;
  825. flex-shrink: 0;
  826. .class1 {
  827. padding: 30rpx 30rpx;
  828. width: 250rpx;
  829. box-sizing: border-box;
  830. background: #FFFFFF;
  831. border-radius: 0rpx 8rpx 0rpx 0rpx;
  832. font-family: PingFang SC, PingFang SC;
  833. font-size: 28rpx;
  834. color: #999999;
  835. }
  836. .class1active {
  837. position: relative;
  838. background: #F7F7FF;
  839. color: #3774F6;
  840. }
  841. .class1active::after {
  842. content: '';
  843. position: absolute;
  844. left: 0;
  845. top: 0;
  846. width: 8rpx;
  847. height: 100%;
  848. background: #3774F6;
  849. }
  850. }
  851. .right {
  852. flex: 1;
  853. }
  854. }
  855. .search-box {
  856. position: relative;
  857. padding: 20rpx;
  858. background: #fff;
  859. .clear {
  860. position: absolute;
  861. display: flex;
  862. align-items: center;
  863. right: 0;
  864. top: 50%;
  865. transform: translateY(-50%);
  866. width: 80rpx;
  867. padding-left: 10rpx;
  868. height: 70rpx;
  869. z-index: 2;
  870. }
  871. }
  872. .footer {
  873. position: fixed;
  874. bottom: 0;
  875. left: 0;
  876. width: 100%;
  877. height: 120rpx;
  878. padding: 10rpx 20rpx;
  879. background: #fff;
  880. box-sizing: border-box;
  881. }
  882. </style>