002201 2 år sedan
förälder
incheckning
d00f5e4dda

+ 7 - 12
src/utils/init-something.js

@@ -23,17 +23,12 @@ export const initRules = (arr) => {
 
 export const initComponents = (arr) => {
   const c = {};
-  try {
-    arr
-      .filter((element) => element.type === "InputDialog")
-      .map((element) => element.config.componentName)
-      .forEach((element) => {
-        c[element] = Components[element];
-      });
+  arr
+    .filter((element) => element.type === "InputDialog")
+    .map((element) => element.config.componentName)
+    .forEach((element) => {
+      c[element] = Components[element];
+    });
 
-    return c;
-  } catch (err) {
-    return c;
-  } finally {
-  }
+  return c;
 };

+ 63 - 26
src/views/purchase/purchase-contract/config/add.js → src/views/purchase/purchase-contract/add/column.js

@@ -323,34 +323,71 @@ export const initColumns = () => columns;
 
 const tabColumns = [
   {
+    show: {
+      contractType: [1, 2],
+    },
     title: "物料基本信息",
-    key: "first",
+    key: "PuContractItem",
     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: "", width: 150 },
-      { title: "价格有效期(起)", key: "", width: 150 },
-      { title: "计划到货日期", key: "", width: 150 },
-      { title: "来源类型", key: "" },
-      { title: "来源单号", key: "" },
-      { title: "需求单号", key: "" },
-      { title: "备注", key: "" },
+      { title: "序号", key: "index" },
+      { title: "物料编码", key: "material", width: 200 },
+      {
+        title: "物料名称",
+        key: "materialName",
+        type: "InputDialog",
+        width: 200,
+      },
+      { title: "规格", key: "specification", width: 200 },
+      { title: "品牌", key: "brand", type: "InputDialog", width: 200 },
+      { title: "生产厂家", key: "manufacturer", type: "Input", width: 200 },
+      { title: "采购单位", key: "puUnit", type: "InputDialog", width: 200 },
+      {
+        title: "税率%",
+        key: "tax",
+        type: "InputDialog",
+        config: {
+          componentName: "Tax",
+          dataMapping: {
+            tax: "mattaxesname",
+          },
+        },
+        width: 200,
+      },
+      {
+        title: "采购数量",
+        key: "qty",
+        type: "InputNumber",
+        config: { controlsPosition: "right" },
+        width: 200,
+      },
+      {
+        title: "含税单价",
+        key: "taxPrice",
+        type: "InputNumber",
+        config: { controlsPosition: "right" },
+        width: 200,
+      },
+      { title: "含税金额合计", key: "taxMoney", width: 200 },
+      { title: "无税单价", key: "taxFreePrice" },
+      { title: "无税金额合计", key: "taxFreeMoney", width: 200 },
+      {
+        title: "注册证号及备案凭证号",
+        key: "registration",
+        type: "Input",
+        width: 200,
+      },
+      {
+        title: "收货客户",
+        key: "customerName",
+        type: "InputDialog",
+        width: 200,
+      },
+      // { title: "备注", key: "remark", type: "Input", width: 200 },
     ],
   },
   {
     title: "合同条款",
-    key: "second",
+    key: "PuContractClause",
     tableColumns: [
       { title: "序号", key: "" },
       { title: "条款编码", key: "" },
@@ -358,12 +395,12 @@ const tabColumns = [
       { title: "条款内容", key: "" },
       { title: "变量序号", key: "" },
       { title: "变量内容", key: "" },
-      { title: "备注", key: "" },
+      // { title: "备注", key: "" },
     ],
   },
   {
     title: "合同费用",
-    key: "third",
+    key: "PuContractExpense",
     tableColumns: [
       { title: "序号", key: "" },
       { title: "费用编码", key: "" },
@@ -374,7 +411,7 @@ const tabColumns = [
   },
   {
     title: "付款协议信息",
-    key: "fourth",
+    key: "PuContractAgreement",
     tableColumns: [
       { title: "序号", key: "" },
       { title: "付款阶段", key: "" },
@@ -390,7 +427,7 @@ const tabColumns = [
   },
   {
     title: "合同执行组织范围",
-    key: "fifth",
+    key: "PuContractApplyOrg",
     tableColumns: [
       { title: "序号", key: "" },
       { title: "组织名称", key: "" },

+ 147 - 88
src/views/purchase/purchase-contract/add-purchase-contract.vue → src/views/purchase/purchase-contract/add/index.vue

@@ -7,7 +7,7 @@ import {
   initParams,
   initComponents,
 } from "@/utils/init-something";
-import { initColumns } from "./config/add";
+import { initColumns, initTabColumns } from "./column";
 
 export default {
   name: "AddPurchaseContractDrawer",
@@ -20,15 +20,15 @@ export default {
       rules: initRules(initColumns()),
       params: initParams(initColumns()),
       tabColumns: initTabColumns(),
-      tabName: "first",
-      tabTableDatas: {
-        first: [],
-        second: [],
-        third: [],
-        fourth: [],
-        fifth: [],
+      tabName: "PuContractItem",
+      tabTableParams: {
+        PuContractItem: [],
+        PuContractClause: [],
+        PuContractExpense: [],
+        PuContractAgreement: [],
+        PuContractApplyOrg: [],
       },
-      currentComponent: { name: "", title: "", value: "", row: {} },
+      currentComponent: { name: "", title: "", value: "", row: {}, source: {} },
     };
   },
   computed: {},
@@ -43,7 +43,17 @@ export default {
     setVisible(prop) {
       this.visible = prop;
     },
-    addTableRow() {},
+    addTableRow(prop) {
+      this.$notify.info({ message: prop });
+      this.tabTableParams[prop].push(
+        arr2obj(
+          initTabColumns().find((element) => element.key === prop).tableColumns,
+          "key",
+          ""
+        )
+      );
+      console.log(this.tabTableParams);
+    },
     cancel() {
       this.setVisible(false);
       this.params = arr2obj(this.columns, "key", "value");
@@ -64,7 +74,7 @@ export default {
       }
     },
     //
-    openAsyncInputDialog(prop, type) {
+    openAsyncInputDialog(prop, type, source) {
       try {
         const {
           key,
@@ -74,6 +84,7 @@ export default {
         this.currentComponent.row = prop;
         this.currentComponent.title = title;
         this.currentComponent.name = componentName;
+        this.currentComponent.source = source;
         if (type === "change") {
           this.currentComponent.value = this.params[key];
         }
@@ -87,6 +98,7 @@ export default {
       } catch (err) {
         this.$notify.error({ title: "error", message: err });
       } finally {
+        console.log(this.currentComponent, source, this.tabTableParams);
       }
     },
     updateParams(prop) {
@@ -94,7 +106,7 @@ export default {
         config: { dataMapping },
       } = this.currentComponent.row;
       for (let key in dataMapping) {
-        this.params[key] = prop[dataMapping[key]];
+        this.currentComponent.source[key] = prop[dataMapping[key]];
       }
     },
   },
@@ -113,47 +125,47 @@ export default {
     :visible.sync="visible"
     @open="beforeOpen"
   >
-    <el-card
-      :body-style="{
-        padding: '20px',
-        display: 'flex',
-        'flex-wrap': 'wrap',
-      }"
-      style="margin: 10px"
+    <el-form
+      size="mini"
+      label-position="right"
+      label-width="135px"
+      :model="params"
+      :rules="rules"
     >
-      <div
-        slot="header"
-        style="
-          display: flex;
-          justify-content: space-between;
-          align-items: center;
-        "
+      <el-card
+        :body-style="{
+          padding: '20px',
+          display: 'flex',
+          'flex-wrap': 'wrap',
+        }"
+        style="margin: 10px"
       >
-        <h3>新增</h3>
-        <div style="text-align: right">
-          <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="135px"
-          :model="params"
-          :rules="rules"
+        <div
+          slot="header"
+          style="
+            display: flex;
+            justify-content: space-between;
+            align-items: center;
+          "
         >
+          <h3>新增</h3>
+          <div style="text-align: right">
+            <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-col
             v-for="(column, index) in columns"
             :key="index"
@@ -175,14 +187,16 @@ export default {
                 :clearable="column.clearable"
                 :disabled="column.disabled"
                 style="width: 100%"
-                @blur="openAsyncInputDialog(column, 'change')"
-                @change="openAsyncInputDialog(column, 'change')"
+                @blur="openAsyncInputDialog(column, 'change', params)"
+                @change="openAsyncInputDialog(column, 'change', params)"
               >
                 <template #suffix>
                   <el-icon
                     class="el-icon-s-operation"
                     style="cursor: pointer"
-                    @click.native.stop="openAsyncInputDialog(column, 'click')"
+                    @click.native.stop="
+                      openAsyncInputDialog(column, 'click', params)
+                    "
                   ></el-icon>
                 </template>
               </el-input>
@@ -275,40 +289,85 @@ export default {
               </el-upload>
             </el-form-item>
           </el-col>
-        </el-form>
-      </el-row>
-    </el-card>
-    <el-card
-      :body-style="{
-        padding: '20px',
-        display: 'flex',
-        'flex-wrap': 'wrap',
-        position: 'relative',
-      }"
-      style="margin: 10px"
-    >
-      <el-tabs v-model="tabName" @tab-click="handleClick" style="width: 100%">
-        <el-tab-pane
-          v-for="(column, index) in tabColumns"
-          :key="index"
-          :label="column.title"
-          :name="column.key"
-        >
-          <el-table :data="tabTableDatas[column.key]" style="width: 100%">
-            <el-table-column
-              v-for="(cColumn, cIndex) in column.tableColumns"
-              :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" @click="addTableRow">增行</el-button>
-      </el-row>
-    </el-card>
+        </el-row>
+      </el-card>
+      <el-card
+        :body-style="{
+          padding: '20px',
+          display: 'flex',
+          'flex-wrap': 'wrap',
+          position: 'relative',
+        }"
+        style="margin: 10px"
+      >
+        <el-tabs v-model="tabName" @tab-click="handleClick" style="width: 100%">
+          <el-tab-pane
+            v-for="(column, index) in tabColumns"
+            :key="index"
+            :label="column.title"
+            :name="column.key"
+          >
+            <el-table :data="tabTableParams[column.key]" style="width: 100%">
+              <el-table-column
+                v-for="(cColumn, cIndex) in column.tableColumns"
+                :key="cIndex"
+                :prop="cColumn.key"
+                :label="cColumn.title"
+                :width="cColumn.width"
+              >
+                <template slot-scope="scope">
+                  <el-tag v-if="cColumn.key === 'index'">
+                    {{ scope.$index + 1 }}
+                  </el-tag>
+                  <el-input
+                    v-if="cColumn.type === 'Input'"
+                    v-model="scope.row[cColumn.key]"
+                    :placeholder="cColumn.placeholder"
+                    :clearable="cColumn.clearable"
+                    :disabled="cColumn.disabled"
+                    size="mini"
+                    style="width: 100%"
+                  ></el-input>
+                  <el-input-number
+                    v-if="cColumn.type === 'InputNumber'"
+                    v-model="scope.row[cColumn.key]"
+                    :controls-position="cColumn.config.controlsPosition"
+                    :placeholder="cColumn.placeholder"
+                    :clearable="cColumn.clearable"
+                    :disabled="cColumn.disabled"
+                    size="mini"
+                    style="width: 100%"
+                  ></el-input-number>
+                  <el-input
+                    v-if="cColumn.type === 'InputDialog'"
+                    v-model="scope.row[cColumn.key]"
+                    :placeholder="cColumn.placeholder"
+                    :clearable="cColumn.clearable"
+                    :disabled="cColumn.disabled"
+                    size="mini"
+                    style="width: 100%"
+                    @blur="openAsyncInputDialog(cColumn, 'change', scope.row)"
+                    @change="openAsyncInputDialog(cColumn, 'change', scope.row)"
+                  >
+                    <template #suffix>
+                      <el-icon
+                        class="el-icon-s-operation"
+                        style="cursor: pointer"
+                        @click.native.stop="
+                          openAsyncInputDialog(cColumn, 'click', scope.row)
+                        "
+                      ></el-icon>
+                    </template>
+                  </el-input>
+                </template>
+              </el-table-column>
+            </el-table>
+          </el-tab-pane>
+        </el-tabs>
+        <el-row style="position: absolute; top: 20px; right: 20px">
+          <el-button size="mini" @click="addTableRow(tabName)">增行</el-button>
+        </el-row>
+      </el-card>
+    </el-form>
   </el-drawer>
 </template>

+ 1 - 1
src/views/purchase/purchase-contract/index.vue

@@ -1,6 +1,6 @@
 <script>
 import { list } from "@/api/business/purchase/purchase-contract";
-import AddPurchaseContractDrawer from "./add-purchase-contract.vue";
+import AddPurchaseContractDrawer from "./add/index.vue";
 import SeePurchaseContractDrawer from "./see-purchase-contract.vue";
 // import DirectSourcingTable from "./direct-sourcing.vue";
 export default {