plm前端
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.

217 lines
7.3 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <script>
  2. import {getItemModal} from "../../../../../api/base/properties";
  3. import {Decimal} from "decimal.js";
  4. export default {
  5. name: "propertyTemplates",
  6. props:{
  7. detail:{
  8. type:Object,
  9. request:true,
  10. },
  11. height:{
  12. type:Number,
  13. default:400,
  14. },
  15. packCost:{
  16. type:Number,
  17. default:0,
  18. },
  19. shippingCost:{
  20. type:Number,
  21. default:0,
  22. },
  23. },
  24. data(){
  25. return{
  26. propertyTemplatesItemList:[],//属性模板item集合
  27. dataListLoading:false,
  28. columnDetailList: [
  29. {
  30. userId: this.$store.state.user.name,
  31. functionId: 102003,
  32. serialNumber: '102003Table7PropertiesItemID',
  33. tableId: "102003Table7",
  34. tableName: "物料属性项目表",
  35. columnProp: 'propertiesItemNo',
  36. headerAlign: "center",
  37. align: "left",
  38. columnLabel: '属性编码',
  39. columnHidden: false,
  40. columnImage: false,
  41. columnSortable: false,
  42. sortLv: 0,
  43. status: true,
  44. fixed: '',
  45. columnWidth: 90,
  46. },
  47. {
  48. userId: this.$store.state.user.name,
  49. functionId: 102003,
  50. serialNumber: '102003Table7PropertiesItemDesc',
  51. tableId: "102003Table7",
  52. tableName: "物料属性项目表",
  53. columnProp: 'itemDesc',
  54. headerAlign: "center",
  55. align: "left",
  56. columnLabel: '属性名称',
  57. columnHidden: false,
  58. columnImage: false,
  59. columnSortable: false,
  60. sortLv: 0,
  61. status: true,
  62. fixed: '',
  63. columnWidth: 90,
  64. },
  65. {
  66. userId: this.$store.state.user.name,
  67. functionId: 102003,
  68. serialNumber: '102003Table7ValueType',
  69. tableId: "102003Table7",
  70. tableName: "物料属性项目表",
  71. columnProp: 'valueType',
  72. headerAlign: "center",
  73. align: "center",
  74. columnLabel: '属性类型',
  75. columnHidden: false,
  76. columnImage: false,
  77. columnSortable: false,
  78. sortLv: 0,
  79. status: true,
  80. fixed: '',
  81. columnWidth: 70,
  82. },
  83. {
  84. userId: this.$store.state.user.name,
  85. functionId: 102003,
  86. serialNumber: '102003TableValueChooseFlag',
  87. tableId: "102003Table",
  88. tableName: "common",
  89. columnProp: 'textValue',
  90. headerAlign: "center",
  91. align: "center",
  92. columnLabel: '文本值',
  93. columnHidden: false,
  94. columnImage: false,
  95. columnSortable: false,
  96. sortLv: 0,
  97. status: true,
  98. fixed: '',
  99. columnWidth: 70,
  100. },
  101. {
  102. userId: this.$store.state.user.name,
  103. functionId: 102003,
  104. serialNumber: '102003TableValueChooseFlag',
  105. tableId: "102003Table",
  106. tableName: "common",
  107. columnProp: 'numValue',
  108. headerAlign: "center",
  109. align: "center",
  110. columnLabel: '数字值',
  111. columnHidden: false,
  112. columnImage: false,
  113. columnSortable: false,
  114. sortLv: 0,
  115. status: true,
  116. fixed: '',
  117. columnWidth: 70,
  118. },
  119. ],
  120. }
  121. },
  122. created() {
  123. // this.getPropertyTemplatesItem();
  124. },
  125. methods:{
  126. getPackInfoCost(){
  127. let boxOfBags = this.propertyTemplatesItemList.find((item)=>item.propertiesItemNo.toUpperCase() === 'PACK-BAGS/BOX');
  128. let boxCost = this.propertyTemplatesItemList.find((item)=>item.propertiesItemNo.toUpperCase() === 'PACK-BOX-COST');
  129. let packOtherCost = this.propertyTemplatesItemList.find((item)=>item.propertiesItemNo.toUpperCase() === 'PACK-OTHER-COST');
  130. let numOfBag = this.propertyTemplatesItemList.find((item)=>item.propertiesItemNo.toUpperCase() === 'PACK-PCS/PE-BAG');
  131. let bagCost = this.propertyTemplatesItemList.find((item)=>item.propertiesItemNo.toUpperCase() === 'PACK-PE-BAG-COST');
  132. if (!boxCost || !boxOfBags || !numOfBag || !bagCost){
  133. // this.$message.warning("缺少包装信息")
  134. return 0;
  135. }
  136. if (boxCost.numValue === null || boxCost.numValue === undefined || boxOfBags.numValue === null || boxOfBags.numValue === undefined
  137. || numOfBag.numValue === null || numOfBag.numValue === undefined || bagCost.numValue === null || bagCost.numValue === undefined){
  138. // this.$message.warning("缺少包装信息")
  139. return 0;
  140. }
  141. let num1 = new Decimal(bagCost.numValue).div(new Decimal(numOfBag.numValue));
  142. let num2 = new Decimal(boxCost.numValue).div(new Decimal(boxOfBags.numValue));
  143. return num1.add(num2).toSignificantDigits().toNumber()
  144. },
  145. getShippingInfoCost(){
  146. let shippingCost = this.propertyTemplatesItemList.find((item)=>item.propertiesItemNo.toUpperCase() === 'SHIPPING-COST');
  147. let shippingDeliverQuantity = this.propertyTemplatesItemList.find((item)=>item.propertiesItemNo.toUpperCase() === 'SHIPPING-DELIVER-QUANTITY');
  148. let shippingOtherCost = this.propertyTemplatesItemList.find((item)=>item.propertiesItemNo.toUpperCase() === 'SHIPPING-OTHER-COST');
  149. if (!shippingCost || !shippingDeliverQuantity){
  150. // this.$message.warning("缺少交付/运输信息")
  151. return 0;
  152. }
  153. if (shippingCost.numValue === null || shippingCost.numValue === undefined || shippingDeliverQuantity.numValue === null || shippingDeliverQuantity.numValue === undefined){
  154. // this.$message.warning("缺少交付/运输信息")
  155. return 0;
  156. }
  157. return new Decimal(shippingCost.numValue).div(new Decimal(shippingDeliverQuantity.numValue)).toSignificantDigits().toNumber()
  158. },
  159. getPropertyTemplatesItem(){
  160. let params = {
  161. site:this.$store.state.user.site,
  162. partNo:this.detail.productNo
  163. }
  164. this.dataListLoading = true
  165. getItemModal(params).then(({data})=>{
  166. if (data && data.code === 0){
  167. this.propertyTemplatesItemList = data.rows;
  168. // 价格
  169. this.$emit("update:packCost",this.getPackInfoCost())
  170. this.$emit("update:shippingCost",this.getShippingInfoCost())
  171. }else {
  172. this.$message.warning(data.msg)
  173. }
  174. this.dataListLoading = false
  175. }).catch((error)=>{
  176. this.$message.error(error)
  177. this.dataListLoading = false
  178. })
  179. }
  180. }
  181. }
  182. </script>
  183. <template>
  184. <div>
  185. <div>
  186. <el-button type="primary" @click="getPropertyTemplatesItem">刷新属性</el-button>
  187. </div>
  188. <el-table
  189. :height="height"
  190. :data="propertyTemplatesItemList"
  191. border element-loading-text = "数据正在加载中"
  192. v-loading="dataListLoading"
  193. style="width: 100%;margin-top: 5px">
  194. <el-table-column
  195. v-for="(item,index) in columnDetailList" :key="index"
  196. :sortable="item.columnSortable"
  197. :prop="item.columnProp"
  198. :header-align="item.headerAlign"
  199. :show-overflow-tooltip="item.showOverflowTooltip"
  200. :align="item.align"
  201. :fixed="item.fixed===''?false:item.fixed"
  202. :min-width="item.columnWidth"
  203. :label="item.columnLabel">
  204. <template slot-scope="scope">
  205. <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
  206. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  207. </template>
  208. </el-table-column>
  209. </el-table>
  210. </div>
  211. </template>
  212. <style scoped>
  213. </style>