Sfoglia il codice sorgente

供货商 ghs 花材管理 明细那边,需要支持批量修改成本价 加价 和排序 (解决)

wangn 5 anni fa
parent
commit
69f953ab59
2 ha cambiato i file con 69 aggiunte e 22 eliminazioni
  1. 14 1
      ghs/src/service/product/index.js
  2. 55 21
      ghs/src/views/item/list.vue

+ 14 - 1
ghs/src/service/product/index.js

@@ -3,5 +3,18 @@ import { BaseService, Service } from '@/cool';
 @Service('product')
 @Service('product')
 export class ProductService extends BaseService {
 export class ProductService extends BaseService {
 
 
+/** *
+ * 批量修改product信息
+ */
+ productBatchUpdate(data) {
+  return this.request({
+    url: '/batch-update',
+    method: 'POST',
+    data: data
+  });
+  }
+  
 }
 }
-export default new ProductService();
+  
+export default new ProductService();
+

+ 55 - 21
ghs/src/views/item/list.vue

@@ -28,10 +28,10 @@
         <span>{{ scope.row.bigUnit }} / {{scope.row.smallUnit}}</span>
         <span>{{ scope.row.bigUnit }} / {{scope.row.smallUnit}}</span>
       </template>
       </template>
 
 
-
+      
       <template #table-column-inTurn="{scope}">
       <template #table-column-inTurn="{scope}">
         <span v-if="!sort.status">{{ scope.row.inTurn }}</span>
         <span v-if="!sort.status">{{ scope.row.inTurn }}</span>
-        <el-input style="width:50%;" ref="sort-input" focus size="mini" v-else v-model="scope.row.inTurn" @blur="changeSort(scope.row)" ></el-input>
+        <el-input style="width:50%;" ref="sort-input" focus size="mini" v-else v-model="scope.row.inTurn" @blur="changeSort(scope.row, 'inTurn')" ></el-input>
       </template>
       </template>
 
 
       <template #table-header-inTurn>
       <template #table-header-inTurn>
@@ -45,18 +45,30 @@
 
 
       <template #table-column-addPrice="{scope}">
       <template #table-column-addPrice="{scope}">
         <span v-if="!canAddPrice">{{ scope.row.addPrice }}</span>
         <span v-if="!canAddPrice">{{ scope.row.addPrice }}</span>
-        <el-input style="width:50%;" ref="add-price-input" focus size="mini" v-else v-model="scope.row.inTurn"></el-input>
+        <el-input style="width:50%;" ref="add-price-input" focus size="mini" v-else v-model="scope.row.addPrice" @blur="changeSort(scope.row, 'addPrice')" ></el-input>
       </template>
       </template>
 
 
       <template #table-header-addPrice>
       <template #table-header-addPrice>
         <div class="set-sort">
         <div class="set-sort">
           <span>每扎加价</span>
           <span>每扎加价</span>
           <el-button v-if="!canAddPrice" icon="el-icon-edit-outline" size="small" type="text" @click="showAddPrice" class="show"></el-button>
           <el-button v-if="!canAddPrice" icon="el-icon-edit-outline" size="small" type="text" @click="showAddPrice" class="show"></el-button>
-          <el-button class="hide" v-else size="mini" @click="hideAddPrice" type="primary">完成</el-button>
+          <el-button class="hide" v-else size="mini" @click="hideSort" type="primary">完成</el-button>
         </div>
         </div>
       </template>
       </template>
 
 
+      <template #table-header-cost>
+        <div class="set-sort">
+          <span>每扎成本价</span>
+          <el-button v-if="!costPrice" icon="el-icon-edit-outline" size="small" type="text" @click="showCost" class="show"></el-button>
+          <el-button class="hide" v-else size="mini" @click="hideSort" type="primary">完成</el-button>
+        </div>
+      </template>
 
 
+
+      <template #table-column-cost="{scope}">
+        <span v-if="!costPrice">{{ scope.row.cost }}</span>
+        <el-input style="width:50%;" ref="sort-input" focus size="mini" v-else v-model="scope.row.cost" @blur="changeSort(scope.row, 'cost')" ></el-input>
+      </template>
       <template #slot-add-goods-btn>
       <template #slot-add-goods-btn>
         <el-button type="primary" size="mini" @click="addFn()">添加</el-button>
         <el-button type="primary" size="mini" @click="addFn()">添加</el-button>
       </template>
       </template>
@@ -92,14 +104,30 @@ export default {
         status: false
         status: false
       },
       },
       canAddPrice:false,
       canAddPrice:false,
+      costPrice: false,
       classId: 0,
       classId: 0,
       className:'',
       className:'',
       showItemModal: false,
       showItemModal: false,
+      dataList: {
+        form: {
+          data: '',
+          type: ''
+        }
+        
+      },
+      initData: []
     };
     };
   },
   },
   computed: {
   computed: {
   },
   },
   methods: {
   methods: {
+    showCost() {
+      this.initData = []
+      this.costPrice = true
+    },
+    hideCost() {
+      this.costPrice = false
+    },
     selectItemFn (currentItem) {
     selectItemFn (currentItem) {
 
 
       let item = currentItem.list
       let item = currentItem.list
@@ -180,7 +208,7 @@ export default {
               prop: 'cost',
               prop: 'cost',
               label: '每扎成本价',
               label: '每扎成本价',
               align: 'center',
               align: 'center',
-              'min-width': 90
+              'min-width': 120
             },
             },
             {
             {
               prop: 'addPrice',
               prop: 'addPrice',
@@ -254,32 +282,38 @@ export default {
       this.app.refresh(params);
       this.app.refresh(params);
     },
     },
     showAddPrice(){
     showAddPrice(){
+      this.initData = []
        this.canAddPrice = true
        this.canAddPrice = true
     },
     },
-    hideAddPrice(){
-      this.canAddPrice = false
-    },
     showSort (e) {
     showSort (e) {
+      this.initData = []
       this.sort.status = true;
       this.sort.status = true;
     },
     },
 
 
     hideSort (e) {
     hideSort (e) {
+      this.dataList.form.data = JSON.stringify(this.initData)
+      this.$service.product.productBatchUpdate(this.dataList.form).then(res => {
+        console.log(res)
+        this.$message.success('保存成功!');
+      }).catch(err => {console.log(err)})
       this.sort.status = false;
       this.sort.status = false;
+      this.canAddPrice = false
+      this.costPrice = false
     },
     },
 
 
-    changeSort (d) {
-      this.$service.goods
-        .sort({
-          inTurn: d.inTurn,
-          id: d.id
-        })
-        .then(() => {
-          this.$message.success('修改成功');
-          this.refresh();
-        })
-        .catch(err => {
-          this.$message.error(err);
-        });
+    changeSort (d, type) {
+      this.dataList.form.type = type
+      let obj = {
+        id: d.id,
+      }
+      if(type == 'inTurn') {
+        obj.inTurn = d.inTurn
+      } else if(type == 'addPrice') {
+        obj.addPrice = d.addPrice
+      } else if(type == 'cost') {
+        obj.cost  = d.cost 
+      }
+      this.initData.push(obj)
     }
     }
   }
   }
 };
 };