diff --git a/package.json b/package.json index 71c4192..0e9ad07 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "author": "Pan ", "scripts": { "dev": "vue-cli-service serve", - "build:prod": "vue-cli-service build" + "build": "vue-cli-service build" }, "dependencies": { "@amap/amap-jsapi-loader": "^1.0.1", diff --git a/src/permission.js b/src/permission.js index f3145ab..508be07 100644 --- a/src/permission.js +++ b/src/permission.js @@ -1,79 +1,79 @@ -import router from "./router"; -import store from "./store"; -import NProgress from "nprogress"; // progress bar -import "nprogress/nprogress.css"; // progress bar style -import getPageTitle from "@/utils/get-page-title"; +import router from './router' +import store from './store' +import NProgress from 'nprogress' // progress bar +import 'nprogress/nprogress.css' // progress bar style +import getPageTitle from '@/utils/get-page-title' -import Layout from "@/layout"; +import Layout from '@/layout' -import serve from "api/login.js"; +import serve from 'api/login.js' -NProgress.configure({ showSpinner: false }); // NProgress Configuration +NProgress.configure({ showSpinner: false }) // NProgress Configuration -const whiteList = ["/login"]; // no redirect whitelist +const whiteList = ['/login'] // no redirect whitelist router.beforeEach(async (to, from, next) => { - NProgress.start(); - document.title = getPageTitle(to.meta.title); - const hasToken = localStorage.getItem("businessToken"); + NProgress.start() + document.title = getPageTitle(to.meta.title) + const hasToken = localStorage.getItem('businessToken') if (hasToken) { - if (to.path === "/login") { - next({ path: "/" }); - NProgress.done(); + if (to.path === '/login') { + next({ path: '/' }) + NProgress.done() } else { - const hasAuth = store.getters.auth && store.getters.auth.length; + const hasAuth = store.getters.auth && store.getters.auth.length if (hasAuth) { - next(); + next() } else { try { // let infoRes = await serve.getUserInfo(); // infoRes.data.authList = [1]; - let infoRes = await serve.info(); + let infoRes = await serve.info() // infoRes.data.authList = infoRes.authList; - store.dispatch("user/info", infoRes.data); + store.dispatch('user/info', infoRes.data) - let routerRes = await serve.getCustomerRouters(); - let realRouter = filterAsyncRouter(routerRes.data); - store.dispatch("permission/generateRoutes", realRouter); - router.addRoutes(realRouter); - next({ ...to, replace: true }); + let routerRes = await serve.getCustomerRouters() + let realRouter = filterAsyncRouter(routerRes.data) + store.dispatch('permission/generateRoutes', realRouter) + router.addRoutes(realRouter) + next({ ...to, replace: true }) } catch (err) { - console.log("catch"); - next("/login"); - NProgress.done(); + console.log('catch') + // next("/login"); + NProgress.done() } } } } else { if (whiteList.includes(to.path)) { - next(); + next() } else { - next("/login"); - NProgress.done(); + next('/login') + NProgress.done() } } -}); +}) router.afterEach(() => { - NProgress.done(); -}); + NProgress.done() +}) function filterAsyncRouter(routers) { - return routers.map((route) => { + return routers.map(route => { if (route.component) { - if (route.component === "Layout") { - route.component = Layout; + if (route.component === 'Layout') { + route.component = Layout } else { - route.component = lazyLoad(route.component); + route.component = lazyLoad(route.component) } } if (route.children && route.children.length) { - route.children = filterAsyncRouter(route.children); + route.children = filterAsyncRouter(route.children) } - return route; - }); + return route + }) } function lazyLoad(path) { - return (resolve) => require([`@/views/${path}`], resolve); + return resolve => require([`@/views/${path}`], resolve) } diff --git a/src/views/order/components/billOfLading.vue b/src/views/order/components/billOfLading.vue index 200fe5b..bf8d79c 100644 --- a/src/views/order/components/billOfLading.vue +++ b/src/views/order/components/billOfLading.vue @@ -11,9 +11,9 @@ - - {{ orderTagType(billData.orderInfo.orderStatus).orderLabel }} - + {{ + orderTagType(billData.orderInfo.orderStatus).orderLabel + }}
@@ -127,9 +127,8 @@ :disabled="item.deliveryStatus !== 'PLATENUM_LOCKED' && item.deliveryStatus !== 'PLATENUM_SUCCESS'" @click="billSubmit(item, index)" :type="orderTagType(item.deliveryStatus).type1" + >{{ orderTagType(item.deliveryStatus).info }} - {{ orderTagType(item.deliveryStatus).info }} -
@@ -194,6 +193,7 @@ 取 消 + 确 定 @@ -359,6 +359,20 @@ export default { created() {}, methods: { billdelivery() { + let percentage103 = (this.billAddData.preDeliveryQuantity * 10000 * 1.03) / 10000 + if (this.deliveryQuantity > percentage103) { + this.$confirm('实际提货量超出预约提货量103%, 是否确认?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + this.realBilldelivery() + }) + return + } + this.realBilldelivery() + }, + realBilldelivery() { this.billAddData.deliveryStatus = 'COMPLETE' this.billAddData.accDeliveryQuantity = this.deliveryQuantity order.update(this.billAddData).then(res => { diff --git a/src/views/order/components/confirmSubmit.vue b/src/views/order/components/confirmSubmit.vue index a54666f..a062d5b 100644 --- a/src/views/order/components/confirmSubmit.vue +++ b/src/views/order/components/confirmSubmit.vue @@ -30,7 +30,9 @@ - {{ controlWindows.addInfo.salePrice }}元 + {{ controlWindows.addInfo.salePrice }} 元/{{ controlWindows.addInfo.productMeasurement }} {{ controlWindows.addInfo.preQuantity | toNumberFixed }} {{ controlWindows.addInfo.productMeasurement }} @@ -44,27 +46,38 @@

订单变更信息

因炼厂单价发生变化,请重新选择策略

- - + + - - + + - + - + - + - + @@ -84,30 +97,37 @@ export default { }, data() { return { - newCostPrice: '', - newSalePrice: '', + // newCostPrice: '', + // newSalePrice: '', undergoChanges: false, tableData: [ { isChecked: false, type: '原策略', - salePrice: 100, - preQuantity: 100, - preAmount: 10000 + salePrice: '', + preQuantity: '', + preAmount: '' }, { isChecked: false, type: '以提货量为准', - salePrice: 100, - preQuantity: 100, - preAmount: 10000 + salePrice: '', + preQuantity: '', + preAmount: '' }, + // { + // isChecked: false, + // type: '以订单金额为准', + // salePrice: '', + // preQuantity: '', + // preAmount: '' + // }, { isChecked: false, - type: '以订单金额为准', - salePrice: 100, - preQuantity: 100, - preAmount: 10000 + type: '自定义提货量', + salePrice: '', + preQuantity: '', + preAmount: '' } ] } @@ -117,7 +137,7 @@ export default { if (val) { return Number(val).toFixed(2) } else { - return '--' + return '- -' } } }, @@ -126,17 +146,25 @@ export default { let { productId, salePrice, floorPrice } = this.controlWindows.addInfo if (productId) { serve.getRefineryProduct(productId).then(res => { - let data = res.data; + let data = res.data if (data.salePrice2company != salePrice || data.floorPrice != floorPrice) { - console.log('价格发生变化了捏') - // 新的价格 - this.newSalePrice = data.salePrice2company - this.newCostPrice = data.floorPrice - this.policyPopulation() - } else console.log('芜湖 没变') + this.policyPopulation(data.salePrice2company, data.floorPrice) + } }) } }, + changePreQuantity(row, val) { + let segment = val.match(/.?\d{0,2}/g) + let realPrice = parseFloat(segment[0] + segment[1]) + if (isNaN(realPrice)) { + this.$message.error('数量输入错误,请重新输入') + return + } + let { salePrice, floorPrice } = row + row.preQuantity = realPrice + row.preAmount = this.fixedHandle(salePrice * realPrice) + row.preCostAmount = this.fixedHandle(floorPrice * realPrice) + }, selectPolicy(index, val) { if (val) { this.tableData.map(item => (item.isChecked = false)) @@ -144,32 +172,78 @@ export default { } }, // 策略选择 - policyPopulation() { + policyPopulation(newSalePrice, newCostPrice) { let { salePrice, floorPrice, preQuantity, preAmount } = this.controlWindows.addInfo - // console.log(salePrice, preQuantity, preAmount) - if ((salePrice, preQuantity, preAmount)) { - // 原策略 - Object.assign(this.tableData[0], { salePrice: salePrice.toFixed(2), - floorPrice: floorPrice.toFixed(2), - preQuantity: preQuantity.toFixed(2), - preAmount: preAmount.toFixed(2) }) - // 以提货量为准 - Object.assign(this.tableData[1], { - salePrice: (this.newSalePrice).toFixed(2), - floorPrice: (this.newCostPrice).toFixed(2), - preQuantity: preQuantity.toFixed(2), - preAmount: (+this.newSalePrice * +preQuantity).toFixed(2) - }) - // 以订单金额为准 - Object.assign(this.tableData[2], { - salePrice: (this.newSalePrice).toFixed(2), - floorPrice: (this.newCostPrice).toFixed(2), - preQuantity: (+preAmount / +this.newSalePrice).toFixed(2), - preAmount: preAmount.toFixed(2) + if (salePrice && floorPrice && preQuantity && preAmount) { + let strategyArr = [ + // 原策略 + () => { + return { salePrice, floorPrice, preQuantity, preAmount, preCostAmount: floorPrice * preQuantity } + }, + // 以提货量为准 + () => { + let _salePrice = newSalePrice + let _floorPrice = newCostPrice + return { + salePrice: _salePrice, + floorPrice: _floorPrice, + preQuantity, + preAmount: _salePrice * preQuantity, + preCostAmount: _floorPrice * preQuantity + } + }, + // // 以订单金额为准 + // () => { + // let _salePrice = newSalePrice + // let _floorPrice = newCostPrice + // return { + // salePrice: _salePrice, + // floorPrice: _floorPrice, + // preQuantity: preAmount / _salePrice, + // preAmount, + // preCostAmount: _floorPrice * this.fixedHandle(preAmount / _salePrice) + // } + // }, + // 自定义数量 + () => { + return { + salePrice: newSalePrice, + floorPrice: newCostPrice, + preQuantity: '', + preAmount: '', + preCostAmount: '' + } + } + ] + strategyArr.forEach((item, index) => { + let originData = this.tableData[index] + let data = item() + if (originData.type === '自定义提货量') { + Object.assign(originData, data) + return + } + for (let key in data) { + data[key] = this.fixedHandle(data[key]) + } + Object.assign(originData, data) }) this.undergoChanges = true } }, + fixedHandle(val) { + val = parseFloat(val) + if (!isNaN(val)) { + let fixedLength4 = val.toFixed(4) + let length = fixedLength4.length + let fixedLength3 = fixedLength4.slice(0, length - 1) + fixedLength3 *= 100 + fixedLength3 = Math.round(fixedLength3) + fixedLength3 /= 100 + let fixedLength2 = fixedLength3.toFixed(2) + return fixedLength2 + } + return 0 + }, submit() { if (this.undergoChanges) { let targetPolicy = this.tableData.filter(item => item.isChecked) @@ -177,6 +251,11 @@ export default { this.$message.warning('炼厂单价发生变化,请选择变更策略') return } + let target = targetPolicy[0] + if (target.type === '自定义提货量' && target.preQuantity <= 0) { + this.$message.warning('请输入提货数量') + return + } serve.orderSuccess({ id: this.controlWindows.addInfo.id, ...targetPolicy[0] }).then(res => { if (res.code == 20000) { this.$message.success(res.msg) @@ -207,11 +286,12 @@ export default { .el-drawer__header { margin-bottom: 0; } + .el-input-group__append { + padding: 0 7px; + } } .confirm-submit { padding: 0 30px; - .title { - } > ul { display: flex; margin: 0 auto 30px; diff --git a/src/views/order/index.vue b/src/views/order/index.vue index 072bdeb..fddc8ab 100644 --- a/src/views/order/index.vue +++ b/src/views/order/index.vue @@ -116,6 +116,9 @@ 订单锁定 + + 下单确认 { + // if (res.code == 20000) { + // this.$message.success(res.msg) + // // this.closeWindow() + // this.getByPage() + // } + // }) }, //启用禁用 switchTrigger(val, row) {