|
@@ -1,184 +1,62 @@
|
|
|
<script>
|
|
|
-import { Columns, TabColumns } from "../column";
|
|
|
-import {
|
|
|
- EDIT,
|
|
|
- ITEM,
|
|
|
- TABLELIST,
|
|
|
- TABLEADD,
|
|
|
- TABLEEDIT,
|
|
|
- TABLEROMOVE,
|
|
|
-} from "@/api/business/purchase/contract";
|
|
|
-import { REFER } from "@/components/popover-select/api";
|
|
|
-import { initDicts, initRules, initParams } from "@/utils/init";
|
|
|
+import Column from "../add/column";
|
|
|
+import useData from "../hooks/use-data";
|
|
|
+import useDicts from "../hooks/use-dicts";
|
|
|
+import useTable from "../hooks/use-table";
|
|
|
+import useWatch from "../hooks/use-watch";
|
|
|
+import useMethods from "../hooks/use-methods";
|
|
|
+const { watchContractType } = useWatch();
|
|
|
|
|
|
export default {
|
|
|
- name: "EditDialog",
|
|
|
- dicts: Array.from(
|
|
|
- new Set([
|
|
|
- ...initDicts(Columns),
|
|
|
- ...initDicts(TabColumns.map((item) => item.tableColumns))
|
|
|
- .flat()
|
|
|
- .filter((cItem) => cItem.inputType === "Select"),
|
|
|
- ])
|
|
|
- ),
|
|
|
+ name: "EditDrawer",
|
|
|
+ dicts: useDicts(Column),
|
|
|
data() {
|
|
|
return {
|
|
|
- size: "mini",
|
|
|
- visible: false,
|
|
|
- loading: false,
|
|
|
- columns: Columns,
|
|
|
- rules: initRules(Columns),
|
|
|
- params: {
|
|
|
- ...initParams(Columns),
|
|
|
- contractItemList: [],
|
|
|
- contractClauseList: [],
|
|
|
- contractExpenseList: [],
|
|
|
- contractApplyOrgList: [],
|
|
|
- contractAgreementList: [],
|
|
|
- },
|
|
|
- tabColumns: TabColumns,
|
|
|
- tabName: "contractItemList",
|
|
|
+ title: "更 新",
|
|
|
+ ...useData(Column),
|
|
|
};
|
|
|
},
|
|
|
computed: {},
|
|
|
watch: {
|
|
|
- "params.contractType": {
|
|
|
- handler: function (newProp) {
|
|
|
- if (newProp === "1") {
|
|
|
- this.params.contractItemList = [];
|
|
|
- this.tabColumns = TabColumns.filter(
|
|
|
- (element) => element.key !== "contractItemList"
|
|
|
- );
|
|
|
- } else {
|
|
|
- this.tabColumns = TabColumns;
|
|
|
- }
|
|
|
- this.tabName = this.tabColumns[0].key;
|
|
|
- },
|
|
|
- immediate: true,
|
|
|
- },
|
|
|
+ "params.contractType": watchContractType(),
|
|
|
},
|
|
|
methods: {
|
|
|
//
|
|
|
- open(prop) {
|
|
|
- this.visible = true;
|
|
|
- this.fetchItem(prop);
|
|
|
- },
|
|
|
- //
|
|
|
- hide() {
|
|
|
- this.visible = false;
|
|
|
- this.params = initParams(Columns);
|
|
|
- this.tabName = this.tabColumns[0].key;
|
|
|
+ async fetchRefer(prop, type, source) {
|
|
|
+ const { fetchRefer } = useMethods();
|
|
|
+ await fetchRefer({ _this: this, prop, type, source });
|
|
|
},
|
|
|
//
|
|
|
- async fetchItem(prop) {
|
|
|
- try {
|
|
|
- this.loading = true;
|
|
|
- const { code, data } = await ITEM(prop);
|
|
|
- if (code === 200) {
|
|
|
- this.params = data;
|
|
|
- }
|
|
|
- } catch (err) {
|
|
|
- // catch
|
|
|
- } finally {
|
|
|
- // finally
|
|
|
- this.loading = false;
|
|
|
- }
|
|
|
+ async open(prop) {
|
|
|
+ const { open, fetchItem } = useMethods();
|
|
|
+ await open({ _this: this });
|
|
|
+ await fetchItem({ _this: this, prop });
|
|
|
},
|
|
|
//
|
|
|
- async fetchRefer(prop, type, source) {
|
|
|
- console.log("prop", prop);
|
|
|
- const { rateCode } = prop;
|
|
|
- if (type === "MATERIAL_PARAM") {
|
|
|
- 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
|
|
|
- } finally {
|
|
|
- // finally
|
|
|
- this.loading = false;
|
|
|
- }
|
|
|
- }
|
|
|
+ async hide() {
|
|
|
+ const { hide } = useMethods();
|
|
|
+ await hide({ _this: this });
|
|
|
},
|
|
|
//
|
|
|
- rowAdd(prop) {
|
|
|
- const tab = this.tabColumns.find((element) => element.key === prop);
|
|
|
- this.params[prop].push(initParams(tab.tableColumns));
|
|
|
+ async useRowAdd(prop) {
|
|
|
+ const { add } = useTable();
|
|
|
+
|
|
|
+ await add({ _this: this, prop });
|
|
|
},
|
|
|
//
|
|
|
- async rowDelete(prop, { row: { id }, $index }) {
|
|
|
- if (id) {
|
|
|
- try {
|
|
|
- this.loading = true;
|
|
|
- const { code } = await TABLEROMOVE(id, prop);
|
|
|
- if (code === 200) {
|
|
|
- this.fetchItem(this.params.id);
|
|
|
- }
|
|
|
- } catch (err) {
|
|
|
- // catch
|
|
|
- } finally {
|
|
|
- // finally
|
|
|
- this.loading = false;
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.params[prop].splice($index, 1);
|
|
|
- }
|
|
|
+ async useRowRemove(prop, scope) {
|
|
|
+ const { remove } = useTable();
|
|
|
+ await remove({ _this: this, prop, scope });
|
|
|
},
|
|
|
//
|
|
|
- async rowSubmit(prop, { row }) {
|
|
|
- try {
|
|
|
- this.loading = true;
|
|
|
- const { id } = this.params;
|
|
|
- const { contractId } = row;
|
|
|
- if (contractId) {
|
|
|
- await TABLEEDIT(row, prop);
|
|
|
- } else {
|
|
|
- await TABLEADD({ ...row, contractId: id }, prop);
|
|
|
- }
|
|
|
- await this.fetchItem(id);
|
|
|
- } catch (err) {
|
|
|
- // catch
|
|
|
- } finally {
|
|
|
- // finally
|
|
|
- this.loading = false;
|
|
|
- }
|
|
|
+ async useRowSubmit(prop, scope) {
|
|
|
+ const { submit } = useTable();
|
|
|
+ await submit({ _this: this, prop, scope });
|
|
|
},
|
|
|
//
|
|
|
- submit(prop) {
|
|
|
- this.$refs[prop].validate(async (valid) => {
|
|
|
- if (valid) {
|
|
|
- try {
|
|
|
- const createById = this.params.buyer;
|
|
|
- const createByName = this.params.buyerName;
|
|
|
- const updateById = this.$store.state.user.id;
|
|
|
- const updateByName = this.$store.state.user.name;
|
|
|
- const { code } = await EDIT({
|
|
|
- createById,
|
|
|
- createByName,
|
|
|
- updateById,
|
|
|
- updateByName,
|
|
|
- ...this.params,
|
|
|
- });
|
|
|
- if (code === 200) {
|
|
|
- this.hide();
|
|
|
- this.$emit("success");
|
|
|
- }
|
|
|
- } catch (err) {
|
|
|
- // catch
|
|
|
- } finally {
|
|
|
- // finally
|
|
|
- }
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- });
|
|
|
+ async useSubmit(prop) {
|
|
|
+ const { submit } = useMethods();
|
|
|
+ await submit({ _this: this, prop, type: "EDIT" });
|
|
|
},
|
|
|
},
|
|
|
created() {},
|
|
@@ -187,7 +65,30 @@ export default {
|
|
|
};
|
|
|
</script>
|
|
|
<template>
|
|
|
- <el-dialog :visible.sync="visible" title="编辑" fullscreen @close="hide">
|
|
|
+ <el-drawer
|
|
|
+ :size="width"
|
|
|
+ :title="title"
|
|
|
+ :show-close="false"
|
|
|
+ :visible.sync="visible"
|
|
|
+ >
|
|
|
+ <template slot="title">
|
|
|
+ <span>{{ title }}</span>
|
|
|
+ <span>
|
|
|
+ <el-button
|
|
|
+ :size="size"
|
|
|
+ circle
|
|
|
+ icon="el-icon-close"
|
|
|
+ @click="hide"
|
|
|
+ ></el-button>
|
|
|
+ <el-button
|
|
|
+ :size="size"
|
|
|
+ circle
|
|
|
+ icon="el-icon-check"
|
|
|
+ @click="useSubmit('ruleForm')"
|
|
|
+ >
|
|
|
+ </el-button>
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
<el-form
|
|
|
ref="ruleForm"
|
|
|
v-loading="loading"
|
|
@@ -196,10 +97,11 @@ export default {
|
|
|
:model="params"
|
|
|
label-width="auto"
|
|
|
label-position="right"
|
|
|
+ style="padding: 10px"
|
|
|
>
|
|
|
<el-row :gutter="20" style="display: flex; flex-wrap: wrap">
|
|
|
<el-col
|
|
|
- v-for="(column, index) in columns"
|
|
|
+ v-for="(column, index) in formColumns"
|
|
|
:key="index"
|
|
|
:span="column.span || 6"
|
|
|
>
|
|
@@ -266,6 +168,7 @@ export default {
|
|
|
:disabled="column.disabled"
|
|
|
:clearable="column.clearable"
|
|
|
:placeholder="column.placeholder"
|
|
|
+ :value-format="column.valueFormat"
|
|
|
:picker-options="column.pickerOptions"
|
|
|
style="width: 100%"
|
|
|
>
|
|
@@ -277,128 +180,126 @@ export default {
|
|
|
></file-upload>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- </el-row>
|
|
|
- <el-form-item label-width="0">
|
|
|
- <el-tabs v-model="tabName" tab-position="left" style="width: 100%">
|
|
|
- <el-tab-pane
|
|
|
- v-for="(column, index) in tabColumns"
|
|
|
- :key="index"
|
|
|
- :label="column.title"
|
|
|
- :name="column.key"
|
|
|
- >
|
|
|
- <el-table :data="params[column.key]" style="width: 100%">
|
|
|
- <el-table-column label="序号">
|
|
|
- <template slot-scope="scope">
|
|
|
- {{ scope.$index + 1 }}
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column
|
|
|
- v-for="(cColumn, cIndex) in column.tableColumns"
|
|
|
- show-overflow-tooltip
|
|
|
- :key="cIndex"
|
|
|
- :prop="cColumn.key"
|
|
|
- :label="cColumn.title"
|
|
|
- :width="cColumn.width"
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label-width="0">
|
|
|
+ <el-tabs v-model="tabName">
|
|
|
+ <el-tab-pane
|
|
|
+ v-for="(column, index) in tabColumns"
|
|
|
+ :key="index"
|
|
|
+ :label="column.title"
|
|
|
+ :name="column.key"
|
|
|
+ lazy
|
|
|
>
|
|
|
- <template slot-scope="scope">
|
|
|
- <el-input
|
|
|
- v-if="cColumn.inputType === 'Input'"
|
|
|
- v-model="scope.row[cColumn.key]"
|
|
|
- :size="size"
|
|
|
- :disabled="cColumn.disabled"
|
|
|
- :clearable="cColumn.clearable"
|
|
|
- :placeholder="cColumn.placeholder"
|
|
|
- style="width: 100%"
|
|
|
- @change="fetchRefer"
|
|
|
- ></el-input>
|
|
|
- <dr-computed-input
|
|
|
- v-else-if="cColumn.inputType === 'ComputedInput'"
|
|
|
- v-model="scope.row[cColumn.key]"
|
|
|
- :source="scope.row"
|
|
|
- :computed="cColumn.computed"
|
|
|
- :placeholder="cColumn.placeholder"
|
|
|
- style="width: 100%"
|
|
|
- ></dr-computed-input>
|
|
|
- <dr-popover-select
|
|
|
- v-else-if="cColumn.inputType === 'PopoverSelect'"
|
|
|
- v-model="scope.row[cColumn.key]"
|
|
|
- :size="size"
|
|
|
- :title="cColumn.title"
|
|
|
- :source.sync="scope.row"
|
|
|
- :type="cColumn.referName"
|
|
|
- :disabled="cColumn.disabled"
|
|
|
- :readonly="cColumn.readonly"
|
|
|
- :clearable="cColumn.clearable"
|
|
|
- :placeholder="cColumn.placeholder"
|
|
|
- :data-mapping="cColumn.dataMapping"
|
|
|
- @change="fetchRefer"
|
|
|
+ <el-divider></el-divider>
|
|
|
+ <el-table :size="size" :data="params[column.key]">
|
|
|
+ <el-table-column label="序号">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ {{ scope.$index + 1 }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ v-for="(cColumn, cIndex) in column.tableColumns"
|
|
|
+ :key="cIndex"
|
|
|
+ :prop="cColumn.key"
|
|
|
+ :label="cColumn.title"
|
|
|
+ :width="cColumn.width"
|
|
|
+ show-overflow-tooltip
|
|
|
>
|
|
|
- </dr-popover-select>
|
|
|
- <el-input-number
|
|
|
- v-else-if="cColumn.inputType === 'InputNumber'"
|
|
|
- v-model="scope.row[cColumn.key]"
|
|
|
- :size="size"
|
|
|
- :disabled="cColumn.disabled"
|
|
|
- :clearable="cColumn.clearable"
|
|
|
- :placeholder="cColumn.placeholder"
|
|
|
- :controls-position="cColumn.controlsPosition"
|
|
|
- style="width: 100%"
|
|
|
- ></el-input-number>
|
|
|
- <el-select
|
|
|
- v-else-if="cColumn.inputType === 'Select'"
|
|
|
- v-model="scope.row[cColumn.key]"
|
|
|
- :disabled="cColumn.disabled"
|
|
|
- :clearable="cColumn.clearable"
|
|
|
- :placeholder="cColumn.placeholder"
|
|
|
- style="width: 100%"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="item in dict.type[cColumn.referName]"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
- >
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- <span v-else> {{ scope.row[cColumn.key] }}</span>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column fixed="right" label="操作" width="100">
|
|
|
- <template slot="header" slot-scope="scope">
|
|
|
- <el-button
|
|
|
- circle
|
|
|
- icon="el-icon-plus"
|
|
|
- :size="size"
|
|
|
- @click="rowAdd(tabName)"
|
|
|
- >
|
|
|
- </el-button>
|
|
|
- </template>
|
|
|
- <template slot-scope="scope">
|
|
|
- <!-- v-if="scope.row.status !== 'success'" -->
|
|
|
- <el-button
|
|
|
- circle
|
|
|
- icon="el-icon-check"
|
|
|
- :size="size"
|
|
|
- @click.native.prevent="rowSubmit(tabName, scope)"
|
|
|
- >
|
|
|
- </el-button>
|
|
|
- <el-button
|
|
|
- circle
|
|
|
- icon="el-icon-minus"
|
|
|
- :size="size"
|
|
|
- @click.native.prevent="rowDelete(tabName, scope)"
|
|
|
- >
|
|
|
- </el-button>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
- </el-tab-pane>
|
|
|
- </el-tabs>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label-width="0" style="text-align: right">
|
|
|
- <el-button :size="size" @click="hide">取 消</el-button>
|
|
|
- <el-button :size="size" @click="submit('ruleForm')"> 更 新 </el-button>
|
|
|
- </el-form-item>
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-input
|
|
|
+ v-if="cColumn.inputType === 'Input'"
|
|
|
+ v-model="scope.row[cColumn.key]"
|
|
|
+ :size="size"
|
|
|
+ :disabled="cColumn.disabled"
|
|
|
+ :clearable="cColumn.clearable"
|
|
|
+ :placeholder="cColumn.placeholder"
|
|
|
+ style="width: 100%"
|
|
|
+ ></el-input>
|
|
|
+ <dr-computed-input
|
|
|
+ v-else-if="cColumn.inputType === 'ComputedInput'"
|
|
|
+ v-model="scope.row[cColumn.key]"
|
|
|
+ :source="scope.row"
|
|
|
+ :computed="cColumn.computed"
|
|
|
+ :placeholder="cColumn.placeholder"
|
|
|
+ style="width: 100%"
|
|
|
+ ></dr-computed-input>
|
|
|
+ <dr-popover-select
|
|
|
+ v-else-if="cColumn.inputType === 'PopoverSelect'"
|
|
|
+ v-model="scope.row[cColumn.key]"
|
|
|
+ :size="size"
|
|
|
+ :title="cColumn.title"
|
|
|
+ :source.sync="scope.row"
|
|
|
+ :type="cColumn.referName"
|
|
|
+ :disabled="cColumn.disabled"
|
|
|
+ :readonly="cColumn.readonly"
|
|
|
+ :clearable="cColumn.clearable"
|
|
|
+ :placeholder="cColumn.placeholder"
|
|
|
+ :data-mapping="cColumn.dataMapping"
|
|
|
+ @change="fetchRefer"
|
|
|
+ >
|
|
|
+ </dr-popover-select>
|
|
|
+ <el-input-number
|
|
|
+ v-else-if="cColumn.inputType === 'InputNumber'"
|
|
|
+ v-model="scope.row[cColumn.key]"
|
|
|
+ :size="size"
|
|
|
+ :disabled="cColumn.disabled"
|
|
|
+ :clearable="cColumn.clearable"
|
|
|
+ :placeholder="cColumn.placeholder"
|
|
|
+ :controls-position="cColumn.controlsPosition"
|
|
|
+ style="width: 100%"
|
|
|
+ ></el-input-number>
|
|
|
+ <el-select
|
|
|
+ v-else-if="cColumn.inputType === 'Select'"
|
|
|
+ v-model="scope.row[cColumn.key]"
|
|
|
+ :disabled="cColumn.disabled"
|
|
|
+ :clearable="cColumn.clearable"
|
|
|
+ :placeholder="cColumn.placeholder"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in dict.type[cColumn.referName]"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ <span v-else> {{ scope.row[cColumn.key] }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column fixed="right" label="操作" width="100">
|
|
|
+ <template slot="header" slot-scope="scope">
|
|
|
+ <el-button
|
|
|
+ circle
|
|
|
+ icon="el-icon-plus"
|
|
|
+ :size="size"
|
|
|
+ @click="useRowAdd(tabName)"
|
|
|
+ >
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button
|
|
|
+ circle
|
|
|
+ icon="el-icon-check"
|
|
|
+ :size="size"
|
|
|
+ @click.native.prevent="useRowSubmit(tabName, scope)"
|
|
|
+ >
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ circle
|
|
|
+ icon="el-icon-minus"
|
|
|
+ :size="size"
|
|
|
+ @click.native.prevent="useRowRemove(tabName, scope)"
|
|
|
+ >
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-tab-pane>
|
|
|
+ </el-tabs>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
</el-form>
|
|
|
- </el-dialog>
|
|
|
+ </el-drawer>
|
|
|
</template>
|