bomDetailDialog.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <el-dialog
  3. :title="dialogTitle"
  4. :visible.sync="dialogVisible"
  5. :close-on-click-modal="false"
  6. append-to-body
  7. width="80%"
  8. top="5vh"
  9. custom-class="ele-dialog-form"
  10. @close="close"
  11. >
  12. <el-card shadow="never">
  13. <el-alert
  14. v-if="!bomList.length"
  15. type="info"
  16. :closable="false"
  17. show-icon
  18. title="该明细行暂无 BOM 数据"
  19. />
  20. <ele-pro-table
  21. v-else
  22. ref="table"
  23. :need-page="false"
  24. :columns="columns"
  25. :datasource="bomList"
  26. row-key="materialCode"
  27. max-height="420px"
  28. >
  29. <template v-slot:shelf="{ row: item }">
  30. <el-tag v-if="Number(item.shelfStatus) === 1" type="success" size="small">
  31. 已上架
  32. </el-tag>
  33. <el-tag v-else type="info" size="small">按0</el-tag>
  34. </template>
  35. </ele-pro-table>
  36. <div class="bom-summary" v-if="bomList.length">
  37. <span class="amount">数量:{{ toNumber(row.totalCount, 0) }}</span>
  38. <span class="amount">单价:{{ formatAmount(row.singlePrice) }}元</span>
  39. <span class="amount">BOM条数:{{ bomList.length }}</span>
  40. <span class="amount">总计:{{ formatAmount(sumTotal) }}元</span>
  41. </div>
  42. </el-card>
  43. <div slot="footer" class="dialog-footer">
  44. <el-button size="small" @click="close">关 闭</el-button>
  45. </div>
  46. </el-dialog>
  47. </template>
  48. <script>
  49. /* 报价单审批页:查看某条物品清单行已导入的 BOM 详情(只读,与 eom 报价单 BOM详情 同版式) */
  50. const textColumn = (prop, label, minWidth) => ({
  51. prop: prop,
  52. label: label,
  53. minWidth: minWidth,
  54. align: 'center',
  55. showOverflowTooltip: true
  56. });
  57. const numberColumn = (prop, label, width) => ({
  58. prop: prop,
  59. label: label,
  60. width: width,
  61. align: 'center',
  62. showOverflowTooltip: true
  63. });
  64. export default {
  65. name: 'QuoteBomDetailDialog',
  66. data() {
  67. return {
  68. dialogVisible: false,
  69. row: {},
  70. bomList: [],
  71. columns: [
  72. textColumn('bomCategory', '物料分类', 180),
  73. numberColumn('bomLevel', '级次', 70),
  74. textColumn('parentMaterialCode', '父级物料编码', 140),
  75. textColumn('materialCode', '物料编码', 150),
  76. numberColumn('dosage', '用量', 80),
  77. textColumn('name', '名称', 160),
  78. textColumn('specification', '规格', 160),
  79. textColumn('supplierInfo', '供应商信息', 130),
  80. numberColumn('quantity', '数量', 90),
  81. textColumn('taxPrice', '含税单价', 110),
  82. numberColumn('taxRate', '税率(%)', 90),
  83. textColumn('notaxPrice', '不含税单价', 120),
  84. textColumn('totalPrice', '总价', 110),
  85. { columnKey: 'shelf', label: '状态', width: 90, align: 'center', slot: 'shelf' }
  86. ]
  87. };
  88. },
  89. computed: {
  90. dialogTitle() {
  91. const name = this.row && this.row.productName ? this.row.productName : '';
  92. return name ? 'BOM详情 - ' + name : 'BOM详情';
  93. },
  94. sumTotal() {
  95. return this.bomList.reduce(
  96. (total, item) => total + this.toNumber(item.totalPrice, 0),
  97. 0
  98. );
  99. }
  100. },
  101. methods: {
  102. toNumber(value, fallback) {
  103. const num = Number(value);
  104. if (value === null || value === undefined || value === '' || !isFinite(num)) {
  105. return fallback === undefined ? 0 : fallback;
  106. }
  107. return num;
  108. },
  109. formatAmount(value) {
  110. return this.toNumber(value, 0).toFixed(4);
  111. },
  112. // BOM 数据随报价单详情返回在 quoteProductList[].bomList 上,这里只做展示
  113. open(payload) {
  114. const params = payload || {};
  115. this.row = params.row || {};
  116. this.bomList = Array.isArray(this.row.bomList) ? this.row.bomList : [];
  117. this.dialogVisible = true;
  118. },
  119. close() {
  120. this.dialogVisible = false;
  121. }
  122. }
  123. };
  124. </script>
  125. <style lang="scss" scoped>
  126. .bom-summary {
  127. margin-top: 8px;
  128. text-align: right;
  129. .amount {
  130. margin-left: 20px;
  131. font-size: 13px;
  132. color: #606266;
  133. }
  134. }
  135. </style>