wangguoyu 1 mês atrás
pai
commit
6dca0fbc90
2 arquivos alterados com 71 adições e 30 exclusões
  1. 12 0
      api/jiazheng.js
  2. 59 30
      pages/admin/Jiazheng/kechengBind.vue

+ 12 - 0
api/jiazheng.js

@@ -393,3 +393,15 @@ export function kechengReset(data = {}) {
     timeout: 20000
   })
 }
+
+export function chaxunNumberKecheng(data = {}) {
+  return request({
+    url: '/app/user/jiazheng/kecheng/yue',
+    headers: {
+      isToken: true
+    },
+    method: 'post',
+    data,
+    timeout: 20000
+  })
+}

+ 59 - 30
pages/admin/Jiazheng/kechengBind.vue

@@ -3,8 +3,10 @@
 		<view class="phone-navBar-box">
 			<view @click="goUpPage" class="nav-bar-icon"></view>
 			<text class="nav-bar-title">家政人员</text>
-			<uni-icons v-show="current ==0" class="nav-bar-right-icon bar-ml10" type="search" @click="searchBtn" size="20"></uni-icons>
-			<uni-icons v-show="current ==1" style="opacity: 0;" class="nav-bar-right-icon bar-ml10" type="search" size="20"></uni-icons>
+			<uni-icons v-show="current ==0" class="nav-bar-right-icon bar-ml10" type="search" @click="searchBtn"
+				size="20"></uni-icons>
+			<uni-icons v-show="current ==1" style="opacity: 0;" class="nav-bar-right-icon bar-ml10" type="search"
+				size="20"></uni-icons>
 		</view>
 		<v-tabs v-model="current" :tabs="tabs" :scroll="false" @change="changeTab" field="name"
 			class="admin-tab-box"></v-tabs>
@@ -37,8 +39,10 @@
 		</view>
 		<view class="kc-notbind-scroll-view scroll-top-border" v-if="current ==1">
 			<uni-list class="admin-list-box">
+				<view style="padding: 12px 15px;">课程剩余数量:{{kechengNumber||0}}</view>
 				<uni-list-item v-for="item in listYx" class="admin-list-item-box">
 					<template v-slot:body>
+
 						<view @click="lookUserInfo(item)" class="kecheng-list-card">
 							<img :src="item.pic" v-if="item.pic">
 							<view class="item-card-row">
@@ -50,7 +54,7 @@
 								</view> -->
 								<view class="bind-btn-row">
 									<button type="default" size="mini" class="kc-bind-btn phone-green-btn"
-										@click="toReset(item)">重置</button>			
+										@click="toReset(item)">重置</button>
 									<button type="default" size="mini" class="kc-bind-btn phone-white-btn"
 										@click="toDelete(item)">删除</button>
 								</view>
@@ -77,7 +81,8 @@
 		jiazhengKcAdd,
 		jiazhengKcDelete,
 		getAdminClassify,
-		kechengReset
+		kechengReset,
+		chaxunNumberKecheng
 	} from "@/api/jiazheng.js";
 	import commonDialog from '@/components/dialog/commonDialog.vue';
 	import kechengLeixingVue from "./common/kechengLeixing.vue";
@@ -93,6 +98,8 @@
 				selectClassify: null,
 				kcClassifyId: 0,
 				id: '',
+				kechengNumber: '',
+				addFlag: false,
 				name: '',
 				current: 0,
 				list: [],
@@ -122,33 +129,49 @@
 			this.id = options.id
 			this.getList()
 			this.getKechengClassify()
+			this.chaxunNumber()
 		},
 		methods: {
-			toReset(data){
-			let req = {
-				kcId: data.kcId,
-				id: this.id
-			}
-			kechengReset(req).then(res => {
-				if (res.code == 0) {
-					this.getList()
-					uni.showToast({
-						title: '成功',
-						icon: 'success'
-					});
-				} else {
-					uni.showToast({
-						title: '失败',
-						icon: 'success'
-					});
-					return false
+			chaxunNumber() {
+				chaxunNumberKecheng({
+					id: this.id
+				}).then(res => {
+					if (res.code == 0) {
+						this.kechengNumber = res.data
+						this.addFlag = this.kechengNumber > 0;
+					} else {
+						uni.showToast({
+							title: '失败'
+						});
+						return false
+					}
+				})
+			},
+			toReset(data) {
+				let req = {
+					kcId: data.kcId,
+					id: this.id
 				}
-			})
+				kechengReset(req).then(res => {
+					if (res.code == 0) {
+						this.getList()
+						uni.showToast({
+							title: '成功',
+							icon: 'success'
+						});
+					} else {
+						uni.showToast({
+							title: '失败'
+
+						});
+						return false
+					}
+				})
 			},
 			searchBtn() {
 				this.$refs.searchRef.handleShow()
 			},
-			
+
 			handleSearchFromBtn(textD) {
 				this.name = textD;
 				this.getList()
@@ -177,13 +200,18 @@
 				})
 			},
 			toAdd(data) {
+				if (!this.addFlag) {
+					uni.showToast({
+						title: '课程剩余数量不足'
+					});
+					return false
+				}
 				debounce(
-					this.jzAdd(data)
-				,500)
-			
+					this.jzAdd(data), 500)
+
 			},
-			
-			jzAdd(data){
+
+			jzAdd(data) {
 				let req = {
 					kcIds: [data.kcId],
 					id: this.id
@@ -234,6 +262,7 @@
 				if (this.current == 0) {
 					this.getList()
 				} else {
+					this.chaxunNumber()
 					this.getYxList()
 				}
 
@@ -248,7 +277,7 @@
 				let req = {
 					id: this.id,
 					"kcClassifyId": this.selectClassify && this.selectClassify.id || 0,
-					name:this.name
+					name: this.name
 				}
 				kcSelectList(req).then(res => {
 					if (res.code == 0) {