shish 5 лет назад
Родитель
Сommit
9c4fd1ba62

+ 1 - 1
ghsApp/src/admin/home/components/module/operate.vue

@@ -1,7 +1,7 @@
 <template>
 	<div 
 		class="operate-module" 
-		:style="{top: top + 'rpx', right: right + 'rpx'}">
+		:style="{top: top + 'px', right: right + 'rpx'}">
 		<!-- <div class="operate-icon">
 			<i class="iconfont" :class="[ isShow ? 'iconcaozuojihuo' : 'iconcaozuo']"></i>
 		</div>-->

+ 52 - 91
ghsApp/src/admin/itemClass/list.vue

@@ -1,5 +1,5 @@
 <template>
-	<div class="app-content">
+	<div class="app-content" @click="globalClick">
 		<!-- list -->
 		<div class="list-wrap">
 			<block v-if="!$util.isEmpty(list.data)">
@@ -10,12 +10,12 @@
 					</div>
 					<div class="list-det">
 						<div class="app-size-28 app-color-0">{{ item.name || '' }}</div>
-						<div>{{ item.description || '暂无' }}</div>
+						
 						<div class="list-operate">
 							<div class="operate-det">
-								<span>商品数: {{ item.num }}</span>
+								<span>花材数:{{ item.num }}</span>
 							</div>
-							<div class="operate-icon-wrap" @click="operateFn(item, index)">
+							<div class="operate-icon-wrap" @click.stop="operateFn(item, index, $event)">
 								<div class="operate-icon">
 									<i class="iconfont" :class="[ index == operateIndex ? 'iconcaozuojihuo' : 'iconcaozuo']" style="font-size:38rpx;"></i>
 								</div>
@@ -40,39 +40,26 @@
 			<button class="admin-button-com middle blue" @click="addCategoryFn">添加分类</button>
 		</div>
 		<!-- modify -->
-		<modal-module :show="modifyModal" :maskClosable="false" @cancel="modalCancel" @click="modifyModalClick" width="92%" :title="modifyTitle" padding="30rpx 30rpx">
+		<modal-module :show="modifyModal" :maskClosable="false" @cancel="modalCancel" @click="replaceModalClick" width="92%" :title="modifyTitle" padding="30rpx 30rpx">
 			<template v-slot:content>
 				<div class="app-modal-input-wrap modify-modal">
 					<div class="inp-list-line">
-						<div class="line-label">分类名称</div>
+						<div class="line-label">名称</div>
 						<div class="line-input">
-							<input type="text" v-model="modifyForm.categoryName" :adjust-position="false" class="inp-input" placeholder="请填写分类名称" />
+							<input type="text" v-model="replaceForm.name" :adjust-position="false" class="inp-input" placeholder="请填写" />
 						</div>
 					</div>
 					<div class="inp-list-line">
-						<div class="line-label">图片</div>
-						<div class="line-input flex-strat">
-							<app-uploader :multiple="false" ref="appUploader" :imgList.sync="modifyForm.img" />
-						</div>
-					</div>
-					<div class="prompt-text">建议尺寸 500X500</div>
-					<div class="inp-list-line">
-						<div class="line-label">排序</div>
+						<div class="line-label">顺序</div>
 						<div class="line-input">
-							<input type="text" v-model="modifyForm.inTurn" :adjust-position="false" class="inp-input" placeholder="默认排序最新在前面" />
-						</div>
-					</div>
-					<div class="inp-list-line switch-wrap">
-						<div class="line-label">启用状态</div>
-						<div class="line-input flex-strat">
-							<switch :checked="modifyForm.status == '0' ? false : true" @change="switchChangeFn" />
+							<input type="text" v-model="replaceForm.inTurn" :adjust-position="false" class="inp-input" placeholder="越大越靠前" />
 						</div>
 					</div>
 				</div>
 			</template>
 		</modal-module>
 		<!-- 删除提示 -->
-		<modal-module :show="delModal" :maskClosable="false" @cancel="modalCancel" @click="delModalClick" content="确定删除该分类吗?" color="#333" :size="32" padding="30rpx 30rpx"></modal-module>
+		<modal-module :show="delModal" :maskClosable="false" @cancel="modalCancel" @click="delModalClick" content="确定删除?" color="#333" :size="32" padding="30rpx 30rpx"></modal-module>
 	</div>
 </template>
 
@@ -82,7 +69,7 @@ import AppUploader from '@/components/app-uploader'
 import OperateModule from '@/admin/home/components/module/operate'
 import AppWrapperEmpty from '@/components/app-wrapper-empty'
 import { list } from '@/mixins'
-import { getList} from '@/api/item-class'
+import { getList,addClass,updateClass} from '@/api/item-class'
 export default {
 	name: 'category-manage',
 	components: {
@@ -96,11 +83,10 @@ export default {
 		return {
 			modifyModal: false,
 			modifyTitle: '添加',
-			modifyForm: {
-				categoryName: '',
-				img: [],
-				inTurn: 0,
-				status: 1
+			replaceForm: {
+				name: '',
+				id:0,
+				inTurn: 100
 			},
 			delModal: false,
 			operateShow: false,
@@ -119,20 +105,12 @@ export default {
 						this.modifyModal = true
 						this.modifyTitle = '编辑'
 						this.modifyForm = {
-							categoryName: this.operateData.categoryName,
-							img: [this.operateData.img],
-							inTurn: this.operateData.inTurn,
-							status: this.operateData.status
+							name: this.operateData.name,
+							id: this.operateData.id,
+							inTurn: this.operateData.inTurn
 						}
 					}
 				},
-				{
-					text: this.operateData.status == 1 ? '停用' : '启用',
-					icon: this.operateData.status == 1 ? 'iconjinyong' : 'iconqiyong',
-					click: () => {
-						this.changeStatusFn()
-					}
-				},
 				{
 					text: '删除',
 					icon: 'iconshanchu1',
@@ -165,15 +143,12 @@ export default {
 			if(index === 0){
 				this.modifyModal = true
 				this.modifyTitle = '编辑'
-				this.modifyForm = {
-					categoryName: this.operateData.categoryName,
-					img: [this.operateData.img],
+				this.replaceForm = {
+                    id:this.operateData.id,
+					name: this.operateData.name,
 					inTurn: this.operateData.inTurn,
-					status: this.operateData.status
 				}
 			}else if(index === 1) {
-				this.changeStatusFn()
-			}else if(index === 2) {
 				this.delModal = true
 			}
 		},
@@ -185,18 +160,13 @@ export default {
 				this.completes(res)
 			})
 		},
-		_categoryAddOrEditB() {
-			if (!this.modifyForm.categoryName) {
-				this.$msg('请输入分类名称!')
+		replaceClass() {
+			if (!this.replaceForm.name) {
+				this.$msg('请填写分类名称')
 				return false
 			}
-			let host = this.modifyTitle == '编辑' ? categoryUpdateB : categoryAddB
-			let form = JSON.parse(JSON.stringify(this.modifyForm))
-			form.img = this.$util.imgSubstr(form.img)
-			form.img = form.img.join()
-			if (this.modifyTitle == '编辑') {
-				form.categoryId = this.operateData.id
-			}
+			let host = this.replaceForm.id == 0 ?  addClass : updateClass;
+			let form = JSON.parse(JSON.stringify(this.replaceForm))
 			host({
 				...form
 			}).then(res => {
@@ -209,25 +179,23 @@ export default {
 				}, 1000)
 			})
 		},
-		// 操作
 		addCategoryFn() {
 			this.resetForm()
 			this.modifyModal = true
 			this.modifyTitle = '新增'
 		},
 		resetForm() {
-			this.modifyForm = {
-				categoryName: '',
-				img: [],
+			this.replaceForm = {
+				name: '',
 				inTurn: 0,
-				status: 1
+                id:0
 			}
 		},
-		modifyModalClick(e) {
+		replaceModalClick(e) {
 			if (e.index === 0) {
 				this.modalCancel()
 			} else {
-				this._categoryAddOrEditB()
+				this.replaceClass()
 			}
 		},
 		modalCancel() {
@@ -235,47 +203,40 @@ export default {
 			this.modifyModal = false
 		},
 		switchChangeFn(e) {
-			this.modifyForm.status = e.detail.value ? 1 : 0
+			this.replaceForm.status = e.detail.value ? 1 : 0
 		},
 		delModalClick(e) {
 			if (e.index === 0) {
 				this.modalCancel()
 			} else {
-				console.log('this.operateData', this.operateData)
-				categoryDelB({ categoryId: this.operateData.id }).then(res => {
-					this.modalCancel()
-					this.operateCancle()
-					this.$msg('删除成功!')
-					this.resetList()
-					this._list()
-				})
+                uni.showToast({
+                    title: '开发中',
+                    duration: 2000, 
+                    icon:'none',
+                });
 			}
 		},
-		operateFn(item, index) {
-			if (this.operateIndex == index) {
-				this.operateCancle()
-			} else {
-				this.operateData = item
-				this.operateIndex = index
-				this.operateShow = true
-				this.operateTop = (index + 1) * 191
-			}
+		operateFn(item, index, event) {
+            this.operateData = item
+            this.operateIndex = index
+            this.operateShow = true
+            this.operateTop = event.currentTarget.offsetTop
 		},
 		operateCancle() {
 			this.operateData = {}
 			this.operateIndex = null
 			this.operateShow = false
 		},
+        //点击页面取消
+        globalClick(){
+            this.operateCancle()
+        },
 		changeStatusFn() {
-			let status = this.operateData.status == 1 ? 0 : 1
-			categoryStatusB({
-				categoryId: this.operateData.id,
-				status: status
-			}).then(res => {
-				this.list.data[this.operateIndex].status = status
-				this.operateCancle()
-				this.$msg('操作成功!')
-			})
+            uni.showToast({
+                title: '开发中',
+                duration: 2000, 
+                icon:'none',
+            });
 		}
 	}
 }
@@ -293,7 +254,7 @@ export default {
 		.list {
 			height: 130px;
 			@include disFlex(center, flex-start);
-			padding: 30px 0;
+			padding: 80rpx 0 80rpx 0;
 			margin: 0 30px;
 			color: $fontColor3;
 			border-bottom: 1px solid $borderColor;

+ 6 - 2
ghsApp/src/api/item-class/index.js

@@ -4,6 +4,10 @@ export const getList = data => {
 	return https.get('/item-class/list', data)
 }
 
-export const picAdd = data => {
-	return https.post('/pic/add', data)
+export const addClass = data => {
+	return https.post('/item-class/add', data)
+}
+
+export const updateClass = data => {
+	return https.post('/item-class/update', data)
 }