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