main.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import XEUtils from "xe-utils"
  2. import { materialDic } from "@/utils/basicDic"
  3. import { mapFormItemInput } from "@/components/scTable/helper"
  4. export const tableOptions = reactive({
  5. tableKey: "material",
  6. columns: [
  7. { type: "seq", fixed: "left", width: 80, className: "vxe-table-seq-cell__handler", footerAlign: "right", showOverflow: false, slots: { default: "seq_del" } },
  8. { field: "code", title: "产品编码", fixed: "left", minWidth: 150 },
  9. { field: "name", title: "产品名称", fixed: "left", minWidth: 150 },
  10. { field: "unit", title: "单位", minWidth: 150 },
  11. { field: "quantity", title: "数量", minWidth: 100, editRender: { name: "VxeNumberInput", props: { min: 1, controlConfig: { enabled: false } }, defaultValue: 1 } },
  12. { field: "price", title: "单价", minWidth: 100, editRender: { name: "VxeNumberInput", props: { min: 0, type: "float", controlConfig: { enabled: false } }, defaultValue: 1 } }
  13. ],
  14. editRules: {
  15. quantity: [{ required: true, message: "必须填写" }],
  16. price: [{ required: true, message: "必须填写" }]
  17. },
  18. footerField: [["quantity", "price"], ["quantity"]],
  19. footerTitle: ["合计:", "整单标价总额:"],
  20. footerMethod: [
  21. (data, field) => XEUtils.sum(data, field),
  22. (data, field) => XEUtils.sum(XEUtils.map(data, item => XEUtils.multiply(XEUtils.get(item, field), XEUtils.get(item, "price"))))
  23. ],
  24. // 整单标价总额
  25. mergeFooterItems: [
  26. { row: 0, col: 0, rowspan: 1, colspan: 4 },
  27. { row: 1, col: 0, rowspan: 1, colspan: 4 },
  28. { row: 1, col: 4, rowspan: 2, colspan: 2 }
  29. ],
  30. selectOptions: {
  31. paramsColums: [
  32. { column: "status", defaultValue: "enable" },
  33. { column: "materialTypeIn", defaultValue: materialDic.typeRelation["salable"] }
  34. ]
  35. },
  36. add_success: (oldValue, newValue) => XEUtils.map(newValue, (item, index) => XEUtils.pick(item, "id", "code", "name", "unit", "price"))
  37. })
  38. export const selectOptions = reactive({
  39. tableKey: "customer",
  40. valueKey: "name",
  41. paramsColums: [{ column: "status", defaultValue: "enable" }]
  42. })