material-detail-option.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. /**
  2. * @fileoverview 物料明细表格配置文件
  3. * @description 定义物料明细表格的AvueJS配置选项、数据类型和相关常量
  4. */
  5. // 从constants.js导入常量
  6. import {
  7. MaterialDetailStatus,
  8. DEFAULT_PAGINATION_CONFIG,
  9. MATERIAL_DETAIL_STATUS_OPTIONS
  10. } from './constants'
  11. // 从types.js导入类型定义
  12. import { MaterialDetailDataSource } from './constants'
  13. // 重新导出常量供其他模块使用
  14. export { MaterialDetailStatus, DEFAULT_PAGINATION_CONFIG, MATERIAL_DETAIL_STATUS_OPTIONS }
  15. /**
  16. * @typedef {import('./constants').MaterialDetailRecord} MaterialDetailRecord
  17. * @typedef {import('./constants').MaterialDetailQueryParams} MaterialDetailQueryParams
  18. * @typedef {import('./constants').ValidationRule} ValidationRule
  19. * @typedef {import('./constants').OrderFormModel} OrderFormModel
  20. */
  21. /**
  22. * @typedef {import('@smallwei/avue').AvueCrudOption} AvueCrudOption
  23. * @typedef {import('@smallwei/avue').AvueCrudColumn} AvueCrudColumn
  24. */
  25. /**
  26. * AvueJS分页配置选项类型定义
  27. * @typedef {Object} AvuePaginationOption
  28. * @description AvueJS表格分页配置对象
  29. * @property {number} pageSize - 每页显示条数,默认10
  30. * @property {number[]} pageSizes - 每页显示个数选择器的选项设置
  31. * @property {string} layout - 组件布局,子组件名用逗号分隔
  32. */
  33. /**
  34. * AvueJS表格配置选项类型定义
  35. * @typedef {Object} AvueTableOption
  36. * @description 物料明细表格的AvueJS配置对象
  37. * @property {boolean} border - 是否显示边框
  38. * @property {boolean} index - 是否显示序号列
  39. * @property {string} indexLabel - 序号列标题
  40. * @property {boolean} stripe - 是否显示斑马纹
  41. * @property {'left'|'center'|'right'} menuAlign - 操作列对齐方式
  42. * @property {'left'|'center'|'right'} align - 表格内容对齐方式
  43. * @property {boolean} [refreshBtn] - 是否显示刷新按钮
  44. * @property {boolean} [columnBtn] - 是否显示列设置按钮
  45. * @property {boolean} searchShow - 是否显示搜索区域
  46. * @property {boolean} addBtn - 是否显示新增按钮
  47. * @property {boolean} editBtn - 是否显示编辑按钮
  48. * @property {boolean} delBtn - 是否显示删除按钮
  49. * @property {boolean} viewBtn - 是否显示查看按钮
  50. * @property {boolean} [selection] - 是否显示多选框
  51. * @property {boolean} [reserveSelection] - 是否保留选择状态
  52. * @property {string} [height] - 表格高度
  53. * @property {string} [calcHeight] - 计算高度的偏移量
  54. * @property {AvuePaginationOption|boolean} page - 分页配置,true启用默认分页,对象为详细配置
  55. * @property {AvueColumnOption[]} column - 列配置数组
  56. */
  57. /**
  58. * AvueJS列配置选项类型定义
  59. * @typedef {Object} AvueColumnOption
  60. * @description 表格列的配置对象
  61. * @property {string} label - 列标题
  62. * @property {string} prop - 列属性名
  63. * @property {'text'|'number'|'select'|'date'|'datetime'} [type] - 列类型
  64. * @property {number} [minWidth] - 最小宽度
  65. * @property {number} [width] - 固定宽度
  66. * @property {boolean} [sortable] - 是否可排序
  67. * @property {'left'|'center'|'right'} [align] - 对齐方式
  68. * @property {boolean} [overHidden] - 是否隐藏溢出内容
  69. * @property {boolean} [hide] - 是否隐藏列
  70. * @property {number} [precision] - 数字精度
  71. * @property {{label: string, value: string|number}[]} [dicData] - 字典数据
  72. * @property {ValidationRule[]} [rules] - 验证规则
  73. */
  74. /**
  75. * 获取物料明细表格配置
  76. * @param {boolean} [isEditMode=false] - 是否为编辑模式
  77. * @returns {AvueTableOption} AvueJS表格配置对象
  78. */
  79. export function getMaterialDetailOption(isEditMode = false) {
  80. return {
  81. border: true,
  82. index: true,
  83. indexLabel: '序号',
  84. stripe: true,
  85. menuAlign: 'center',
  86. align: 'center',
  87. addBtn: false,
  88. editBtn: false,
  89. delBtn: false,
  90. viewBtn: false,
  91. searchShow: false,
  92. cellBtn: isEditMode,
  93. page: DEFAULT_PAGINATION_CONFIG,
  94. menuWidth: 120,
  95. rowKey: 'id',
  96. column: [
  97. {
  98. label: '物料编码',
  99. prop: 'itemCode',
  100. width: 120,
  101. rules: [{
  102. required: true,
  103. message: '请输入物料编码',
  104. trigger: 'blur'
  105. }]
  106. },
  107. {
  108. label: '物料名称',
  109. prop: 'itemName',
  110. width: 150,
  111. rules: [{
  112. required: true,
  113. message: '请输入物料名称',
  114. trigger: 'blur'
  115. }]
  116. },
  117. {
  118. label: '规格型号',
  119. prop: 'specs',
  120. width: 120
  121. },
  122. {
  123. label: '主物料分类',
  124. prop: 'mainItemCategoryName',
  125. width: 120
  126. },
  127. {
  128. label: '仓库名称',
  129. prop: 'warehouseName',
  130. width: 120
  131. },
  132. {
  133. label: '可用数量',
  134. prop: 'availableQuantity',
  135. type: 'number',
  136. precision: 2,
  137. width: 100,
  138. align: 'right',
  139. slot: true
  140. },
  141. {
  142. label: '订单数量',
  143. prop: 'orderQuantity',
  144. type: 'number',
  145. precision: 4,
  146. width: 100,
  147. align: 'right',
  148. slot: true
  149. },
  150. {
  151. label: '确认数量',
  152. prop: 'confirmQuantity',
  153. type: 'number',
  154. precision: 2,
  155. width: 100,
  156. align: 'right',
  157. slot: true
  158. },
  159. {
  160. label: '单价',
  161. prop: 'unitPrice',
  162. type: 'number',
  163. precision: 2,
  164. width: 100,
  165. align: 'right',
  166. slot: true,
  167. rules: [{
  168. required: true,
  169. message: '请输入单价',
  170. trigger: 'blur'
  171. }]
  172. },
  173. {
  174. label: '税率(%)',
  175. prop: 'taxRate',
  176. type: 'number',
  177. precision: 2,
  178. width: 100,
  179. align: 'right',
  180. slot: true
  181. },
  182. {
  183. label: '税额',
  184. prop: 'taxAmount',
  185. type: 'number',
  186. precision: 2,
  187. width: 100,
  188. align: 'right',
  189. slot: true
  190. },
  191. {
  192. label: '总金额',
  193. prop: 'totalAmount',
  194. type: 'number',
  195. precision: 2,
  196. width: 120,
  197. align: 'right',
  198. slot: true
  199. },
  200. {
  201. label: '明细状态',
  202. prop: 'status',
  203. type: 'select',
  204. dicData: MATERIAL_DETAIL_STATUS_OPTIONS,
  205. width: 100
  206. },
  207. {
  208. label: '物料ID',
  209. prop: 'itemId',
  210. hide: true
  211. },
  212. {
  213. label: '主物料分类ID',
  214. prop: 'mainCategoryId',
  215. hide: true
  216. },
  217. {
  218. label: '仓库ID',
  219. prop: 'warehouseId',
  220. hide: true
  221. }
  222. ]
  223. }
  224. }
  225. /**
  226. * 获取物料导入筛选表格配置
  227. * @description 生成物料导入弹窗中筛选表格的AvueJS配置选项
  228. * @returns {AvueCrudOption} AvueJS表格配置对象
  229. */
  230. export function getMaterialImportOption() {
  231. return {
  232. border: true,
  233. index: true,
  234. indexLabel: '序号',
  235. stripe: true,
  236. menuAlign: 'center',
  237. align: 'center',
  238. addBtn: false,
  239. editBtn: false,
  240. delBtn: false,
  241. viewBtn: false,
  242. menu: false,
  243. searchShow: false,
  244. selection: true,
  245. selectionWidth: 60,
  246. page: true,
  247. column: [
  248. {
  249. label: '物料编码',
  250. prop: 'itemCode',
  251. width: 120
  252. },
  253. {
  254. label: '物料名称',
  255. prop: 'itemName',
  256. width: 150
  257. },
  258. {
  259. label: '规格型号',
  260. prop: 'specification',
  261. width: 120
  262. },
  263. {
  264. label: '物料描述',
  265. prop: 'itemDescription',
  266. width: 200,
  267. overHidden: true
  268. },
  269. {
  270. label: '主物料分类',
  271. prop: 'mainCategoryName',
  272. width: 120
  273. },
  274. {
  275. label: '分类编码',
  276. prop: 'mainCategoryCode',
  277. width: 100
  278. },
  279. {
  280. label: '单位',
  281. prop: 'inventoryInfoName',
  282. width: 80,
  283. align: 'center'
  284. },
  285. {
  286. label: '仓库名称',
  287. prop: 'warehouseName',
  288. width: 120
  289. },
  290. {
  291. label: '仓库编码',
  292. prop: 'warehouseCode',
  293. width: 100
  294. },
  295. {
  296. label: '可用数量',
  297. prop: 'availableQuantity',
  298. type: 'number',
  299. precision: 2,
  300. width: 100,
  301. align: 'right'
  302. },
  303. {
  304. label: '销售员',
  305. prop: 'saleserName',
  306. width: 100
  307. },
  308. {
  309. label: '发货仓库',
  310. prop: 'shipmentWarehouseName',
  311. width: 120
  312. },
  313. {
  314. label: '组织名称',
  315. prop: 'orgName',
  316. width: 120
  317. },
  318. {
  319. label: '创建时间',
  320. prop: 'createTime',
  321. width: 150,
  322. type: 'datetime',
  323. format: 'YYYY-MM-DD HH:mm:ss'
  324. },
  325. {
  326. label: '物料ID',
  327. prop: 'itemId',
  328. hide: true
  329. },
  330. {
  331. label: '主物料分类ID',
  332. prop: 'mainCategoryId',
  333. hide: true
  334. },
  335. {
  336. label: '仓库ID',
  337. prop: 'warehouseId',
  338. hide: true
  339. },
  340. {
  341. label: '库存信息ID',
  342. prop: 'inventoryInfoId',
  343. hide: true
  344. },
  345. {
  346. label: '销售员ID',
  347. prop: 'saleserId',
  348. hide: true
  349. },
  350. {
  351. label: '发货仓库ID',
  352. prop: 'shipmentWarehouseId',
  353. hide: true
  354. },
  355. {
  356. label: '组织ID',
  357. prop: 'orgId',
  358. hide: true
  359. }
  360. ]
  361. }
  362. }
  363. /**
  364. * 默认物料明细查询参数
  365. * @type {MaterialDetailQueryParams}
  366. */
  367. export const DEFAULT_QUERY_PARAMS = {
  368. itemName: '',
  369. itemCode: '',
  370. specification: '',
  371. warehouseName: '',
  372. current: 1,
  373. size: 10
  374. }
  375. // 重新导出MaterialDetailDataSource供其他模块使用
  376. export { MaterialDetailDataSource }
  377. /**
  378. * 默认表单数据
  379. * @type {Readonly<MaterialDetailRecord>}
  380. */
  381. export const DEFAULT_FORM_DATA = {
  382. itemCode: '',
  383. itemName: '',
  384. specification: '',
  385. mainCategoryName: '',
  386. warehouseName: '',
  387. availableQuantity: 0,
  388. orderQuantity: 0,
  389. confirmQuantity: 0,
  390. unitPrice: 0,
  391. taxRate: 0,
  392. taxAmount: 0,
  393. totalAmount: 0,
  394. status: '0', // MaterialDetailStatus.PENDING
  395. dataSource: MaterialDetailDataSource.IMPORTED,
  396. isDeletable: true
  397. }