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.

394 lines
19 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <script>
  2. import {Decimal} from "decimal.js";
  3. export default {
  4. name: "costPrice",
  5. props: {
  6. detail: {
  7. type: Object,
  8. request: true
  9. },
  10. height: {
  11. type: Number,
  12. default: 400,
  13. },
  14. loadingStatus:{
  15. type:Boolean,
  16. default: false,
  17. },
  18. bomCost:{
  19. type:Number,
  20. default:0,
  21. },
  22. toolCost:{
  23. type:Number,
  24. default:0,
  25. },
  26. packCost:{
  27. type:Number,
  28. default:0,
  29. },
  30. shippingCost:{
  31. type:Number,
  32. default:0,
  33. },
  34. machineCost:{
  35. type:Number,
  36. default:0,
  37. },
  38. laborCost:{
  39. type:Number,
  40. default:0,
  41. },
  42. manufacturingCost:{
  43. type:Number,
  44. default:0,
  45. }
  46. },
  47. data() {
  48. return {
  49. rules: {
  50. detailProfitRate: [{required: true, pattern:/^[1-9]\d{0,14}(\.\d{1,16})?$|^0(\.\d{1,16})?$/, message: ' ', trigger: ['change','blur']}],
  51. adjustPartCost: [{required: true, pattern:/^[1-9]\d{0,14}(\.\d{1,16})?$|^0(\.\d{1,16})?$/, message: ' ', trigger: ['change','blur']}],
  52. adjustMachineCost: [{required: true,pattern:/^[1-9]\d{0,14}(\.\d{1,16})?$|^0(\.\d{1,16})?$/, message: ' ', trigger: ['change','blur']}],
  53. adjustFabricateCost: [{required: true,pattern:/^[1-9]\d{0,14}(\.\d{1,16})?$|^0(\.\d{1,16})?$/, message: ' ', trigger: ['change','blur']}],
  54. adjustLabourCost: [{required: true,pattern:/^[1-9]\d{0,14}(\.\d{1,16})?$|^0(\.\d{1,16})?$/, message: ' ', trigger: ['change','blur']}],
  55. adjustToolCost: [{required: true,pattern:/^[1-9]\d{0,14}(\.\d{1,16})?$|^0(\.\d{1,16})?$/, message: ' ', trigger: ['change','blur']}],
  56. detailManageCost: [{required: true,pattern:/^[1-9]\d{0,14}(\.\d{1,16})?$|^0(\.\d{1,16})?$/, message: ' ', trigger: ['change','blur']}],
  57. detailOtherCost: [{required: true,pattern:/^[1-9]\d{0,14}(\.\d{1,16})?$|^0(\.\d{1,16})?$/, message: ' ', trigger: ['change','blur']}],
  58. taxRate: [{required: true, message: ' ', trigger: ['change','blur']}],
  59. },
  60. quotationDetailColumns: [
  61. {label: "productDesc", value: "产品名称"},
  62. {label: "quotationDetailQuantity", value: "报价数量"},
  63. {label: "internalInquiryNo", value: "内部询价单号"},
  64. {label: "quotationDetailStatus", value: "报价状态"},
  65. {label: "itemNo", value: "序号"},
  66. {label: "adjustPartCost", value: "调整后的材料成本"},
  67. {label: "adjustMachineCost", value: "调整后的机器成本"},
  68. {label: "adjustFabricateCost", value: "调整后的制造费用"},
  69. {label: "adjustLabourCost", value: "调整后人的工成本"},
  70. {label: "adjustToolCost", value: "调整后的工具成本"},
  71. {label: "detailManageCost", value: "管理成本"},
  72. {label: "detailOtherCost", value: "其他成本"},
  73. {label: "detailProfitRate", value: "利润率"},
  74. {label: "finalUntaxedPrice", value: "最终去税价格"},
  75. ],
  76. copyPackCost:0,
  77. copyShippingCost:0,
  78. }
  79. },
  80. computed: {
  81. copyDetail: {
  82. get() {
  83. return this.detail
  84. },
  85. set(val) {
  86. }
  87. }
  88. },
  89. methods:{
  90. ruleCostForm(){
  91. let flag = false;
  92. this.$refs.costForm.validate((validate,objects)=>{
  93. if (!validate){
  94. this.rulesValidateLabel(objects, this.quotationDetailColumns);
  95. }
  96. flag = validate;
  97. })
  98. return flag;
  99. },
  100. restCostForm(){
  101. this.$refs.costForm.resetFields();
  102. },
  103. getQuotationDetail(){
  104. return JSON.parse(JSON.stringify(this.copyDetail));
  105. },
  106. rulesValidateLabel(objects, labels) {
  107. for (let filed in objects) {
  108. for (let i = 0; i < labels.length; i++) {
  109. let quotationToolColumn = labels[i];
  110. if (quotationToolColumn.label === filed) {
  111. this.$message.warning(quotationToolColumn.value+"为空或填写不正确");
  112. return
  113. }
  114. }
  115. }
  116. },
  117. computeCost(){
  118. //材料成本
  119. this.copyDetail.computePartCost = new Decimal(new Decimal(this.bomCost).mul(new Decimal(this.detail.quotationDetailQuantity)).toFixed(4,Decimal.ROUND_HALF_UP)).toNumber()
  120. this.copyDetail.adjustPartCost = new Decimal(new Decimal(this.bomCost).mul(new Decimal(this.detail.quotationDetailQuantity)).toFixed(4,Decimal.ROUND_HALF_UP)).toNumber()
  121. // 机器成本
  122. this.copyDetail.computeMachineCost = new Decimal(this.machineCost).mul(new Decimal(this.detail.quotationDetailQuantity))
  123. this.copyDetail.adjustMachineCost = new Decimal(this.machineCost).mul(new Decimal(this.detail.quotationDetailQuantity))
  124. this.copyDetail.computeMachineCost = new Decimal(this.copyDetail.computeMachineCost.toFixed(4,Decimal.ROUND_HALF_UP)).toNumber()
  125. this.copyDetail.adjustMachineCost = new Decimal(this.copyDetail.adjustMachineCost.toFixed(4,Decimal.ROUND_HALF_UP)).toNumber()
  126. // 制作费用
  127. this.copyDetail.computeFabricateCost = new Decimal(this.manufacturingCost).mul(new Decimal(this.detail.quotationDetailQuantity))
  128. this.copyDetail.adjustFabricateCost = new Decimal(this.manufacturingCost).mul(new Decimal(this.detail.quotationDetailQuantity))
  129. this.copyDetail.computeFabricateCost = new Decimal(this.copyDetail.computeFabricateCost.toFixed(4,Decimal.ROUND_HALF_UP)).toNumber()
  130. this.copyDetail.adjustFabricateCost = new Decimal(this.copyDetail.adjustFabricateCost.toFixed(4,Decimal.ROUND_HALF_UP)).toNumber()
  131. // 人工费用
  132. this.copyDetail.computeLabourCost = new Decimal(this.laborCost).mul(new Decimal(this.detail.quotationDetailQuantity))
  133. this.copyDetail.adjustLabourCost = new Decimal(this.laborCost).mul(new Decimal(this.detail.quotationDetailQuantity))
  134. this.copyDetail.computeLabourCost = new Decimal(this.copyDetail.computeLabourCost.toFixed(4,Decimal.ROUND_HALF_UP)).toNumber()
  135. this.copyDetail.adjustLabourCost = new Decimal(this.copyDetail.adjustLabourCost.toFixed(4,Decimal.ROUND_HALF_UP)).toNumber()
  136. // 工具成本
  137. this.copyDetail.computeToolCost = new Decimal(this.toolCost).mul(new Decimal(this.detail.quotationDetailQuantity))
  138. this.copyDetail.adjustToolCost = new Decimal(this.toolCost).mul(new Decimal(this.detail.quotationDetailQuantity))
  139. this.copyDetail.computeToolCost = new Decimal(this.copyDetail.computeToolCost.toFixed(4,Decimal.ROUND_HALF_UP)).toNumber()
  140. this.copyDetail.adjustToolCost = new Decimal(this.copyDetail.adjustToolCost.toFixed(4,Decimal.ROUND_HALF_UP)).toNumber()
  141. // 其他成本
  142. this.copyDetail.detailOtherCost = new Decimal(new Decimal(new Decimal(this.shippingCost).add(new Decimal(this.packCost)).mul(new Decimal(this.detail.quotationDetailQuantity))).toFixed(4,Decimal.ROUND_HALF_UP)).toSignificantDigits().toNumber()
  143. this.copyPackCost = new Decimal(new Decimal(new Decimal(new Decimal(this.packCost)).mul(new Decimal(this.detail.quotationDetailQuantity))).toFixed(4,Decimal.ROUND_HALF_UP)).toSignificantDigits().toNumber()
  144. this.copyShippingCost = new Decimal(new Decimal(new Decimal(this.shippingCost).mul(new Decimal(this.detail.quotationDetailQuantity))).toFixed(4,Decimal.ROUND_HALF_UP)).toSignificantDigits().toNumber()
  145. // 管理成本
  146. if (!this.copyDetail.detailManageCost){
  147. this.copyDetail.detailManageCost = 0;
  148. }
  149. // 利润率
  150. if (!this.copyDetail.detailProfitRate){
  151. this.copyDetail.detailProfitRate = 0;
  152. }
  153. this.computeAllCost();
  154. },
  155. computeAllCost(){
  156. this.computedTotalCost();// 总成本
  157. this.computedAmountOfProfitCost();//利润额
  158. this.computedUntaxedCost();//未税总额和单价
  159. this.computedTaxedCost();//含税总额和单价
  160. },
  161. // 计算总成本
  162. computedTotalCost(){
  163. this.copyDetail.detailTotalCost = new Decimal(this.copyDetail.adjustPartCost)
  164. .add(new Decimal(this.copyDetail.adjustMachineCost))
  165. .add(new Decimal(this.copyDetail.adjustFabricateCost))
  166. .add(new Decimal(this.copyDetail.adjustLabourCost))
  167. .add(new Decimal(this.copyDetail.adjustToolCost))
  168. .add(new Decimal(this.copyDetail.detailManageCost))
  169. .add(new Decimal(this.copyDetail.detailOtherCost))
  170. this.copyDetail.detailTotalCost = new Decimal(this.copyDetail.detailTotalCost.toFixed(4,Decimal.ROUND_HALF_UP)).toNumber()
  171. },
  172. computedAmountOfProfitCost(){
  173. this.copyDetail.detailProfitAmount = new Decimal(this.copyDetail.detailTotalCost)
  174. .mul(
  175. this.copyDetail.detailProfitRate===0
  176. ?new Decimal(this.copyDetail.detailProfitRate)
  177. :new Decimal(this.copyDetail.detailProfitRate).div(new Decimal(100))
  178. )
  179. this.copyDetail.detailProfitAmount = new Decimal(this.copyDetail.detailProfitAmount.toFixed(4,Decimal.ROUND_HALF_UP)).toNumber()
  180. },
  181. computedUntaxedCost(){
  182. this.copyDetail.systemComputeAmount =
  183. new Decimal(this.copyDetail.detailTotalCost)
  184. .add(new Decimal(this.copyDetail.detailProfitAmount));
  185. this.copyDetail.systemComputeAmount = new Decimal(this.copyDetail.systemComputeAmount.toFixed(6,Decimal.ROUND_HALF_UP)).toNumber()
  186. this.copyDetail.finalUntaxedPrice =
  187. new Decimal(this.copyDetail.systemComputeAmount)
  188. .div(new Decimal(this.copyDetail.quotationDetailQuantity));
  189. this.copyDetail.finalUntaxedPrice = new Decimal(this.copyDetail.finalUntaxedPrice.toFixed(4,Decimal.ROUND_HALF_UP)).toNumber()
  190. },
  191. computedTaxedCost(){
  192. this.copyDetail.systemComputePrice =
  193. new Decimal(this.copyDetail.systemComputeAmount)
  194. .add(new Decimal(this.copyDetail.systemComputeAmount)
  195. .mul(
  196. this.copyDetail.taxRate===0
  197. ?new Decimal(this.copyDetail.taxRate)
  198. :new Decimal(this.copyDetail.taxRate).div(new Decimal(100))
  199. )
  200. );
  201. this.copyDetail.systemComputePrice = new Decimal(this.copyDetail.systemComputePrice.toFixed(6,Decimal.ROUND_HALF_UP)).toNumber()
  202. this.copyDetail.finalTaxedPrice =
  203. new Decimal(this.copyDetail.systemComputePrice)
  204. .div(new Decimal(this.copyDetail.quotationDetailQuantity));
  205. this.copyDetail.finalTaxedPrice = new Decimal(this.copyDetail.finalTaxedPrice.toFixed(4,Decimal.ROUND_HALF_UP)).toNumber()
  206. }
  207. }
  208. }
  209. </script>
  210. <template>
  211. <div>
  212. <div>
  213. <el-button type="primary" :loading="loadingStatus" @click="computeCost"> </el-button>
  214. </div>
  215. <!--系统自动计算结果-->
  216. <el-form :model="copyDetail" ref="costForm" :rules="rules" label-position="top" label-width="120px">
  217. <fieldset
  218. style="height:80px;margin-top: 2px;">
  219. <legend>系统自动计算结果(料工费/工具)</legend>
  220. <el-row :gutter="20">
  221. <el-col :span="4">
  222. <el-form-item label="材料成本:" prop="computePartCost">
  223. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false"
  224. v-model="copyDetail.computePartCost" :precision="4" disabled/>
  225. </el-form-item>
  226. </el-col>
  227. <el-col :span="4">
  228. <el-form-item label="机器成本:" prop="computeMachineCost">
  229. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false"
  230. v-model="copyDetail.computeMachineCost" :precision="4" disabled/>
  231. </el-form-item>
  232. </el-col>
  233. <el-col :span="4">
  234. <el-form-item label="制造费用成本:" prop="computeFabricateCost">
  235. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false"
  236. v-model="copyDetail.computeFabricateCost" :precision="4" disabled/>
  237. </el-form-item>
  238. </el-col>
  239. <el-col :span="4">
  240. <el-form-item label="人工成本:" prop="computeLabourCost">
  241. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false"
  242. v-model="copyDetail.computeLabourCost" :precision="4" disabled/>
  243. </el-form-item>
  244. </el-col>
  245. <el-col :span="4">
  246. <el-form-item label="工具成本:" prop="computeToolCost">
  247. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false"
  248. v-model="copyDetail.computeToolCost" :precision="4" disabled/>
  249. </el-form-item>
  250. </el-col>
  251. </el-row>
  252. </fieldset>
  253. <fieldset
  254. style="height:80px;margin-top: 5px;">
  255. <legend>调整后成本(料工费/工具)</legend>
  256. <el-row :gutter="20">
  257. <el-col :span="4">
  258. <el-form-item label="材料成本:" prop="adjustPartCost">
  259. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false" @blur="computeAllCost"
  260. v-model="copyDetail.adjustPartCost" :step="0" :precision="4" :min="0"/>
  261. </el-form-item>
  262. </el-col>
  263. <el-col :span="4">
  264. <el-form-item label="机器成本:" prop="adjustMachineCost">
  265. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false" @blur="computeAllCost"
  266. v-model="copyDetail.adjustMachineCost" :step="0" :precision="4" :min="0"/>
  267. </el-form-item>
  268. </el-col>
  269. <el-col :span="4">
  270. <el-form-item label="制造费用成本:" prop="adjustFabricateCost">
  271. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false" @blur="computeAllCost"
  272. v-model="copyDetail.adjustFabricateCost" :step="0" :precision="4" :min="0"/>
  273. </el-form-item>
  274. </el-col>
  275. <el-col :span="4">
  276. <el-form-item label="人工成本:" prop="adjustLabourCost">
  277. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false" @blur="computeAllCost"
  278. v-model="copyDetail.adjustLabourCost" :step="0" :precision="4" :min="0"/>
  279. </el-form-item>
  280. </el-col>
  281. <el-col :span="4">
  282. <el-form-item label="工具成本:" prop="adjustToolCost">
  283. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false" @blur="computeAllCost"
  284. v-model="copyDetail.adjustToolCost" :step="0" :precision="4" :min="0"/>
  285. </el-form-item>
  286. </el-col>
  287. </el-row>
  288. </fieldset>
  289. <fieldset
  290. style="height:80px;margin-top: 5px;">
  291. <legend>其他成本</legend>
  292. <el-row :gutter="20">
  293. <el-col :span="4">
  294. <el-form-item label="管理成本:" prop="detailManageCost">
  295. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false" @blur="computeAllCost"
  296. v-model="copyDetail.detailManageCost" :step="0" :precision="4" :min="0"/>
  297. </el-form-item>
  298. </el-col>
  299. <el-col :span="4">
  300. <el-form-item label="包装成本:" >
  301. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false"
  302. v-model="copyPackCost" :step="0" :precision="4" :min="0" disabled/>
  303. </el-form-item>
  304. </el-col>
  305. <el-col :span="4">
  306. <el-form-item label="运输成本:" >
  307. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false"
  308. v-model="copyShippingCost" :step="0" :precision="4" :min="0" disabled/>
  309. </el-form-item>
  310. </el-col>
  311. <el-col :span="4">
  312. <el-form-item label="其他成本:" prop="detailOtherCost">
  313. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false" @blur="computeAllCost"
  314. v-model="copyDetail.detailOtherCost" :step="0" :precision="4" :min="0"/>
  315. </el-form-item>
  316. </el-col>
  317. <el-col :span="4">
  318. <el-form-item label="总成本:" prop="detailTotalCost">
  319. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false"
  320. v-model="copyDetail.detailTotalCost" :step="0" :precision="4" :min="0" disabled/>
  321. </el-form-item>
  322. </el-col>
  323. </el-row>
  324. </fieldset>
  325. <fieldset style="height:80px;margin-top: 5px;">
  326. <legend>利润</legend>
  327. <el-row :gutter="20">
  328. <el-col :span="4">
  329. <el-form-item label="利润率%:" prop="detailProfitRate">
  330. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false" @blur="computeAllCost"
  331. v-model="copyDetail.detailProfitRate" :step="0" :min="0"/>
  332. </el-form-item>
  333. </el-col>
  334. <el-col :span="4">
  335. <el-form-item label="利润额:" prop="detailProfitAmount">
  336. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false"
  337. v-model="copyDetail.detailProfitAmount" :step="0" :precision="4" :min="0" disabled/>
  338. </el-form-item>
  339. </el-col>
  340. </el-row>
  341. </fieldset>
  342. <fieldset style="height:80px;margin-top: 5px;">
  343. <legend>最终价格</legend>
  344. <el-row :gutter="20">
  345. <el-col :span="4">
  346. <el-form-item label="未税总额:" prop="systemComputeAmount">
  347. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false"
  348. v-model="copyDetail.systemComputeAmount" :step="0" :precision="4" :min="0" disabled/>
  349. </el-form-item>
  350. </el-col>
  351. <el-col :span="4">
  352. <el-form-item label="未税单价:" prop="finalUntaxedPrice">
  353. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false"
  354. v-model="copyDetail.finalUntaxedPrice" :step="0" :min="0" :precision="6" disabled/>
  355. </el-form-item>
  356. </el-col>
  357. <el-col :span="4">
  358. <el-form-item label="税率%:" prop="taxRate">
  359. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false" @blur="computeAllCost"
  360. v-model="copyDetail.taxRate" :step="0" :min="0"/>
  361. </el-form-item>
  362. </el-col>
  363. <el-col :span="4">
  364. <el-form-item label="含税总额:" prop="systemComputePrice">
  365. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false"
  366. v-model="copyDetail.systemComputePrice" :step="0" :precision="4" :min="0" disabled/>
  367. </el-form-item>
  368. </el-col>
  369. <el-col :span="4">
  370. <el-form-item label="含税单价:" prop="finalTaxedPrice">
  371. <el-input-number style="width: 100%;margin-top: -5px;" :controls="false"
  372. v-model="copyDetail.finalTaxedPrice" :step="0" :precision="6" :min="0" disabled/>
  373. </el-form-item>
  374. </el-col>
  375. </el-row>
  376. </fieldset>
  377. </el-form>
  378. </div>
  379. </template>
  380. <style scoped>
  381. .el-input-number /deep/ .el-input__inner {
  382. text-align: right;
  383. padding-right: 5px !important;
  384. }
  385. form fieldset{
  386. border: 1px solid #000;
  387. }
  388. </style>