Browse Source

利润结算表,结算功能调整. 深拷贝功能:proxy.deepClone

lxf 1 year ago
parent
commit
e42d18c5eb

+ 3 - 1
src/main.js

@@ -54,7 +54,8 @@ import {
   getPdf,
   getPdfTransverseA4,
   translateIntoEnglish,
-  random
+  random,
+  deepClone
 } from '@/utils/util'
 
 // 分页组件
@@ -97,6 +98,7 @@ app.config.globalProperties.getPdf = getPdf
 app.config.globalProperties.getPdfTransverseA4 = getPdfTransverseA4
 app.config.globalProperties.translateIntoEnglish = translateIntoEnglish
 app.config.globalProperties.random = random
+app.config.globalProperties.deepClone = deepClone
 
 
 // 全局组件挂载

+ 33 - 0
src/utils/util.js

@@ -309,3 +309,36 @@ export function random() {
   }
   return random;
 }
+
+// 深拷贝
+export function checkType(target) {
+  return Object.prototype.toString.call(target).slice(8, -1);
+}
+export function deepClone(data) {
+  const obj = checkType(data) === "Array" ? [] : {};
+  let arr = ["Object", "Array"];
+  if (arr.includes(checkType(data))) {
+    for (let key in data) {
+      let value = data[key];
+      //value为简单类型,直接赋值
+      if (!arr.includes(checkType(value))) {
+        obj[key] = value;
+      } else {
+        // 定义一个映射,初始化时,将data本身加入映射中
+        const map = new WeakMap();
+        // 如果拷贝的是复杂数据类型第一次拷贝后存入map
+        // 第二次再遇到该值时,直接赋值为null,结束递归
+        map.set(data, true);
+        if (map.has(value)) {
+          obj[key] = null;
+        } else {
+          map.set(value, true);
+          obj[key] = deepClone(value);
+        }
+      }
+    }
+  } else {
+    return data;
+  }
+  return obj;
+}

+ 1 - 1
src/views/customer/file/index.vue

@@ -1016,7 +1016,7 @@ const clickInformationMore = (item, index) => {
   } else {
     item.contact = [];
   }
-  formPerson.data = JSON.parse(JSON.stringify(item));
+  formPerson.data = proxy.deepClone(item);
   openPerson.value = true;
 };
 const clickDelete = (index) => {

+ 1 - 1
src/views/customer/highseas/index.vue

@@ -991,7 +991,7 @@ const clickInformationMore = (item, index) => {
   } else {
     item.contact = [];
   }
-  formPerson.data = JSON.parse(JSON.stringify(item));
+  formPerson.data = proxy.deepClone(item);
   openPerson.value = true;
 };
 const clickDelete = (index) => {

+ 1 - 1
src/views/customer/privatesea/index.vue

@@ -925,7 +925,7 @@ const clickInformationMore = (item, index) => {
   } else {
     item.contact = [];
   }
-  formPerson.data = JSON.parse(JSON.stringify(item));
+  formPerson.data = proxy.deepClone(item);
   openPerson.value = true;
 };
 const clickDelete = (index) => {

+ 2 - 2
src/views/dataBoard/board/productAnalysis/index.vue

@@ -363,7 +363,7 @@ const sortChangeThree = ({ prop, order }) => {
 };
 const getProductTypeRanking = () => {
   loadingTwo.value = true;
-  let query = JSON.parse(JSON.stringify(queryForm));
+  let query = proxy.deepClone(queryForm);
   query.pageNum = 1;
   query.pageSize = 10;
   query.sort = productTypeRankingSort.value[productTypeRankingProp.value] || 10;
@@ -385,7 +385,7 @@ const getProductTypeRanking = () => {
 };
 const getProductRanking = () => {
   loadingThree.value = true;
-  let query = JSON.parse(JSON.stringify(queryForm));
+  let query = proxy.deepClone(queryForm);
   query.pageNum = 1;
   query.pageSize = 10;
   query.sort = productRankingSort.value[productRankingProp.value] || 10;

+ 2 - 2
src/views/oa/work/schedule/index.vue

@@ -420,7 +420,7 @@ const getStyle = (text) => {
   }
 };
 const getSelectDayList = () => {
-  let queryParam = JSON.parse(JSON.stringify(sourceList.value.pagination));
+  let queryParam = proxy.deepClone(sourceList.value.pagination);
   queryParam.startDate = moment(today.value).format("yyyy-MM-DD");
   queryParam.endDate = moment(today.value).format("yyyy-MM-DD");
   if (menuDefault.value === 1) {
@@ -621,7 +621,7 @@ const clickSubmit = () => {
       return ElMessage("结束时间不能小于开始时间");
     }
     loadingDialog.value = true;
-    let data = JSON.parse(JSON.stringify(formData.data));
+    let data = proxy.deepClone(formData.data);
     if (data.participantList && data.participantList.length > 0) {
       data.participantList = data.participantList.map((item) => {
         return {

+ 2 - 8
src/views/publicModule/codingRule/index.vue

@@ -1,13 +1,7 @@
 <template>
   <div class="tenant">
     <div class="content">
-      <byTable
-        :source="sourceList.data"
-        :pagination="sourceList.pagination"
-        :config="config"
-        :loading="loading"
-        highlight-current-row
-        @get-list="getList">
+      <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" highlight-current-row @get-list="getList">
       </byTable>
     </div>
 
@@ -273,7 +267,7 @@ const submitForm = () => {
   });
 };
 const update = (row) => {
-  formData.data = JSON.parse(JSON.stringify(row));
+  formData.data = proxy.deepClone(row);
   loadingDialog.value = false;
   dialogVisible.value = true;
 };

+ 1 - 1
src/views/publicModule/salesman/index.vue

@@ -133,7 +133,7 @@ const submitForm = () => {
   });
 };
 const update = (row) => {
-  formData.data = JSON.parse(JSON.stringify(row));
+  formData.data = proxy.deepClone(row);
   loadingDialog.value = false;
   dialogVisible.value = true;
 };

+ 54 - 145
src/views/salesMange/salesMange/profitSettlement/index.vue

@@ -16,16 +16,12 @@
             action: () => openModal(),
           },
         ]"
-        @get-list="getList"
-      >
+        @get-list="getList">
         <template #amount="{ item }">
           <div></div>
         </template>
       </byTable>
-      <div
-        style="padding: 0 20px 20px 20px; background-color: white"
-        v-if="rateStatus"
-      >
+      <div style="padding: 0 20px 20px 20px; background-color: white" v-if="rateStatus">
         <el-table v-loading="loading" :data="sourceList.data">
           <el-table-column label="合同编号">
             <el-table-column label="" prop="contractCode" width="160" />
@@ -40,11 +36,7 @@
             <el-table-column label="" prop="contractAmount" width="120" />
           </el-table-column>
           <el-table-column label="收入">
-            <el-table-column
-              label="合同到账"
-              prop="contractArrival"
-              width="120"
-            />
+            <el-table-column label="合同到账" prop="contractArrival" width="120" />
             <el-table-column label="其他收入" prop="otherIncome" width="120" />
           </el-table-column>
           <el-table-column label="采购合同金额">
@@ -52,51 +44,24 @@
           </el-table-column>
           <el-table-column label="支出">
             <el-table-column label="支付货款" prop="payForGoods" width="120" />
-            <el-table-column
-              label="其他支出"
-              prop="otherExpenses"
-              width="120"
-            />
+            <el-table-column label="其他支出" prop="otherExpenses" width="120" />
           </el-table-column>
           <el-table-column label="统计">
             <el-table-column label="收入合计" prop="totalIncome" width="120" />
-            <el-table-column
-              label="支出合计"
-              prop="totalExpenses"
-              width="120"
-            />
+            <el-table-column label="支出合计" prop="totalExpenses" width="120" />
             <el-table-column label="毛利" prop="grossProfit" width="120" />
-            <el-table-column
-              label="毛利率"
-              prop="grossProfitMargin"
-              width="120"
-            />
+            <el-table-column label="毛利率" prop="grossProfitMargin" width="120">
+              <template #default="{ row }">
+                <div style="width: 100%">{{ row.grossProfitMargin }}%</div>
+              </template>
+            </el-table-column>
           </el-table-column>
-          <el-table-column
-            label="操作"
-            align="center"
-            width="170"
-            fixed="right"
-          >
+          <el-table-column label="操作" align="center" width="170" fixed="right">
             <template #default="{ row }">
               <div>
-                <el-button type="primary" @click="changeExchangeRate(row)" link
-                  >调整汇率</el-button
-                >
-                <el-button
-                  type="primary"
-                  @click="clickSettlement(row)"
-                  v-if="row.settlementStatus === 0"
-                  link
-                  >结算</el-button
-                >
-                <el-button
-                  type="primary"
-                  @click="clickCancelSettlement(row)"
-                  v-else
-                  link
-                  >取消结算</el-button
-                >
+                <el-button type="primary" @click="changeExchangeRate(row)" link>调整汇率</el-button>
+                <el-button type="primary" @click="clickSettlement(row)" v-if="row.settlementStatus === 0" link>结算</el-button>
+                <el-button type="primary" @click="clickCancelSettlement(row)" v-else link>取消结算</el-button>
               </div>
             </template>
           </el-table-column>
@@ -110,30 +75,14 @@
           :page-size="sourceList.pagination.pageSize"
           :total="sourceList.pagination.total"
           @size-change="handleSizeChange"
-          @current-change="handlePageChange"
-        />
+          @current-change="handlePageChange" />
       </el-row>
     </div>
 
-    <el-dialog
-      title="默认汇率"
-      v-if="dialogVisible"
-      v-model="dialogVisible"
-      width="600"
-    >
-      <byForm
-        :formConfig="formConfig"
-        :formOption="formOption"
-        v-model="formData.data"
-        :rules="rules"
-        ref="submit"
-      >
+    <el-dialog title="默认汇率" v-if="dialogVisible" v-model="dialogVisible" width="600">
+      <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
         <template #currencyList>
-          <el-table
-            :data="formData.data.list"
-            style="width: 100%"
-            v-loading="loadingDialog"
-          >
+          <el-table :data="formData.data.list" style="width: 100%" v-loading="loadingDialog">
             <el-table-column label="币种">
               <template #default="{ row }">
                 <div>{{ dictValueLabel(row.type, accountCurrency) }}</div>
@@ -141,19 +90,8 @@
             </el-table-column>
             <el-table-column label="兑 CHY 汇率">
               <template #default="{ row, $index }">
-                <el-form-item
-                  :prop="'list.' + $index + '.rate'"
-                  :rules="rules.rate"
-                  :inline-message="true"
-                >
-                  <el-input-number
-                    v-model="row.rate"
-                    placeholder="请输入兑 CHY 汇率"
-                    style="width: 100%"
-                    :precision="6"
-                    :controls="false"
-                    :min="0"
-                  />
+                <el-form-item :prop="'list.' + $index + '.rate'" :rules="rules.rate" :inline-message="true">
+                  <el-input-number v-model="row.rate" placeholder="请输入兑 CHY 汇率" style="width: 100%" :precision="6" :controls="false" :min="0" />
                 </el-form-item>
               </template>
             </el-table-column>
@@ -162,31 +100,14 @@
       </byForm>
       <template #footer>
         <el-button @click="dialogVisible = false" size="large">取 消</el-button>
-        <el-button type="primary" @click="submitForm()" size="large"
-          >确 定</el-button
-        >
+        <el-button type="primary" @click="submitForm()" size="large">确 定</el-button>
       </template>
     </el-dialog>
 
-    <el-dialog
-      title="调整汇率"
-      v-if="openChange"
-      v-model="openChange"
-      width="600"
-    >
-      <byForm
-        :formConfig="formChangeConfig"
-        :formOption="formOption"
-        v-model="formChangeData.data"
-        :rules="rules"
-        ref="change"
-      >
+    <el-dialog title="调整汇率" v-if="openChange" v-model="openChange" width="600">
+      <byForm :formConfig="formChangeConfig" :formOption="formOption" v-model="formChangeData.data" :rules="rules" ref="change">
         <template #currencyList>
-          <el-table
-            :data="formChangeData.data.list"
-            style="width: 100%"
-            v-loading="loadingDialog"
-          >
+          <el-table :data="formChangeData.data.list" style="width: 100%" v-loading="loadingDialog">
             <el-table-column label="币种">
               <template #default="{ row }">
                 <div>{{ dictValueLabel(row.type, accountCurrency) }}</div>
@@ -194,19 +115,8 @@
             </el-table-column>
             <el-table-column label="兑 CHY 汇率">
               <template #default="{ row, $index }">
-                <el-form-item
-                  :prop="'list.' + $index + '.rate'"
-                  :rules="rules.rate"
-                  :inline-message="true"
-                >
-                  <el-input-number
-                    v-model="row.rate"
-                    placeholder="请输入兑 CHY 汇率"
-                    style="width: 100%"
-                    :precision="6"
-                    :controls="false"
-                    :min="0"
-                  />
+                <el-form-item :prop="'list.' + $index + '.rate'" :rules="rules.rate" :inline-message="true">
+                  <el-input-number v-model="row.rate" placeholder="请输入兑 CHY 汇率" style="width: 100%" :precision="6" :controls="false" :min="0" />
                 </el-form-item>
               </template>
             </el-table-column>
@@ -215,9 +125,7 @@
       </byForm>
       <template #footer>
         <el-button @click="openChange = false" size="large">取 消</el-button>
-        <el-button type="primary" @click="submitChangeForm()" size="large"
-          >确 定</el-button
-        >
+        <el-button type="primary" @click="submitChangeForm()" size="large">确 定</el-button>
       </template>
     </el-dialog>
   </div>
@@ -311,15 +219,13 @@ const getDict = () => {
 const getList = async (req) => {
   sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
   loading.value = true;
-  proxy
-    .post("/saleStatement/getProfitSettlement", sourceList.value.pagination)
-    .then((res) => {
-      sourceList.value.data = res.rows;
-      sourceList.value.pagination.total = res.total;
-      setTimeout(() => {
-        loading.value = false;
-      }, 200);
-    });
+  proxy.post("/saleStatement/getProfitSettlement", sourceList.value.pagination).then((res) => {
+    sourceList.value.data = res.rows;
+    sourceList.value.pagination.total = res.total;
+    setTimeout(() => {
+      loading.value = false;
+    }, 200);
+  });
 };
 const rateStatus = ref(false);
 const judgeRate = () => {
@@ -526,7 +432,7 @@ const submitChangeForm = () => {
     let data = {};
     data.id = formChangeData.data.id;
     data.currencyRateJson = JSON.stringify(formChangeData.data.list);
-    proxy.post("/saleStatement/update", data).then(
+    proxy.post("/commission/add", data).then(
       () => {
         ElMessage({
           message: "保存成功",
@@ -543,26 +449,29 @@ const submitChangeForm = () => {
   });
 };
 const clickSettlement = (row) => {
-  proxy
-    .post("/saleStatement/update", { id: row.contractId, settlementStatus: 1 })
-    .then(() => {
-      ElMessage({
-        message: "保存成功",
-        type: "success",
-      });
-      getList();
+  let data = proxy.deepClone(row);
+  data.afterSalesAmount = 0;
+  data.publicAmount = 0;
+  data.haveOverallAmount = 0;
+  data.departmentalCommission = 0;
+  data.personalCommission = 0;
+  data.settlementStatus = 1;
+  proxy.post("/commission/add", data).then(() => {
+    ElMessage({
+      message: "保存成功",
+      type: "success",
     });
+    getList();
+  });
 };
 const clickCancelSettlement = (row) => {
-  proxy
-    .post("/saleStatement/update", { id: row.contractId, settlementStatus: 0 })
-    .then(() => {
-      ElMessage({
-        message: "保存成功",
-        type: "success",
-      });
-      getList();
+  proxy.post("/commission/add", { id: row.contractId, settlementStatus: 0 }).then(() => {
+    ElMessage({
+      message: "保存成功",
+      type: "success",
     });
+    getList();
+  });
 };
 </script>
 

+ 1 - 1
src/views/salesMange/shipmentMange/document/index.vue

@@ -1405,7 +1405,7 @@ const clickDownload = () => {
     proxy.getPdf("销售确认书PDF文件");
   } else if (openStatus.value === 4) {
     textShow.value = true;
-    let data = JSON.parse(JSON.stringify(printCustomsDeclaration.value));
+    let data = proxy.deepClone(printCustomsDeclaration.value);
     data.content = JSON.stringify(data.content);
     proxy.post("/documentsPdf/add", data).then();
     setTimeout(() => {