table-function.js 889 B

1234567891011121314151617181920212223242526272829303132
  1. import { initParams } from "@/utils/init";
  2. export default function useTable() {
  3. // 新 增
  4. const add = ({ _this, prop }) => {
  5. const { puOrgName, supplierName } = _this.params;
  6. if (!supplierName) {
  7. return _this.$notify.info("请选择供应商");
  8. }
  9. if (!puOrgName) {
  10. return _this.$notify.info("请选择采购组织");
  11. }
  12. const { tableColumns } = _this.tabColumns.find(
  13. (element) => element.key === prop
  14. );
  15. _this.params[prop].push(initParams(tableColumns));
  16. };
  17. // 删 除
  18. const remove = ({ _this, prop, scope, type }) => {
  19. const { $index } = scope;
  20. if (type === "ADD") {
  21. _this.params[prop].splice($index, 1);
  22. } else {
  23. _this.params[prop] = _this.params[prop].map((item, index) => ({
  24. ...item,
  25. delFlag: index === $index ? "2" : item.delFlag,
  26. }));
  27. }
  28. };
  29. return { add, remove };
  30. }