| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418 | 
							- <!DOCTYPE html>
 
- <html>
 
- <head>
 
- 	<meta charset="utf-8">
 
- 	<title>新增经销商</title>
 
- 	<meta name="renderer" content="webkit">
 
- 	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
 
- 	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
 
- 	<meta name="apple-mobile-web-app-status-bar-style" content="black">
 
- 	<meta name="apple-mobile-web-app-capable" content="yes">
 
- 	<meta name="format-detection" content="telephone=no">
 
- 	<script type="text/javascript"
 
- 		src="https://webapi.amap.com/maps?v=1.4.15&key=388e4a971a8fb8d616e4a85d7deff144"></script>
 
- 	<link rel="stylesheet" type="text/css" href="../../layui/css/layui.css" />
 
- 	<link rel="stylesheet" type="text/css" href="../../css/common.css" />
 
- 	<style type="text/css">
 
- 		.ui-required:before {
 
- 			content: "*";
 
- 			color: red;
 
- 			vertical-align: middle;
 
- 		}
 
- 		#roleSelectViwe .layui-form-item {
 
- 			margin-bottom: 0
 
- 		}
 
- 		#roleSelectViwe .layui-input-inline {
 
- 			width: calc(100% - 110px);
 
- 			margin-right: 0;
 
- 		}
 
- 		.region {
 
- 			padding-left: 10px;
 
- 			height: 38px;
 
- 			line-height: 38px;
 
- 			background-color: #fff;
 
- 			border-radius: 2px;
 
- 			border: 1px solid #e6e6e6;
 
- 			width: 100% !important;
 
- 			width: calc(100% - 132px) !important;
 
- 		}
 
- 		.userTip {
 
- 			color: #666;
 
- 			font-size: 12px;
 
- 		}
 
- 		.userTip b {
 
- 			color: #333;
 
- 		}
 
- 		.amap {
 
- 			width: 658px;
 
- 			height: 300px;
 
- 			margin-left: 110px;
 
- 		}
 
- 	</style>
 
- 	<script type="text/html" id="typeHtmlTpl">
 
- 		<option value="">请选择</option>
 
- 		{{# if(!d.list){d.list = []}; layui.each(d.list, function(index, item){ }}
 
- 		<option value="{{item.guid}}">{{item.roleName}}</option>
 
- 		{{# }); }}
 
- 	</script>
 
- </head>
 
- <body>
 
- 	<form class="layui-form" action="" lay-filter="addForm" style="padding: 20px 20px 0 0">
 
- 		<h3 style="font-size:16px;margin:10px 20px 10px 20px;padding:10px 6px;border-bottom:1px dashed #ddd;">经销商信息</h3>
 
- 		<div class="layui-form-item">
 
- 			<label class="layui-form-label ui-required">经销商编码</label>
 
- 			<div class="layui-input-block">
 
- 				<input type="text" name="dealerCode" maxlength="32" lay-verify="required" placeholder="请输入经销商编码"
 
- 					autocomplete="off" class="layui-input" readonly="readonly">
 
- 			</div>
 
- 		</div>
 
- 		<div class="layui-form-item">
 
- 			<label class="layui-form-label ui-required">经销商名称</label>
 
- 			<div class="layui-input-block">
 
- 				<input type="text" name="dealerName" maxlength="32" lay-verify="required" placeholder="请输入经销商名称"
 
- 					autocomplete="off" class="layui-input">
 
- 			</div>
 
- 		</div>
 
- 		<div class="layui-form-item">
 
- 			<label class="layui-form-label ui-required">联系方式</label>
 
- 			<div class="layui-input-block">
 
- 				<input type="text" name="linkPhone" maxlength="11" lay-verify="required" placeholder="请输入联系电话"
 
- 					autocomplete="off" class="layui-input">
 
- 			</div>
 
- 		</div>
 
- 		<div class="layui-form-item">
 
- 			<label class="layui-form-label">备注说明</label>
 
- 			<div class="layui-input-block">
 
- 				<textarea type="text" name="remark" maxlength="200" autocomplete="off" class="layui-textarea"></textarea>
 
- 			</div>
 
- 		</div>
 
- 		<h3 style="font-size:16px;margin:10px 20px 10px 20px;padding:10px 6px;border-bottom:1px dashed #ddd;">地理位置标记</h3>
 
- 		<div class="layui-form-item">
 
- 			<label class="layui-form-label ui-required">产地地址</label>
 
- 			<div id="address" class="layui-input-block">
 
- 			</div>
 
- 		</div>
 
- 		<div class="layui-form-item">
 
- 			<div class="amap" id="container"></div>
 
- 		</div>
 
- 		<div class="layui-form-item layui-layer-btn">
 
- 			<div class="layui-input-block">
 
- 				<button type="reset" class="layui-btn layui-btn-primary" id="closeWin">取消</button>
 
- 				<button class="layui-btn" lay-submit lay-filter="formDemo">保存</button>
 
- 			</div>
 
- 		</div>
 
- 	</form>
 
- 	<script type="text/javascript">
 
- 		function loadJS(url) {
 
- 			document.write("<script src='" + url + "?ver=" + new Date().getTime() + "'><\/script>")
 
- 		}
 
- 		loadJS("../../layui/layui.js");
 
- 		loadJS("../../js/ajaxhook.min.js");
 
- 		loadJS("../../js/config.js");
 
- 	</script>
 
- 	<script type="text/javascript">
 
- 		layui.config({
 
- 			base: "../../js/layuiPlugins/"
 
- 		}).use(["form", 'layer', 'laytpl', 'jquery', 'cascade'], function () {
 
- 			var form = layui.form,
 
- 				layer = layui.layer,
 
- 				laytpl = layui.laytpl,
 
- 				cascade = layui.cascade,
 
- 				$ = layui.jquery;
 
- 			var funcName = "dealer";
 
- 			var formData = {
 
- 				guid: (JSON.stringify(location.searchObj()) != "{}") ? location.searchObj().guid || null : null, //带参传入ID
 
- 				roleTableDataId: "roleDataList", //数据ID
 
- 				current: {
 
- 					latitudeLongitude: ''
 
- 				}, //当前表单数据
 
- 				select_data: "select_" + funcName, //查询用户
 
- 				selectPId_dealer: "selectPId_" + funcName,
 
- 				save_data: (location.searchObj().guid ? 'edit' : 'add') + '_' + funcName, //查询用户
 
- 				formLayFilter: "addForm", //表单容器
 
- 				closeModal: function () { //关闭当前窗口
 
- 					parent.layer.close(parent.layer.getFrameIndex(window.name));
 
- 				}
 
- 			};
 
- 			//高德地图初始化
 
- 			var marker, map = new AMap.Map('container', {
 
- 				zoom: 11,//级别
 
- 				viewMode: '3D'//使用3D视图
 
- 			});
 
- 			AMap.plugin('AMap.ToolBar', function () {
 
- 				var toolbar = new AMap.ToolBar();
 
- 				map.addControl(toolbar)
 
- 			})
 
- 			//点击标记地图点
 
- 			map.on('click', function (e) {
 
- 				clearMarker();
 
- 				let lnglat = [e.lnglat.getLng(), e.lnglat.getLat()]
 
- 				marker = new AMap.Marker({
 
- 					icon: "//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png",
 
- 					position: lnglat,
 
- 					offset: new AMap.Pixel(-13, -30)
 
- 				});
 
- 				marker.setMap(map);
 
- 				formData.current.latitudeLongitude = lnglat.toString()
 
- 			});
 
- 			//设置标记点
 
- 			function setMarker(lnglat) {
 
- 				marker = new AMap.Marker({
 
- 					icon: "//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png",
 
- 					position: lnglat,
 
- 					offset: new AMap.Pixel(-13, -30)
 
- 				});
 
- 				marker.setMap(map);
 
- 			}
 
- 			//清空坐标点
 
- 			function clearMarker() {
 
- 				if (marker) {
 
- 					marker.setMap(null);
 
- 					marker = null;
 
- 				}
 
- 			}
 
- 			//类型下拉列表模板
 
- 			function typeTpl(obj) {
 
- 				laytpl(typeHtmlTpl.innerHTML).render(obj, function (html) {
 
- 					$(obj.elem).html(html);
 
- 					form.render();
 
- 				});
 
- 			}
 
- 			//初始化
 
- 			formData.main = function () {
 
- 				var _this = this;
 
- 				if (this.guid) {
 
- 					_this.getCurrent(_this.guid); //获取并初始化表单角色信息
 
- 				} else {
 
- 					_this.initialization();
 
- 				}
 
- 				if (location.searchObj().event == "view") {
 
- 					var el = document.getElementsByTagName("INPUT");
 
- 					for (var i = 0; i < el.length; i++) {
 
- 						el[i].readOnly = true;
 
- 					}
 
- 					el = document.getElementsByTagName("textarea");
 
- 					for (var i = 0; i < el.length; i++) {
 
- 						el[i].disabled = true;
 
- 					}
 
- 					el = document.getElementsByTagName("checkbox");
 
- 					for (var i = 0; i < el.length; i++) {
 
- 						el[i].disabled = true;
 
- 					}
 
- 					el = document.getElementsByTagName("button");
 
- 					for (var i = 0; i < el.length; i++) {
 
- 						if (el[i].innerText.replace(" ", "") == "保存") {
 
- 							el[i].style.display = "none";
 
- 						}
 
- 					}
 
- 				}
 
- 				return this;
 
- 			};
 
- 			//初始化
 
- 			formData.initialization = function () {
 
- 				var _this = this;
 
- 				//坐标设定
 
- 				if (!(formData.current.latitudeLongitude === "")) {
 
- 					let mapMark = formData.current.latitudeLongitude.split(",")
 
- 					setMarker(mapMark);
 
- 				}
 
- 				//新增->初始化编码
 
- 				if (!formData.current.dealerCode) {
 
- 					formData.getProductId();
 
- 				}
 
- 				//初始化地区
 
- 				cascade.render({
 
- 					elem: "#address",
 
- 					hostParm: {
 
- 						idName: 'parentId'
 
- 					},
 
- 					url: {
 
- 						provinceId: 'areaSearch',
 
- 						cityId: 'areaSearch',
 
- 						countyId: 'areaSearch'
 
- 					},
 
- 					listParamName: {
 
- 						valueName: 'code',
 
- 						name: 'name'
 
- 					},
 
- 					width: {
 
- 						provinceId: '8em',
 
- 						cityId: '8em',
 
- 						countyId: '8em',
 
- 						townId: '8em'
 
- 					}
 
- 				}).val({
 
- 					provinceId: this.current.provinceId,
 
- 					cityId: this.current.cityId,
 
- 					countyId: this.current.countyId
 
- 				});
 
- 				//监听提交
 
- 				form.on('submit(formDemo)', function (obj) {
 
- 					//必须return false;
 
- 					return _this.fusionData(obj.field).submitInfo(); //获取选中权限变数组,提交变化===下拉
 
- 				});
 
- 				//关闭窗口
 
- 				$("#closeWin").on("click", function () {
 
- 					_this.closeModal();
 
- 				});
 
- 				return _this;
 
- 			};
 
- 			//创建新的编码
 
- 			formData.getProductId = function () {
 
- 				var _this = this;
 
- 				$.ajax({
 
- 					url: this.selectPId_dealer,
 
- 					method: 'get',
 
- 					success: function (res) {
 
- 						_this.current.dealerCode = res.data[0].dealerCode;
 
- 						form.val(_this.formLayFilter, _this.current);
 
- 					}
 
- 				});
 
- 			}
 
- 			//获取当前信息
 
- 			formData.getCurrent = function (id) {
 
- 				var _this = this;
 
- 				$.ajax({
 
- 					url: this.select_data,
 
- 					method: 'get',
 
- 					data: {
 
- 						guid: id || this.guid //当前ID
 
- 					},
 
- 					success: function (res) {
 
- 						_this.current = res.data[0];
 
- 						_this.initialization().formVal();
 
- 					}
 
- 				});
 
- 				return _this;
 
- 			};
 
- 			//表单赋值
 
- 			formData.formVal = function () {
 
- 				var _this = this;
 
- 				form.val(this.formLayFilter, this.current);
 
- 				return this;
 
- 			};
 
- 			//合并表单内容
 
- 			formData.fusionData = function (obj) {
 
- 				this.current = $.extend(this.current, obj);
 
- 				if (this.current.guid) {
 
- 					delete this.current.password;
 
- 				}
 
- 				return this;
 
- 			};
 
- 			//提交新增修改
 
- 			formData.submitInfo = function () {
 
- 				var _this = this;
 
- 				if (!this.current.countyId || this.current.countyId == "") {
 
- 					layer.msg("必须选择省市县地址");
 
- 					return false;
 
- 				}
 
- 				this.current.fkPostionId = this.current.countyId;
 
- 				$.ajax({
 
- 					type: 'POST',
 
- 					url: this.save_data,//+'?userId='+this.guid
 
- 					data: JSON.stringify(this.current),
 
- 					contentType: 'application/json',
 
- 					success: function (res) {
 
- 						if (!(res.code - 0)) {
 
- 							parent.layer.msg(res.msg, {
 
- 								icon: 1
 
- 							});
 
- 							_this.closeModal();
 
- 						} else {
 
- 							layer.msg(res.msg, {
 
- 								icon: 2
 
- 							});
 
- 						}
 
- 					}
 
- 				});
 
- 				return false;
 
- 			};
 
- 			formData.main();
 
- 			//验证规则
 
- 			form.verify({
 
- 				nickname: function (value) {
 
- 					if (!new RegExp("^[a-zA-Z][a-zA-Z0-9_]*$").test(value)) {
 
- 						return '账号必须以英文字母开头,只能包含英文字母、数字、下划线';
 
- 					}
 
- 					if (/(^\_)|(\__)|(\_+$)/.test(value)) {
 
- 						return '账号首尾不能出现下划线\'_\'';
 
- 					}
 
- 				},
 
- 				checkName: function (value) {
 
- 				},
 
- 				phoneNumber: function (value) {
 
- 					if (value) {
 
- 						if (!(/^1[3|4|5|7|8]\d{9}$/).test(value)) {
 
- 							return '请输入正确的手机号码';
 
- 						}
 
- 					}
 
- 					return false;
 
- 				},
 
- 				password: function (value) {
 
- 					if (location.searchObj().guid) {
 
- 						if (value) {
 
- 							if (!(/^[\S]{6,12}$/).test(value)) {
 
- 								return '密码必须6到12位,且不能出现空格';
 
- 							}
 
- 						}
 
- 						return false;
 
- 					}
 
- 					if (!(/^[\S]{6,12}$/).test(value)) {
 
- 						return '密码必须6到12位,且不能出现空格';
 
- 					}
 
- 				},
 
- 				resspaword: function (value) {
 
- 					var pass = $('#L_pass').val();
 
- 					if (value != pass) {
 
- 						return '两次密码不一致';
 
- 					}
 
- 				},
 
- 				ageLength: [
 
- 					/^[0-9]{0,2}$/,
 
- 					'年龄必须0到2位,且只能是数字'
 
- 				],
 
- 				jobLength: [
 
- 					/^[a-z\A-Z\u4e00-\u9fa5_]{0,10}$/,
 
- 					'职务必须是0-10位,且不包含特殊字符与数字'
 
- 				],
 
- 				workUnit: [
 
- 					/^[0-9\a-z\A-Z\u4e00-\u9fa5_]{0,25}$/,
 
- 					'工作单位必须是0-25位,且不包含特殊字符'
 
- 				],
 
- 				vcode: [
 
- 					/^[\w]{4,5}$/,
 
- 					'验证码不符合规则'
 
- 				]
 
- 			});
 
- 		});
 
- 	</script>
 
- </body>
 
- </html>
 
 
  |