|
@@ -1,192 +1,25 @@
|
|
|
<script>
|
|
|
+import { add } from "@/api/business/purchase/purchase-contract";
|
|
|
+import { arr2obj } from "./hooks";
|
|
|
+import {
|
|
|
+ initDicts,
|
|
|
+ initRules,
|
|
|
+ initParams,
|
|
|
+ initColumns,
|
|
|
+ initTabColumns,
|
|
|
+ initComponents,
|
|
|
+} from "./config/add";
|
|
|
+// import { initComponents } from "@/views/common-dialog/utils/init-something";
|
|
|
+
|
|
|
export default {
|
|
|
name: "AddPurchaseContractDrawer",
|
|
|
+ components: initComponents(initColumns()),
|
|
|
+ dicts: initDicts(),
|
|
|
data() {
|
|
|
- const arr2Obj = function (data, keyName, valueName) {
|
|
|
- return Object.fromEntries(
|
|
|
- data.map((item) => [item[keyName], item[valueName]])
|
|
|
- );
|
|
|
- };
|
|
|
- const columns = [
|
|
|
- { key: "puOrg", title: "采购组织", type: "TagSelect", require: true },
|
|
|
- { key: "code", title: "合同编码", type: "Input" },
|
|
|
- { key: "contractName", title: "合同名称", type: "Input", require: true },
|
|
|
- { key: "supplier", title: "供应商", type: "TagSelect", require: true },
|
|
|
- { key: "contractType", title: "合同类型", type: "Select", require: true },
|
|
|
- { key: "puDept", title: "采购部门", type: "TagSelect", require: true },
|
|
|
- { key: "buyer", title: "采购员", type: "TagSelect" },
|
|
|
- { key: "source", title: "合同来源", type: "Select" },
|
|
|
- {
|
|
|
- key: "signDate",
|
|
|
- title: "合同签订日期",
|
|
|
- type: "DatePicker",
|
|
|
- require: true,
|
|
|
- },
|
|
|
- {
|
|
|
- key: "effectiveDate",
|
|
|
- title: "合同生效日期",
|
|
|
- type: "DatePicker",
|
|
|
- require: true,
|
|
|
- },
|
|
|
- { key: "endDate", title: "合同终止日期", type: "DatePicker" },
|
|
|
- { key: "externalContract", title: "外部合同号", type: "Input" },
|
|
|
- { key: "refusalReasons", title: "拒绝理由", type: "Input" },
|
|
|
- { key: "enquiryCode", title: "询价单号", type: "Input" },
|
|
|
- { key: "externalFile", title: "对外附件", type: "Upload", span: 24 },
|
|
|
- { key: "puFile", title: "采购商盖章合同附件", type: "Upload", span: 24 },
|
|
|
- {
|
|
|
- key: "supplierFile",
|
|
|
- title: "供应商盖章合同附件",
|
|
|
- type: "Upload",
|
|
|
- span: 24,
|
|
|
- },
|
|
|
- { key: "projectName", title: "项目名称", type: "TagSelect" },
|
|
|
- { key: "projectCode", title: "项目编号", type: "Input" },
|
|
|
- { key: "area", title: "区域", type: "Input" },
|
|
|
- { key: "consigneePhone", title: "收货人联系方式", type: "Input" },
|
|
|
- { key: "paymentAgreement", title: "付款协议", type: "TagSelect" },
|
|
|
- { key: "currency", title: "币种", type: "TagSelect", require: true },
|
|
|
- { key: "taxPrice", title: "价税合计", type: "InputNumber" },
|
|
|
- { key: "guaranteePeriod", title: "质保期", type: "Input" },
|
|
|
-
|
|
|
- // { key: "lastPuMoney", title: "上年度采购额" },
|
|
|
- // { key: "buyerName", title: "采购员名称" },
|
|
|
- // { key: "supplierName", title: "供应商名称" },
|
|
|
- // { key: "puMoneyYear", title: "本年度采购额" },
|
|
|
- // { key: "puDeptName", title: "采购部门名称" },
|
|
|
- // { key: "supplierTier", title: "供应商层级" },
|
|
|
- // { key: "grossRateAverage", title: "平均毛利率" },
|
|
|
- // { key: "approveFlow", title: "审批流程" },
|
|
|
- // { key: "consumableClass", title: "耗材类别" },
|
|
|
- // { key: "brandGrossRate", title: "同类品牌及毛利率" },
|
|
|
- // { key: "contractFormat", title: "合同格式" },
|
|
|
- // { key: "productName", title: "产品类别&名称" },
|
|
|
- // { key: "invoiceTax", title: "发票税率" },
|
|
|
- // { key: "emergencyDegree", title: "紧急程度" },
|
|
|
- // { key: "project", title: "项目医院" },
|
|
|
- // { key: "deliveryType", title: "交货方式" },
|
|
|
- // { key: "contractPartyc", title: "合同丙方" },
|
|
|
- // { key: "contractPartycName", title: "合同丙方名称" },
|
|
|
- // { key: "guaranteePeriodEnd", title: "质保期限" },
|
|
|
- // { key: "freightMethods", title: "运费承担方式" },
|
|
|
- // { key: "isTarget", title: "是否有指标" },
|
|
|
- // { key: "contractTarget", title: "合同指标" },
|
|
|
- // { key: "exemptionPostageCondtion", title: "包邮条件" },
|
|
|
- // { key: "isRebate", title: "是否有返利" },
|
|
|
- // { key: "rebatePolicy", title: "返利政策" },
|
|
|
- // { key: "rollbackPolicy", title: "退换货政策" },
|
|
|
- // { key: "contractContent", title: "合同主要内容" },
|
|
|
- // { key: "currencyName", title: "币种名称" },
|
|
|
- // { key: "tenantId", title: "租户号" },
|
|
|
- // { key: "revision", title: "乐观锁" },
|
|
|
- // { key: "createByName", title: "创建人" },
|
|
|
- // { key: "updateByName", title: "创建人名称" },
|
|
|
- // { key: "delFlag", title: "删除标记" },
|
|
|
- ];
|
|
|
- const initColumns = () =>
|
|
|
- columns.map((column) => {
|
|
|
- const clearable = column.clearable || true;
|
|
|
- if (column.type === "InputNumber") {
|
|
|
- return {
|
|
|
- ...column,
|
|
|
- clearable,
|
|
|
- config: { controlsPosition: "right" },
|
|
|
- };
|
|
|
- }
|
|
|
- if (column.type === "DatePicker") {
|
|
|
- return {
|
|
|
- ...column,
|
|
|
- clearable,
|
|
|
- config: { type: "date" },
|
|
|
- };
|
|
|
- }
|
|
|
- return {
|
|
|
- ...column,
|
|
|
- clearable,
|
|
|
- };
|
|
|
- });
|
|
|
- const initParams = () => arr2Obj(initColumns(), "key", "value");
|
|
|
- const tabColumns = [
|
|
|
- {
|
|
|
- title: "物料基本信息",
|
|
|
- key: "first",
|
|
|
- tableColumns: [
|
|
|
- { title: "序号", key: "" },
|
|
|
- { title: "赠品", key: "" },
|
|
|
- { title: "物料编码", key: "" },
|
|
|
- { title: "物料名称", key: "" },
|
|
|
- { title: "规格", key: "" },
|
|
|
- { title: "生产厂家", key: "" },
|
|
|
- { title: "收货客户", key: "" },
|
|
|
- { title: "品牌", key: "" },
|
|
|
- { title: "采购数量", key: "" },
|
|
|
- { title: "采购单位", key: "" },
|
|
|
- { title: "计价数量", key: "" },
|
|
|
- { title: "税率%", key: "" },
|
|
|
- { title: "含税单价", key: "" },
|
|
|
- { title: "含税金额合计", key: "" },
|
|
|
- { title: "价格有效期(起)", key: "" },
|
|
|
- { title: "计划到货日期", key: "" },
|
|
|
- { title: "来源类型", key: "" },
|
|
|
- { title: "来源单号", key: "" },
|
|
|
- { title: "需求单号", key: "" },
|
|
|
- { title: "备注", key: "" },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- title: "合同条款",
|
|
|
- key: "second",
|
|
|
- tableColumns: [
|
|
|
- { title: "序号", key: "" },
|
|
|
- { title: "条款编码", key: "" },
|
|
|
- { title: "条款名称", key: "" },
|
|
|
- { title: "条款内容", key: "" },
|
|
|
- { title: "变量序号", key: "" },
|
|
|
- { title: "变量内容", key: "" },
|
|
|
- { title: "备注", key: "" },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- title: "合同费用",
|
|
|
- key: "third",
|
|
|
- tableColumns: [
|
|
|
- { title: "序号", key: "" },
|
|
|
- { title: "费用编码", key: "" },
|
|
|
- { title: "费用名称", key: "" },
|
|
|
- { title: "费用金额", key: "" },
|
|
|
- { title: "备注", key: "" },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- title: "付款协议信息",
|
|
|
- key: "fourth",
|
|
|
- tableColumns: [
|
|
|
- { title: "序号", key: "" },
|
|
|
- { title: "付款阶段", key: "" },
|
|
|
- { title: "是否预付款", key: "" },
|
|
|
- { title: "是否质保金", key: "" },
|
|
|
- { title: "结算方式", key: "" },
|
|
|
- { title: "付款起点", key: "" },
|
|
|
- { title: "付款金额", key: "" },
|
|
|
- { title: "付款比例%", key: "" },
|
|
|
- { title: "账期天数", key: "" },
|
|
|
- { title: "备注", key: "" },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- title: "合同执行组织范围",
|
|
|
- key: "fifth",
|
|
|
- tableColumns: [
|
|
|
- { title: "序号", key: "" },
|
|
|
- { title: "组织名称", key: "" },
|
|
|
- { title: "组织编码", key: "" },
|
|
|
- ],
|
|
|
- },
|
|
|
- ];
|
|
|
- const initTabColumns = () => tabColumns;
|
|
|
return {
|
|
|
- visible: false,
|
|
|
+ visible: true,
|
|
|
columns: initColumns(),
|
|
|
+ rules: initRules(),
|
|
|
params: initParams(),
|
|
|
options: [
|
|
|
{
|
|
@@ -219,17 +52,76 @@ export default {
|
|
|
fourth: [],
|
|
|
fifth: [],
|
|
|
},
|
|
|
+ currentComponent: { name: "", title: "", value: "", row: {} },
|
|
|
};
|
|
|
},
|
|
|
computed: {},
|
|
|
watch: {},
|
|
|
methods: {
|
|
|
+ beforeOpen() {
|
|
|
+ const { deptName, nickName, orgName } = this.$store.state.user;
|
|
|
+ this.params.puOrg = orgName;
|
|
|
+ this.params.buyer = nickName;
|
|
|
+ this.params.puDept = deptName;
|
|
|
+ },
|
|
|
setVisible(prop) {
|
|
|
this.visible = prop;
|
|
|
},
|
|
|
+ cancel() {
|
|
|
+ this.setVisible(false);
|
|
|
+ this.params = arr2obj(this.columns, "key", "value");
|
|
|
+ },
|
|
|
+ sava() {
|
|
|
+ this.setVisible(false);
|
|
|
+ },
|
|
|
+ async submitSava() {
|
|
|
+ console.log(this.params);
|
|
|
+ return;
|
|
|
+ try {
|
|
|
+ const res = await add(this.params);
|
|
|
+ console.log("res", res);
|
|
|
+ } catch (err) {
|
|
|
+ this.$notify.error({ title: "error", message: err });
|
|
|
+ } finally {
|
|
|
+ this.setVisible(false);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ openAsyncInputDialog(prop, type) {
|
|
|
+ try {
|
|
|
+ const {
|
|
|
+ key,
|
|
|
+ title,
|
|
|
+ config: { componentName },
|
|
|
+ } = prop;
|
|
|
+ this.currentComponent.row = prop;
|
|
|
+ this.currentComponent.title = title;
|
|
|
+ this.currentComponent.name = componentName;
|
|
|
+ if (type === "change") {
|
|
|
+ this.currentComponent.value = this.params[key];
|
|
|
+ }
|
|
|
+ if (type === "click") {
|
|
|
+ this.currentComponent.value = "";
|
|
|
+ }
|
|
|
+ this.$nextTick(() => {
|
|
|
+ const { setVisible } = this.$refs[componentName];
|
|
|
+ setVisible(true);
|
|
|
+ });
|
|
|
+ } catch (err) {
|
|
|
+ this.$notify.error({ title: "error", message: err });
|
|
|
+ } finally {
|
|
|
+ }
|
|
|
+ },
|
|
|
+ updateParams(prop) {
|
|
|
+ const {
|
|
|
+ config: { dataMapping },
|
|
|
+ } = this.currentComponent.row;
|
|
|
+ for (let key in dataMapping) {
|
|
|
+ this.params[key] = prop[dataMapping[key]];
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
created() {
|
|
|
- console.log(this.params, this.columns);
|
|
|
+ // console.log("this,", initComponents(initColumns()));
|
|
|
},
|
|
|
mounted() {},
|
|
|
destroyed() {},
|
|
@@ -237,12 +129,11 @@ export default {
|
|
|
</script>
|
|
|
<template>
|
|
|
<el-drawer
|
|
|
- title="我是标题"
|
|
|
direction="btt"
|
|
|
size="100%"
|
|
|
:with-header="false"
|
|
|
:visible.sync="visible"
|
|
|
- :before-close="handleClose"
|
|
|
+ @open="beforeOpen"
|
|
|
>
|
|
|
<el-card
|
|
|
:body-style="{
|
|
@@ -262,38 +153,69 @@ export default {
|
|
|
>
|
|
|
<h3>新增</h3>
|
|
|
<div style="text-align: right">
|
|
|
- <el-button size="mini" @click="setVisible(false)">取消</el-button>
|
|
|
- <el-button size="mini" type="info" @click="setVisible(false)"
|
|
|
- >保存并新增</el-button
|
|
|
- >
|
|
|
- <el-button size="mini" type="danger" @click="setVisible(false)"
|
|
|
- >保存</el-button
|
|
|
- >
|
|
|
+ <el-button size="mini" @click="cancel">取消</el-button>
|
|
|
+ <el-button size="mini" type="danger" @click="sava">保存</el-button>
|
|
|
+ <el-button size="mini" type="info" @click="submitSava">
|
|
|
+ 保存并新增
|
|
|
+ </el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <component
|
|
|
+ v-if="currentComponent.name"
|
|
|
+ :is="currentComponent.name"
|
|
|
+ :ref="currentComponent.name"
|
|
|
+ :title="currentComponent.title"
|
|
|
+ :value="currentComponent.value"
|
|
|
+ @confirm="updateParams"
|
|
|
+ ></component>
|
|
|
<el-row>
|
|
|
<el-form
|
|
|
size="mini"
|
|
|
label-position="right"
|
|
|
- label-width="150px"
|
|
|
+ label-width="135px"
|
|
|
:model="params"
|
|
|
+ :rules="rules"
|
|
|
>
|
|
|
<el-col
|
|
|
v-for="(column, index) in columns"
|
|
|
:key="index"
|
|
|
- :span="column.span || 8"
|
|
|
+ :span="column.span || 6"
|
|
|
>
|
|
|
- <el-form-item
|
|
|
- :prop="column.key"
|
|
|
- :label="column.title"
|
|
|
- :required="column.required"
|
|
|
- >
|
|
|
+ <el-form-item :prop="column.key" :label="column.title">
|
|
|
<el-input
|
|
|
v-if="column.type === 'Input'"
|
|
|
v-model="params[column.key]"
|
|
|
:placeholder="column.placeholder"
|
|
|
:clearable="column.clearable"
|
|
|
- style="width: 90%"
|
|
|
+ :disabled="column.disabled"
|
|
|
+ style="width: 100%"
|
|
|
+ ></el-input>
|
|
|
+ <el-input
|
|
|
+ v-if="column.type === 'InputDialog'"
|
|
|
+ v-model="params[column.key]"
|
|
|
+ :placeholder="column.placeholder"
|
|
|
+ :clearable="column.clearable"
|
|
|
+ :disabled="column.disabled"
|
|
|
+ style="width: 100%"
|
|
|
+ @blur="openAsyncInputDialog(column, 'change')"
|
|
|
+ @change="openAsyncInputDialog(column, 'change')"
|
|
|
+ >
|
|
|
+ <template #suffix>
|
|
|
+ <el-icon
|
|
|
+ class="el-icon-s-operation"
|
|
|
+ style="cursor: pointer"
|
|
|
+ @click.native.stop="openAsyncInputDialog(column, 'click')"
|
|
|
+ ></el-icon>
|
|
|
+ </template>
|
|
|
+ </el-input>
|
|
|
+ <el-input
|
|
|
+ v-if="column.type === 'Textarea'"
|
|
|
+ v-model="params[column.key]"
|
|
|
+ type="textarea"
|
|
|
+ :placeholder="column.placeholder"
|
|
|
+ :clearable="column.clearable"
|
|
|
+ :disabled="column.disabled"
|
|
|
+ style="width: 100%"
|
|
|
></el-input>
|
|
|
<el-input-number
|
|
|
v-if="column.type === 'InputNumber'"
|
|
@@ -301,17 +223,19 @@ export default {
|
|
|
:controls-position="column.config.controlsPosition"
|
|
|
:placeholder="column.placeholder"
|
|
|
:clearable="column.clearable"
|
|
|
- style="width: 90%"
|
|
|
+ :disabled="column.disabled"
|
|
|
+ style="width: 100%"
|
|
|
></el-input-number>
|
|
|
<el-select
|
|
|
v-if="column.type === 'Select'"
|
|
|
v-model="params[column.key]"
|
|
|
:placeholder="column.placeholder"
|
|
|
:clearable="column.clearable"
|
|
|
- style="width: 90%"
|
|
|
+ :disabled="column.disabled"
|
|
|
+ style="width: 100%"
|
|
|
>
|
|
|
<el-option
|
|
|
- v-for="item in options"
|
|
|
+ v-for="item in dict.type[column.config.optionsName]"
|
|
|
:key="item.value"
|
|
|
:label="item.label"
|
|
|
:value="item.value"
|
|
@@ -326,7 +250,8 @@ export default {
|
|
|
collapse-tags
|
|
|
:placeholder="column.placeholder"
|
|
|
:clearable="column.clearable"
|
|
|
- style="width: 90%"
|
|
|
+ :disabled="column.disabled"
|
|
|
+ style="width: 100%"
|
|
|
>
|
|
|
<template #prefix>
|
|
|
<el-icon
|
|
@@ -349,13 +274,15 @@ export default {
|
|
|
:type="column.config.type"
|
|
|
:placeholder="column.placeholder"
|
|
|
:clearable="column.clearable"
|
|
|
+ :disabled="column.disabled"
|
|
|
:picker-options="column.pickerOptions"
|
|
|
- style="width: 90%"
|
|
|
+ style="width: 100%"
|
|
|
>
|
|
|
</el-date-picker>
|
|
|
<el-upload
|
|
|
v-if="column.type === 'Upload'"
|
|
|
:file-list="params[column.key]"
|
|
|
+ :disabled="column.disabled"
|
|
|
drag
|
|
|
action="https://jsonplaceholder.typicode.com/posts/"
|
|
|
multiple
|
|
@@ -378,6 +305,7 @@ export default {
|
|
|
padding: '20px',
|
|
|
display: 'flex',
|
|
|
'flex-wrap': 'wrap',
|
|
|
+ position: 'relative',
|
|
|
}"
|
|
|
style="margin: 10px"
|
|
|
>
|
|
@@ -394,11 +322,15 @@ export default {
|
|
|
:key="cIndex"
|
|
|
:prop="cColumn.key"
|
|
|
:label="cColumn.title"
|
|
|
+ :width="cColumn.width"
|
|
|
>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
</el-tab-pane>
|
|
|
</el-tabs>
|
|
|
+ <el-row style="position: absolute; top: 20px; right: 20px">
|
|
|
+ <el-button size="mini">增行</el-button>
|
|
|
+ </el-row>
|
|
|
</el-card>
|
|
|
</el-drawer>
|
|
|
</template>
|