123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- const mapTemplateToTable = {
- '所属平台ID': 'platform_id',
- '供应商公司编码': 'supplierNo',
- '销售方公司编码': 'companyNo',
- '购买方公司编码': 'customerNo',
- // '一级品类ID': 'cat_id1',
- // '二级品类ID': 'cat_id2',
- '三级品类ID': 'cat_id',
- '商品单位ID': 'good_unit',
- '商品名称': 'good_name',
- '销售单价': 'sale_price',
- '数量': 'good_num',
- '销售总额': 'sale_total',
- '税率': 'good_tax',
- '采购单价': 'cgd_price',
- '采购总额': 'cgd_total',
- '采购毛利率': 'cgd_tax',
- '平台订单号': 'poCode',
- '收货人': 'contactor',
- '联系电话': 'mobile',
- '联系地址': 'addr',
- '发货时间': 'sendtime'
- }
- // '其他单号': 'workCode',
- export const getTableProperty = (key) => mapTemplateToTable[key]
- export const getTableLabel = (field) => {
- const keys = Object.keys(mapTemplateToTable)
- for (const key of keys) {
- if (mapTemplateToTable[key] === field) {
- return key
- }
- }
- }
- export const PROPERTYS = {
- COMPANY_NO: getTableProperty('销售方公司编码'),
- CUSTOMER_NO: getTableProperty('购买方公司编码'),
- SUPPLIER_NO: getTableProperty('供应商公司编码'),
- PLATFORM: getTableProperty('所属平台ID'),
- CATEGORY: getTableProperty('三级品类ID'),
- GOOD_NAME: getTableProperty('商品名称'),
- GOOD_UNIT: getTableProperty('商品单位ID'),
- GOOD_NUM: getTableProperty('数量'),
- GOOD_PRICE: getTableProperty('销售单价'),
- TAX: getTableProperty('税率'),
- CGD_PRICE: getTableProperty('采购单价'),
- CGD_TAX: getTableProperty('采购毛利率'),
- SALE_TOTAL: getTableProperty('销售总额'),
- CONTACTOR: getTableProperty('收货人'),
- MOBILE: getTableProperty('联系电话'),
- ADDR: getTableProperty('联系地址'),
- SEND_TIME: getTableProperty('发货时间'),
- PO_CODE: getTableProperty('平台订单号'),
- CGD_TOTAL: getTableProperty('采购总额'),
- WORK_CODE: getTableProperty('其他单号')
- }
- export const template = [
- {
- '所属平台ID': '58',
- '供应商公司编码': 'QS2206011407522117',
- '销售方公司编码': 'GS2302231323386950',
- '购买方公司编码': 'KH2203271822232121',
- // '一级品类ID': '871',
- // '二级品类ID': '871',
- '三级品类ID': '871',
- '商品单位ID': '7',
- '商品名称': '测试商品名称',
- '销售单价': '32',
- '数量': '100',
- '销售总额': '3200',
- '税率': '13',
- '采购单价': '30.00',
- '采购总额': '3000',
- '采购毛利率': '6',
- '平台订单号': 'PO206020230400240002',
- '收货人': '张三',
- '联系电话': '19955554444',
- '联系地址': 'xx市xx区xx街道',
- '发货时间': '2023-4-9 8:00:00'
- }
- ]
- export const columns = [
- {
- type: 'index',
- label: '序号',
- width: '70px'
- },
- {
- prop: PROPERTYS.PLATFORM,
- label: '所属平台ID',
- width: '110px',
- required: true
- },
- {
- prop: PROPERTYS.SUPPLIER_NO,
- label: '供应商公司编码',
- width: '120px',
- required: true
- },
- {
- prop: PROPERTYS.COMPANY_NO,
- label: '销售方公司编码',
- width: '156px',
- required: true
- },
- {
- prop: PROPERTYS.CUSTOMER_NO,
- label: '购买方公司编码',
- width: '180px',
- required: true
- },
- // {
- // prop: getTableProperty('一级品类ID'),
- // label: '一级品类ID',
- // width: '150px',
- // required: true
- // },
- // {
- // prop: getTableProperty('二级品类ID'),
- // label: '二级品类ID',
- // width: '150px',
- // required: true
- // },
- {
- prop: getTableProperty('三级品类ID'),
- label: '三级品类ID',
- width: '150px',
- required: true
- },
- {
- prop: PROPERTYS.GOOD_UNIT,
- label: '商品单位ID',
- width: '150px',
- required: true
- },
- {
- prop: PROPERTYS.GOOD_NAME,
- label: '商品名称',
- width: '150px',
- required: true
- },
- {
- prop: PROPERTYS.GOOD_PRICE,
- label: '销售单价',
- 'width': '150px',
- required: true
- },
- {
- prop: PROPERTYS.GOOD_NUM,
- label: '数量',
- width: '140px',
- required: true
- },
- {
- prop: PROPERTYS.SALE_TOTAL,
- label: '销售总额',
- 'width': '150px'
- },
- {
- prop: PROPERTYS.TAX,
- label: '税率',
- width: '150px',
- required: true
- },
- {
- prop: PROPERTYS.CGD_PRICE,
- label: '采购单价',
- 'width': '150px',
- required: true
- },
- {
- prop: PROPERTYS.CGD_TOTAL,
- label: '采购总额',
- 'width': '150px',
- required: true
- },
- {
- prop: getTableProperty('采购毛利率'),
- label: '采购毛利率',
- 'width': '150px'
- },
- {
- prop: PROPERTYS.PO_CODE,
- label: '平台订单号',
- 'width': '150px',
- required: true
- },
- {
- prop: PROPERTYS.CONTACTOR,
- label: '收货人',
- 'width': '150px',
- required: true
- },
- // {
- // prop: PROPERTYS.WORK_CODE,
- // label: '其他单号',
- // 'width': '150px'
- // },
- {
- prop: PROPERTYS.MOBILE,
- label: '联系电话',
- 'width': '150px',
- required: true
- },
- {
- prop: PROPERTYS.ADDR,
- label: '联系地址',
- 'width': '150px',
- required: true
- },
- {
- prop: PROPERTYS.SEND_TIME,
- label: '发货时间',
- 'width': '150px',
- required: true
- }
- ]
- export function createErrorMessage(messages) {
- const rows = Object.keys(messages)
- return [rows[0]].reduce((prev, row, index) => {
- console.log(messages[row])
- const suffix = index === rows.length - 1 ? '</ul>' : ''
- const content = prev + `
- <li>
- <strong style="font-weight:700">第${row}行</strong>,${messages[row][0]}
- </li>
- `
- return content + suffix
- }, '<ul>')
- }
- export const createFieldVerification = (message) => ({
- notValidRows: [],
- isValid: true,
- message
- })
- export const requsetFields = [
- PROPERTYS.TAX,
- PROPERTYS.ADDR,
- PROPERTYS.MOBILE,
- PROPERTYS.PO_CODE,
- PROPERTYS.PLATFORM,
- PROPERTYS.CATEGORY,
- PROPERTYS.GOOD_NAME,
- PROPERTYS.GOOD_UNIT,
- PROPERTYS.GOOD_NUM,
- PROPERTYS.CGD_PRICE,
- PROPERTYS.CONTACTOR,
- PROPERTYS.SEND_TIME,
- PROPERTYS.WORK_CODE,
- PROPERTYS.GOOD_PRICE,
- PROPERTYS.COMPANY_NO,
- PROPERTYS.SUPPLIER_NO,
- PROPERTYS.CUSTOMER_NO,
- PROPERTYS.CGD_TAX,
- PROPERTYS.SALE_TOTAL,
- PROPERTYS.CGD_TOTAL
- ]
- // 税率、数量、销售单价、采购单价
- export const requiredFields = [
- PROPERTYS.TAX,
- PROPERTYS.ADDR,
- PROPERTYS.MOBILE,
- PROPERTYS.PO_CODE,
- PROPERTYS.PLATFORM,
- PROPERTYS.CATEGORY,
- PROPERTYS.GOOD_NAME,
- PROPERTYS.GOOD_UNIT,
- PROPERTYS.GOOD_NUM,
- PROPERTYS.CONTACTOR,
- PROPERTYS.SEND_TIME,
- PROPERTYS.COMPANY_NO,
- PROPERTYS.SUPPLIER_NO,
- PROPERTYS.CUSTOMER_NO,
- PROPERTYS.CGD_TOTAL,
- PROPERTYS.SALE_TOTAL,
- PROPERTYS.CGD_TAX
- ]
- export const numberFields = [
- PROPERTYS.CGD_TOTAL,
- PROPERTYS.SALE_TOTAL,
- PROPERTYS.GOOD_PRICE,
- PROPERTYS.CGD_PRICE,
- PROPERTYS.CGD_TAX
- ]
- export const intNumberFields = [
- PROPERTYS.CATEGORY,
- PROPERTYS.GOOD_UNIT,
- PROPERTYS.GOOD_NUM,
- PROPERTYS.TAX
- ]
- export const helper = {
- fields(sourceObject) {
- return Object.keys(sourceObject)
- },
- values(sourceObject, fields, index = 0) {
- return fields.map(field => {
- return sourceObject[field][index]
- })
- },
- write(sourceObject, fields) {
- return fields.reduce((prev, currentKey) => ({
- ...prev,
- [currentKey]: sourceObject[currentKey]
- }), {})
- }
- }
|