|
@@ -19,7 +19,9 @@ let GLJTypeConst = [];
|
|
|
// spreadjs载入数据所需
|
|
|
let jsonData = [];
|
|
|
let mixRatioConnectData = [];
|
|
|
-
|
|
|
+// 单价文件相关
|
|
|
+let usedUnitPriceInfo = {};
|
|
|
+let otherFileData = {};
|
|
|
let currentTag = '';
|
|
|
let isChanging = false;
|
|
|
$(document).ready(function () {
|
|
@@ -27,6 +29,118 @@ $(document).ready(function () {
|
|
|
init();
|
|
|
});
|
|
|
|
|
|
+ // 单价文件切换弹框
|
|
|
+ $('#change-dj').on('shown.bs.modal', function () {
|
|
|
+ // 获取当前建设项数据
|
|
|
+ let projectName = projectInfoObj.projectInfo.fullFolder !== undefined &&
|
|
|
+ projectInfoObj.projectInfo.fullFolder.length > 0 ? projectInfoObj.projectInfo.fullFolder[0] : '';
|
|
|
+ $("#current-project-name").text(projectName);
|
|
|
+
|
|
|
+ // 获取切换单价文件相关数据
|
|
|
+ $.ajax({
|
|
|
+ url: '/glj/get-project-info',
|
|
|
+ type: 'post',
|
|
|
+ data: {project_id: scUrlUtil.GetQueryString('project')},
|
|
|
+ dataType: 'json',
|
|
|
+ success: function(response) {
|
|
|
+ if (response.err === 1) {
|
|
|
+ alert('数据传输错误!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let data = response.data;
|
|
|
+ // 本项目中的单价文件
|
|
|
+ if (data.self.length > 0) {
|
|
|
+ let selfFileHtml = '';
|
|
|
+ for(let tmp of data.self) {
|
|
|
+ let select = usedUnitPriceInfo === tmp.id ? ' selected="selected"' : '';
|
|
|
+ selfFileHtml += '<option'+ select +' value="'+ tmp.id +'">'+ tmp.name +'</option>';
|
|
|
+ }
|
|
|
+ $("#self-file").html(selfFileHtml);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 其他建设项目数据
|
|
|
+ if (data.other.length > 0) {
|
|
|
+ let otherProjectHtml = '';
|
|
|
+ let otherFileHtml = '';
|
|
|
+ for(let tmp of data.other) {
|
|
|
+ otherProjectHtml += '<option value="'+ tmp.ID +'">'+ tmp.name +'</option>';
|
|
|
+ otherFileData[tmp.ID] = tmp.unitPriceList;
|
|
|
+ if (otherFileHtml !== '') {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for(let unitPrice of tmp.unitPriceList) {
|
|
|
+ otherFileHtml += '<option value="'+ unitPrice.id +'">'+ unitPrice.name +'</option>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $("#other-project").html(otherProjectHtml);
|
|
|
+ $("#other-file").html(otherFileHtml);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ // 从其他建设项目中复制 选择建设项目
|
|
|
+ $("#other-project").change(function() {
|
|
|
+ let projectId = $(this).val();
|
|
|
+ if (otherFileData[projectId] === undefined) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let otherFileHtml = '';
|
|
|
+ for(let unitPrice of otherFileData[projectId]) {
|
|
|
+ otherFileHtml += '<option value="'+ unitPrice.id +'">'+ unitPrice.name +'</option>';
|
|
|
+ }
|
|
|
+ $("#other-file").html(otherFileHtml);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 单价文件选项切换
|
|
|
+ $("input[name='change-type']").change(function() {
|
|
|
+ let type = $(this).val();
|
|
|
+ type = parseInt(type);
|
|
|
+ $("#change-dj .option").hide();
|
|
|
+ if (type === 0) {
|
|
|
+ $(".option.select").show();
|
|
|
+ } else {
|
|
|
+ $(".option.copy").show();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 单价文件切换确认
|
|
|
+ $("#change-file-confirm").click(function() {
|
|
|
+ if (isChanging) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let type = $("input[name='change-type']:checked").val();
|
|
|
+ type = parseInt(type);
|
|
|
+ let changeUnitPriceId = 0;
|
|
|
+ if (type === 0) {
|
|
|
+ // 从本项目中选择
|
|
|
+ changeUnitPriceId = $("#self-file").val();
|
|
|
+ } else {
|
|
|
+ // 从其他项目中复制
|
|
|
+ changeUnitPriceId = $("#other-file").val();
|
|
|
+ }
|
|
|
+ $.ajax({
|
|
|
+ url: '/glj/change-file',
|
|
|
+ type: 'post',
|
|
|
+ data: {project_id: scUrlUtil.GetQueryString('project'), change_id: changeUnitPriceId},
|
|
|
+ error: function() {
|
|
|
+ isChanging = false;
|
|
|
+ },
|
|
|
+ beforeSend: function() {
|
|
|
+ isChanging = true;
|
|
|
+ },
|
|
|
+ success: function(response) {
|
|
|
+ isChanging = false;
|
|
|
+ if (response.err === 1) {
|
|
|
+ let msg = response.msg !== undefined ? response.msg : '未知错误';
|
|
|
+ alert(msg);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $('#change-dj').modal("hide");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
// 是否主动更改数据
|
|
|
// $("#message").on('click', '#load-data', function() {
|
|
|
// $("#notify").slideUp('fast');
|
|
@@ -77,14 +191,13 @@ function init() {
|
|
|
GLJTypeConst = data.constData.GLJTypeConst !== undefined ? JSON.parse(data.constData.GLJTypeConst) : GLJTypeConst;
|
|
|
|
|
|
let usedTenderList = data.usedTenderList !== undefined ? data.usedTenderList : [];
|
|
|
- let usedUnitFileName = data.constData.usedUnitPriceName !== undefined ?
|
|
|
- data.constData.usedUnitPriceName : '';
|
|
|
+ usedUnitPriceInfo = data.constData.usedUnitPriceInfo !== undefined ?
|
|
|
+ data.constData.usedUnitPriceInfo : {};
|
|
|
// 存入缓存
|
|
|
projectObj.project.projectGLJ.datas = jsonData;
|
|
|
- console.log(projectObj.project);
|
|
|
|
|
|
spreadInit();
|
|
|
- unitPriceFileInit(usedUnitFileName, usedTenderList);
|
|
|
+ unitPriceFileInit(usedUnitPriceInfo.name, usedTenderList);
|
|
|
}
|
|
|
});
|
|
|
|