ken_nogi/pleasanter/develop/★MSS/★マスターシート/sites/scripts/6.ワークフロー状態ウインドウ表示.js
Kenichiro NOGI 7176dc33ec pleasanter
2025-07-10 10:15:35 +09:00

716 lines
24 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
@config : next999.json
@filename : ${psFileBasename}
@title : 6.ワークフロー状態ウインドウ表示
@name :
@siteIds : 189112
@siteTitles : ★マスターシート
@disabled: false
*/
//本契約ワークフローステータス一覧
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 = {};
/*
Class130 新規申請者
Class131 管理設計承認者
Class132 所属長承認者
Class133 着工要因承認者
Class134 専務承認者
Class135 総務承認者
Class136 役員承認者
Class137 差戻し者
Date130 新規申請日
Date131 管理設計処理日
Date132 所属長処理日
Date133 着工要因処理日
Date134 専務処理日
Date135 総務処理日
Date136 役員処理日
Date137 差戻し日
Class140 新規申請処理内容
Class141 管理設計処理内容
Class142 所属長処理内容
Class143 着工要因処理内容
Class144 専務処理内容
Class145 総務処理内容
Class146 役員処理内容
Class147 差戻し内容
設計契約
Class150 [設契] 新規申請者
Class151 [設契] 管理設計承認者
Class152 [設契] 所属長承認者
Class153 [設契] 着工要因承認者
Class154 [設契] 専務承認者
Class155 [設契] 総務承認者
Class156 [設契] 役員承認者
Class157 [設契] 差戻し者
Class158 設計契約→本契約
Date150 [設契] 新規申請日
Date151 [設契] 管理設計処理日
Date152 [設契] 所属長処理日
Date153 [設契] 着工要因処理日
Date154 [設契] 専務処理日
Date155 [設契] 総務処理日
Date156 [設契] 役員処理日
Date157 [設契] 差戻し日
Date158 本契約移行日
Class160 [設契] 新規申請処理内容
Class161 [設契] 管理設計処理内容
Class162 [設契] 所属長処理内容
Class163 [設契] 着工要因処理内容
Class164 [設契] 専務処理内容
Class165 [設契] 総務処理内容
Class166 [設契] 役員処理内容
Class167 [設契] 差戻し内容
*/
let flowTitle = 'ワークフロー';
const sumi = '★★★';
const next = '▶▷▶';
$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) {
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) {
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();
}