|
@@ -1,6 +1,6 @@
|
|
|
import { REFER } from "@/components/popover-select/api";
|
|
|
import { EXIST } from "@/api/business/purchase/catalogue";
|
|
|
-import { SAVE, ITEM } from "@/api/business/purchase/apply";
|
|
|
+import { ITEM } from "@/api/business/purchase/apply";
|
|
|
|
|
|
export default function useMethods() {
|
|
|
const fetchItem = async ({ _this, prop }) => {
|
|
@@ -9,7 +9,7 @@ export default function useMethods() {
|
|
|
_this.loading = true;
|
|
|
const { code, data } = await ITEM(prop);
|
|
|
if (code === 200) {
|
|
|
- _this.params = data;
|
|
|
+ return data;
|
|
|
}
|
|
|
} catch (err) {
|
|
|
|
|
@@ -50,7 +50,6 @@ export default function useMethods() {
|
|
|
source.recentlyPrice = recentlyPrice;
|
|
|
source.isApprovalFirst = isApprovalFirst;
|
|
|
source.isPriceAdjustment = isPriceAdjustment;
|
|
|
-
|
|
|
}
|
|
|
} catch (err) {
|
|
|
|
|
@@ -61,87 +60,8 @@ export default function useMethods() {
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
- const open = ({ _this }) => {
|
|
|
- _this.visible = true;
|
|
|
- _this.tabName = _this.tabColumns[0].key;
|
|
|
- };
|
|
|
- const hide = ({ _this }) => {
|
|
|
- _this.visible = false;
|
|
|
- };
|
|
|
- const add = ({ _this, prop }) => {
|
|
|
- _this.$refs[prop].validate(async (valid) => {
|
|
|
- if (valid) {
|
|
|
- try {
|
|
|
-
|
|
|
- const {
|
|
|
- priceApplyOrgs: _priceApplyOrgs,
|
|
|
- priceApplyItems: _priceApplyItems,
|
|
|
- } = _this.params;
|
|
|
- const id = undefined;
|
|
|
- const priceApplyOrgs = _priceApplyOrgs.map((item) => ({
|
|
|
- ...item,
|
|
|
- id: undefined,
|
|
|
- applyId: undefined,
|
|
|
- }));
|
|
|
- const priceApplyItems = _priceApplyItems.map((item) => ({
|
|
|
- ...item,
|
|
|
- id: undefined,
|
|
|
- applyId: undefined,
|
|
|
- }));
|
|
|
- const { msg, code } = await SAVE({
|
|
|
- ..._this.params,
|
|
|
- id,
|
|
|
- priceApplyOrgs,
|
|
|
- priceApplyItems,
|
|
|
- });
|
|
|
- if (code === 200) {
|
|
|
- _this.hide();
|
|
|
- _this.$emit("success");
|
|
|
- _this.$notify.success(msg);
|
|
|
- }
|
|
|
- } catch (err) {
|
|
|
-
|
|
|
- console.error(err);
|
|
|
- } finally {
|
|
|
-
|
|
|
- _this.loading = false;
|
|
|
- }
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- });
|
|
|
- };
|
|
|
- const edit = ({ _this, prop }) => {
|
|
|
- _this.$refs[prop].validate(async (valid) => {
|
|
|
- if (valid) {
|
|
|
- try {
|
|
|
-
|
|
|
- const { msg, code } = await SAVE({
|
|
|
- ..._this.params,
|
|
|
- });
|
|
|
- if (code === 200) {
|
|
|
- _this.hide();
|
|
|
- _this.$emit("success");
|
|
|
- _this.$notify.success(msg);
|
|
|
- }
|
|
|
- } catch (err) {
|
|
|
-
|
|
|
- console.error(err);
|
|
|
- } finally {
|
|
|
-
|
|
|
- _this.loading = false;
|
|
|
- }
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- });
|
|
|
- };
|
|
|
|
|
|
return {
|
|
|
- open,
|
|
|
- hide,
|
|
|
- add,
|
|
|
- edit,
|
|
|
fetchItem,
|
|
|
fetchRefer,
|
|
|
};
|