wxy 4 years ago
parent
commit
f18f4ccca2
4 changed files with 337 additions and 232 deletions
  1. 169 65
      src/views/order/goods.vue
  2. 6 3
      src/views/order/in.vue
  3. 159 161
      src/views/order/out.vue
  4. 3 3
      src/views/order/transport/sign.vue

+ 169 - 65
src/views/order/goods.vue

@@ -10,10 +10,21 @@
                   <el-row :gutter="10">
                     <el-col class="card-header1" :span="24">订单号:{{ item.order_no }}</el-col>
                     <el-col class="card-header1" :span="24">客户:{{ choose(item.client) }}</el-col>
-                    <!-- <el-col class="card-header1" :span="24">线路:xxxxxxxxxxxxxxxxxx</el-col> -->
                   </el-row>
                 </div>
-                <data-table height="200px" :fields="fields" :data="item.goods" :usePage="false" :opera="opera"> </data-table>
+                <!-- <data-table height="200px" :fields="fields" :data="item.split" :usePage="false" :opera="opera" @splice="splice"> </data-table> -->
+                <el-table :data="item.split" style="width: 100%" @row-click="clickTable(index)">
+                  <el-table-column prop="name" label="货物名"></el-table-column>
+                  <el-table-column prop="number" label="数量"></el-table-column>
+                  <el-table-column prop="weight" label="重量"></el-table-column>
+                  <el-table-column prop="volume" label="体积"></el-table-column>
+                  <el-table-column prop="remark" label="备注"></el-table-column>
+                  <el-table-column label="操作">
+                    <template slot-scope="scope">
+                      <el-button size="mini" @click="splice(index, scope.row)">编辑</el-button>
+                    </template>
+                  </el-table-column>
+                </el-table>
               </el-card>
             </el-col>
           </el-row>
@@ -21,51 +32,33 @@
       </el-col>
     </el-row>
     <el-dialog :visible.sync="dialog" title="货物编辑" @close="toClose" width="50%">
-      <!-- <el-form ref="form" :model="form" label-width="80px" class="goods">
-        <el-form-item label="活动名称">
-          <el-input v-model="form.name"></el-input>
-        </el-form-item>
-        <el-col :span="24">
-          <el-col :span="24" class="title">原订单</el-col>
-          <el-col :span="4" class="title2">订单号</el-col>
-          <el-col :span="4" class="title2">拆分单号</el-col>
-          <el-col :span="4" class="title2">货物名称</el-col>
-          <el-col :span="4" class="title2">数量</el-col>
-          <el-col :span="4" class="title2">重量</el-col>
-          <el-col :span="4" class="title2">体积</el-col>
-          <el-col :span="4" class="con">123</el-col>
-          <el-col :span="4" class="con">1_2_3</el-col>
-          <el-col :span="4" class="con">器具</el-col>
-          <el-col :span="4" class="con">4</el-col>
-          <el-col :span="4" class="con">400</el-col>
-          <el-col :span="4" class="con">24</el-col>
-        </el-col>
-      </el-form> -->
-      <el-table :data="tableData" style="width: 100%">
+      <el-table :data="[orderForm]" style="width: 100%">
         <el-table-column label="原订单">
-          <el-table-column prop="ordernum" label="订单号"></el-table-column>
-          <el-table-column prop="splitnum" label="拆分单号"></el-table-column>
-          <el-table-column prop="goods" label="货物"></el-table-column>
+          <el-table-column prop="name" label="货物名"></el-table-column>
           <el-table-column prop="number" label="数量"></el-table-column>
           <el-table-column prop="weight" label="重量"></el-table-column>
           <el-table-column prop="volume" label="体积"></el-table-column>
+          <el-table-column prop="remark" label="备注"></el-table-column>
         </el-table-column>
       </el-table>
       <el-col :span="24" class="splite">
         <el-button type="primary" size="mini" @click="splite()">拆分</el-button>
       </el-col>
-      <el-table :data="part1Data" style="width: 100%">
+      <el-table :data="splitList" style="width: 100%">
         <el-table-column label="拆分订单">
-          <el-table-column prop="splitnum" label="拆分单号"></el-table-column>
-          <el-table-column prop="goods" label="货物"></el-table-column>
+          <el-table-column prop="name" label="货物名"></el-table-column>
           <el-table-column prop="number" label="数量"
             ><template slot-scope="scope">
               <el-input-number
                 v-model="scope.row.number"
                 controls-position="right"
-                @change="handleChange"
-                :min="1"
-                :max="100"
+                @change="
+                  (currentValue, oldValue) => {
+                    changeNumber(scope.$index, currentValue, oldValue);
+                  }
+                "
+                :min="0"
+                :max="scope.row.max"
                 size="mini"
                 style="width: 100px"
               ></el-input-number> </template
@@ -75,9 +68,13 @@
               <el-input-number
                 v-model="scope.row.weight"
                 controls-position="right"
-                @change="handleChange"
-                :min="1"
-                :max="100"
+                @change="
+                  (currentValue, oldValue) => {
+                    changeWeight(scope.$index, currentValue, oldValue);
+                  }
+                "
+                :min="0"
+                :max="scope.row.max"
                 size="mini"
                 style="width: 100px"
               ></el-input-number>
@@ -88,14 +85,23 @@
               <el-input-number
                 v-model="scope.row.volume"
                 controls-position="right"
-                @change="handleChange"
-                :min="1"
-                :max="100"
+                @change="
+                  (currentValue, oldValue) => {
+                    changeVolume(scope.$index, currentValue, oldValue);
+                  }
+                "
+                :min="0"
+                :max="scope.row.max"
                 size="mini"
                 style="width: 100px"
               ></el-input-number>
             </template>
           </el-table-column>
+          <el-table-column prop="remark" label="备注">
+            <template slot-scope="scope">
+              <el-input type="textarea" :autosize="{ minRows: 1, maxRows: 3 }" v-model="scope.row.remark"></el-input>
+            </template>
+          </el-table-column>
           <el-table-column label="操作">
             <template slot-scope="scope">
               <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
@@ -104,7 +110,7 @@
         </el-table-column>
       </el-table>
       <span slot="footer" class="dialog-footer">
-        <el-button type="primary" @click="dialog = false">拆分订单</el-button>
+        <el-button type="primary" @click="add(splitList)">拆分订单</el-button>
       </span>
     </el-dialog>
   </div>
@@ -134,19 +140,20 @@ export default {
       opera: [{ label: '拆分', method: 'splice' }],
       total: 0,
       form: {},
+      orderForm: {},
       dialog: false,
       tableData: [
-        {
-          ordernum: '111111',
-          splitnum: '111_222',
-          goods: '好吃的',
-          number: '20',
-          weight: '20',
-          volume: '8',
-        },
+        // {
+        //   ordernum: '111111',
+        //   splitnum: '111_222',
+        //   goods: '好吃的',
+        //   number: '20',
+        //   weight: '20',
+        //   volume: '8',
+        // },
       ],
       //拆分订单列表
-      part1Data: [],
+      splitList: [],
       //合同列表
       contractList: [{ name: '合同一' }, { name: '合同二' }],
       //项目列表
@@ -154,6 +161,12 @@ export default {
       //客戶列表
       nameList: [],
       // name: [],
+      num: 1,
+      number: 0,
+      max: 0,
+      weight: 0,
+      volume: 0,
+      tableNumber: 0,
     };
   },
   async created() {
@@ -185,35 +198,126 @@ export default {
     turnSave(data) {
       console.log(data);
     },
-    //拆分货物
-    split({ data }) {
-      console.log(data);
+    //卡片上面的拆分
+    splice(index, data) {
+      this.$set(this, `orderForm`, _.cloneDeep(data));
       this.dialog = true;
+      this.number = this.orderForm.number;
+      this.weight = this.orderForm.weight;
+      this.volume = this.orderForm.volume;
     },
+    //真的拆分订单
     splite() {
-      const data = this.tableData[0];
-      console.log(data);
-      console.log('拆分');
+      let origin = this.orderForm;
+      this.splitList.push({ type: 1, name: `${this.orderForm.name}-${this.num++}`, number: 0, weight: 0, volume: 0, pid: origin.pid });
+    },
+    //数量改变
+    changeNumber(index, currentValue, oldValue) {
+      let list = this.splitList;
+      let count = 0;
+      for (let item of list) {
+        count += item.number;
+        if (this.orderForm.number === 1) {
+          this.$set(item, `max`, item.number);
+        } else {
+          this.$set(item, `max`, item.number + this.orderForm.number + 1);
+        }
+      }
+      if (currentValue > oldValue) {
+        if (this.orderForm.number > 0) {
+          let sum = this.number - count;
+          this.$set(this.orderForm, `number`, sum);
+        }
+      } else {
+        if (this.orderForm.number >= 0) {
+          let num = this.number - count;
+          this.$set(this.orderForm, `number`, num);
+        }
+      }
     },
-    handleChange(value) {
-      console.log(value);
+    //重量改变
+    changeWeight(index, currentValue, oldValue) {
+      let list = this.splitList;
+      let count = 0;
+      for (let item of list) {
+        count += item.weight;
+        if (this.orderForm.weight === 1) {
+          this.$set(item, `max`, item.weight);
+        } else {
+          this.$set(item, `max`, item.weight + this.orderForm.weight + 1);
+        }
+      }
+      if (currentValue > oldValue) {
+        if (this.orderForm.weight > 0) {
+          let sum = this.weight - count;
+          this.$set(this.orderForm, `weight`, sum);
+        }
+      } else {
+        if (this.orderForm.weight >= 0) {
+          let num = this.weight - count;
+          this.$set(this.orderForm, `weight`, num);
+        }
+      }
+    },
+    //体积改变
+    changeVolume(index, currentValue, oldValue) {
+      let list = this.splitList;
+      let count = 0;
+      for (let item of list) {
+        count += item.volume;
+        if (this.orderForm.volume === 1) {
+          this.$set(item, `max`, item.volume);
+        } else {
+          this.$set(item, `max`, item.volume + this.orderForm.volume + 1);
+        }
+      }
+      if (currentValue > oldValue) {
+        if (this.orderForm.volume > 0) {
+          let sum = this.volume - count;
+          this.$set(this.orderForm, `volume`, sum);
+        }
+      } else {
+        if (this.orderForm.volume >= 0) {
+          let num = this.volume - count;
+          this.$set(this.orderForm, `volume`, num);
+        }
+      }
     },
     //删除
     handleDelete(index, row) {
-      console.log(index, row);
+      this.orderForm.number += this.splitList[index].number;
+      this.orderForm.weight += this.splitList[index].weight;
+      this.orderForm.volume += this.splitList[index].volume;
+      this.splitList.splice(index, 1);
     },
-    // choose() {
-    //   let orderList = this.list;
-    //   for (let item of orderList) {
-    //     let arr = this.nameList.find(i => i.id === item.client);
-    //     item.name = arr.name;
-    //   }
-    //   this.$set(this, `list`, orderList);
-    // },
     choose(client) {
       const obj = this.nameList.find(i => i.id === client);
       if (obj) return obj.name;
     },
+    //保存拆分订单  ???修改不上 search栏怎么弄
+    async add(data) {
+      let splitList = this.list[this.tableNumber].split;
+      // console.log(splitList);
+      let newList = [];
+      newList.push(splitList[0]);
+      newList.push();
+      for (let item of data) {
+        newList.push(item);
+      }
+      this.$set(this.list[this.tableNumber], `split`, newList);
+      let newData = this.list[this.tableNumber];
+      let owner = this.user.id;
+      const res = await this.update(this.list);
+      if (this.$checkRes(res, '拆分成功', res.errmsg || '拆分失败')) {
+        this.search();
+        this.orderForm = {};
+        this.dialog = false;
+      }
+    },
+    clickTable(index) {
+      console.log(index);
+      this.tableNumber = index;
+    },
   },
   computed: {
     ...mapState(['user']),

+ 6 - 3
src/views/order/in.vue

@@ -145,10 +145,13 @@ export default {
       this.dialog = false;
     },
     //保存
-    turnSave({ data }) {
+    async turnSave({ data }) {
       if (data) {
-        console.log(data);
-        console.log(this.form);
+        const res = await this.update(data);
+        if (this.$checkRes(res, '修改成功', res.errmsg || '修改失败')) {
+          this.search();
+          this.dialog = false;
+        }
       }
     },
     //修改收入

+ 159 - 161
src/views/order/out.vue

@@ -4,22 +4,21 @@
       <animates>
         <el-col :span="24" class="container">
           <el-col :span="24" class="info">
-            <data-table :fields="fields" :data="list" :opera="opera" :total="total" :size="50" :step="10" @query="search" v-if="!dialog" @see="see">
+            <data-table
+              :fields="fields"
+              :data="list"
+              :opera="opera"
+              :total="total"
+              :size="50"
+              :step="10"
+              @query="search"
+              v-if="!dialog"
+              @see="see"
+              :toFormat="roleSelect"
+            >
               <template #options="{item}">
-                <template v-if="item.model == 'name'">
-                  <el-option v-for="(item, index) in nameList" :key="index" :value="item.name" :label="item.name"></el-option>
-                </template>
-                <template v-if="item.model == 'contract'">
-                  <el-option v-for="(item, index) in contractList" :key="index" :value="item.name" :label="item.name"></el-option>
-                </template>
-                <template v-if="item.model == 'project'">
-                  <el-option v-for="(item, index) in projectList" :key="index" :value="item.name" :label="item.name"></el-option>
-                </template>
-                <template v-if="item.model == 'route'">
-                  <el-option v-for="(item, index) in routeList" :key="index" :value="item.name" :label="item.name"></el-option>
-                </template>
-                <template v-if="item.model == 'way'">
-                  <el-option v-for="(item, index) in wayList" :key="index" :value="item.name" :label="item.name"></el-option>
+                <template v-if="item.model == 'client'">
+                  <el-option v-for="(item, index) in nameList" :key="index" :value="item.id" :label="item.name"></el-option>
                 </template>
               </template>
             </data-table>
@@ -32,8 +31,7 @@
               </el-row>
               <el-row>
                 <el-col :span="24" class="head">
-                  <el-col :span="12" style="text-align:center">流水账号:{{ detailList[0].current }}</el-col>
-                  <el-col :span="12" style="text-align:left">订单号:{{ detailList[0].ordernumber }}</el-col>
+                  <el-col :span="12" style="text-align:left">订单号:{{ detailForm.order_no }}</el-col>
                 </el-col>
               </el-row>
               <el-row>
@@ -42,7 +40,7 @@
                     <span>货物列表</span>
                   </div>
                   <div class="text item">
-                    <data-table :fields="detailFields" :data="detailList" :usePage="false"> </data-table>
+                    <data-table :fields="detailFields" :data="detailForm.goods" :usePage="false"> </data-table>
                   </div>
                   <el-divider></el-divider>
                 </el-card>
@@ -63,29 +61,17 @@
                   + 添加支出
                 </el-button>
                 <el-tabs v-model="editableTabsValue" type="card" closable @tab-remove="removeTab">
-                  <el-tab-pane v-for="(item, index) in editableTabs" :key="index" :label="`支出${index + 1}`" :name="`${index + 1}`">
+                  <el-tab-pane v-for="(item, index) in detailForm.out_bill" :key="index" :label="`支出${index + 1}`" :name="`${index + 1}`">
                     <el-col :span="24">
-                      <el-form ref="form" label-width="90px" :inline="true">
+                      <el-form v-model="item.item" ref="form" label-width="90px" :inline="true">
                         <el-form-item label="支出项">
                           <el-select v-model="item.cost" placeholder="请选择支出项">
-                            <el-option v-for="(item, index) in costList" :key="index" :label="item.name" :value="item.name"></el-option>
-                          </el-select>
-                        </el-form-item>
-
-                        <el-form-item label="供应商方式">
-                          <el-radio-group v-model="item.supplierway">
-                            <el-radio label="自运"></el-radio>
-                            <el-radio label="他运"></el-radio>
-                          </el-radio-group>
-                        </el-form-item>
-                        <el-form-item label="车辆">
-                          <el-select v-model="item.supplier" placeholder="请选择车辆">
-                            <el-option v-for="(item, index) in carList" :key="index" :label="item.name" :value="item.name"></el-option>
+                            <el-option v-for="(item, index) in costList" :key="index" :label="item.label" :value="item.value"></el-option>
                           </el-select>
                         </el-form-item>
                         <el-form-item label="税率">
                           <el-select
-                            v-model="item.rate"
+                            v-model="item.taxes"
                             placeholder="请选择税率"
                             @change="
                               val => {
@@ -93,23 +79,20 @@
                               }
                             "
                           >
-                            <el-option v-for="(item, index) in rateList" :key="index" :label="item.name" :value="item.name"></el-option>
+                            <el-option v-for="(item, index) in rateList" :key="index" :label="item.label" :value="item.label"></el-option>
                           </el-select>
                         </el-form-item>
                         <el-form-item label="税前应付">
-                          <el-input v-model="item.cost1" @change="change(index)"></el-input>
+                          <el-input v-model="item.sq_ys" @change="change(index)"></el-input>
                         </el-form-item>
                         <el-form-item label="税后应付">
-                          <el-input v-model="item.cost2" readonly></el-input>
+                          <el-input v-model="item.sh_ys" readonly></el-input>
                         </el-form-item>
                         <el-form-item label="税前实付">
-                          <el-input v-model="item.cost3" @change="toChange(index)"></el-input>
+                          <el-input v-model="item.sq_ss" @change="toChange(index)"></el-input>
                         </el-form-item>
                         <el-form-item label="税后实付">
-                          <el-input v-model="item.cost4" readonly></el-input>
-                        </el-form-item>
-                        <el-form-item label="备注">
-                          <el-input type="textarea" v-model="item.desc"></el-input>
+                          <el-input v-model="item.sh_ss" readonly></el-input>
                         </el-form-item>
                       </el-form>
                     </el-col>
@@ -117,7 +100,7 @@
                 </el-tabs>
                 <el-row>
                   <el-col :span="24" style="text-align:center">
-                    <el-button type="primary" size="mini" @click="save(editableTabs)" style="margin:10px 0px">
+                    <el-button type="primary" size="mini" @click="save(detailForm.out_bill)" style="margin:10px 0px">
                       保存
                     </el-button>
                   </el-col>
@@ -133,6 +116,10 @@
 
 <script>
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: order } = createNamespacedHelpers('order');
+const { mapActions: client } = createNamespacedHelpers('client');
+const { mapActions: dictionary } = createNamespacedHelpers('dictionary');
+
 const _ = require('lodash');
 export default {
   metaInfo() {
@@ -145,34 +132,33 @@ export default {
     return {
       dialog: false,
       fields: [
-        { label: '订单号', model: 'num', filter: 'input' },
-        { label: '客户', model: 'name', filter: 'select' },
-        { label: '长途运费金额', model: 'money' },
-        { label: '合同', model: 'contract', notable: 'true', filter: 'select' },
-        { label: '项目', model: 'project', notable: 'true', filter: 'select' },
-        { label: '线路', model: 'route', notable: 'true', filter: 'select' },
-        { label: '付费方式', model: 'way', notable: 'true', filter: 'select' },
+        { label: '订单号', model: 'order_no', filter: 'input' },
+        { label: '客户', model: 'client', filter: 'select', format: true },
+        // { label: '合同', model: 'contract', notable: 'true', filter: 'select' },
+        // { label: '项目', model: 'project', notable: 'true', filter: 'select' },
+        // { label: '线路', model: 'route', notable: 'true', filter: 'select' },
+        // { label: '付费方式', model: 'way', notable: 'true', filter: 'select' },
       ],
       list: [
-        {
-          id: '1',
-          name: 'xxx有限公司',
-          num: 'AW-YS-ZF-2018-005',
-          money: 100,
-          way: '银行转账',
-        },
-        {
-          id: '2',
-          name: 'xxx有限公司',
-          num: 'AW-YS-ZF-2018-005',
-          money: 200,
-          way: '银行转账',
-        },
+        // {
+        //   id: '1',
+        //   name: 'xxx有限公司',
+        //   num: 'AW-YS-ZF-2018-005',
+        //   money: 100,
+        //   way: '银行转账',
+        // },
+        // {
+        //   id: '2',
+        //   name: 'xxx有限公司',
+        //   num: 'AW-YS-ZF-2018-005',
+        //   money: 200,
+        //   way: '银行转账',
+        // },
       ],
       total: 0,
       opera: [{ label: '查看', method: 'see' }],
       //客户列表
-      nameList: [{ name: '客户一' }, { name: '客户二' }],
+      nameList: [],
       //合同列表
       contractList: [{ name: '合同一' }, { name: '合同二' }],
       //项目列表
@@ -182,161 +168,173 @@ export default {
       //付费方式列表
       wayList: [{ name: '方式一' }, { name: '方式二' }],
       detailFields: [
-        { label: '货物', model: 'goods' },
+        { label: '货物名', model: 'name' },
         { label: '数量', model: 'number' },
         { label: '重量(t)', model: 'weight' },
         { label: '体积(m²)', model: 'volume' },
-        { label: '流水账号', model: 'current', notable: 'true' },
-        { label: '订单号', model: 'ordernumber', notable: 'true' },
+        { label: '备注', model: 'remark' },
       ],
       detailList: [
-        {
-          goods: '真皮',
-          number: '3',
-          weight: '40',
-          volume: '50',
-          current: '0000',
-          ordernumber: '9999',
-        },
+        // {
+        //   goods: '真皮',
+        //   number: '3',
+        //   weight: '40',
+        //   volume: '50',
+        //   current: '0000',
+        //   ordernumber: '9999',
+        // },
       ],
       editableTabsValue: '1',
       editableTabs: [],
       tabIndex: 1,
       //支出项列表
-      costList: [{ name: '罚款' }, { name: '过桥费' }, { name: '油费' }, { name: '长途运费' }],
+      costList: [],
       //供应商列表
       supplierList: [{ name: '供应商一' }, { name: '供应商二' }],
       //车辆列表
       carList: [{ name: '车辆一' }, { name: '车辆二' }],
       //税率列表
-      rateList: [{ name: '1' }, { name: '1.003' }, { name: '1.05' }, { name: '1.06' }, { name: '1.09' }, { name: '1.1' }, { name: '1.13' }],
+      rateList: [],
       cost1: 0,
       cost2: 0,
       cost3: 0,
       cost4: 0,
+      detailForm: {},
     };
   },
-  created() {},
+  created() {
+    this.search();
+  },
   methods: {
-    async search() {
-      console.log('查询');
+    ...order(['query', 'create', 'update', 'delete', 'fetch']),
+    ...client({ clientQuery: 'query' }),
+    ...dictionary(['tree']),
+
+    async search({ skip = 0, limit = 8, ...info } = {}) {
+      //查订单
+      const res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        const { data, total } = res;
+        this.$set(this, `list`, data);
+        this.$set(this, `total`, total);
+      }
+      //查客户列表
+      const res1 = await this.clientQuery({ type: '客户' });
+      if (this.$checkRes(res1)) {
+        const { data, total } = res1;
+        this.$set(this, `nameList`, data);
+      }
+      //查询其他收费项
+      const res2 = await this.tree('sr');
+      if (res2) {
+        this.$set(this, `costList`, res2[0].children);
+      }
+      //查其他收费项的税率
+      const res3 = await this.tree('sl');
+      if (res3) {
+        this.$set(this, `rateList`, res3[0].children);
+      }
     },
     //查看
-    see() {
-      console.log('查看');
+    async see({ data }) {
+      const res = await this.fetch(data.id);
+      if (res) this.$set(this, `detailForm`, res);
       this.dialog = true;
     },
     //添加选项卡
     addTab(value) {
+      console.log(value);
       if (this.editableTabsValue == '0') {
         this.editableTabsValue = '1';
       }
-      this.editableTabs.push({ rate: '1' });
+      // this.detailForm.out_bill.push({ taxes: '1', item: '保费' });
+      //????总是显示最后一个
+      this.detailForm.out_bill.push({ taxes: 1, item: '保費' });
     },
     //删除选项卡
     removeTab(targetName) {
+      console.log(targetName);
       const name1 = Number(targetName);
-      const form1 = this.editableTabs[name1 - 1];
-      if (form1.cost1 || form1.cost3) {
-        this.cost1 -= Number(form1.cost1);
-        this.cost2 -= Number(form1.cost2);
-        this.cost3 -= Number(form1.cost3);
-        this.cost4 -= Number(form1.cost4);
-      }
+      const form1 = this.detailForm.out_bill[name1 - 1];
       if (name1 > -1) {
-        this.editableTabs.splice(name1 - 1, 1);
+        this.detailForm.out_bill.splice(name1 - 1, 1);
       }
       this.editableTabsValue = String(name1 - 1);
+      this.computRate();
     },
     //选择税率
     selectChange(val, index) {
-      const form = this.editableTabs[index];
-      if ((form.rate && form.cost1) || (form.rate && form.cost3)) {
-        const result = _.round(form.rate * form.cost1, 2);
-        console.log(result);
-        this.$set(form, `cost2`, result);
-        const result1 = _.round(form.rate * form.cost3, 2);
-        this.$set(form, `cost4`, result1);
-        if (this.editableTabs[index - 1]) {
-          this.cost2 = Number(this.editableTabs[index - 1].cost2) + form.cost2;
-          this.cost4 = Number(this.editableTabs[index - 1].cost4) + form.cost4;
-        } else {
-          this.cost2 = Number(form.cost2);
-          this.cost4 = Number(form.cost4);
-        }
-      }
+      const outList = this.detailForm.out_bill;
+      let outForm = outList[index];
+      let sh_ys = _.round(Number(val * outForm.sq_ys), 2);
+      let sh_ss = _.round(Number(val * outForm.sq_ss), 2);
+      this.$set(outForm, `sh_ys`, sh_ys);
+      this.$set(outForm, `sh_ss`, sh_ss);
+      this.computRate();
     },
     //税前应收
     change(index) {
-      const form = this.editableTabs[index];
-      if (form.rate && form.cost1) {
-        const result = _.round(form.rate * form.cost1, 2);
-        this.$set(form, `cost2`, result);
-        this.$set(form, `cost3`, form.cost1);
-        this.$set(form, `cost4`, result);
-        let num1 = 0;
-        let num2 = 0;
-        let num3 = 0;
-        let num4 = 0;
-        for (let item of this.editableTabs) {
-          if (item.cost1) {
-            num1 = _.round(num1 + Number(item.cost1), 2);
-            num2 = _.round(num2 + Number(item.cost2), 2);
-            num3 = _.round(num3 + Number(item.cost3), 2);
-            num4 = _.round(num4 + Number(item.cost4), 2);
-          } else {
-          }
-        }
-        this.cost1 = num1;
-        this.cost2 = num2;
-        this.cost3 = num3;
-        this.cost4 = num4;
+      const outList = this.detailForm.out_bill;
+      let outForm = outList[index];
+      console.log(outForm);
+      let sh_ys = _.round(outForm.sq_ys * outForm.taxes, 2);
+      this.$set(outForm, `sh_ys`, sh_ys);
+      let sq_ss = _.round(outForm.sq_ys, 2);
+      this.$set(outForm, `sq_ss`, sq_ss);
+      let sh_ss = _.round(outForm.sq_ss * outForm.taxes, 2);
+      this.$set(outForm, `sh_ss`, sh_ss);
+      this.computRate();
+    },
+    async computRate() {
+      let num1 = 0;
+      let num2 = 0;
+      let num3 = 0;
+      let num4 = 0;
+      const outList = this.detailForm.out_bill;
+      for (let row1 of outList) {
+        num1 = _.round(num1 + Number(row1.sq_ys), 2);
+        num2 = _.round(num2 + row1.sh_ys, 2);
+        num3 = _.round(num3 + Number(row1.sq_ss), 2);
+        num4 = _.round(num4 + row1.sh_ss, 2);
       }
+      this.$set(this, `cost1`, num1);
+      this.$set(this, `cost2`, num2);
+      this.$set(this, `cost3`, num3);
+      this.$set(this, `cost4`, num4);
     },
     //税前实收
     toChange(index) {
-      const form = this.editableTabs[index];
-      if (form.rate && form.cost3) {
-        const result = parseFloat(form.rate * form.cost3).toFixed(2);
-        this.$set(form, `cost4`, result);
-        let num1 = 0;
-        let num2 = 0;
-        let num3 = 0;
-        let num4 = 0;
-        for (let item of this.editableTabs) {
-          num1 = _.round(num1 + Number(item.cost1), 2);
-          num2 = _.round(num2 + Number(item.cost2), 2);
-          num3 = _.round(num3 + Number(item.cost3), 2);
-          num4 = _.round(num4 + Number(item.cost4), 2);
-        }
-        this.cost1 = num1;
-        this.cost2 = num2;
-        this.cost3 = num3;
-        this.cost4 = num4;
-      }
-      // this.cost3 += Number(form.cost3);
-      // this.cost4 += Number(form.cost4);
+      const outList = this.detailForm.out_bill;
+      let outForm = outList[index];
+      let sh_ss = _.round(Number(outForm.sq_ss) * outForm.taxes, 2);
+      this.$set(outForm, `sh_ss`, sh_ss);
+      this.computRate();
     },
     //保存
-    save(data) {
-      // data.forEach(item => {
-      //   this.cost1 += Number(item.cost1);
-      //   console.log(this.cost1);
-      //   this.cost2 += Number(item.cost2);
-      //   this.cost3 += Number(item.cost3);
-      //   this.cost4 += Number(item.cost4);
-      // });
-      // this.back();
+    async save(data) {
+      console.log(data);
+      //owner不能为空????
+      let owner = this.user.id;
+      const res = await this.update(data);
+      if (this.$checkRes(res, '修改成功', res.errmsg || '修改失败')) {
+        this.back();
+      }
     },
     //返回
     back() {
       this.dialog = false;
-      this.editableTabs = [];
+      this.detailForm.out_bill = [];
       this.cost1 = 0;
       this.cost2 = 0;
       this.cost3 = 0;
       this.cost4 = 0;
     },
+    roleSelect({ model, value }) {
+      if (model == 'client') {
+        let arr = this.nameList.find(i => i.id === value);
+        if (arr) return arr.name;
+      }
+    },
   },
   computed: {
     ...mapState(['user']),

+ 3 - 3
src/views/order/transport/sign.vue

@@ -99,13 +99,13 @@ export default {
     };
   },
   async created() {
-    await this.search();
+    // await this.search();
   },
   methods: {
     // ...order(['query', 'create', 'update', 'delete']),
     async search({ skip = 0, limit = 10, ...info } = {}) {
-      const res = await this.query({ skip, limit, ...info });
-      console.log(res);
+      // const res = await this.query({ skip, limit, ...info });
+      // console.log(res);
     },
     //关闭
     toClose() {