columns.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  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: "sourceType", title: "来源单据类型" },
  85. attr: { is: "el-input", disabled: true, readonly: true },
  86. },
  87. {
  88. item: { key: "status", title: "单据状态" },
  89. attr: {
  90. is: "el-select",
  91. dictName: "sys_status",
  92. disabled: true,
  93. readonly: true,
  94. value: "0",
  95. },
  96. },
  97. {
  98. item: { key: "file", title: "附件", span: 24 },
  99. attr: { is: "el-file-upload" },
  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: "materialCode", title: "物料编码", required: true },
  117. attr: {
  118. is: "el-input",
  119. clearable: true,
  120. },
  121. },
  122. {
  123. item: { key: "materialName", title: "物料名称", required: true },
  124. attr: {
  125. is: "el-popover-select-v2",
  126. checkbox: true,
  127. clearable: true,
  128. valueKey: "name",
  129. referName: "MATERIAL_PARAM",
  130. dataMapping: {
  131. model: "model",
  132. material: "id",
  133. materialCode: "code",
  134. materialName: "name",
  135. unitName: "unitIdName",
  136. puUnitName: "unitIdName",
  137. specification: "specification",
  138. manufacturer: "manufacturerId",
  139. manufacturerName: "manufacturerIdName",
  140. tax: "materialRateName",
  141. },
  142. },
  143. },
  144. { item: { key: "specification", title: "规格" }, attr: {} },
  145. { item: { key: "model", title: "型号" }, attr: {} },
  146. { item: { key: "manufacturerName", title: "生产厂家" }, attr: {} },
  147. {
  148. item: { key: "unitName", title: "单位" },
  149. attr: {
  150. is: "el-popover-select-v2",
  151. valueKey: "name",
  152. referName: "UNIT_PARAM",
  153. dataMapping: { unit: "id", unitCode: "code", unitName: "name" },
  154. },
  155. },
  156. // {
  157. // item: { key: "puUnitName", title: "采购单位", hidden: false },
  158. // attr: {
  159. // is: "el-popover-select-v2",
  160. // valueKey: "name",
  161. // referName: "UNIT_PARAM",
  162. // dataMapping: {
  163. // puUnit: "id",
  164. // puUnitCode: "code",
  165. // puUnitName: "name",
  166. // },
  167. // },
  168. // },
  169. // {
  170. // item: { key: "conversionRate", title: "采购换算率", required: true },
  171. // attr: {
  172. // is: "el-input-number",
  173. // min: 0,
  174. // precision: CONFIG.precision,
  175. // value: 1,
  176. // disabled: true,
  177. // },
  178. // },
  179. {
  180. item: { key: "customerName", title: "客户" },
  181. attr: {
  182. is: "el-popover-select-v2",
  183. valueKey: "name",
  184. referName: "CUSTOMER_PARAM",
  185. dataMapping: {
  186. customer: "id",
  187. customerCode: "code",
  188. customerName: "name",
  189. },
  190. },
  191. },
  192. {
  193. item: { key: "taxPrice", title: "含税单价", required: true },
  194. attr: {
  195. is: "el-input-number",
  196. min: 0.00000001,
  197. },
  198. },
  199. {
  200. item: { key: "tax", title: "税率%", required: true },
  201. attr: {
  202. is: "el-popover-select-v2",
  203. valueKey: "ntaxrate",
  204. referName: "TAX_RATE_PARAM",
  205. dataMapping: { tax: "ntaxrate" },
  206. disabled: true,
  207. },
  208. },
  209. // {
  210. // item: { key: "price", title: "无税单价", required: true },
  211. // attr: {
  212. // formatter: (prop) => {
  213. // const { tax = 0, taxPrice = 0 } = prop;
  214. // return (prop.price = iunitprice(tax, taxPrice));
  215. // },
  216. // },
  217. // },
  218. // {
  219. // item: { key: "currencyName", title: "币种" },
  220. // attr: {
  221. // is: "el-popover-select-v2",
  222. // valueKey: "name",
  223. // referName: "CURRENCY_PARAM",
  224. // dataMapping: {
  225. // currency: "id",
  226. // currencyCode: "code",
  227. // currencyName: "name",
  228. // },
  229. // },
  230. // },
  231. {
  232. item: {
  233. key: "periodBegin",
  234. title: "价格有效期(起)",
  235. required: true,
  236. },
  237. attr: {
  238. is: "el-date-picker",
  239. valueFormat: "yyyy-MM-dd",
  240. value: new Date(),
  241. },
  242. },
  243. {
  244. item: { key: "periodEnd", title: "价格有效期(止)", required: true },
  245. attr: {
  246. is: "el-date-picker",
  247. valueFormat: "yyyy-MM-dd",
  248. pickerOptions: {
  249. disabledDate(time) {
  250. return time.getTime() < Date.now() + 3600 * 1000 * 24 * 365;
  251. },
  252. },
  253. value: new Date(new Date().getTime() + 3600 * 1000 * 24 * 366),
  254. },
  255. },
  256. {
  257. item: { key: "recentlyPrice", title: "最近价格" },
  258. attr: {
  259. is: "el-input-number",
  260. min: 0,
  261. precision: CONFIG.precision,
  262. disabled: true,
  263. },
  264. },
  265. {
  266. item: {
  267. key: "recentlyPriceDate",
  268. title: "最近价格日期",
  269. },
  270. attr: {
  271. is: "el-date-picker",
  272. valueFormat: "yyyy-MM-dd",
  273. },
  274. },
  275. {
  276. item: { key: "isApprovalFirst", title: "首次报批" },
  277. attr: {
  278. is: "el-select",
  279. dictName: "is_effective",
  280. disabled: true,
  281. },
  282. },
  283. {
  284. item: { key: "isPriceAdjustmentName", title: "调价类型" },
  285. attr: {
  286. value: '无',
  287. formatter: (prop) => {
  288. const { priceDiffer } = prop;
  289. return (prop.isPriceAdjustment = priceDiffer > 0 ? '涨价' : priceDiffer < 0 ? '降价' : '无');
  290. },
  291. },
  292. },
  293. {
  294. item: { width: 100, key: "priceDiffer", title: "单价差" },
  295. attr: {
  296. formatter: (prop) => {
  297. const { taxPrice = 0, recentlyPrice = 0 } = prop;
  298. return (prop.priceDiffer = Number(recentlyPrice) !== 0 ? Number(taxPrice) - Number(recentlyPrice) : 0);
  299. },
  300. },
  301. },
  302. {
  303. item: { width: 100, key: "increase", title: "涨幅(%)" },
  304. attr: {
  305. formatter: (prop) => {
  306. const { priceDiffer = 0, recentlyPrice = 0 } = prop;
  307. return (prop.increase = recentlyPrice ? ((Number(priceDiffer) / Number(recentlyPrice)) * 100).toFixed(1) : 0);
  308. },
  309. },
  310. },
  311. {
  312. item: { width: 100, key: "yPurchaseQuantity", title: "预计年采购量" },
  313. attr: {
  314. // is: "el-computed-input-v2",
  315. formatter: (prop) => {
  316. return prop.yPurchaseQuantity
  317. },
  318. },
  319. },
  320. {
  321. item: { width: 100, key: "yPurchaseVolume", title: "预计年采购额" },
  322. attr: {
  323. formatter: (prop) => {
  324. const { taxPrice = 0, yPurchaseQuantity = 0 } = prop;
  325. return (prop.yPurchaseVolume = (Number(taxPrice) * Number(yPurchaseQuantity)).toFixed(2));
  326. },
  327. },
  328. },
  329. {
  330. item: { width: 100, key: "yAffectedAmount", title: "预计年影响金额" },
  331. attr: {
  332. formatter: (prop) => {
  333. const { priceDiffer = 0, yPurchaseQuantity = 0 } = prop;
  334. return (prop.yAffectedAmount =
  335. Number(priceDiffer) * Number(yPurchaseQuantity));
  336. },
  337. },
  338. },
  339. {
  340. item: { key: "priceType", title: "价格类型", required: true },
  341. attr: {
  342. is: "el-select",
  343. dictName: "sys_price_type",
  344. value: "order",
  345. },
  346. },
  347. {
  348. item: { key: "isDistributionPrice", title: "配送价", required: true },
  349. attr: {
  350. is: "el-select",
  351. dictName: "is_effective",
  352. value: "N",
  353. },
  354. },
  355. {
  356. item: { width: 100, key: "isChannel", title: "是否渠道变更" },
  357. attr: {
  358. is: "el-select",
  359. dictName: "is_effective",
  360. value: "N",
  361. },
  362. },
  363. {
  364. item: { width: 100, key: "brandReplacement", title: "是否品牌替换" },
  365. attr: {
  366. is: "el-select",
  367. dictName: "is_effective",
  368. value: "N",
  369. },
  370. },
  371. {
  372. item: { width: 150, key: "supplierName", title: "供应商名称1" },
  373. attr: { is: "el-input" },
  374. },
  375. {
  376. item: { width: 150, key: "bidPrice", title: "中标价1" },
  377. attr: {
  378. is: "el-input-number",
  379. min: 0,
  380. precision: CONFIG.precision,
  381. },
  382. },
  383. {
  384. item: { width: 150, key: "unitPrice", title: "单价1" },
  385. attr: {
  386. is: "el-input-number",
  387. min: 0,
  388. precision: CONFIG.precision,
  389. },
  390. },
  391. {
  392. item: { width: 150, key: "profit", title: "利润比1" },
  393. attr: {
  394. is: "el-input-number",
  395. min: 0,
  396. precision: CONFIG.precision,
  397. },
  398. },
  399. {
  400. item: { width: 150, key: "supplierName1", title: "供应商名称2" },
  401. attr: { is: "el-input" },
  402. },
  403. {
  404. item: { width: 150, key: "bidPrice1", title: "中标价2" },
  405. attr: {
  406. is: "el-input-number",
  407. min: 0,
  408. precision: CONFIG.precision,
  409. },
  410. },
  411. {
  412. item: { width: 150, key: "unitPrice1", title: "单价2" },
  413. attr: {
  414. is: "el-input-number",
  415. min: 0,
  416. precision: CONFIG.precision,
  417. },
  418. },
  419. {
  420. item: { width: 150, key: "profit1", title: "利润比2" },
  421. attr: {
  422. is: "el-input-number",
  423. min: 0,
  424. precision: CONFIG.precision,
  425. },
  426. },
  427. {
  428. item: { width: 150, key: "supplierName2", title: "供应商名称3" },
  429. attr: { is: "el-input" },
  430. },
  431. {
  432. item: { width: 150, key: "bidPrice2", title: "中标价3" },
  433. attr: {
  434. is: "el-input-number",
  435. min: 0,
  436. precision: CONFIG.precision,
  437. },
  438. },
  439. {
  440. item: { width: 150, key: "unitPrice2", title: "单价3" },
  441. attr: {
  442. is: "el-input-number",
  443. min: 0,
  444. precision: CONFIG.precision,
  445. },
  446. },
  447. {
  448. item: { width: 150, key: "profit2", title: "利润比3" },
  449. attr: {
  450. is: "el-input-number",
  451. min: 0,
  452. precision: CONFIG.precision,
  453. },
  454. },
  455. // { item: { key: "createByName", title: "创建人名称" }, attr: {} },
  456. // { item: { key: "updateByName", title: "更新人名称" }, attr: {} },
  457. {
  458. item: { key: "isPriceAdjustment", title: "", width: 10 },
  459. attr: {
  460. value: 'no',
  461. formatter: (prop) => {
  462. const { priceDiffer } = prop;
  463. return (prop.isPriceAdjustment = priceDiffer > 0 ? 'up' : priceDiffer < 0 ? 'down' : 'no');
  464. },
  465. },
  466. },
  467. ],
  468. },
  469. ];
  470. return { TableColumns, TabColumns };
  471. }