|
@@ -1,44 +1,8 @@
|
|
<script>
|
|
<script>
|
|
import useColumns from "./columns";
|
|
import useColumns from "./columns";
|
|
-import { REFER } from "@/components/popover-select/api";
|
|
|
|
import { EXIST } from "@/api/business/purchase/catalogue";
|
|
import { EXIST } from "@/api/business/purchase/catalogue";
|
|
import { ITEM, SAVE } from "@/api/business/purchase/apply";
|
|
import { ITEM, SAVE } from "@/api/business/purchase/apply";
|
|
-
|
|
|
|
-const fetchTax = async (prop) => {
|
|
|
|
- try {
|
|
|
|
- // try
|
|
|
|
- const { code, rows } = await REFER({
|
|
|
|
- search: prop,
|
|
|
|
- type: "TAX_RATE_PARAM",
|
|
|
|
- });
|
|
|
|
- if (code === 200) {
|
|
|
|
- return rows[0] || {};
|
|
|
|
- }
|
|
|
|
- } catch (err) {
|
|
|
|
- // catch
|
|
|
|
- console.error(err);
|
|
|
|
- } finally {
|
|
|
|
- // finally
|
|
|
|
- }
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-const fetchUnit = async (prop) => {
|
|
|
|
- try {
|
|
|
|
- // try
|
|
|
|
- const { code, rows } = await REFER({
|
|
|
|
- search: prop,
|
|
|
|
- type: "UNIT_PARAM",
|
|
|
|
- });
|
|
|
|
- if (code === 200) {
|
|
|
|
- return rows[0] || {};
|
|
|
|
- }
|
|
|
|
- } catch (err) {
|
|
|
|
- // catch
|
|
|
|
- console.error(err);
|
|
|
|
- } finally {
|
|
|
|
- // finally
|
|
|
|
- }
|
|
|
|
-};
|
|
|
|
|
|
+import { tax, unit, currency } from "@/components/popover-select-v2/fetch";
|
|
|
|
|
|
const fetchExist = async (prop) => {
|
|
const fetchExist = async (prop) => {
|
|
try {
|
|
try {
|
|
@@ -143,21 +107,13 @@ export default {
|
|
},
|
|
},
|
|
priceApply: {
|
|
priceApply: {
|
|
get() {
|
|
get() {
|
|
- const {
|
|
|
|
- params: { priceApplyOrgs, priceApplyItems },
|
|
|
|
- } = this;
|
|
|
|
- this.params.priceApplyOrgs = priceApplyOrgs.map((item, index) => ({
|
|
|
|
- ...item,
|
|
|
|
- $index: index,
|
|
|
|
- }));
|
|
|
|
- this.params.priceApplyItems = priceApplyItems.map((item, index) => ({
|
|
|
|
- ...item,
|
|
|
|
- $index: index,
|
|
|
|
- }));
|
|
|
|
|
|
+ this.params.priceApplyItems = this.params.priceApplyItems.map(
|
|
|
|
+ (item, index) => ({
|
|
|
|
+ ...item,
|
|
|
|
+ $index: index,
|
|
|
|
+ })
|
|
|
|
+ );
|
|
return {
|
|
return {
|
|
- priceApplyOrgs: this.params.priceApplyOrgs.filter(
|
|
|
|
- ({ delFlag }) => delFlag !== "2"
|
|
|
|
- ),
|
|
|
|
priceApplyItems: this.params.priceApplyItems.filter(
|
|
priceApplyItems: this.params.priceApplyItems.filter(
|
|
({ delFlag }) => delFlag !== "2"
|
|
({ delFlag }) => delFlag !== "2"
|
|
),
|
|
),
|
|
@@ -169,35 +125,17 @@ export default {
|
|
watch: {},
|
|
watch: {},
|
|
methods: {
|
|
methods: {
|
|
//
|
|
//
|
|
- changePuOrgName(prop) {
|
|
|
|
- const {
|
|
|
|
- select: { id: org, code: orgCode, name: orgName },
|
|
|
|
- } = prop;
|
|
|
|
- const index = this.params.priceApplyOrgs.findIndex(
|
|
|
|
- (item) => item.org === org
|
|
|
|
- );
|
|
|
|
- if (index === -1) {
|
|
|
|
- this.params.priceApplyOrgs.push({
|
|
|
|
- org,
|
|
|
|
- orgCode,
|
|
|
|
- orgName,
|
|
|
|
- createByName: undefined,
|
|
|
|
- updateByName: undefined,
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- //
|
|
|
|
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 { rateCode, unitIdName, code: materialCode } = row;
|
|
// task 1
|
|
// task 1
|
|
- fetchTax(rateCode).then((res) => {
|
|
|
|
|
|
+ tax(rateCode).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
|
|
- fetchUnit(unitIdName).then((res) => {
|
|
|
|
|
|
+ unit(unitIdName).then((res) => {
|
|
const { id, code, name } = res;
|
|
const { id, code, name } = res;
|
|
row.unit = id;
|
|
row.unit = id;
|
|
row.unitCode = code;
|
|
row.unitCode = code;
|
|
@@ -236,10 +174,28 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
//
|
|
//
|
|
- async open() {
|
|
|
|
|
|
+ async onOpen() {
|
|
const { addType, selectData } = this.$props;
|
|
const { addType, selectData } = this.$props;
|
|
if (addType === "add") {
|
|
if (addType === "add") {
|
|
this.visible = true;
|
|
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") {
|
|
if (addType === "copy") {
|
|
const [{ id }] = selectData;
|
|
const [{ id }] = selectData;
|
|
@@ -258,13 +214,6 @@ export default {
|
|
updateByName: null,
|
|
updateByName: null,
|
|
})
|
|
})
|
|
);
|
|
);
|
|
- this.params.priceApplyOrgs = this.params.priceApplyOrgs.map((item) => ({
|
|
|
|
- ...item,
|
|
|
|
- id: null,
|
|
|
|
- applyId: null,
|
|
|
|
- createByName: null,
|
|
|
|
- updateByName: null,
|
|
|
|
- }));
|
|
|
|
}
|
|
}
|
|
if (addType === "edit") {
|
|
if (addType === "edit") {
|
|
const [{ id }] = selectData;
|
|
const [{ id }] = selectData;
|
|
@@ -274,13 +223,10 @@ export default {
|
|
...item,
|
|
...item,
|
|
})
|
|
})
|
|
);
|
|
);
|
|
- this.params.priceApplyOrgs = this.params.priceApplyOrgs.map((item) => ({
|
|
|
|
- ...item,
|
|
|
|
- }));
|
|
|
|
}
|
|
}
|
|
},
|
|
},
|
|
//
|
|
//
|
|
- async hide() {
|
|
|
|
|
|
+ async onHide() {
|
|
const {
|
|
const {
|
|
TabColumns,
|
|
TabColumns,
|
|
TableColumns,
|
|
TableColumns,
|
|
@@ -295,7 +241,7 @@ export default {
|
|
this.params = this.$init.params([...TabColumns, ...TableColumns]);
|
|
this.params = this.$init.params([...TabColumns, ...TableColumns]);
|
|
},
|
|
},
|
|
//
|
|
//
|
|
- async useRowAdd(prop) {
|
|
|
|
|
|
+ async onRowAdd(prop) {
|
|
const {
|
|
const {
|
|
$notify,
|
|
$notify,
|
|
TabColumns,
|
|
TabColumns,
|
|
@@ -316,7 +262,7 @@ export default {
|
|
});
|
|
});
|
|
},
|
|
},
|
|
//
|
|
//
|
|
- async useRowRemove(prop, scope) {
|
|
|
|
|
|
+ async onRowRemove(prop, scope) {
|
|
const { addType } = this.$props;
|
|
const { addType } = this.$props;
|
|
const {
|
|
const {
|
|
row: { $index },
|
|
row: { $index },
|
|
@@ -338,24 +284,18 @@ export default {
|
|
//
|
|
//
|
|
async useSubmit(prop) {
|
|
async useSubmit(prop) {
|
|
this.$refs[prop].$refs[prop].validate(async (valid) => {
|
|
this.$refs[prop].$refs[prop].validate(async (valid) => {
|
|
|
|
+ console.log(this.params);
|
|
if (valid) {
|
|
if (valid) {
|
|
try {
|
|
try {
|
|
this.loading = true;
|
|
this.loading = true;
|
|
- const {
|
|
|
|
- params,
|
|
|
|
- params: { priceApplyOrgs, priceApplyItems },
|
|
|
|
- } = this;
|
|
|
|
if (this.addType === "edit") {
|
|
if (this.addType === "edit") {
|
|
- params.priceApplyOrgs = priceApplyOrgs.filter(
|
|
|
|
- (item) => item.orgName
|
|
|
|
- );
|
|
|
|
- params.priceApplyItems = priceApplyItems.filter(
|
|
|
|
|
|
+ this.params.priceApplyItems = this.params.priceApplyItems.filter(
|
|
(item) => item.materialName
|
|
(item) => item.materialName
|
|
);
|
|
);
|
|
}
|
|
}
|
|
- const { msg, code } = await SAVE(params);
|
|
|
|
|
|
+ const { msg, code } = await SAVE(this.params);
|
|
if (code === 200) {
|
|
if (code === 200) {
|
|
- this.hide();
|
|
|
|
|
|
+ this.onHide();
|
|
this.$emit("success");
|
|
this.$emit("success");
|
|
this.$notify.success(msg);
|
|
this.$notify.success(msg);
|
|
}
|
|
}
|
|
@@ -382,17 +322,32 @@ export default {
|
|
v-bind="$attrs"
|
|
v-bind="$attrs"
|
|
v-on="$listeners"
|
|
v-on="$listeners"
|
|
:disabled="disabled"
|
|
:disabled="disabled"
|
|
- @click="open"
|
|
|
|
|
|
+ @click="onOpen"
|
|
>
|
|
>
|
|
{{ title }}
|
|
{{ title }}
|
|
<el-drawer
|
|
<el-drawer
|
|
|
|
+ :show-close="false"
|
|
:size="width"
|
|
:size="width"
|
|
:title="title"
|
|
:title="title"
|
|
:visible.sync="visible"
|
|
:visible.sync="visible"
|
|
append-to-body
|
|
append-to-body
|
|
destroy-on-close
|
|
destroy-on-close
|
|
- @close="hide"
|
|
|
|
|
|
+ @close="onHide"
|
|
>
|
|
>
|
|
|
|
+ <template slot="title">
|
|
|
|
+ <span>{{ title }}</span>
|
|
|
|
+ <el-button
|
|
|
|
+ type="primary"
|
|
|
|
+ :size="$attrs.size"
|
|
|
|
+ :loading="loading"
|
|
|
|
+ @click="useSubmit('superForm')"
|
|
|
|
+ >
|
|
|
|
+ 确 认
|
|
|
|
+ </el-button>
|
|
|
|
+ <el-button :size="$attrs.size" :loading="loading" @click="onHide">
|
|
|
|
+ 取 消
|
|
|
|
+ </el-button>
|
|
|
|
+ </template>
|
|
<el-super-form
|
|
<el-super-form
|
|
v-model="params"
|
|
v-model="params"
|
|
:dict="dict"
|
|
:dict="dict"
|
|
@@ -440,41 +395,24 @@ export default {
|
|
>
|
|
>
|
|
</component>
|
|
</component>
|
|
</template>
|
|
</template>
|
|
- <el-table-column fixed="right" label="操作" width="75">
|
|
|
|
|
|
+ <el-table-column fixed="right" label="操作" width="100">
|
|
<template slot="header" slot-scope="scope">
|
|
<template slot="header" slot-scope="scope">
|
|
- <el-button
|
|
|
|
- circle
|
|
|
|
- icon="el-icon-plus"
|
|
|
|
- :size="$attrs.size"
|
|
|
|
- @click="useRowAdd(tabName)"
|
|
|
|
- >
|
|
|
|
|
|
+ <el-button :size="$attrs.size" @click="onRowAdd(tabName)">
|
|
|
|
+ 新增
|
|
</el-button>
|
|
</el-button>
|
|
</template>
|
|
</template>
|
|
<template slot-scope="scope">
|
|
<template slot-scope="scope">
|
|
<el-button
|
|
<el-button
|
|
- circle
|
|
|
|
- icon="el-icon-minus"
|
|
|
|
:size="$attrs.size"
|
|
:size="$attrs.size"
|
|
- @click.native.prevent="useRowRemove(tabName, scope)"
|
|
|
|
|
|
+ @click.native.prevent="onRowRemove(tabName, scope)"
|
|
>
|
|
>
|
|
|
|
+ 删除
|
|
</el-button>
|
|
</el-button>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
</el-super-table>
|
|
</el-super-table>
|
|
</el-tab-pane>
|
|
</el-tab-pane>
|
|
</el-tabs>
|
|
</el-tabs>
|
|
- <div style="padding: 20px; text-align: right">
|
|
|
|
- <el-button :size="$attrs.size" :loading="loading" @click="hide"
|
|
|
|
- >取 消</el-button
|
|
|
|
- >
|
|
|
|
- <el-button
|
|
|
|
- type="primary"
|
|
|
|
- :size="$attrs.size"
|
|
|
|
- :loading="loading"
|
|
|
|
- @click="useSubmit('superForm')"
|
|
|
|
- >确 认</el-button
|
|
|
|
- >
|
|
|
|
- </div>
|
|
|
|
</el-drawer>
|
|
</el-drawer>
|
|
</el-button>
|
|
</el-button>
|
|
</template>
|
|
</template>
|