zhangdan 3 vuotta sitten
vanhempi
commit
520a801c35

+ 30 - 5
api/data.js

@@ -1,19 +1,35 @@
 import axios from '@/libs/axios.js';
 // 根据字典code查询选项
+// export const getLookUpDatas = (params) => {
+//   return axios.request({
+//     url: `lookup/findByLookup/${params.type}`,
+//     method: 'get'
+//   })
+// }
 export const getLookUpDatas = (params) => {
+  const url = `lookupItem/query/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
   return axios.request({
-    url: `lookup/findByLookup/${params.type}`,
-    method: 'get'
+    url: url,
+    data: params,
+    method: 'post'
   })
 }
-
 export const listLookUp = (params) => {
-  let url = `lookup/findAll`
+  const url = `/lookup/queryLike`
   return axios.request({
     url: url,
-    method: 'post'
+    method: 'POST'
   }).then(res => res)
 }
+// export const listLookUp = (params) => {
+//   let url = `lookup/findAll`
+//   return axios.request({
+//     url: url,
+//     method: 'post'
+//   }).then(res => res)
+// }
 // 查询最新版本信息
 export const getSysVersion = (params) => {
   return axios.request({
@@ -32,4 +48,13 @@ export const getLookUpItem = (params) => {
     data: params,
     method: 'post'
   })
+}
+
+// 查询省市区
+export const getArea = (params) => {
+  return axios.request({
+    url: `area/queryList`,
+    data: params,
+    method: 'post'
+  })
 }

+ 143 - 98
api/sales.js

@@ -1,113 +1,158 @@
-import axios from '@/libs/axios.js'
-
-// 数据统计信息
-export const bizData = (params) => {
+import axios from '@/libs/axios.js'
+
+// 数据统计信息
+export const bizData = (params) => {
+  return axios.request({
+    url: `home/queryBizData`,
+    data: params,
+    method: 'post'
+  })
+}
+
+// 销售单列表
+export const salesList = (params) => {
+  const url = `sales/queryPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios.request({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+//  销售 审核
+export const salesWriteAudit = (params) => {
+  return axios.request({
+    url: 'sales/audit',
+    data: params,
+    method: 'post'
+  })
+}
+//  销售 出库
+export const salesWriteStockOut = (params) => {
+  return axios.request({
+    url: `sales/stockOut/${params.salesBillSn}`,
+    method: 'get'
+  })
+}
+//  销售 删除
+export const salesDel = (params) => {
+  return axios.request({
+    url: `sales/delete/${params.id}`,
+    data: params,
+    method: 'post'
+  })
+}
+//  销售详情 列表  分页
+export const salesDetailList = (params) => {
+  const url = `salesDetail/queryPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios.request({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+//  销售详情 删除
+export const salesDetailDel = (params) => {
+  return axios.request({
+    url: `salesDetail/delete/${params.id}`,
+    method: 'get'
+  })
+}
+
+// 销售单新增
+export const salesSave = (params) => {
+  const url = 'sales/save'
+  return axios.request({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+
+//  仓库列表  无分页
+export const warehouseAllList = (params) => {
+  const url = 'warehouse/queryList'
+  return axios.request({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+// 车架号  识别图片内容
+export const vinCodeParse = params => {
+  return axios.request({
+    url: `vinIdentify/ocr`,
+    method: 'post',
+    data: params,
+    responseType: 'blob'
+  })
+}
+
+// 产品报价列表
+export const dealerProductList = (params) => {
+  const url = `dealerProduct/queryPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios.request({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+//  结算方式列表
+export const settleStyleQueryAll = (params) => {
+  return axios.request({
+    url: 'settleStyle/findAll',
+    data: params,
+    method: 'post'
+  })
+}
+
+// 客户列表
+export const customerList = (params) => {
+	const url=`cust/queryPage/${params.pageNo}/${params.pageSize}`
+	delete params.pageNo
+	delete params.pageSize
+	return axios.request({
+		url: url,
+		data: params,
+		method: 'post'
+	})
+}
+
+// 新增客户
+export const custSave = (params) => {
   return axios.request({
-    url: `home/queryBizData`,
+    url: 'cust/save',
     data: params,
     method: 'post'
   })
-}
-
-// 销售单列表
-export const salesList = (params) => {
-  const url = `sales/queryPage/${params.pageNo}/${params.pageSize}`
-  delete params.pageNo
-  delete params.pageSize
+} 
+ // 客户详情
+export const customerDetail = params => {
   return axios.request({
-    url: url,
-    data: params,
-    method: 'post'
-  })
-}
-//  销售 审核
-export const salesWriteAudit = (params) => {
-  return axios.request({
-    url: 'sales/audit',
-    data: params,
-    method: 'post'
-  })
-}
-//  销售 出库
-export const salesWriteStockOut = (params) => {
-  return axios.request({
-    url: `sales/stockOut/${params.salesBillSn}`,
+    url: `cust/findById/${params.id}`,
+    data: {},
     method: 'get'
   })
-}
-//  销售 删除
-export const salesDel = (params) => {
+}

+// 客户类型
+export const custType = (params) => {
   return axios.request({
-    url: `sales/delete/${params.id}`,
+    url: 'custType/findAll',
     data: params,
     method: 'post'
   })
-}
-//  销售详情 列表  分页
-export const salesDetailList = (params) => {
-  const url = `salesDetail/queryPage/${params.pageNo}/${params.pageSize}`
-  delete params.pageNo
-  delete params.pageSize
+} 
+
+// h业务员
+export const employeeAllList = (params) => {
   return axios.request({
-    url: url,
-    data: params,
-    method: 'post'
-  })
-}
-//  销售详情 删除
-export const salesDetailDel = (params) => {
-  return axios.request({
-    url: `salesDetail/delete/${params.id}`,
-    method: 'get'
-  })
-}
-//  仓库列表  无分页
-export const warehouseAllList = (params) => {
-  const url = 'warehouse/queryList'
-  return axios.request({
-    url: url,
-    data: params,
-    method: 'post'
-  })
-}
-// 车架号  识别图片内容
-export const vinCodeParse = params => {
-  return axios.request({
-    url: `vinIdentify/ocr`,
-    method: 'post',
-    data: params,
-    responseType: 'blob'
-  })
-}
-
-// 产品报价列表
-export const dealerProductList = (params) => {
-  const url = `dealerProduct/queryPage/${params.pageNo}/${params.pageSize}`
-  delete params.pageNo
-  delete params.pageSize
-  return axios.request({
-    url: url,
-    data: params,
-    method: 'post'
-  })
-}
-//  结算方式列表
-export const settleStyleQueryAll = (params) => {
-  return axios.request({
-    url: 'settleStyle/findAll',
-    data: params,
+    url: 'employee/queryList',
+    data: {},
     method: 'post'
   })
-}
-
-// 客户列表
-export const customerList = (params) => {
-	const url=`cust/queryPage/${params.pageNo}/${params.pageSize}`
-	delete params.pageNo
-	delete params.pageSize
-	return axios.request({
-		url: url,
-		data: params,
-		method: 'post'
-	})
 }

+ 444 - 0
components/address.vue

@@ -0,0 +1,444 @@
+<template>
+	<view class="simple-address" v-if="showPopup">
+		<!-- 遮罩层 -->
+		<view
+			class="simple-address-mask"
+			v-if="maskClick"
+			:class="[ani + '-mask', animation ? 'mask-ani' : '']"
+			:style="{
+				'background-color': maskBgColor
+			}"
+			@tap="hideMask(true)"
+		></view>
+		
+		<!-- 省市区 -->
+		<view class="simple-address-content simple-address--fixed" :class="[type, ani + '-content', animation ? 'content-ani' : '']">
+			<view class="simple-address__header">
+				<view class="simple-address__header-btn-box" @click="pickerCancel">
+					<text class="simple-address__header-text" :style="{ color: cancelColor, fontSize: btnFontSize }">取消</text>
+				</view>
+				<view class="simple-address__header-btn-box" @click="pickerConfirm">
+					<text class="simple-address__header-text" :style="{ color: confirmColor, fontSize: btnFontSize }">确定</text>
+				</view>
+			</view>
+			<view class="simple-address__box">
+				<picker-view class="simple-address-view" :value="pickerValue" @change="pickerChange">
+					<picker-view-column>
+						<!-- #ifndef APP-NVUE -->
+						<view class="picker-item" :style="{ fontSize: fontSize }" v-for="(item, index) in provinceDataList" :key="index">{{ item.name }}</view>
+						<!-- #endif -->
+						<!-- #ifdef APP-NVUE -->
+						<text class="picker-item" :style="{ fontSize: fontSize }" v-for="(item, index) in provinceDataList" :key="index">{{ item.name }}</text>
+						<!-- #endif -->
+					</picker-view-column>
+					<picker-view-column>
+						<!-- #ifndef APP-NVUE -->
+						<view class="picker-item" :style="{ fontSize: fontSize }" v-for="(item, index) in cityDataList" :key="index">{{ item.name }}</view>
+						<!-- #endif -->
+						<!-- #ifdef APP-NVUE -->
+						<text class="picker-item" :style="{ fontSize: fontSize }" v-for="(item, index) in cityDataList" :key="index">{{ item.name }}</text>
+						<!-- #endif -->
+					</picker-view-column>
+					<picker-view-column>
+						<!-- #ifndef APP-NVUE -->
+						<view class="picker-item" :style="{ fontSize: fontSize }" v-for="(item, index) in areaDataList" :key="index">{{ item.name }}</view>
+						<!-- #endif -->
+						<!-- #ifdef APP-NVUE -->
+						<text class="picker-item" :style="{ fontSize: fontSize }" v-for="(item, index) in areaDataList" :key="index">{{ item.name }}</text>
+						<!-- #endif -->
+					</picker-view-column>
+				</picker-view>
+			</view>
+		</view>
+		
+	</view>
+</template>
+
+<script>
+	import { getProvince, getCityByPro, getDistrictByCity } from '@/api/data.js'
+	import {getArea} from '@/api/data.js'
+	export default{
+		name: 'Address',
+		props: {
+			// 是否允许点击遮罩层关闭
+			maskClick: {
+				type: Boolean,
+				default: true
+			},
+			// 是否开启动画
+			animation: {
+				type: Boolean,
+				default: true
+			},
+			//  遮罩层背景颜色
+			maskBgColor: {
+				type: String,
+				default: 'rgba(0, 0, 0, 0.4)' //背景颜色 rgba(0, 0, 0, 0.4) 为空则调用 uni.scss
+			},
+			/* 弹出层类型,可选值;  暂时只支持底部弹出
+					bottom:底部弹出层
+				*/
+			type: {
+				type: String,
+				default: 'bottom'
+			},
+			cancelColor: {
+				type: String,
+				default: '' // 取消按钮颜色
+			},
+			confirmColor: {
+				type: String,
+				default: '' // 确认按钮颜色
+			},
+			fontSize: {
+				type: String,
+				default: '28rpx' // picker-item字体大小
+			},
+			btnFontSize: {
+				type: String,
+				default: '' // 按钮的字体大小
+			},
+		},
+		data(){
+			return{
+				showPopup: false,  //  是否显示省市区选择
+				ani: '',
+				pickerValue: [0, 0, 0],  //  默认值下标
+				pickerId: [],  //  省市区默认值id
+				provinceDataList: [],  //  省数据列表
+				cityDataList: [],  //  市数据列表
+				areaDataList: [],  //  区数据列表
+				isFirst: false,  //  是否首次进入组件
+			}
+		},
+		methods: {
+			//  初始化
+			init(){
+				this.provinceDataList = []
+				this.cityDataList = []
+				this.areaDataList = []
+				this.isFirst = false
+			},
+			//  点击遮罩层关闭选择省市区
+			hideMask() {
+				this._$emit('onCancel')
+				this.close()
+			},
+			//  打开省市区picker
+			open(idArr) {
+				//  初始化数据
+				this.init()
+				this.pickerId = idArr
+				//  idArr 省市区默认id
+				if(this.pickerId && this.pickerId.length > 0){
+					//  获取省下拉
+					this.getProvinceList(idArr)
+				}else{
+					//  获取省下拉
+					this.getProvinceList()
+				}
+				this.showPopup = true
+				this.$nextTick(() => {
+					setTimeout(() => {
+						this.ani = 'simple-' + this.type
+					}, 100)
+				});
+			},
+			//  关闭省市区picker
+			close(type) {
+				if (!this.maskClick && type) return
+				this.ani = ''
+				this.$nextTick(() => {
+					setTimeout(() => {
+						this.showPopup = false
+					}, 300)
+				})
+			},
+			//  取消按钮
+			pickerCancel() {
+				this._$emit('onCancel')
+				this.close()
+			},
+			//  确定按钮
+			pickerConfirm() {
+				this._$emit('onConfirm')
+				if(!this.isFirst){
+					//  首次
+					this.isFirst = true
+				}
+				this.close()
+			},
+			//  省市区  change
+			pickerChange(e) {
+				const _this = this
+				let changePickerValue = e.detail.value
+				console.log(changePickerValue,'changePickerValue')
+				if (this.pickerValue[0] !== changePickerValue[0]) {
+					if(this.pickerId && this.pickerId.length > 0 && this.isFirst){
+						//  获取市下拉
+						this.getCityList(this.pickerId[0], this.pickerId)
+					}else{
+						// 第一级发生滚动,省 change重置市区下拉数据
+						this.getCityList(this.provinceDataList[changePickerValue[0]].id)
+						changePickerValue[1] = 0
+						changePickerValue[2] = 0
+					}
+				} else if (this.pickerValue[1] !== changePickerValue[1]) {
+					if(this.pickerId && this.pickerId.length > 0 && this.isFirst){
+						//  获取市下拉
+						this.getAreaList(this.pickerId[1], this.pickerId)
+					}else{
+						// 第二级滚动,市 change重置区县下拉数据
+						this.getAreaList(this.cityDataList[changePickerValue[1]].id)
+						changePickerValue[2] = 0
+					}
+				}
+				this.pickerValue = changePickerValue
+				//  setTimeout解决由于省市区接口请求数据有延缓导致获值报错
+				setTimeout(()=>{
+					_this._$emit('onChange')
+				},1000)
+			},
+			_$emit(emitName) {
+				let pickObj = {
+					label: this._getLabel(),
+					value: this.pickerValue,
+					cityCode: this._getCityCode(),
+					areaCode: this._getAreaCode(),
+					provinceCode: this._getProvinceCode(),
+					labelArr: this._getLabel().split('-')
+				}
+				this.$emit(emitName, pickObj)
+			},
+			_getLabel() {
+				//  name报错未发现页面影响(由于省市区接口请求数据延缓)
+				let pcikerLabel =
+					this.provinceDataList[this.pickerValue[0]].name + '-' + this.cityDataList[this.pickerValue[1]].name + '-' + this.areaDataList[this.pickerValue[2]].name
+				return pcikerLabel
+			},
+			_getCityCode() {
+				return this.cityDataList[this.pickerValue[1]].id
+			},
+			_getProvinceCode() {
+				return this.provinceDataList[this.pickerValue[0]].id
+			},
+			_getAreaCode() {
+				return this.areaDataList[this.pickerValue[2]].id
+			},
+			//  获取省下拉数据
+			getProvinceList(idArr){
+				const _this = this
+				getArea({type:"2"}).then(res => {
+				  if (res.code == 200 || res.status == 204 || res.status == 200) {
+				    _this.provinceDataList = res.data || []  //  省下拉数据
+					//  判断是否有默认值
+					if(idArr){
+						_this.getCityList(idArr[0], idArr)
+						_this.getAreaIndArr(idArr)
+					}else{
+						//  默认省数据第一条下的市下拉数据
+						_this.getCityList(_this.provinceDataList[0].id)
+					}
+					
+				  } else {
+				    _this.provinceDataList = []
+				  }
+				})
+			},
+			// 获取城市列表
+			getCityList (val, idArr) {
+				const _this = this
+				_this.cityDataList = []
+				_this.areaDataList = []
+				if (val != null && val != '') {
+					getArea({parentId: val,type:3}).then(res => {
+						if (res.code == 200 || res.status == 204 || res.status == 200) {
+							_this.cityDataList = res.data || []  //  市下拉数据
+							//  判断是否有默认值
+							if(idArr){
+								_this.getAreaList(idArr[1], idArr)
+								_this.getAreaIndArr(idArr)
+							}else{
+								//  默认市数据第一条下的区县下拉数据
+								_this.getAreaList(_this.cityDataList[0].id)
+							}
+						} else {
+							_this.cityDataList = []
+						}
+					})
+				}
+			},
+			// 获取区县列表
+			getAreaList (val, idArr) {
+				const _this = this
+				this.areaDataList = []
+				if (val != null && val != '') {
+					getArea({parentId: val,type:4}).then(res => {
+						if (res.code == 200 || res.status == 204 || res.status == 200) {
+							_this.areaDataList = res.data || []
+							//  判断是否有默认值
+							if(idArr){ _this.getAreaIndArr(idArr) }
+						} else {
+							_this.areaDataList = []
+						}
+					})
+				}
+			},
+			//  根据id 获取省市区 下标值
+			getAreaIndArr(idArr){
+				const _this = this
+				const provinceInd = _this.provinceDataList.findIndex(res => res['id'] == idArr[0])
+				const cityInd = _this.cityDataList.findIndex(res => res['id'] == idArr[1])
+				const districtInd = _this.areaDataList.findIndex(res => res['id'] == idArr[2])
+				setTimeout(()=>{
+					_this.pickerValue = [provinceInd, cityInd, districtInd]
+				},100)
+				// console.log(_this.pickerValue,'_this.pickerValue')
+			}
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+.simple-address {
+	/* #ifndef APP-NVUE */
+	display: flex;
+	/* #endif */
+	flex-direction: column;
+}
+
+.simple-address-mask {
+	position: fixed;
+	bottom: 0;
+	top: 0;
+	left: 0;
+	right: 0;
+
+	transition-property: opacity;
+	transition-duration: 0.3s;
+	opacity: 0;
+	/* #ifndef APP-NVUE */
+	z-index: 99999;
+	/* #endif */
+}
+
+.mask-ani {
+	transition-property: opacity;
+	transition-duration: 0.2s;
+}
+
+.simple-bottom-mask {
+	opacity: 1;
+}
+
+.simple-center-mask {
+	opacity: 1;
+}
+
+.simple-address--fixed {
+	position: fixed;
+	bottom: 0;
+	left: 0;
+	right: 0;
+	width: 100%;
+	transition-property: transform;
+	transition-duration: 0.3s;
+	transform: translateY(460rpx);
+	/* #ifndef APP-NVUE */
+	z-index: 999999;
+	/* #endif */
+}
+
+.simple-address-content {
+	background-color: #ffffff;
+}
+
+.simple-content-bottom {
+	bottom: 0;
+	left: 0;
+	right: 0;
+	transform: translateY(500rpx);
+}
+
+.content-ani {
+	transition-property: transform, opacity;
+	transition-duration: 0.2s;
+}
+
+.simple-bottom-content {
+	transform: translateY(0);
+}
+
+.simple-center-content {
+	transform: scale(1);
+	opacity: 1;
+}
+
+.simple-address__header {
+	position: relative;
+	/* #ifndef APP-NVUE */
+	display: flex;
+	/* #endif */
+	flex-direction: row;
+	flex-wrap: nowrap;
+	justify-content: space-between;
+	border-bottom-color: #f2f2f2;
+	border-bottom-style: solid;
+	border-bottom-width: 1rpx;
+}
+
+.simple-address--fixed-top {
+	/* #ifndef APP-NVUE */
+	display: flex;
+	/* #endif */
+	flex-direction: row;
+	justify-content: space-between;
+	border-top-color: $uni-border-color;
+	border-top-style: solid;
+	border-top-width: 1rpx;
+}
+
+.simple-address__header-btn-box {
+	/* #ifndef APP-NVUE */
+	display: flex;
+	/* #endif */
+	flex-direction: row;
+	align-items: center;
+	justify-content: center;
+	height: 70rpx;
+}
+
+.simple-address__header-text {
+	text-align: center;
+	font-size: $uni-font-size-base;
+	color: #1aad19;
+	line-height: 70rpx;
+	padding-left: 40rpx;
+	padding-right: 40rpx;
+}
+
+.simple-address__box {
+	position: relative;
+}
+
+.simple-address-view {
+	position: relative;
+	bottom: 0;
+	left: 0;
+	/* #ifndef APP-NVUE */
+	width: 100%;
+	/* #endif */
+	/* #ifdef APP-NVUE */
+	width: 750rpx;
+	/* #endif */
+	height: 408rpx;
+	background-color: rgba(255, 255, 255, 1);
+}
+
+.picker-item {
+	text-align: center;
+	line-height: 70rpx;
+	text-overflow: ellipsis;
+	font-size: 28rpx;
+}
+</style>

+ 4 - 4
components/select/v-select.vue

@@ -1,8 +1,7 @@
 <template>
 	<picker @change="toChange" :value="index" :range="datalist" range-key="dispName">
 		<view style="display: flex;align-items: center;">
-			<input class="form-input" :disabled="disabled" v-model="selected" placeholder-class="form-input-placeholder" :placeholder="getPlaceholderText" />
-			<uni-font-icons size="12" type="icon-xiangyoujiantou" color="#9DA8B5"></uni-font-icons>
+			<input class="form-input" :disabled="disabled" style="width: 100%;" v-model="selected" placeholder-style="color:#C0C4CC" :placeholder="getPlaceholderText" />
 		</view>
 	</picker>
 </template>
@@ -46,6 +45,7 @@ export default {
     },
     getPlaceholderText () {
       let _this = this
+	  console.log(_this.lookUp,'_this.lookUp')
       for (let i = 0; i < _this.lookUp.length; i++) {
         if (_this.lookUp[i].code == _this.code) {
           if (this.placeholder === '') _this.placeholderText = _this.lookUp[i].name
@@ -61,11 +61,11 @@ export default {
         this.placeholderText = this.placeholder
       }
       getLookUpDatas({
-        type: this.code
+        lookupCode: this.code,pageNo:1,pageSize:1000
       }).then(result => {
 		  console.log(result, 'result')
         if (result && result.status + '' === '200') {
-          this.datalist = result.data
+          this.datalist = result.data.list
           
         }
       })

+ 7 - 0
pages.json

@@ -220,6 +220,13 @@
 				}
 			}
 		},
+		{
+			"path": "pages/sales/addSales", // 新增销售单
+			"style": {
+				"navigationBarTitleText": "新增销售单",
+				"enablePullDownRefresh": false
+			}
+		},
 		{
 			"path": "pages/sales/edit", // 新增销售单/编辑销售单/销售单详情
 			"style": {

+ 10 - 1
pages/common/customerSearch.vue

@@ -8,7 +8,7 @@
 			@clear="clearSearch"
 			:action-style="{'color': '#fff', 'font-size': '24upx', 'background-color': $config('primaryColor'), 'border-radius': '6upx', 'padding': '12upx 0'}">
 		</u-search>
-		<scroll-view class="picker-content flex_1" scroll-y>
+		<scroll-view class="picker-content flex_1" scroll-y v-if="isShow">
 			<view class="picker-main">
 				<view class="picker-main-item" v-for="(item, index) in listData" :key="item.id" @click="chooseItem(index)">
 					<view class="item-name">{{item.customerName}}</view>
@@ -31,6 +31,7 @@
 				queryWord:'',
 				pageSize:20,
 				pageNo:1,
+				isShow:true
 			}
 		},
 		methods:{
@@ -55,6 +56,14 @@
 				this.getData()
 			},
 			chooseItem(val){
+				console.log(val)
+				this.queryWord=this.listData[val].customerName
+				// uni.navigateTo({
+				// 	url:'/pages/sales/addSales'
+				// })
+				uni.navigateTo({
+					url:'/pages/sales/addSales?nowId='+this.listData[val].id
+				})
 				
 			}
 		}

+ 202 - 68
pages/sales/addCustomer.vue

@@ -1,49 +1,71 @@
 <template>
 	<view class="addCustomer-content">
 		<view class="content-form">
-			<u-form :model="form" ref="uForm" :rules="rules" label-width="180">
-				<u-form-item label="客户名称" required prop="customerName"><u-input v-model.trim="form.customerName" placeholder="请输入客户名称" input-align="right" /></u-form-item>
-				<u-form-item label="客户地址" required prop=""><u-input v-model="form.contactName" input-align="right" placeholder="客户地址"/></u-form-item>
-				<u-form-item label="联系电话"><u-input v-model.trim="form.contactTel" placeholder="请输入联系电话" input-align="right" /></u-form-item>
-				<u-form-item label="联系手机"><u-input v-model.trim="form.contactMobile" placeholder="请输入联系手机" input-align="right" /></u-form-item>
-				<u-form-item label="联系人"><u-input v-model="form.contactName" input-align="right" placeholder="请输入联系人"/></u-form-item>
-				<u-form-item label="详细地址"><u-input v-model.trim="form.customerAddr" type="textarea" placeholder="请输入详细地址" input-align="right" /></u-form-item>
-				<u-form-item label="客户传真"><u-input v-model="form.fax" input-align="right" placeholder="请输入客户传真"/></u-form-item>
-				<u-form-item label="配送方式"><u-input v-model="priceTypeName" input-align="right" :disabled="true" placeholder="请选择客户类型" @click="showCust=true"/></u-form-item>
-				<u-form-item label="客户类型"><u-input v-model="priceTypeName" input-align="right" :disabled="true" placeholder="请选择客户类型" @click="showCust=true"/></u-form-item>
-				<u-form-item label="价格类型" required prop=""></u-form-item>
+			<u-form :model="form" ref="uForm"  label-width="180" :error-type="['toast']">
+				<u-form-item label="客户名称" required ><u-input v-model.trim="form.customerName" placeholder="请输入客户名称(最多30个字符)" input-align="right" :maxlength="60"/></u-form-item>
+				<u-form-item label="客户地址" required >
+					<u-input v-model="areaInfo.label" :disabled="true" input-align="right" placeholder="请选择客户地址" @click="openAddress"/>
+					<u-icon name="arrow-right" color="#C0C4CC" slot="right"  @click="openAddress"></u-icon>
+				</u-form-item>
+				<u-form-item label="详细地址">
+					<textarea :auto-height="true" input-align="right" placeholder="请输入详细地址(最多60个字符)" :maxlength="60" v-model="form.customerAddr" class="receiveAddress" placeholder-style="color:#C0C4CC;font-size:28upx;"/>
+				</u-form-item>
+				<u-form-item label="联系人">
+					<u-input v-model="form.contactName" input-align="right" placeholder="请输入联系人(最多30个字符)" :maxlength="11"/>
+				</u-form-item>
+				<u-form-item label="联系电话">
+					<u-input v-model.trim="form.contactTel" placeholder="请输入联系电话(最多15个字符)" input-align="right" :maxlength="15"/>
+				</u-form-item>
+				<u-form-item label="联系手机"><u-input v-model.trim="form.contactMobile" placeholder="请输入联系手机(最多11位字符)" input-align="right" :maxlength="11"/>
+				</u-form-item>
+				<u-form-item label="价格类型" required >
+					<v-select ref="priceType" :disabled="true" placeholder="请选择价格类型" @itemChange="chooseType" code="PRICE_TYPE" style="width: 100%"></v-select>
+					<u-icon name="arrow-right" color="#C0C4CC" slot="right"></u-icon>
+				</u-form-item>
 				<u-form-item label="收款方式" required prop="settleStyleSn">
 					<u-input v-model="settleStyleName" input-align="right" :disabled="true" placeholder="请选择收款方式" @click="showSettle=true"/>
+					<u-icon name="arrow-right" color="#C0C4CC" slot="right"></u-icon>
+				</u-form-item>
+				<u-form-item label="客户传真">
+					<u-input v-model="form.fax" input-align="right" placeholder="请输入客户传真(最多30个字符)" :maxlength="30"/>
+				</u-form-item>
+				<u-form-item label="客户类型">
+					<u-input v-model="custTypeName" input-align="right" :disabled="true" placeholder="请选择客户类型"  @click="showCust=true"/>
+					<u-icon name="arrow-right" color="#C0C4CC" slot="right"  @click="showCust=true"></u-icon>
+				</u-form-item>
+				<u-form-item label="配送方式" >
+					<v-select ref="dispatchType" :disabled="true" placeholder="请选择配送方式" @itemChange="choosedispatchType" code="DISPATCH_TYPE" style="width: 100%"></v-select>
+					<u-icon name="arrow-right" color="#C0C4CC" slot="right" @click="chooseType"></u-icon>
 				</u-form-item>
 			</u-form>
 		</view>
 		<view class="form-footer-btn">
-			<u-button class="handle-btn" size="medium" shape="circle" hover-class="none" @click="handleSubmit" :custom-style="customBtnStyle">保存</u-button>
+			<u-button class="handle-btn" size="medium" shape="circle" hover-class="none" @click="customerSubmit" :custom-style="customBtnStyle">保存</u-button>
 		</view>
-		<!-- 配送方式 -->
-		<u-picker v-model="showDispatch" title="配送方式"  @confirm="dispatchTypeChange" :range="dispatchTypeList" range-key="name" mode="selector"></u-picker>
-		<!-- 价格类型 -->
-		<u-picker v-model="showDispatch" title="配送方式"  @confirm="dispatchTypeChange" :range="dispatchTypeList" range-key="name" mode="selector"></u-picker>
+		<!-- 省市区 -->
+		<Address ref="applyAddress" @onConfirm="areaConfirm"></Address>
 		<!-- 选择收款方式 -->
-		<u-picker v-model="showSettle" title="收款方式"  @confirm="settleStyleChange" :range="settleTypeList" range-key="name" mode="selector"></u-picker>
+		<u-picker v-model="showSettle" title="收款方式"  @confirm="settleStyleChange" :range="settleTypeList" range-key="name" mode="selector" :default-selector="JSON.parse(JSON.stringify(defaultSettleIndex))"></u-picker>
 		<!-- 客户类型 -->
-		<u-picker v-model="showCust" title="客户类型" @confirm="custTypeChange" :range="custTypeList" range-key="name" mode="selector"></u-picker>
+		<u-picker v-model="showCust" title="客户类型" @confirm="custTypeChange" :range="custTypeList" range-key="name" mode="selector" :default-selector="JSON.parse(JSON.stringify(defaultCustIndex))"></u-picker>
 	</view>
 </template>
 
 <script>
-	import {customerDetail,settleStyleQueryAll,custType} from '@/api/sales.js'
+	import {customerDetail,settleStyleQueryAll,custType,custSave,employeeAllList,salesSave} from '@/api/sales.js'
+	import { getLookUpDatas } from '@/api/data'
+	import Address from '@/components/address.vue'
 	import vSelect  from  '@/components/select/v-select.vue'
 	export default{
-		components: { vSelect },
+		components:{Address,vSelect},
 		data(){
 			return{
 				customerData:null, // 客户信息
 				priceTypeName:'', //客户类型名称
 				customBtnStyle: {  //  自定义按钮样式
-					backgroundColor: this.$config('primaryColor'),
-					color: '#fff'
+					margin:0
 				},
+				// 客户form
 				form:{
 					id: null,
 					customerName: '', // 客户名称
@@ -64,16 +86,7 @@
 					priceType: '', //  价格类型
 					settleStyleSn: undefined //  收款方式
 				},
-				rules:{
-					customerName: [{ required: true, message: '请输入客户名称', trigger: 'blur' }],
-					contactMobile: [{ required: false, pattern: /^\d{11}$/, message: '请输入正确的手机号', trigger: 'blur' }],
-					provinceSn: [{ required: true, message: '请选择省', trigger: 'change' }],
-					citySn: [{ required: true, message: '请选择市', trigger: 'change' }],
-					countySn: [{ required: true, message: '请选择区/县', trigger: 'change' }],
-					priceType: [{ required: true, message: '请选择价格类型', trigger: 'change' }],
-					settleStyleSn: [{ required: true, message: '请选择收款方式', trigger: 'change' }]
-				},
-				
+				distributionFlag:0, //铺货出库
 				showDispatch:false,// 配送方式下拉弹窗初始值
 				dispatchTypeList:[], // 配送方式列表
 				dispatchTypeName:'', // 配送方式名称
@@ -83,36 +96,98 @@
 				custTypeList:[] ,// 客户类型数据
 				showCust:false, //客户类型下拉弹窗初始值
 				custTypeName:'', // 客户类型名称
+				areaInfo: {},  //  省市区
+				areaIdArr: [],  //  省市区id数组
+				itemId:'',
+				ckList:[{dispName: "是",code:1,lookupCode: "FLAG"},{dispName: "否",code:0,lookupCode: "FLAG"}],
+				showUser:false,//业务员下拉框初始默认值
+				defaultSettleIndex:[0] ,//选中收款方式的下标
+				defaultIndex:[0] ,//选中收款方式的下标
+				defaultCustIndex:[0],//选中客户类型的下标
+				defaultUserIndex:[0],//选中业务员的下标
 			}
 		},
+		// 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
+		onReady() {
+			this.$refs.uForm.setRules(this.rules);
+		},
+		onUnload() {
+			this.$u.vuex("vuex_OrderAddress",{})
+		},
 		onLoad(option) {
+			console.log(option.nowId,'option')
 			this.getSettleStyle()
 			this.getCustomerList()
-			
 		},
 		methods:{
+			getCodeList(code){
+				getLookUpDatas({type:code}).then(res=>{
+					if(res.status==200){
+						this.dispatchTypeList=res.data
+						this.showDispatch=true
+					}
+				})
+			},
+			// getCustomerData(val){
+			// 	customerDetail({id:val}).then(res=>{
+			// 		if(res.status==200){
+			// 			this.customerData=res.data
+			// 			if(this.customerData.priceType || this.customerData.dispatchType){
+			// 				setTimeout(()=>{
+			// 					this.$refs.priceType.setVal(this.customerData.priceType)
+			// 					this.$refs.dispatchType.setVal(this.customerData.dispatchType)
+			// 				},200)
+							
+			// 			}
+			// 			this.form=Object.assign(this.form,res.data)
+			// 		}else{
+			// 			this.customerData=null
+			// 		}
+			// 	})
+			// },
+			getCodeByName (dispName) {
+			  return this.dispatchTypeList.find((item) => {
+			    return item.dispName == dispName
+			  })
+			},
+			// 重新选择
+			goBack(){
+				uni.navigateBack({})
+			},
+			radioChange(e) {
+				console.log(e);
+				this.distributionFlag=e
+			},
+			// 选择价格类型
+			chooseType(val){
+				console.log(val,'vai')
+				this.form.priceType=val
+			},
 			// 选择配送方式
-			chooseType(v){
-				console.log(v,'---------')
+			choosedispatchType(val){
+				this.form.dispatchType=val
+			},
+			//  选择省区市
+			areaConfirm(e) {
+				console.log('已选择的省市区', e)
+				this.areaInfo = e
+				this.areaIdArr = [ e.provinceCode, e.cityCode, e.areaCode ]
+				this.form.provinceSn=e.provinceCode
+				this.form.citySn=e.cityCode
+				this.form.countySn=e.areaCode
+				this.form.provinceName=e.labelArr[0]
+				this.form.cityName=e.labelArr[1]
+				this.form.countyName=e.labelArr[2]
 			},
-			// 下拉选择
-			selete(val){
-				if(val==0){
-					this.drownType='customer'
-				}else{
-					this.drownType='settle'
-				}
-				console.log(val,this.drownType)
-				setTimeout(()=>{
-					this.showSettle=true
-				},300)
-				
+			openAddress(){
+				//  省市区  回显     参数为省市区id数组
+				// console.log(this.areaIdArr,'this.areaIdArr')
+				this.$refs.applyAddress.open(this.areaIdArr)
 			},
 			brandClean(){
 				this.settleStyleName=''
 				this.form.settleStyleSn=undefined
 			},
-			// 获取配送方式
 			// 获取客户类型列表
 			getCustomerList(){
 				custType({}).then(res=>{
@@ -133,38 +208,79 @@
 					}
 				})
 			},
+			// 收款方式change
 			settleStyleChange(e){
 				console.log(e,'data')
+				this.defaultSettleIndex=[e]
 				this.settleStyleName=this.settleTypeList[e].name
 				this.form.settleStyleSn=this.settleTypeList[e].settleStyleSn
-				
 			},
 			custTypeChange(e){
-				this.priceTypeName=this.custTypeList[e].name
+				this.defaultCustIndex=[e]
+				this.custTypeName=this.custTypeList[e].name
+				this.form.customerTypeSn=this.custTypeList[e].customerTypeSn
+			},
+			userChange(e){
+				this.defaultUserIndex=[e]
+				this.custTypeName=this.custTypeList[e].name
 				this.form.customerTypeSn=this.custTypeList[e].customerTypeSn
 			},
-			// 保存
-			handleSubmit(){
+			// 保存 (新增客户)
+			customerSubmit(){
 				console.log('保存===========')
-				this.$refs.uForm.validate().then(res => {
-					if(res){
-						uni.$u.toast('校验通过')
+				this.$refs.uForm.validate(valid => {
+					if (valid) {
+						console.log('验证通过');
+						if (this.form.customerName ==='') {
+							uni.showToast({
+								title: '请输入客户名称',
+								icon: 'none'
+							})
+							return false
+						}
+						//  省市区
+						if(this.areaIdArr.length == 0){
+							uni.showToast({icon: 'none',title: '请选择省市区'})
+							return
+						}
+						if (this.form.priceType ==undefined) {
+							uni.showToast({
+								title: '请选择价格类型',
+								icon: 'none'
+							})
+							return false
+						}
+						if (this.form.settleStyleSn ==undefined) {
+							uni.showToast({
+								title: '请选择收款方式',
+								icon: 'none'
+							})
+							return false
+						}
+						const params=Object.assign({},this.form,this.areaIdArr)
+						console.log(params,'params')
+						if(this.form.id) {
+							params.id = this.form.id
+						}
+						custSave(params).then(res=>{
+							if(res.status == 200) {
+								uni.showToast({
+									title: res.message,
+									icon: 'none'
+								})
+								// uni.$emit('setFun',res.data)
+								setTimeout(()=>{
+									uni.navigateTo({
+										url:'/pages/sales/addSales?nowId='+res.data.id
+									})
+								},300)
+							} 
+						})
+					} else {
+						console.log('验证失败');
 					}
-					console.log(res,'--------------校验')
-					
-				}).catch(errors => {
-					uni.$u.toast('校验失败')
 				})
 			},
-			// getCustomerData(){
-			// 	customerDetail({id:this.itemId}).then(res=>{
-			// 		if(res.status==200){
-			// 			this.customerData=res.data
-			// 		}else{
-			// 			this.customerData=null
-			// 		}
-			// 	})
-			// }
 		}
 	}
 </script>
@@ -177,20 +293,38 @@
 		padding:0 40upx;
 		display: flex;
 		flex-direction: column;
+		.content-customerName{
+			// padding: 10upx;
+			// border-radius: 10upx;
+			// border: 1upx solid #e5e5e5;
+		}
 		.content-form{
 			flex: 1;
+			// box-shadow:0 8upx 24upx rgba(0,0,0,.1);
+			// border: 1upx solid #e5e5e5;
+			.receiveAddress{
+				width: 100%;
+				line-height: 1.5em;
+				box-sizing: border-box;
+				font-style: normal;
+				text-align: end;
+			}
 		}
 		.content-form:not(:last-child){
 			border-bottom: none;
 		}
 		.form-footer-btn{
+			background-color: #fff;
 			position: fixed;
 			bottom: 0;
 			left: 0;
 			width: 100%;
 			padding: 16upx 20upx 12upx;
+			z-index: 999;
 			.handle-btn{
 				width: 100%;
+				background-color: rgb(51, 95, 182);
+				color: #fff;
 			}
 		}
 	}

+ 583 - 0
pages/sales/addSales.vue

@@ -0,0 +1,583 @@
+<template>
+	<view class="addCustomer-content">
+		<view class="flex justify_between align_center content-customerName" v-if="itemId">
+			<text>{{customerData?customerData.customerName:''}}</text>
+			<u-button size="mini" :hair-line="false" plain type="primary" hover-class="none" @click="goBack" :custom-style="customBtnStyle">重新选择</u-button>
+		</view>
+		<view class="content-form">
+			<u-form :model="form" ref="uForm"  label-width="180" :error-type="['toast']">
+				<u-form-item label="客户地址" required >
+					<u-input v-model="areaInfo.label" :disabled="true" input-align="right" placeholder="请选择客户地址" @click="openAddress"/>
+					<u-icon name="arrow-right" color="#C0C4CC" slot="right"  @click="openAddress"></u-icon>
+				</u-form-item>
+				<u-form-item label="详细地址">
+					<textarea :auto-height="true" input-align="right" placeholder="请输入详细地址(最多60个字符)" :maxlength="60" v-model="form.shippingAddress" class="receiveAddress" placeholder-style="color:#C0C4CC;font-size:28upx;"/>
+				</u-form-item>
+				<u-form-item label="联系人">
+					<u-input v-model="form.consigneeName" input-align="right" placeholder="请输入联系人(最多30个字符)" :maxlength="11"/>
+				</u-form-item>
+				<u-form-item label="联系电话">
+					<u-input v-model.trim="form.consigneeTel" placeholder="请输入联系电话(最多15个字符)" input-align="right" :maxlength="15"/>
+				</u-form-item>
+				<u-form-item label="联系手机"><u-input v-model.trim="form.contactMobile" placeholder="请输入联系手机(最多11位字符)" input-align="right" :maxlength="11"/>
+				</u-form-item>
+				<u-form-item label="价格类型" required >
+					<v-select ref="priceType" :disabled="true" placeholder="请选择价格类型" @itemChange="chooseType" code="PRICE_TYPE" style="width: 100%"></v-select>
+					<u-icon name="arrow-right" color="#C0C4CC" slot="right"></u-icon>
+				</u-form-item>
+				<u-form-item label="收款方式" required prop="settleStyleSn">
+					<u-input v-model="settleStyleName" input-align="right" :disabled="true" placeholder="请选择收款方式" @click="showSettle=true"/>
+					<u-icon name="arrow-right" color="#C0C4CC" slot="right"></u-icon>
+				</u-form-item>
+				<u-form-item label="铺货出库" required v-if="itemId">
+					<view style="width: 100%;display:flex;justify-content: flex-end;">
+					<u-radio-group v-model="form.distributionFlag" @change="radioChange" >
+						<u-radio 
+							v-for="(item, index) in ckList" :key="index" 
+							:name="item.code"
+						>
+							{{item.dispName}}
+						</u-radio>
+					</u-radio-group>
+					</view>
+				</u-form-item>
+				<u-form-item label="配送方式" >
+					<v-select ref="dispatchType" :disabled="true" placeholder="请选择配送方式" @itemChange="choosedispatchType" code="DISPATCH_TYPE" style="width: 100%"></v-select>
+					<u-icon name="arrow-right" color="#C0C4CC" slot="right" @click="chooseType(0)"></u-icon>
+				</u-form-item>
+				<u-form-item label="业务员">
+					<u-input v-model="userName" input-align="right" :disabled="true" placeholder="请选择业务员"  @click="showUser=true"/>
+					<u-icon name="arrow-right" color="#C0C4CC" slot="right"  @click="showUser=true"></u-icon>
+				</u-form-item>
+				<u-form-item label="备注">
+					<textarea :auto-height="true" input-align="right" placeholder="请输入备注(最多100个字符)" :maxlength="100" v-model="form.remarks" class="receiveAddress" placeholder-style="color:#C0C4CC;font-size:28upx;"/>
+				</u-form-item>
+			</u-form>
+		</view>
+		<view class="form-footer-btn">
+			<u-button v-if="!itemId" class="handle-btn" size="medium" shape="circle" hover-class="none" @click="customerSubmit" :custom-style="customBtnStyle">保存</u-button>
+			<u-button v-else class="handle-btn" size="medium" shape="circle" hover-class="none" @click="salesSbmit" :custom-style="customBtnStyle">新增销售单</u-button>
+		</view>
+		<!-- 省市区 -->
+		<Address ref="applyAddress" @onConfirm="areaConfirm"></Address>
+		<!-- 选择收款方式 -->
+		<u-picker v-model="showSettle" title="收款方式"  @confirm="settleStyleChange" :range="settleTypeList" range-key="name" mode="selector" :default-selector="JSON.parse(JSON.stringify(defaultSettleIndex))"></u-picker>
+		<!-- 客户类型 -->
+		<u-picker v-model="showCust" title="客户类型" @confirm="custTypeChange" :range="custTypeList" range-key="name" mode="selector" :default-selector="JSON.parse(JSON.stringify(defaultCustIndex))"></u-picker>
+		<!-- 业务员 -->
+		<u-picker v-model="showUser" title="业务员" @confirm="userChange" :range="userList" range-key="name" mode="selector"></u-picker>
+	</view>
+</template>
+
+<script>
+	import {customerDetail,settleStyleQueryAll,custType,custSave,employeeAllList,salesSave} from '@/api/sales.js'
+	import { getLookUpDatas } from '@/api/data'
+	import { getArea } from '@/api/data'
+	import Address from '@/components/address.vue'
+	import vSelect  from  '@/components/select/v-select.vue'
+	export default{
+		components:{Address,vSelect},
+		data(){
+			return{
+				title:'',
+				customerData:null, // 客户信息
+				priceTypeName:'', //客户类型名称
+				customBtnStyle: {  //  自定义按钮样式
+					margin:0
+				},
+				showDispatch:false,// 配送方式下拉弹窗初始值
+				dispatchTypeList:[], // 配送方式列表
+				dispatchTypeName:'', // 配送方式名称
+				showSettle:false,//结算方式初始值
+				settleTypeList:[],//收款方式列表
+				settleStyleName:'',//收款方式名称
+				custTypeList:[] ,// 客户类型数据
+				showCust:false, //客户类型下拉弹窗初始值
+				custTypeName:'', // 客户类型名称
+				areaInfo: {},  //  省市区
+				areaIdArr: [],  //  省市区id数组
+				itemId:'',
+				ckList:[{dispName: "是",code:1,lookupCode: "FLAG"},{dispName: "否",code:0,lookupCode: "FLAG"}],
+				showUser:false,//业务员下拉框初始默认值
+				userList:[], //业务员数据
+				userName:'', //业务员姓名
+				salesManSn:'', //业务员sn
+				defaultSettleIndex:[0] ,//选中收款方式的下标
+				defaultIndex:[0] ,//选中收款方式的下标
+				defaultCustIndex:[0],//选中客户类型的下标
+				defaultUserIndex:[0],//选中业务员的下标
+				//销售单form
+				form:{
+					buyerName: '', // 客户名称
+					buyerSn: undefined, // 客户sn
+					consigneeTel: '', //  联系电话
+					contactMobile: '',
+					consigneeName: '', //  联系人
+					shippingAddressProvinceSn: undefined, //  省
+					shippingAddressProvinceName: '',
+					shippingAddressCitySn: undefined, // 市
+					shippingAddressCityName: '',
+					shippingAddressCountySn: undefined, // 区
+					shippingAddressCountyName: '',
+					shippingAddress: '', //  详细地址
+					fax: '', //  客户传真
+					dispatchType: undefined, //  配送方式
+					satelliteFlag: 0, //  是否卫星仓客户
+					priceType: undefined, //  价格类型
+					settleStyleSn: undefined, //  收款方式
+					salesManSn: undefined, //  业务员
+					salesManName: '',
+					distributionFlag: '0', // 铺货出库
+					salesTragetType: 'CUSTOMER',
+					remarks: '' ,//  备注
+					addrProvinceList:[],
+					addrDistrictList:[],
+					addrCityList:[]
+				}
+			}
+		},
+		// 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
+		onReady() {
+			this.$refs.uForm.setRules(this.rules);
+		},
+		onLoad(option) {
+			// uni.$on('setFun',this.setFun)
+			console.log(option.nowId,'option')
+			// this.form = this.$store.state.vuex_OrderAddress
+			// this.areaIdArr = this.form.receiveAreas.split(',')
+			// this.areaInfo.label = this.form.receiveAreasName.replace(/\,/g,'-')
+			if(option.nowId){
+				this.itemId=option.nowId
+				this.getCustomerData(this.itemId)
+				this.getUserAllList()
+				// setTimeout(()=>{
+				// 	const ind=this.settleTypeList.findIndex((item)=>{
+				// 		return item.settleStyleSn==this.customerData.settleStyleSn
+				// 	})
+				// 	console.log(ind,'ind')
+				// 	this.settleStyleName=this.settleTypeList[ind].name
+				// 	this.defaultSettleIndex=[ind]
+				// 	// if(this.customerData.customerSn){
+				// 	// 	const settleInd=this.custTypeList.findIndex((item)=>{
+				// 	// 		return item.customerSn==this.customerData.customerSn
+				// 	// 	})
+				// 	// 	this.custTypeName=this.custTypeList[settleInd].name
+				// 	// 	this.defaultCustIndex=[settleInd]
+				// 	// }
+				// 	console.log(ind,'a',JSON.parse(JSON.stringify(this.defaultSettleIndex)) )
+				// },200)
+			}
+			this.getSettleStyle()
+			this.getCustomerList()
+		},
+		onUnload() {
+			this.$u.vuex("vuex_OrderAddress",{})
+			// uni.$off('setFun',this.setFun)
+		},
+		methods:{
+			// 新增完客户将客户数据传过来
+			// setFun(data){
+			// 	console.log(data,'========页面传参')
+			// 	// if(data){
+			// 	// 	this.form = Object.assign(this.form, {
+			// 	// 	  buyerName: data.customerName, // 客户名称
+			// 	// 	  buyerSn: data.customerSn, // 客户sn
+			// 	// 	  consigneeTel: data.contactTel, //  联系电话
+			// 	// 	  contactMobile: data.contactMobile,
+			// 	// 	  consigneeName: data.contactName, //  联系人
+			// 	// 	  shippingAddressProvinceSn: data.provinceSn, //  省
+			// 	// 	  shippingAddressProvinceName: data.provinceName,
+			// 	// 	  shippingAddressCitySn: data.citySn, // 市
+			// 	// 	  shippingAddressCityName: data.cityName,
+			// 	// 	  shippingAddressCountySn: data.countySn, // 区
+			// 	// 	  shippingAddressCountyName: data.countyName,
+			// 	// 	  shippingAddress: data.customerAddr, //  详细地址
+			// 	// 	  fax: data.fax, //  客户传真
+			// 	// 	  dispatchType: data.dispatchType, //  配送方式
+			// 	// 	  satelliteFlag: data.satelliteFlag, //  是否卫星仓客户
+			// 	// 	  priceType: data.priceType, //  价格类型
+			// 	// 	  settleStyleSn: data.settleStyleSn //  收款方式
+			// 	// 	})
+			// 	// }
+			// },
+			getCodeList(code){
+				getLookUpDatas({type:code}).then(res=>{
+					if(res.status==200){
+						this.dispatchTypeList=res.data
+						this.showDispatch=true
+					}
+				})
+			},
+			getCustomerData(val){
+				customerDetail({id:val}).then(res=>{
+					if(res.status==200){
+						this.customerData=res.data
+						if (this.customerData.provinceSn) { this.getArea('city', this.customerData.provinceSn) }
+						if (this.customerData.citySn) { this.getArea('district', this.customerData.citySn) }
+						
+						// this.setFun(res.data)
+						this.form = Object.assign(this.form, {
+						  buyerName: this.customerData.customerName, // 客户名称
+						  buyerSn: this.customerData.customerSn, // 客户sn
+						  consigneeTel: this.customerData.contactTel, //  联系电话
+						  contactMobile: this.customerData.contactMobile,
+						  consigneeName: this.customerData.contactName, //  联系人
+						  shippingAddressProvinceSn: this.customerData.provinceSn, //  省
+						  shippingAddressProvinceName: this.customerData.provinceName,
+						  shippingAddressCitySn: this.customerData.citySn, // 市
+						  shippingAddressCityName: this.customerData.cityName,
+						  shippingAddressCountySn: this.customerData.countySn, // 区
+						  shippingAddressCountyName: this.customerData.countyName,
+						  shippingAddress: this.customerData.customerAddr, //  详细地址
+						  fax: this.customerData.fax, //  客户传真
+						  dispatchType: this.customerData.dispatchType, //  配送方式
+						  satelliteFlag: this.customerData.satelliteFlag, //  是否卫星仓客户
+						  priceType: this.customerData.priceType, //  价格类型
+						  settleStyleSn: this.customerData.settleStyleSn //  收款方式
+						})
+						if(this.customerData.priceType || this.customerData.dispatchType){
+							setTimeout(()=>{
+								this.$refs.priceType.setVal(this.customerData.priceType)
+								this.$refs.dispatchType.setVal(this.customerData.dispatchType)
+							},200)
+							
+						}
+						this.form=Object.assign(this.form,res.data)
+					}else{
+						this.customerData=null
+					}
+				})
+			},
+			// 获取城市列表
+			getCityList (val) {
+			  this.addrCityList = []
+			  this.addrDistrictList = []
+			  this.form.shippingAddressCitySn = undefined
+			  this.form.shippingAddressCityName = ''
+			  this.form.shippingAddressCountySn = undefined
+			  this.form.shippingAddressCountyName = ''
+			  if (val) {
+			    this.getArea('city', val)
+			    this.form.shippingAddressProvinceName = this.addrProvinceList.find(item => item.areaSn == val).name
+			  } else {
+			    this.form.shippingAddressProvinceName = ''
+			  }
+			},
+			// 获取区县列表
+			getAreaList (val) {
+			  this.addrDistrictList = []
+			  this.form.shippingAddressCountySn = undefined
+			  this.form.shippingAddressCountyName = ''
+			  if (val) {
+			    this.getArea('district', val)
+			    this.form.shippingAddressCityName = this.addrCityList.find(item => item.areaSn == val).name
+			  } else {
+			    this.form.shippingAddressCityName = ''
+			  }
+			},
+			// 区县变更
+			areaCharged (val) {
+			  if (val) {
+			    this.form.shippingAddressCountyName = this.addrDistrictList.find(item => item.areaSn == val).name
+			  } else {
+			    this.form.shippingAddressCountyName = ''
+			  }
+			},
+			//  省/市/区
+			getArea (leve, sn) {
+			  let params
+			  if (leve == 'province') {
+			    params = { type: '2' }
+			  } else {
+			    params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
+			  }
+			  getArea(params).then(res => {
+			    if (res.status == 200) {
+			      if (leve == 'province') {
+			        this.addrProvinceList = res.data || []
+			      } else if (leve == 'city') {
+			        this.addrCityList = res.data || []
+			      } else if (leve == 'district') {
+			        this.addrDistrictList = res.data || []
+			      }
+			    } else {
+			      if (leve == 'province') {
+			        this.addrProvinceList = []
+			      } else if (leve == 'city') {
+			        this.addrCityList = []
+			      } else if (leve == 'district') {
+			        this.addrDistrictList = []
+			      }
+			    }
+			  })
+			},
+			getCodeByName (dispName) {
+			  return this.dispatchTypeList.find((item) => {
+			    return item.dispName == dispName
+			  })
+			},
+			// 重新选择
+			goBack(){
+				uni.navigateBack({})
+			},
+			radioChange(e) {
+				console.log(e);
+				this.form.distributionFlag=e
+			},
+			// 选择价格类型
+			chooseType(val){
+				console.log(val,'vai')
+				this.form.priceType=val
+			},
+			// 选择配送方式
+			choosedispatchType(val){
+				this.form.dispatchType=val
+			},
+			//  选择省区市
+			areaConfirm(e) {
+				console.log('已选择的省市区', e)
+				this.areaInfo = e
+				this.areaIdArr = [ e.provinceCode, e.cityCode, e.areaCode ]
+				this.form.shippingAddressProvinceSn=e.provinceCode
+				this.form.shippingAddressCitySn=e.cityCode
+				this.form.shippingAddressCountySn=e.areaCode
+				this.form.shippingAddressProvinceName=e.labelArr[0]
+				this.form.shippingAddressCityName=e.labelArr[1]
+				this.form.shippingAddressCountyName=e.labelArr[2]
+			},
+			openAddress(){
+				//  省市区  回显     参数为省市区id数组
+				// console.log(this.areaIdArr,'this.areaIdArr')
+				this.$refs.applyAddress.open(this.areaIdArr)
+			},
+			brandClean(){
+				this.settleStyleName=''
+				this.form.settleStyleSn=undefined
+			},
+			// 获取业务员列表数据
+			getUserAllList () {
+			  employeeAllList({}).then(res => {
+			    if (res.status == 200) {
+			      this.userList = res.data || []
+			    } else {
+			      this.userList = []
+			    }
+			  })
+			},
+			// 获取客户类型列表
+			getCustomerList(){
+				custType({}).then(res=>{
+					if(res.status==200){
+						this.custTypeList=res.data
+					}else{
+						this.custTypeList=[]
+					}
+				})
+			},
+			// 获取结算方式列表
+			getSettleStyle(){
+				settleStyleQueryAll({}).then(res=>{
+					if(res.status==200){
+						this.settleTypeList=res.data
+					}else{
+						this.settleTypeList=null
+					}
+				})
+			},
+			// 收款方式change
+			settleStyleChange(e){
+				console.log(e,'data')
+				this.defaultSettleIndex=[e]
+				this.settleStyleName=this.settleTypeList[e].name
+				if(this.itemId){
+					this.form.settleStyleSn=this.settleTypeList[e].settleStyleSn
+				}else{
+					this.form.settleStyleSn=this.settleTypeList[e].settleStyleSn
+				}
+				
+				
+			},
+			custTypeChange(e){
+				this.defaultCustIndex=[e]
+				this.custTypeName=this.custTypeList[e].name
+				this.form.customerTypeSn=this.custTypeList[e].customerTypeSn
+			},
+			userChange(e){
+				this.defaultUserIndex=[e]
+				this.custTypeName=this.custTypeList[e].name
+				this.form.customerTypeSn=this.custTypeList[e].customerTypeSn
+			},
+			// 保存 (新增客户)
+			customerSubmit(){
+				console.log('保存===========')
+				this.$refs.uForm.validate(valid => {
+					if (valid) {
+						console.log('验证通过');
+						if (this.form.customerName ==='') {
+							uni.showToast({
+								title: '请输入客户名称',
+								icon: 'none'
+							})
+							return false
+						}
+						//  省市区
+						if(this.areaIdArr.length == 0){
+							uni.showToast({icon: 'none',title: '请选择省市区'})
+							return
+						}
+						if (this.form.priceType ==undefined ) {
+							uni.showToast({
+								title: '请选择价格类型',
+								icon: 'none'
+							})
+							return false
+						}
+						if (this.form.settleStyleSn ==undefined) {
+							uni.showToast({
+								title: '请选择收款方式',
+								icon: 'none'
+							})
+							return false
+						}
+						const params=Object.assign({},this.form,this.areaIdArr)
+						console.log(params,'params')
+						if(this.form.id) {
+							params.id = this.form.id
+						}
+						custSave(params).then(res=>{
+							if(res.status == 200) {
+								uni.showToast({
+									title: res.message,
+									icon: 'none'
+								})
+								setTimeout(()=>{
+									uni.navigateBack()
+								},300)
+							} 
+						})
+					} else {
+						console.log('验证失败');
+					}
+				})
+			},
+			// 保存 (新增销售单)
+			salesSbmit(){
+				console.log('保存===========')
+				this.$refs.uForm.validate(valid => {
+					if (valid) {
+						console.log('验证通过');
+						if (this.form.customerName ==='') {
+							uni.showToast({
+								title: '请输入客户名称',
+								icon: 'none'
+							})
+							return false
+						}
+						//  省市区
+						if(this.areaIdArr.length == 0){
+							uni.showToast({icon: 'none',title: '请选择省市区'})
+							return
+						}
+						if (this.form.priceType ==undefined ||this.form.priceType =='') {
+							uni.showToast({
+								title: '请选择价格类型',
+								icon: 'none'
+							})
+							return false
+						}
+						if (this.form.settleStyleSn ==undefined) {
+							uni.showToast({
+								title: '请选择收款方式',
+								icon: 'none'
+							})
+							return false
+						}
+						const params={
+							buyerName:this.customerData.customerName , // 客户名称
+							buyerSn: this.customerData.customerSn, // 客户sn
+							consigneeTel: this.form.consigneeTel?this.form.consigneeTel: this.customerData.contactTel, //  联系电话
+							contactMobile:this.form.contactMobile?this.form.contactMobile: this.customerData.contactMobile, // 联系手机
+							consigneeName:this.form.consigneeName?this.form.consigneeName: this.customerData.contactName, //  联系人
+							shippingAddressProvinceSn:this.form.shippingAddressProvinceSn?this.form.shippingAddressProvinceSn: this.customerData.provinceSn, //  省
+							shippingAddressProvinceName:this.form.shippingAddressProvinceName?this.form.shippingAddressProvinceName: this.customerData.customerName,
+							shippingAddressCitySn:this.form.shippingAddressCitySn?this.form.shippingAddressCitySn: this.customerData.citySn, // 市
+							shippingAddressCityName:this.form.shippingAddressCityName?this.form.shippingAddressCityName: this.customerData.cityName,
+							shippingAddressCountySn:this.form.shippingAddressCountySn?this.form.shippingAddressCountySn: this.customerData.countySn, // 区
+							shippingAddressCountyName:this.form.shippingAddressCountyName?this.form.shippingAddressCountyName: this.customerData.countyName,
+							shippingAddress:this.form.customerAddr?this.form.customerAddr: this.customerData.customerAddr, //  详细地址
+							fax:this.form.fax?this.form.fax: this.customerData.fax, //  客户传真
+							dispatchType:this.form.dispatchType?this.form.dispatchType: this.customerData.dispatchType, //  配送方式
+							satelliteFlag: 0, //  是否卫星仓客户
+							priceType:this.form.priceType?this.form.priceType: this.customerData.priceType, //  价格类型
+							settleStyleSn:this.form.settleStyleSn?this.form.settleStyleSn: this.customerData.settleStyleSn, //  收款方式
+							salesManSn:this.salesManSn ||undefined, //  业务员
+							salesManName: '',
+							distributionFlag: '0', // 铺货出库
+							salesTragetType: 'CUSTOMER',
+							remarks: this.remarks //  备注
+						}
+						console.log(params,'params')
+						salesSave(params).then(res=>{
+							if(res.status == 200) {
+								uni.showToast({
+									title: res.message,
+									icon: 'none'
+								})
+								setTimeout(()=>{
+									uni.navigateBack()
+								},300)
+							} 
+						})
+					} else {
+						console.log('验证失败');
+					}
+				})
+			},
+		}
+	}
+</script>
+
+<style lang="scss">
+	.addCustomer-content{
+		width: 100%;
+		height: 100vh;
+		background-color: #fff;
+		padding:0 40upx;
+		display: flex;
+		flex-direction: column;
+		.content-customerName{
+			// padding: 10upx;
+			// border-radius: 10upx;
+			// border: 1upx solid #e5e5e5;
+		}
+		.content-form{
+			flex: 1;
+			// box-shadow:0 8upx 24upx rgba(0,0,0,.1);
+			// border: 1upx solid #e5e5e5;
+			.receiveAddress{
+				width: 100%;
+				line-height: 1.5em;
+				box-sizing: border-box;
+				font-style: normal;
+				text-align: end;
+			}
+		}
+		.content-form:not(:last-child){
+			border-bottom: none;
+		}
+		.form-footer-btn{
+			background-color: #fff;
+			position: fixed;
+			bottom: 0;
+			left: 0;
+			width: 100%;
+			padding: 16upx 20upx 12upx;
+			z-index: 999;
+			.handle-btn{
+				width: 100%;
+				background-color: rgb(51, 95, 182);
+				color: #fff;
+			}
+		}
+	}
+</style>

+ 7 - 2
pages/sales/chooseCustomer.vue

@@ -5,7 +5,7 @@
 			<view class="search-btn">
 				<text>没有搜索到?</text>
 				<text>点击</text>
-				<text>新增客户</text>
+				<text @click="addCustomer">新增客户</text>
 			</view>
 		</view>
 		<!-- 客户搜索框 -->
@@ -19,7 +19,12 @@
 		components:{customerSearch},
 		data(){
 			return{
-				
+				// 新增客户
+				addCustomer(){
+					uni.navigateTo({
+						url:'/pages/sales/addCustomer'
+					})
+				}
 			}
 		}
 	}

+ 0 - 1
pages/sales/search.vue

@@ -1,7 +1,6 @@
 <template>
 	<view class="modal-box">
 		<u-popup v-model="isShow"  @close="isShow=false" mode="right" length="85%" >
-			<view class="search-title">查询</view>
 			<u-form :model="form" ref="uForm" label-width="180" class="form-content">
 				<u-form-item label="产品编码"><u-input v-model.trim="form.productCode" placeholder="请输入产品编码" input-align="right" /></u-form-item>
 				<u-form-item label="原厂编码"><u-input v-model.trim="form.productOrigCode" placeholder="请输入原厂编码" input-align="right" /></u-form-item>

+ 3 - 1
store/index.js

@@ -101,7 +101,9 @@ const store = new Vuex.Store({
 		vuex_reConnectId: null, // 重连id
 		vuex_messagUnReadCount: 0, // 消息未读数
 		vuex_messagLaster: [], // 最新消息
-		vuex_lastBuleDevice: null
+		vuex_lastBuleDevice: null,
+		vuex_OrderAddress: {}, // 地址
+		vuex_allLookUp: [],  //  数据字典
 	},
 	mutations: {
 		$uStore(state, payload) {