columns.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  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: "isPriceAdjustmentName", title: "调价类型" },
  279. attr: {
  280. value: '无',
  281. formatter: (prop) => {
  282. const { priceDiffer } = prop;
  283. return (prop.isPriceAdjustment = priceDiffer > 0 ? '涨价' : priceDiffer < 0 ? '降价' : '无');
  284. },
  285. },
  286. },
  287. {
  288. item: { key: "priceType", title: "价格类型", required: true },
  289. attr: {
  290. is: "el-select",
  291. dictName: "sys_price_type",
  292. value: "order",
  293. },
  294. },
  295. {
  296. item: { key: "isDistributionPrice", title: "配送价", required: true },
  297. attr: {
  298. is: "el-select",
  299. dictName: "is_effective",
  300. value: "N",
  301. },
  302. },
  303. {
  304. item: { width: 100, key: "isChannel", title: "是否渠道变更" },
  305. attr: {
  306. is: "el-select",
  307. dictName: "is_effective",
  308. value: "N",
  309. },
  310. },
  311. {
  312. item: { width: 100, key: "brandReplacement", title: "是否品牌替换" },
  313. attr: {
  314. is: "el-select",
  315. dictName: "is_effective",
  316. value: "N",
  317. },
  318. },
  319. {
  320. item: { width: 100, key: "priceDiffer", title: "单价差" },
  321. attr: {
  322. formatter: (prop) => {
  323. const { taxPrice = 0, recentlyPrice = 0 } = prop;
  324. return (prop.priceDiffer = Number(recentlyPrice) !== 0 ? Number(taxPrice) - Number(recentlyPrice) : 0);
  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. item: { width: 150, key: "supplierName", title: "供应商名称1" },
  371. attr: { is: "el-input" },
  372. },
  373. {
  374. item: { width: 150, key: "bidPrice", title: "中标价1" },
  375. attr: {
  376. is: "el-input-number",
  377. precision: CONFIG.precision,
  378. },
  379. },
  380. {
  381. item: { width: 150, key: "unitPrice", title: "单价1" },
  382. attr: {
  383. is: "el-input-number",
  384. precision: CONFIG.precision,
  385. },
  386. },
  387. {
  388. item: { width: 150, key: "profit", title: "利润比1" },
  389. attr: {
  390. is: "el-input-number",
  391. precision: CONFIG.precision,
  392. },
  393. },
  394. {
  395. item: { width: 150, key: "supplierName1", title: "供应商名称2" },
  396. attr: { is: "el-input" },
  397. },
  398. {
  399. item: { width: 150, key: "bidPrice1", title: "中标价2" },
  400. attr: {
  401. is: "el-input-number",
  402. precision: CONFIG.precision,
  403. },
  404. },
  405. {
  406. item: { width: 150, key: "unitPrice1", title: "单价2" },
  407. attr: {
  408. is: "el-input-number",
  409. precision: CONFIG.precision,
  410. },
  411. },
  412. {
  413. item: { width: 150, key: "profit1", title: "利润比2" },
  414. attr: {
  415. is: "el-input-number",
  416. precision: CONFIG.precision,
  417. },
  418. },
  419. {
  420. item: { width: 150, key: "supplierName2", title: "供应商名称3" },
  421. attr: { is: "el-input" },
  422. },
  423. {
  424. item: { width: 150, key: "bidPrice2", title: "中标价3" },
  425. attr: {
  426. is: "el-input-number",
  427. precision: CONFIG.precision,
  428. },
  429. },
  430. {
  431. item: { width: 150, key: "unitPrice2", title: "单价3" },
  432. attr: {
  433. is: "el-input-number",
  434. precision: CONFIG.precision,
  435. },
  436. },
  437. {
  438. item: { width: 150, key: "profit2", title: "利润比3" },
  439. attr: {
  440. is: "el-input-number",
  441. precision: CONFIG.precision,
  442. },
  443. },
  444. { item: { key: "createByName", title: "创建人名称" }, attr: {} },
  445. { item: { key: "updateByName", title: "更新人名称" }, attr: {} },
  446. {
  447. item: { key: "isPriceAdjustment", title: "", width: 10 },
  448. attr: {
  449. value: 'no',
  450. formatter: (prop) => {
  451. const { priceDiffer } = prop;
  452. return (prop.isPriceAdjustment = priceDiffer > 0 ? 'up' : priceDiffer < 0 ? 'down' : 'no');
  453. },
  454. },
  455. },
  456. ],
  457. },
  458. ];
  459. return { TableColumns, TabColumns };
  460. }