wxy 4 年之前
父节点
当前提交
3e6d555420

+ 3 - 0
src/store/index.js

@@ -23,6 +23,8 @@ import split from '@f/store/order/split';
 import inBill from '@f/store/order/inBill';
 //支出
 import outBill from '@f/store/order/outBill';
+//订单负责人
+import orderPri from '@f/store/order/orderPri';
 
 import car from '@f/store/car/car';
 import daily from '@f/store/car/daily';
@@ -61,5 +63,6 @@ export default new Vuex.Store({
     split,
     inBill,
     outBill,
+    orderPri,
   },
 });

+ 67 - 32
src/views/order/goods.vue

@@ -3,7 +3,14 @@
     <el-row>
       <el-col :span="24" class="container">
         <el-col :span="24" class="search">
-          <search-bar :nameList="nameList"></search-bar>
+          <el-row type="flex">
+            <el-col :span="20">
+              <search-bar v-model="sform" :clientList="clientList" :userList="userList"></search-bar>
+            </el-col>
+            <el-col :span="2">
+              <el-button type="primary" @click="search">查询</el-button>
+            </el-col>
+          </el-row>
         </el-col>
         <el-col :span="24" class="info">
           <el-row :gutter="20">
@@ -16,7 +23,8 @@
                   </el-row>
                 </div>
                 <!-- <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 :data="item.split" style="width: 100%" @row-click="clickTable(index)"> -->
+                <el-table :data="item.split" style="width: 100%" height="200px">
                   <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>
@@ -24,7 +32,7 @@
                   <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>
+                      <el-button size="mini" @click="splice(index, scope.row, scope.$index)">拆分</el-button>
                     </template>
                   </el-table-column>
                 </el-table>
@@ -113,7 +121,7 @@
         </el-table-column>
       </el-table>
       <span slot="footer" class="dialog-footer">
-        <el-button type="primary" @click="add(splitList)">拆分订单</el-button>
+        <el-button type="primary" @click="add(splitList, orderForm)">拆分订单</el-button>
       </span>
     </el-dialog>
   </div>
@@ -122,6 +130,9 @@
 <script>
 const { mapActions: client } = createNamespacedHelpers('client');
 const { mapActions: order } = createNamespacedHelpers('order');
+const { mapActions: user } = createNamespacedHelpers('user');
+const { mapActions: split } = createNamespacedHelpers('split');
+
 import { mapState, createNamespacedHelpers } from 'vuex';
 import searchBar from './index-parts/search-bar.vue';
 export default {
@@ -154,14 +165,18 @@ export default {
       //项目列表
       projectList: [{ name: '项目一' }, { name: '项目二' }],
       //客戶列表
-      nameList: [],
+      clientList: [],
+      //用户列表
+      userList: [],
+      sform: {},
       // name: [],
-      num: 1,
+      num: 0,
       number: 0,
       max: 0,
       weight: 0,
       volume: 0,
       tableNumber: 0,
+      spiteIndex: 0,
     };
   },
   async created() {
@@ -169,10 +184,20 @@ export default {
   },
   methods: {
     ...client({ clientQuery: 'query' }),
-    ...order(['query', 'create', 'update', 'delete', 'fetch']),
-    async search({ skip = 0, limit = 8, ...info } = {}) {
+    ...order(['query']),
+    ...split({ getSplit: 'split', getQuery: 'query' }),
+    ...user({ getUserList: 'query' }),
+    async search({ skip = 0, limit = 8 } = {}) {
       //查订单
-      const res = await this.query({ skip, limit, ...info });
+      let duplicate = _.cloneDeep(this.sform);
+      let { date, ...info } = duplicate;
+      let querys = { skip, limit, ...info };
+      if (date && date.length === 2) {
+        querys[`rq_send_time@start`] = date[0];
+        querys[`rq_send_time@end`] = date[1];
+      }
+      if (this.user.role !== '0') querys.principal = this.user.id;
+      const res = await this.query(querys);
       if (this.$checkRes(res)) {
         const { data, total } = res;
         this.$set(this, `list`, data);
@@ -182,7 +207,13 @@ export default {
       const res1 = await this.clientQuery({ type: '客户' });
       if (this.$checkRes(res1)) {
         const { data, total } = res1;
-        this.$set(this, `nameList`, data);
+        this.$set(this, `clientList`, data);
+      }
+      //查用户
+      const res2 = await this.getUserList();
+      if (this.$checkRes(res2)) {
+        const { data, total } = res2;
+        this.$set(this, `userList`, data);
       }
     },
     //关闭
@@ -194,17 +225,25 @@ export default {
       console.log(data);
     },
     //卡片上面的拆分
-    splice(index, data) {
-      this.$set(this, `orderForm`, _.cloneDeep(data));
+    splice(tableIndex, data, index) {
+      let newList = this.list[tableIndex].split;
+      this.$set(this, `orderForm`, data);
+      let arr = newList.filter(function(i) {
+        return i.pid === newList[index]._id;
+      });
+      this.num = arr.length;
       this.dialog = true;
       this.number = this.orderForm.number;
       this.weight = this.orderForm.weight;
       this.volume = this.orderForm.volume;
+      this.tableNumber = tableIndex;
+      this.spiteIndex = index;
     },
     //真的拆分订单
     splite() {
       let origin = this.orderForm;
-      this.splitList.push({ type: 1, name: `${this.orderForm.name}-${this.num++}`, number: 0, weight: 0, volume: 0, pid: origin.pid });
+      let n = ++this.num;
+      this.splitList.push({ type: 1, name: `${this.orderForm.name}-${n}`, number: 0, weight: 0, volume: 0, pid: origin._id });
     },
     //数量改变
     changeNumber(index, currentValue, oldValue) {
@@ -285,32 +324,28 @@ export default {
       this.orderForm.volume += this.splitList[index].volume;
       this.splitList.splice(index, 1);
     },
-    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]);
-      for (let item of data) {
-        newList.push(item);
+    //保存拆分订单
+    async add(splitList, orderForm) {
+      // 复制一份数据在orderSplite;
+      let orderSplite = _.cloneDeep(this.list[this.tableNumber].split);
+      // 从orderSplite删除拆分的数据;
+      orderSplite.splice(this.spiteIndex, 1);
+      orderSplite.unshift(orderForm);
+      for (let item of splitList) {
+        orderSplite.push(item);
       }
-      this.$set(this.list[this.tableNumber], `split`, newList);
+      this.$set(this.list[this.tableNumber], `split`, orderSplite);
       let newData = this.list[this.tableNumber];
-      let owner = this.user.id;
-      const res = await this.update(this.list);
+      const res = await this.getSplit(newData);
       if (this.$checkRes(res, '拆分成功', res.errmsg || '拆分失败')) {
         this.search();
-        this.orderForm = {};
+        this.splitList = [];
         this.dialog = false;
       }
     },
-    clickTable(index) {
-      console.log(index);
-      this.tableNumber = index;
+    choose(client) {
+      const obj = this.clientList.find(i => i.id === client);
+      if (obj) return obj.name;
     },
   },
   computed: {

+ 10 - 5
src/views/order/in.vue

@@ -49,6 +49,8 @@ const { mapActions: client } = createNamespacedHelpers('client');
 const { mapActions: order } = createNamespacedHelpers('order');
 const { mapActions: user } = createNamespacedHelpers('user');
 const { mapActions: inBill } = createNamespacedHelpers('inBill');
+const { mapActions: orderPri } = createNamespacedHelpers('orderPri');
+
 import { mapState, createNamespacedHelpers } from 'vuex';
 import inDetail from './inDetail.vue';
 export default {
@@ -111,9 +113,12 @@ export default {
     ...user({ userQuery: 'query' }),
     ...inBill(['inBill']),
     ...order(['query', 'create', 'update', 'delete', 'fetch']),
+    ...orderPri({ oderPri: 'principal' }),
     async search({ skip = 0, limit = 10, ...info } = {}) {
       //查订单
-      const res = await this.query({ skip, limit, ...info });
+      let obj = { skip, limit, ...info };
+      if (this.user.role !== '0') obj.principal = this.user.id;
+      const res = await this.query(obj);
       if (this.$checkRes(res)) {
         const { data, total } = res;
         this.$set(this, `list`, data);
@@ -145,14 +150,14 @@ export default {
     toClose() {
       this.dialog = false;
     },
-    //保存
+    //修改负责人保存
     async turnSave({ data }) {
       if (data) {
-        const res = await this.update(data);
+        const res = await this.oderPri(data);
         if (this.$checkRes(res, '修改成功', res.errmsg || '修改失败')) {
-          this.search();
           this.dialog = false;
         }
+        this.search();
       }
     },
     //修改收入
@@ -165,8 +170,8 @@ export default {
       this.flag = false;
       this.detailForm = {};
     },
+    //详情保存
     async toSave(data) {
-      console.log(data);
       if (data.id) {
         const res = await this.inBill(data);
         console.log(res);

+ 3 - 3
src/views/order/inDetail.vue

@@ -307,13 +307,13 @@ export default {
       //查询其他收费项
       const res = await this.tree('sr');
       if (res) {
-        this.$set(this, `options`, res[0].children);
+        this.$set(this, `options`, res);
         // console.log(this.options);
       }
       //查其他收费项的税率
       const res1 = await this.tree('sl');
       if (res1) {
-        this.$set(this, `rateList`, res1[0].children);
+        this.$set(this, `rateList`, res1);
       }
     },
     handleChange(value) {
@@ -321,7 +321,7 @@ export default {
     },
     //添加收費項目
     addGoods() {
-      this.detailForm.in_bill.push({ taxes: 1, item: '保費' });
+      this.detailForm.in_bill.push({ taxes: 1 });
     },
     //刪除
     handleDelete(index, row) {

+ 15 - 8
src/views/order/index-parts/search-bar.vue

@@ -11,7 +11,7 @@
       </el-form-item>
       <el-form-item>
         <el-select v-model="value.treaty" placeholder="请选择要查询的合同" style="width:200px;padding-right: 5px;" @change="getItem" clearable filterable>
-          <el-option v-for="(i, index) in treatyList" :key="`treaty${index}`" :label="i.name" :value="i.id"></el-option>
+          <el-option v-for="(i, index) in treatyList" :key="`treaty${index}`" :label="i.number" :value="i.id"></el-option>
         </el-select>
       </el-form-item>
       <el-form-item>
@@ -24,11 +24,11 @@
           <el-option v-for="(i, index) in routeList" :key="`route${index}`" :label="i.name" :value="i.id"></el-option>
         </el-select>
       </el-form-item>
-      <el-form-item>
+      <!-- <el-form-item>
         <el-select v-model="value.mode" placeholder="请选择要查询的运输方式" style="width:200px;padding-right: 5px;" clearable filterable>
           <el-option v-for="(i, index) in modeList" :key="`mode${index}`" :label="i.name" :value="i.id"></el-option>
         </el-select>
-      </el-form-item>
+      </el-form-item> -->
       <el-form-item>
         <el-date-picker
           v-model="value.date"
@@ -94,15 +94,18 @@ export default {
       const res = await this.getTreatyList({ client });
       if (this.$checkRes(res)) {
         const { data } = res;
-        this.$set(this, `treatyList`, data);
+        let arr = data.map(item => {
+          return { number: item.number, id: item.id };
+        });
+        this.$set(this, `treatyList`, arr);
       }
     },
     async getItem(treaty) {
       const res = await this.getItemList({ treaty });
-      if (this.$checkRes(res)) {
-        const { data } = res;
-        this.$set(this, `itemList`, data);
-      }
+      // if (this.$checkRes(res)) {
+      //   const { data } = res;
+      //   this.$set(this, `itemList`, data);
+      // }
     },
     async getRoute(item) {
       const res = await this.getItemList({ item });
@@ -122,6 +125,10 @@ export default {
     checkNoUse(model) {
       return !this.nouse.includes(model);
     },
+    choose(client) {
+      const obj = this.clientList.find(i => i.id === client);
+      if (obj) return obj.name;
+    },
   },
   computed: {
     ...mapState(['user']),

+ 18 - 15
src/views/order/out.vue

@@ -63,9 +63,9 @@
                 <el-tabs v-model="editableTabsValue" type="card" closable @tab-remove="removeTab">
                   <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 v-model="item.item" ref="form" label-width="90px" :inline="true">
+                      <el-form ref="form" label-width="90px" :inline="true">
                         <el-form-item label="支出项">
-                          <el-select v-model="item.cost" placeholder="请选择支出项">
+                          <el-select v-model="item.item" placeholder="请选择支出项">
                             <el-option v-for="(item, index) in costList" :key="index" :label="item.label" :value="item.value"></el-option>
                           </el-select>
                         </el-form-item>
@@ -100,7 +100,7 @@
                 </el-tabs>
                 <el-row>
                   <el-col :span="24" style="text-align:center">
-                    <el-button type="primary" size="mini" @click="save(detailForm.out_bill)" style="margin:10px 0px">
+                    <el-button type="primary" size="mini" @click="save(detailForm)" style="margin:10px 0px">
                       保存
                     </el-button>
                   </el-col>
@@ -119,6 +119,7 @@ import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: order } = createNamespacedHelpers('order');
 const { mapActions: client } = createNamespacedHelpers('client');
 const { mapActions: dictionary } = createNamespacedHelpers('dictionary');
+const { mapActions: outBill } = createNamespacedHelpers('outBill');
 
 const _ = require('lodash');
 export default {
@@ -202,17 +203,20 @@ export default {
       detailForm: {},
     };
   },
-  created() {
-    this.search();
+  async created() {
+    await this.search();
   },
   methods: {
     ...order(['query', 'create', 'update', 'delete', 'fetch']),
     ...client({ clientQuery: 'query' }),
     ...dictionary(['tree']),
+    ...outBill(['outBill']),
 
     async search({ skip = 0, limit = 8, ...info } = {}) {
       //查订单
-      const res = await this.query({ skip, limit, ...info });
+      let obj = { skip, limit, ...info };
+      if (this.user.role !== '0') obj.principal = this.user.id;
+      const res = await this.query(obj);
       if (this.$checkRes(res)) {
         const { data, total } = res;
         this.$set(this, `list`, data);
@@ -227,18 +231,21 @@ export default {
       //查询其他收费项
       const res2 = await this.tree('zc');
       if (res2) {
-        this.$set(this, `costList`, res2[0].children);
+        this.$set(this, `costList`, res2);
       }
       //查其他收费项的税率
       const res3 = await this.tree('sl');
       if (res3) {
-        this.$set(this, `rateList`, res3[0].children);
+        this.$set(this, `rateList`, res3);
       }
     },
     //查看
     async see({ data }) {
       const res = await this.fetch(data.id);
       if (res) this.$set(this, `detailForm`, res);
+      if (this.detailForm.out_bill.length > 0) {
+        this.computRate();
+      }
       this.dialog = true;
     },
     //添加选项卡
@@ -247,13 +254,10 @@ export default {
       if (this.editableTabsValue == '0') {
         this.editableTabsValue = '1';
       }
-      // this.detailForm.out_bill.push({ taxes: '1', item: '保费' });
-      //????总是显示最后一个
       this.detailForm.out_bill.push({ taxes: 1 });
     },
     //删除选项卡
     removeTab(targetName) {
-      console.log(targetName);
       const name1 = Number(targetName);
       const form1 = this.detailForm.out_bill[name1 - 1];
       if (name1 > -1) {
@@ -285,6 +289,7 @@ export default {
       this.$set(outForm, `sh_ss`, sh_ss);
       this.computRate();
     },
+    //计算
     async computRate() {
       let num1 = 0;
       let num2 = 0;
@@ -312,10 +317,8 @@ export default {
     },
     //保存
     async save(data) {
-      console.log(data);
-      //owner不能为空????
-      let owner = this.user.id;
-      const res = await this.update(data);
+      // console.log(data);
+      const res = await this.outBill(this.detailForm);
       if (this.$checkRes(res, '修改成功', res.errmsg || '修改失败')) {
         this.back();
       }