|
@@ -2,9 +2,10 @@
|
|
import Column from "../add/column";
|
|
import Column from "../add/column";
|
|
import useData from "../hooks/data";
|
|
import useData from "../hooks/data";
|
|
import useDicts from "../hooks/dicts";
|
|
import useDicts from "../hooks/dicts";
|
|
-import useTable from "../hooks/table-function";
|
|
|
|
import useWatch from "../hooks/watch";
|
|
import useWatch from "../hooks/watch";
|
|
-import useMethods from "../hooks/function";
|
|
|
|
|
|
+import { initParams } from "@/utils/init";
|
|
|
|
+import { REFER } from "@/components/popover-select/api";
|
|
|
|
+import { EDIT, ITEM, TABLE } from "@/api/business/purchase/contract";
|
|
const { watchContractType } = useWatch();
|
|
const { watchContractType } = useWatch();
|
|
|
|
|
|
export default {
|
|
export default {
|
|
@@ -17,6 +18,9 @@ export default {
|
|
};
|
|
};
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
|
|
+ root: function () {
|
|
|
|
+ return this.$parent.$parent;
|
|
|
|
+ },
|
|
hasPowerAlteration: function () {
|
|
hasPowerAlteration: function () {
|
|
return this.$parent.$parent.hasPowerAlteration;
|
|
return this.$parent.$parent.hasPowerAlteration;
|
|
},
|
|
},
|
|
@@ -25,47 +29,143 @@ export default {
|
|
"params.contractType": watchContractType(),
|
|
"params.contractType": watchContractType(),
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- //
|
|
|
|
async fetchRefer(prop, type, source) {
|
|
async fetchRefer(prop, type, source) {
|
|
- const { fetchRefer } = useMethods();
|
|
|
|
- await fetchRefer({ _this: this, prop, type, source });
|
|
|
|
|
|
+ const { rateCode } = prop;
|
|
|
|
+ if (type === "MATERIAL_PARAM") {
|
|
|
|
+ try {
|
|
|
|
+ // try
|
|
|
|
+ this.loading = true;
|
|
|
|
+ const { code, rows } = await REFER({
|
|
|
|
+ search: rateCode,
|
|
|
|
+ type: "TAX_RATE_PARAM",
|
|
|
|
+ });
|
|
|
|
+ if (code === 200) {
|
|
|
|
+ const [{ ntaxrate }] = rows;
|
|
|
|
+ source.tax = ntaxrate === "0E-8" ? "0.00000000" : ntaxrate;
|
|
|
|
+ }
|
|
|
|
+ } catch (err) {
|
|
|
|
+ // catch
|
|
|
|
+ console.error(err);
|
|
|
|
+ } finally {
|
|
|
|
+ // finally
|
|
|
|
+ this.loading = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ 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) {
|
|
async open(prop) {
|
|
- const { open, fetchItem } = useMethods();
|
|
|
|
- await open({ _this: this });
|
|
|
|
- await fetchItem({ _this: this, prop });
|
|
|
|
|
|
+ this.visible = await this.fetchItem(prop);
|
|
},
|
|
},
|
|
//
|
|
//
|
|
async hide() {
|
|
async hide() {
|
|
- const { hide } = useMethods();
|
|
|
|
- await hide({ _this: this });
|
|
|
|
|
|
+ this.visible = false;
|
|
|
|
+ this.tabName = this.tabColumns[0].key;
|
|
},
|
|
},
|
|
//
|
|
//
|
|
async useRowAdd(prop) {
|
|
async useRowAdd(prop) {
|
|
- const { add } = useTable();
|
|
|
|
-
|
|
|
|
- await add({ _this: this, prop });
|
|
|
|
|
|
+ const { tableColumns } = this.tabColumns.find(
|
|
|
|
+ (item) => item.key === prop
|
|
|
|
+ );
|
|
|
|
+ this.params[prop].push(initParams(tableColumns));
|
|
},
|
|
},
|
|
//
|
|
//
|
|
async useRowRemove(prop, scope) {
|
|
async useRowRemove(prop, scope) {
|
|
- const { remove } = useTable();
|
|
|
|
- await remove({ _this: this, prop, scope });
|
|
|
|
|
|
+ const { ROMVE } = TABLE;
|
|
|
|
+ const {
|
|
|
|
+ row: { id, contractId },
|
|
|
|
+ } = scope;
|
|
|
|
+ try {
|
|
|
|
+ // try
|
|
|
|
+ this.loading = true;
|
|
|
|
+ const { code } = ROMVE(id, prop);
|
|
|
|
+ if (code === 200) {
|
|
|
|
+ this.fetchItem(contractId);
|
|
|
|
+ }
|
|
|
|
+ } catch (err) {
|
|
|
|
+ // catch
|
|
|
|
+ console.error(err);
|
|
|
|
+ } finally {
|
|
|
|
+ // finally
|
|
|
|
+ this.loading = false;
|
|
|
|
+ }
|
|
},
|
|
},
|
|
//
|
|
//
|
|
async useRowSubmit(prop, scope) {
|
|
async useRowSubmit(prop, scope) {
|
|
- const { submit } = useTable();
|
|
|
|
- await submit({ _this: this, prop, scope });
|
|
|
|
|
|
+ const {
|
|
|
|
+ row: { contractId },
|
|
|
|
+ } = scope;
|
|
|
|
+ const { id } = this.params;
|
|
|
|
+ const { ADD, EDIT } = TABLE;
|
|
|
|
+ try {
|
|
|
|
+ // try
|
|
|
|
+ this.loading = true;
|
|
|
|
+ if (contractId) {
|
|
|
|
+ await EDIT(row, prop);
|
|
|
|
+ } else {
|
|
|
|
+ await ADD({ ...row, contractId: id }, prop);
|
|
|
|
+ }
|
|
|
|
+ } catch (err) {
|
|
|
|
+ // catch
|
|
|
|
+ console.error(err);
|
|
|
|
+ } finally {
|
|
|
|
+ // finally
|
|
|
|
+ this.fetchItem(id);
|
|
|
|
+ this.loading = false;
|
|
|
|
+ }
|
|
},
|
|
},
|
|
//
|
|
//
|
|
async useSubmit(prop) {
|
|
async useSubmit(prop) {
|
|
- const { submit } = useMethods();
|
|
|
|
- await submit({ _this: this, prop, type: "EDIT" });
|
|
|
|
|
|
+ this.$refs[prop].validate(async (valid) => {
|
|
|
|
+ if (valid) {
|
|
|
|
+ try {
|
|
|
|
+ // try
|
|
|
|
+ this.loading = true;
|
|
|
|
+ const params = { ...this.params };
|
|
|
|
+ const { msg, code } = await EDIT(params);
|
|
|
|
+ if (code === 200) {
|
|
|
|
+ this.hide();
|
|
|
|
+ this.$emit("success");
|
|
|
|
+ this.$notify.success(msg);
|
|
|
|
+ }
|
|
|
|
+ } catch (err) {
|
|
|
|
+ // catch
|
|
|
|
+ console.error(err);
|
|
|
|
+ } finally {
|
|
|
|
+ // finally
|
|
|
|
+ this.loading = false;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
},
|
|
},
|
|
//
|
|
//
|
|
async useAlteration(prop) {
|
|
async useAlteration(prop) {
|
|
- const { useAlteration } = this.$parent.$parent;
|
|
|
|
- await useAlteration(prop);
|
|
|
|
|
|
+ await this.root
|
|
|
|
+ .useAlteration(prop)
|
|
|
|
+ .then(() => {
|
|
|
|
+ this.hide();
|
|
|
|
+ })
|
|
|
|
+ .catch(() => {});
|
|
},
|
|
},
|
|
},
|
|
},
|
|
created() {},
|
|
created() {},
|
|
@@ -83,28 +183,36 @@ export default {
|
|
<template slot="title">
|
|
<template slot="title">
|
|
<span>{{ title }}</span>
|
|
<span>{{ title }}</span>
|
|
<span>
|
|
<span>
|
|
|
|
+ <el-tooltip
|
|
|
|
+ v-if="root.hasPowerAlteration([params])"
|
|
|
|
+ effect="dark"
|
|
|
|
+ content="变 更"
|
|
|
|
+ placement="bottom-end"
|
|
|
|
+ >
|
|
|
|
+ <el-button
|
|
|
|
+ :size="size"
|
|
|
|
+ circle
|
|
|
|
+ icon="el-icon-check"
|
|
|
|
+ @click="useAlteration([params])"
|
|
|
|
+ >
|
|
|
|
+ </el-button>
|
|
|
|
+ </el-tooltip>
|
|
|
|
+ <el-tooltip v-else effect="dark" content="更 新" placement="bottom-end">
|
|
|
|
+ <el-button
|
|
|
|
+ :size="size"
|
|
|
|
+ circle
|
|
|
|
+ icon="el-icon-check"
|
|
|
|
+ @click="useSubmit('ruleForm')"
|
|
|
|
+ >
|
|
|
|
+ </el-button>
|
|
|
|
+ </el-tooltip>
|
|
<el-button
|
|
<el-button
|
|
:size="size"
|
|
:size="size"
|
|
circle
|
|
circle
|
|
|
|
+ type="danger"
|
|
icon="el-icon-close"
|
|
icon="el-icon-close"
|
|
@click="hide"
|
|
@click="hide"
|
|
></el-button>
|
|
></el-button>
|
|
- <el-button
|
|
|
|
- v-if="hasPowerAlteration([params])"
|
|
|
|
- :size="size"
|
|
|
|
- circle
|
|
|
|
- icon="el-icon-check"
|
|
|
|
- @click="useAlteration([params])"
|
|
|
|
- >
|
|
|
|
- </el-button>
|
|
|
|
- <el-button
|
|
|
|
- v-else
|
|
|
|
- :size="size"
|
|
|
|
- circle
|
|
|
|
- icon="el-icon-check"
|
|
|
|
- @click="useSubmit('ruleForm')"
|
|
|
|
- >
|
|
|
|
- </el-button>
|
|
|
|
</span>
|
|
</span>
|
|
</template>
|
|
</template>
|
|
<el-form
|
|
<el-form
|