1234567891011121314151617181920212223242526272829303132 |
- import { initParams } from "@/utils/init";
- export default function useTable() {
- // 新 增
- const add = ({ _this, prop }) => {
- const { puOrgName, supplierName } = _this.params;
- if (!supplierName) {
- return _this.$notify.info("请选择供应商");
- }
- if (!puOrgName) {
- return _this.$notify.info("请选择采购组织");
- }
- const { tableColumns } = _this.tabColumns.find(
- (element) => element.key === prop
- );
- _this.params[prop].push(initParams(tableColumns));
- };
- // 删 除
- const remove = ({ _this, prop, scope, type }) => {
- const { $index } = scope;
- if (type === "ADD") {
- _this.params[prop].splice($index, 1);
- } else {
- _this.params[prop] = _this.params[prop].map((item, index) => ({
- ...item,
- delFlag: index === $index ? "2" : item.delFlag,
- }));
- }
- };
- return { add, remove };
- }
|