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.

1379 lines
41 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <div class="mod-config">
  3. <el-form :inline="true" label-position="top" :model="searchData">
  4. <el-form-item label="Customer">
  5. <el-input v-model="searchData.customer" clearable style="width: 120px"></el-input>
  6. </el-form-item>
  7. <el-form-item label="Buyer">
  8. <el-input v-model="searchData.buyer" clearable style="width: 120px"></el-input>
  9. </el-form-item>
  10. <el-form-item label="PO No">
  11. <el-input v-model="searchData.poNo" clearable style="width: 140px"></el-input>
  12. </el-form-item>
  13. <el-form-item label="SKU">
  14. <el-input v-model="searchData.sku" clearable style="width: 120px"></el-input>
  15. </el-form-item>
  16. <el-form-item label="Status">
  17. <el-select v-model="searchData.status" placeholder="请选择" style="width:100px" clearable>
  18. <el-option label="全部" value=""></el-option>
  19. <el-option label="已下达" value="已下达"></el-option>
  20. <el-option label="已取消" value="已取消"></el-option>
  21. </el-select>
  22. </el-form-item>
  23. </el-form>
  24. <el-form :inline="true" label-position="top" style="margin-top:10px ">
  25. <el-form-item>
  26. <el-button type="primary" @click="getDataList()" v-if="!editMode">查询</el-button>
  27. <el-button type="primary" style="margin-left: 2px" @click="toggleEditMode">
  28. {{ editMode ? '确定' : '编辑' }}
  29. </el-button>
  30. </el-form-item>
  31. </el-form>
  32. <el-table
  33. ref="poTable"
  34. :height="height"
  35. :data="masterRows"
  36. border
  37. highlight-current-row
  38. style="width: 100%;"
  39. @current-change="onTableCurrentChange">
  40. <el-table-column
  41. v-for="(item, index) in visibleColumns"
  42. :key="item.serialNumber || index"
  43. :sortable="item.columnSortable"
  44. :prop="item.columnProp"
  45. :header-align="item.headerAlign"
  46. :show-overflow-tooltip="item.showOverflowTooltip && (!editMode || !item.editAble)"
  47. :align="item.align"
  48. :fixed="item.fixed === '' ? false : item.fixed"
  49. :min-width="item.columnWidth"
  50. :label="item.columnLabel">
  51. <template slot-scope="scope">
  52. <template v-if="editMode && item.editAble && item.columnProp==='supplierName'">
  53. <el-select
  54. v-model="rowSupplierNo[scope.row.id]"
  55. size="mini"
  56. style="width: 100%"
  57. clearable
  58. filterable
  59. placeholder="请选择供应商"
  60. @change="(val) => handleSupplierChange(scope.row, val)">
  61. <el-option
  62. v-for="opt in supplierOptions"
  63. :key="String(opt.value)"
  64. :label="opt.label"
  65. :value="opt.value">
  66. </el-option>
  67. </el-select>
  68. </template>
  69. <template v-else-if="editMode && item.editAble && item.columnProp==='partNo'">
  70. <el-select
  71. v-model="rowPartNo[scope.row.id]"
  72. size="mini"
  73. style="width: 100%"
  74. clearable
  75. filterable
  76. placeholder="请选择物料"
  77. @change="(val) => handlePartNoChange(scope.row, val)">
  78. <el-option
  79. v-for="opt in poPartNoOptions"
  80. :key="String(opt.value)"
  81. :label="opt.label"
  82. :value="opt.value">
  83. </el-option>
  84. </el-select>
  85. </template>
  86. <template v-else-if="editMode && item.editAble">
  87. <!-- 下拉框 -->
  88. <el-select
  89. v-if="item.editType === 'select'"
  90. v-model="scope.row[item.columnProp]"
  91. size="mini"
  92. style="width: 100%"
  93. clearable
  94. @change="onCellChange(scope.row)">
  95. <el-option
  96. v-for="opt in getSelectOptionsForColumn(item)"
  97. :key="String(opt.value)"
  98. :label="opt.label"
  99. :value="opt.value">
  100. </el-option>
  101. </el-select>
  102. <!-- 数字输入框 -->
  103. <el-input
  104. v-else-if="item.editType === 'num'"
  105. v-model="scope.row[item.columnProp]"
  106. type="number"
  107. size="mini"
  108. @change="onCellChange(scope.row)">
  109. </el-input>
  110. <!-- 时间控件 -->
  111. <el-date-picker
  112. v-else-if="item.editType === 'date'"
  113. v-model="scope.row[item.columnProp]"
  114. type="date"
  115. size="mini"
  116. style="width: 100%"
  117. value-format="yyyy-MM-dd"
  118. placeholder="选择日期"
  119. @change="onCellChange(scope.row)">
  120. </el-date-picker>
  121. <el-date-picker
  122. v-else-if="item.editType === 'datetime'"
  123. v-model="scope.row[item.columnProp]"
  124. type="datetime"
  125. size="mini"
  126. style="width: 100%"
  127. value-format="yyyy-MM-dd HH:mm:ss"
  128. placeholder="选择日期时间"
  129. @change="onCellChange(scope.row)">
  130. </el-date-picker>
  131. <!-- 普通文本输入框 -->
  132. <el-input
  133. v-else
  134. v-model="scope.row[item.columnProp]"
  135. size="mini"
  136. @change="onCellChange(scope.row)">
  137. </el-input>
  138. </template>
  139. <span v-else>{{ scope.row[item.columnProp] }}</span>
  140. </template>
  141. </el-table-column>
  142. </el-table>
  143. <el-pagination
  144. @size-change="sizeChangeHandle"
  145. @current-change="currentChangeHandle"
  146. :current-page="pageIndex"
  147. :page-sizes="[20, 50, 100, 200, 500]"
  148. :page-size="pageSize"
  149. :total="totalPage"
  150. layout="total, sizes, prev, pager, next, jumper">
  151. </el-pagination>
  152. </div>
  153. </template>
  154. <script>
  155. import { searchPoDetailPage, batchUpdatePoDetail } from '@/api/order/poOrder.js'
  156. import { getPartList } from '@/api/part/partInfo.js'
  157. import { checkSrmSupplierList } from '@/api/srm/srmSupplier.js'
  158. export default {
  159. name: 'PoOrder',
  160. data () {
  161. return {
  162. masterRows: [],
  163. /**
  164. * 需要单独写编辑 UI columnProp 填在这里才会走模板里自定义分支不在此数组的仍用默认 select/num/text - rqrq
  165. * 示例['mPlanner', 'comments']
  166. */
  167. rowPartNo: {}, //存储每行选中的物料编号
  168. rowSupplierNo: {}, //存储每行选中的供应商编号
  169. poPartNoOptions: [],
  170. supplierOptions: [],
  171. customEditColumnProps: [],
  172. currentRow: null,
  173. // 各列下拉:select 列通过 selectOptionsKey 指向此处;也可在列定义里写 selectOptions 数组 - rqrq
  174. columnSelectOptions: {
  175. poStatusOptions: [
  176. { label: '已下达', value: '已下达' },
  177. { label: '已取消', value: '已取消' }
  178. ],
  179. poPartNoOptions: [],
  180. transportOptions: [
  181. { label: '海运 SEA', value: 'SEA' },
  182. { label: '空运 AIR', value: 'AIR' },
  183. { label: '陆运 ROAD', value: 'ROAD' }
  184. ],
  185. yesNoOptions: [
  186. { label: 'Y', value: 'Y' },
  187. { label: 'N', value: 'N' }
  188. ]
  189. },
  190. searchData: {
  191. site: this.$store.state.user.site,
  192. customer: '',
  193. buyer: '',
  194. poNo: '',
  195. sku: '',
  196. status: ''
  197. },
  198. height: 200,
  199. pageIndex: 1,
  200. pageSize: 20,
  201. totalPage: 0,
  202. dataList: [],
  203. editMode: false,
  204. columnList: [
  205. {
  206. userId: this.$store.state.user.name,
  207. functionId: 812003,
  208. serialNumber: '812003Table1Customer',
  209. tableId: '812003Table1',
  210. tableName: 'PO Order',
  211. columnProp: 'customer',
  212. headerAlign: 'center',
  213. align: 'center',
  214. columnLabel: 'Customer',
  215. columnHidden: false,
  216. columnImage: false,
  217. columnSortable: false,
  218. sortLv: 0,
  219. status: true,
  220. fixed: '',
  221. columnWidth: 100,
  222. showOverflowTooltip: true,
  223. editAble: false,
  224. editType: 'text',
  225. selectOptionsKey: '',
  226. selectOptions: null
  227. },
  228. {
  229. userId: this.$store.state.user.name,
  230. functionId: 812003,
  231. serialNumber: '812003Table1Buyer',
  232. tableId: '812003Table1',
  233. tableName: 'PO Order',
  234. columnProp: 'buyer',
  235. headerAlign: 'center',
  236. align: 'center',
  237. columnLabel: 'Buyer',
  238. columnHidden: false,
  239. columnImage: false,
  240. columnSortable: false,
  241. sortLv: 0,
  242. status: true,
  243. fixed: '',
  244. columnWidth: 90,
  245. showOverflowTooltip: true,
  246. editAble: false,
  247. editType: 'text',
  248. selectOptionsKey: '',
  249. selectOptions: null
  250. },
  251. {
  252. userId: this.$store.state.user.name,
  253. functionId: 812003,
  254. serialNumber: '812003Table1VendorName',
  255. tableId: '812003Table1',
  256. tableName: 'PO Order',
  257. columnProp: 'supplierName',
  258. headerAlign: 'center',
  259. align: 'center',
  260. columnLabel: 'Vendor Name',
  261. columnHidden: false,
  262. columnImage: false,
  263. columnSortable: false,
  264. sortLv: 0,
  265. status: true,
  266. fixed: '',
  267. columnWidth: 120,
  268. showOverflowTooltip: true,
  269. editAble: true,
  270. editType: 'select',
  271. selectOptionsKey: 'supplierOptions',
  272. selectOptions: null
  273. },
  274. {
  275. userId: this.$store.state.user.name,
  276. functionId: 812003,
  277. serialNumber: '812003Table1VShortOffice',
  278. tableId: '812003Table1',
  279. tableName: 'PO Order',
  280. columnProp: 'shortOffice',
  281. headerAlign: 'center',
  282. align: 'center',
  283. columnLabel: 'V_Short_Office',
  284. columnHidden: false,
  285. columnImage: false,
  286. columnSortable: false,
  287. sortLv: 0,
  288. status: true,
  289. fixed: '',
  290. columnWidth: 110,
  291. showOverflowTooltip: true,
  292. editAble: false,
  293. editType: 'text',
  294. selectOptionsKey: '',
  295. selectOptions: null
  296. },
  297. {
  298. userId: this.$store.state.user.name,
  299. functionId: 812003,
  300. serialNumber: '812003Table1VShortNpc',
  301. tableId: '812003Table1',
  302. tableName: 'PO Order',
  303. columnProp: 'shortNpc',
  304. headerAlign: 'center',
  305. align: 'center',
  306. columnLabel: 'V_Short_NPC',
  307. columnHidden: false,
  308. columnImage: false,
  309. columnSortable: false,
  310. sortLv: 0,
  311. status: true,
  312. fixed: '',
  313. columnWidth: 100,
  314. showOverflowTooltip: true,
  315. editAble: false,
  316. editType: 'text',
  317. selectOptionsKey: '',
  318. selectOptions: null
  319. },
  320. {
  321. userId: this.$store.state.user.name,
  322. functionId: 812003,
  323. serialNumber: '812003Table1PoNo',
  324. tableId: '812003Table1',
  325. tableName: 'PO Order',
  326. columnProp: 'poNo',
  327. headerAlign: 'center',
  328. align: 'center',
  329. columnLabel: 'PO_No',
  330. columnHidden: false,
  331. columnImage: false,
  332. columnSortable: false,
  333. sortLv: 0,
  334. status: true,
  335. fixed: '',
  336. columnWidth: 120,
  337. showOverflowTooltip: true,
  338. editAble: true,
  339. editType: 'text',
  340. selectOptionsKey: '',
  341. selectOptions: null
  342. },
  343. {
  344. userId: this.$store.state.user.name,
  345. functionId: 812003,
  346. serialNumber: '812003Table1Item',
  347. tableId: '812003Table1',
  348. tableName: 'PO Order',
  349. columnProp: 'item',
  350. headerAlign: 'center',
  351. align: 'center',
  352. columnLabel: 'Item',
  353. columnHidden: false,
  354. columnImage: false,
  355. columnSortable: false,
  356. sortLv: 0,
  357. status: true,
  358. fixed: '',
  359. columnWidth: 70,
  360. showOverflowTooltip: true,
  361. editAble: true,
  362. editType: 'text',
  363. selectOptionsKey: '',
  364. selectOptions: null
  365. },
  366. {
  367. userId: this.$store.state.user.name,
  368. functionId: 812003,
  369. serialNumber: '812003Table1PartNo',
  370. tableId: '812003Table1',
  371. tableName: 'PO Order',
  372. columnProp: 'partNo',
  373. headerAlign: 'center',
  374. align: 'center',
  375. columnLabel: 'Part_No',
  376. columnHidden: false,
  377. columnImage: false,
  378. columnSortable: false,
  379. sortLv: 0,
  380. status: true,
  381. fixed: '',
  382. columnWidth: 90,
  383. showOverflowTooltip: true,
  384. editAble: true,
  385. editType: 'select',
  386. selectOptionsKey: 'poPartNoOptions',
  387. selectOptions: null
  388. },
  389. {
  390. userId: this.$store.state.user.name,
  391. functionId: 812003,
  392. serialNumber: '812003Table1Category',
  393. tableId: '812003Table1',
  394. tableName: 'PO Order',
  395. columnProp: 'category',
  396. headerAlign: 'center',
  397. align: 'center',
  398. columnLabel: 'Category',
  399. columnHidden: false,
  400. columnImage: false,
  401. columnSortable: false,
  402. sortLv: 0,
  403. status: true,
  404. fixed: '',
  405. columnWidth: 90,
  406. showOverflowTooltip: true,
  407. editAble: false,
  408. editType: 'text',
  409. selectOptionsKey: '',
  410. selectOptions: null
  411. },
  412. {
  413. userId: this.$store.state.user.name,
  414. functionId: 812003,
  415. serialNumber: '812003Table1Sku',
  416. tableId: '812003Table1',
  417. tableName: 'PO Order',
  418. columnProp: 'sku',
  419. headerAlign: 'center',
  420. align: 'center',
  421. columnLabel: 'SKU',
  422. columnHidden: false,
  423. columnImage: false,
  424. columnSortable: false,
  425. sortLv: 0,
  426. status: true,
  427. fixed: '',
  428. columnWidth: 100,
  429. showOverflowTooltip: true,
  430. editAble: false,
  431. editType: 'text',
  432. selectOptionsKey: '',
  433. selectOptions: null
  434. },
  435. {
  436. userId: this.$store.state.user.name,
  437. functionId: 812003,
  438. serialNumber: '812003Table1UnitPrice',
  439. tableId: '812003Table1',
  440. tableName: 'PO Order',
  441. columnProp: 'price',
  442. headerAlign: 'center',
  443. align: 'center',
  444. columnLabel: 'Unit_Price',
  445. columnHidden: false,
  446. columnImage: false,
  447. columnSortable: false,
  448. sortLv: 0,
  449. status: true,
  450. fixed: '',
  451. columnWidth: 90,
  452. showOverflowTooltip: true,
  453. editAble: true,
  454. editType: 'num',
  455. selectOptionsKey: '',
  456. selectOptions: null
  457. },
  458. {
  459. userId: this.$store.state.user.name,
  460. functionId: 812003,
  461. serialNumber: '812003Table1PQty',
  462. tableId: '812003Table1',
  463. tableName: 'PO Order',
  464. columnProp: 'qty',
  465. headerAlign: 'center',
  466. align: 'center',
  467. columnLabel: 'P_Qty',
  468. columnHidden: false,
  469. columnImage: false,
  470. columnSortable: false,
  471. sortLv: 0,
  472. status: true,
  473. fixed: '',
  474. columnWidth: 80,
  475. showOverflowTooltip: true,
  476. editAble: true,
  477. editType: 'num',
  478. selectOptionsKey: '',
  479. selectOptions: null
  480. },
  481. {
  482. userId: this.$store.state.user.name,
  483. functionId: 812003,
  484. serialNumber: '812003Table1PValue',
  485. tableId: '812003Table1',
  486. tableName: 'PO Order',
  487. columnProp: 'value',
  488. headerAlign: 'center',
  489. align: 'center',
  490. columnLabel: 'P_Value',
  491. columnHidden: false,
  492. columnImage: false,
  493. columnSortable: false,
  494. sortLv: 0,
  495. status: true,
  496. fixed: '',
  497. columnWidth: 90,
  498. showOverflowTooltip: true,
  499. editAble: true,
  500. editType: 'text',
  501. selectOptionsKey: '',
  502. selectOptions: null
  503. },
  504. {
  505. userId: this.$store.state.user.name,
  506. functionId: 812003,
  507. serialNumber: '812003Table1AQty',
  508. tableId: '812003Table1',
  509. tableName: 'PO Order',
  510. columnProp: 'shipQty',
  511. headerAlign: 'center',
  512. align: 'center',
  513. columnLabel: 'A_Qty',
  514. columnHidden: false,
  515. columnImage: false,
  516. columnSortable: false,
  517. sortLv: 0,
  518. status: true,
  519. fixed: '',
  520. columnWidth: 80,
  521. showOverflowTooltip: true,
  522. editAble: true,
  523. editType: 'text',
  524. selectOptionsKey: '',
  525. selectOptions: null
  526. },
  527. {
  528. userId: this.$store.state.user.name,
  529. functionId: 812003,
  530. serialNumber: '812003Table1AValue',
  531. tableId: '812003Table1',
  532. tableName: 'PO Order',
  533. columnProp: 'sumPrice',
  534. headerAlign: 'center',
  535. align: 'center',
  536. columnLabel: 'A_Value',
  537. columnHidden: false,
  538. columnImage: false,
  539. columnSortable: false,
  540. sortLv: 0,
  541. status: true,
  542. fixed: '',
  543. columnWidth: 90,
  544. showOverflowTooltip: true,
  545. editAble: true,
  546. editType: 'text',
  547. selectOptionsKey: '',
  548. selectOptions: null
  549. },
  550. {
  551. userId: this.$store.state.user.name,
  552. functionId: 812003,
  553. serialNumber: '812003Table1PDeparture',
  554. tableId: '812003Table1',
  555. tableName: 'PO Order',
  556. columnProp: 'departure',
  557. headerAlign: 'center',
  558. align: 'center',
  559. columnLabel: 'P_Departure',
  560. columnHidden: false,
  561. columnImage: false,
  562. columnSortable: false,
  563. sortLv: 0,
  564. status: true,
  565. fixed: '',
  566. columnWidth: 100,
  567. showOverflowTooltip: true,
  568. editAble: true,
  569. editType: 'text',
  570. selectOptionsKey: '',
  571. selectOptions: null
  572. },
  573. {
  574. userId: this.$store.state.user.name,
  575. functionId: 812003,
  576. serialNumber: '812003Table1PDestination',
  577. tableId: '812003Table1',
  578. tableName: 'PO Order',
  579. columnProp: 'destination',
  580. headerAlign: 'center',
  581. align: 'center',
  582. columnLabel: 'P_Destination',
  583. columnHidden: false,
  584. columnImage: false,
  585. columnSortable: false,
  586. sortLv: 0,
  587. status: true,
  588. fixed: '',
  589. columnWidth: 110,
  590. showOverflowTooltip: true,
  591. editAble: true,
  592. editType: 'text',
  593. selectOptionsKey: '',
  594. selectOptions: null
  595. },
  596. {
  597. userId: this.$store.state.user.name,
  598. functionId: 812003,
  599. serialNumber: '812003Table1SMethod',
  600. tableId: '812003Table1',
  601. tableName: 'PO Order',
  602. columnProp: 'shipVia',
  603. headerAlign: 'center',
  604. align: 'center',
  605. columnLabel: 'S_Method',
  606. columnHidden: false,
  607. columnImage: false,
  608. columnSortable: false,
  609. sortLv: 0,
  610. status: true,
  611. fixed: '',
  612. columnWidth: 90,
  613. showOverflowTooltip: true,
  614. editAble: true,
  615. editType: 'select',
  616. selectOptionsKey: 'transportOptions',
  617. selectOptions: null
  618. },
  619. {
  620. userId: this.$store.state.user.name,
  621. functionId: 812003,
  622. serialNumber: '812003Table1DIssue',
  623. tableId: '812003Table1',
  624. tableName: 'PO Order',
  625. columnProp: 'orderDate',
  626. headerAlign: 'center',
  627. align: 'center',
  628. columnLabel: 'D_Issue',
  629. columnHidden: false,
  630. columnImage: false,
  631. columnSortable: false,
  632. sortLv: 0,
  633. status: true,
  634. fixed: '',
  635. columnWidth: 100,
  636. showOverflowTooltip: true,
  637. editAble: true,
  638. editType: 'date',
  639. selectOptionsKey: '',
  640. selectOptions: null
  641. },
  642. {
  643. userId: this.$store.state.user.name,
  644. functionId: 812003,
  645. serialNumber: '812003Table1DEnquiry',
  646. tableId: '812003Table1',
  647. tableName: 'PO Order',
  648. columnProp: 'enquiry',
  649. headerAlign: 'center',
  650. align: 'center',
  651. columnLabel: 'D_Enquiry',
  652. columnHidden: false,
  653. columnImage: false,
  654. columnSortable: false,
  655. sortLv: 0,
  656. status: true,
  657. fixed: '',
  658. columnWidth: 100,
  659. showOverflowTooltip: true,
  660. editAble: true,
  661. editType: 'date',
  662. selectOptionsKey: '',
  663. selectOptions: null
  664. },
  665. {
  666. userId: this.$store.state.user.name,
  667. functionId: 812003,
  668. serialNumber: '812003Table1Status',
  669. tableId: '812003Table1',
  670. tableName: 'PO Order',
  671. columnProp: 'status',
  672. headerAlign: 'center',
  673. align: 'center',
  674. columnLabel: 'Status',
  675. columnHidden: false,
  676. columnImage: false,
  677. columnSortable: false,
  678. sortLv: 0,
  679. status: true,
  680. fixed: '',
  681. columnWidth: 80,
  682. showOverflowTooltip: true,
  683. editAble: true,
  684. editType: 'select',
  685. selectOptionsKey: 'poStatusOptions',
  686. selectOptions: null
  687. },
  688. {
  689. userId: this.$store.state.user.name,
  690. functionId: 812003,
  691. serialNumber: '812003Table1DConfirmed',
  692. tableId: '812003Table1',
  693. tableName: 'PO Order',
  694. columnProp: 'confirmed',
  695. headerAlign: 'center',
  696. align: 'center',
  697. columnLabel: 'D_Confirmed',
  698. columnHidden: false,
  699. columnImage: false,
  700. columnSortable: false,
  701. sortLv: 0,
  702. status: true,
  703. fixed: '',
  704. columnWidth: 100,
  705. showOverflowTooltip: true,
  706. editAble: true,
  707. editType: 'date',
  708. selectOptionsKey: '',
  709. selectOptions: null
  710. },
  711. {
  712. userId: this.$store.state.user.name,
  713. functionId: 812003,
  714. serialNumber: '812003Table1DNeed',
  715. tableId: '812003Table1',
  716. tableName: 'PO Order',
  717. columnProp: 'wantReceiveDate',
  718. headerAlign: 'center',
  719. align: 'center',
  720. columnLabel: 'D_Need',
  721. columnHidden: false,
  722. columnImage: false,
  723. columnSortable: false,
  724. sortLv: 0,
  725. status: true,
  726. fixed: '',
  727. columnWidth: 100,
  728. showOverflowTooltip: true,
  729. editAble: true,
  730. editType: 'date',
  731. selectOptionsKey: '',
  732. selectOptions: null
  733. },
  734. {
  735. userId: this.$store.state.user.name,
  736. functionId: 812003,
  737. serialNumber: '812003Table1DNarrival',
  738. tableId: '812003Table1',
  739. tableName: 'PO Order',
  740. columnProp: 'narrival',
  741. headerAlign: 'center',
  742. align: 'center',
  743. columnLabel: 'D_Narrival',
  744. columnHidden: false,
  745. columnImage: false,
  746. columnSortable: false,
  747. sortLv: 0,
  748. status: true,
  749. fixed: '',
  750. columnWidth: 100,
  751. showOverflowTooltip: true,
  752. editAble: true,
  753. editType: 'date',
  754. selectOptionsKey: '',
  755. selectOptions: null
  756. },
  757. {
  758. userId: this.$store.state.user.name,
  759. functionId: 812003,
  760. serialNumber: '812003Table1DCrd',
  761. tableId: '812003Table1',
  762. tableName: 'PO Order',
  763. columnProp: 'crd',
  764. headerAlign: 'center',
  765. align: 'center',
  766. columnLabel: 'D_CRD',
  767. columnHidden: false,
  768. columnImage: false,
  769. columnSortable: false,
  770. sortLv: 0,
  771. status: true,
  772. fixed: '',
  773. columnWidth: 100,
  774. showOverflowTooltip: true,
  775. editAble: true,
  776. editType: 'date',
  777. selectOptionsKey: '',
  778. selectOptions: null
  779. },
  780. {
  781. userId: this.$store.state.user.name,
  782. functionId: 812003,
  783. serialNumber: '812003Table1DInspection',
  784. tableId: '812003Table1',
  785. tableName: 'PO Order',
  786. columnProp: 'inspection',
  787. headerAlign: 'center',
  788. align: 'center',
  789. columnLabel: 'D_Inspection',
  790. columnHidden: false,
  791. columnImage: false,
  792. columnSortable: false,
  793. sortLv: 0,
  794. status: true,
  795. fixed: '',
  796. columnWidth: 100,
  797. showOverflowTooltip: true,
  798. editAble: true,
  799. editType: 'date',
  800. selectOptionsKey: '',
  801. selectOptions: null
  802. },
  803. {
  804. userId: this.$store.state.user.name,
  805. functionId: 812003,
  806. serialNumber: '812003Table1ACrd',
  807. tableId: '812003Table1',
  808. tableName: 'PO Order',
  809. columnProp: 'crd',
  810. headerAlign: 'center',
  811. align: 'center',
  812. columnLabel: 'A_CRD',
  813. columnHidden: false,
  814. columnImage: false,
  815. columnSortable: false,
  816. sortLv: 0,
  817. status: true,
  818. fixed: '',
  819. columnWidth: 100,
  820. showOverflowTooltip: true,
  821. editAble: true,
  822. editType: 'date',
  823. selectOptionsKey: '',
  824. selectOptions: null
  825. },
  826. {
  827. userId: this.$store.state.user.name,
  828. functionId: 812003,
  829. serialNumber: '812003Table1Eta',
  830. tableId: '812003Table1',
  831. tableName: 'PO Order',
  832. columnProp: 'eta',
  833. headerAlign: 'center',
  834. align: 'center',
  835. columnLabel: 'ETA',
  836. columnHidden: false,
  837. columnImage: false,
  838. columnSortable: false,
  839. sortLv: 0,
  840. status: true,
  841. fixed: '',
  842. columnWidth: 100,
  843. showOverflowTooltip: true,
  844. editAble: true,
  845. editType: 'date',
  846. selectOptionsKey: '',
  847. selectOptions: null
  848. },
  849. {
  850. userId: this.$store.state.user.name,
  851. functionId: 812003,
  852. serialNumber: '812003Table1Flexid',
  853. tableId: '812003Table1',
  854. tableName: 'PO Order',
  855. columnProp: 'flexid',
  856. headerAlign: 'center',
  857. align: 'center',
  858. columnLabel: 'FLEXID',
  859. columnHidden: false,
  860. columnImage: false,
  861. columnSortable: false,
  862. sortLv: 0,
  863. status: true,
  864. fixed: '',
  865. columnWidth: 90,
  866. showOverflowTooltip: true,
  867. editAble: true,
  868. editType: 'text',
  869. selectOptionsKey: '',
  870. selectOptions: null
  871. },
  872. {
  873. userId: this.$store.state.user.name,
  874. functionId: 812003,
  875. serialNumber: '812003Table1AObd',
  876. tableId: '812003Table1',
  877. tableName: 'PO Order',
  878. columnProp: 'obd',
  879. headerAlign: 'center',
  880. align: 'center',
  881. columnLabel: 'A_OBD',
  882. columnHidden: false,
  883. columnImage: false,
  884. columnSortable: false,
  885. sortLv: 0,
  886. status: true,
  887. fixed: '',
  888. columnWidth: 100,
  889. showOverflowTooltip: true,
  890. editAble: true,
  891. editType: 'date',
  892. selectOptionsKey: '',
  893. selectOptions: null
  894. },
  895. {
  896. userId: this.$store.state.user.name,
  897. functionId: 812003,
  898. serialNumber: '812003Table1DocSent',
  899. tableId: '812003Table1',
  900. tableName: 'PO Order',
  901. columnProp: 'docSent',
  902. headerAlign: 'center',
  903. align: 'center',
  904. columnLabel: 'Doc_Sent',
  905. columnHidden: false,
  906. columnImage: false,
  907. columnSortable: false,
  908. sortLv: 0,
  909. status: true,
  910. fixed: '',
  911. columnWidth: 90,
  912. showOverflowTooltip: true,
  913. editAble: true,
  914. editType: 'select',
  915. selectOptionsKey: 'yesNoOptions',
  916. selectOptions: null
  917. },
  918. {
  919. userId: this.$store.state.user.name,
  920. functionId: 812003,
  921. serialNumber: '812003Table1TelexRelease',
  922. tableId: '812003Table1',
  923. tableName: 'PO Order',
  924. columnProp: 'telexRelease',
  925. headerAlign: 'center',
  926. align: 'center',
  927. columnLabel: 'Telex_Release',
  928. columnHidden: false,
  929. columnImage: false,
  930. columnSortable: false,
  931. sortLv: 0,
  932. status: true,
  933. fixed: '',
  934. columnWidth: 100,
  935. showOverflowTooltip: true,
  936. editAble: true,
  937. editType: 'select',
  938. selectOptionsKey: 'yesNoOptions',
  939. selectOptions: null
  940. },
  941. {
  942. userId: this.$store.state.user.name,
  943. functionId: 812003,
  944. serialNumber: '812003Table1AdvancePayment',
  945. tableId: '812003Table1',
  946. tableName: 'PO Order',
  947. columnProp: 'advancePayment',
  948. headerAlign: 'center',
  949. align: 'center',
  950. columnLabel: 'Advance_Payment',
  951. columnHidden: false,
  952. columnImage: false,
  953. columnSortable: false,
  954. sortLv: 0,
  955. status: true,
  956. fixed: '',
  957. columnWidth: 120,
  958. showOverflowTooltip: true,
  959. editAble: true,
  960. editType: 'text',
  961. selectOptionsKey: '',
  962. selectOptions: null
  963. },
  964. {
  965. userId: this.$store.state.user.name,
  966. functionId: 812003,
  967. serialNumber: '812003Table1AdvancePaid',
  968. tableId: '812003Table1',
  969. tableName: 'PO Order',
  970. columnProp: 'advancePaid',
  971. headerAlign: 'center',
  972. align: 'center',
  973. columnLabel: 'Advance_Paid',
  974. columnHidden: false,
  975. columnImage: false,
  976. columnSortable: false,
  977. sortLv: 0,
  978. status: true,
  979. fixed: '',
  980. columnWidth: 100,
  981. showOverflowTooltip: true,
  982. editAble: true,
  983. editType: 'select',
  984. selectOptionsKey: 'yesNoOptions',
  985. selectOptions: null
  986. },
  987. {
  988. userId: this.$store.state.user.name,
  989. functionId: 812003,
  990. serialNumber: '812003Table1DCreate',
  991. tableId: '812003Table1',
  992. tableName: 'PO Order',
  993. columnProp: 'createTime',
  994. headerAlign: 'center',
  995. align: 'center',
  996. columnLabel: 'D_Create',
  997. columnHidden: false,
  998. columnImage: false,
  999. columnSortable: false,
  1000. sortLv: 0,
  1001. status: true,
  1002. fixed: '',
  1003. columnWidth: 100,
  1004. showOverflowTooltip: true,
  1005. editAble: true,
  1006. editType: 'date',
  1007. selectOptionsKey: '',
  1008. selectOptions: null
  1009. },
  1010. {
  1011. userId: this.$store.state.user.name,
  1012. functionId: 812003,
  1013. serialNumber: '812003Table1MPlanner',
  1014. tableId: '812003Table1',
  1015. tableName: 'PO Order',
  1016. columnProp: 'planner',
  1017. headerAlign: 'center',
  1018. align: 'center',
  1019. columnLabel: 'M_Planner',
  1020. columnHidden: false,
  1021. columnImage: false,
  1022. columnSortable: false,
  1023. sortLv: 0,
  1024. status: true,
  1025. fixed: '',
  1026. columnWidth: 100,
  1027. showOverflowTooltip: true,
  1028. editAble: true,
  1029. editType: 'text',
  1030. selectOptionsKey: '',
  1031. selectOptions: null
  1032. },
  1033. {
  1034. userId: this.$store.state.user.name,
  1035. functionId: 812003,
  1036. serialNumber: '812003Table1DEdit',
  1037. tableId: '812003Table1',
  1038. tableName: 'PO Order',
  1039. columnProp: 'edit',
  1040. headerAlign: 'center',
  1041. align: 'center',
  1042. columnLabel: 'D_Edit',
  1043. columnHidden: false,
  1044. columnImage: false,
  1045. columnSortable: false,
  1046. sortLv: 0,
  1047. status: true,
  1048. fixed: '',
  1049. columnWidth: 100,
  1050. showOverflowTooltip: true,
  1051. editAble: true,
  1052. editType: 'date',
  1053. selectOptionsKey: '',
  1054. selectOptions: null
  1055. },
  1056. {
  1057. userId: this.$store.state.user.name,
  1058. functionId: 812003,
  1059. serialNumber: '812003Table1EPlanner',
  1060. tableId: '812003Table1',
  1061. tableName: 'PO Order',
  1062. columnProp: 'endPlanner',
  1063. headerAlign: 'center',
  1064. align: 'center',
  1065. columnLabel: 'E_Planner',
  1066. columnHidden: false,
  1067. columnImage: false,
  1068. columnSortable: false,
  1069. sortLv: 0,
  1070. status: true,
  1071. fixed: '',
  1072. columnWidth: 100,
  1073. showOverflowTooltip: true,
  1074. editAble: true,
  1075. editType: 'text',
  1076. selectOptionsKey: '',
  1077. selectOptions: null
  1078. },
  1079. {
  1080. userId: this.$store.state.user.name,
  1081. functionId: 812003,
  1082. serialNumber: '812003Table1RemarkDelay',
  1083. tableId: '812003Table1',
  1084. tableName: 'PO Order',
  1085. columnProp: 'remarkDelay',
  1086. headerAlign: 'center',
  1087. align: 'center',
  1088. columnLabel: 'Remark_Delay',
  1089. columnHidden: false,
  1090. columnImage: false,
  1091. columnSortable: false,
  1092. sortLv: 0,
  1093. status: true,
  1094. fixed: '',
  1095. columnWidth: 110,
  1096. showOverflowTooltip: true,
  1097. editAble: true,
  1098. editType: 'text',
  1099. selectOptionsKey: '',
  1100. selectOptions: null
  1101. },
  1102. {
  1103. userId: this.$store.state.user.name,
  1104. functionId: 812003,
  1105. serialNumber: '812003Table1Comments',
  1106. tableId: '812003Table1',
  1107. tableName: 'PO Order',
  1108. columnProp: 'remark',
  1109. headerAlign: 'center',
  1110. align: 'center',
  1111. columnLabel: 'Comments',
  1112. columnHidden: false,
  1113. columnImage: false,
  1114. columnSortable: false,
  1115. sortLv: 0,
  1116. status: true,
  1117. fixed: '',
  1118. columnWidth: 140,
  1119. showOverflowTooltip: true,
  1120. editAble: true,
  1121. editType: 'text',
  1122. selectOptionsKey: '',
  1123. selectOptions: null
  1124. }
  1125. ]
  1126. }
  1127. },
  1128. computed: {
  1129. visibleColumns () {
  1130. return this.columnList.filter(c => !c.columnHidden)
  1131. }
  1132. },
  1133. created () {
  1134. this.getDataList()
  1135. },
  1136. mounted () {
  1137. this.$nextTick(() => {
  1138. this.height = window.innerHeight - 180
  1139. })
  1140. },
  1141. methods: {
  1142. /**
  1143. * 表格当前行变化将选中行深拷贝到 currentRow取消选中时为 null - rqrq
  1144. */
  1145. onTableCurrentChange (row) {
  1146. if (!row) {
  1147. this.currentRow = null
  1148. return
  1149. }
  1150. this.currentRow = row
  1151. },
  1152. /**
  1153. * 解析列对应的下拉选项优先列上 selectOptions其次 columnSelectOptions[selectOptionsKey]
  1154. */
  1155. getSelectOptionsForColumn (item) {
  1156. if (item.selectOptions && item.selectOptions.length) {
  1157. return item.selectOptions
  1158. }
  1159. const key = item.selectOptionsKey
  1160. if (key && this.columnSelectOptions[key]) {
  1161. return this.columnSelectOptions[key]
  1162. }
  1163. return []
  1164. },
  1165. getDataList() {
  1166. this.loading = true
  1167. const params = {
  1168. ...this.searchData,
  1169. page: this.pageIndex,
  1170. limit: this.pageSize
  1171. }
  1172. searchPoDetailPage(params).then(({ data }) => {
  1173. if (data.code === 0) {
  1174. this.dataList = data.page.list
  1175. // 将 dataList 深拷贝到 masterRows,并为每行添加 changeFlag
  1176. this.masterRows = this.dataList.map(row => ({
  1177. ...row,
  1178. changeFlag: 0 // 初始化变更标记
  1179. }))
  1180. this.initRowEditValues()
  1181. this.pageIndex = data.page.currPage
  1182. this.pageSize = data.page.pageSize
  1183. this.totalPage = data.page.totalCount
  1184. } else {
  1185. this.$message.error((data && data.msg) || '获取列表失败')
  1186. }
  1187. this.loading = false
  1188. }).catch(() => {
  1189. this.loading = false
  1190. this.$message.error('请求失败')
  1191. })
  1192. },
  1193. sizeChangeHandle (val) {
  1194. this.pageSize = val
  1195. this.pageIndex = 1
  1196. this.getDataList()
  1197. },
  1198. currentChangeHandle (val) {
  1199. this.pageIndex = val
  1200. this.getDataList()
  1201. },
  1202. onCellChange (row) {
  1203. this.$set(row, 'changeFlag', 1)
  1204. },
  1205. handleSupplierChange(row, supplierNo) {
  1206. console.log('供应商变更:', supplierNo, '行ID:', row.id)
  1207. const selectedOption = this.supplierOptions.find(opt => opt.value === supplierNo)
  1208. if (selectedOption) {
  1209. this.$set(row, 'supplierName', selectedOption.label)
  1210. this.$set(row, 'supplierNo', selectedOption.value)
  1211. this.$set(row, 'shortOffice', selectedOption.shortOffice || '')
  1212. this.$set(row, 'shortNpc', selectedOption.shortNpc || '')
  1213. this.$set(row, 'changeFlag', 1)
  1214. } else if (!supplierNo) {
  1215. this.$set(row, 'supplierName', '')
  1216. this.$set(row, 'supplierNo', '')
  1217. this.$set(row, 'shortOffice', '')
  1218. this.$set(row, 'shortNpc', '')
  1219. this.$set(row, 'changeFlag', 1)
  1220. this.$set(this.rowSupplierNo, row.id, '')
  1221. }
  1222. },
  1223. handlePartNoChange(row, partNo) {
  1224. console.log('物料变更:', partNo, '行ID:', row.id)
  1225. // 根据 partNo 找到对应的物料信息
  1226. const selectedOption = this.poPartNoOptions.find(opt => opt.value === partNo)
  1227. if (selectedOption) {
  1228. // 更新物料相关信息
  1229. this.$set(row, 'partNo', selectedOption.label)
  1230. //同时更新 category 和 sku
  1231. this.$set(row, 'category', selectedOption.category || '')
  1232. this.$set(row, 'sku', selectedOption.sku || '')
  1233. this.$set(row, 'changeFlag', 1)
  1234. } else if (!partNo) {
  1235. // 清空选择
  1236. this.$set(row, 'partNo', '')
  1237. this.$set(row, 'category', '')
  1238. this.$set(row, 'sku', '')
  1239. this.$set(row, 'changeFlag', 1)
  1240. // 清除存储的物料编号
  1241. this.$set(this.rowPartNo, row.id, '')
  1242. }
  1243. },
  1244. toggleEditMode () {
  1245. if (!this.editMode) {
  1246. this.editMode = true
  1247. this.initRowEditValues()
  1248. this.getSupplierOptions()
  1249. this.getPartNoOptions()
  1250. return
  1251. }
  1252. const changed = this.masterRows.filter(r => r.changeFlag === 1)
  1253. this.batchUpdatePoOrder(changed)
  1254. },
  1255. initRowEditValues () {
  1256. this.rowSupplierNo = {}
  1257. this.rowPartNo = {}
  1258. this.masterRows.forEach(row => {
  1259. if (row && row.id != null) {
  1260. this.$set(this.rowSupplierNo, row.id, row.supplierNo || '')
  1261. this.$set(this.rowPartNo, row.id, row.partNo || '')
  1262. }
  1263. })
  1264. },
  1265. getPartNoOptions() {
  1266. console.log('获取分类选项')
  1267. getPartList(
  1268. {
  1269. site: this.$store.state.user.site
  1270. }
  1271. ).then(({data}) => {
  1272. if (data && data.code === 0) {
  1273. console.log('接口返回的rows:', data.rows) // 查看返回数据
  1274. this.poPartNoOptions = (data.rows || []).map(item => ({
  1275. label: item.partNo,
  1276. value: item.partNo,
  1277. partNo: item.partNo,
  1278. category: item.category,
  1279. sku: item.sku
  1280. }))
  1281. } else {
  1282. this.$message.error(data.msg || '操作失败')
  1283. }
  1284. }).catch(error => {
  1285. this.$message.error('操作失败: ' + error.message)
  1286. })
  1287. },
  1288. getSupplierOptions(){
  1289. console.log('获取供应商选项')
  1290. checkSrmSupplierList(
  1291. {
  1292. site: this.$store.state.user.site
  1293. }
  1294. ).then(({data}) => {
  1295. if (data && data.code === 0) {
  1296. console.log('接口返回的rows:', data.rows) // 查看返回数据
  1297. this.supplierOptions = (data.rows || []).map(item => ({
  1298. label: item.supplierName,
  1299. value: item.supplierNo,
  1300. supplierNo: item.supplierNo,
  1301. supplierName: item.supplierName,
  1302. shortOffice: item.cshortOffice,
  1303. shortNpc: item.cshortNpc
  1304. }))
  1305. } else {
  1306. this.$message.error(data.msg || '操作失败')
  1307. }
  1308. }).catch(error => {
  1309. this.$message.error('操作失败: ' + error.message)
  1310. })
  1311. },
  1312. // 保存订单信息
  1313. batchUpdatePoOrder(changed) {
  1314. // 构建批量修改的数据
  1315. const updateData = changed.map(row => ({
  1316. id: row.id,
  1317. ...row
  1318. }))
  1319. // 调用批量修改接口
  1320. batchUpdatePoDetail(updateData)
  1321. .then(({ data }) => {
  1322. if (data && data.code === 0) {
  1323. this.$message({
  1324. message: `已提交 ${updateData.length} 行变更`,
  1325. type: 'success',
  1326. duration: 2000
  1327. })
  1328. changed.forEach(r => {
  1329. this.$set(r, 'changeFlag', 0)
  1330. })
  1331. this.editMode = false
  1332. this.getDataList()
  1333. } else {
  1334. this.$message.error(data.msg || '操作失败')
  1335. }
  1336. })
  1337. .catch(error => {
  1338. this.$message.error('操作失败: ' + error.message)
  1339. })
  1340. }
  1341. }
  1342. }
  1343. </script>
  1344. <style scoped lang="scss">
  1345. .el-table /deep/ .cell {
  1346. height: auto;
  1347. line-height: 1.5;
  1348. }
  1349. </style>