|
@@ -1,7 +1,7 @@
|
|
<script>
|
|
<script>
|
|
import useColumns from "./columns";
|
|
import useColumns from "./columns";
|
|
import { EXIST } from "@/api/business/purchase/catalogue";
|
|
import { EXIST } from "@/api/business/purchase/catalogue";
|
|
-import { ITEM, SAVE } from "@/api/business/purchase/apply";
|
|
|
|
|
|
+import { SAVE } from "@/api/business/purchase/apply";
|
|
import { tax, unit, currency } from "@/components/popover-select-v2/fetch";
|
|
import { tax, unit, currency } from "@/components/popover-select-v2/fetch";
|
|
|
|
|
|
const fetchExist = async (prop) => {
|
|
const fetchExist = async (prop) => {
|
|
@@ -23,14 +23,6 @@ export default {
|
|
dict: {
|
|
dict: {
|
|
type: Object,
|
|
type: Object,
|
|
},
|
|
},
|
|
- selectData: {
|
|
|
|
- type: [Array],
|
|
|
|
- require: true,
|
|
|
|
- },
|
|
|
|
- addType: {
|
|
|
|
- type: String,
|
|
|
|
- default: "add",
|
|
|
|
- },
|
|
|
|
},
|
|
},
|
|
components: {
|
|
components: {
|
|
ElSuperForm: () => import("@/components/super-form/index.vue"),
|
|
ElSuperForm: () => import("@/components/super-form/index.vue"),
|
|
@@ -50,6 +42,7 @@ export default {
|
|
const rules = this.$init.rules([...TabColumns, ...TableColumns]);
|
|
const rules = this.$init.rules([...TabColumns, ...TableColumns]);
|
|
const params = this.$init.params([...TabColumns, ...TableColumns]);
|
|
const params = this.$init.params([...TabColumns, ...TableColumns]);
|
|
return {
|
|
return {
|
|
|
|
+ title: "新 增",
|
|
width: "100%",
|
|
width: "100%",
|
|
visible: false,
|
|
visible: false,
|
|
loading: false,
|
|
loading: false,
|
|
@@ -60,82 +53,21 @@ export default {
|
|
TableColumns: TableColumns,
|
|
TableColumns: TableColumns,
|
|
};
|
|
};
|
|
},
|
|
},
|
|
- computed: {
|
|
|
|
- title: {
|
|
|
|
- get() {
|
|
|
|
- const { addType } = this;
|
|
|
|
- if (addType === "add") {
|
|
|
|
- return "新 增";
|
|
|
|
- }
|
|
|
|
- if (addType === "copy") {
|
|
|
|
- return "复 制";
|
|
|
|
- }
|
|
|
|
- if (addType === "edit") {
|
|
|
|
- return "编 辑";
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- set() {},
|
|
|
|
- },
|
|
|
|
- disabled: {
|
|
|
|
- get() {
|
|
|
|
- const {
|
|
|
|
- addType,
|
|
|
|
- selectData,
|
|
|
|
- selectData: [{ status } = {}],
|
|
|
|
- } = this.$props;
|
|
|
|
- if (addType === "add") {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- if (addType === "copy") {
|
|
|
|
- if (selectData.length !== 1) {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (addType === "edit") {
|
|
|
|
- if (selectData.length !== 1) {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- if (selectData.length === 1 && status === "1") {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- if (selectData.length === 1 && status === "2") {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- set() {},
|
|
|
|
- },
|
|
|
|
- priceApply: {
|
|
|
|
- get() {
|
|
|
|
- this.params.priceApplyItems = this.params.priceApplyItems.map(
|
|
|
|
- (item, index) => ({
|
|
|
|
- ...item,
|
|
|
|
- $index: index,
|
|
|
|
- })
|
|
|
|
- );
|
|
|
|
- return {
|
|
|
|
- priceApplyItems: this.params.priceApplyItems.filter(
|
|
|
|
- ({ delFlag }) => delFlag !== "2"
|
|
|
|
- ),
|
|
|
|
- };
|
|
|
|
- },
|
|
|
|
- set() {},
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
|
|
+ computed: {},
|
|
watch: {},
|
|
watch: {},
|
|
methods: {
|
|
methods: {
|
|
//
|
|
//
|
|
changeMaterialName(prop) {
|
|
changeMaterialName(prop) {
|
|
const { row } = prop;
|
|
const { row } = prop;
|
|
const { puOrg, customer, supplier } = this.params;
|
|
const { puOrg, customer, supplier } = this.params;
|
|
- const { rateCode, unitIdName, code: materialCode } = row;
|
|
|
|
|
|
+ const { tax: taxName, unitName, code: materialCode } = row;
|
|
// task 1
|
|
// task 1
|
|
- tax(rateCode).then((res) => {
|
|
|
|
|
|
+ tax(taxName).then((res) => {
|
|
const { ntaxrate } = res;
|
|
const { ntaxrate } = res;
|
|
row.tax = ntaxrate === "0E-8" ? "0.000000" : (ntaxrate * 1).toFixed(6);
|
|
row.tax = ntaxrate === "0E-8" ? "0.000000" : (ntaxrate * 1).toFixed(6);
|
|
});
|
|
});
|
|
// task 2
|
|
// task 2
|
|
- unit(unitIdName).then((res) => {
|
|
|
|
|
|
+ unit(unitName).then((res) => {
|
|
const { id, code, name } = res;
|
|
const { id, code, name } = res;
|
|
row.unit = id;
|
|
row.unit = id;
|
|
row.unitCode = code;
|
|
row.unitCode = code;
|
|
@@ -145,99 +77,50 @@ export default {
|
|
row.puUnitName = name;
|
|
row.puUnitName = name;
|
|
});
|
|
});
|
|
// task 3
|
|
// task 3
|
|
|
|
+ currency("人民币").then((res) => {
|
|
|
|
+ const { id, code, name } = res;
|
|
|
|
+ row.currency = id;
|
|
|
|
+ row.currencyCode = code;
|
|
|
|
+ row.currencyName = name;
|
|
|
|
+ });
|
|
|
|
+ // task 4
|
|
fetchExist({ puOrg, customer, supplier, materialCode }).then((res) => {
|
|
fetchExist({ puOrg, customer, supplier, materialCode }).then((res) => {
|
|
const { recentlyPrice, isApprovalFirst, isPriceAdjustment } = res;
|
|
const { recentlyPrice, isApprovalFirst, isPriceAdjustment } = res;
|
|
row.recentlyPrice = recentlyPrice;
|
|
row.recentlyPrice = recentlyPrice;
|
|
- row.isApprovalFirst = isApprovalFirst;
|
|
|
|
- row.isPriceAdjustment = isPriceAdjustment;
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- //
|
|
|
|
- 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;
|
|
|
|
|
|
+ if (isApprovalFirst) {
|
|
|
|
+ row.isApprovalFirst = isApprovalFirst == 0 ? "Y" : "N";
|
|
}
|
|
}
|
|
- } catch (err) {
|
|
|
|
- // catch
|
|
|
|
- console.error(err);
|
|
|
|
- } finally {
|
|
|
|
- // finally
|
|
|
|
- this.loading = false;
|
|
|
|
- }
|
|
|
|
|
|
+ if (isPriceAdjustment) {
|
|
|
|
+ row.isPriceAdjustment = isPriceAdjustment == 0 ? "Y" : "N";
|
|
|
|
+ }
|
|
|
|
+ });
|
|
},
|
|
},
|
|
//
|
|
//
|
|
async onOpen() {
|
|
async onOpen() {
|
|
- const { addType, selectData } = this.$props;
|
|
|
|
- if (addType === "add") {
|
|
|
|
- this.visible = true;
|
|
|
|
- const {
|
|
|
|
- deptId: puDept,
|
|
|
|
- deptName: puDeptName,
|
|
|
|
- name: buyer,
|
|
|
|
- nickName: buyerName,
|
|
|
|
- orgId: puOrg,
|
|
|
|
- orgName: puOrgName,
|
|
|
|
- } = this.$store.state.user;
|
|
|
|
- const { id, code, name } = await currency("人民币");
|
|
|
|
- this.params.currency = id;
|
|
|
|
- this.params.currencyCode = code;
|
|
|
|
- this.params.currencyName = name;
|
|
|
|
- this.params.puOrg = puOrg;
|
|
|
|
- this.params.puOrgName = puOrgName;
|
|
|
|
- this.params.buyer = buyer;
|
|
|
|
- this.params.buyerName = buyerName;
|
|
|
|
- this.params.puDept = puDept;
|
|
|
|
- this.params.puDeptName = puDeptName;
|
|
|
|
- }
|
|
|
|
- if (addType === "copy") {
|
|
|
|
- const [{ id }] = selectData;
|
|
|
|
- this.visible = await this.fetchItem(id);
|
|
|
|
- this.params.id = null;
|
|
|
|
- this.params.createBy = null;
|
|
|
|
- this.params.priceCode = null;
|
|
|
|
- this.params.createByName = null;
|
|
|
|
- this.params.effectiveDate = null;
|
|
|
|
- this.params.priceApplyItems = this.params.priceApplyItems.map(
|
|
|
|
- (item) => ({
|
|
|
|
- ...item,
|
|
|
|
- id: null,
|
|
|
|
- applyId: null,
|
|
|
|
- createByName: null,
|
|
|
|
- updateByName: null,
|
|
|
|
- })
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
- if (addType === "edit") {
|
|
|
|
- const [{ id }] = selectData;
|
|
|
|
- this.visible = await this.fetchItem(id);
|
|
|
|
- this.params.priceApplyItems = this.params.priceApplyItems.map(
|
|
|
|
- (item) => ({
|
|
|
|
- ...item,
|
|
|
|
- })
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
|
|
+ this.visible = true;
|
|
|
|
+ const {
|
|
|
|
+ deptId: puDept,
|
|
|
|
+ deptName: puDeptName,
|
|
|
|
+ name: buyer,
|
|
|
|
+ nickName: buyerName,
|
|
|
|
+ orgId: puOrg,
|
|
|
|
+ orgName: puOrgName,
|
|
|
|
+ } = this.$store.state.user;
|
|
|
|
+ const { id, code, name } = await currency("人民币");
|
|
|
|
+ this.params.currency = id;
|
|
|
|
+ this.params.currencyCode = code;
|
|
|
|
+ this.params.currencyName = name;
|
|
|
|
+ this.params.puOrg = puOrg;
|
|
|
|
+ this.params.puOrgName = puOrgName;
|
|
|
|
+ this.params.buyer = buyer;
|
|
|
|
+ this.params.buyerName = buyerName;
|
|
|
|
+ this.params.puDept = puDept;
|
|
|
|
+ this.params.puDeptName = puDeptName;
|
|
},
|
|
},
|
|
//
|
|
//
|
|
async onHide() {
|
|
async onHide() {
|
|
- const {
|
|
|
|
- TabColumns,
|
|
|
|
- TableColumns,
|
|
|
|
- TabColumns: [
|
|
|
|
- {
|
|
|
|
- item: { key: tabName },
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- } = useColumns();
|
|
|
|
|
|
+ const { TabColumns, TableColumns } = useColumns();
|
|
this.visible = false;
|
|
this.visible = false;
|
|
- this.tabName = tabName;
|
|
|
|
this.params = this.$init.params([...TabColumns, ...TableColumns]);
|
|
this.params = this.$init.params([...TabColumns, ...TableColumns]);
|
|
},
|
|
},
|
|
//
|
|
//
|
|
@@ -263,39 +146,15 @@ export default {
|
|
},
|
|
},
|
|
//
|
|
//
|
|
async onRowRemove(prop, scope) {
|
|
async onRowRemove(prop, scope) {
|
|
- const { addType } = this.$props;
|
|
|
|
- const {
|
|
|
|
- row: { $index },
|
|
|
|
- } = scope;
|
|
|
|
- if (addType === "add") {
|
|
|
|
- this.params[prop].splice($index, 1);
|
|
|
|
- }
|
|
|
|
- if (addType === "copy") {
|
|
|
|
- this.params[prop].splice($index, 1);
|
|
|
|
- }
|
|
|
|
- if (addType === "edit") {
|
|
|
|
- this.params[prop] = this.params[prop].map((item, index) => ({
|
|
|
|
- ...item,
|
|
|
|
- delFlag: index === $index ? "2" : item.delFlag,
|
|
|
|
- }));
|
|
|
|
- console.log(this.params[prop]);
|
|
|
|
- }
|
|
|
|
|
|
+ const { $index } = scope;
|
|
|
|
+ this.params[prop].splice($index, 1);
|
|
},
|
|
},
|
|
//
|
|
//
|
|
async useSubmit(prop) {
|
|
async useSubmit(prop) {
|
|
- this.$refs[prop].$refs[prop].validate(async (valid) => {
|
|
|
|
- console.log(this.params);
|
|
|
|
|
|
+ this.$refs[prop].validate(async (valid) => {
|
|
if (valid) {
|
|
if (valid) {
|
|
try {
|
|
try {
|
|
this.loading = true;
|
|
this.loading = true;
|
|
- if (this.addType === "copy") {
|
|
|
|
- this.params.priceApplyOrgs = [];
|
|
|
|
- }
|
|
|
|
- if (this.addType === "edit") {
|
|
|
|
- this.params.priceApplyItems = this.params.priceApplyItems.filter(
|
|
|
|
- (item) => item.materialName
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
const { msg, code } = await SAVE(this.params);
|
|
const { msg, code } = await SAVE(this.params);
|
|
if (code === 200) {
|
|
if (code === 200) {
|
|
this.onHide();
|
|
this.onHide();
|
|
@@ -321,12 +180,7 @@ export default {
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
<template>
|
|
<template>
|
|
- <el-button
|
|
|
|
- v-bind="$attrs"
|
|
|
|
- v-on="$listeners"
|
|
|
|
- :disabled="disabled"
|
|
|
|
- @click="onOpen"
|
|
|
|
- >
|
|
|
|
|
|
+ <el-button v-bind="$attrs" v-on="$listeners" @click="onOpen">
|
|
{{ title }}
|
|
{{ title }}
|
|
<el-drawer
|
|
<el-drawer
|
|
:show-close="false"
|
|
:show-close="false"
|
|
@@ -382,7 +236,7 @@ export default {
|
|
lazy
|
|
lazy
|
|
>
|
|
>
|
|
<el-super-table
|
|
<el-super-table
|
|
- v-model="priceApply[item.key]"
|
|
|
|
|
|
+ v-model="params[item.key]"
|
|
:dict="dict"
|
|
:dict="dict"
|
|
:ref="tabName"
|
|
:ref="tabName"
|
|
:columns="columns"
|
|
:columns="columns"
|