initIndicatorList();
queryIndicatorTree();
queryIndicatorList();
点击三级指标下方出现供选择的数据
var indicator_select = $('#indicator_select');
var minWidth = $element.innerWidth();
indicator_select.width(minWidth);
indicator_select.height($element.innerHeight());
var top = $element.offset().top + 1;
var left = $element.offset().left + 1;
indicator_select.offset({top: top, left: left});
$('#indicator_select').show();
<div id="indicator_select" class="input-group"
style="background-color:#FFFFFF;display:none;position: absolute;width:100%;z-index:9999">
</div>
填报页面
主要思路 : Options ———— columns ———— columnOption
1. $('#' + indicator_table_id).bootstrapTable(options);
2. var options = {
url: prefix + "/list",
updateUrl: prefix + "/edit/{id}",
sortName: "indicatorOne,indicatorTwo",
sortOrder: "",
paginationDetailHAlign: "right",
onLoadSuccess,
onClickCell,
columns: columns
};
3. var columns = [];
4. var columnOption = {
field: indicatorColumnName[i],
title: indicatorColumnTitle[i],
width: indicatorColumnWidth[i]
};
columnOption.formatter = function (value, row, index) {}
5.columns.push(columnOption);
function initIndicatorList() {
var columnsTitle = [];
var titleCount = 0;
var columns = [];
var initRowSpan = 1;
for (var i = 0; i < indicatorColumnHeadTitle.length; i++) {
if (indicatorColumnHeadTitle[i]) {
initRowSpan = 2;
break;
}
}
for (var i = 0; i < 16; i++) {
var colspan = initRowSpan > 1 ? getTitleMerge(i) : -1;
var rowspan = initRowSpan;
var columnOption = {
field: indicatorColumnName[i],
title: indicatorColumnTitle[i],
width: indicatorColumnWidth[i]
};
if (i == 2) {
columnOption.formatter = function (value, row, index) {
if (row.type && row.type == '用户指标' && value != null) {
value = '<i style="float:left" type="primary" class="glyphicon glyphicon-user">' + value + '</i>';
} else if (value) {
value = '<div style="float:left">' + value + '</div>'
}
var values = [];
values.push(value);
if (getRowEdited(index) && indicatorColumnEdited[1])
values.push('<i οnclick="indicator_out_showModel(\'' + row.indicatorOne + '\',\'' + row.indicatorTwo + '\')" data-toggle="modal" data-target="#myModal5" class="glyphicon glyphicon-list" style="color:#2e82ff;float:right" ></i>');
return values.join('');
}
}
if (indicatorColumnName[i] === 'standardType') {
columnOption.formatter = function (value, row, index) {
var standardTypeEditFlag = false;
var resultIndex = 0;
for (var tempindex = 0;tempindex < indicatorColumnName.length; tempindex++) {
if (indicatorColumnName[tempindex] === 'standardType') {
standardTypeEditFlag = indicatorColumnEdited[tempindex];
resultIndex = tempindex;
}
}
if (standardTypeEditFlag && indicator_tableData.rows[index].edited[resultIndex]) {
var selects = [];
selects.push('<select class="indicator_standType" οnchange="doSelectStandType(this.value,' + index + ')">');
for (var i = 0; i < standardTypes.length; i++) {
selects.push('<option value="' + standardTypes[i] + '"');
if (row.standardType === standardTypes[i])
selects.push(' selected ');
selects.push('>' + standardTypes[i] + '</option>');
}
selects.push('</select>');
return selects.join('');
} else {
return row.standardType;
}
}
}
if (indicatorColumnName[i] === 'valueType'){
columnOption.formatter = function (value, row, index) {
debugger;
if (area == "柘荣县" && row.indicatorTwo != "时效目标"){
businessTypes = ['', '定量'];
}
var tempValueTypeEditFlag = false;
var resultIndex = 0;
for (var tempindex = 0;tempindex < indicatorColumnName.length; tempindex++) {
if (indicatorColumnName[tempindex] === 'valueType') {
tempValueTypeEditFlag = indicatorColumnEdited[tempindex];
resultIndex = tempindex;
}
}
if (tempValueTypeEditFlag && indicator_tableData.rows[index].edited[resultIndex]) {
var selects = [];
selects.push('<select class="indicator_inSymbol" οnchange="doSelectValueType(this.value,' + index + ')">');
for (var i = 0; i < businessTypes.length; i++) {
selects.push('<option value="' + businessTypes[i] + '"');
if (row.valueType === businessTypes[i])
selects.push(' selected ');
selects.push('>' + businessTypes[i] + '</option>');
}
selects.push('</select>');
return selects.join('');
} else {
return row.valueType;
}
}
}
if( indicatorColumnName[i] === 'inSymbol'){
columnOption.formatter = function (value, row, index) {
var tempInSymbolEditFlag = false;
var resultIndex = 0,valueTypeIndex = 0;
for (var tempindex = 0;tempindex < indicatorColumnName.length; tempindex++) {
if (indicatorColumnName[tempindex] === 'inSymbol') {
tempInSymbolEditFlag = indicatorColumnEdited[tempindex];
resultIndex = tempindex;
}
if (indicatorColumnName[tempindex] === 'valueType') {
valueTypeIndex = tempindex;
}
}
if (row[indicatorColumnName[valueTypeIndex]] === '定性')
return '';
if (tempInSymbolEditFlag && indicator_tableData.rows[index].edited[resultIndex]) {
var selects = [];
selects.push('<select class="indicator_inSymbol" οnchange="doSelectInSymbol(this.value,' + index + ')">');
for (var i = 0; i < symbols.length; i++) {
selects.push('<option value="' + symbols[i] + '"');
if (row.inSymbol === symbols[i])
selects.push(' selected ');
selects.push('>' + symbolsHtml[i] + '</option>');
}
selects.push('</select>');
return selects.join('');
} else {
return row.inSymbol;
}
}
}
if( indicatorColumnName[i] === 'unit'){
var tempInSymbolEditFlag = false;
var resultIndex = 0,valueTypeIndex = 0;
for (var tempindex = 0;tempindex < indicatorColumnName.length; tempindex++) {
if (indicatorColumnName[tempindex] === 'unit') {
tempInSymbolEditFlag = indicatorColumnEdited[tempindex];
resultIndex = tempindex;
}
if (indicatorColumnName[tempindex] === 'valueType') {
valueTypeIndex = tempindex;
}
}
columnOption.formatter = function (value, row, index) {
if (row[indicatorColumnName[valueTypeIndex]] == '定性'){
indicator_tableData.rows[index].unit = null;
indicator_tableData.rows[index].inSymbol = null;
indicator_tableData.rows[index].symbol = null;
indicator_tableData.rows[index].edited[7] = false;
return " ";
}else {
indicator_tableData.rows[index].edited[7] = true;
}
return value
}
}
if (indicatorColumnVisible[i]) {
if (colspan >= 0) {
rowspan = 1;
titleCount++;
if (colspan > 0) {
columns.push({
title: indicatorColumnHeadTitle[i],
colspan: colspan,
align: 'center',
valign: 'middle'
});
}
columnsTitle.push(columnOption);
} else {
columnOption.rowspan = initRowSpan;
columns.push(columnOption);
}
}
if (i === 1 && indicatorColumnVisible[i] && showIndicatorThreeIndex) {
if (indicatorColumnHeadTitle[i])
columnsTitle.push({
field: 'indThreeIndex',
title: "目标",
width: 70
});
else
columns.push({
field: 'indThreeIndex',
title: "目标",
width: 70,
rowspan: initRowSpan
});
}
if (i === 8 && showSymbol) {
var symbolColumn = {
field: "symbol",
title: symbolTitle,
width: 70,
formatter: function (value, row, index) {
var valueTypeIndex = 0;
for (var tempindex = 0;tempindex < indicatorColumnName.length; tempindex++) {
if (indicatorColumnName[tempindex] === 'valueType') {
valueTypeIndex = tempindex;
}
}
if (row[indicatorColumnName[valueTypeIndex]] === '定性')
return '';
if (symbolEdited && row[indicatorColumnName[2]]) {
var selects = [];
selects.push('<select class="indicator_symbol" οnchange="doSelectSymbol(this.value,' + index + ')">');
for (var i = 0; i < symbols.length; i++) {
selects.push('<option value="' + symbols[i] + '"');
if (row.symbol === symbols[i])
selects.push(' selected ');
selects.push('>' + symbolsHtml[i] + '</option>');
}
selects.push('</select>');
return selects.join('');
} else
return row.symbol;
}
};
if (initRowSpan > 1) {
if (indicatorColumnHeadTitle[i] === symbolHeadTitle) {
columnsTitle.push(symbolColumn);
} else if (symbolHeadTitle) {
var symbolColspan = 1;
for (var j = 8; j < indicatorColumnHeadTitle.length; j++) {
if (!indicatorColumnVisible[j])
continue;
if (symbolHeadTitle === indicatorColumnHeadTitle[j])
symbolColspan++;
else
break;
}
columns.push({
title: symbolHeadTitle,
colspan: symbolColspan,
align: 'center',
valign: 'middle'
});
columnsTitle.push(symbolColumn);
} else {
symbolColumn.rowspan = initRowSpan;
columns.push(symbolColumn);
}
} else {
columns.push(symbolColumn);
}
}
}
if (showFiles) {
columns.push({
field: "file",
title: fileTitle,
width: 200,
rowspan: initRowSpan,
formatter: function (value, row, index) {
var files = [];
if (row.files) {
for (var i = 0; i < row.files.length; i++) {
var file_id = 'file_' + index + '_' + i;
files.push('<a id="' + file_id + '" class="indicator_file pop" οnclick="downLoadFile(' + index + ',' + i + ')" data-container="body" data-toggle="popover" data-placement="top" data-content="' + row.files[i].name + '">')
if (fileEdited && row[indicatorColumnName[2]]) {
files.push('<i οnclick="removeFile(\'' + file_id + '\',' + index + ',' + i + ')" class="fa fa-times-circle" style="display: inline"></i>');
}
files.push('<span >' + row.files[i].name + '</span></a>');
}
}
if (fileEdited && row[indicatorColumnName[2]]) {
files.push('<i style="color:#1E0FBE;vertical-align: middle" data-toggle="modal" data-target="#myModal4" οnclick="showFileSelect(' + index + ')" class="fa fa-folder-open-o"></i>');
}
files.push('<script>resetPopover()<\/script>');
return files.join('');
}
});
}
if (indicatorColumnEdited[1])
columns.push({
title: '操作',
align: 'center',
width: 80,
rowspan: initRowSpan,
formatter: function (value, row, index) {
var actions = [];
actions.push('<div style="margin:0;width:100%;height:100%">');
if (getRowEdited(index)) {
if(indicatorName=='监控指标'){
if(row.isAuto==0){
if (indicatorColumnEdited[1])
actions.push(' <i style="color:green;vertical-align: middle" class="glyphicon glyphicon-plus-sign" οnclick="changeAction(\'' + row.guid + '\',\''+index+'\',\''+row.isAuto+'\')">修改累计值</i><!--</div>-->');
}else{
if (indicatorColumnEdited[1])
actions.push('<i style="color:red;vertical-align: middle" class="glyphicon glyphicon-plus-sign" οnclick="changeAction(\'' + row.guid + '\',\''+index+'\',\''+row.isAuto+'\')">自动计算累计值</i>');
}
}else{
if (indicatorColumnEdited[2])
actions.push('<i style="color:red;vertical-align: middle" οnclick="deleteRow(' + index + ')" class="glyphicon glyphicon-trash"></i>');
if (indicatorColumnEdited[1])
actions.push(' <i style="color:green;vertical-align: middle" οnclick="addRow(' + index + ')" class="glyphicon glyphicon-plus-sign"></i></div>');
}
}
return actions.join('');
}
});
if (titleCount > 0) {
columns = [columns, columnsTitle];
}
for (var j =0;j<columns[0].length-1;j++) {
if (columns[0][j].title == columns[0][j + 1].title){
columns[0][j].colspan += columns[0][j + 1].colspan;
columns[0].splice(j+1,1);
j--;
}
}
var options = {
sortName: "indicatorOne,indicatorTwo",
sortOrder: "",
paginationDetailHAlign: "right",
columns: columns
, onLoadSuccess: function (data) {
mergeTable(indicator_tableData, indicator_table_id);
}
, onClickCell: function (field, value, row, $element) {
for (var i = 2; i < 16; i++) {
if (field == indicatorColumnName[i]) {
if (indicatorColumnEdited[i]) {
var index = $element.parent().data('index');
if (!indicator_tableData.rows[index].edited[i])
return;
if (i == 2) {
indicatorParam.firstIndicator = row[indicatorColumnName[0]];
indicatorParam.secondIndicator = row[indicatorColumnName[1]];
if (lastindex != index) {
if (hideSuggest(lastindex))
return;
curRow = row;
var indicator_select = $('#indicator_select');
var minWidth = $element.innerWidth();
indicator_select.width(minWidth);
indicator_select.height($element.innerHeight());
var top = $element.offset().top + 1;
var left = $element.offset().left + 1;
indicator_select.show();
indicator_select.offset({top: top, left: left});
lastindex = index;
init(index, minWidth);
return;
}
} else if (indicatorColumnName[i]=== 'standardType' ||
indicatorColumnName[i]=== 'inSymbol' ||
indicatorColumnName[i]=== 'valueType') {
} else if (indicator_tableData.rows[index][indicatorColumnName[2]]) {
var contextDiv = document.getElementById("t_div_id1");
if(contextDiv!=null){
break;
}
if (!indicator_tableData.rows[index][field])
$element.html('');
$element.html('<div tabindex="0" id="t_div_id1" style="border: none ; width: 100%;height:100%;min-height:30px;line-height: 30px;" contenteditable="true"> ' + $element.html() + '</div>');
document.getElementById("t_div_id1").focus();
$("#t_div_id1").blur(function () {
var tdValue = document.getElementById("t_div_id1").innerText;
if (!tdValue)
indicator_tableData.rows[index][field] = null;
else{
indicator_tableData.rows[index][field] = tdValue;
$element.html(tdValue);
}
$("#t_div_id1").remove();
if (field == "practicalValue") {
quarterOutputResults();
}
if (field == "value5") {
quarterOutputResults();
}
if (field == "unit") {
}
if(field == "score"){
calculateWholeDepartmentEvaluationScoreHJ();
}
var valueTypeIndex = null;
for (var tempIndex = 2;tempIndex < indicatorColumnName.length;tempIndex ++){
if (indicatorColumnName[tempIndex] === 'valueType'){
valueTypeIndex = tempIndex;
}
}
if(field == "score"||field == "yearTargetScore"||field == "expectedScore"||field == "reference"){
if (valueTypeIndex != null){
if(indicator_tableData.rows[index].valueType == '定量'){
checkSum($element);
}
}
}
});
}
}
break;
}
}
hideSuggest(lastindex);
}
};
$('#' + indicator_table_id).bootstrapTable(options);
$('#' + indicator_table_id).on('reset-view.bs.table', function () {
mergeTable(indicator_tableData, indicator_table_id);
});
loadIndicator();
}