815 lines
27 KiB
JavaScript
815 lines
27 KiB
JavaScript
/*
|
||
@config : next999.json
|
||
@filename : ${psFileBasename}
|
||
@title : 100.一覧画面用スクリプト
|
||
@name :
|
||
@siteIds : 189112
|
||
@siteTitles : ★マスターシート
|
||
@disabled: false
|
||
*/
|
||
|
||
let myData;
|
||
let apiKey = '6504c8a807677a3a576e10327f3c19876c55736ee45d4a845796b9e7f5e087bfd4bd0d8184863da8cf1733ca635111432ab334aea59102b06a96ee6d2c05190d';
|
||
|
||
//本契約ワークフローステータス一覧
|
||
const statusArray1 = [100, 102, 101, 150, 160, 200, 300, 400, 500, 600, 700, 900];
|
||
const statusList1 = {
|
||
100: {
|
||
'next': 150,
|
||
'columnId': "",
|
||
'flow': "",
|
||
'status': "新規作成",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "",
|
||
'comments': ""
|
||
},
|
||
102: {
|
||
'next': 150,
|
||
'columnId': "158",
|
||
'flow': "",
|
||
'status': "設計契約→本契約",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "",
|
||
'comments': ""
|
||
},
|
||
101: {
|
||
'next': 200,
|
||
'columnId': "137",
|
||
'flow': "",
|
||
'status': "[本契]差戻し",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "",
|
||
'comments': ""
|
||
},
|
||
150: {
|
||
'next': 160,
|
||
'columnId': "138",
|
||
'flow': "",
|
||
'status': "[本契]事前申請",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "",
|
||
'comments': ""
|
||
},
|
||
160: {
|
||
'next': 200,
|
||
'columnId': "139",
|
||
'flow': "",
|
||
'status': "[本契]事前確認",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "",
|
||
'comments': ""
|
||
},
|
||
200: {
|
||
'next': 300,
|
||
'columnId': "130",
|
||
'flow': "",
|
||
'status': "[本契]WF申請",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "",
|
||
'comments': ""
|
||
},
|
||
300: {
|
||
'next': 400,
|
||
'columnId': "131",
|
||
'flow': "",
|
||
'status': "[本契]管理設計承認",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "107",
|
||
'comments': ""
|
||
},
|
||
400: {
|
||
'next': 500,
|
||
'columnId': "132",
|
||
'flow': "",
|
||
'status': "[本契]所属長承認",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "108",
|
||
'comments': ""
|
||
},
|
||
500: {
|
||
'next': 600,
|
||
'columnId': "133",
|
||
'flow': "",
|
||
'status': "[本契]着工要因承認",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "109",
|
||
'comments': ""
|
||
},
|
||
600: {
|
||
'next': 700,
|
||
'columnId': "134",
|
||
'flow': "",
|
||
'status': "[本契]専務承認",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "110",
|
||
'comments': ""
|
||
},
|
||
700: {
|
||
'next': 900,
|
||
'columnId': "135",
|
||
'flow': "",
|
||
'status': "[本契]総務承認",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "111",
|
||
'comments': ""
|
||
},
|
||
900: {
|
||
'next': 0,
|
||
'columnId': "136",
|
||
'flow': "",
|
||
'status': "[本契]最終承認",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "112",
|
||
'comments': ""
|
||
}
|
||
}
|
||
|
||
//設計ワークフローステータス一覧
|
||
const statusArray2 = [110, 111, 151, 161, 210, 310, 410, 510, 710, 910, 102]
|
||
const statusList2 = {
|
||
110: {
|
||
'next': 151,
|
||
'columnId': "",
|
||
'flow': "",
|
||
'status': "新規作成",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "",
|
||
'comments': ""
|
||
},
|
||
111: {
|
||
'next': 210,
|
||
'columnId': "157",
|
||
'flow': "",
|
||
'status': "[設契]差戻し",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "",
|
||
'comments': ""
|
||
},
|
||
151: {
|
||
'next': 161,
|
||
'columnId': "169",
|
||
'flow': "",
|
||
'status': "[設契]事前申請",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "",
|
||
'comments': ""
|
||
},
|
||
161: {
|
||
'next': 210,
|
||
'columnId': "170",
|
||
'flow': "",
|
||
'status': "[設契]事前確認",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "",
|
||
'comments': ""
|
||
},
|
||
210: {
|
||
'next': 310,
|
||
'columnId': "150",
|
||
'flow': "",
|
||
'status': "[設契]WF申請",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "",
|
||
'comments': ""
|
||
},
|
||
310: {
|
||
'next': 410,
|
||
'columnId': "151",
|
||
'flow': "",
|
||
'status': "[設契]管理設計承認",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "101",
|
||
'comments': ""
|
||
},
|
||
410: {
|
||
'next': 510,
|
||
'columnId': "152",
|
||
'flow': "",
|
||
'status': "[設契]所属長承認",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "102",
|
||
'comments': ""
|
||
},
|
||
510: {
|
||
'next': 710,
|
||
'columnId': "153",
|
||
'flow': "",
|
||
'status': "[設契]着工要因承認",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "103",
|
||
'comments': ""
|
||
},
|
||
710: {
|
||
'next': 910,
|
||
'columnId': "155",
|
||
'flow': "",
|
||
'status': "[設契]総務承認",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "104",
|
||
'comments': ""
|
||
},
|
||
910: {
|
||
'next': 102,
|
||
'columnId': "156",
|
||
'flow': "",
|
||
'status': "[設契]最終承認",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "105",
|
||
'comments': ""
|
||
},
|
||
102: {
|
||
'next': 150,
|
||
'columnId': "158",
|
||
'flow': "",
|
||
'status': "設計契約→本契約",
|
||
'tanto_user': "",
|
||
'shonin_user': "",
|
||
'shonin_date': "",
|
||
'checkId': "",
|
||
'comments': ""
|
||
},
|
||
}
|
||
|
||
let statusArray = [];
|
||
let statusList = {};
|
||
let flowTitle = 'ワークフロー';
|
||
let userList = $('#userList').length > 0 ? JSON.parse($('#userList').val()) : {};
|
||
|
||
const sumi = '★★★';
|
||
const next = '▶▷▶';
|
||
|
||
let pageLoading = 0;
|
||
window.addEventListener('load', function () {
|
||
if (pageLoading == 0) {
|
||
console.log('load Event');
|
||
onLoad();
|
||
}
|
||
});
|
||
|
||
$p.events.on_grid_load = function () {
|
||
//処理内容
|
||
if (pageLoading == 0) {
|
||
console.log('on Editor Load');
|
||
onLoad();
|
||
}
|
||
}
|
||
|
||
function onLoad() {
|
||
pageLoading = 1;
|
||
//getUserList(0);
|
||
createStatusButtons();
|
||
pageLoading = 0;
|
||
}
|
||
|
||
//window.addEventListener("scroll", createStatusButtons(), false);
|
||
|
||
window.addEventListener("scroll", function () {
|
||
//console.log('scroll events');
|
||
if (pageLoading == 0) {
|
||
createStatusButtons()
|
||
}
|
||
});
|
||
|
||
function createStatusButtons() {
|
||
|
||
let recordIdCol = 0;
|
||
let statusCol = 0;
|
||
let titleCol = 0;
|
||
$("#Grid>thead>tr>th").each(function (index, value) {
|
||
if (value.getAttribute('data-name') == 'ResultId') {
|
||
recordIdCol = index;
|
||
}
|
||
if (value.getAttribute('data-name') == 'Status') {
|
||
statusCol = index;
|
||
}
|
||
if (value.getAttribute('data-name') == 'Title') {
|
||
titleCol = index;
|
||
}
|
||
});
|
||
|
||
$("#Grid>tbody>tr").each(function (index, value) {
|
||
//console.log(value.cells[2]);
|
||
let recordId = value.cells[recordIdCol].innerText;
|
||
let divId = 'status_' + recordId
|
||
let divId2 = 'oboegaki_' + recordId
|
||
if (recordId) {
|
||
if (document.getElementById(divId) == null) {
|
||
let link = document.createElement('a');
|
||
link.innerHTML = ">WFステータス";
|
||
link.href = "javascript:void(0);";
|
||
link.classList.add('statusLink')
|
||
link.setAttribute('onclick', '$p.ex.createArrayData("' + recordId + '")');
|
||
|
||
let div = document.createElement('div');
|
||
div.id = divId;
|
||
div.classList.add('statusLinkDiv');
|
||
div.append(link);
|
||
|
||
value.cells[statusCol].append(div);
|
||
|
||
|
||
let link2 = document.createElement('a');
|
||
link2.innerHTML = ">>覚書";
|
||
link2.href = "javascript:void(0);";
|
||
link2.classList.add('statusLink')
|
||
link2.setAttribute('onclick', 'openOboegaki("' + recordId + '")');
|
||
|
||
let div2 = document.createElement('div');
|
||
div2.id = divId2;
|
||
div2.classList.add('statusLinkDiv');
|
||
div2.append(link2);
|
||
|
||
//console.log(value.cells[titleCol]);
|
||
value.cells[titleCol].append(div2);
|
||
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
$p.ex.createArrayData = function (recordId) {
|
||
getMyData(recordId);
|
||
|
||
let status = myData.Status;
|
||
|
||
//担当者配列生成
|
||
const tanto_userList = {
|
||
100: {//[本契]新規作成
|
||
tanto_user: myData.ClassHash.ClassG ? userList[myData.ClassHash.ClassG].name : ''
|
||
},
|
||
101: {//[本契]差戻し
|
||
tanto_user: '*'
|
||
},
|
||
102: {//設計契約→本契約
|
||
tanto_user: myData.ClassHash.ClassG ? userList[myData.ClassHash.ClassG].name : ''
|
||
},
|
||
110: {//[設契]新規作成
|
||
tanto_user: myData.ClassHash.ClassG ? userList[myData.ClassHash.ClassG].name : ''
|
||
},
|
||
111: {//[設契]差戻し
|
||
tanto_user: '*'
|
||
},
|
||
150: {//[本契]事前申請
|
||
tanto_user: myData.ClassHash.ClassG ? userList[myData.ClassHash.ClassG].name : ''
|
||
},
|
||
160: {//[本契]事前確認
|
||
//tanto_user: '管理設計\n所属長\n専務\n総務\n担当役員\n▼▽▼\n' + userList[myData.ClassHash.ClassG].name
|
||
tanto_user: '管理設計\n所属長\n専務\n総務\n▼▽▼\n' + userList[myData.ClassHash.ClassG].name
|
||
},
|
||
151: {//[設契]事前申請
|
||
tanto_user: myData.ClassHash.ClassG ? userList[myData.ClassHash.ClassG].name : ''
|
||
},
|
||
161: {//[設契]事前確認
|
||
//tanto_user: '管理設計\n所属長\n総務\n担当役員\n▼▽▼\n' + userList[myData.ClassHash.ClassG].name
|
||
tanto_user: '管理設計\n所属長\n総務\n▼▽▼\n' + userList[myData.ClassHash.ClassG].name
|
||
},
|
||
200: {
|
||
tanto_user: myData.ClassHash.ClassG ? userList[myData.ClassHash.ClassG].name : ''
|
||
},
|
||
210: {
|
||
tanto_user: myData.ClassHash.ClassG ? userList[myData.ClassHash.ClassG].name : ''
|
||
},
|
||
300: {//管理設計承認
|
||
tanto_user: myData.ClassHash.ClassL ? userList[myData.ClassHash.ClassL].name : ''
|
||
},
|
||
310: {
|
||
tanto_user: myData.ClassHash.ClassL ? userList[myData.ClassHash.ClassL].name : ''
|
||
},
|
||
400: {//所属長承認
|
||
tanto_user: myData.ClassHash.ClassY ? userList[myData.ClassHash.ClassY].name : ''
|
||
},
|
||
410: {
|
||
tanto_user: myData.ClassHash.ClassY ? userList[myData.ClassHash.ClassY].name : ''
|
||
},
|
||
500: {//着工要因承認
|
||
tanto_user: '入谷 優子'
|
||
},
|
||
510: {
|
||
tanto_user: '入谷 優子'
|
||
},
|
||
//専務承認
|
||
600: {
|
||
tanto_user: '川名 真治'
|
||
},
|
||
610: {
|
||
tanto_user: '川名 真治'
|
||
},
|
||
//専務承認
|
||
600: {
|
||
tanto_user: '川名 真治'
|
||
},
|
||
610: {
|
||
tanto_user: '川名 真治'
|
||
},
|
||
//専務承認
|
||
700: {
|
||
tanto_user: '豊蔵 恵美\n長谷川 望\n秦野 勇輝\n露﨑 直樹'
|
||
},
|
||
710: {
|
||
tanto_user: '豊蔵 恵美\n長谷川 望\n秦野 勇輝\n露﨑 直樹'
|
||
},
|
||
//最終承認
|
||
900: {
|
||
//tanto_user: myData.ClassHash.Class122 ? userList[myData.ClassHash.Class122].name : ''
|
||
tanto_user: myData.ClassHash.ClassY ? userList[myData.ClassHash.ClassY].name : ''
|
||
},
|
||
910: {
|
||
//tanto_user: myData.ClassHash.Class122 ? userList[myData.ClassHash.Class122].name : ''
|
||
tanto_user: myData.ClassHash.ClassY ? userList[myData.ClassHash.ClassY].name : ''
|
||
},
|
||
}
|
||
|
||
//設計契約か本契約かによって配列を切替え
|
||
if (statusArray1.includes(status)) {
|
||
flowTitle = '本契約ワークフロー';
|
||
//ステータス配列切り替え
|
||
statusArray = statusArray1.concat();
|
||
//statusList = statusList1;
|
||
statusList = JSON.parse(JSON.stringify(statusList1));
|
||
} else if (statusArray2.includes(status)) {
|
||
flowTitle = '設計契約ワークフロー';
|
||
//ステータス配列切り替え
|
||
statusArray = statusArray2.concat();
|
||
//statusList = statusList2;
|
||
statusList = JSON.parse(JSON.stringify(statusList2));
|
||
}
|
||
|
||
let nextStatus = '';
|
||
let jizen = false;
|
||
$.each(statusArray, function (index, value) {
|
||
//各ステータスの入力値の取得
|
||
let columnId = statusList[value].columnId;
|
||
let shonin_user = columnId != '' ? myData.ClassHash["Class" + columnId] != '' ? userList[myData.ClassHash["Class" + columnId]].name : '' : '';
|
||
let shonin_date = columnId != '' ? myData.DateHash["Date" + columnId] != '1899-12-30T00:00:00' ? new Date(myData.DateHash["Date" + columnId]) : '' : '';
|
||
let comments = columnId != '' ? myData.ClassHash["Class" + (parseFloat(columnId) + 10)] : '';
|
||
let checkId = statusList[value].checkId;
|
||
let checked = checkId != '' ? myData.CheckHash["Check" + checkId] : true;
|
||
|
||
|
||
statusList[value].tanto_user = tanto_userList[value].tanto_user;
|
||
|
||
if (value == '100' || value == '110') {//申請作成
|
||
//新規作成
|
||
statusList[value].flow = sumi;
|
||
statusList[value].shonin_user = userList[myData.Owner].name;
|
||
statusList[value].shonin_date = new Date(myData.CreatedTime);
|
||
statusList[value].comments = '新規作成';
|
||
} else if (value == '102') {
|
||
//設計契約→本契約移行
|
||
if (shonin_date != '') {
|
||
statusList[value].flow = sumi;
|
||
statusList[value].shonin_user = shonin_user;
|
||
statusList[value].shonin_date = shonin_date;
|
||
statusList[value].comments = '本契約移行済み';
|
||
}
|
||
} else if (value == '101' || value == '111') {
|
||
//差戻し
|
||
if (shonin_date != '') {
|
||
statusList[value].flow = sumi;
|
||
statusList[value].shonin_user = shonin_user;
|
||
statusList[value].shonin_date = shonin_date;
|
||
let tmp = comments.split(':');
|
||
statusList[value].comments = tmp[tmp.length - 1];
|
||
}
|
||
} else if (value == '150' || value == '151') {
|
||
//事前申請
|
||
if (shonin_date != '') {
|
||
statusList[value].flow = sumi;
|
||
statusList[value].shonin_user = shonin_user;
|
||
statusList[value].shonin_date = shonin_date;
|
||
statusList[value].comments = '事前申請済み';
|
||
jizen = true;
|
||
}
|
||
} else if (value == '160' || value == '161') {
|
||
//事前確認
|
||
if (value == '160' && jizen) {
|
||
statusList[value].shonin_user = '';
|
||
let endFlag = true;
|
||
|
||
if (myData.CheckHash.Check124) {
|
||
statusList[value].shonin_user += myData.ClassHash["Class124"] != '' ? userList[myData.ClassHash["Class124"]].name + '\n' : '';
|
||
} else {
|
||
statusList[value].shonin_user += '<b style="color:red">※未※</b>\n';
|
||
endFlag = false;
|
||
}
|
||
|
||
if (myData.CheckHash.Check125) {
|
||
statusList[value].shonin_user += myData.ClassHash["Class125"] != '' ? userList[myData.ClassHash["Class125"]].name + '\n' : '';
|
||
} else {
|
||
statusList[value].shonin_user += '<b style="color:red">※未※</b>\n';
|
||
endFlag = false;
|
||
}
|
||
|
||
if (myData.CheckHash.Check126) {
|
||
statusList[value].shonin_user += myData.ClassHash["Class126"] != '' ? userList[myData.ClassHash["Class126"]].name + '\n' : '';
|
||
} else {
|
||
statusList[value].shonin_user += '<b style="color:red">※未※</b>\n';
|
||
endFlag = false;
|
||
}
|
||
|
||
if (myData.CheckHash.Check127) {
|
||
statusList[value].shonin_user += myData.ClassHash["Class127"] != '' ? userList[myData.ClassHash["Class127"]].name + '\n' : '';
|
||
} else {
|
||
statusList[value].shonin_user += '<b style="color:red">※未※</b>\n';
|
||
endFlag = false;
|
||
}
|
||
|
||
/*
|
||
if (myData.CheckHash.Check128) {
|
||
statusList[value].shonin_user += myData.ClassHash["Class128"] != '' ? userList[myData.ClassHash["Class128"]].name + '\n' : '';
|
||
} else {
|
||
statusList[value].shonin_user += '<b style="color:red">※未※</b>\n';
|
||
endFlag = false;
|
||
}
|
||
*/
|
||
|
||
if (endFlag) {
|
||
if (myData.CheckHash.Check131, myData.CheckHash.Check132, myData.CheckHash.Check133, myData.CheckHash.Check134, myData.CheckHash.Check135) {
|
||
statusList[value].flow = sumi;
|
||
statusList[value].shonin_user += '▼▽▼\n';
|
||
statusList[value].shonin_user += shonin_user;
|
||
statusList[value].shonin_date = shonin_date;
|
||
statusList[value].comments = '事前確認済み';
|
||
} else {
|
||
statusList[value].shonin_user += '▼▽▼\n';
|
||
statusList[value].shonin_user += '<b style="color:red">※未※</b>\n';
|
||
statusList[value].comments = '担当営業\n未確認';
|
||
statusList[value].next = value;
|
||
}
|
||
} else {
|
||
statusList[value].shonin_user += '▼▽▼\n';
|
||
statusList[value].shonin_user += '<b style="color:red">※未※</b>\n';
|
||
statusList[value].comments = '各担当者の\n事前確認\n未完了';
|
||
statusList[value].next = value;
|
||
}
|
||
|
||
} else if (value == '161' && jizen) {
|
||
statusList[value].shonin_user = '';
|
||
let endFlag = true;
|
||
|
||
if (myData.CheckHash.Check195) {
|
||
statusList[value].shonin_user += myData.ClassHash["Class195"] != '' ? userList[myData.ClassHash["Class195"]].name + '\n' : '';
|
||
} else {
|
||
statusList[value].shonin_user += '<b style="color:red">※未※</b>\n';
|
||
endFlag = false;
|
||
}
|
||
|
||
if (myData.CheckHash.Check196) {
|
||
statusList[value].shonin_user += myData.ClassHash["Class196"] != '' ? userList[myData.ClassHash["Class196"]].name + '\n' : '';
|
||
} else {
|
||
statusList[value].shonin_user += '<b style="color:red">※未※</b>\n';
|
||
endFlag = false;
|
||
}
|
||
|
||
if (myData.CheckHash.Check197) {
|
||
statusList[value].shonin_user += myData.ClassHash["Class197"] != '' ? userList[myData.ClassHash["Class197"]].name + '\n' : '';
|
||
} else {
|
||
statusList[value].shonin_user += '<b style="color:red">※未※</b>\n';
|
||
endFlag = false;
|
||
}
|
||
|
||
/*
|
||
if (myData.CheckHash.Check198) {
|
||
statusList[value].shonin_user += myData.ClassHash["Class198"] != '' ? userList[myData.ClassHash["Class198"]].name + '\n' : '';
|
||
} else {
|
||
statusList[value].shonin_user += '<b style="color:red">※未※</b>\n';
|
||
endFlag = false;
|
||
}
|
||
*/
|
||
|
||
if (endFlag) {
|
||
if (myData.CheckHash.Check141, myData.CheckHash.Check142, myData.CheckHash.Check143, myData.CheckHash.Check144) {
|
||
statusList[value].flow = sumi;
|
||
statusList[value].shonin_user += '▼▽▼\n';
|
||
statusList[value].shonin_user += shonin_user;
|
||
statusList[value].shonin_date = shonin_date;
|
||
statusList[value].comments = '事前確認済み';
|
||
} else {
|
||
statusList[value].shonin_user += '▼▽▼\n';
|
||
statusList[value].shonin_user += '<b style="color:red">※未※</b>\n';
|
||
statusList[value].comments = '担当営業\n未確認';
|
||
statusList[value].next = value;
|
||
}
|
||
} else {
|
||
statusList[value].shonin_user += '▼▽▼\n';
|
||
statusList[value].shonin_user += '<b style="color:red">※未※</b>\n';
|
||
statusList[value].comments = '各担当者の\n事前確認\n未完了';
|
||
statusList[value].next = value;
|
||
}
|
||
}
|
||
} else {
|
||
//200以降
|
||
if (shonin_date != '') {
|
||
if (status == '101' || status == '111') {
|
||
if (checkId) {
|
||
if (checked) {
|
||
statusList[value].flow = sumi;
|
||
statusList[value].shonin_user = shonin_user;
|
||
statusList[value].shonin_date = shonin_date;
|
||
statusList[value].comments = comments;
|
||
}
|
||
}
|
||
} else {
|
||
if (value > status) {
|
||
if (checked) {
|
||
statusList[value].flow = sumi;
|
||
statusList[value].shonin_user = shonin_user;
|
||
statusList[value].shonin_date = shonin_date;
|
||
statusList[value].comments = comments;
|
||
}
|
||
} else {
|
||
statusList[value].flow = sumi;
|
||
statusList[value].shonin_user = shonin_user;
|
||
statusList[value].shonin_date = shonin_date;
|
||
statusList[value].comments = comments;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
});
|
||
|
||
nextStatus = statusList[status].next;
|
||
if (nextStatus != '') {
|
||
statusList[nextStatus].flow = next;
|
||
}
|
||
|
||
|
||
$p.ex.createFlowTable();
|
||
}
|
||
|
||
$p.ex.createFlowTable = function () {
|
||
const req = new XMLHttpRequest();
|
||
let url = '/pleasanter/myScripts/flowTable.html';
|
||
let flowArray = [];
|
||
|
||
$.each(statusArray, function (index, value) {
|
||
//console.log(statusList[value]);
|
||
let dateStr = '';
|
||
let timeStr = '';
|
||
if (statusList[value].shonin_date != '') {
|
||
dateStr = statusList[value].shonin_date.getFullYear() + '年' +
|
||
(statusList[value].shonin_date.getMonth() + 1).toString().padStart(2, '0') + '月' +
|
||
statusList[value].shonin_date.getDate().toString().padStart(2, '0') + '日';
|
||
timeStr = statusList[value].shonin_date.getHours().toString().padStart(2, '0') + '時' +
|
||
statusList[value].shonin_date.getMinutes().toString().padStart(2, '0') + '分';
|
||
}
|
||
|
||
let data = {
|
||
"flow": statusList[value].flow,
|
||
"status": statusList[value].status,
|
||
"tanto_user": statusList[value].tanto_user,
|
||
"shonin_user": statusList[value].shonin_user,
|
||
"shonin_date": dateStr,
|
||
"shonin_time": timeStr,
|
||
"comments": statusList[value].comments
|
||
};
|
||
flowArray.push(data);
|
||
})
|
||
|
||
//console.log(flowArray);
|
||
let sekkeiKeiyaku;
|
||
if (myData.ClassHash.ClassN == "0") {
|
||
sekkeiKeiyaku = '無し';
|
||
} else if (myData.ClassHash.ClassN == "1") {
|
||
sekkeiKeiyaku = '有り';
|
||
}
|
||
|
||
req.onreadystatechange = function () {
|
||
if (req.readyState == 4) {
|
||
if (req.status == 200) {
|
||
let templateHTML = req.response;
|
||
let template = Hogan.compile(templateHTML);
|
||
|
||
let outputHtml = template.render({
|
||
"keiyaku_cd": myData.ClassHash.ClassA,
|
||
"kouji_mei": myData.ClassHash.ClassQ,
|
||
"sekkei_keiyaku": sekkeiKeiyaku,
|
||
"eigyo_tanto_user": userList[myData.ClassHash.ClassG].name,
|
||
"flow_title": flowTitle,
|
||
"flowArray": flowArray
|
||
});
|
||
|
||
let newWin = window.open('', 'マスターシートワークフロー', 'left=10,top=10,width=900,height=900,menubar=no,toolbar=no,location=no,status=no,resizable=yes');
|
||
newWin.document.open();
|
||
newWin.document.write(outputHtml);
|
||
newWin.document.close();
|
||
}
|
||
}
|
||
};
|
||
req.open('GET', url);
|
||
req.setRequestHeader('Pragma', 'no-cache');
|
||
req.setRequestHeader('Cache-Control', 'no-cache');
|
||
req.setRequestHeader('If-Modified-Since', 'Thu, 01 Jun 1970 00:00:00 GMT');
|
||
req.send();
|
||
}
|
||
|
||
function getMyData(recordId) {
|
||
let thisId = recordId;
|
||
|
||
$p.apiGet({
|
||
'id': thisId,
|
||
'data': {
|
||
'ApiVersion': 1.1,
|
||
'ApiKey': apiKey,
|
||
},
|
||
'async': false,
|
||
'done': function (data) {
|
||
//console.log('マスターシートデータを取得しました');
|
||
myData = data.Response.Data[0];
|
||
//console.log(myData);
|
||
},
|
||
'fail': function (data) {
|
||
console.log(data);
|
||
}
|
||
|
||
});
|
||
}
|
||
|
||
function getUserList(offset) {
|
||
let json = {
|
||
'ApiVersion': 1.1,
|
||
'ApiKey': apiKey,
|
||
'Offset': offset,
|
||
'View': {
|
||
'ApiGetMailAddresses': true,
|
||
},
|
||
};
|
||
let url = 'https://' + location.hostname + '/pleasanter/api/users/get';
|
||
|
||
$.ajax({
|
||
type: 'post',
|
||
url: url,
|
||
contentType: 'application/json',
|
||
data: JSON.stringify(json),
|
||
success: function (data) {
|
||
//console.log(data);
|
||
$.each(data.Response.Data, function (index, value) {
|
||
let name = value.Name;
|
||
let deptId = value.DeptId;
|
||
let userId = value.UserId;
|
||
let mailAddress = value.MailAddresses[0];
|
||
|
||
userList[userId] = {
|
||
name: name,
|
||
userId: userId,
|
||
deptId: deptId,
|
||
mailAddress: mailAddress,
|
||
};
|
||
});
|
||
//console.log(data.Response.Data.length);
|
||
if ((offset + data.Response.Data.length) < data.Response.TotalCount) {
|
||
let offset2 = offset + 200;
|
||
getUserList(offset2);
|
||
}
|
||
},
|
||
error: function (data) {
|
||
console.log(data);
|
||
},
|
||
});
|
||
}
|