columns.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. import CONFIG from "@/config";
  2. import { iunitprice } from "@/utils/expression";
  3. export default function useColumns() {
  4. const TableColumns = [
  5. {
  6. item: { key: "priceCode", title: "价格编码" },
  7. attr: { is: "el-input", disabled: true, readonly: true },
  8. },
  9. {
  10. item: { key: "supplierName", title: "供应商", require: true },
  11. attr: {
  12. is: "el-popover-select-v2",
  13. valueKey: "name",
  14. referName: "SUPPLIER_PARAM",
  15. dataMapping: {
  16. supplier: "id",
  17. supplierCode: "code",
  18. supplierName: "name",
  19. },
  20. },
  21. },
  22. {
  23. item: { key: "puOrgName", title: "采购组织", require: true },
  24. attr: {
  25. is: "el-popover-select-v2",
  26. valueKey: "name",
  27. referName: "ORG_PARAM",
  28. dataMapping: { puOrg: "id", puOrgCode: "code", puOrgName: "name" },
  29. },
  30. },
  31. {
  32. item: { key: "currencyName", title: "币种", require: true },
  33. attr: {
  34. is: "el-popover-select-v2",
  35. valueKey: "name",
  36. referName: "CURRENCY_PARAM",
  37. dataMapping: {
  38. currency: "id",
  39. currencyCode: "code",
  40. currencyName: "name",
  41. },
  42. },
  43. },
  44. {
  45. item: { key: "explainStr", title: "价格合理性说明", require: true },
  46. attr: { is: "el-input" },
  47. },
  48. {
  49. item: { key: "buyerName", title: "采购员", require: true },
  50. attr: {
  51. is: "el-popover-select-v2",
  52. valueKey: "name",
  53. referName: "CONTACTS_PARAM",
  54. dataMapping: { buyer: "code", buyerName: "name" },
  55. },
  56. },
  57. {
  58. item: { key: "puDeptName", title: "采购部门", require: true },
  59. attr: {
  60. is: "el-popover-select-v2",
  61. valueKey: "name",
  62. referName: "DEPT_PARAM",
  63. dataMapping: { puDept: "id", puDeptCode: "code", puDeptName: "name" },
  64. },
  65. },
  66. {
  67. item: { key: "createByName", title: "创建人" },
  68. attr: { is: "el-input", disabled: true, readonly: true },
  69. },
  70. {
  71. item: { key: "isEffective", title: "是否已推价格" },
  72. attr: {
  73. is: "el-select",
  74. dictName: "is_effective",
  75. value: "N",
  76. disabled: true,
  77. },
  78. },
  79. {
  80. item: { key: "effectiveDate", title: "生效日期" },
  81. attr: { is: "el-input", disabled: true, readonly: true },
  82. },
  83. {
  84. item: { key: "file", title: "附件", require: true, span: 24 },
  85. attr: { is: "el-file-upload" },
  86. },
  87. {
  88. item: { key: "sourceType", title: "来源单据类型" },
  89. attr: { is: "el-input", disabled: true, readonly: true },
  90. },
  91. {
  92. item: { key: "status", title: "单据状态" },
  93. attr: {
  94. is: "el-select",
  95. dictName: "sys_status",
  96. disabled: true,
  97. readonly: true,
  98. value: "0",
  99. },
  100. },
  101. ].map(({ item, attr }) => ({
  102. attr,
  103. item: { ...item, hidden: true, span: item.span || 6 },
  104. }));
  105. const TabColumns = [
  106. {
  107. item: {
  108. title: "物料信息表",
  109. key: "priceApplyItems",
  110. },
  111. attr: {
  112. value: [],
  113. },
  114. TableColumns: [
  115. {
  116. item: { key: "materialName", title: "物料名称", require: true },
  117. attr: {
  118. is: "el-popover-select-v2",
  119. checkbox: true,
  120. valueKey: "name",
  121. referName: "MATERIAL_PARAM",
  122. dataMapping: {
  123. model: "model",
  124. material: "id",
  125. materialCode: "code",
  126. materialName: "name",
  127. unitName: "unitIdName",
  128. puUnitName: "unitIdName",
  129. specification: "specification",
  130. manufacturer: "manufacturerId",
  131. manufacturerName: "manufacturerIdName",
  132. tax: "materialRateName",
  133. },
  134. },
  135. },
  136. {
  137. item: { key: "materialCode", title: "物料编码", require: true },
  138. attr: {},
  139. },
  140. { item: { key: "manufacturerName", title: "生产厂家" }, attr: {} },
  141. { item: { key: "specification", title: "规格" }, attr: {} },
  142. { item: { key: "model", title: "型号" }, attr: {} },
  143. {
  144. item: { key: "unitName", title: "单位", hidden: false },
  145. attr: {
  146. is: "el-popover-select-v2",
  147. valueKey: "name",
  148. referName: "UNIT_PARAM",
  149. dataMapping: { unit: "id", unitCode: "code", unitName: "name" },
  150. },
  151. },
  152. {
  153. item: { key: "puUnitName", title: "采购单位", hidden: false },
  154. attr: {
  155. is: "el-popover-select-v2",
  156. valueKey: "name",
  157. referName: "UNIT_PARAM",
  158. dataMapping: {
  159. puUnit: "id",
  160. puUnitCode: "code",
  161. puUnitName: "name",
  162. },
  163. },
  164. },
  165. {
  166. item: { key: "conversionRate", title: "采购换算率", require: true },
  167. attr: {
  168. is: "el-input-number",
  169. precision: CONFIG.precision,
  170. value: 1,
  171. disabled: true,
  172. },
  173. },
  174. {
  175. item: { key: "tax", title: "税率%", require: true },
  176. attr: {
  177. is: "el-popover-select-v2",
  178. valueKey: "ntaxrate",
  179. referName: "TAX_RATE_PARAM",
  180. dataMapping: { tax: "ntaxrate" },
  181. disabled: true,
  182. },
  183. },
  184. {
  185. item: { key: "taxPrice", title: "含税单价", require: true },
  186. attr: {
  187. is: "el-input-number",
  188. precision: CONFIG.precision,
  189. },
  190. },
  191. {
  192. item: { key: "price", title: "无税单价", require: true },
  193. attr: {
  194. formatter: (prop) => {
  195. const { tax = 0, taxPrice = 0 } = prop;
  196. return (prop.price = iunitprice(tax, taxPrice));
  197. },
  198. },
  199. },
  200. {
  201. item: { key: "currencyName", title: "币种" },
  202. attr: {
  203. is: "el-popover-select-v2",
  204. valueKey: "name",
  205. referName: "CURRENCY_PARAM",
  206. dataMapping: {
  207. currency: "id",
  208. currencyCode: "code",
  209. currencyName: "name",
  210. },
  211. },
  212. },
  213. {
  214. item: {
  215. key: "periodBegin",
  216. title: "价格有效期(起)",
  217. require: true,
  218. },
  219. attr: {
  220. is: "el-date-picker",
  221. valueFormat: "yyyy-MM-dd",
  222. value: new Date(),
  223. },
  224. },
  225. {
  226. item: { key: "periodEnd", title: "价格有效期(止)", require: true },
  227. attr: {
  228. is: "el-date-picker",
  229. valueFormat: "yyyy-MM-dd",
  230. pickerOptions: {
  231. disabledDate(time) {
  232. return time.getTime() < Date.now() + 3600 * 1000 * 24 * 365;
  233. },
  234. },
  235. value: new Date(new Date().getTime() + 3600 * 1000 * 24 * 366),
  236. },
  237. },
  238. {
  239. item: { key: "customerName", title: "客户" },
  240. attr: {
  241. is: "el-popover-select-v2",
  242. valueKey: "name",
  243. referName: "CUSTOMER_PARAM",
  244. dataMapping: {
  245. customer: "id",
  246. customerCode: "code",
  247. customerName: "name",
  248. },
  249. },
  250. },
  251. {
  252. item: { key: "recentlyPrice", title: "最近价格" },
  253. attr: {
  254. is: "el-input-number",
  255. precision: CONFIG.precision,
  256. disabled: true,
  257. },
  258. },
  259. {
  260. item: { key: "isApprovalFirst", title: "首次报批" },
  261. attr: {
  262. is: "el-select",
  263. dictName: "is_effective",
  264. disabled: true,
  265. },
  266. },
  267. {
  268. item: { key: "isPriceAdjustment", title: "价格调整" },
  269. attr: {
  270. is: "el-select",
  271. dictName: "is_effective",
  272. disabled: true,
  273. },
  274. },
  275. {
  276. item: { key: "priceType", title: "价格类型", require: true },
  277. attr: {
  278. is: "el-select",
  279. dictName: "sys_price_type",
  280. value: "order",
  281. },
  282. },
  283. {
  284. item: { key: "isDistributionPrice", title: "配送价", require: true },
  285. attr: {
  286. is: "el-select",
  287. dictName: "is_effective",
  288. value: "N",
  289. },
  290. },
  291. {
  292. item: { width: 100, key: "isChannel", title: "是否渠道变更" },
  293. attr: {
  294. is: "el-select",
  295. dictName: "is_effective",
  296. value: "N",
  297. },
  298. },
  299. {
  300. item: { width: 100, key: "brandReplacement", title: "是否品牌替换" },
  301. attr: {
  302. is: "el-select",
  303. dictName: "is_effective",
  304. value: "N",
  305. },
  306. },
  307. {
  308. item: { width: 100, key: "priceDiffer", title: "单价差" },
  309. attr: {
  310. formatter: (prop) => {
  311. const { taxPrice = 0, recentlyPrice = 0 } = prop;
  312. return (prop.priceDiffer = (
  313. Number(taxPrice) - Number(recentlyPrice)
  314. ));
  315. },
  316. },
  317. },
  318. {
  319. item: { width: 100, key: "increase", title: "涨幅(%)" },
  320. attr: {
  321. formatter: (prop) => {
  322. const { priceDiffer = 0, recentlyPrice = 0 } = prop;
  323. return (prop.increase = recentlyPrice
  324. ? ((Number(priceDiffer) / Number(recentlyPrice)) * 100).toFixed(
  325. 2
  326. )
  327. : "0.00");
  328. },
  329. },
  330. },
  331. {
  332. item: { width: 100, key: "yPurchaseQuantity", title: "预计年采购量" },
  333. attr: {
  334. is: "el-computed-input-v2",
  335. formatter: (prop) => {
  336. return prop == null ? 0 : (prop * 1);
  337. },
  338. },
  339. },
  340. {
  341. item: { width: 100, key: "yAffectedAmount", title: "预计年影响金额" },
  342. attr: {
  343. formatter: (prop) => {
  344. const { priceDiffer = 0, yPurchaseQuantity = 0 } = prop;
  345. return (prop.yAffectedAmount = (
  346. Number(priceDiffer) * Number(yPurchaseQuantity)
  347. ));
  348. },
  349. },
  350. },
  351. {
  352. item: { width: 150, key: "supplierName", title: "供应商名称" },
  353. attr: { is: "el-input" },
  354. },
  355. {
  356. item: { width: 150, key: "bidPrice", title: "中标价" },
  357. attr: {
  358. is: "el-input-number",
  359. precision: CONFIG.precision,
  360. },
  361. },
  362. {
  363. item: { width: 150, key: "unitPrice", title: "单价" },
  364. attr: {
  365. is: "el-input-number",
  366. precision: CONFIG.precision,
  367. },
  368. },
  369. {
  370. item: { width: 150, key: "profit", title: "利润比" },
  371. attr: {
  372. is: "el-input-number",
  373. precision: CONFIG.precision,
  374. },
  375. },
  376. {
  377. item: { width: 150, key: "supplierName1", title: "供应商名称1" },
  378. attr: { is: "el-input" },
  379. },
  380. {
  381. item: { width: 150, key: "bidPrice1", title: "中标价1" },
  382. attr: {
  383. is: "el-input-number",
  384. precision: CONFIG.precision,
  385. },
  386. },
  387. {
  388. item: { width: 150, key: "unitPrice1", title: "单价1" },
  389. attr: {
  390. is: "el-input-number",
  391. precision: CONFIG.precision,
  392. },
  393. },
  394. {
  395. item: { width: 150, key: "profit1", title: "利润比1" },
  396. attr: {
  397. is: "el-input-number",
  398. precision: CONFIG.precision,
  399. },
  400. },
  401. {
  402. item: { width: 150, key: "supplierName2", title: "供应商名称2" },
  403. attr: { is: "el-input" },
  404. },
  405. {
  406. item: { width: 150, key: "bidPrice2", title: "中标价2" },
  407. attr: {
  408. is: "el-input-number",
  409. precision: CONFIG.precision,
  410. },
  411. },
  412. {
  413. item: { width: 150, key: "unitPrice2", title: "单价2" },
  414. attr: {
  415. is: "el-input-number",
  416. precision: CONFIG.precision,
  417. },
  418. },
  419. {
  420. item: { width: 150, key: "profit2", title: "利润比2" },
  421. attr: {
  422. is: "el-input-number",
  423. precision: CONFIG.precision,
  424. },
  425. },
  426. { item: { key: "createByName", title: "创建人名称" }, attr: {} },
  427. { item: { key: "updateByName", title: "更新人名称" }, attr: {} },
  428. ],
  429. },
  430. ];
  431. return { TableColumns, TabColumns };
  432. }