shish 5 жил өмнө
parent
commit
a8bea43692

+ 3 - 1
ghs/src/cool/request/index.js

@@ -32,6 +32,7 @@ import unit from '@/service/unit/index';
 import ptItem from '@/service/pt-item/index';
 import custom from '@/service/custom/index';
 import product from '@/service/product/index';
+import ptItemClass from '@/service/pt-item-class/index';
 
 export function SET_SERVICE({ store }) {
 	// const files = require.context('@/service/', true, /\.js$/);
@@ -69,7 +70,8 @@ export function SET_SERVICE({ store }) {
 		unit,
 		ptItem,
 		custom,
-		product
+		product,
+		ptItemClass
 	};
 
 	Vue.prototype.$service = modules;

+ 9 - 0
ghs/src/service/item-class/index.js

@@ -29,5 +29,14 @@ export class ItemClassService extends BaseService {
 			params: data
 		});
 	}
+
+	changeInTurn(data) {
+		return this.request({
+			url: '/change-in-turn',
+            method: 'POST',
+            data: data
+		});
+	}
+
 }
 export default new ItemClassService();

+ 7 - 0
ghs/src/service/pt-item-class/index.js

@@ -0,0 +1,7 @@
+import { BaseService, Service } from '@/cool';
+
+@Service('pt-item-class')
+export class PtItemClassService extends BaseService {
+
+}
+export default new PtItemClassService();

+ 19 - 33
ghs/src/views/item-class/list.vue

@@ -19,9 +19,7 @@
 			</template>
 
 			<template #table-column-num="{scope}">
-				<el-link
-					@click="getItemList(scope.row)"
-				>{{ scope.row.num }}</el-link>
+				{{ scope.row.num }}
 			</template>
 
 			<template #table-column-name="{scope}">
@@ -34,7 +32,6 @@
 				<span v-if="!sort.status">{{ scope.row.inTurn }}</span>
 				<el-input
 					ref="sort-input"
-					focus
 					size="mini"
 					v-else
 					v-model="scope.row.inTurn"
@@ -51,11 +48,11 @@
 						icon="el-icon-edit-outline"
 						size="small"
 						type="text"
-						@click="showSort"
+						@click="showSortInput"
 						class="show"
 					></el-button>
 
-					<el-button class="hide" v-else size="mini" @click="hideSort" type="primary"
+					<el-button class="hide" v-else size="mini" @click="commitSort()" type="primary"
 						>完成</el-button
 					>
 				</div>
@@ -129,6 +126,7 @@ export default {
 			ruleForm: {
 				name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
 			},
+			initData: [],
 		};
 	},
 	computed: {
@@ -230,11 +228,7 @@ export default {
 						}
 					],
 
-					on: {
-						'row-click': (row, column) => {
-							this.getItemList(row)
-						}
-					},
+					on: {},
 
 					op: {
 						visible: true,
@@ -247,8 +241,6 @@ export default {
 						layout: ['slot-item-list','slot-modify']
 					}
 
-
-
 				})
 				.set('dict', {
 					search: {
@@ -274,32 +266,26 @@ export default {
 				.done();
 			app.refresh({ status: this.tabIndex });
 		},
-
 		refresh(params) {
 			this.app.refresh(params);
 		},
-
-		showSort(e) {
+		showSortInput(e) {
 			this.sort.status = true;
 		},
-
-		hideSort(e) {
-			this.sort.status = false;
+		commitSort () {
+			let that = this
+			this.$service.itemClass.changeInTurn({sortData:JSON.stringify(this.initData)}).then(res => {
+				that.$message.success('保存成功!')
+				that.sort.status = false
+				that.refresh({status:this.tabIndex});
+			}).catch(err => {console.log(err)})
 		},
-
-		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) {
+			let obj = {
+				id: d.id,
+			}
+			obj.inTurn = d.inTurn
+			this.initData.push(obj)
 		}
 	}
 };

+ 34 - 39
ghs/src/views/item/list.vue

@@ -28,14 +28,14 @@
       
       <template #table-column-inTurn="{scope}">
         <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, 'inTurn')" ></el-input>
+        <el-input style="width:50%;" ref="sort-input" focus size="mini" v-else v-model="scope.row.inTurn" @blur="changeValue(scope.row, 'inTurn')" ></el-input>
       </template>
 
       <template #table-header-inTurn>
         <div class="set-sort">
           <span>排序</span>
           <el-button v-if="!sort.status" icon="el-icon-edit-outline" size="small" type="text" @click="showSort" class="show"></el-button>
-          <el-button class="hide" v-else size="mini" @click="hideSort('inTurn')" type="primary">完成</el-button>
+          <el-button class="hide" v-else size="mini" @click="commitChange('inTurn')" type="primary">完成</el-button>
         </div>
       </template>
 
@@ -49,48 +49,48 @@
 			<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('cost')" type="primary">完成</el-button>
+				<el-button class="hide" v-else size="mini" @click="commitChange('cost')" 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>
+			<el-input style="width:50%;" ref="sort-input" focus size="mini" v-else v-model="scope.row.cost" @blur="changeValue(scope.row, 'cost')" ></el-input>
 		</template>
 		<template #table-header-addPrice="{scope}">
 			<div class="set-sort">
 				<span>每扎加价</span>
 				<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-if="canAddPrice"  size="mini" @click="changeAllSort(scope)" type="primary">批</el-button>
-				<el-button class="hide" v-if="canAddPrice"  size="mini" @click="hideSort('addPrice')" type="primary">完成</el-button>
+				<el-button class="hide" v-if="canAddPrice"  size="mini" @click="commitChange('addPrice')" type="primary">完成</el-button>
 			</div>
 		</template>
       	<template #table-column-addPrice="{scope}">
         <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.addPrice" @blur="changeSort(scope.row, 'addPrice')" ></el-input>
+        <el-input style="width:50%;" ref="add-price-input" focus size="mini" v-else v-model="scope.row.addPrice" @blur="changeValue(scope.row, 'addPrice')" ></el-input>
       </template>
 
 		<template #table-header-ratio="{scope}">
 			<div class="set-sort">
 				<span>单位比</span>
 				<el-button v-if="!canAddRatio" icon="el-icon-edit-outline" size="small" type="text" @click="showAddRatio" class="show"></el-button>
-				<el-button class="hide" v-if="canAddRatio"  size="mini" @click="hideSort('ratio')" type="primary">完成</el-button>
+				<el-button class="hide" v-if="canAddRatio"  size="mini" @click="commitChange('ratio')" type="primary">完成</el-button>
 			</div>
 		</template>
       	<template #table-column-ratio="{scope}">
         <span v-if="!canAddRatio">{{ scope.row.ratio }}</span>
-        <el-input style="width:50%;" ref="add-price-input" focus size="mini" v-else v-model="scope.row.ratio" @blur="changeSort(scope.row, 'ratio')" ></el-input>
+        <el-input style="width:50%;" ref="add-price-input" focus size="mini" v-else v-model="scope.row.ratio" @blur="changeValue(scope.row, 'ratio')" ></el-input>
       </template>
 
 	  	<template #table-header-weight>
 		<div class="set-sort">
 			<span>重量(公斤)</span>
 			<el-button v-if="!costWeight" icon="el-icon-edit-outline" size="small" type="text" @click="showWeight" class="show"></el-button>
-			<el-button class="hide" v-else size="mini" @click="hideSort('weight')" type="primary">完成</el-button>
+			<el-button class="hide" v-else size="mini" @click="commitChange('weight')" type="primary">完成</el-button>
 		</div>
 	  </template>
 		<template #table-column-weight="{scope}">
 			<span v-if="!costWeight">{{ scope.row.weight }}</span>
-			<el-input style="width:50%;" ref="add-price-input" focus size="mini" v-else v-model="scope.row.weight" @blur="changeSort(scope.row, 'weight')"></el-input>
+			<el-input style="width:50%;" ref="add-price-input" focus size="mini" v-else v-model="scope.row.weight" @blur="changeValue(scope.row, 'weight')"></el-input>
 		</template>
 		<template #table-column-delStatus="{scope}">
 			<span>{{ scope.row.delStatus==0?'上架':'下架' }}</span>
@@ -621,7 +621,7 @@ export default {
 		this.costWeight = false;
     },
 
-    hideSort (type) {
+    commitChange (type) {
       if(this.$util.isEmpty(this.initData)){
       	switch (type) {
 			case 'inTurn':
@@ -646,6 +646,7 @@ export default {
       this.$service.product.productBatchUpdate(this.dataList.form).then(res => {
         console.log(res)
         this.$message.success('保存成功!');
+		this.app.refresh()
       }).catch(err => {console.log(err)})
 		switch (type) {
 			case 'inTurn':
@@ -754,48 +755,42 @@ export default {
 				ele.addPrice = batchAddPrice
 				this.initData.push({id:ele.id,addPrice:ele.addPrice})
 			})
-
-
-		  this.dialogFormVisible = false;
-		  //   data[0].cost = 999
+		  	this.dialogFormVisible = false;
 	  },
 	  //批量改价
 	  batchAlterFun(){
 		  if(this.batchAlter=='') return;
 		  this.dataList.form.type = 'addPrice'
-		  // batchAlter
 		  let data = this.$refs['xCrud'].table.data;
 		  data.forEach((ele)=>{
 			  ele.addPrice = this.batchAlter
 			  this.initData.push({id:ele.id,addPrice:this.batchAlter})
 		  })
 		  this.dialogFormVisible = false
-		  // console.log(this.$refs['xCrud'].table.data,'1111');
 	  },
 	  changeAllSort(e){
-		  this.batchAlter='';
-		  this.batchAddPrice='';
-    	this.dialogFormVisible = true;
-
+		this.batchAlter='';
+		this.batchAddPrice='';
+		this.dialogFormVisible = true;
 	  },
-    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 
-      }else if(type == 'weight') {
-        obj.weight  = d.weight
-      }else if(type == 'ratio') {
-        obj.ratio  = d.ratio
-      }
-      this.initData.push(obj)
-    }
+	changeValue (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 
+		}else if(type == 'weight') {
+			obj.weight  = d.weight
+		}else if(type == 'ratio') {
+			obj.ratio  = d.ratio
+		}
+		this.initData.push(obj)
+	}
   }
 };
 </script>