因?yàn)槲业氖强偳鍐?,然后點(diǎn)擊后里面生成苗木頁面(默認(rèn)有一個(gè)苗木),他們關(guān)系是1對多,總清單結(jié)束時(shí)間默認(rèn)是當(dāng)天,苗木的結(jié)束時(shí)間不能超過總清單的結(jié)束時(shí)間

添加苗木下面有添加苗木按鈕
js
代碼開始:
#初始化清單上的結(jié)束時(shí)間
var endTime = laydate.render({
? ? ? ? elem: '#endTime', //選擇需要初始化時(shí)間控件的元素(dom或者JQdou 都可以)
? ? ? ? min: getNowFormatDate() - 1,//設(shè)置一個(gè)默認(rèn)最大值
? ? ? ? value: new Date(), //設(shè)置默認(rèn)值
? ? ? ? done: function(value,date){ //添加回調(diào)事件
? ? ? ? ? ? laydateDestory() //調(diào)用銷毀所有苗木里結(jié)束時(shí)間控件方法
? ? ? ? ? ? for (let i = 0; i < $(".endTime").length; i++) {
? ? ? ? ? ? ? ? if ($(".endTime")[i].value >= value) {
? ? ? ? ? ? ? ? ? ? console.log($(".endTime")[i].value)
? ? ? ? ? ? ? ? ? ? laydate.render({
? ? ? ? ? ? ? ? ? ? ? ? elem: $(".endTime")[i],
? ? ? ? ? ? ? ? ? ? ? ? min: getNowFormatDate() - 1,//設(shè)置一個(gè)默認(rèn)最小值
? ? ? ? ? ? ? ? ? ? ? ? max: $("#endTime").val(),
? ? ? ? ? ? ? ? ? ? ? ? value: $("#endTime").val(),
? ? ? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? ? }else {
? ? ? ? ? ? ? ? ? ? console.log($(".endTime")[i].value)
? ? ? ? ? ? ? ? ? ? laydate.render({
? ? ? ? ? ? ? ? ? ? ? ? elem: $(".endTime")[i],
? ? ? ? ? ? ? ? ? ? ? ? min: getNowFormatDate() - 1,//設(shè)置一個(gè)默認(rèn)最小值
? ? ? ? ? ? ? ? ? ? ? ? max: $("#endTime").val(),
? ? ? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? });
//頁面加載時(shí),初始化第一個(gè)苗木的時(shí)間控件
? ? $(function () {?
? ? ? ? addTimePlugs()
? ? })
//為每個(gè)最后動(dòng)態(tài)生成的頁面里的結(jié)束時(shí)間初始化時(shí)間控件
? ? function addTimePlugs() {
? ? ? ? laydate.render({
? ? ? ? ? ? elem: $('.endTime')[$('.endTime').length - 1],
? ? ? ? ? ? min: getNowFormatDate() - 1,//設(shè)置一個(gè)默認(rèn)最大值
? ? ? ? ? ? max: $("#endTime").val(),
? ? ? ? ? ? value: $("#endTime").val(),
? ? ? ? });
? ? }
//獲取當(dāng)前時(shí)間
? ? function getNowFormatDate() {
? ? ? ? var date = new Date();
? ? ? ? var seperator1 = "-";
? ? ? ? var seperator2 = ":";
? ? ? ? var month = date.getMonth() + 1;
? ? ? ? var strDate = date.getDate() + 1;
? ? ? ? if (month >= 1 && month <= 9) {
? ? ? ? ? ? month = "0" + month;
? ? ? ? }
? ? ? ? if (strDate >= 0 && strDate <= 9) {
? ? ? ? ? ? strDate = "0" + strDate;
? ? ? ? }
? ? ? ? var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
? ? ? ? ? ? + " " + date.getHours() + seperator2 + date.getMinutes()
? ? ? ? ? ? + seperator2 + date.getSeconds();
? ? ? ? return currentdate;
? ? }
//銷毀所有的苗木里結(jié)束時(shí)間控件的方法
? ? function laydateDestory() {
? ? ? ? var endTimeClone = $(".endTime").clone(true);//復(fù)制所有苗木頁面節(jié)點(diǎn)(復(fù)制后的是沒有時(shí)間控件的,不過有l(wèi)ay-key屬性)
? ? ? ? for (var i = 0; i < endTimeClone.length; i++) {
? ? ? ? ? ? $(endTimeClone[i]).attr("lay-key",null)? //每次初始化時(shí)間控件會(huì)自動(dòng)生成一個(gè)lay-key的值,復(fù)制時(shí)把此值也復(fù)制了,所以需要清空此值
? ? ? ? ? ? $(".endTime").get(i).replaceWith(endTimeClone[i])//替換頁面節(jié)點(diǎn)
? ? ? ? }
? ? }
js代碼結(jié)束
動(dòng)態(tài)生成頁面后頁面加載控件調(diào)用addTimePlugs()方法 生成控件
#endTime初始化時(shí)增加事件,如果值改變回調(diào)后先銷毀所有的(.endTime)控件,再生成新的控件
后面是整個(gè)頁面代碼:
@layout("/common/_container.html"){
? ? .purchase_add_sin {
padding:20px;
? ? ? ? box-sizing:border-box;
? ? ? ? position:relative;
? ? }
.purchase_add_sin >div {
background:#f3f2f2;
? ? }
.purchase_add_single {
}
.purchase_add_single_span {
vertical-align:middle;
? ? ? ? display:inline-block;
? ? ? ? width:12.5%;
? ? ? ? font-size:13px;
? ? ? ? font-weight:700;
? ? ? ? text-align:right;
? ? ? ? padding:20px 10px 20px 0;
? ? ? ? box-sizing:border-box;
? ? }
.purchase_add_single_div {
width:85%;
? ? ? ? display:inline-block;
? ? ? ? padding:20px 0;
? ? }
.purchase_add_single_div input {
background-color:#FFFFFF;
? ? ? ? background-image:none;
? ? ? ? border:1px solid #e5e6e7;
? ? ? ? border-radius:1px;
? ? ? ? margin-right:20px;
? ? ? ? color:inherit;
? ? ? ? padding:6px 12px;
? ? }
.purchase_add_single_div p {
width:100%;
? ? }
.purchase_add_single_div p span {
display:inline-block;
? ? ? ? width:12.5%;
? ? ? ? font-size:13px;
? ? ? ? text-align:right;
? ? ? ? padding:10px 10px 10px 0;
? ? ? ? box-sizing:border-box;
? ? }
.purchase_add_single_div p input {
margin-right:0;
? ? ? ? width:100px;
? ? }
.purchase_add_single_div_list p {
margin-top:20px;
? ? }
.purchase_add_single_div_list p span {
display:inline;
? ? }
.purchase_add_single_div_list p span i {
font-style:normal;
? ? ? ? margin-right:10px;
? ? ? ? padding:5px 10px;
? ? ? ? cursor:pointer;
? ? }
.purchase_add_single_div_list p span i.active {
background:#ccc;
? ? ? ? color:#ffffff;
? ? ? ? border-radius:3px;
? ? }
textarea {
resize:none
? ? }
.detele_btn {
display:inline-block;
? ? ? ? position:absolute;
? ? ? ? right:30px;
? ? ? ? top:30px;
? ? ? ? padding:10px;
? ? ? ? background:#b1b1b1 !important;
? ? ? ? border-radius:3px;
? ? ? ? color:#ffffff;
? ? ? ? cursor:pointer;
? ? }
.select_btn {
display:inline-block;
? ? ? ? padding:6px 12px;
? ? ? ? background:#b1b1b1 !important;
? ? ? ? border-radius:3px;
? ? ? ? color:#ffffff;
? ? ? ? cursor:pointer;
? ? }
.treeName{position:absolute;
? ? ? ? background:#ffffff;
? ? ? ? width:200px;? ? max-height:250px;
? ? ? ? overflow-y:auto;}
.treeName p{padding:5px;border-bottom:1px solid #f3f3f3;cursor:pointer;}
.col-sm-12{border-bottom:1px solid #efefef;}
<div class="ibox float-e-margins">
? ? <title>發(fā)布訂單分配
? ? <div class="ibox-content">
? ? ? ? <div class="form-horizontal">
? ? ? ? ? ? <input id="purchaseId" type="hidden" value="0">
? ? ? ? ? ? <div class="row">
? ? ? ? ? ? ? ? <h1 style="text-align:center"><p style="width:100%;background-color:rgba(159,159,157,0.9)">基本信息
? ? ? ? ? ? ? ? <div class="col-sm-6 b-r">
? ? ? ? ? ? ? ? ? ? <#input id="company" name="用苗公司*" underline="true" />
<#input id="name" name="負(fù)責(zé)人*" underline="true"/>
<#input id="endTime" name="截止時(shí)間*" underline="true" />
<#input id="projectName" name="項(xiàng)目名*" underline="true"/>
? ? ? ? ? ? ? ? <div class="col-sm-6">
? ? ? ? ? ? ? ? ? ? <div class="form-group">
? ? ? ? ? ? ? ? ? ? ? ? <label class="col-md-3 control-label" style="float:left;width:25%;">用苗地*
? ? ? ? ? ? ? ? ? ? ? ? <div class="col-sm-9">
? ? ? ? ? ? ? ? ? ? ? ? ? ? <select name="province" required id="province" class="form-control" style="width:30%;float:left;margin-right:15px;"? onclick="chooseMarket();">
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <option selected value="">選擇所在的省份
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? @for(province in provinces){
<option value="${province.id}">${province.name}
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? @}
? ? ? ? ? ? ? ? ? ? ? ? ? ? <select id="market" name="city" required class="form-control"? style="width:30%;float:left;margin-right:15px;" onclick="chooseArea();"? >
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <option selected value="">請選擇所在的市
? ? ? ? ? ? ? ? ? ? ? ? ? ? <select name="county" required id="area1" style="width:30%;float:left;margin-right:15px;" class="form-control">
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <option selected value="">請選擇所在的區(qū)/縣
? ? ? ? ? ? ? ? ? ? <div class="hr-line-dashed">
? ? ? ? ? ? ? ? ? ? <#input id="telephone" name="聯(lián)系電話*" underline="true"/>
<#input id="num" name="苗木品種數(shù)" underline="true" value="0" readonly="readonly"/>
? ? ? ? <div class="form-horizontal">
? ? ? ? ? ? <div class="row" id="purchase_add">
? ? ? ? ? ? ? ? <h1 style="text-align:center"><p style="width:100%;background-color:rgba(159,159,157,0.9)">添加苗木
? ? ? ? ? ? ? ? <div class="purchase_add_sin" class="col-sm-12">
? ? ? ? ? ? ? ? ? ? <div class="purchase_add_single">
? ? ? ? ? ? ? ? ? ? ? ? <span class="purchase_add_single_span">苗木名稱*
? ? ? ? ? ? ? ? ? ? ? ? <div class="purchase_add_single_div" style="position:relative;">
? ? ? ? ? ? ? ? ? ? ? ? ? ? <input type="text" id="treeName">
? ? ? ? ? ? ? ? ? ? ? ? ? ? <span class="select_btn">查詢
? ? ? ? ? ? ? ? ? ? ? ? ? ? <div class="treeName">
? ? ? ? ? ? ? ? ? ? <div class="purchase_add_single">
? ? ? ? ? ? ? ? ? ? ? ? <span class="purchase_add_single_span">集采數(shù)量*
? ? ? ? ? ? ? ? ? ? ? ? <div class="purchase_add_single_div">
? ? ? ? ? ? ? ? ? ? ? ? ? ? <input type="number" step="1" class="number">棵
? ? ? ? ? ? ? ? ? ? <div class="purchase_add_single">
? ? ? ? ? ? ? ? ? ? ? ? <span class="purchase_add_single_span">預(yù)估價(jià)格
? ? ? ? ? ? ? ? ? ? ? ? <div class="purchase_add_single_div">
? ? ? ? ? ? ? ? ? ? ? ? ? ? <input type="number" step="0.01" class="price">元/棵
? ? ? ? ? ? ? ? ? ? <div class="purchase_add_single">
? ? ? ? ? ? ? ? ? ? ? ? <span class="purchase_add_single_span">截止時(shí)間
? ? ? ? ? ? ? ? ? ? ? ? <div class="purchase_add_single_div">
? ? ? ? ? ? ? ? ? ? ? ? ? ? <input type="text" class="endTime" readonly>
? ? ? ? ? ? ? ? ? ? <div class="purchase_add_single">
? ? ? ? ? ? ? ? ? ? ? ? <span class="purchase_add_single_span" style="vertical-align:top;">備注
? ? ? ? ? ? ? ? ? ? ? ? <div class="purchase_add_single_div">
? ? ? ? ? ? ? ? ? ? ? ? ? ? <textarea name="" id="" style="width:70%;border-radius:3px;" rows="10" class="content" placeholder="備注說明">
? ? ? ? <div class="row btn-group-m-t">
? ? ? ? ? ? <div class="col-sm-10" style="text-align:center">
? ? ? ? ? ? ? ? <#button btnCss="info" name="添加苗木" id="ensure" icon="fa-check" clickFun=""/>
? ? ? ? <div class="col-sm-10" style="text-align:center">
? ? ? ? ? ? <div style="text-align:center">
? ? ? ? ? ? ? ? <#button btnCss="danger" name="返回" id="cancel" icon="fa-eraser" clickFun="PurchaseInfoDlg.close()"/>
? ? ? ? ? ? ? ? <button class="btn btn-info fa fa-save" id="submit_btn" style="font-size:20px;">保存
<script src="${ctxPath}/static/modular/system/purchase/purchase_info.js">
<script src="${ctxPath}/static/modular/system/purchasePlatform/purchasePlatform_info.js">
? ? var endTime =laydate.render({
elem:'#endTime',
? ? ? ? min:getNowFormatDate() -1,//設(shè)置一個(gè)默認(rèn)最大值
? ? ? ? value:new Date(),
? ? ? ? done:function(value,date){
laydateDestory()
for (let i =0; i <$(".endTime").length; i++) {
if ($(".endTime")[i].value >= value) {
console.log($(".endTime")[i].value)
laydate.render({
elem:$(".endTime")[i],
? ? ? ? ? ? ? ? ? ? ? ? min:getNowFormatDate() -1,//設(shè)置一個(gè)默認(rèn)最小值
? ? ? ? ? ? ? ? ? ? ? ? max:$("#endTime").val(),
? ? ? ? ? ? ? ? ? ? ? ? value:$("#endTime").val(),
? ? ? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? ? }else {
console.log($(".endTime")[i].value)
laydate.render({
elem:$(".endTime")[i],
? ? ? ? ? ? ? ? ? ? ? ? min:getNowFormatDate() -1,//設(shè)置一個(gè)默認(rèn)最小值
? ? ? ? ? ? ? ? ? ? ? ? max:$("#endTime").val(),
? ? ? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? ? }
}
}
});
? ? $(function () {
addTimePlugs()
})
function addTimePlugs() {
laydate.render({
elem:$('.endTime')[$('.endTime').length -1],
? ? ? ? ? ? min:getNowFormatDate() -1,//設(shè)置一個(gè)默認(rèn)最大值
? ? ? ? ? ? max:$("#endTime").val(),
? ? ? ? ? ? value:$("#endTime").val(),
? ? ? ? });
? ? }
function getNowFormatDate() {
var date =new Date();
? ? ? ? var seperator1 ="-";
? ? ? ? var seperator2 =":";
? ? ? ? var month = date.getMonth() +1;
? ? ? ? var strDate = date.getDate() +1;
? ? ? ? if (month >=1 && month <=9) {
month ="0" + month;
? ? ? ? }
if (strDate >=0 && strDate <=9) {
strDate ="0" + strDate;
? ? ? ? }
var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
+" " + date.getHours() + seperator2 + date.getMinutes()
+ seperator2 + date.getSeconds();
? ? ? ? return currentdate;
? ? }
function laydateDestory() {
var endTimeClone =$(".endTime").clone(true);
? ? ? ? for (var i =0; i < endTimeClone.length; i++) {
$(endTimeClone[i]).attr("lay-key",null)
$(".endTime").get(i).replaceWith(endTimeClone[i])
}
}
function bindClicks() {
//刪除按鈕綁定事件
? ? ? ? $(".detele_btn").bind("click", function () {
$(this).parent().remove()
})
//查詢按鈕綁定事件
? ? ? ? $(".select_btn").bind("click", function () {
var tempThis =this
? ? ? ? ? ? if ($(tempThis).prev().val().trim() =='') {
Feng.info("苗木名稱不能為空")
}else {
//查詢苗木名稱
? ? ? ? ? ? ? ? $.ajax({
type:'post',
? ? ? ? ? ? ? ? ? ? url: Feng.ctxPath +"/tree/getTrees",
? ? ? ? ? ? ? ? ? ? data: {
treeName:$(tempThis).prev().val().trim()
},
? ? ? ? ? ? ? ? ? ? success:function (data) {
//? ? ? ? ? ? ? ? ? ? ? ? console.log(data.data)
? ? ? ? ? ? ? ? ? ? ? ? var tempTreeNameP ='';
? ? ? ? ? ? ? ? ? ? ? ? for (var i =0; i < data.data.length; i++) {
tempTreeNameP +='<p data-treeId="' + data.data[i].treeId +'">' + data.data[i].treeName +''
? ? ? ? ? ? ? ? ? ? ? ? }
$(tempThis).next().html(tempTreeNameP)
$(tempThis).next().css("display", "block");
? ? ? ? ? ? ? ? ? ? ? ? //綁定選擇事件
? ? ? ? ? ? ? ? ? ? ? ? $('.treeName p').bind("click", function () {
var treeNameThis =this
? ? ? ? ? ? ? ? ? ? ? ? ? ? //查詢苗木標(biāo)簽
? ? ? ? ? ? ? ? ? ? ? ? ? ? $.ajax({
type:'post',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? url: Feng.ctxPath +"/tree/getStandards",
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? async:false,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? data: {
treeId:$(treeNameThis).attr("data-treeId")
},
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? success:function (data) {
console.log(data.data)
$(treeNameThis).parent().prev().prev().val($(treeNameThis).html())
$(treeNameThis).parent().css("display", "none");
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? var htmlSelectTemp ='';
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? htmlSelectTemp +='<div>';
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? htmlSelectTemp +='<div>';
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? htmlSelectTemp +='<span class="purchase_add_single_span">苗木名稱*</span><input class="input_name" type="text" data-treeId="' + data.data.treeId +'" value="' + data.data.treeName +'" disabled>';
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? htmlSelectTemp +='<div class="purchase_add_single_div" style="width:100%;">';
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? for (var i =0; i < data.data.standards.length; i++) {
htmlSelectTemp +='<p class="standards" data-standardId="' + data.data.standards[i].standardId +'"><span>' + data.data.standards[i].standardName +'</span><input type="number" class="minInput"> - <input class="maxInput" type="number"> cm</p>';
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
htmlSelectTemp +='</div>';
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? htmlSelectTemp +='</div>';
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? htmlSelectTemp +='<div class="purchase_add_single">';
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? htmlSelectTemp +='<span class="purchase_add_single_span" style="vertical-align: top;">苗木標(biāo)簽</span>';
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? htmlSelectTemp +='<div class="purchase_add_single_div purchase_add_single_div_list" style="padding-top:0;">';
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? for (var i =0; i < data.data.propertyAndTags.length; i++) {
htmlSelectTemp +='<p><span>' + data.data.propertyAndTags[i].name +'</span><span>';
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? for (var j =0; j < data.data.propertyAndTags[i].tags.length; j++) {
// if(j==0){
//? ? htmlSelectTemp += ''+data.data.propertyAndTags[i].tags[j].tagName+'';
// }else{
//? ? htmlSelectTemp += ''+data.data.propertyAndTags[i].tags[j].tagName+'';
// }
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? htmlSelectTemp +='<i data-tagId="' + data.data.propertyAndTags[i].tags[j].tagId +'">' + data.data.propertyAndTags[i].tags[j].tagName +'</i>';
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
htmlSelectTemp +='</span></p>';
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
htmlSelectTemp +='</div>';
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? htmlSelectTemp +='</div>';
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? htmlSelectTemp +='</div>';
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? $(treeNameThis).parent().parent().parent().next().remove()
$(treeNameThis).parent().parent().parent().after(htmlSelectTemp)
$(".purchase_add_single_div_list p span i").bind("click", function () {
$(this).parent().children().removeClass("active")
$(this).addClass("active")
})
}
})
})
},
? ? ? ? ? ? ? ? ? ? error:function (data) {
Feng.error("請求失??!")
}
})
}
})
}
$(function () {
//添加按鈕綁定事件
? ? ? ? bindClicks();
? ? ? ? //點(diǎn)擊保存按鈕
? ? ? ? $('#submit_btn').bind("click", function () {
var strObj = []
for (var i =0; i <$(".purchase_add_sin").length; i++) {
var strObjSingle = {}
strObjSingle.treeId =$(".purchase_add_sin").eq(i).find('.input_name').attr('data-treeId')//苗木id
? ? ? ? ? ? ? ? if (!strObjSingle.treeId) {
Feng.info("請搜索選擇苗木")
return
? ? ? ? ? ? ? ? }
strObjSingle.number =$(".purchase_add_sin").eq(i).find('.number').val()//集采數(shù)量
? ? ? ? ? ? ? ? if (strObjSingle.number ==0) {
Feng.info("請?zhí)顚憯?shù)量")
return
? ? ? ? ? ? ? ? }else if (strObjSingle.number >0) {
}else {
Feng.info("數(shù)量格式錯(cuò)誤")
return
? ? ? ? ? ? ? ? }
strObjSingle.endTime =$(".purchase_add_sin").eq(i).find('.endTime').val()//截止時(shí)間
? ? ? ? ? ? ? ? if (strObjSingle.endTime ==0) {
Feng.info("請選擇苗木的截止日期")
return
? ? ? ? ? ? ? ? }else if (strObjSingle.endTime >$("#endTime").val()) {
Feng.info("截止日期不能超過清單截止日期")
return
? ? ? ? ? ? ? ? }
strObjSingle.price =$(".purchase_add_sin").eq(i).find('.price').val()//預(yù)估價(jià)格
? ? ? ? ? ? ? ? if (strObjSingle.price ==0) {
Feng.info("請?zhí)顚憙r(jià)格")
return
? ? ? ? ? ? ? ? }else if (strObjSingle.price >0) {
}else {
Feng.info("價(jià)格格式錯(cuò)誤")
return
? ? ? ? ? ? ? ? }
strObjSingle.content =$(".purchase_add_sin").eq(i).find('.content').val()//備注
? ? ? ? ? ? ? ? var tempTag = []
for (var j =0; j <$(".purchase_add_sin").eq(i).find('.active').length; j++) {
tempTag[j] =$(".purchase_add_sin").eq(i).find('.active').eq(j).attr('data-tagId')//標(biāo)簽ID
? ? ? ? ? ? ? ? }
//? ? ? ? ? ? ? ? console.log(tempTag)
? ? ? ? ? ? ? ? strObjSingle.tags = tempTag
var tempStandard = []
for (var k =0; k <$(".purchase_add_sin").eq(i).find('.standards').length; k++) {
var standardVoTemp = {}
standardVoTemp.standardId =$(".purchase_add_sin").eq(i).find('.standards').eq(k).attr("data-standardId")
standardVoTemp.minSize =$(".purchase_add_sin").eq(i).find('.standards').eq(k).find(".minInput").val()
standardVoTemp.maxSize =$(".purchase_add_sin").eq(i).find('.standards').eq(k).find(".maxInput").val()
tempStandard.push(standardVoTemp)
}
strObjSingle.standardVo = tempStandard
console.log(strObjSingle, '單個(gè)苗木')
strObj.push(strObjSingle)
}
var company =$("#company").val()
if (!company) {
Feng.info("請?zhí)顚懹妹绻?)
return
? ? ? ? ? ? }
var endTime =$("#endTime").val()
if (!endTime) {
Feng.info("請?zhí)顚懬鍐谓刂箷r(shí)間")
return
? ? ? ? ? ? }
var telephone =$("#telephone").val()
if (!telephone) {
Feng.info("請?zhí)顚懧?lián)系電話")
return
? ? ? ? ? ? }
var name =$("#name").val()
if (!name) {
Feng.info("請?zhí)顚懾?fù)責(zé)人")
return
? ? ? ? ? ? }
var area1 =$("#area1").val()
if (!area1) {
Feng.info("請選擇用苗地")
return
? ? ? ? ? ? }
var projectName =$("#projectName").val()
if (!projectName) {
Feng.info("請?zhí)顚戫?xiàng)目名")
return
? ? ? ? ? ? }
var purchaseTreeVo = JSON.stringify(strObj)
console.log(JSON.stringify(strObj), "拼接后數(shù)據(jù)")
$.ajax({
type:"post",
? ? ? ? ? ? ? ? async:false,
? ? ? ? ? ? ? ? url: Feng.ctxPath +"/purchasePlatform/add",
? ? ? ? ? ? ? ? data: {
company: company,
? ? ? ? ? ? ? ? ? ? name: name,
? ? ? ? ? ? ? ? ? ? telephone: telephone,
? ? ? ? ? ? ? ? ? ? endTime: endTime,
? ? ? ? ? ? ? ? ? ? city: area1,
? ? ? ? ? ? ? ? ? ? projectName: projectName,
? ? ? ? ? ? ? ? ? ? purchaseTreeVo: purchaseTreeVo
},
? ? ? ? ? ? ? ? success:function (data) {
Feng.info("添加成功")
location.href = Feng.ctxPath +"/purchasePlatform";
? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? error:function (data) {
Feng.error("添加失敗")
}
})
//----------------------------------------拼接完成提交字符串(JSON.stringify(strAll))---------------------------------------------------
? ? ? ? })
$("#ensure").bind("click", function () {
var htmlTemp =''
? ? ? ? ? ? htmlTemp +='<div class="purchase_add_sin" class="col-sm-12">';
? ? ? ? ? ? htmlTemp +='<div class="detele_btn">刪除苗木</div>';
? ? ? ? ? ? htmlTemp +='<div class="purchase_add_single">';
? ? ? ? ? ? htmlTemp +='<span class="purchase_add_single_span">苗木名稱*</span>';
? ? ? ? ? ? htmlTemp +='<div class="purchase_add_single_div">';
? ? ? ? ? ? htmlTemp +='<input type="text"><span class="select_btn">查詢</span>';
? ? ? ? ? ? htmlTemp +='<div class="treeName"></div>';
? ? ? ? ? ? htmlTemp +='</div>';
? ? ? ? ? ? htmlTemp +='</div><div></div>';
? ? ? ? ? ? htmlTemp +='<div class="purchase_add_single">';
? ? ? ? ? ? htmlTemp +='<span class="purchase_add_single_span">集采數(shù)量*</span>';
? ? ? ? ? ? htmlTemp +='<div class="purchase_add_single_div">';
? ? ? ? ? ? htmlTemp +='<input type="number" step="1" class="number">棵';
? ? ? ? ? ? htmlTemp +='</div>';
? ? ? ? ? ? htmlTemp +='</div>';
? ? ? ? ? ? htmlTemp +='<div class="purchase_add_single" >';
? ? ? ? ? ? htmlTemp +='<span class="purchase_add_single_span">預(yù)估價(jià)格</span>';
? ? ? ? ? ? htmlTemp +='<div class="purchase_add_single_div">';
? ? ? ? ? ? htmlTemp +='<input type="number" step="0.01" class="price">元/棵';
? ? ? ? ? ? htmlTemp +='</div>';
? ? ? ? ? ? htmlTemp +='</div>';
? ? ? ? ? ? htmlTemp +='<div class="purchase_add_single">';
? ? ? ? ? ? htmlTemp +='<span class="purchase_add_single_span">截止時(shí)間</span>';
? ? ? ? ? ? htmlTemp +='<div class="purchase_add_single_div">';
? ? ? ? ? ? htmlTemp +='<input type="text" class="endTime">';
? ? ? ? ? ? htmlTemp +='</div>';
? ? ? ? ? ? htmlTemp +='</div>';
? ? ? ? ? ? htmlTemp +='<div class="purchase_add_single">';
? ? ? ? ? ? htmlTemp +='<span class="purchase_add_single_span" style="vertical-align: top;">備注</span>';
? ? ? ? ? ? htmlTemp +='<div class="purchase_add_single_div">';
? ? ? ? ? ? htmlTemp +='<textarea name="" id="" style="width:70%;border-radius: 3px;" rows="10" class="content" placeholder="備注說明"></textarea>';
? ? ? ? ? ? htmlTemp +='</div>';
? ? ? ? ? ? htmlTemp +='</div>';
? ? ? ? ? ? htmlTemp +='</div>';
? ? ? ? ? ? $('#purchase_add').append(htmlTemp)
bindClicks();
? ? ? ? ? ? addTimePlugs();
? ? ? ? })
})
? ? function? chooseMarket() {
var options=$("#province option:selected");
? ? ? ? if(options.text()!="選擇所在的省份"){
$.post(Feng.ctxPath +"/common/getLowerCityData",{"id":options.val()},function (data) {
for(var i=0; i
$("#market").append('<option value="' + data[i].id +'">' + data[i].name +'</option>')
};
? ? ? ? ? ? ? ? var id=data[0].id;
? ? ? ? ? ? ? ? defaultNext(id);
? ? ? ? ? ? });
? ? ? ? }
$("#market").empty();
? ? ? ? $("#area1").empty();
? ? }
function chooseArea() {
var options=$("#market option:selected");
? ? ? ? if(options.text()!="請選擇所在的市"){
$.post(Feng.ctxPath +"/common/getLowerCityData",{"id":options.val()},function (data) {
for(var i=0; i
$("#area1").append('<option value="' + data[i].id +'">' + data[i].name +'</option>')
};
? ? ? ? ? ? });
? ? ? ? }
$("#area1").empty();
? ? }
function defaultNext(id) {
$.post(Feng.ctxPath +"/common/getLowerCityData",{"id":id},function (data) {
for(var i=0; i
$("#area1").append('<option value="' + data[i].id +'">' + data[i].name +'</option>')
};
? ? ? ? });
? ? ? ? $("#area1").empty();
? ? }
@}