|
-
- //采购范围html
- var rangeHTML = '';
- //联系信息html
- var infoHTML = '';
- //判断是否有采购范围信息
- var range_count = 0;
- //判断是否有联系信息
- var contact_count = 0;
-
- window. onload = function(){
- rangeHTML = $('#range_info').html();
- infoHTML = $('#table_info_list').html();
-
- //加载省的信息
- reloadProvinceInfo();
- reloadCityInfo(1);
- }
-
-
- //添加采购范围
- function addRange(){
- var newhtml = rangeHTML;
- $("#range_info").prepend(newhtml);
- }
-
- //删除对应的采购范围
- function delThisInfo(obj){
- $(obj).parent().remove();
- var value = $(obj).parent().children().eq(0).val();
- var value1 = $(this).children().eq(1).children().eq(0).val();
- if (value != -1 && value1 != '') {
- range_count = range_count -1;
- }
- }
-
- //添加联系信息
- function addInfo(){
- var newhtml = infoHTML;
- $("#table_info_list").prepend(newhtml);
- }
-
- //联系信息的删除
- function delBtnDidClicked(obj){
- var link_id = $(obj).closest('.tabbable_info').attr('id');
- if(link_id == "-1"){
- $(obj).closest('.tabbable_info').remove();
- var contact = $(obj).closest('.tabbable_info').find('.contact').val();
- var name = $(obj).closest('.tabbable_info').find('.name').val();
- if (contact != '' && name != '') {
- contact_count = contact_count -1;
- }
- }else{
- $.ajax({
- url:base_api+'index.php', //请求地址
- data:{
- tp : "supply_dataInfo_execLink",
- operate:"delete",
- link_id:link_id
-
- },
- type: "post",
- dataType: "json",
- success: function (data) {
- console.log(data);
- if(data.code == "0"){
- $(obj).closest('.tabbable_info').remove();
- var contact = $(obj).closest('.tabbable_info').find('.contact').val();
- var name = $(obj).closest('.tabbable_info').find('.name').val();
- if (contact != '' && name != '') {
- contact_count = contact_count -1;
- }
- }else{
- ZZAlertInfo(data.info);
- }
- }
- });
- }
- }
- //联系信息的取消
- function cancelBtnDidClicked(obj){
- var link_id = $(obj).closest('.tabbable_info').attr('id');
- if (link_id == '-1') {
- $(obj).closest('.tabbable_info').remove();
- var contact = $(obj).closest('.tabbable_info').find('.contact').val();
- var name = $(obj).closest('.tabbable_info').find('.name').val();
- if (contact != '' && name != '') {
- contact_count = contact_count -1;
- }
- } else{
- $.ajax({
- url:base_api+'index.php', //请求地址
- data:{
- tp:"supply_dataInfo_execLink",
- operate:"select",
- link_id:link_id
- },
- type: "post",
- dataType: "json",
- success: function (data) {
- console.log(data);
- if(data.code == "0"){
- $(obj).closest('.tabbable_info').find('.contact').val(data.list.link_name);
- $(obj).closest('.tabbable_info').find('.name').val(data.list.contact_name);
- $(obj).closest('.tabbable_info').find('.tel').val(data.list.contact_mobile);
- $(obj).closest('.tabbable_info').find('.tel_short').val(data.list.contact_telphone);
- $(obj).closest('.tabbable_info').find('.fax').val(data.list.fax);
- $(obj).closest('.tabbable_info').find('.mail').val(data.list.email);
- $(obj).closest('.tabbable_info').find('.remarks').val(data.list.remark);
- $(obj).parent().parent().parent().find('input,textarea').attr('readonly','readonly');
- $(obj).parent().parent().parent().find('input,textarea').addClass('input_no');
- $(obj).closest('.tabbable_info').find('.save').hide();
- $(obj).closest('.tabbable_info').find('.change').show();
- }else{
- ZZAlertInfo(data.info);
- }
- }
- });
- }
-
-
-
-
-
-
- //
- // $(obj).closest('.tabbable_info').remove();
- // var contact = $(obj).closest('.tabbable_info').find('.contact').val();
- // var name = $(obj).closest('.tabbable_info').find('.name').val();
- // if (contact != '' && name != '') {
- // contact_count = contact_count -1;
- // }
- }
- //联系信息的小保存
- function saveBtnDidClicked(obj){
- var link_id = $(obj).closest('.tabbable_info').attr('id');
- var contact = $(obj).closest('.tabbable_info').find('.contact').val();
- var name = $(obj).closest('.tabbable_info').find('.name').val();
- if (contact == '' || name == '') {
- ZZAlertInfo('联系信息不完整!')
- return;
- } else{
- var contact = $(obj).closest('.tabbable_info').find('.contact').val();
- var name = $(obj).closest('.tabbable_info').find('.name').val();
-
- var tel = $(obj).closest('.tabbable_info').find('.tel').val();
- var tel_short = $(obj).closest('.tabbable_info').find('.tel_short').val();
- var fax = $(obj).closest('.tabbable_info').find('.fax').val();
- var mail = $(obj).closest('.tabbable_info').find('.mail').val();
- var remarks = $(obj).closest('.tabbable_info').find('.remarks').val();
- var data = '';
-
- if (link_id == -1) {
- data = {
- tp:"supply_dataInfo_execLink",
- operate:"insert",
- link_name:contact,
- contact_name:name,
- contact_mobile:tel,
- contact_telphone:tel_short,
- fax:fax,
- email:mail,
- remark:remarks
- };
- } else{
- data = {
- tp:"supply_dataInfo_execLink",
- operate:"update",
- link_id:link_id,
- link_name:contact,
- contact_name:name,
- contact_mobile:tel,
- contact_telphone:tel_short,
- fax:fax,
- email:mail,
- remark:remarks
- };
- }
- console.log(data);
-
- $.ajax({
- url:base_api+'index.php', //请求地址
- data:data,
- type: "post",
- dataType: "json",
- success: function (data) {
- console.log(data);
- if(data.code == "0"){
- $(obj).closest('.tabbable_info').attr('id',data.list.link_id);
- $(obj).parent().parent().parent().find('input,textarea').attr('readonly','readonly');
- $(obj).parent().parent().parent().find('input,textarea').addClass('input_no');
- $(obj).closest('.tabbable_info').find('.save').hide();
- $(obj).closest('.tabbable_info').find('.change').show();
- }else{
- ZZAlertInfo(data.info);
- }
- }
- });
- }
- }
- //联系信息的修改
- function changeBtnDidClicked(obj){
- // var link_id = $(obj).closest('.tabbable_info').attr('id');
- // var contact = $(obj).closest('.tabbable_info').find('.contact').val();
- // var name = $(obj).closest('.tabbable_info').find('.name').val();
- // var tel = $(obj).closest('.tabbable_info').find('.tel').val();
- // var tel_short = $(obj).closest('.tabbable_info').find('.tel_short').val();
- // var fax = $(obj).closest('.tabbable_info').find('.fax').val();
- // var mail = $(obj).closest('.tabbable_info').find('.mail').val();
- // var remarks = $(obj).closest('.tabbable_info').find('.remarks').val();
- // $.ajax({
- // url:base_path+'control.php', //请求地址
- // data:{
- // type:"data_link",
- // operate:"update",
- // link_id:link_id,
- // link_name:contact,
- // contact_name:name,
- // contact_mobile:tel,
- // contact_telphone:tel_short,
- // fax:fax,
- // email:mail,
- // remark:remarks
- // },
- // type: "post",
- // dataType: "json",
- // success: function (data) {
- // console.log(data);
- // if(data.code == "0"){
- $(obj).closest('.tabbable_info').find('input,textarea').removeAttr('readonly');
- $(obj).closest('.tabbable_info').find('input,textarea').removeClass('input_no');
- $(obj).closest('.tabbable_info').find('.change').hide();
- $(obj).closest('.tabbable_info').find('.save').show();
- // }else{
- // ZZAlertInfo(data.info);
- // }
- // }
- // });
- //
-
-
-
-
-
- }
-
-
- //总保存按钮
- function saveInfo(){
-
- var name_str = $('#name_str').val();
- var all_name = $('#all_name').val();
- var sale_style = $('input[name="sale_style"]:checked').val();
- var sale_time = $('input[name="sale_time"]:checked').val();
- var bank = $('#bank').val();
- var account_name = $('#account_name').val();
- var bank_id = $('#bank_id').val();
- var city_id = $('#cantonal').val();
- if (name_str == '') {
- ZZAlertInfo('名称不能为空!');
- return;
- }
- if (all_name == '') {
- ZZAlertInfo('公司全称不能为空!');
- return;
- }
- //采购范围的参数
- range_count = 0;
- var range_str = '';
- $('.range_every').each(function(index,dom){
- var value = $(this).children().eq(0).val();
- var value1 = $(this).children().eq(1).children().eq(0).val();
- if (value != -1 && value1 != '') {
- range_str += '{' + value + ',' + value1 + '}';
- range_count ++ ;
- }
- })
- if (range_count == 0) {
- ZZAlertInfo('采购信息输入不完整!');
- return;
- }
- console.log('采购范围参数');
- console.log(range_str);
-
- //联系信息的参数
- var submit_link_id_arr = [];
- $('.tabbable_info').each(function(index,dom){
- var link_id = $(this).closest('.tabbable_info').attr('id');
- submit_link_id_arr.push(link_id);
- })
-
- if($.inArray("-1", submit_link_id_arr)!="-1"){
- ZZAlertInfo("联系信息未保存");
- return;
- };
-
-
-
-
- // contact_count = 0;
- // var contact_str = '{';
- // $('.tabbable_info').each(function(index,dom){
- // var link_id = $(this).closest('.tabbable_info').attr('id');
- // if (link_id != -1) {
- // contact_str += link_id + ','
- // ZZAlertInfo(contact_str);
- // }
- // })
- // contact_str = contact_str.substring(0,contact_str.length-1);
- // contact_str = contact_str +'}';
- // console.log('联系信息参数');
- // console.log(contact_str);
-
-
- var data = {
- tp:'supply_supplier_addSupplier',
- supplier_name:name_str,
- area_id:city_id,
- company_name:all_name,
- purchase:range_str,
- sett_type:sale_style,
- sett_frequency:sale_time,
- account_bank:bank,
- account_num:account_name,
- account_name:bank_id,
- link_info:submit_link_id_arr.toString()
- }
- console.log('这里是data')
- console.log(data);
- $.ajax({
- url:base_api+'index.php', //请求地址
- data:data,
- type: "post",
- dataType: "json",
- success: function (data) {
- if(data.code == "0"){
- ZZAlertInfo(data.info,function(){
- window.location.href = './supplier_list.html';
- });
- }else{
- ZZAlertInfo(data.info);
- }
- }
- });
- }
-
-
- //加载省的信息
- function reloadProvinceInfo(){
- var data = {
- tp:"supply_dataInfo_getArea",
- area_id:0
- };
- console.log(data);
- $.ajax({
- url:base_api+'index.php', //请求地址
- type: "post", //请求方式
- data:data,
- async:false,
- dataType: "json",
- success: function (data) {
- if(data.code == 0){
-
- console.log(data);
- var HTML = "";
- var proList = data.list;
- for (var i = 0; i<proList.length;i ++) {
- var dict = proList[i];
- var tempHTML = '<option value="0">请选择省</option>';
- tempHTML = tempHTML.replace('请选择省',proList[i]['area_name']);
- tempHTML = tempHTML.replace('0',proList[i]['id']);
- HTML += tempHTML;
- }
- $('#province').html(HTML);
- }else{
- ZZAlertInfo(data.info);
- }
- }
- });
- }
-
-
-
- //加载市的信息
- function reloadCityInfo(proid){
- var data = {
- tp:"supply_dataInfo_getArea",
- area_id:proid
- };
- console.log(data);
- $.ajax({
- url:base_api+'index.php', //请求地址
- type: "post", //请求方式
- data:data,
- async:false,
- dataType: "json",
- success: function (data) {
- if(data.code == 0){
- var HTML = "";
- var proList = data.list;
- for (var i = 0; i<proList.length;i ++) {
- var dict = proList[i];
- var tempHTML = '<option value="0">请选择市</option>';
- tempHTML = tempHTML.replace('请选择市',proList[i]['area_name']);
- tempHTML = tempHTML.replace('0',proList[i]['id']);
- HTML += tempHTML;
- }
- $('#cantonal').html(HTML);
- }else{
- ZZAlertInfo(data.info);
- }
- }
- });
- }
-
-
- function selectOneProvince(selected){
- $("#province").find("option:selected").text();
- reloadCityInfo(selected.value);
- }
-
-
- //失去焦点
- $("#name_str").blur(function(){
- var value = $('#name_str').val();
- $.ajax({
- url:base_api+'index.php', //请求地址
- data:{
- tp:"supply_dataInfo_checkSupplierName",
- supplier_name:value,
- supplier_type:'187'
- },
- type: "post",
- dataType: "json",
- success: function (data) {
- console.log(data);
- if(data.code == "0"){
- $('#attention').text('名称可用');
- }else{
- $('#attention').text('名称已存在');
- }
-
- }
- });
- })
|