123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- var SVR_URL = "/server/"; //http://172.30.84.3:8803
- if(location.host.indexOf("niimei") === -1){
- SVR_URL = "http://172.30.84.3:8803/server/";
- }
- function get_data(url, callback) {
- $.ajax({
- url: SVR_URL + url,
- apiName: url,
- sendTime: new Date()
- }).done(callback).fail(on_fail);
- }
- function on_fail(msg) {
- alert("很抱歉,网络错误,请查看Console");
- console.log("----- 网络请求失败 ---------")
- console.log(JSON.stringify(this));
- console.log("----------------------------")
- }
- function on_data_success(obj, status) {
- }
- function first_parse(ajax, obj) {
- if (typeof obj === "string") {
- obj = JSON.parse(obj);
- }
- if (typeof obj !== "object") {
- console.log(ajax);
- throw "Error ! Parsing JSON failed ." + JSON.stringify(obj);
- }
- if (obj.ret == "10000" || obj.ret == 10000 || obj.ret == 1000) {
- return obj.model;
- } else {
- console.log(ajax);
- throw "Error ! Server returned error." + JSON.stringify(obj);
- }
- }
- function on_document_load() {
- firsttime_load_spots_data();
- secondtime_load_spots_data();
- }
- function firsttime_load_spots_data() {
- get_data("fcFlow/list", first_success)
- }
- var flowID=[];
- var flowname=[];
- var periodID=[];
- var periodname=[];
- function first_success(obj, sta) {
- var output = first_parse(this, obj);
- //在这里排序 spo\
- console.log(" output : ");
- console.log(output);
- var i,j,k;
- j=0;
- k=0;
- for(i=0;i<output.list.length;i++){
- if(userId==output.list[i].flowMasterId){
- flowID[j]=output.list[i].flowId;
- flowname[j]=output.list[i].flowName;
- j++;
- }
- else {
- k++;
- }
- }
- if(k==output.list.length-1){
- alert("无权限访问!");
- }
- showEachSpot();
- showEachSpot1();
- }
- function secondtime_load_spots_data() {
- get_data("fcWorkPeriod/list", second_success);
- }
- function thirdtime_load_spots_data() {
- get_data("fcWorkSchedule/list", third_success);
- }
- function second_success(obj, sta) {
- var history = first_parse(this, obj);
- var i, j;
- console.log(" history : ");
- console.log(history);
- for(i=0;i<history.length;i++){
- periodID[i]=history[i].periodId;
- periodname[i]=history[i].periodName;
- }
- thirdtime_load_spots_data();
- }
- var scheduleID;
- function second_success(obj, sta) {
- var history = first_parse(this, obj);
- var i, j;
- console.log(" history : ");
- console.log(history);
- for(i=0;i<history.list.length;i++){
- if(flowID[i]==history.list[i].flowId&&periodID[i]==history.list[i].periodId){
- scheduleID=history.list[i].scheduleId;
- }
- }
- }
|