{"version":3,"file":"pages/home/myDetail/enquiryDetail.js","sources":["webpack:///./utils/price.js","webpack:///./pages/home/myDetail/enquiryDetail.vue?d31b","webpack:///./pages/home/myDetail/enquiryDetail.vue?5bcf","webpack:///./pages/home/myDetail/enquiryDetail.vue?eb8f","webpack:///./pages/home/myDetail/enquiryDetail.vue?f70e","webpack:///./pages/home/myDetail/enquiryDetail.vue","webpack:///./pages/home/myDetail/enquiryDetail.vue?47f8","webpack:///./pages/home/myDetail/enquiryDetail.vue?52f4"],"sourcesContent":["// 商品价格计算相关\nimport { times, plus, minus, divide } from 'number-precision'\n\n// 价格格式化\nexport function formatPrice(value, needSymbol = true) {\n // 不能在最后一步显示之前格式化999 111, 否则可能出现单价1买999个得到999价格被格式化成poa的情况\n if (value === 0) {\n return needSymbol ? '£0.00' : '0.00'\n } else {\n return needSymbol ? `£${value}` : `${value}`\n }\n}\n\n// 简单的乘法换算\nfunction multiply(value, ratio = 100) {\n return parseFloat((value * ratio).toPrecision(12))\n}\n// 小数处理, 四舍五入, 为toFixed做准备\nexport function round(number, ratio = 100) {\n return Math.round(multiply(number, ratio)) / ratio\n}\n\n/**\n * 将字符串简单转换成数字, 并可数倍转换. 注意, 这个适用于整数倍(商品件数), 非整数的不能用这个处理小数.\n * @param {*} value 目标值\n * @param {*} ratio 倍数, 默认1\n * @returns number | origin, 转换后的数字, 无法转成数字的返回原值\n */\nexport function transformNumber(value, ratio = 1) {\n const v = Number(value)\n if (Number.isNaN(v)) {\n return value\n } else {\n // 保留两位小数\n return divide(Math.trunc(times(times(v, ratio), 100)), 100)\n }\n}\n\n// unit 单个商品的, 没有乘数量. 因为含有111 999 这些极端值, 没有格式化输出之前直接乘回出问题的.\nexport const getUnit = function (buyNum, index, attributeList, basePriceList) {\n // 算出购买数量位于 价格阶梯的 哪个区间\n const candidate = Object.entries(attributeList).filter(\n item => buyNum >= item[1]\n )\n\n let key = 'website_qty1'\n if (candidate.length) {\n key = candidate.pop()[0]\n }\n\n return transformNumber(basePriceList[index][key], buyNum)\n}\n\n// 打印和附加价格 的steup之和. 商品基础价格现在没有setup了.\nexport const getSetup = function (buyNum, form, additionList) {\n const sum = Object.entries(form).reduce((total, current) => {\n let s = 0\n // 打印服务表单的数据跟附加服务表单的数据结构不一致, 以数字id字符串键名的是打印服务的数据\n if (/\\d+/.test(current[0]) && current[1].enable) {\n const temp = current[1].colorForm.filter(\n i => i.id === current[1].printService\n )\n let colorNumber = 1\n if (temp.length) {\n colorNumber = temp[0].colorNumber\n }\n\n const decoration = current[1].decorationList.filter(\n i => i.id === current[1].printService\n )\n let setup = 0\n if (decoration.length) {\n setup = plus(\n Number(decoration[0].website_setup),\n times(Number(decoration[0].supplier_setup), colorNumber - 1)\n )\n }\n s = plus(s, setup)\n } else if (current[1].length) {\n // 附加服务的表单数据, 有值说明该项有选中了附加服务\n const addition = additionList[current[0]].filter(addition =>\n current[1].includes(addition.id)\n )\n\n if (addition.length) {\n const temp = addition.reduce((t, c) => {\n let value = Number(c.website_setup)\n if ([5, 6].includes(c.website_setup_id)) {\n // 5是poa, 6是waived. 这种情况一般setup是留空的, 不留空大概是异常数据, 重置0保险一点.\n value = 0\n }\n return plus(t, Number.isNaN(value) ? 0 : value)\n }, 0)\n\n s = plus(s, temp)\n }\n }\n\n total = plus(total, s)\n return total\n }, 0)\n return transformNumber(sum)\n}\n\n// 打印价格的 阶梯基础价*购买数量.\nexport const getPrint = function (buyNum, form, attributeList) {\n // 算出购买数量位于 价格阶梯的 哪个区间\n const candidate = Object.entries(attributeList).filter(\n item => buyNum >= item[1]\n )\n const key = `website_qty${candidate.length}`\n const key2 = `supplier_qty${candidate.length}`\n\n // 如果其中一项为POA, 则‘和’都是POA\n const result = Object.entries(form).reduce((total, current) => {\n if (total === 'POA') {\n return total\n }\n let sum = 0\n if (/\\d+/.test(current[0]) && current[1].enable) {\n const temp = current[1].colorForm.filter(\n i => i.id === current[1].printService\n )\n let colorNumber = 1\n if (temp.length) {\n colorNumber = temp[0].colorNumber\n }\n\n const decoration = current[1].decorationList.filter(\n i => i.id === current[1].printService\n )\n // 打印价格的基础价. 其中数字111(代表'-') 和999(代表'POA')\n const p1 = transformNumber(decoration[0][key])\n if (p1 === 999 || p1 === 111 || typeof p1 !== 'number') {\n return 'POA'\n }\n // 打印价格的附加价\n const p2 = transformNumber(decoration[0][key2])\n if (p2 === 999 || p2 === 111 || typeof p2 !== 'number') {\n return 'POA'\n }\n let price = 0\n if (decoration.length) {\n price = plus(p1, times(p2, colorNumber - 1))\n }\n sum = plus(sum, price)\n }\n total = plus(total, sum)\n return total\n }, 0)\n\n return transformNumber(result, buyNum)\n}\n// 附加服务除了packing之外的总价\nexport const getAddon = function (buyNum, form, attributeList, additionList) {\n // 算出购买数量位于 价格阶梯的 哪个区间\n const candidate = Object.entries(attributeList).filter(\n item => buyNum >= item[1]\n )\n const key = `website_qty${candidate.length}`\n const result = Object.entries(form).reduce((total, current) => {\n if (total === 'POA') {\n return total\n }\n\n let sum = 0\n if (!/\\d+/.test(current[0]) && current[0] !== 'packaging') {\n sum = additionList[current[0]]\n .filter(item => current[1].includes(item.id))\n .reduce((t, c) => {\n if (t === 'POA') {\n return t\n }\n let temp = transformNumber(c[key])\n if (temp === 999 || temp === 111 || typeof temp !== 'number') {\n temp = 0\n return 'POA'\n }\n t = plus(t, temp)\n return t\n }, 0)\n }\n return plus(total, sum)\n }, 0)\n\n return transformNumber(result, buyNum)\n}\n// 附加服务中 packing 的价格\nexport const getPackaging = function (\n buyNum,\n form,\n attributeList,\n additionList\n) {\n // 算出购买数量位于 价格阶梯的 哪个区间\n const candidate = Object.entries(attributeList).filter(\n item => buyNum >= item[1]\n )\n const key = `website_qty${candidate.length}`\n const result = Object.entries(form).reduce((total, current) => {\n if (total === 'POA') {\n return total\n }\n\n let sum = 0\n if (!/\\d+/.test(current[0]) && current[0] === 'packaging') {\n sum = additionList[current[0]]\n .filter(item => current[1].includes(item.id))\n .reduce((t, c) => {\n if (t === 'POA') {\n return t\n }\n let temp = transformNumber(c[key])\n if (temp === 999 || temp === 111 || typeof temp !== 'number') {\n temp = 0\n return 'POA'\n }\n t = plus(t, temp)\n return t\n }, 0)\n }\n return plus(total, sum)\n }, 0)\n\n return transformNumber(result, buyNum)\n}\n\n// 运费计算. 从product页面抄过来的逻辑. +号是隐式类型转换\nexport const getFright = function (buyNum, config, freight, weight, ratio = 1) {\n // 单独批次数量的总重\n const totalWeight = Math.ceil(times(+weight.unit_w_local, buyNum))\n\n const expressFactor = plus(\n 1,\n divide(plus(+config.express_freight, +config.fuel), 100)\n )\n\n const AAEFactor = plus(\n 1,\n divide(plus(+config.bag_freight, +config.fuel), 100)\n )\n let frightCost = 0\n\n if (freight.type === 1) {\n if (totalWeight > 20) {\n const a1 = minus(totalWeight, 20)\n const a2 = times(a1, +freight.basic)\n const a3 = plus(+freight.pickup, a2)\n frightCost = times(a3, expressFactor)\n } else {\n frightCost = times(+freight.pickup, expressFactor)\n }\n } else if (freight.type === 2) {\n const a1 = times(totalWeight, +freight.basic)\n const a2 = plus(+freight.pickup, a1)\n frightCost = times(a2, AAEFactor)\n } else {\n frightCost = 0\n }\n return transformNumber(frightCost, ratio)\n}\n","// Exports\nmodule.exports = {\n\n};\n","// Exports\nmodule.exports = {\n\n};\n","export * from \"-!../../../node_modules/css-loader/dist/cjs.js??ref--7-oneOf-1-0!../../../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../../../node_modules/postcss-loader/dist/cjs.js??ref--7-oneOf-1-1!../../../node_modules/sass-loader/dist/cjs.js??ref--7-oneOf-1-2!../../../node_modules/@nuxt/components/dist/loader.js??ref--0-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./enquiryDetail.vue?vue&type=style&index=0&id=0826eaac&prod&lang=scss\"","export * from \"-!../../../node_modules/css-loader/dist/cjs.js??ref--7-oneOf-1-0!../../../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../../../node_modules/postcss-loader/dist/cjs.js??ref--7-oneOf-1-1!../../../node_modules/sass-loader/dist/cjs.js??ref--7-oneOf-1-2!../../../node_modules/@nuxt/components/dist/loader.js??ref--0-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./enquiryDetail.vue?vue&type=style&index=1&id=0826eaac&prod&lang=scss&scoped=true\"","var render = function render(){var _vm=this,_c=_vm._self._c;return _c('div',{staticClass:\"page-enquiry-detail com-main com-margin-auto\"},[_c('el-breadcrumb',{attrs:{\"separator-class\":\"el-icon-arrow-right\"}},[_c('el-breadcrumb-item',{attrs:{\"to\":{ path: '/' }}},[_vm._v(\"Home\")]),_vm._v(\" \"),_c('el-breadcrumb-item',{attrs:{\"to\":{ path: '/home/myDetail', query: { type: 'enquiry' } }}},[_vm._v(\"My Enquiry\")]),_vm._v(\" \"),_c('el-breadcrumb-item',[_vm._v(\"detail\")])],1),_vm._ssrNode(\" \"),(_vm.loading)?_c('div',{directives:[{name:\"loading\",rawName:\"v-loading\",value:(_vm.loadiding),expression:\"loadiding\"}],staticClass:\"com-loading\"},[]):_vm._e(),_vm._ssrNode(\" \"),(!_vm.loading)?_vm._ssrNode(\"
Enquiries Information
\"+_vm._ssrEscape(_vm._s(_vm.detail.Website_Message))+\"
\\n Artwork link:\\n \"+_vm._ssrEscape(_vm._s(_vm.detail.Artworklink))+\"
Sub Total | \"+_vm._ssrEscape(\"\\n \"+_vm._s(_vm.detail.Currency)+\" \\n \")+\" \"+_vm._ssrEscape(\"\\n \"+_vm._s(_vm.transformNumber(\n _vm.detail.Quotes_Information\n .quotecalculation__Sub_Total_Amount\n ))+\"\\n \")+\" |
Total Taxes | \"+_vm._ssrEscape(\"\\n \"+_vm._s(_vm.detail.Currency)+\" \\n \")+\" \"+_vm._ssrEscape(\"\\n \"+_vm._s(_vm.transformNumber(_vm.detail.Quotes_Information.Tax_Total))+\"\\n \")+\" |
Total Discount | \"+_vm._ssrEscape(\"\\n \"+_vm._s(_vm.detail.Currency)+\" \\n \")+\" \"+_vm._ssrEscape(\"\\n \"+_vm._s(_vm.transformNumber(_vm.detail.Quotes_Information.Discount_Amount))+\"\\n \")+\" |
Adjustment | \"+_vm._ssrEscape(\"\\n \"+_vm._s(_vm.detail.Currency)+\" \\n \")+\" \"+_vm._ssrEscape(\"\\n \"+_vm._s(_vm.transformNumber(_vm.detail.Quotes_Information.Adjustment))+\"\\n \")+\" |
Grand Total | \"+_vm._ssrEscape(\"\\n \"+_vm._s(_vm.detail.Currency)+\" \\n \")+\" \"+_vm._ssrEscape(\"\\n \"+_vm._s(_vm.transformNumber(\n _vm.detail.Quotes_Information.Total_Including_Tax\n ))+\"\\n \")+\" |