material-detail-option.js 12 KB

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