spareInfo.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <el-form ref="spareInfoRef">
  3. <headerTitle :title="title" style="margin-top: 15px"></headerTitle>
  4. <ele-pro-table
  5. ref="table"
  6. :columns="columns"
  7. :datasource="tableList"
  8. row-key="id"
  9. height="30vh"
  10. :needPage="false"
  11. >
  12. <template v-slot:toolbar>
  13. <div class="toobar toobar_r" v-if="taskDefinitionKey != 'wms_out'">
  14. <div class="total_price">总计: {{ totalPrice }} (元)</div>
  15. </div>
  16. </template>
  17. </ele-pro-table>
  18. </el-form>
  19. </template>
  20. <script>
  21. export default {
  22. props: {
  23. detailList: {
  24. type: Array,
  25. default: () => []
  26. },
  27. types: {
  28. type: String,
  29. default: ''
  30. },
  31. title: {
  32. type: String,
  33. default: '配件信息'
  34. },
  35. taskDefinitionKey: {
  36. type: String,
  37. default: ''
  38. }
  39. },
  40. watch: {
  41. detailList: {
  42. handler(newVal) {
  43. console.log(this.taskDefinitionKey,'this.taskDefinitionKeythis.taskDefinitionKeythis.taskDefinitionKeythis.taskDefinitionKey00000')
  44. this.tableList = JSON.parse(JSON.stringify(newVal));
  45. this.calculatePrice();
  46. },
  47. immediate: true
  48. }
  49. },
  50. data() {
  51. return {
  52. tableList: [],
  53. columns: [
  54. {
  55. columnKey: 'index',
  56. label: '序号',
  57. type: 'index',
  58. width: 55,
  59. align: 'center',
  60. showOverflowTooltip: true,
  61. fixed: 'left'
  62. },
  63. {
  64. prop: 'categoryCode',
  65. label: '物品编码',
  66. align: 'center'
  67. },
  68. {
  69. prop: 'categoryName',
  70. label: '物品名称',
  71. align: 'center'
  72. },
  73. {
  74. prop: 'categoryModel',
  75. label: '型号',
  76. align: 'center'
  77. },
  78. {
  79. prop: 'specification',
  80. label: '规格',
  81. align: 'center'
  82. },
  83. {
  84. prop: 'level',
  85. label: '级别',
  86. align: 'center'
  87. },
  88. {
  89. prop: 'totalCount',
  90. label: '数量',
  91. align: 'center',
  92. width: 100,
  93. show: this.taskDefinitionKey != 'wms_out'
  94. },
  95. {
  96. prop: 'singlePrice',
  97. label: '单价',
  98. align: 'center',
  99. width: 100,
  100. show: this.taskDefinitionKey != 'wms_out'
  101. },
  102. {
  103. prop: 'totalPrice',
  104. label: '总价',
  105. align: 'center',
  106. width: 100,
  107. show: this.taskDefinitionKey != 'wms_out'
  108. },
  109. {
  110. prop: 'measureUnit',
  111. label: '计量单位',
  112. align: 'center',
  113. show: this.taskDefinitionKey != 'wms_out'
  114. },
  115. {
  116. prop: 'warehouseName',
  117. label: '仓库',
  118. align: 'center'
  119. }
  120. ],
  121. totalPrice: 0 // 总计
  122. };
  123. },
  124. mounted() {
  125. console.log(this.$store.state.user?.info, '--------------- 这是数据信息');
  126. },
  127. methods: {
  128. // 计算汇总价格 ***
  129. calculatePrice() {
  130. let totlal = 0;
  131. this.tableList.map((el) => (totlal += el.totalPrice || 0));
  132. this.totalPrice = totlal;
  133. }
  134. }
  135. };
  136. </script>
  137. <style lang="scss" scoped>
  138. .add-product {
  139. // width: 70%;
  140. display: flex;
  141. align-items: center;
  142. // justify-content: flex-end;
  143. font-size: 30px;
  144. color: #1890ff;
  145. margin: 10px 0;
  146. cursor: pointer;
  147. }
  148. .toobar {
  149. display: flex;
  150. align-items: center;
  151. justify-content: space-between;
  152. padding-right: 16px;
  153. .total_price {
  154. margin-left: 24px;
  155. min-width: 50px;
  156. }
  157. }
  158. .toobar_r {
  159. justify-content: flex-end;
  160. }
  161. </style>