From 8af3db52a632968206ca2bc7f9bd6b4662350232 Mon Sep 17 00:00:00 2001
From: xuxy <1059738716@qq.com>
Date: 星期二, 25 六月 2024 11:50:18 +0800
Subject: [PATCH] 商品管理

---
 environments/index.js                        |   13 -
 pages/login/farmer-login.vue                 |    5 
 pages/farmer/flower-manage/flower-add.vue    |  191 ++++++++++++-------------------
 mixin/mixin.js                               |    4 
 pages/farmer/flower-manage/flower-manage.vue |  110 ++++++++++++++++-
 store/index.js                               |    8 
 6 files changed, 193 insertions(+), 138 deletions(-)

diff --git a/environments/index.js b/environments/index.js
index d716832..32acfb1 100644
--- a/environments/index.js
+++ b/environments/index.js
@@ -22,16 +22,9 @@
 // export default environments['dev']
 
 export default {
-	httpBaseUri: 'http://localhost:8084',
-	httpBaseUri: 'http://bio51-api.fixbug.fun',
-	// https://api.bio1751.com/swagger-ui.html
-	httpBaseUri: 'https://api.bio1751.com',
-	httpBaseUri: 'http://localhost:8084',
-	httpBaseUri: 'http://39.106.36.7:8081',
-	// httpBaseUri: 'https://bewy-api.fixbug.fun',
-	
-	
-	httpBaseUri: 'https://www.doggooo.com',
+	// httpBaseUri: 'http://localhost:8084',
+	httpBaseUri: 'http://106.14.123.210:8080/flower',
+	// http://106.14.123.210:8080/flower/swagger-ui.html#/
 	// httpBaseUri: 'http://121.196.214.70',
 	// httpBaseUri: 'http://localhost:8084',
 	// httpBaseUri:'http://39.103.237.67:80',
diff --git a/mixin/mixin.js b/mixin/mixin.js
index 7459a6f..e3db599 100644
--- a/mixin/mixin.js
+++ b/mixin/mixin.js
@@ -255,6 +255,10 @@
 			}
 			return true
 		},
+		async refreshList(){
+			this.page.current = 1
+			await this.getList()
+		},
 		async getList() {
 			if (this.listApi) {
 				this.$message.showLoading()
diff --git a/pages/farmer/flower-manage/flower-add.vue b/pages/farmer/flower-manage/flower-add.vue
index bf2fb5f..421428e 100644
--- a/pages/farmer/flower-manage/flower-add.vue
+++ b/pages/farmer/flower-manage/flower-add.vue
@@ -3,12 +3,12 @@
 		<view>
 			<view class="form-item">
 				<view class="label required">商品分类</view>
-				<view class="m-l-a m-r-0 flex " :class="[!dto.applicationType?'desc-gray':'']" @click="()=>{
+				<view class="m-l-a m-r-0 flex " :class="[!dto.category?'desc-gray':'']" @click="()=>{
 					if(!id){
-						show_select_type=true
+						show_select_category=true
 					}
 				}">
-					<view>{{dto.applicationTypeStr||dto.applicationType || '请选择'}}</view>
+					<view>{{dto.categoryStr||dto.category || '请选择'}}</view>
 					<u-icon class="m-l-a" name="arrow-right"></u-icon>
 				</view>
 
@@ -112,16 +112,16 @@
 			</view>
 
 
-
-
-			<view class="button-green-1 m-t-20 button-fixed-bottom before-line" @click="submit">
+			<view class="button-green-1 m-t-20 button-fixed-bottom before-line" @click="submit" v-if="!dto.id">
 				提交审核
 			</view>
-
+			<view class="button-green-1 m-t-20 button-fixed-bottom before-line" @click="submit" v-if="dto.id">
+				修改
+			</view>
 		</view>
 
 
-		<u-picker @confirm="select_type" keyName="label" @cancel="show_select_type=false" :show="show_select_type"
+		<u-picker @confirm="select_category" keyName="label" @cancel="show_select_category=false" :show="show_select_category"
 			:columns="columns_types"></u-picker>
 
 		<u-picker @confirm="select_user" keyName="label" @cancel="show_select_user=false" :show="show_select_user"
@@ -133,7 +133,6 @@
 
 <script>
 	import environments from '@/environments'
-	import xflSelect from '@/components/xfl-select/xfl-select.vue'; //导入
 
 	import {
 		mapState
@@ -144,76 +143,63 @@
 		data() {
 			return {
 				id: '',
-				orderId: '',
-				show_addlog: false,
-				log_remarks: '',
-				refresh: false,
-				api: '',
 				dto: {
 					id: '',
-					applicationType: '',
+					name: '',
+					category: '',
+					unit: '',
+					color: '',
+					cover: '',
+					bannerList: [], //str[]
+					video: '',
+					level: '', //FLOWER_LEVEL
+					price: 0.00,
+					stock: 0,
+					params: [], //id,value
 				},
-				show_select_type: false,
+				show_select_category: false,
 				show_select_user: false,
-				columns_types: [],
-				audit_remarks: '',
-				audit_result: false,
-				show_audit: false,
-
-
-				//审核方式
-				shTypeList: [{
-						name: '身份证',
-						disabled: false
-					},
-					{
-						name: '营业执照',
-						disabled: false
-					}
-				],
-				radiovalue1: '身份证',
+				columns_categorys: [],
+				columns_levels:[],
 
 			}
 		},
-		onLoad(options) {
+		async onLoad(options) {
 			if (options.id) {
 				this.id = options.id
 				this.getDetail()
 			} else {
-				// this.$http.request('get', '/api/personnel/employee/list', {
-				// 	params: {
-				// 		size: 4000,
-				// 		current: 1
-				// 	}
-				// }).then(res => {
-				// 	this.userListAll = (res.data && res.data.records || []).map(item => {
-				// 		item.label = item.label || item.name || item.nickName || item.loginName || '-'
-				// 		return item
-				// 	})
-				// 	var index = 0
-				// 	this.userList = this.userListAll.map(item => {
-				// 		index += 1
-				// 		return `${index}.` + item.label + (item.tel ? `(${item.tel})` : '')
-				// 	})
-				// 	var arr = this.userListAll.map(item => {
-				// 		return {
-				// 			label: item.label + (item.tel ? `(${item.tel})` : ''),
-				// 			value: item.id
-				// 		}
-				// 	})
-				// 	this.userListCols = [arr]
-
-				// })
-
-
-				this.$http.request('get', '/api/dict/value', {
+				if (options.copyId) {
+					this.id = options.copyId
+					await this.getDetail()
+					this.id = ''
+					delete this.dto.id
+				}
+				
+				//tree
+				this.$http.request('get', '/api/flower/category/tree', {
 					params: {
-						typeCode: 'APPLICATION_TYPE'
+						typeCode: 'FLOWER_LEVEL'
 					}
 				}).then(res => {
 					var data = res.data
-					this.columns_types = [data || []]
-					this.columns_types[0].unshift({
+					this.columns_categorys = [data || []]
+					this.columns_categorys[0].unshift({
+						label: '全部',
+						value: '',
+						children:[]
+					})
+
+				})
+				
+				this.$http.request('get', '/api/dict/value', {
+					params: {
+						typeCode: 'FLOWER_LEVEL'
+					}
+				}).then(res => {
+					var data = res.data
+					this.columns_levels = [data || []]
+					this.columns_levels[0].unshift({
 						label: '全部',
 						value: ''
 					})
@@ -226,10 +212,10 @@
 		methods: {
 
 
-			select_type(e) {
-				this.show_select_type = false
-				this.dto.applicationTypeStr = e.value[0].label
-				this.dto.applicationType = e.value[0].value
+			select_category(e) {
+				this.show_select_category = false
+				this.dto.categoryStr = e.value[0].label
+				this.dto.category = e.value[0].value
 			},
 			select_user(e) {
 				this.show_select_user = false
@@ -242,16 +228,16 @@
 				const {
 					code,
 					data
-				} = await this.$http.request('get', "/api/app/application/get/" + this.id, {})
+				} = await this.$http.request('get', "/api/supplier/flower/list/view?id=" + this.id, {})
 				if (code == 0) {
 					this.dto = {
 						...data,
 
 					}
-					if (this.dto.applicationDate) {
-						this.dto.applicationDate = this.$util.toDate(new Date(this.dto.applicationDate))
-					}
-					// console.log('this.dto', this.dto)
+					// if (this.dto.applicationDate) {
+					// 	this.dto.applicationDate = this.$util.toDate(new Date(this.dto.applicationDate))
+					// }
+					// // console.log('this.dto', this.dto)
 
 				}
 
@@ -259,64 +245,41 @@
 
 			},
 			async submit() {
-				if (!this.dto.applicationType) {
-					this.$message.showToast('未选择类型')
-					return
-				}
-				if (!this.dto.applicationTitle) {
-					this.$message.showToast('未填写申请主题')
-					return
-				}
-				if (!this.dto.auditPersonId) {
-					this.$message.showToast('未选择审批人')
-					return
-				}
-				await this.$message.confirm(`是否确定提交申请${this.auditPersonName?(",审批人为:"+this.auditPersonName):""}`)
+				// if (!this.dto.applicationType) {
+				// 	this.$message.showToast('未选择类型')
+				// 	return
+				// }
+				// if (!this.dto.applicationTitle) {
+				// 	this.$message.showToast('未填写申请主题')
+				// 	return
+				// }
+				// if (!this.dto.auditPersonId) {
+				// 	this.$message.showToast('未选择审批人')
+				// 	return
+				// }
+				// await this.$message.confirm(`是否确定提交申请${this.auditPersonName?(",审批人为:"+this.auditPersonName):""}`)
 
 				// this.$message.showToast('1')
 				// return
 				var dto = {
 					...this.dto,
-					applicationDate: this.$util.toDate(new Date()),
-					applicantId: this.currentInfo.id
+					// applicationDate: this.$util.toDate(new Date()),
+					// applicantId: this.currentInfo.id
 				}
 				this.$message.showLoading()
-				const re = await this.$http.request('post', '/api/app/application/create', {
+				const re = await this.$http.request('post', `/api/supplier/flower/list/${this.id?'edit':'new'}`, {
 					data: dto
 				})
 				this.$message.hideLoading()
 				if (re.code == 2000 || re.code == 0) {
 					this.$message.showToast('操作成功')
 					//需要标记加一下
-					this.$store.dispatch('sign_add', 'application');
+					// this.$store.dispatch('sign_add', 'application');
 
 					this.backpage()
 				}
 			},
-			async submitAudit() {
-				var url = ''
-				if (this.audit_result) {
-					url = '/api/app/application/audit/pass'
-				} else {
-					url = '/api/app/application/audit/reject'
-				}
-				var dto = {
-					id: this.id,
-					auditRemarks: this.audit_remarks
-				}
-				this.show_audit = false
-				this.$message.showLoading()
-				const re = await this.$http.request('post', url, {
-					data: dto
-				})
-				this.$message.hideLoading()
-				if (re.code == 2000 || re.code == 0) {
-					this.$message.showToast('操作成功')
-					this.$store.dispatch('sign_add', 'application');
 
-					this.getDetail()
-				}
-			},
 			uploadIcon(key) {
 				const that = this
 				uni.chooseImage({
@@ -351,7 +314,7 @@
 			...mapState(['currentInfo'])
 		},
 		components: {
-			xflSelect
+
 		}
 	}
 </script>
diff --git a/pages/farmer/flower-manage/flower-manage.vue b/pages/farmer/flower-manage/flower-manage.vue
index a539a1e..3b6f2db 100644
--- a/pages/farmer/flower-manage/flower-manage.vue
+++ b/pages/farmer/flower-manage/flower-manage.vue
@@ -2,10 +2,10 @@
 	<view class="flow-manage">
 		<view class="top-buttons" v-if="type==='all'">
 			<view @click.stop="clickButton('add')" class="button button-add"></view>
-			<view class="button button-search-in"></view>
-			<view class="button button-search-unpass"></view>
-			<view class="button button-search-inpass"></view>
-			<view class="button button-search-delete"></view>
+			<view @click.stop="clickButton('in')" class="button button-search-in"></view>
+			<view @click.stop="clickButton('unpass')" class="button button-search-unpass"></view>
+			<view @click.stop="clickButton('inpass')" class="button button-search-inpass"></view>
+			<view @click.stop="clickButton('delete')" class="button button-search-delete"></view>
 
 		</view>
 
@@ -54,12 +54,13 @@
 
 					</view>
 					<view class="buttons">
-						<view class="button">复制</view>
-						<view class="button">删除</view>
-						<view class="button">下架</view>
+						<view class="button" @click.stop="toDetailAdd(item)">复制</view>
+						<view class="button" @click.stop="buttonDelete(item)">删除</view>
+						<view class="button" @click.stop="buttonStatus(item,'off')" v-if="item.status=='UP'">下架</view>
+						<view class="button" @click.stop="buttonStatus(item,'up')" v-if="item.status=='OFF'">上架</view>
 						<view class="button" @click.stop="toDetail(item)">编辑</view>
-						<view class="button">价格</view>
-						<view class="button">库存</view>
+						<view class="button" @click.stop="changeValue(item,'price')">价格</view>
+						<view class="button" @click.stop="changeValue(item,'stock')">库存</view>
 					</view>
 				</view>
 			</view>
@@ -83,7 +84,22 @@
 		onLoad(options) {
 			this.type = options.type || 'all'
 			//todo 根据type切换查询条件
-			this.listApi = '/api/ua/announcement/list'
+			if (this.type === 'delete') {
+				this.listApi = '/api/supplier/flower/list/rc'
+
+			} else {
+				this.listApi = '/api/supplier/flower/list'
+				this.query.status = ''
+				if (this.type === 'inpass') {
+					this.query.status = 'PENDING'
+				}
+				if (this.type === 'in') {
+					this.query.status = 'UP'
+				}
+				if (this.type === 'unpass') {
+					this.query.status = 'REJECT'
+				}
+			}
 			this.getList()
 		},
 		onReachBottom() {
@@ -96,11 +112,85 @@
 			uni.stopPullDownRefresh()
 		},
 		methods: {
+			async changeValue(item, key) {
+				const res = await this.$message.confirm(`确定修改此商品的${key==='price'&&'价格'|| key==='stock'&&'库存'}吗`, {
+					editable: true
+				})
+				if(!res.content){
+					this.$message.showToast('输入不能为空')
+					return
+				}
+				var value = ''
+				if(key=='price'){
+					value = parseFloat(res.content).toFixed(2)
+				}else{
+					value = parseInt(res.content)
+				}
+				if(isNaN(value)){
+					this.$message.showToast('输入格式不正确')
+					return
+				}
+				var dto = {
+					id: item.id,
+				}
+				dto[key] = value
+
+
+				this.$message.showLoading()
+				this.$http.request('post', '/api/supplier/flower/list/' + key, {
+					data: dto
+				}).then(res => {
+					if (res.code == 0) {
+						this.$message.showToast('操作成功')
+						item[key] = value
+					}
+				}).finally(() => {
+					this.$message.hideLoading()
+				})
+			},
+			async buttonStatus(item, status) {
+				await this.$message.confirm(`确定${status==='off'?'下降':'上架'}此商品吗`)
+				this.$message.showLoading()
+				this.$http.request('get', '/api/supplier/flower/list/' + status, {
+					params: {
+						id: item.id
+					}
+				}).then(res => {
+					if (res.code == 0) {
+						this.$message.showToast('操作成功')
+						item.status = status
+						item.statusStr = (status == 'off' ? '下架' : '上架')
+					}
+				}).finally(() => {
+					this.$message.hideLoading()
+				})
+			},
+			async buttonDelete(item) {
+				await this.$message.confirm('确定删除此商品吗')
+				this.$message.showLoading()
+				this.$http.request('get', '/api/supplier/flower/list/delete', {
+					params: {
+						id: item.id
+					}
+				}).then(res => {
+					if (res.code == 0) {
+						this.$message.showToast('删除成功')
+						this.refreshList()
+					}
+				}).finally(() => {
+					this.$message.hideLoading()
+				})
+			},
 			toDetail(item) {
 				uni.navigateTo({
 					url: '/pages/farmer/flower-manage/flower-add?id=' + item.id
 				})
 			},
+			toDetailAdd(item) {
+				uni.navigateTo({
+					url: '/pages/farmer/flower-manage/flower-add?copyId=' + item.id
+				})
+			},
 			clickButton(type) {
 				if (type == 'add') {
 					//添加页面
diff --git a/pages/login/farmer-login.vue b/pages/login/farmer-login.vue
index 1f71a78..36c80da 100644
--- a/pages/login/farmer-login.vue
+++ b/pages/login/farmer-login.vue
@@ -26,13 +26,15 @@
 
 
 					<view class="t-a input" v-if="loginType=='code'">
-						<input type="text" :password="true" name="password" placeholder="请输入密码" v-model="password" />
+						<input type="text" name="userName" placeholder="请输入手机验证码" v-model="smsCode" />						
 					</view>
 
 					<button @tap="login()" class="bottom-button">登 录</button>
 
 					<view class="flex">
 						<view class="topic-font" @click="loginType='code'">手机验证码登录</view>
+						<view class="topic-font" @click="loginType='pwd'">账号密码登录</view>
+						
 						<view class="topic-font m-l-a m-r-0" @click="toReg">前往注册</view>
 					</view>
 				</form>
@@ -52,6 +54,7 @@
 				// password: '12345678',
 				userName: '',
 				phoneNumber: '',
+				smsCode:'',
 				password: '',
 				checked: false,
 				loginType: 'pwd', //pwd和code,密码和验证码登录
diff --git a/store/index.js b/store/index.js
index ba31727..fd022d1 100644
--- a/store/index.js
+++ b/store/index.js
@@ -245,16 +245,18 @@
 						}
 						return resp
 					},
-					loginShop: async function({
+					loginSupplier: async function({
 						commit,
 						dispatch,
 						state
 					}, data) {
 						{
-							const resp = await http.request('post', '/api/login/employee', {
+							const resp = await http.request('post', '/api/login/supplier'+(data.phoneNumber?'/phone':''), {
 								data: {
 									username: data.username,
-									password: data.password
+									password: data.password,
+									tel:data.phoneNumber,
+									smsCode:data.smsCode || ''
 								},
 								params: {
 									clientType: data.clientType || 'app'

--
Gitblit v1.9.3