template-c.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. const mapTemplateToTable = {
  2. '所属平台ID': 'platform_id',
  3. '供应商公司编码': 'supplierNo',
  4. '销售方公司编码': 'companyNo',
  5. '购买方公司编码': 'customerNo',
  6. // '一级品类ID': 'cat_id1',
  7. // '二级品类ID': 'cat_id2',
  8. '三级品类ID': 'cat_id',
  9. '商品单位ID': 'good_unit',
  10. '商品名称': 'good_name',
  11. '销售单价': 'sale_price',
  12. '数量': 'good_num',
  13. '销售总额': 'sale_total',
  14. '税率': 'good_tax',
  15. '采购单价': 'cgd_price',
  16. '采购总额': 'cgd_total',
  17. '采购毛利率': 'cgd_tax',
  18. '平台订单号': 'poCode',
  19. '收货人': 'contactor',
  20. '联系电话': 'mobile',
  21. '联系地址': 'addr',
  22. '发货时间': 'sendtime'
  23. }
  24. // '其他单号': 'workCode',
  25. export const getTableProperty = (key) => mapTemplateToTable[key]
  26. export const getTableLabel = (field) => {
  27. const keys = Object.keys(mapTemplateToTable)
  28. for (const key of keys) {
  29. if (mapTemplateToTable[key] === field) {
  30. return key
  31. }
  32. }
  33. }
  34. export const PROPERTYS = {
  35. COMPANY_NO: getTableProperty('销售方公司编码'),
  36. CUSTOMER_NO: getTableProperty('购买方公司编码'),
  37. SUPPLIER_NO: getTableProperty('供应商公司编码'),
  38. PLATFORM: getTableProperty('所属平台ID'),
  39. CATEGORY: getTableProperty('三级品类ID'),
  40. GOOD_NAME: getTableProperty('商品名称'),
  41. GOOD_UNIT: getTableProperty('商品单位ID'),
  42. GOOD_NUM: getTableProperty('数量'),
  43. GOOD_PRICE: getTableProperty('销售单价'),
  44. TAX: getTableProperty('税率'),
  45. CGD_PRICE: getTableProperty('采购单价'),
  46. CGD_TAX: getTableProperty('采购毛利率'),
  47. SALE_TOTAL: getTableProperty('销售总额'),
  48. CONTACTOR: getTableProperty('收货人'),
  49. MOBILE: getTableProperty('联系电话'),
  50. ADDR: getTableProperty('联系地址'),
  51. SEND_TIME: getTableProperty('发货时间'),
  52. PO_CODE: getTableProperty('平台订单号'),
  53. CGD_TOTAL: getTableProperty('采购总额'),
  54. WORK_CODE: getTableProperty('其他单号')
  55. }
  56. export const template = [
  57. {
  58. '所属平台ID': '58',
  59. '供应商公司编码': 'QS2206011407522117',
  60. '销售方公司编码': 'GS2302231323386950',
  61. '购买方公司编码': 'KH2203271822232121',
  62. // '一级品类ID': '871',
  63. // '二级品类ID': '871',
  64. '三级品类ID': '871',
  65. '商品单位ID': '7',
  66. '商品名称': '测试商品名称',
  67. '销售单价': '32',
  68. '数量': '100',
  69. '销售总额': '3200',
  70. '税率': '13',
  71. '采购单价': '30.00',
  72. '采购总额': '3000',
  73. '采购毛利率': '6',
  74. '平台订单号': 'PO206020230400240002',
  75. '收货人': '张三',
  76. '联系电话': '19955554444',
  77. '联系地址': 'xx市xx区xx街道',
  78. '发货时间': '2023-4-9 8:00:00'
  79. }
  80. ]
  81. export const columns = [
  82. {
  83. type: 'index',
  84. label: '序号',
  85. width: '70px'
  86. },
  87. {
  88. prop: PROPERTYS.PLATFORM,
  89. label: '所属平台ID',
  90. width: '110px',
  91. required: true
  92. },
  93. {
  94. prop: PROPERTYS.SUPPLIER_NO,
  95. label: '供应商公司编码',
  96. width: '120px',
  97. required: true
  98. },
  99. {
  100. prop: PROPERTYS.COMPANY_NO,
  101. label: '销售方公司编码',
  102. width: '156px',
  103. required: true
  104. },
  105. {
  106. prop: PROPERTYS.CUSTOMER_NO,
  107. label: '购买方公司编码',
  108. width: '180px',
  109. required: true
  110. },
  111. // {
  112. // prop: getTableProperty('一级品类ID'),
  113. // label: '一级品类ID',
  114. // width: '150px',
  115. // required: true
  116. // },
  117. // {
  118. // prop: getTableProperty('二级品类ID'),
  119. // label: '二级品类ID',
  120. // width: '150px',
  121. // required: true
  122. // },
  123. {
  124. prop: getTableProperty('三级品类ID'),
  125. label: '三级品类ID',
  126. width: '150px',
  127. required: true
  128. },
  129. {
  130. prop: PROPERTYS.GOOD_UNIT,
  131. label: '商品单位ID',
  132. width: '150px',
  133. required: true
  134. },
  135. {
  136. prop: PROPERTYS.GOOD_NAME,
  137. label: '商品名称',
  138. width: '150px',
  139. required: true
  140. },
  141. {
  142. prop: PROPERTYS.GOOD_PRICE,
  143. label: '销售单价',
  144. 'width': '150px',
  145. required: true
  146. },
  147. {
  148. prop: PROPERTYS.GOOD_NUM,
  149. label: '数量',
  150. width: '140px',
  151. required: true
  152. },
  153. {
  154. prop: PROPERTYS.SALE_TOTAL,
  155. label: '销售总额',
  156. 'width': '150px'
  157. },
  158. {
  159. prop: PROPERTYS.TAX,
  160. label: '税率',
  161. width: '150px',
  162. required: true
  163. },
  164. {
  165. prop: PROPERTYS.CGD_PRICE,
  166. label: '采购单价',
  167. 'width': '150px',
  168. required: true
  169. },
  170. {
  171. prop: PROPERTYS.CGD_TOTAL,
  172. label: '采购总额',
  173. 'width': '150px',
  174. required: true
  175. },
  176. {
  177. prop: getTableProperty('采购毛利率'),
  178. label: '采购毛利率',
  179. 'width': '150px'
  180. },
  181. {
  182. prop: PROPERTYS.PO_CODE,
  183. label: '平台订单号',
  184. 'width': '150px',
  185. required: true
  186. },
  187. {
  188. prop: PROPERTYS.CONTACTOR,
  189. label: '收货人',
  190. 'width': '150px',
  191. required: true
  192. },
  193. // {
  194. // prop: PROPERTYS.WORK_CODE,
  195. // label: '其他单号',
  196. // 'width': '150px'
  197. // },
  198. {
  199. prop: PROPERTYS.MOBILE,
  200. label: '联系电话',
  201. 'width': '150px',
  202. required: true
  203. },
  204. {
  205. prop: PROPERTYS.ADDR,
  206. label: '联系地址',
  207. 'width': '150px',
  208. required: true
  209. },
  210. {
  211. prop: PROPERTYS.SEND_TIME,
  212. label: '发货时间',
  213. 'width': '150px',
  214. required: true
  215. }
  216. ]
  217. export function createErrorMessage(messages) {
  218. const rows = Object.keys(messages)
  219. return [rows[0]].reduce((prev, row, index) => {
  220. console.log(messages[row])
  221. const suffix = index === rows.length - 1 ? '</ul>' : ''
  222. const content = prev + `
  223. <li>
  224. <strong style="font-weight:700">第${row}行</strong>,${messages[row][0]}
  225. </li>
  226. `
  227. return content + suffix
  228. }, '<ul>')
  229. }
  230. export const createFieldVerification = (message) => ({
  231. notValidRows: [],
  232. isValid: true,
  233. message
  234. })
  235. export const requsetFields = [
  236. PROPERTYS.TAX,
  237. PROPERTYS.ADDR,
  238. PROPERTYS.MOBILE,
  239. PROPERTYS.PO_CODE,
  240. PROPERTYS.PLATFORM,
  241. PROPERTYS.CATEGORY,
  242. PROPERTYS.GOOD_NAME,
  243. PROPERTYS.GOOD_UNIT,
  244. PROPERTYS.GOOD_NUM,
  245. PROPERTYS.CGD_PRICE,
  246. PROPERTYS.CONTACTOR,
  247. PROPERTYS.SEND_TIME,
  248. PROPERTYS.WORK_CODE,
  249. PROPERTYS.GOOD_PRICE,
  250. PROPERTYS.COMPANY_NO,
  251. PROPERTYS.SUPPLIER_NO,
  252. PROPERTYS.CUSTOMER_NO,
  253. PROPERTYS.CGD_TAX,
  254. PROPERTYS.SALE_TOTAL,
  255. PROPERTYS.CGD_TOTAL
  256. ]
  257. // 税率、数量、销售单价、采购单价
  258. export const requiredFields = [
  259. PROPERTYS.TAX,
  260. PROPERTYS.ADDR,
  261. PROPERTYS.MOBILE,
  262. PROPERTYS.PO_CODE,
  263. PROPERTYS.PLATFORM,
  264. PROPERTYS.CATEGORY,
  265. PROPERTYS.GOOD_NAME,
  266. PROPERTYS.GOOD_UNIT,
  267. PROPERTYS.GOOD_NUM,
  268. PROPERTYS.CONTACTOR,
  269. PROPERTYS.SEND_TIME,
  270. PROPERTYS.COMPANY_NO,
  271. PROPERTYS.SUPPLIER_NO,
  272. PROPERTYS.CUSTOMER_NO,
  273. PROPERTYS.CGD_TOTAL,
  274. PROPERTYS.SALE_TOTAL,
  275. PROPERTYS.CGD_TAX
  276. ]
  277. export const numberFields = [
  278. PROPERTYS.CGD_TOTAL,
  279. PROPERTYS.SALE_TOTAL,
  280. PROPERTYS.GOOD_PRICE,
  281. PROPERTYS.CGD_PRICE,
  282. PROPERTYS.CGD_TAX
  283. ]
  284. export const intNumberFields = [
  285. PROPERTYS.CATEGORY,
  286. PROPERTYS.GOOD_UNIT,
  287. PROPERTYS.GOOD_NUM,
  288. PROPERTYS.TAX
  289. ]
  290. export const helper = {
  291. fields(sourceObject) {
  292. return Object.keys(sourceObject)
  293. },
  294. values(sourceObject, fields, index = 0) {
  295. return fields.map(field => {
  296. return sourceObject[field][index]
  297. })
  298. },
  299. write(sourceObject, fields) {
  300. return fields.reduce((prev, currentKey) => ({
  301. ...prev,
  302. [currentKey]: sourceObject[currentKey]
  303. }), {})
  304. }
  305. }