|
|
<script>import {getItemModal} from "../../../../../api/base/properties";import {Decimal} from "decimal.js";
export default { name: "propertyTemplates", props:{ detail:{ type:Object, request:true, }, height:{ type:Number, default:400, }, packCost:{ type:Number, default:0, }, shippingCost:{ type:Number, default:0, }, }, data(){ return{ propertyTemplatesItemList:[],//属性模板item集合
dataListLoading:false, columnDetailList: [ { userId: this.$store.state.user.name, functionId: 102003, serialNumber: '102003Table7PropertiesItemID', tableId: "102003Table7", tableName: "物料属性项目表", columnProp: 'propertiesItemNo', headerAlign: "center", align: "left", columnLabel: '属性编码', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 90, }, { userId: this.$store.state.user.name, functionId: 102003, serialNumber: '102003Table7PropertiesItemDesc', tableId: "102003Table7", tableName: "物料属性项目表", columnProp: 'itemDesc', headerAlign: "center", align: "left", columnLabel: '属性名称', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 90, }, { userId: this.$store.state.user.name, functionId: 102003, serialNumber: '102003Table7ValueType', tableId: "102003Table7", tableName: "物料属性项目表", columnProp: 'valueType', headerAlign: "center", align: "center", columnLabel: '属性类型', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 70, }, { userId: this.$store.state.user.name, functionId: 102003, serialNumber: '102003TableValueChooseFlag', tableId: "102003Table", tableName: "common", columnProp: 'textValue', headerAlign: "center", align: "center", columnLabel: '文本值', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 70, }, { userId: this.$store.state.user.name, functionId: 102003, serialNumber: '102003TableValueChooseFlag', tableId: "102003Table", tableName: "common", columnProp: 'numValue', headerAlign: "center", align: "center", columnLabel: '数字值', columnHidden: false, columnImage: false, columnSortable: false, sortLv: 0, status: true, fixed: '', columnWidth: 70, }, ], } }, created() { // this.getPropertyTemplatesItem();
}, methods:{ getPackInfoCost(){ let boxOfBags = this.propertyTemplatesItemList.find((item)=>item.propertiesItemNo.toUpperCase() === 'PACK-BAGS/BOX'); let boxCost = this.propertyTemplatesItemList.find((item)=>item.propertiesItemNo.toUpperCase() === 'PACK-BOX-COST'); let packOtherCost = this.propertyTemplatesItemList.find((item)=>item.propertiesItemNo.toUpperCase() === 'PACK-OTHER-COST'); let numOfBag = this.propertyTemplatesItemList.find((item)=>item.propertiesItemNo.toUpperCase() === 'PACK-PCS/PE-BAG'); let bagCost = this.propertyTemplatesItemList.find((item)=>item.propertiesItemNo.toUpperCase() === 'PACK-PE-BAG-COST'); if (!boxCost || !boxOfBags || !numOfBag || !bagCost){ // this.$message.warning("缺少包装信息")
return 0; } if (boxCost.numValue === null || boxCost.numValue === undefined || boxOfBags.numValue === null || boxOfBags.numValue === undefined || numOfBag.numValue === null || numOfBag.numValue === undefined || bagCost.numValue === null || bagCost.numValue === undefined){ // this.$message.warning("缺少包装信息")
return 0; } let num1 = new Decimal(bagCost.numValue).div(new Decimal(numOfBag.numValue)); let num2 = new Decimal(boxCost.numValue).div(new Decimal(boxOfBags.numValue)); return num1.add(num2).toSignificantDigits().toNumber() }, getShippingInfoCost(){ let shippingCost = this.propertyTemplatesItemList.find((item)=>item.propertiesItemNo.toUpperCase() === 'SHIPPING-COST'); let shippingDeliverQuantity = this.propertyTemplatesItemList.find((item)=>item.propertiesItemNo.toUpperCase() === 'SHIPPING-DELIVER-QUANTITY'); let shippingOtherCost = this.propertyTemplatesItemList.find((item)=>item.propertiesItemNo.toUpperCase() === 'SHIPPING-OTHER-COST'); if (!shippingCost || !shippingDeliverQuantity){ // this.$message.warning("缺少交付/运输信息")
return 0; } if (shippingCost.numValue === null || shippingCost.numValue === undefined || shippingDeliverQuantity.numValue === null || shippingDeliverQuantity.numValue === undefined){ // this.$message.warning("缺少交付/运输信息")
return 0; } return new Decimal(shippingCost.numValue).div(new Decimal(shippingDeliverQuantity.numValue)).toSignificantDigits().toNumber() }, getPropertyTemplatesItem(){ let params = { site:this.$store.state.user.site, partNo:this.detail.productNo } this.dataListLoading = true getItemModal(params).then(({data})=>{ if (data && data.code === 0){ this.propertyTemplatesItemList = data.rows; // 价格
this.$emit("update:packCost",this.getPackInfoCost()) this.$emit("update:shippingCost",this.getShippingInfoCost()) }else { this.$message.warning(data.msg) } this.dataListLoading = false }).catch((error)=>{ this.$message.error(error) this.dataListLoading = false }) } }}</script>
<template><div> <div> <el-button type="primary" @click="getPropertyTemplatesItem">刷新属性</el-button> </div> <el-table :height="height" :data="propertyTemplatesItemList" border element-loading-text = "数据正在加载中" v-loading="dataListLoading" style="width: 100%;margin-top: 5px"> <el-table-column v-for="(item,index) in columnDetailList" :key="index" :sortable="item.columnSortable" :prop="item.columnProp" :header-align="item.headerAlign" :show-overflow-tooltip="item.showOverflowTooltip" :align="item.align" :fixed="item.fixed===''?false:item.fixed" :min-width="item.columnWidth" :label="item.columnLabel"> <template slot-scope="scope"> <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span> <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span> </template> </el-table-column> </el-table></div></template>
<style scoped>
</style>
|