chenrui %!s(int64=3) %!d(string=hai) anos
pai
achega
3dd4cdc661
Modificáronse 4 ficheiros con 301 adicións e 7 borrados
  1. 11 0
      api/dealerProductType.js
  2. 0 2
      pages/common/productBrand.vue
  3. 201 0
      pages/common/productType.vue
  4. 89 5
      pages/stock/index.vue

+ 11 - 0
api/dealerProductType.js

@@ -0,0 +1,11 @@
+import axios from '@/libs/axios.js'
+
+//  产品分类 列表  无分页
+export const dealerProductTypeList = (params) => {
+  const url = `dealerProductType/query`
+  return axios.request({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}

+ 0 - 2
pages/common/productBrand.vue

@@ -51,7 +51,6 @@
 				listData: [],
 				queryWord: '',
 				isGobleSearch: false,
-				brandList: [],
 				brandSn: this.itemSn || null
 			}
 		},
@@ -146,7 +145,6 @@
 					.item-name{
 						padding: 14upx 0;
 						text-align: center;
-						// border-bottom: 1upx dashed #efefef;
 					}
 					.item-icon{
 						position: absolute;

+ 201 - 0
pages/common/productType.vue

@@ -0,0 +1,201 @@
+<template>
+	<u-popup v-model="isShow" class="type-picker" @close="isShow=false" mode="bottom">
+		<view class="type-header flex justify_between align_center">
+			<text class="type-picker-btn" @click="onClean">清空</text>
+			<text>产品分类</text>
+			<text class="type-picker-btn color-blue" @click="isShow=false">X</text>
+		</view>
+		<u-row class="choose-info">
+			<u-col :span="3">当前已选:</u-col>
+			<u-col :span="7" :style="{color: $config('primaryColor')}">
+				<view v-for="(item, index) in infoDataS" :key="index" style="display: inline-block;">{{item.productTypeName}}<text v-if="index+1 != infoData.length"> > </text></view>
+			</u-col>
+			<u-col :span="2"><u-button v-if="infoDataS.length>0" @click="handlerConfirm" type="success" size="mini" :custom-style="customStyle" hover-class="none" shape="circle">确定</u-button></u-col>
+		</u-row>
+		<scroll-view class="picker-content" scroll-y>
+			<view class="picker-main">
+				<view class="picker-main-item" v-for="(item, index) in typeList" :key="item.productTypeSn" @click="chooseItem(index)">
+					<view class="item-name">{{item.productTypeName}}</view>
+					<u-icon v-show="item.productTypeSn==(infoDataS[nowInd]&&infoDataS[nowInd].productTypeSn)" class="item-icon" name="checkbox-mark" :color="$config('primaryColor')" size="28"></u-icon>
+				</view>
+				<view v-if="typeList && typeList.length == 0">
+					<u-empty text="数据为空" mode="list" :img-width="200" :margin-top="-60"></u-empty>
+				</view>
+			</view>
+		</scroll-view>
+	</u-popup>
+</template>
+
+<script>
+	import { dealerProductTypeList } from '@/api/dealerProductType'
+	export default {
+		props: {
+			openModal: { //  弹框显示状态
+				type: Boolean,
+				default: false
+			},
+			nowData: {
+				type: Object,
+				default: ()=>{
+					return {
+						data: [],
+						indArr: [],
+						nowInd: 0
+					}
+				}
+			}
+		},
+		data() {
+			return {
+				isShow: this.openModal, //  是否打开弹框
+				listData: [],
+				typeList: [],
+				nowInd: 0,
+				indArr: [],
+				infoData: [],
+				infoDataS: [],
+				customStyle: {
+					background: this.$config('primaryColor')
+				}
+			}
+		},
+		mounted() {
+			this.getTypeList()
+		},
+		methods: {
+			getTypeList(){
+				dealerProductTypeList({}).then(res => {
+					if(res.status == 200 && res.data){
+						this.listData = res.data
+						this.typeList = res.data
+					}else{
+						this.listData = []
+						this.typeList = []
+					}
+				})
+			},
+			//  选择
+			chooseItem(ind){
+				if(this.nowInd == 0){
+					this.infoData[this.nowInd] = { productTypeName: this.typeList[ind].productTypeName, productTypeSn: this.typeList[ind].productTypeSn }
+					this.infoData[1] ? delete this.infoData[1] : null
+					this.infoData[2] ? delete this.infoData[2] : null
+					this.indArr[this.nowInd] = ind
+					this.indArr[1] ? delete this.indArr[1] : null
+					this.indArr[2] ? delete this.indArr[2] : null
+					this.nowInd++
+				}else if(this.nowInd == 1){
+					this.infoData[this.nowInd] = { productTypeName: this.typeList[ind].productTypeName, productTypeSn: this.typeList[ind].productTypeSn }
+					this.infoData[2] ? delete this.infoData[2] : null
+					this.indArr[this.nowInd] = ind
+					this.indArr[2] ? delete this.indArr[2] : null
+					this.nowInd++
+				}else if(this.nowInd == 2){
+					this.infoData[this.nowInd] = { productTypeName: this.typeList[ind].productTypeName, productTypeSn: this.typeList[ind].productTypeSn }
+					this.indArr[this.nowInd] = ind
+				}
+				this.infoDataS = JSON.parse(JSON.stringify(this.infoData))
+			},
+			handlerConfirm(){
+				const params = {
+					data: this.infoDataS,
+					indArr: this.indArr,
+					nowInd: this.nowInd
+				}
+				this.$emit('choose', params)
+				this.isShow = false
+			},
+			// 清空
+			onClean(){
+				this.infoData = []
+				this.infoDataS = []
+				this.indArr = []
+				this.nowInd = 0
+				this.$emit('clean')
+				this.isShow = false
+			}
+		},
+		watch: {
+			//  父页面传过来的弹框状态
+			openModal (newValue, oldValue) {
+				this.isShow = newValue
+			},
+			//  重定义的弹框状态
+			isShow (newValue, oldValue) {
+				if (!newValue) {
+					this.$emit('close')
+				}else{
+					this.infoData = JSON.parse(JSON.stringify(this.nowData.data))
+					this.infoDataS = JSON.parse(JSON.stringify(this.nowData.data))
+					this.indArr = this.nowData.indArr
+					this.nowInd = this.nowData.nowInd
+				}
+			},
+			nowInd (newValue, oldValue) {
+				if (newValue || newValue == 0) {
+					if (newValue == 0) {
+						this.typeList = this.listData || []
+					}else if (newValue == 1) {
+						this.typeList = (this.indArr[0] || this.indArr[0]==0) && this.listData[this.indArr[0]] && this.listData[this.indArr[0]].children ? this.listData[this.indArr[0]].children : []
+					}else if (newValue == 2) {
+						let oList = (this.indArr[0] || this.indArr[0]==0) && this.listData[this.indArr[0]] && this.listData[this.indArr[0]].children ? this.listData[this.indArr[0]].children : []
+						let tList = (this.indArr[1] || this.indArr[1]==0) && oList[this.indArr[1]] && oList[this.indArr[1]].children ? oList[this.indArr[1]].children : []
+						this.typeList = tList
+					}
+				}
+			}
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+	.type-picker{
+		.type-header{
+			padding: 20upx 30upx;
+			position: relative;
+			.type-picker-btn{
+				color: rgb(96, 98, 102);
+			}
+		}
+		.type-header:after{
+			content: "";
+			position: absolute;
+			border-bottom: 1px solid #eaeef1;
+			-webkit-transform: scaleY(.5);
+			transform: scaleY(.5);
+			bottom: 0;
+			right: 0;
+			left: 0;
+		}
+		.choose-info{
+			padding: 14upx 30upx 14upx;
+			color: rgb(96, 98, 102);
+		}
+		.picker-content{
+			height: 300upx;
+			padding: 6upx 0 20upx;
+			position: relative;
+			.picker-main{
+				position: absolute;
+				top: 50%;
+				left: 50%;
+				transform: translate(-50%,-50%);
+				width: 100%;
+				max-height: 300upx;
+				.picker-main-item{
+					position: relative;
+					padding: 0 30upx;
+					.item-name{
+						padding: 14upx 0;
+						text-align: center;
+					}
+					.item-icon{
+						position: absolute;
+						right: 100upx;
+						top: 19upx;
+					}
+				}
+			}
+		}
+	}
+</style>

+ 89 - 5
pages/stock/index.vue

@@ -21,19 +21,28 @@
 				<u-form-item label="原厂编码"><u-input v-model.trim="form.productOrigCode" placeholder="请输入原厂编码" input-align="right" /></u-form-item>
 				<u-form-item label="产品名称"><u-input v-model.trim="form.productName" placeholder="请输入产品名称" input-align="right" /></u-form-item>
 				<u-form-item label="产品品牌"><u-input v-model="brandName" @click="brandModal=true" disabled placeholder="请选择产品品牌" input-align="right" /></u-form-item>
+				<u-form-item label="产品分类"><u-input v-model="productTypeNameArr" @click="showTypeModal=true" disabled placeholder="请选择产品分类" input-align="right" /></u-form-item>
 				<u-form-item label="只查看有库存"><u-switch slot="right" v-model="form.zeroQtyFlag"></u-switch></u-form-item>
 			</u-form>
+			<view class="form-footer-btn">
+				<u-button size="medium" hover-class="none" @click="handleClean">清空</u-button>
+				<u-button size="medium" hover-class="none" :custom-style="customBtnStyle" @click="handleSearch">查询</u-button>
+			</view>
 		</view>
 		<!-- 产品品牌 -->
 		<productBrand :openModal="brandModal" :itemSn="form.productBrandSn" @choose="brandChoose" @clean="brandClean" @close="brandModal=false" />
+		<!-- 产品分类 -->
+		<productType :openModal="showTypeModal" :nowData="nowData" @choose="typeChoose" @clean="typeClean" @close="showTypeModal=false" />
 	</view>
 </template>
 
 <script>
 	import productBrand from '@/pages/common/productBrand.vue'
+	import productType from '@/pages/common/productType.vue'
+	import { dealerProductTypeList } from '@/api/dealerProductType'
 	import { stockCount } from '@/api/stock'
 	export default{
-		components: { productBrand },
+		components: { productBrand, productType },
 		data(){
 			return {
 				form: {
@@ -41,14 +50,34 @@
 					productName: '', //  产品名称
 					productOrigCode: '', //  原厂编码
 					productBrandSn: undefined, //  产品品牌
-					productTypeSn1: '', //  产品分类1
-					productTypeSn2: '', //  产品分类2
-					productTypeSn3: '', //  产品分类3
+					productTypeSn1: undefined, //  产品分类1
+					productTypeSn2: undefined, //  产品分类2
+					productTypeSn3: undefined, //  产品分类3
 					zeroQtyFlag: false //  库存情况
 				},
 				totalData: null,
 				brandModal: false,
-				brandName: ''
+				brandName: '',
+				showTypeModal: false,
+				nowData: {
+					data: [],
+					indArr: [],
+					nowInd: 0
+				},
+				customBtnStyle: {  //  自定义按钮样式
+					borderColor: this.$config('primaryColor'),
+					backgroundColor: this.$config('primaryColor'),
+					color: '#fff'
+				},
+			}
+		},
+		computed: {
+			productTypeNameArr: function() {
+				let str = ''
+				this.nowData.data.map(item => {
+					str += item.productTypeName+' / '
+				})
+				return str ? str.substr(0, str.length-3) : ''
 			}
 		},
 		onLoad() {
@@ -65,6 +94,29 @@
 					}
 				})
 			},
+			// 表单清空
+			handleClean(){
+				this.form.productCode = ''
+				this.form.productName = ''
+				this.form.productOrigCode = ''
+				this.form.productBrandSn = undefined
+				this.form.productTypeSn1 = undefined
+				this.form.productTypeSn2 = undefined
+				this.form.productTypeSn3 = undefined
+				this.form.zeroQtyFlag = false
+				console.log(this.form)
+			},
+			// 查询
+			handleSearch(){
+				let params = JSON.parse(JSON.stringify(this.form))
+				if (params.zeroQtyFlag) {
+					params.zeroQtyFlag = '0'
+				} else {
+					params.zeroQtyFlag = ''
+				}
+				console.log(params)
+			},
+			// 选择品牌
 			brandChoose(data){
 				this.brandName = data.brandName
 				this.form.productBrandSn = data.brandSn
@@ -73,6 +125,28 @@
 			brandClean(){
 				this.brandName = ''
 				this.form.productBrandSn = undefined
+			},
+			// 选择分类
+			typeChoose(obj){
+				this.nowData = {
+					data: obj.data,
+					indArr: obj.indArr,
+					nowInd: obj.nowInd
+				}
+				this.form.productTypeSn1 = this.nowData.data[0]&&this.nowData.data[0].productTypeSn ? this.nowData.data[0].productTypeSn : undefined
+				this.form.productTypeSn2 = this.nowData.data[0]&&this.nowData.data[1].productTypeSn ? this.nowData.data[1].productTypeSn : undefined
+				this.form.productTypeSn3 = this.nowData.data[0]&&this.nowData.data[2].productTypeSn ? this.nowData.data[2].productTypeSn : undefined
+			},
+			// 清空分类
+			typeClean(){
+				this.nowData = {
+					data: [],
+					indArr: [],
+					nowInd: 0
+				}
+				this.form.productTypeSn1 = undefined
+				this.form.productTypeSn2 = undefined
+				this.form.productTypeSn3 = undefined
 			}
 		}
 	}
@@ -114,6 +188,16 @@
 					margin: 0 20upx 0 10upx;
 				}
 			}
+			.form-footer-btn{
+				margin: 60upx 30upx 30upx;
+				display: flex;
+				justify-content: space-between;
+			}
+			.form-footer-btn uni-button{
+				width: 40%;
+				margin: 0 auto;
+				font-size: 30upx;
+			}
 		}
 	}
 </style>