You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

960 lines
28 KiB

12 months ago
12 months ago
12 months ago
12 months ago
11 months ago
11 months ago
12 months ago
12 months ago
12 months ago
  1. <template>
  2. <div class="mod-config">
  3. <!-- 查询条件 -->
  4. <el-form :inline="true" label-position="top" :model="searchData">
  5. <el-form-item :label="'BU'">
  6. <el-select v-model="searchData.buNo" placeholder="请选择" clearable style="width: 90px">
  7. <el-option
  8. v-for = "i in buList"
  9. :key = "i.buNo"
  10. :label = "i.buDesc"
  11. :value = "i.buNo">
  12. </el-option>
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item :label="'物料编码'">
  16. <el-input v-model="searchData.partNo" clearable style="width: 120px"></el-input>
  17. </el-form-item>
  18. <el-form-item :label="'物料名称'">
  19. <el-input v-model="searchData.partDesc" clearable style="width: 300px"></el-input>
  20. </el-form-item>
  21. <el-form-item prop="partType2" label="零件类型">
  22. <el-select v-model="searchData.partType2" clearable style="width: 100px">
  23. <el-option label="成品" value="Manufactured"></el-option>
  24. <el-option label="半成品" value="Manufactured Recipe"></el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item :label="'BOM版本号'">
  28. <el-input v-model="searchData.engChgLevel" style="width: 70px"></el-input>
  29. </el-form-item>
  30. <el-form-item :label="' '">
  31. <el-button v-if="!authSearch" @click="getDataList()">查询</el-button>
  32. <download-excel
  33. :fields="fields()"
  34. :data="exportData"
  35. type="xls"
  36. :name="exportName"
  37. :header="exportHeader"
  38. :footer="exportFooter"
  39. :fetch="createExportData"
  40. :before-generate="startDownload"
  41. :before-finish="finishDownload"
  42. worksheet="导出信息"
  43. class="el-button el-button--primary el-button--medium">
  44. {{ "导出" }}
  45. </download-excel>
  46. </el-form-item>
  47. </el-form>
  48. <!-- bom列表 -->
  49. <el-table
  50. :height="height"
  51. :data="dataList"
  52. border
  53. ref="bomHeaderTable"
  54. @row-click="headerClickRow"
  55. @current-change="changeCurrentRow"
  56. v-loading="queryLoading"
  57. style="width: 100%">
  58. <el-table-column
  59. v-for="(item,index) in columnList" :key="index"
  60. :sortable="item.columnSortable"
  61. :prop="item.columnProp"
  62. :header-align="item.headerAlign"
  63. :show-overflow-tooltip="item.showOverflowTooltip"
  64. :align="item.align"
  65. :fixed="item.fixed === ''?false:item.fixed"
  66. :min-width="item.columnWidth"
  67. :label="item.columnLabel">
  68. <template slot-scope="scope">
  69. <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
  70. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column
  74. fixed="right"
  75. header-align="center"
  76. align="center"
  77. width="80"
  78. label="操作">
  79. <template slot-scope="scope">
  80. <el-link style="cursor: pointer" v-loading="queryLoading" @click="copyBomModal(scope.row)">BOM复制</el-link>
  81. </template>
  82. </el-table-column>
  83. </el-table>
  84. <!-- 分页插件 -->
  85. <el-pagination style="margin-top: 0px"
  86. @size-change="sizeChangeHandle"
  87. @current-change="currentChangeHandle"
  88. :current-page="pageIndex"
  89. :page-sizes="[20, 50, 100, 200, 500]"
  90. :page-size="pageSize"
  91. :total="totalPage"
  92. layout="total, sizes, prev, pager, next, jumper">
  93. </el-pagination>
  94. <!-- 页签 -->
  95. <el-tabs v-model="activeTable" style="width: 100%" :style="{height: secondHeight + 50 + 'px'}" type="border-card" @tab-click="tabClick" class="customer-tab">
  96. <!-- Graphical Structure页签 -->
  97. <el-tab-pane label="Graphical Structure" name="GraphicalStructure">
  98. <el-row>
  99. <el-col :style="{width: leftWidth + 'px',height: secondHeight + 'px'}" class="down-tree">
  100. <el-tree
  101. :data="treeData"
  102. :props="defaultProps"
  103. :default-expand-all="true"
  104. :expand-on-click-node="false"
  105. node-key="id"
  106. highlight-current
  107. @node-click="handleNodeClick"
  108. ref="tree">
  109. </el-tree>
  110. </el-col>
  111. <el-col :style="{width: rightWidth + 'px',height: secondHeight + 'px'}" style="margin-left: 10px">
  112. <el-table
  113. :height="secondHeight"
  114. :data="componentPartList"
  115. border
  116. style="width: 100%">
  117. <el-table-column
  118. v-for="(item,index) in componentPartColumnList" :key="index"
  119. :sortable="item.columnSortable"
  120. :prop="item.columnProp"
  121. :header-align="item.headerAlign"
  122. :show-overflow-tooltip="item.showOverflowTooltip"
  123. :align="item.align"
  124. :fixed="item.fixed==''?false:item.fixed"
  125. :min-width="item.columnWidth"
  126. :label="item.columnLabel">
  127. <template slot-scope="scope">
  128. <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
  129. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  130. </template>
  131. </el-table-column>
  132. </el-table>
  133. </el-col>
  134. </el-row>
  135. </el-tab-pane>
  136. </el-tabs>
  137. <!-- chooseList模态框 -->
  138. <ChooseList ref="baseList" @getBaseData="getBaseData"></ChooseList>
  139. <copy-bom-modal ref="copyBomModal" @refreshPageTables="getDataList"></copy-bom-modal>
  140. </div>
  141. </template>
  142. <script>
  143. import {
  144. bomSearchHeader, // bom列表查询
  145. getAlternativeTree, // 查询bom替代树形
  146. getComponentPartList, // 查询子物料
  147. saveCopyBomInfo, // 新增数据到临时表
  148. } from '@/api/part/bomSearch3.js'
  149. import {getSiteAndBuByUserName2} from "@/api/qc/qc.js"
  150. import ChooseList from '@/views/modules/common/Chooselist_eam'
  151. import copyBomModal from "./copy_bom_modal.vue"
  152. export default {
  153. components: {
  154. copyBomModal,
  155. ChooseList
  156. },
  157. watch: {
  158. searchData: {
  159. deep: true,
  160. handler: function (newV, oldV) {
  161. this.searchData.partNo = this.searchData.partNo.toUpperCase()
  162. }
  163. }
  164. },
  165. data () {
  166. return {
  167. // 导出
  168. exportData: [],
  169. exportName: 'BOM多级查询' + this.dayjs().format('YYYYMMDDHHmmss'),
  170. exportHeader: ['BOM多级查询'],
  171. exportFooter: [],
  172. resultList: [],
  173. buList: [],
  174. menuId: this.$route.meta.menuId,
  175. // ======== 行高 ========
  176. height: 200,
  177. secondHeight: 200,
  178. leftWidth: 300,
  179. rightWidth: '',
  180. // ======== 分页 ========
  181. pageIndex: 1,
  182. pageSize: 50,
  183. totalPage: 0,
  184. // 条件查询
  185. searchData: {
  186. site: '',
  187. buNo: '',
  188. userName: this.$store.state.user.name,
  189. partNo: '',
  190. partDesc: '',
  191. bomType: '',
  192. engChgLevel: '',
  193. partType2: '',
  194. page: 1,
  195. limit: 10
  196. },
  197. // loading
  198. queryLoading: false,
  199. // 初始页签
  200. activeTable: 'GraphicalStructure',
  201. // ======== 数据对象 ========
  202. alternativeData: {
  203. site: '',
  204. partNo: '',
  205. partDesc: '',
  206. bomType: '',
  207. engChgLevel: '',
  208. alternativeNo: '',
  209. alternativeDescription: '',
  210. minLotQty: '',
  211. noteText: '',
  212. status: '',
  213. },
  214. // ======== 选中的当前行数据 ========
  215. headerCurrentRow: {},
  216. defaultProps: {
  217. children: "list",
  218. label: "id",
  219. },
  220. // ======== 数据列表 ========
  221. dataList: [],
  222. treeData: [],
  223. componentPartList: [],
  224. // ======== 列表表头 ========
  225. columnList: [
  226. {
  227. userId: this.$store.state.user.name,
  228. functionId: 601002002,
  229. serialNumber: '601002002Table1PartNo',
  230. tableId: '601002002Table1',
  231. tableName: 'BOMHeader表',
  232. columnProp: 'partNo',
  233. headerAlign: 'center',
  234. align: 'center',
  235. columnLabel: '物料编码',
  236. columnHidden: false,
  237. columnImage: false,
  238. columnSortable: false,
  239. sortLv: 0,
  240. status: true,
  241. fixed: '',
  242. columnWidth: 120
  243. },
  244. {
  245. userId: this.$store.state.user.name,
  246. functionId: 601002002,
  247. serialNumber: '601002002Table1PartDesc',
  248. tableId: '601002002Table1',
  249. tableName: 'BOMHeader表',
  250. columnProp: 'partDesc',
  251. headerAlign: 'center',
  252. align: 'left',
  253. columnLabel: '物料名称',
  254. columnHidden: false,
  255. columnImage: false,
  256. columnSortable: false,
  257. sortLv: 0,
  258. status: true,
  259. fixed: '',
  260. columnWidth: 300
  261. },
  262. {
  263. userId: this.$store.state.user.name,
  264. functionId: 601002002,
  265. serialNumber: '601002002Table1PartType2Desc',
  266. tableId: '601002002Table1',
  267. tableName: 'BOMHeader表',
  268. columnProp: 'partType2Desc',
  269. headerAlign: 'center',
  270. align: 'left',
  271. columnLabel: '零件类型',
  272. columnHidden: false,
  273. columnImage: false,
  274. columnSortable: false,
  275. sortLv: 0,
  276. status: true,
  277. fixed: '',
  278. columnWidth: 120
  279. },
  280. {
  281. userId: this.$store.state.user.name,
  282. functionId: 601002002,
  283. serialNumber: '601002002Table1BomType',
  284. tableId: '601002002Table1',
  285. tableName: 'BOMHeader表',
  286. columnProp: 'bomType',
  287. headerAlign: 'center',
  288. align: 'center',
  289. columnLabel: '制造类型',
  290. columnHidden: false,
  291. columnImage: false,
  292. columnSortable: false,
  293. sortLv: 0,
  294. status: true,
  295. fixed: '',
  296. columnWidth: 100
  297. },
  298. {
  299. userId: this.$store.state.user.name,
  300. functionId: 601002002,
  301. serialNumber: '601002002Table1EngChgLevel',
  302. tableId: '601002002Table1',
  303. tableName: 'BOMHeader表',
  304. columnProp: 'engChgLevel',
  305. headerAlign: 'center',
  306. align: 'right',
  307. columnLabel: 'BOM版本号',
  308. columnHidden: false,
  309. columnImage: false,
  310. columnSortable: false,
  311. sortLv: 0,
  312. status: true,
  313. fixed: '',
  314. columnWidth: 100
  315. },
  316. {
  317. userId: this.$store.state.user.name,
  318. functionId: 601002002,
  319. serialNumber: '601002002Table1engRevision',
  320. tableId: '601002002Table1',
  321. tableName: 'BOMHeader表',
  322. columnProp: 'engRevision',
  323. headerAlign: 'center',
  324. align: 'center',
  325. columnLabel: '工程版本号',
  326. columnHidden: false,
  327. columnImage: false,
  328. columnSortable: false,
  329. sortLv: 0,
  330. status: true,
  331. fixed: '',
  332. columnWidth: 100
  333. },
  334. {
  335. userId: this.$store.state.user.name,
  336. functionId: 601002002,
  337. serialNumber: '601002002Table1NetWeight',
  338. tableId: '601002002Table1',
  339. tableName: 'BOMHeader表',
  340. columnProp: 'netWeight',
  341. headerAlign: 'center',
  342. align: 'right',
  343. columnLabel: '净重',
  344. columnHidden: false,
  345. columnImage: false,
  346. columnSortable: false,
  347. sortLv: 0,
  348. status: true,
  349. fixed: '',
  350. columnWidth: 100
  351. },
  352. {
  353. userId: this.$store.state.user.name,
  354. functionId: 601002002,
  355. serialNumber: '601002002Table1EffPhaseInDate',
  356. tableId: '601002002Table1',
  357. tableName: 'BOMHeader表',
  358. columnProp: 'effPhaseInDate',
  359. headerAlign: 'center',
  360. align: 'center',
  361. columnLabel: '生效日期',
  362. columnHidden: false,
  363. columnImage: false,
  364. columnSortable: false,
  365. sortLv: 0,
  366. status: true,
  367. fixed: '',
  368. columnWidth: 130
  369. },
  370. {
  371. userId: this.$store.state.user.name,
  372. functionId: 601002002,
  373. serialNumber: '601002002Table1EffPhaseOutDate',
  374. tableId: '601002002Table1',
  375. tableName: 'BOMHeader表',
  376. columnProp: 'effPhaseOutDate',
  377. headerAlign: 'center',
  378. align: 'center',
  379. columnLabel: '失效日期',
  380. columnHidden: false,
  381. columnImage: false,
  382. columnSortable: false,
  383. sortLv: 0,
  384. status: true,
  385. fixed: '',
  386. columnWidth: 130
  387. },
  388. {
  389. userId: this.$store.state.user.name,
  390. functionId: 601002002,
  391. serialNumber: '601002002Table1CreateDate',
  392. tableId: '601002002Table1',
  393. tableName: 'BOMHeader表',
  394. columnProp: 'createDate',
  395. headerAlign: 'center',
  396. align: 'center',
  397. columnLabel: '创建时间',
  398. columnHidden: false,
  399. columnImage: false,
  400. columnSortable: false,
  401. sortLv: 0,
  402. status: true,
  403. fixed: '',
  404. columnWidth: 170
  405. },
  406. {
  407. userId: this.$store.state.user.name,
  408. functionId: 601002002,
  409. serialNumber: '601002002Table1CreateBy',
  410. tableId: '601002002Table1',
  411. tableName: 'BOMHeader表',
  412. columnProp: 'createByDesc',
  413. headerAlign: 'center',
  414. align: 'center',
  415. columnLabel: '创建人',
  416. columnHidden: false,
  417. columnImage: false,
  418. columnSortable: false,
  419. sortLv: 0,
  420. status: true,
  421. fixed: '',
  422. columnWidth: 100
  423. },
  424. {
  425. userId: this.$store.state.user.name,
  426. functionId: 601002002,
  427. serialNumber: '601002002Table1UpdateDate',
  428. tableId: '601002002Table1',
  429. tableName: 'BOMHeader表',
  430. columnProp: 'updateDate',
  431. headerAlign: 'center',
  432. align: 'center',
  433. columnLabel: '更新时间',
  434. columnHidden: false,
  435. columnImage: false,
  436. columnSortable: false,
  437. sortLv: 0,
  438. status: true,
  439. fixed: '',
  440. columnWidth: 170
  441. },
  442. {
  443. userId: this.$store.state.user.name,
  444. functionId: 601002002,
  445. serialNumber: '601002002Table1UpdateBy',
  446. tableId: '601002002Table1',
  447. tableName: 'BOMHeader表',
  448. columnProp: 'updateByDesc',
  449. headerAlign: 'center',
  450. align: 'center',
  451. columnLabel: '更新人',
  452. columnHidden: false,
  453. columnImage: false,
  454. columnSortable: false,
  455. sortLv: 0,
  456. status: true,
  457. fixed: '',
  458. columnWidth: 100
  459. }
  460. ],
  461. componentPartColumnList: [
  462. {
  463. userId: this.$store.state.user.name,
  464. functionId: 601002002,
  465. serialNumber: '601002002Table2LineSequence',
  466. tableId: '601002002Table2',
  467. tableName: 'BOMComponent表',
  468. columnProp: 'lineSequence',
  469. headerAlign: 'center',
  470. align: 'center',
  471. columnLabel: '序号',
  472. columnHidden: false,
  473. columnImage: false,
  474. columnSortable: false,
  475. sortLv: 0,
  476. status: true,
  477. fixed: '',
  478. columnWidth: 50
  479. },
  480. {
  481. userId: this.$store.state.user.name,
  482. functionId: 601002002,
  483. serialNumber: '601002002Table2ComponentPart',
  484. tableId: '601002002Table2',
  485. tableName: 'BOMComponent表',
  486. columnProp: 'componentPart',
  487. headerAlign: 'center',
  488. align: 'center',
  489. columnLabel: '物料编码',
  490. columnHidden: false,
  491. columnImage: false,
  492. columnSortable: false,
  493. sortLv: 0,
  494. status: true,
  495. fixed: '',
  496. columnWidth: 120
  497. },
  498. {
  499. userId: this.$store.state.user.name,
  500. functionId: 601002002,
  501. serialNumber: '601002002Table2ComponentPartDesc',
  502. tableId: '601002002Table2',
  503. tableName: 'BOMComponent表',
  504. columnProp: 'componentPartDesc',
  505. headerAlign: 'center',
  506. align: 'left',
  507. columnLabel: '物料名称',
  508. columnHidden: false,
  509. columnImage: false,
  510. columnSortable: false,
  511. sortLv: 0,
  512. status: true,
  513. fixed: '',
  514. columnWidth: 300
  515. },
  516. {
  517. userId: this.$store.state.user.name,
  518. functionId: 601002002,
  519. serialNumber: '601002002Table2QtyPerAssembly',
  520. tableId: '601002002Table2',
  521. tableName: 'BOMComponent表',
  522. columnProp: 'qtyPerAssembly',
  523. headerAlign: 'center',
  524. align: 'right',
  525. columnLabel: '单位用量',
  526. columnHidden: false,
  527. columnImage: false,
  528. columnSortable: false,
  529. sortLv: 0,
  530. status: true,
  531. fixed: '',
  532. columnWidth: 80
  533. },
  534. {
  535. userId: this.$store.state.user.name,
  536. functionId: 601002002,
  537. serialNumber: '601002002Table2ComponentScrap',
  538. tableId: '601002002Table2',
  539. tableName: 'BOMComponent表',
  540. columnProp: 'componentScrap',
  541. headerAlign: 'center',
  542. align: 'right',
  543. columnLabel: '调机量',
  544. columnHidden: false,
  545. columnImage: false,
  546. columnSortable: false,
  547. sortLv: 0,
  548. status: true,
  549. fixed: '',
  550. columnWidth: 80
  551. },
  552. {
  553. userId: this.$store.state.user.name,
  554. functionId: 601002002,
  555. serialNumber: '601002002Table2ShrinkageFactor',
  556. tableId: '601002002Table2',
  557. tableName: 'BOMComponent表',
  558. columnProp: 'shrinkageFactor',
  559. headerAlign: 'center',
  560. align: 'right',
  561. columnLabel: '损耗率',
  562. columnHidden: false,
  563. columnImage: false,
  564. columnSortable: false,
  565. sortLv: 0,
  566. status: true,
  567. fixed: '',
  568. columnWidth: 80
  569. },
  570. {
  571. userId: this.$store.state.user.name,
  572. functionId: 601002002,
  573. serialNumber: '601002002Table2ConsumptionItem',
  574. tableId: '601002002Table2',
  575. tableName: 'BOMComponent表',
  576. columnProp: 'consumptionItem',
  577. headerAlign: 'center',
  578. align: 'center',
  579. columnLabel: '消耗项目',
  580. columnHidden: false,
  581. columnImage: false,
  582. columnSortable: false,
  583. sortLv: 0,
  584. status: true,
  585. fixed: '',
  586. columnWidth: 80
  587. },
  588. {
  589. userId: this.$store.state.user.name,
  590. functionId: 601002002,
  591. serialNumber: '601002002Table2PrintUnitName',
  592. tableId: '601002002Table2',
  593. tableName: 'BOMComponent表',
  594. columnProp: 'printUnitName',
  595. headerAlign: 'center',
  596. align: 'center',
  597. columnLabel: '物料单位',
  598. columnHidden: false,
  599. columnImage: false,
  600. columnSortable: false,
  601. sortLv: 0,
  602. status: true,
  603. fixed: '',
  604. columnWidth: 60
  605. },
  606. {
  607. userId: this.$store.state.user.name,
  608. functionId: 601002002,
  609. serialNumber: '601002002Table2IssueType',
  610. tableId: '601002002Table2',
  611. tableName: 'BOMComponent表',
  612. columnProp: 'issueType',
  613. headerAlign: 'center',
  614. align: 'center',
  615. columnLabel: '生产属性',
  616. columnHidden: false,
  617. columnImage: false,
  618. columnSortable: false,
  619. sortLv: 0,
  620. status: true,
  621. fixed: '',
  622. columnWidth: 140
  623. },
  624. {
  625. userId: this.$store.state.user.name,
  626. functionId: 601002002,
  627. serialNumber: '601002002Table2OperationNo',
  628. tableId: '601002002Table2',
  629. tableName: 'BOMComponent表',
  630. columnProp: 'operationNo',
  631. headerAlign: 'center',
  632. align: 'left',
  633. columnLabel: '工序编码',
  634. columnHidden: false,
  635. columnImage: false,
  636. columnSortable: false,
  637. sortLv: 0,
  638. status: true,
  639. fixed: '',
  640. columnWidth: 80
  641. },
  642. {
  643. userId: this.$store.state.user.name,
  644. functionId: 601002002,
  645. serialNumber: '601002002Table2OperationName',
  646. tableId: '601002002Table2',
  647. tableName: 'BOMComponent表',
  648. columnProp: 'operationName',
  649. headerAlign: 'center',
  650. align: 'left',
  651. columnLabel: '工序名称',
  652. columnHidden: false,
  653. columnImage: false,
  654. columnSortable: false,
  655. sortLv: 0,
  656. status: true,
  657. fixed: '',
  658. columnWidth: 120
  659. },
  660. {
  661. userId: this.$store.state.user.name,
  662. functionId: 601002002,
  663. serialNumber: '601002002Table2IssueToLoc',
  664. tableId: '601002002Table2',
  665. tableName: 'BOMComponent表',
  666. columnProp: 'issueToLocName',
  667. headerAlign: 'center',
  668. align: 'center',
  669. columnLabel: '发料库位',
  670. columnHidden: false,
  671. columnImage: false,
  672. columnSortable: false,
  673. sortLv: 0,
  674. status: true,
  675. fixed: '',
  676. columnWidth: 80
  677. },
  678. {
  679. userId: this.$store.state.user.name,
  680. functionId: 601002002,
  681. serialNumber: '601002002Table2NoteText',
  682. tableId: '601002002Table2',
  683. tableName: 'BOMComponent表',
  684. columnProp: 'noteText',
  685. headerAlign: 'center',
  686. align: 'left',
  687. columnLabel: '备注',
  688. columnHidden: false,
  689. columnImage: false,
  690. columnSortable: false,
  691. sortLv: 0,
  692. status: true,
  693. fixed: '',
  694. columnWidth: 150
  695. },
  696. ],
  697. // ======== 必填规则 ========
  698. // ======== 复选数据集 ========
  699. // ======== 模态框开关控制 ========
  700. authSearch: false,
  701. }
  702. },
  703. mounted () {
  704. this.$nextTick(() => {
  705. this.height = window.innerHeight / 2 - 140
  706. /*第二个表格高度的动态调整*/
  707. this.secondHeight = window.innerHeight - this.height - 220
  708. this.rightWidth = window.innerWidth - this.leftWidth - 275
  709. })
  710. },
  711. created () {
  712. // 按钮控制
  713. this.getButtonAuthData()
  714. // 获取用户的 site 和 bu
  715. this.getSiteAndBuByUserName2()
  716. if (!this.authSearch) {
  717. // 获取数据列表
  718. this.getDataList()
  719. }
  720. },
  721. methods: {
  722. // ======== 分页相关方法 ========
  723. // 每页数
  724. sizeChangeHandle (val) {
  725. this.pageSize = val
  726. this.pageIndex = 1
  727. this.getDataList()
  728. },
  729. // 当前页
  730. currentChangeHandle (val) {
  731. this.pageIndex = val
  732. this.getDataList()
  733. },
  734. // 获取用户的bu
  735. getSiteAndBuByUserName2 () {
  736. let tempData = {
  737. username: this.$store.state.user.name,
  738. }
  739. getSiteAndBuByUserName2(tempData).then(({data}) => {
  740. if (data.code === 0) {
  741. this.buList = data.rows
  742. }
  743. })
  744. },
  745. // ======== 列表数据操作方法 ========
  746. // 获取数据列表
  747. getDataList () {
  748. this.searchData.limit = this.pageSize
  749. this.searchData.page = this.pageIndex
  750. this.queryLoading = true
  751. bomSearchHeader(this.searchData).then(({data}) => {
  752. if (data.code === 0) {
  753. this.dataList = data.page.list
  754. this.pageIndex = data.page.currPage
  755. this.pageSize = data.page.pageSize
  756. this.totalPage = data.page.totalCount
  757. // 判断是否全部存在数据
  758. if (this.dataList.length > 0) {
  759. // 设置选中行
  760. this.$refs.bomHeaderTable.setCurrentRow(this.dataList[0])
  761. this.headerClickRow(this.dataList[0])
  762. } else {
  763. this.headerCurrentRow = {}
  764. }
  765. // 加载当前的页签的table
  766. this.refreshCurrentTabTable()
  767. }
  768. this.queryLoading = false
  769. })
  770. },
  771. // 单机选中信息
  772. headerClickRow (row) {
  773. this.$refs.bomHeaderTable.toggleRowSelection(row)
  774. this.headerCurrentRow = JSON.parse(JSON.stringify(row))
  775. },
  776. // 树节点单机事件
  777. handleNodeClick (e) {
  778. // 查询替代子物料
  779. getComponentPartList(e).then(({data}) => {
  780. if (data && data.code === 0) {
  781. this.componentPartList = data.rows
  782. } else {
  783. this.componentPartList = []
  784. }
  785. })
  786. },
  787. // copyBom
  788. copyBomModal (row) {
  789. this.queryLoading = true
  790. row.createBy = this.$store.state.user.name
  791. // 新增数据到临时表
  792. saveCopyBomInfo(row).then(({data}) => {
  793. if (data && data.code === 0) {
  794. this.$nextTick(() => {
  795. this.$refs.copyBomModal.init(row)
  796. })
  797. this.queryLoading = false
  798. } else {
  799. this.queryLoading = false
  800. this.$alert(data.msg, '错误', {
  801. confirmButtonText: '确定'
  802. })
  803. }
  804. }).catch(() => {
  805. this.queryLoading = false
  806. })
  807. },
  808. // ======== 页签切换相关方法 ========
  809. // 列表表格选择替换
  810. tabClick (tab, event) {
  811. // 刷新列表数据
  812. this.refreshCurrentTabTable()
  813. },
  814. // 当前值发生变化的时候修改
  815. changeCurrentRow (row, oldRow) {
  816. // 判断是否是获取焦点的事件
  817. if (row) {
  818. this.headerCurrentRow = JSON.parse(JSON.stringify(row))
  819. //刷新当前页表
  820. this.refreshCurrentTabTable()
  821. this.componentPartList = []
  822. }
  823. },
  824. // 刷新页签的table数据
  825. refreshCurrentTabTable () {
  826. if (this.activeTable === 'GraphicalStructure') {
  827. // 获取bom替代树形
  828. this.getAlternativeTree()
  829. }
  830. },
  831. // 获取bom替代树形
  832. getAlternativeTree () {
  833. getAlternativeTree(this.headerCurrentRow).then(({data}) => {
  834. if (data && data.code === 0) {
  835. this.treeData = data.rows
  836. if (this.treeData.length > 0) {
  837. this.$nextTick(() => {
  838. this.$refs.tree.setCurrentKey(this.treeData[0].id);
  839. this.handleNodeClick(this.treeData[0])
  840. })
  841. }
  842. } else {
  843. this.$message.warning(data.msg)
  844. }
  845. })
  846. },
  847. // ======== chooseList相关方法 ========
  848. // 获取基础数据列表S
  849. getBaseList (val, type) {
  850. this.tagNo = val
  851. this.$nextTick(() => {
  852. let strVal = ''
  853. if (val === 117) {
  854. strVal = this.componentData.issueToLoc
  855. }
  856. this.$refs.baseList.init(val, strVal)
  857. })
  858. },
  859. // 列表方法的回调
  860. getBaseData (val) {
  861. if (this.tagNo === 117) {
  862. this.componentData.issueToLoc = val.location_id
  863. this.componentData.issueToLocName = val.location_name
  864. }
  865. },
  866. //获取按钮的权限数据
  867. getButtonAuthData () {
  868. let searchFlag = this.isAuth(this.menuId+":search")
  869. //处理页面的权限数据
  870. this.authSearch = !searchFlag
  871. },
  872. // ======== 导出相关方法 ========
  873. // 导出excel
  874. async createExportData () {
  875. this.searchData.limit = -1
  876. this.searchData.page = 1
  877. await bomSearchHeader(this.searchData).then(({data}) => {
  878. this.resultList = data.page.list
  879. })
  880. return this.resultList
  881. },
  882. startDownload () {},
  883. finishDownload () {},
  884. fields () {
  885. let json = '{'
  886. this.columnList.forEach((item, index) => {
  887. if (index == this.columnList.length - 1) {
  888. json += '"' + item.columnLabel + '"' + ':' + '"' + item.columnProp + '"'
  889. } else {
  890. json += '"' + item.columnLabel + '"' + ':' + '"' + item.columnProp + '"' + ','
  891. }
  892. })
  893. json += '}'
  894. let s = eval('(' + json + ')')
  895. return s
  896. },
  897. }
  898. }
  899. </script>
  900. <style scoped lang="scss">
  901. .el-table /deep/ .cell{
  902. height: auto;
  903. line-height: 1.5;
  904. }
  905. .down-tree{
  906. //height: 470px;
  907. display: block;
  908. overflow-y: scroll;
  909. }
  910. /deep/ .el-tabs--border-card>.el-tabs__content{
  911. padding: 5px;
  912. }
  913. </style>