Commit 1ce592a2 by 张立顺

feat 功能开发

1 parent 56b59af4
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<div v-for="(item, index) in displayOrderForm" :key="index" class="info-item" :class="{ 'flex-start': item.flexStart }"> <div v-for="(item, index) in displayOrderForm" :key="index" class="info-item" :class="{ 'flex-start': item.flexStart }">
<span class="info-label">{{ item.label }}</span> <span class="info-label">{{ item.label }}</span>
<template v-if="item.format"> <template v-if="item.format">
<div class="info-value">{{ djOrderTypeMap[orderInfo[item.key]] || '-' }}</div> <div class="info-value">{{ getFormattedFieldValue(orderInfo[item.key], item.format) }}</div>
</template> </template>
<template v-else-if="item.arr"> <template v-else-if="item.arr">
<div class="info-value"> <div class="info-value">
...@@ -108,6 +108,7 @@ import dayjs from 'dayjs' ...@@ -108,6 +108,7 @@ import dayjs from 'dayjs'
import { ImagePreview } from 'vant' import { ImagePreview } from 'vant'
import orderApprovalApi from '@/api/orderApproval' import orderApprovalApi from '@/api/orderApproval'
import mockOrderDetailRes from './mockData' import mockOrderDetailRes from './mockData'
import { getFormattedFieldValue as formatFieldValue } from './orderApprovalFormat'
import GoodsOrderItem from './components/goodsOrderItem.vue' import GoodsOrderItem from './components/goodsOrderItem.vue'
import ApprovalPopup from './components/approvalPopup.vue' import ApprovalPopup from './components/approvalPopup.vue'
import store from '@/store' import store from '@/store'
...@@ -130,18 +131,10 @@ export default { ...@@ -130,18 +131,10 @@ export default {
3: { name: '已审核', tips: '订单已审核', icon: 'passed', color: '#35C376' }, 3: { name: '已审核', tips: '订单已审核', icon: 'passed', color: '#35C376' },
4: { name: '已驳回', tips: '订单已驳回', icon: 'warning-o', color: '#666666' } 4: { name: '已驳回', tips: '订单已驳回', icon: 'warning-o', color: '#666666' }
}, },
djOrderTypeMap: {
'': '订单类型',
1: '正常订单',
2: '打折策略',
3: '买赠策略',
4: '冲量活动',
5: '组合付款',
6: '内部结算'
},
orderForm: [ orderForm: [
{ label: '订单编号', key: 'orderCode' }, { label: '订单编号', key: 'orderCode' },
{ label: '订单类型', key: 'djOrderType', format: true }, { label: '订单类型', key: 'djOrderType', format: 'djOrderType' },
{ label: '订单归属', key: 'lowPriceFlag', format: 'lowPriceFlag' },
{ label: '总价', key: 'finalPrice', unit: '¥' }, { label: '总价', key: 'finalPrice', unit: '¥' },
{ label: '提单人', key: ['sellerName', 'merchantName'], arr: true }, { label: '提单人', key: ['sellerName', 'merchantName'], arr: true },
{ label: '提单时间', key: 'applyDate' }, { label: '提单时间', key: 'applyDate' },
...@@ -190,6 +183,9 @@ export default { ...@@ -190,6 +183,9 @@ export default {
} }
}, },
methods: { methods: {
getFormattedFieldValue(value, format) {
return formatFieldValue(value, format)
},
initPageParams() { initPageParams() {
const { orderCode } = this.$route.query const { orderCode } = this.$route.query
if (orderCode) this.setLocalStorage('ww_orderCode', orderCode) if (orderCode) this.setLocalStorage('ww_orderCode', orderCode)
......
const orderFieldMaps = {
djOrderType: {
'': '订单类型',
1: '正常订单',
2: '打折策略',
3: '买赠策略',
4: '冲量活动',
5: '组合付款',
6: '内部结算'
},
lowPriceFlag: {
0: '普通订单',
1: '低价订单'
}
}
function getFormattedFieldValue(value, format) {
const fieldMap = orderFieldMaps[format]
if (!fieldMap || value === undefined || value === null) return '-'
return Object.prototype.hasOwnProperty.call(fieldMap, value) ? fieldMap[value] : '-'
}
module.exports = {
getFormattedFieldValue
}
const assert = require('assert')
const { getFormattedFieldValue } = require('../src/views/orderApproval/orderApprovalFormat')
assert.strictEqual(getFormattedFieldValue(0, 'lowPriceFlag'), '普通订单')
assert.strictEqual(getFormattedFieldValue(1, 'lowPriceFlag'), '低价订单')
assert.strictEqual(getFormattedFieldValue(undefined, 'lowPriceFlag'), '-')
assert.strictEqual(getFormattedFieldValue(null, 'lowPriceFlag'), '-')
assert.strictEqual(getFormattedFieldValue(2, 'lowPriceFlag'), '-')
console.log('orderApprovalFormat tests passed')
...@@ -4,9 +4,9 @@ const defaultSettings = require('./src/config/conf.js') ...@@ -4,9 +4,9 @@ const defaultSettings = require('./src/config/conf.js')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const resolve = dir => path.join(__dirname, dir) const resolve = dir => path.join(__dirname, dir)
// page title // page title
const name = defaultSettings.title || '登录中...' const name = defaultSettings.title || '登录中...'
// 生产环境,测试和正式 // 生产环境,测试和正式
const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV) const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV)
/** /**
...@@ -16,14 +16,16 @@ const SpritesmithPlugin = require('webpack-spritesmith') ...@@ -16,14 +16,16 @@ const SpritesmithPlugin = require('webpack-spritesmith')
const spritesmithFunction = data => { const spritesmithFunction = data => {
let { spritesheet, sprites } = data let { spritesheet, sprites } = data
let shared = `.sprite-icon { background-image: url(${data.sprites[0].image});background-size: ${spritesheet.width / 2}px ${spritesheet.height / 2}px;}` let shared = `.sprite-icon { background-image: url(${data.sprites[0].image});background-size: ${spritesheet.width / 2}px ${spritesheet.height / 2}px;}`
let perSprite = sprites.map(sprite => { let perSprite = sprites
let { name, width, height, offset_x, offset_y } = sprite .map(sprite => {
return `.icon-${name} { width: ${width / 2}px; height: ${height / 2}px; background-position: ${offset_x / 2}px ${offset_y / 2}px;}` let { name, width, height, offset_x, offset_y } = sprite
}).join('\n') return `.icon-${name} { width: ${width / 2}px; height: ${height / 2}px; background-position: ${offset_x / 2}px ${offset_y / 2}px;}`
})
.join('\n')
return `${shared}\n${perSprite}` return `${shared}\n${perSprite}`
} }
module.exports = { module.exports = {
publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-main-test/', // 署应用包时的基本 URL。 vue-router hash 模式使用 // publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-main-test/', // 署应用包时的基本 URL。 vue-router hash 模式使用
// publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-lwk/', // 署应用包时的基本 URL。 vue-router hash 模式使用 // publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-lwk/', // 署应用包时的基本 URL。 vue-router hash 模式使用
// publicPath: '/dj-scrm-wx-work-main/', // 署应用包时的基本 URL。 vue-router history模式使用 微信开发环境需打开 // publicPath: '/dj-scrm-wx-work-main/', // 署应用包时的基本 URL。 vue-router history模式使用 微信开发环境需打开
outputDir: 'dist', // 生产环境构建文件的目录 outputDir: 'dist', // 生产环境构建文件的目录
...@@ -32,9 +34,9 @@ module.exports = { ...@@ -32,9 +34,9 @@ module.exports = {
productionSourceMap: false, // 如果不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。 productionSourceMap: false, // 如果不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
devServer: { devServer: {
disableHostCheck: true, disableHostCheck: true,
port: 9527, // port: 9527,
open: false, // 启动后打开浏览器. open: false, // 启动后打开浏览器.
public:'http://scrm.dev.glsx.com.cn/dj-scrm-wx-work-main-test/#/', // public:'http://scrm.dev.glsx.com.cn/dj-scrm-wx-work-main-test/#/',
overlay: { overlay: {
// 当出现编译器错误或警告时,在浏览器中显示全屏覆盖层 // 当出现编译器错误或警告时,在浏览器中显示全屏覆盖层
warnings: false, warnings: false,
...@@ -80,13 +82,16 @@ module.exports = { ...@@ -80,13 +82,16 @@ module.exports = {
image: path.resolve(__dirname, './src/assets/images/sprite.png'), image: path.resolve(__dirname, './src/assets/images/sprite.png'),
// 生成SCSS // 生成SCSS
css: [ css: [
[path.resolve(__dirname, './src/assets/css/sprite.scss'), { [
format: 'function_based_template' path.resolve(__dirname, './src/assets/css/sprite.scss'),
}] {
format: 'function_based_template'
}
]
] ]
}, },
customTemplates: { customTemplates: {
'function_based_template': spritesmithFunction, function_based_template: spritesmithFunction
}, },
//background引用路径 //background引用路径
apiOptions: { apiOptions: {
...@@ -99,11 +104,11 @@ module.exports = { ...@@ -99,11 +104,11 @@ module.exports = {
}) })
] ]
config.plugins = [...config.plugins, ...Plugins] config.plugins = [...config.plugins, ...Plugins]
// 为生产环境修改配置... // 为生产环境修改配置...
// if (IS_PROD) { // if (IS_PROD) {
// // externals // // externals
// config.externals = externals // config.externals = externals
// } // }
}, },
chainWebpack: config => { chainWebpack: config => {
...@@ -132,26 +137,30 @@ module.exports = { ...@@ -132,26 +137,30 @@ module.exports = {
return options return options
}) })
.end() .end()
/** /**
* 打包分析 * 打包分析
*/ */
if (IS_PROD) { if (IS_PROD) {
config.plugin('webpack-report').use(BundleAnalyzerPlugin, [{ config.plugin('webpack-report').use(BundleAnalyzerPlugin, [
analyzerMode: 'static' {
}]) analyzerMode: 'static'
}
])
} }
config config
// https://webpack.js.org/configuration/devtool/#development // https://webpack.js.org/configuration/devtool/#development
.when(!IS_PROD, config => config.devtool('cheap-source-map')) .when(!IS_PROD, config => config.devtool('cheap-source-map'))
config.when(IS_PROD, config => { config.when(IS_PROD, config => {
config config
.plugin('ScriptExtHtmlWebpackPlugin') .plugin('ScriptExtHtmlWebpackPlugin')
.after('html') .after('html')
.use('script-ext-html-webpack-plugin', [{ .use('script-ext-html-webpack-plugin', [
// 将 runtime 作为内联引入不单独存在 {
inline: /runtime\..*\.js$/ // 将 runtime 作为内联引入不单独存在
}]) inline: /runtime\..*\.js$/
}
])
.end() .end()
config.optimization.splitChunks({ config.optimization.splitChunks({
chunks: 'all', chunks: 'all',
...@@ -180,4 +189,4 @@ module.exports = { ...@@ -180,4 +189,4 @@ module.exports = {
config.optimization.runtimeChunk('single') config.optimization.runtimeChunk('single')
}) })
} }
}
\ No newline at end of file \ No newline at end of file
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!