lrf402788946 4 years ago
parent
commit
31968a7709

+ 39 - 13
src/views/bill/client.vue

@@ -26,6 +26,15 @@
         </data-table>
       </el-col>
     </el-row>
+
+    <el-dialog title="是否结算" :visible.sync="dialog" :destroy-on-close="true" @close="toClose">
+      <el-row>
+        <el-col :span="24">若要结算,可以填写该结算单的标题及备注,以便以后查看可以快速找到结算单</el-col>
+        <el-col :span="24">
+          <data-form v-model="form" :fields="efields" @save="toJs"></data-form>
+        </el-col>
+      </el-row>
+    </el-dialog>
   </div>
 </template>
 
@@ -43,6 +52,7 @@ export default {
   components: {},
   data: function() {
     return {
+      dialog: false,
       fields: [
         { label: '客户', model: 'client', filter: 'select' },
         { label: '订单号', model: 'order_no', filter: true },
@@ -56,6 +66,12 @@ export default {
       selected: [],
       clientList: [],
       client: undefined, //选择的客户
+
+      form: {},
+      efields: [
+        { label: '标题', model: 'title' },
+        { label: '备注', model: 'remark', type: 'textarea', options: { autosize: { maxRows: 5, minRows: 3 } } },
+      ],
     };
   },
   created() {
@@ -78,20 +94,30 @@ export default {
     async toExport() {
       const ids = this.selected.map(i => i._id);
       const res = await this.export({ ids });
-      if (this.$checkRes(res)) window.open(res);
-      this.$confirm('是否结算选择的订单?', '结算提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning',
-      }).then(async () => {
-        const jsRes = await this.js({ ids, client: this.client, owner: this.user.id });
-        if (this.$checkRes(jsRes, '结算成功', '结算失败')) {
-          this.$refs.table.selectReset();
-          this.list = [];
-          this.selected = [];
-        }
-      });
+      if (this.$checkRes(res)) {
+        window.open(res);
+        this.dialog = true;
+      }
     },
+
+    async toJs() {
+      let dup = _.cloneDeep(this.form);
+      dup.ids = this.selected.map(i => i._id);
+      dup.client = this.client;
+      dup.owner = this.user.id;
+      const jsRes = await this.js(dup);
+      if (this.$checkRes(jsRes, '结算成功', '结算失败')) {
+        this.toClose();
+        this.$refs.table.selectReset();
+        this.list = [];
+        this.selected = [];
+      }
+    },
+    toClose() {
+      this.dialog = false;
+      this.form = {};
+    },
+
     async getOtherList() {
       const cRes = await this.getClientList({ type: '客户' });
       if (this.$checkRes(cRes)) this.$set(this, `clientList`, cRes.data);

+ 8 - 2
src/views/bill/finished/client.vue

@@ -36,7 +36,9 @@ export default {
       ],
       fields: [
         { label: '客户', model: 'client', filter: 'select', format: true, notable: true },
+        { label: '标题', model: 'title', filter: true },
         { label: '创建时间', model: 'create_time', filter: 'date' },
+        { label: '备注', model: 'remark' },
       ],
       list: [],
       total: 0,
@@ -52,13 +54,17 @@ export default {
     ...order(['export']),
     ...client({ getClientList: 'query' }),
     async search(data) {
+      if (!_.get(data, 'client')) {
+        this.$message.error('请选择客户');
+        return;
+      }
       const res = await this.query(data);
       if (this.$checkRes(res)) this.$set(this, `list`, res.data);
     },
     //导出
     async toExport({ data }) {
-      const { ids } = data;
-      const res = await this.export({ ids });
+      const { params } = data;
+      const res = await this.export(params);
       if (this.$checkRes(res)) window.open(res);
     },
     async getOtherList() {

+ 38 - 38
src/views/bill/finished/supplier.vue

@@ -2,23 +2,23 @@
   <div id="supplier">
     <el-row>
       <el-col :span="24" class="info">
-        <data-table :fields="fields" :data="list" :total="total" :size="50" :step="10" @query="search" :opera="opera" @see="toSee" @delete="toDelete">
+        <data-table :fields="fields" :data="list" :opera="opera" :usePage="false" @query="search" @export="toExport">
           <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 v-if="item.model == 'client'">
+              <el-option v-for="(item, index) in clientList" :key="index" :value="item._id" :label="item.name"></el-option>
             </template>
           </template>
         </data-table>
       </el-col>
     </el-row>
-    <el-dialog :visible.sync="dialog" title="供应商结算详情" @close="toClose" width="50%">
-      <data-form v-model="form" :fields="fields"> </data-form>
-    </el-dialog>
   </div>
 </template>
 
 <script>
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: transport } = createNamespacedHelpers('transport');
+const { mapActions: bill } = createNamespacedHelpers('bill');
+const { mapActions: client } = createNamespacedHelpers('client');
 export default {
   metaInfo() {
     return { title: this.$route.meta.title };
@@ -28,48 +28,48 @@ export default {
   components: {},
   data: function() {
     return {
-      dialog: false,
-      fields: [
-        { label: '供应商', model: 'name', filter: 'select' },
-        { label: '银行', model: 'yin' },
-        { label: '卡号', model: 'num' },
-        { label: '支付单位', model: 'price' },
-        { label: '运费合计(不含实收合计税)', model: 'cont' },
-      ],
-      list: [
+      opera: [
         {
-          name: '哈哈哈',
-          num: '1111111111',
+          label: '导出',
+          method: 'export',
         },
       ],
+      fields: [
+        { label: '供应商', model: 'client', filter: 'select', format: true, notable: true },
+        { label: '标题', model: 'title', filter: true },
+        { label: '创建时间', model: 'create_time', filter: 'date' },
+        { label: '备注', model: 'remark' },
+      ],
+      list: [],
       total: 0,
       //用户列表
-      nameList: [{ name: '名字一' }],
-      opera: [
-        { label: '查看', method: 'see' },
-        { label: '删除', method: 'delete' },
-      ],
-      form: {},
+      clientList: [],
     };
   },
-  created() {},
+  created() {
+    this.getOtherList();
+  },
   methods: {
-    async search() {
-      console.log('查询');
-    },
-    //查看
-    toSee({ data }) {
-      console.log(data);
-      this.$set(this, `form`, data);
-      this.dialog = true;
+    ...bill(['query']),
+    ...transport(['supplierExport']),
+    ...client({ getClientList: 'query' }),
+    async search(data) {
+      if (!_.get(data, 'client')) {
+        this.$message.error('请选择客户');
+        return;
+      }
+      const res = await this.query(data);
+      if (this.$checkRes(res)) this.$set(this, `list`, res.data);
     },
-    //删除
-    toDelete() {
-      console.log('删除');
+    //导出
+    async toExport({ data }) {
+      const { params } = data;
+      const res = await this.supplierExport(params);
+      if (this.$checkRes(res)) window.open(res);
     },
-    //关闭
-    toClose() {
-      this.dialog = false;
+    async getOtherList() {
+      const cRes = await this.getClientList({ type: '供应商' });
+      if (this.$checkRes(cRes)) this.$set(this, `clientList`, cRes.data);
     },
   },
   computed: {

+ 80 - 21
src/views/bill/supplier.vue

@@ -13,6 +13,7 @@
           :select="true"
           :usePage="false"
           @handleSelect="toSelect"
+          rowkey="_id"
         >
           <template #options="{item}">
             <template v-if="item.model == 'client'">
@@ -26,6 +27,15 @@
         </data-table>
       </el-col>
     </el-row>
+
+    <el-dialog title="是否结算" :visible.sync="dialog" :destroy-on-close="true" @close="toClose">
+      <el-row>
+        <el-col :span="24">若要结算,可以填写该结算单的标题及备注,以便以后查看可以快速找到结算单</el-col>
+        <el-col :span="24">
+          <data-form v-model="form" :fields="efields" @save="toJs"></data-form>
+        </el-col>
+      </el-row>
+    </el-dialog>
   </div>
 </template>
 
@@ -43,6 +53,7 @@ export default {
   components: {},
   data: function() {
     return {
+      dialog: false,
       fields: [
         { label: '供应商', model: 'client', notable: true, filter: 'select' },
         { label: '第三方车号', model: 'car_no', notable: true, filter: true },
@@ -50,17 +61,30 @@ export default {
         { label: '发货时间', model: 'send_time' },
         { label: '订单号', model: 'order_nos' },
         { label: '线路', model: 'route' },
-        { label: '货物', model: 'goods', format: i => i.map(g => g.name).join(';') },
-        { label: '运费(不含税)', model: 't_sq_ys' },
+        {
+          label: '货物',
+          model: 'goods',
+          format: i => {
+            if (i) return i.map(g => g.name).join(';');
+          },
+        },
+        { label: '费用类型', model: 'cost_item' },
+        { label: '金额(不含税)', model: 'sq_ys' },
         { label: '税率', model: 'taxes' },
-        { label: '运费税后', model: 't_sh_ys' },
+        { label: '税后金额', model: 'sh_ys' },
       ],
       list: [],
       total: 0,
       //选择的数据列表
       selected: [],
       clientList: [],
-      client: undefined, //选择的客户
+      searchData: {},
+
+      form: {},
+      efields: [
+        { label: '标题', model: 'title' },
+        { label: '备注', model: 'remark', type: 'textarea', options: { autosize: { maxRows: 5, minRows: 3 } } },
+      ],
     };
   },
   created() {
@@ -70,33 +94,68 @@ export default {
     ...transport(['supplierCalculate', 'supplierExport', 'js']),
     ...client({ getClientList: 'query' }),
     async search(data) {
-      const { client } = data;
-      this.$set(this, `client`, client);
+      this.$set(this, 'searchData', data);
       const res = await this.supplierCalculate(data);
+      console.log(res);
       if (this.$checkRes(res)) this.$set(this, `list`, res.data);
     },
     //选中的数据
     toSelect(data) {
+      console.log(data);
       this.selected = data;
     },
     //导出
     async toExport() {
-      const ids = this.selected.map(i => i._id);
-      const res = await this.supplierExport({ ids });
-      if (this.$checkRes(res)) window.open(res);
-      this.$confirm('是否结算选择的订单?', '结算提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning',
-      }).then(async () => {
-        const jsRes = await this.js({ ids, client: this.client, owner: this.user.id });
-        if (this.$checkRes(jsRes, '结算成功', '结算失败')) {
-          this.$refs.table.selectReset();
-          this.list = [];
-          this.selected = [];
-        }
-      });
+      // 需要将运费支出与其他支出分到2个字段
+      // ids仍然是运输表的
+      const ids = _.compact(
+        this.selected.map(i => {
+          if (i.supplier) return i._id;
+        })
+      );
+      // 订单支出部分,根据运输方字段是否存在来区分
+      const outOrderIds = _.compact(
+        this.selected.map(i => {
+          if (!i.supplier) return i.order_id;
+        })
+      );
+      // 将客户id/车号也传过去,这里只能有一个,因为查询时限制其只能有一个
+      const obj = _.pickBy(this.searchData, (value, key) => (key === 'client' || key === 'car_no') && value);
+      const res = await this.supplierExport({ ids, outOrderIds, ...obj });
+      if (this.$checkRes(res)) {
+        window.open(res);
+        this.dialog = true;
+      }
+    },
+
+    async toJs() {
+      let dup = _.cloneDeep(this.form);
+      dup.ids = _.compact(
+        this.selected.map(i => {
+          if (i.supplier) return i._id;
+        })
+      );
+      dup.outOrderIds = _.compact(
+        this.selected.map(i => {
+          if (!i.supplier) return i.order_id;
+        })
+      );
+      dup.owner = this.user.id;
+      dup = { ...dup, ..._.pickBy(this.searchData, (value, key) => (key === 'client' || key === 'car_no') && value) };
+      const jsRes = await this.js(dup);
+      if (this.$checkRes(jsRes, '结算成功', '结算失败')) {
+        this.toClose();
+        this.$refs.table.selectReset();
+        this.list = [];
+        this.selected = [];
+      }
+    },
+
+    toClose() {
+      this.dialog = false;
+      this.form = {};
     },
+
     async getOtherList() {
       const cRes = await this.getClientList({ type: '供应商' });
       if (this.$checkRes(cRes)) this.$set(this, `clientList`, cRes.data);