|
@@ -4,8 +4,7 @@ import useData from "../hooks/data";
|
|
|
import useDicts from "../hooks/dicts";
|
|
|
import useWatch from "../hooks/watch";
|
|
|
import useMethods from "../hooks/function";
|
|
|
-import useTable from "../hooks/table-function";
|
|
|
-import { SAVE } from "@/api/business/purchase/apply";
|
|
|
+import { ITEM, SAVE } from "@/api/business/purchase/apply";
|
|
|
const { watchPuOrgName, watchPriceApplyOrgs, watchPriceApplyItems } =
|
|
|
useWatch();
|
|
|
|
|
@@ -36,26 +35,59 @@ export default {
|
|
|
await fetchRefer({ _this: this, prop, type, source });
|
|
|
},
|
|
|
//
|
|
|
+ async fetchItem(prop) {
|
|
|
+ try {
|
|
|
+ // try
|
|
|
+ this.loading = true;
|
|
|
+ const { code, data } = await ITEM(prop);
|
|
|
+ if (code === 200) {
|
|
|
+ this.params = data;
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ // catch
|
|
|
+ console.error(err);
|
|
|
+ } finally {
|
|
|
+ // finally
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //
|
|
|
async open(prop) {
|
|
|
- this.visible = true;
|
|
|
- this.tabName = this.tabColumns[0].key;
|
|
|
- const { fetchItem } = useMethods();
|
|
|
- this.params = await fetchItem({ _this: this, prop });
|
|
|
+ this.visible = await this.fetchItem(prop);
|
|
|
},
|
|
|
//
|
|
|
async hide() {
|
|
|
this.visible = false;
|
|
|
this.params = this.resetParams();
|
|
|
+ this.tabName = this.tabColumns[0].key;
|
|
|
},
|
|
|
//
|
|
|
async useRowAdd(prop) {
|
|
|
- const { add } = useTable();
|
|
|
- await add({ _this: this, prop });
|
|
|
+ const {
|
|
|
+ $notify,
|
|
|
+ params: { tabColumns, puOrgName, supplierName },
|
|
|
+ } = this;
|
|
|
+ if (!supplierName) {
|
|
|
+ return $notify.info("请选择供应商");
|
|
|
+ }
|
|
|
+ if (!puOrgName) {
|
|
|
+ return $notify.info("请选择采购组织");
|
|
|
+ }
|
|
|
+ const { tableColumns } = tabColumns.find(
|
|
|
+ (element) => element.key === prop
|
|
|
+ );
|
|
|
+ this.params[prop].push(initParams(tableColumns));
|
|
|
},
|
|
|
//
|
|
|
async useRowRemove(prop, scope) {
|
|
|
- const { remove } = useTable();
|
|
|
- await remove({ _this: this, prop, scope, type: "EDIT" });
|
|
|
+ const { $index } = scope;
|
|
|
+ this.params[prop] = this.params[prop].map((item, index) => ({
|
|
|
+ ...item,
|
|
|
+ delFlag: index === $index ? "2" : item.delFlag,
|
|
|
+ }));
|
|
|
},
|
|
|
//
|
|
|
async useSubmit(prop) {
|