columns.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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: "供应商", required: 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: "采购组织", required: 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: "币种", required: 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: "价格合理性说明", required: true },
  46. attr: { is: "el-input" },
  47. },
  48. {
  49. item: { key: "buyerName", title: "采购员", required: 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: "采购部门", required: 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: "approveTime", title: "单据申请日期" },
  81. attr: { is: "el-input", disabled: true, readonly: true },
  82. },
  83. {
  84. item: { key: "file", title: "附件", required: 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: "物料名称", required: 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: "物料编码", required: 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: "采购换算率", required: 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: "税率%", required: 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: "含税单价", required: true },
  186. attr: {
  187. is: "el-input-number",
  188. precision: CONFIG.precision,
  189. },
  190. },
  191. {
  192. item: { key: "price", title: "无税单价", required: 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. required: 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: "价格有效期(止)", required: 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: {
  261. key: "recentlyPriceDate",
  262. title: "最近价格日期",
  263. },
  264. attr: {
  265. is: "el-date-picker",
  266. valueFormat: "yyyy-MM-dd",
  267. },
  268. },
  269. {
  270. item: { key: "isApprovalFirst", title: "首次报批" },
  271. attr: {
  272. is: "el-select",
  273. dictName: "is_effective",
  274. disabled: true,
  275. },
  276. },
  277. {
  278. item: { key: "isPriceAdjustment", title: "价格调整" },
  279. attr: {
  280. is: "el-select",
  281. dictName: "is_effective",
  282. disabled: true,
  283. },
  284. },
  285. {
  286. item: { key: "priceType", title: "价格类型", required: true },
  287. attr: {
  288. is: "el-select",
  289. dictName: "sys_price_type",
  290. value: "order",
  291. },
  292. },
  293. {
  294. item: { key: "isDistributionPrice", title: "配送价", required: true },
  295. attr: {
  296. is: "el-select",
  297. dictName: "is_effective",
  298. value: "N",
  299. },
  300. },
  301. {
  302. item: { width: 100, key: "isChannel", title: "是否渠道变更" },
  303. attr: {
  304. is: "el-select",
  305. dictName: "is_effective",
  306. value: "N",
  307. },
  308. },
  309. {
  310. item: { width: 100, key: "brandReplacement", title: "是否品牌替换" },
  311. attr: {
  312. is: "el-select",
  313. dictName: "is_effective",
  314. value: "N",
  315. },
  316. },
  317. {
  318. item: { width: 100, key: "priceDiffer", title: "单价差" },
  319. attr: {
  320. formatter: (prop) => {
  321. const { taxPrice = 0, recentlyPrice = 0 } = prop;
  322. return (prop.priceDiffer = (
  323. Number(taxPrice) - Number(recentlyPrice)
  324. ));
  325. },
  326. },
  327. },
  328. {
  329. item: { width: 100, key: "increase", title: "涨幅(%)" },
  330. attr: {
  331. formatter: (prop) => {
  332. const { priceDiffer = 0, recentlyPrice = 0 } = prop;
  333. return (prop.increase = recentlyPrice
  334. ? ((Number(priceDiffer) / Number(recentlyPrice)) * 100).toFixed(
  335. 2
  336. )
  337. : "0.00");
  338. },
  339. },
  340. },
  341. {
  342. item: { width: 100, key: "yPurchaseQuantity", title: "预计年采购量" },
  343. attr: {
  344. is: "el-computed-input-v2",
  345. formatter: (prop) => {
  346. return prop == null ? 0 : (prop * 1);
  347. },
  348. },
  349. },
  350. {
  351. item: { width: 100, key: "yPurchaseVolume", title: "预计年采购额" },
  352. attr: {
  353. formatter: (prop) => {
  354. const { taxPrice = 0, yPurchaseQuantity = 0 } = prop;
  355. return (prop.yPurchaseVolume = (Number(taxPrice) * Number(yPurchaseQuantity)).toFixed(2));
  356. },
  357. },
  358. },
  359. {
  360. item: { width: 100, key: "yAffectedAmount", title: "预计年影响金额" },
  361. attr: {
  362. formatter: (prop) => {
  363. const { priceDiffer = 0, yPurchaseQuantity = 0 } = prop;
  364. return (prop.yAffectedAmount = (
  365. Number(priceDiffer) * Number(yPurchaseQuantity)
  366. ));
  367. },
  368. },
  369. },
  370. {
  371. item: { width: 150, key: "supplierName", title: "供应商名称" },
  372. attr: { is: "el-input" },
  373. },
  374. {
  375. item: { width: 150, key: "bidPrice", title: "中标价" },
  376. attr: {
  377. is: "el-input-number",
  378. precision: CONFIG.precision,
  379. },
  380. },
  381. {
  382. item: { width: 150, key: "unitPrice", title: "单价" },
  383. attr: {
  384. is: "el-input-number",
  385. precision: CONFIG.precision,
  386. },
  387. },
  388. {
  389. item: { width: 150, key: "profit", title: "利润比" },
  390. attr: {
  391. is: "el-input-number",
  392. precision: CONFIG.precision,
  393. },
  394. },
  395. {
  396. item: { width: 150, key: "supplierName1", title: "供应商名称1" },
  397. attr: { is: "el-input" },
  398. },
  399. {
  400. item: { width: 150, key: "bidPrice1", title: "中标价1" },
  401. attr: {
  402. is: "el-input-number",
  403. precision: CONFIG.precision,
  404. },
  405. },
  406. {
  407. item: { width: 150, key: "unitPrice1", title: "单价1" },
  408. attr: {
  409. is: "el-input-number",
  410. precision: CONFIG.precision,
  411. },
  412. },
  413. {
  414. item: { width: 150, key: "profit1", title: "利润比1" },
  415. attr: {
  416. is: "el-input-number",
  417. precision: CONFIG.precision,
  418. },
  419. },
  420. {
  421. item: { width: 150, key: "supplierName2", title: "供应商名称2" },
  422. attr: { is: "el-input" },
  423. },
  424. {
  425. item: { width: 150, key: "bidPrice2", title: "中标价2" },
  426. attr: {
  427. is: "el-input-number",
  428. precision: CONFIG.precision,
  429. },
  430. },
  431. {
  432. item: { width: 150, key: "unitPrice2", title: "单价2" },
  433. attr: {
  434. is: "el-input-number",
  435. precision: CONFIG.precision,
  436. },
  437. },
  438. {
  439. item: { width: 150, key: "profit2", title: "利润比2" },
  440. attr: {
  441. is: "el-input-number",
  442. precision: CONFIG.precision,
  443. },
  444. },
  445. { item: { key: "createByName", title: "创建人名称" }, attr: {} },
  446. { item: { key: "updateByName", title: "更新人名称" }, attr: {} },
  447. ],
  448. },
  449. ];
  450. return { TableColumns, TabColumns };
  451. }