shish 2 лет назад
Родитель
Сommit
fb707e5f98

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

@@ -2,5 +2,12 @@ import { BaseService, Service } from '@/cool';
 @Service('item-cat')
 export class ItemCatService extends BaseService {
 
+	getAllCat(data) {
+		return this.request({
+			url: '/get-all-cat',
+			params: data
+		});
+	}
+
 }
 export default new ItemCatService();

+ 34 - 29
pt/src/views/item-cat-relate/list.vue

@@ -1,6 +1,7 @@
 <template>
 	<div class="app-list-content">
 		<x-crud class="liu-crud-wrap" @load="onLoad">
+
 			<template #slot-tabs>
 				<el-tabs class="liu-tabs" type="border-card" v-model="tabIndex">
 					<el-tab-pane v-for="(item, index) in tabsData" :key="index" :label="item.text" :name="item.key" >
@@ -24,7 +25,7 @@
 				<span v-if="!sort.status">{{ scope.row.inTurn }}</span>
 				<el-input ref="sort-input" focus size="mini" v-else v-model="scope.row.inTurn" @blur="changeSort(scope.row)" ></el-input>
 			</template>
-			<!-- 排序 -->
+
 			<template #table-header-inTurn>
 				<div class="set-sort">
 					<span>排序</span>
@@ -34,7 +35,6 @@
 				</div>
 			</template>
 
-			<!-- 操作 -->
 			<template #slot-column-option="{scope}">
 					<template>
 						<el-popover placement="top" width="160" :ref="'popover-' + scope.row.id">
@@ -43,11 +43,17 @@
 								<el-button size="mini" type="text" @click="cancelDel(scope.row.id)">取消</el-button>
 								<el-button type="primary" size="mini" @click="confirmDel(scope.row)">确定</el-button>
 							</div>
-							<el-button type="text" size="small" slot="reference">删除</el-button>
+							<el-button type="text" size="small" slot="reference">删除建议</el-button>
 						</el-popover>
 					</template>
 			</template>
 
+			<template #slot-cp-class="{scope}">
+				<el-select size="mini" v-model="currentClassName" placeholder="请选分类" style="width:150px;margin-right:10px;" @change="getClass" clearable>
+					<el-option v-for="item in classData" :key="item.value" :label="item.name" :value="item.id"> </el-option>
+				</el-select>				
+			</template>
+
 		</x-crud>
 	</div>
 </template>
@@ -72,35 +78,41 @@ export default {
 			sort: {
 				status: false,
 			},
-			catId: '',
 			addDialog: false,
 			itemClassList: [],
 			unitList: [],
-			currentItemId: 0
+			currentItemId: 0,
+			currentClassName:'',
+			classData:[],
+			currentClassId:''
 		};
 	},
 	computed: {},
 	methods: {
-    	//取消删除
+		getClass(e){
+			this.currentClassId = e
+			this.app.refresh({ catId: this.currentClassId })
+		},
 		cancelDel(id) {
 			this.$refs[`popover-` + id].doClose();
 		},
-    	// 确定删除
 		confirmDel(item) {
 			this.$service.itemCatRelate.delRelate({ itemId: item.id }).then(res => {
 				this.$message.success('删除成功');
 				this.$refs[`popover-` + item.id].doClose();
-				this.app.refresh()
-			});
+				this.app.refresh({ catId: this.currentClassId })
+			})
+		},
+		getAllCatetory(){
+			this.$service.itemCat.getAllCat().then(res=>{
+				this.classData = res.list ? res.list : []
+			})
 		},
 		onLoad({ ctx, app }) {
 			this.app = app;
 			if (this.$route.query.catId) {
-				this.catId = this.$route.query.catId;
-				if (this.$route.query.name != '') {
-					this.tabsData[0].text = this.$route.query.tabName;
-					this.$forceUpdate();
-				}
+				this.currentClassId = this.$route.query.catId;
+				this.currentClassName = this.$route.query.catName ? this.$route.query.catName : ''
 			}
 			ctx.service(this.$service.itemCatRelate)
 				.set('table', {
@@ -165,22 +177,19 @@ export default {
 					},
 				})
 				.set('pagination', {
-					size: 50
+					size:20
 				})
 				.set('layout', [
 					['slot-tabs'],
-					['flex1', 'refresh-btn'],
+					['slot-cp-class','flex1', 'refresh-btn'],
 					['data-table'],
 					['flex1', 'pagination'],
 				])
 				.done();
-				app.refresh({ catId: this.catId });
-		},
+				app.refresh({ catId: this.currentClassId });
 
-		refresh(params) {
-			this.app.refresh(params);
+				this.getAllCatetory()
 		},
-
 		showSort(e) {
 			this.sort.status = true;
 		},
@@ -189,14 +198,10 @@ export default {
 			this.sort.status = 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)
-				});
+			this.$service.goods .sort({ inTurn: d.inTurn, id: d.id, }).then(() => {
+				this.$message.success('修改成功')
+				this.app.refresh({catId: this.currentClassId})
+			})
 		}
 	},
 };

+ 2 - 2
pt/src/views/item-cat/list.vue

@@ -75,7 +75,7 @@ export default {
 		getItemList(data) {
 			let query = {};
 			query.catId = data.id
-			query.tabName = data.name
+			query.catName = data.name
 			this.$router.push({ path: '/item-cat-relate/list', query });
 		},
 		onLoad({ ctx, app }) {
@@ -140,7 +140,7 @@ export default {
 					}
 				})
 				.set('pagination', {
-					size: 100
+					size:50
 				})
 				.set('layout', [
 					['slot-tabs'],