|
-
- var jtone=document.getElementById('jtone');
- var jtsec=document.getElementById('jtsec');
- var LastMonth=document.getElementById('LastMonth');
- var NowMonth=document.getElementById('NowMonth');
- var NowYear=document.getElementById('NowYear');
- var futureMonth=document.getElementById('futureMonth');
- var rili=document.getElementById('rili');
- var kc=document.getElementById('kc');
- //var imgs = $('#rili').is('img');
- var imgs=rili.getElementsByTagName('img');
- var quan=document.getElementById('quan');
- var selectweek=document.getElementById('selectweek');
- //var iptweek = $('#rili').is('input');
- var iptweek=selectweek.getElementsByTagName('input');
- //var iptrili = $('#rili').is('input');
- var iptrili=rili.getElementsByTagName('input');
- var kg=document.getElementById('kg');
- var rkc=document.getElementById('rkc');
- var rcg=document.getElementById('rcg');
- var rls=document.getElementById('rls');
- var rqd=document.getElementById('rqd');
- var crsele1=document.getElementById('crsele1');
- //var opt1 = $('#crsele1').is('option');
- var opt1=crsele1.getElementsByTagName('option');
- var crsele2=document.getElementById('crsele2');
- //var opt2 = $('#crsele2').is('option');
- var opt2=crsele2.getElementsByTagName('option');
- var aa='<div class="xk"><div><span>[day_info]</span><input class="se allse xian" type="checkbox"></div><div class="kc" id="kc"><span>[sell]</span><span>/</span><span >[all]</span><span style="font-size:10px; margin-left:10px;">[type]</span><img class="switchs" index="1" src="images/close.jpg" alt=""></div><div class="jg"><span>采购:</span><span>[purchasing price]</span></div><div class="jg"><span>分销:</span><span>[distribution price]</span></div><div class="jg"><span>零售:</span><span>[retail price]</span></div></div>'
-
- var pro_names_ary = new Array();
- var pro_names_count = '';
-
- var prod_id = '';
- var ttttttt='';
- var product_name = document.getElementById("product_name_search");
- window.onload=function(){
-
- }
- //加月份
- function addMonth () {
- var LM=parseInt(LastMonth.innerHTML);
- var NM=parseInt(NowMonth.innerHTML);
- var fM=parseInt(futureMonth.innerHTML);
- var NY=parseInt(NowYear.innerHTML);
- if (LM==1) {LM=13};
- if (LM==12) {NM=13; NY=NY-1};
- if (fM==1) {fM=13};
- LM--;
- NM--;
- fM--;
- LastMonth.innerHTML=LM;
- NowMonth.innerHTML=NM;
- futureMonth.innerHTML=fM;
- NowYear.innerHTML=NY;
- }
- //日历相关 减月份
- function MinusMonth () {
- var LM=parseInt(LastMonth.innerHTML);
- var NM=parseInt(NowMonth.innerHTML);
- var fM=parseInt(futureMonth.innerHTML);
- var NY=parseInt(NowYear.innerHTML);
- if (fM==12) {fM=0};
- if (LM==12) {LM=0};
- if (fM==1) {NY=NY+1;NM=0};
- LM++;
- NM++;
- fM++;
- LastMonth.innerHTML=LM;
- NowMonth.innerHTML=NM;
- futureMonth.innerHTML=fM;
- NowYear.innerHTML=NY;
- }
-
- jtone.onclick=function () {
- addMonth();
- rili.innerHTML=aa;
- getjson(NowYear.innerHTML,NowMonth.innerHTML);
- // SW();
- }
- jtsec.onclick=function () {
- MinusMonth();
- rili.innerHTML=aa;
- getjson(NowYear.innerHTML,NowMonth.innerHTML);
-
- }
- var m=0;
- //右下角开关
- kg.onclick=function (){
- // if (m==0) {
- // kg.src="images/close.jpg";
- // $('#kaiguanStyle').val('144');
- // m=1;
- // }else{
- // kg.src="images/open.jpg";
- // $('#kaiguanStyle').val('143');
- // m=0;
- // }
- var switch_val = $('#kaiguanStyle').val();
- if(switch_val==144){
- kg.src='images/open.jpg';
- $('#kaiguanStyle').val('143');
- $('#see_switch').html('开');
- }else{
- kg.src='images/close.jpg';
- $('#kaiguanStyle').val('144');
- $('#see_switch').html('关');
- }
- }
- //控制开关函数
- //function SW(data) {
- // for(var i = 0; i < imgs.length; i++){
- // imgs[i].index=parseInt(data["calender_Info"][i]["switchStyle"]);
- // }
- // for (var n = 0; n < imgs.length; n++) {
- // imgs[n].onclick=function (){
- // for (var i = 0; i < imgs.length; i++) {
- // if(imgs[i]==this&&imgs[i].index=="开"){
- // imgs[i].src="images/open.jpg";
- // imgs[i].index=2;
- // }else if(imgs[i]==this&&imgs[i].index=="关"){
- // imgs[i].src="images/close.jpg";
- // imgs[i].index=1;
- // }
- // };
- // }
- // };
- //}
- //控制打钩
- function Check(){
- quan.checked=false;
- for (var i = 0; i < iptweek.length; i++) {
- iptweek[i].checked=false;
- };
- for (var i = 0; i < iptrili.length; i++) {
- iptrili[i].checked=false;
- };
- quan.onclick=function (){
- var sss=0
- if (quan.checked==true) {
- for (var i = 0; i < iptweek.length; i++) {
- iptweek[i].checked=true;
- };
- for (var i = 0; i < iptrili.length; i++) {
- iptrili[i].checked=true;
- if (iptrili[i].className!="se allse xian") {
- sss=i;
- };
- };
- sss=sss+1;
- var mm=rili.getElementsByTagName("input")[sss];
- var youbian1="";
- var youbian2="";
- // youbian1=mm.parentNode.parentNode.children[1].children[0].innerHTML;
- // youbian1+=mm.parentNode.parentNode.children[1].children[1].innerHTML;
-
- youbian1+=mm.parentNode.parentNode.children[1].children[2].innerHTML;
- rkc.value=youbian1;
- youbian2=mm.parentNode.parentNode.children[1].children[3].innerHTML;
- for (var i = 0; i < opt1.length; i++) {
- if(opt1[i].innerHTML==youbian2){opt1[i].selected=true;};
- };
- rcg.value=mm.parentNode.parentNode.children[2].children[1].innerHTML;
- rfx.value=mm.parentNode.parentNode.children[3].children[1].innerHTML;
- rls.value=mm.parentNode.parentNode.children[4].children[1].innerHTML;
- kg.src=mm.parentNode.parentNode.children[1].children[4].src;
-
- }else{
- for (var i = 0; i < iptweek.length; i++) {
- iptweek[i].checked=false;
- };
- for (var i = 0; i < iptrili.length; i++) {
- iptrili[i].checked=false;
- };
- }
- }
- for (var i = 0; i < iptweek.length; i++) {
- iptweek[i].onclick=function (){
- for (var i = 0; i < iptweek.length; i++) {
- if(iptweek[i]==this&&iptweek[i].checked==true){
- for (var j = i; j < iptrili.length; j=j+7) {
- iptrili[j].checked=true;
- };
- }else if(iptweek[i]==this&&iptweek[i].checked==false){
- for (var j = i; j < iptrili.length; j=j+7) {
- iptrili[j].checked=false;
- };
- }
- }
- }
- };
-
- }
- //控制右边修改框
- function Changecontent (){
- for (var i = 0; i < iptrili.length; i++) {
- iptrili[i].onclick=function (){
- var youbian1="";
- var youbian2="";
- // youbian1=this.parentNode.parentNode.children[1].children[0].innerHTML;
- // youbian1+=this.parentNode.parentNode.children[1].children[1].innerHTML;
- youbian1+=this.parentNode.parentNode.children[1].children[2].innerHTML;
- rkc.value=youbian1;
- youbian2=this.parentNode.parentNode.children[1].children[3].innerHTML;
- for (var i = 0; i < opt1.length; i++) {
- if(opt1[i].innerHTML==youbian2){opt1[i].selected=true;};
- };
- rcg.value=this.parentNode.parentNode.children[2].children[1].innerHTML;
- rfx.value=this.parentNode.parentNode.children[3].children[1].innerHTML;
- rls.value=this.parentNode.parentNode.children[4].children[1].innerHTML;
- kg.src=this.parentNode.parentNode.children[1].children[4].src;
- // if(kg.src == "./images/open.jpg"){
- // var t = $('#see_switch').html('开');
- // }else{
- // var t1 = $('#see_switch').html('关');
- // }
- var a_str = kg.src;
- if(a_str.indexOf("open.jpg")>0 ){
- var t = $('#see_switch').html('开');
- }else{
- var t1 = $('#see_switch').html('关');
- }
- }
- };
- rqd.onclick=function(){
- var xian = $('.xian');
- var dateStr = ''
- for(var k = 0; k<xian.length;k++){
- var nowdate = getDateTime(0);
- var seldate = xian[k].getAttribute('id');
-
- if(seldate>=nowdate && xian[k].checked==true){
- dateStr = dateStr+xian[k].getAttribute('id')+',';
- }
- }
- dateStr = dateStr.substr(0,dateStr.length-1);
- if_can_send(dateStr);
- }
- }
- //判断是否可以提交数据
- function if_can_send(dateTimeStr){
- var prod_id = getPar("prod_id");
- //库存
- var kucun = $('#rkc').val();
- //采购
- var caigou = $('#rcg').val();
- //分销
- var fenxiao = $('#rfx').val();
- //零售
- var lingshou = $('#rls').val();
- //采购类型
- var caigouStyle = $('#crsele1').val();
- //早餐
- var zaocan = $('#crsele2').val();
- var kaiguan = $('#kaiguanStyle').val();
-
-
- var parStr = caigouStyle+','+kucun+','+caigou+','+fenxiao+','+lingshou+','+zaocan+','+kaiguan;
- if (caigou&&kucun&&fenxiao&&lingshou&&caigouStyle&&zaocan&&dateTimeStr){
- $.ajax({
- // var urlStr = 'http://temp.zhizhuchuxing.com/st-xm/Api/hotel_stock.php'
- url:'./st-xm/Api/hotel_stock.php', //请求地址
- type: "post", //请求方式
- data: {method:'add',prod_id:prod_id,info:parStr,dateTime:dateTimeStr}, //请求参数
- async:false,
- dataType: "json",
- success: function (data) {
- if(data.code == 0){
- var xian = $('.xian');
- for(var k = 0; k<xian.length;k++){
- var nowdate = getDateTime(0);
- var seldate = xian[k].getAttribute('id');
- if(xian[k].checked==true && seldate>=nowdate){
- xian[k].parentNode.parentNode.children[2].children[1].innerHTML=rcg.value;
- xian[k].parentNode.parentNode.children[2].children[1].innerHTML=rcg.value;
- xian[k].parentNode.parentNode.children[3].children[1].innerHTML=rfx.value;
- xian[k].parentNode.parentNode.children[4].children[1].innerHTML=rls.value;
- xian[k].parentNode.parentNode.children[1].children[4].src=kg.src;
- // alert(kg.value);
- if(crsele1.value == 229){
- xian[k].parentNode.parentNode.children[1].children[3].innerHTML='现询';
- }else if(crsele1.value == 230){
- xian[k].parentNode.parentNode.children[1].children[3].innerHTML='保留';
- }else if(crsele1.value == 228){
- xian[k].parentNode.parentNode.children[1].children[3].innerHTML='买断';
- }else{
- }
-
- //开关状态
- // xian[k].parentNode.parentNode.children[1].children[3].innerHTML='====';
- // alert(crsele1.value);
- // xian[k].parentNode.parentNode.children[1].children[0].innerHTML=rkc.value.split("/")[0];
- xian[k].parentNode.parentNode.children[1].children[2].innerHTML=rkc.value;
- }else{
- }
- }
- alert('保存成功');
- }
-
- },
- fail: function (status) {
- // 此处放失败后执行的代码
- alert('添加失败');
- }
- });
- }else{
- alert("信息输入不完成!");
- }
-
- }
-
-
- $(document).ready(function(){
- var n=new Date();
- var y=n.getFullYear();
- var m=n.getMonth();
- NowYear.innerHTML=y;
- NowMonth.innerHTML=m+1;
- LastMonth.innerHTML=m;
- futureMonth.innerHTML=m+2;
- prod_id=getPar('prod_id');
- var hotel_id = getPar('hotelName');
- get_hotel_name(prod_id,hotel_id);
- getjson(NowYear.innerHTML,NowMonth.innerHTML);
- ttttttt=rili.innerHTML;
-
-
- })
-
- function get_hotel_name(prod_id,hotel_id){
- var prod_ida=getPar('prod_id');
- var hotel_ida = getPar('hotelName');
- $.getJSON("./st-xm/Api/calender_productName.php?hotel_id="+hotel_ida+'&prod_id='+prod_ida,function(data){
- $('#product').html(data['hotelName']);
- $('#pro_name').val(data['select_prod_name']);
- $('#pro_name_value').val(prod_ida);
- pro_names_count = data['detailInfo'].length;
- });
- }
- //检测输入框的变化
- function hotelname_change(value){
- var div = document.getElementById("product_name_search");
- div.style.display = "";
- // var valueStr = 'http://192.168.6.185/system2.0/zsq/add_hotel.php?hotelName='+value;
- var valueStr = './st-xm/Api/products_search.php?productName='+value;
- var htmlStr = "";
-
- $.getJSON(valueStr, function(data) {
-
- if (data['code'] != "0") {
- alert(data.info);
- return;
- }
-
- // 得到数据中的数据
- var list = data['pro_names'];
- var productName = list['prod_name'];
-
- for (var i = 0; i < list.length; i++) {
- console.log(list[i]['prod_name'])
- htmlStr += '<div class="div_input" onclick="click_select_supplier(' + '\'' + list[i].prod_name + '\',\'' + list[i].prod_id+ '\')">' + list[i].prod_name + '</div>';
- }
- product_name.innerHTML = htmlStr;
- });
- }
-
- function click_select_supplier(name,id){
- var pro_name = document.getElementById("pro_name");
- pro_name.value = name;
- // var pro_name_value = document.getElementById("pro_name_value");
- // console.log(pro_name_value);
- // console.log(id);
- // pro_name_value.value = id;
- var div = document.getElementById("product_name_search");
- div.style.display = "none";
-
- var htl_id = getPar('hotelName');
-
- var year = $('#NowYear').html();
- var month = $('#NowMonth').html();
- if(month.length == 1){
- month="0"+month;
- }
- var dateStr = year+'-'+month;
- var listURL = "ccss.html?prod_id=" + id+"&hotelName="+htl_id;
- // 跳转前将URL编码
- listURL = encodeURI(listURL);
- window.location.href = listURL;
- }
-
-
- function getjson (year,month){
- if(month.length==1){
- month="0"+month;
- }
- var prod_id=getPar('prod_id');
- var hotel_name = getPar('hotelName');
- // $.getJSON("riliJson.html?rand="+Math.random()+"&date="+year+"."+month,function(data){
- $.getJSON("./st-xm/Api/calender_productInfo.php?productID="+prod_id+'&dateTime='+year+'-'+month,function(data){
- $("#product").innerHTML=data["calender_Info"];
- ProcessingData (data,year,month);
- // SW(data);
- Check();
- Changecontent ();
- get_hotel_name();
- // hotelname_change();
- });
-
- kg.src = "images/close.jpg";
- $('#see_switch').html('关');
- }
- function ProcessingData (data,year,month){
- var firDay = new Date(year,month-1).getDay();
- var newstr="";
- for(var i=0;i<firDay;i++){
- newstr += "<div class='xk kong'><input style='display:none;' type='checkbox' /><div></div></div>";
-
- };
- for(var i=0;i<data["calender_Info"].length;i++){
- var nullstr = ttttttt;
-
- nullstr=nullstr.replace("[开关状态]",data["calender_Info"][i]["can_sale"]);
- nullstr=nullstr.replace("[day_info]",data["calender_Info"][i]["dateTime"]);
- nullstr=nullstr.replace("[sell]",data["calender_Info"][i]["saleCount"]);
- nullstr=nullstr.replace("[all]",data["calender_Info"][i]["totalCount"]);
- console.log(data["calender_Info"][i]["totalCount"]+data["calender_Info"][i]["saleCount"]);
- nullstr=nullstr.replace("[type]",data["calender_Info"][i]["buyStyle"]);
- nullstr=nullstr.replace("[purchasing price]",data["calender_Info"][i]["buyPrice"]);
- nullstr=nullstr.replace("[distribution price]",data["calender_Info"][i]["distributionPrice"]);
- nullstr=nullstr.replace("[retail price]",data["calender_Info"][i]["retailPrice"]);
-
- // var str = data["calender_Info"][i]["dateTime"].substr(0,7);
- nullstr=nullstr.replace("[xian_check]",data["calender_Info"][i]["dateTime"]);
-
- var img_src="";
- if(data["calender_Info"][i]["can_sale"]=="143"){
- img_src='src="images/open.jpg"';
- $('#see_switch').html('开');
- }else{
- img_src='src="images/close.jpg"';
- $('#see_switch').html('关');
- }
- nullstr=nullstr.replace('src="images/close.jpg"',img_src);
- newstr+=nullstr;
- };
- rili.innerHTML=newstr;
- var xian = $('.xian');
- for(var k = 0; k<xian.length;k++){
- var nowdate = getDateTime(0);
- var seldate = xian[k].getAttribute('id');
- var nowdate1 = new Date(nowdate.replace(/\-/g, '/'));
- var seldate1 = new Date(seldate.replace(/\-/g, '/'));
- if(seldate1<nowdate1){
- // xian[k].closest('.xk').css('background-color',"red");
- xian[k].closest('.xk').style.backgroundColor='lightgray';
- xian[k].setAttribute('disabled','disabled');
- xian[k].style.display = 'none';
- }else{
- }
- }
- }
-
-
-
-
- function getPar(par){
- //获取当前URL
- var local_url = document.location.href;
- local_url = decodeURI(local_url);
- //获取要取得的get参数位置
- var get = local_url.indexOf(par +"=");
- if(get == -1){
- return false;
- }
- //截取字符串
- var get_par = local_url.slice(par.length + get + 1);
- //判断截取后的字符串是否还有其他get参数
- var nextPar = get_par.indexOf("&");
- if(nextPar != -1){
- get_par = get_par.slice(0, nextPar);
- }
- return get_par;
- }
-
- function getDateTime(nTypeFlag) {
- var tNowTime = new Date();
- var myYear = ';' + tNowTime.getFullYear() + ';';
- var myMonth = ';' + (tNowTime.getMonth() + 1 - 0) + ';';
- var myDay = ';' + tNowTime.getDate() + ';';
- var myHour = ';' + tNowTime.getHours() + ';';
- var myMinu = ';' + tNowTime.getMinutes() + ';';
- var mySecond = ';' + tNowTime.getSeconds() + ';';
-
- if (myMonth.length < 4) myMonth = '0' + myMonth;
- if (myDay.length < 4) myDay = '0' + myDay;
- if (myHour.length < 4) myHour = '0' + myHour;
- if (myMinu.length < 4) myMinu = '0' + myMinu;
- if (mySecond.length < 4) mySecond = '0' + mySecond;
-
- var cNewTimeStr;
- switch (nTypeFlag + 1 - 1) {
- case 0:
- cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
- break;
- case 1:
- cNewTimeStr = myYear + myMonth + myDay;
- break;
- case 2:
- cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
- break;
- case 3:
- cNewTimeStr = myHour + myMinu + mySecond;
- break;
- case 4:
- cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
- break;
- case 5:
- cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
- break;
- case 6:
- cNewTimeStr = myYear;
- break;
- case 7:
- cNewTimeStr = myYear + '-' + myMonth;
- break;
- default:
- cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
- break;
- }
-
- cNewTimeStr = cNewTimeStr.replace(/;/g, "");
-
- return cNewTimeStr;
-
- }
-
- //删除库存
- function delInfo(){
- // del_db_info();
- var dateStr = '';
- var xian = $('.xian');
- for(var k = 0; k<xian.length;k++){
- var nowdate = getDateTime(0);
- var seldate = xian[k].getAttribute('id');
- if(seldate>=nowdate && xian[k].checked==true){
- dateStr = dateStr+xian[k].getAttribute('id')+',';
- }
- }
- dateStr = dateStr.substr(0,dateStr.length-1);
- if(dateStr!=''){
- del_db_info(dateStr);
- }else{
- alert('未选择删除产品');
- }
-
- }
-
- //删除数据库信息
- function del_db_info(dateStr){
- var prod_id = getPar("prod_id");
- $.ajax({
- url:'./st-xm/Api/hotel_stock.php', //请求地址
- type: "post", //请求方式
- data: {method:'del',prod_id:prod_id,dateTime:dateStr}, //请求参数
- async:false,
- dataType: "json",
- success: function (data) {
- if(data.code == 0){
- alert("删除成功");
- del_cur_info();
- }
- },
- fail: function (status) {
- alert('删除失败');
- }
- });
- }
- //更改本地页面
- function del_cur_info() {
- var xian = $('.xian');
- //库存
- var kucun = $('#rkc').val('');
- //采购
- var caigou = $('#rcg').val('');
- //分销
- var fenxiao = $('#rfx').val('');
- //零售
- var lingshou = $('#rls').val('');
- for (var k = 0; k < xian.length; k++) {
- var nowdate = getDateTime(0);
- var seldate = xian[k].getAttribute('id');
- if (xian[k].checked == true && seldate >= nowdate) {
- xian[k].parentNode.parentNode.children[2].children[1].innerHTML = "";
- xian[k].parentNode.parentNode.children[2].children[1].innerHTML = "";
- xian[k].parentNode.parentNode.children[3].children[1].innerHTML = "";
- xian[k].parentNode.parentNode.children[4].children[1].innerHTML = "";
- // xian[k].parentNode.parentNode.children[1].children[4].src = "";
- xian[k].parentNode.parentNode.children[1].children[3].innerHTML = "";
- // xian[k].parentNode.parentNode.children[1].children[0].innerHTML=""
- xian[k].parentNode.parentNode.children[1].children[2].innerHTML="-";
-
- }
- }
- }
|