Bläddra i källkod

Merge branch 'master' of http://192.168.1.41:3000/SmartCost/YangHuOperation

Tony Kang 1 år sedan
förälder
incheckning
6b2e6becf7

+ 2 - 0
modules/all_models/compilation.js

@@ -78,6 +78,8 @@ let modelSchema = {
     example: Array,
     // 版本号
     edition: String,
+    // 序号(用于排序)
+    serialNumber: Number,
     // 发布时间
     release_time: {
         type: Number,

+ 26 - 25
modules/all_models/engineering_lib.js

@@ -10,13 +10,13 @@ let mongoose = require("mongoose");
 
 let Schema = mongoose.Schema;
 let collectionName = 'engineering_lib';
-let taxGroupSchema = new  Schema({
+let taxGroupSchema = new Schema({
     taxType: String,//计税方式
-    program_lib: { type: Schema.Types.Mixed,default:{}},// 计算程序标准库
-    template_lib:{ type: Schema.Types.Mixed,default:{}},//清单模板库
-    col_lib:{ type: Schema.Types.Mixed,default:{}},//列设置
-    fee_lib:{ type: Schema.Types.Mixed,default:{}}//费率标准库
-},{_id: false});
+    program_lib: { type: Schema.Types.Mixed, default: {} },// 计算程序标准库
+    template_lib: { type: Schema.Types.Mixed, default: {} },//清单模板库
+    col_lib: { type: Schema.Types.Mixed, default: {} },//列设置
+    fee_lib: { type: Schema.Types.Mixed, default: {} }//费率标准库
+}, { _id: false });
 
 
 let modelSchema = {
@@ -40,22 +40,22 @@ let modelSchema = {
         type: Schema.Types.Mixed,
         default: []
     },
-    tax_group :{
-      type: [taxGroupSchema],
-      default: []
-    },
-   /* // 费率标准库 2018-08-28 改成放在tax_group 里了
-    fee_lib: {
-        type: Schema.Types.Mixed,
+    tax_group: {
+        type: [taxGroupSchema],
         default: []
-    },*/
+    },
+    /* // 费率标准库 2018-08-28 改成放在tax_group 里了
+     fee_lib: {
+         type: Schema.Types.Mixed,
+         default: []
+     },*/
     // 人工系数标准库
     artificial_lib: {
         type: Schema.Types.Mixed,
         default: []
     },
     //工程特征库
-    feature_lib:{
+    feature_lib: {
         type: Schema.Types.Mixed,
         default: []
     },
@@ -80,23 +80,24 @@ let modelSchema = {
         default: []
     },
     //设置人材机显示列
-    glj_col:{
-        showAdjustPrice:Boolean//是否显示调整价列
+    glj_col: {
+        showAdjustPrice: Boolean//是否显示调整价列
     },
     //清单或定额计价规则ID
-    valuationID:{type:String,index: true},
+    valuationID: { type: String, index: true },
     //工程专业名称
-    name:String,
+    name: String,
     //费用标准
-    feeName:String,
+    feeName: String,
     //前端是否显示
-    visible:{type: Boolean, default: false},
+    visible: { type: Boolean, default: false },
     //取费专业
-    engineering:Number,
+    engineering: Number,
     //单位工程取费专业
-    projectEngineering:Number,
+    projectEngineering: Number,
     //是否计算安装增加费
-    isInstall:{type: Boolean, default: false}
+    isInstall: { type: Boolean, default: false },
+    seq: Number//序列号
 };
-mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));
+mongoose.model(collectionName, new Schema(modelSchema, { versionKey: false, collection: collectionName }));
 

+ 38 - 38
modules/price_info_lib/facade/index.js

@@ -312,7 +312,7 @@ async function importKeyData(libID, mainData, subData) {
             taxPrice: rowData[5] || '',
             noTaxPrice: rowData[6] || '',
             dateRemark: rowData[7] || '',
-            expString: rowData[8] ||  '',
+            expString: rowData[8] || '',
             keywordList: keywordMap[code] || [],
         }
         priceItems.push(priceItem);
@@ -430,10 +430,10 @@ async function getAreas(compilationID) {
 
 async function updateAres(updateData) {
     const bulks = [];
-    updateData.forEach(({ ID, name }) => bulks.push({
+    updateData.forEach(({ ID, field, value }) => bulks.push({
         updateOne: {
             filter: { ID },
-            update: { name }
+            update: { [field]: value }
         }
     }));
     if (bulks.length) {
@@ -538,79 +538,79 @@ async function editClassData(updateData) {
 }
 
 //计算指标平均值
-function calcIndexAvg (period, areaID,compilationID,preCodeMap){
-    const newData = []; 
-    for(const code in preCodeMap){
+function calcIndexAvg(period, areaID, compilationID, preCodeMap) {
+    const newData = [];
+    for (const code in preCodeMap) {
         const indexArr = preCodeMap[code];
         let total = 0;
 
-        for(const index of indexArr){
-            total  =   scMathUtil.roundForObj(total + index,2); 
+        for (const index of indexArr) {
+            total = scMathUtil.roundForObj(total + index, 2);
         }
-        const avg = scMathUtil.roundForObj(total/indexArr.length,2); 
-        newData.push({ID:uuidV1(),code,period,areaID,compilationID,index:avg})
+        const avg = scMathUtil.roundForObj(total / indexArr.length, 2);
+        newData.push({ ID: uuidV1(), code, period, areaID, compilationID, index: avg })
     }
     return newData
 }
 
 //一个月里有classCode相同,但是价格不同的情况,取平均值
-function getClassCodePriceAvgMap  (items){
+function getClassCodePriceAvgMap(items) {
     const classCodeMap = {};
-    for(const b of items){
-        classCodeMap[b.classCode]?classCodeMap[b.classCode].push(b):classCodeMap[b.classCode]=[b];
+    for (const b of items) {
+        classCodeMap[b.classCode] ? classCodeMap[b.classCode].push(b) : classCodeMap[b.classCode] = [b];
     }
 
-    for(const classCode in classCodeMap){
+    for (const classCode in classCodeMap) {
         const baseItems = classCodeMap[classCode];
         const item = baseItems[0];
-        if(baseItems.length > 1){
+        if (baseItems.length > 1) {
             let sum = 0;
-            for(const b of baseItems){
-                sum += parseFloat(b.noTaxPrice);       
-            }      
-            classCodeMap[classCode] = {code:item.code,name:item.name,price:scMathUtil.roundForObj(sum/baseItems.length,2)};
-        }else{
-            classCodeMap[classCode] = {code:item.code,name:item.name,price:parseFloat(item.noTaxPrice)}
+            for (const b of baseItems) {
+                sum += parseFloat(b.noTaxPrice);
+            }
+            classCodeMap[classCode] = { code: item.code, name: item.name, price: scMathUtil.roundForObj(sum / baseItems.length, 2) };
+        } else {
+            classCodeMap[classCode] = { code: item.code, name: item.name, price: parseFloat(item.noTaxPrice) }
         }
 
     }
 
     return classCodeMap
-  
+
 }
 
-async function calcPriceIndex(libID,period, areaID,compilationID){
-    const baseItems = await priceInfoItemModel.find({areaID,period:'2022年-01月'}).lean();//以珠海 22年1月的数据为基准
-    const currentItems =  await priceInfoItemModel.find({areaID,period}).lean();
+async function calcPriceIndex(libID, period, areaID, compilationID) {
+    const baseItems = await priceInfoItemModel.find({ areaID, period: '2022年-01月' }).lean();//以珠海 22年1月的数据为基准
+    const currentItems = await priceInfoItemModel.find({ areaID, period }).lean();
     const preCodeMap = {};//编码前4位-指数映射
     const baseAvgMap = getClassCodePriceAvgMap(baseItems);
     const currentAvgMap = getClassCodePriceAvgMap(currentItems);
-    
+
     let message = '';
 
-    for(const classCode in currentAvgMap){
+    for (const classCode in currentAvgMap) {
         const c = currentAvgMap[classCode];
-        const preCode = c.code.substr(0,4);
+        const preCode = c.code.substr(0, 4);
         let index = 1;
         const baseItem = baseAvgMap[classCode];
-        const tem = {index,classCode,name:c.name,code:c.code};
-        
-        if(baseItem && baseItem.price){//一个月份里有多个值时,先取平均再计算
-            index =  scMathUtil.roundForObj(c.price/baseItem.price,2);
+        const tem = { index, classCode, name: c.name, code: c.code };
+
+        if (baseItem && baseItem.price) {//一个月份里有多个值时,先取平均再计算
+            index = scMathUtil.roundForObj(c.price / baseItem.price, 2);
             tem.baseName = baseItem.name;
         }
         tem.index = index;
-        if(Math.abs(index - 1) > 0.2){
+        if (Math.abs(index - 1) > 0.2) {
             const string = `classCode:${tem.classCode},编号:${tem.code},基础名称:${tem.baseName},当前库中名称:${tem.name},指数:${tem.index};\n`;
-            message +=string;
+            message += string;
             console.log(string)
-        } 
+        }
 
-      preCodeMap[preCode]?preCodeMap[preCode].push(index):preCodeMap[preCode]=[index];
+        preCodeMap[preCode] ? preCodeMap[preCode].push(index) : preCodeMap[preCode] = [index];
     }
-    const newIndexData = calcIndexAvg(period, areaID,compilationID,preCodeMap)
+    const newIndexData = calcIndexAvg(period, areaID, compilationID, preCodeMap)
     //删除旧数据
-    await priceInfoIndexModel.deleteMany({areaID,period});
+    await priceInfoIndexModel.deleteMany({ areaID, period });
     //插入新数据
     await priceInfoIndexModel.insertMany(newIndexData);
     return message;

+ 110 - 96
modules/users/controllers/compilation_controller.js

@@ -11,10 +11,10 @@ import STDRationLibMapModel from "../../common/std/std_ration_lib_map_model";
 import STDBillLibListsModel from "../../common/std/std_bills_lib_lists_model";
 import STDGLJLibMapModel from "../../common/std/std_glj_lib_map_model";
 import STDFeeRateLibsModel from "../../common/std/std_fee_rate_libs_model";
-import {default as EngineeringConst, List as EngineeringList} from "../../common/const/engineering";
+import { default as EngineeringConst, List as EngineeringList } from "../../common/const/engineering";
 import BillsTemplateModel from "../models/bills_template_model";
-import {default as BillsFixedFlagConst, List as BillsFixedFlagList} from "../../common/const/bills_fixed.js";
-import {default as BillsTypeFlagConst, List as BillsTypeFlagList} from "../../common/const/bills_type.js";
+import { default as BillsFixedFlagConst, List as BillsFixedFlagList } from "../../common/const/bills_fixed.js";
+import { default as BillsTypeFlagConst, List as BillsTypeFlagList } from "../../common/const/bills_type.js";
 import EngineeringLibModel from "../models/engineering_lib_model";
 import STDLabourCoesModel from "../../common/std/std_labour_coes_model";
 import STDCalcProgramModel from "../../common/std/std_calc_program_model";
@@ -26,11 +26,12 @@ import basicInfoFacade from "../../basic_info_lib/facade/basic_info_facade";
 import progressiveFacade from "../../progressive_interval_lib/facade/progressive_facade";
 import vvTaxFacade from "../../vehicleVessel_lib/facade/vvTax_facade";
 import billCodeFacade from "../../bill_code_lib/facade/bill_code_facade";
-import {default as category, List as categoryList} from "../../common/const/category_const.js";
-import locationList from  "../../common/const/locationList";
+import { default as category, List as categoryList } from "../../common/const/category_const.js";
+import locationList from "../../common/const/locationList";
 
 let config = require("../../../config/config.js");
 const fs = require('fs');
+let _ = require('lodash');
 
 class CompilationController extends BaseController {
 
@@ -74,11 +75,11 @@ class CompilationController extends BaseController {
             id: id,
             compilationList: compilationList,
             categoryList: categoryList,
-            locationList:locationList,
+            locationList: locationList,
             selectedCompilation: selectedCompilation,
-            title : config[process.env.NODE_ENV].title?config[process.env.NODE_ENV].title:'养护云版',
+            title: config[process.env.NODE_ENV].title ? config[process.env.NODE_ENV].title : '养护云版',
             layout: 'users/views/layout/layout',
-            LicenseKey:config.getLicenseKey(process.env.NODE_ENV)
+            LicenseKey: config.getLicenseKey(process.env.NODE_ENV)
         };
 
         response.render('users/views/compilation/index', renderData);
@@ -156,6 +157,7 @@ class CompilationController extends BaseController {
             // 获取计价规则中对应的标准库数据
             let engineeringLibModel = new EngineeringLibModel();
             engineeringList = await engineeringLibModel.getLibsByValuationID(valuationId);
+            engineeringList = _.sortBy(engineeringList, ['seq'])
 
         } catch (error) {
             console.log(error);
@@ -170,8 +172,8 @@ class CompilationController extends BaseController {
             valuationId: valuationId,
             section: section,
             layout: 'users/views/layout/layout',
-            title : config[process.env.NODE_ENV].title?config[process.env.NODE_ENV].title:'养护云版',
-            LicenseKey:config.getLicenseKey(process.env.NODE_ENV)
+            title: config[process.env.NODE_ENV].title ? config[process.env.NODE_ENV].title : '养护云版',
+            LicenseKey: config.getLicenseKey(process.env.NODE_ENV)
         };
         response.render('users/views/compilation/add', renderData);
     }
@@ -233,9 +235,9 @@ class CompilationController extends BaseController {
             calculationList = await stdCalcProgramModel.getProgramList(selectedCompilation._id);
 
             //获取列设置库
-             mainTreeColList = await mainColFacade.getColLibsByCompilationID(selectedCompilation._id);
+            mainTreeColList = await mainColFacade.getColLibsByCompilationID(selectedCompilation._id);
 
-             //获取清单模板库
+            //获取清单模板库
             billTemplateList = await billTemplateFacade.getTemplateLibByCompilationID(selectedCompilation._id);
 
             // 获取对应的计价规则数据
@@ -246,29 +248,29 @@ class CompilationController extends BaseController {
 
             // 获取对应专业工程下的标准库数据
             let engineeringLibModel = new EngineeringLibModel();
-            libData = await engineeringLibModel.findDataByCondition({_id:engineerID});
+            libData = await engineeringLibModel.findDataByCondition({ _id: engineerID });
 
             // 获取清单模板数据
             let billsTemplateModel = new BillsTemplateModel();
             billsTemplateData = await billsTemplateModel.getTemplateData(valuationId, libData.engineering);
 
             //获取清单指引数据
-            billsGuidanceList = await billsGuidanceFc.getBillsGuideLibs({compilationId: selectedCompilation._id, $or: [{deleted: null}, {deleted: false}]});
+            billsGuidanceList = await billsGuidanceFc.getBillsGuideLibs({ compilationId: selectedCompilation._id, $or: [{ deleted: null }, { deleted: false }] });
 
             //获取工程特征库
-            featureList = await projectFeatureFacade.findByCondition({compilationId: selectedCompilation._id},null,false);
+            featureList = await projectFeatureFacade.findByCondition({ compilationId: selectedCompilation._id }, null, false);
 
             //获取基本信息库
-            infoList = await basicInfoFacade.findByCondition({},null,false);
+            infoList = await basicInfoFacade.findByCondition({}, null, false);
 
             //获取累进区间库
-            progressiveList = await progressiveFacade.findByCondition({},null,false);
+            progressiveList = await progressiveFacade.findByCondition({}, null, false);
 
             //获取车船税库
             vvTaxList = await vvTaxFacade.findByCondition({}, false, false);
 
-             //获取递延清单库
-             billCodeList = await billCodeFacade.findByCondition({}, false, false);
+            //获取递延清单库
+            billCodeList = await billCodeFacade.findByCondition({}, false, false);
 
         } catch (error) {
             console.log(error);
@@ -289,19 +291,19 @@ class CompilationController extends BaseController {
             artificialCoefficientList: JSON.stringify(artificialCoefficientList),
             feeRateList: JSON.stringify(feeRateList),
             billsTemplateData: JSON.stringify(billsTemplateData),
-            billTemplateList:JSON.stringify(billTemplateList),
+            billTemplateList: JSON.stringify(billTemplateList),
             mainTreeColList: JSON.stringify(mainTreeColList),
-            gljCol:JSON.stringify(libData.glj_col),
+            gljCol: JSON.stringify(libData.glj_col),
             calculationList: JSON.stringify(calculationList),
             billsGuidanceList: JSON.stringify(billsGuidanceList),
-            featureList:JSON.stringify(featureList),
+            featureList: JSON.stringify(featureList),
             infoList: JSON.stringify(infoList),
-            progressiveList:JSON.stringify(progressiveList),
+            progressiveList: JSON.stringify(progressiveList),
             vvTaxList: JSON.stringify(vvTaxList),
             billCodeList: JSON.stringify(billCodeList),
-            title : config[process.env.NODE_ENV].title?config[process.env.NODE_ENV].title:'养护云版',
+            title: config[process.env.NODE_ENV].title ? config[process.env.NODE_ENV].title : '养护云版',
             layout: 'users/views/layout/layout',
-            LicenseKey:config.getLicenseKey(process.env.NODE_ENV)
+            LicenseKey: config.getLicenseKey(process.env.NODE_ENV)
         };
         response.render('users/views/compilation/engineering', renderData);
     }
@@ -342,22 +344,22 @@ class CompilationController extends BaseController {
      * @param response
      * @returns {Promise.<void>}
      */
-    async deleteEngineer(request,response){
-        let result={
-            error:0
+    async deleteEngineer(request, response) {
+        let result = {
+            error: 0
         };
         try {
             let data = request.body.data;
             data = JSON.parse(data);
-            if(data.id ){
+            if (data.id) {
                 let engineeringLibModel = new EngineeringLibModel();
-                result.data = await engineeringLibModel.deleteById(data.id,true);
-            }else {
+                result.data = await engineeringLibModel.deleteById(data.id, true);
+            } else {
                 throw new Error("提交数据有误");
             }
-        }catch (err){
+        } catch (err) {
             console.log(err);
-            result.error=1;
+            result.error = 1;
             result.message = err.message;
         }
         response.json(result);
@@ -369,23 +371,23 @@ class CompilationController extends BaseController {
      * @param response
      * @returns {Promise.<void>}
      */
-    async updateEngineer(request,response){
-        let result={
-            error:0
+    async updateEngineer(request, response) {
+        let result = {
+            error: 0
         };
         try {
             let data = request.body.data;
             data = JSON.parse(data);
-            if(data.id && data.updateData){
+            if (data.id && data.updateData) {
                 let engineeringLibModel = new EngineeringLibModel();
-                result.data = await engineeringLibModel.updateById(data.id,data.updateData);
-            }else {
+                result.data = await engineeringLibModel.updateById(data.id, data.updateData);
+            } else {
                 throw new Error("提交数据有误");
             }
 
-        }catch (err){
+        } catch (err) {
             console.log(err);
-            result.error=1;
+            result.error = 1;
             result.message = err.message;
         }
         response.json(result);
@@ -493,7 +495,7 @@ class CompilationController extends BaseController {
      * @param {object} response
      * @return {void}
      */
-     async setFileTypes(request, response) {
+    async setFileTypes(request, response) {
         let id = request.body.id;
         let section = request.params.section;
         let fileTypes = request.body.fileTypes;
@@ -586,22 +588,22 @@ class CompilationController extends BaseController {
         response.json(responseData);
     }
 
-    async setDescription(request, response){
+    async setDescription(request, response) {
         let compilationId = request.body.id;
         let description = request.body.description;
-        try{
+        try {
             let compilationModel = new CompilationModel();
             await compilationModel.setDescription(compilationId, description);
-            response.json({err: 0, msg: '', data: null});
+            response.json({ err: 0, msg: '', data: null });
         }
-        catch (err){
-            response.json({err: 1, msg: err, data: null});
+        catch (err) {
+            response.json({ err: 1, msg: err, data: null });
         }
     }
-    async setOverWriteUrl(request, response){
+    async setOverWriteUrl(request, response) {
         let compilationId = request.body.id;
         let overWriteUrl = request.body.overWriteUrl;
-        try{
+        try {
             let compilationModel = new CompilationModel();
             //绝对路径
             let absoluteUrl = request.app.locals.rootDir + overWriteUrl;
@@ -609,33 +611,33 @@ class CompilationController extends BaseController {
             let fileExists = fs.existsSync(absoluteUrl);
             let pricePropertiesTemplate = [],
                 consumeAmtPropertiesTemplate = [];
-            if(fileExists && fs.statSync(absoluteUrl).isFile()){
+            if (fileExists && fs.statSync(absoluteUrl).isFile()) {
                 //读取配置文件并赋值
                 let overWriteExports = require(absoluteUrl);
-                if(overWriteExports){
+                if (overWriteExports) {
                     pricePropertiesTemplate = overWriteExports.pricePropertiesTemplate ? overWriteExports.pricePropertiesTemplate : [];
                     consumeAmtPropertiesTemplate = overWriteExports.consumeAmtPropertiesTemplate ? overWriteExports.consumeAmtPropertiesTemplate : [];
                 }
             }
             await compilationModel.setOverWriteUrl(compilationId, overWriteUrl, pricePropertiesTemplate, consumeAmtPropertiesTemplate);
-            response.json({err: 0, msg: '', data: null});
+            response.json({ err: 0, msg: '', data: null });
         }
-        catch (err){
+        catch (err) {
             console.log(err);
-            response.json({err: 1, msg: err, data: null});
+            response.json({ err: 1, msg: err, data: null });
         }
     }
-    async setExample(request, response){
+    async setExample(request, response) {
         let compilationId = request.body.id,
             example = request.body.example;
         try {
             let compilationModel = new CompilationModel();
             await compilationModel.setExample(compilationId, example);
-            response.json({err: 0, msg: 'success', data: null});
+            response.json({ err: 0, msg: 'success', data: null });
         }
-        catch (err){
+        catch (err) {
             console.log(err);
-            response.json({err: 1, msg: err, data: null});
+            response.json({ err: 1, msg: err, data: null });
         }
     }
 
@@ -687,9 +689,9 @@ class CompilationController extends BaseController {
             compilationList: compilationList,
             valuationId: valuationId,
             section: section,
-            title : config[process.env.NODE_ENV].title?config[process.env.NODE_ENV].title:'养护云版',
+            title: config[process.env.NODE_ENV].title ? config[process.env.NODE_ENV].title : '养护云版',
             layout: 'users/views/layout/layout',
-            LicenseKey:config.getLicenseKey(process.env.NODE_ENV)
+            LicenseKey: config.getLicenseKey(process.env.NODE_ENV)
         };
         response.render('users/views/compilation/template', renderData);
     }
@@ -710,9 +712,9 @@ class CompilationController extends BaseController {
         let result = await billsTemplateModel.updateTemplate(valuationId, engineering, data);
 
         if (result) {
-            response.json({error: 0, message: '', data: data});
+            response.json({ error: 0, message: '', data: data });
         } else {
-            response.json({error: 1, message: '更新数据错误', data: null});
+            response.json({ error: 1, message: '更新数据错误', data: null });
         }
     }
 
@@ -728,11 +730,11 @@ class CompilationController extends BaseController {
 
     }
 
-    async addEngineer(request,response){
+    async addEngineer(request, response) {
         let engineeringLibModel = new EngineeringLibModel();
         try {
             await engineeringLibModel.addEngineer(request.body);
-        }catch (error) {
+        } catch (error) {
             console.log(error);
         }
         response.redirect(request.headers.referer);
@@ -753,21 +755,21 @@ class CompilationController extends BaseController {
             let compilationModel = new CompilationModel();
             let result = await compilationModel.updateCategory(valuationId, category);
             if (result) {
-                response.json({error: 0, message: '', data: null});
+                response.json({ error: 0, message: '', data: null });
             } else {
-                response.json({error: 1, message: '更新数据错误', data: null});
+                response.json({ error: 1, message: '更新数据错误', data: null });
             }
-        } catch(error) {
-            response.json({error: 1, message: '更新数据错误', data: null});
+        } catch (error) {
+            response.json({ error: 1, message: '更新数据错误', data: null });
         }
     }
-      /**
-     * 更改编办默认工程所在工
-     *
-     * @param request
-     * @param response
-     * @return {Promise.<void>}
-     */
+    /**
+   * 更改编办默认工程所在工
+   *
+   * @param request
+   * @param response
+   * @return {Promise.<void>}
+   */
     async changeLocation(request, response) {
         let compilationId = request.body.id;
         let location = request.body.location;
@@ -775,49 +777,61 @@ class CompilationController extends BaseController {
             let compilationModel = new CompilationModel();
             let result = await compilationModel.updateLocation(compilationId, location);
             if (result) {
-                response.json({error: 0, message: '', data: null});
+                response.json({ error: 0, message: '', data: null });
             } else {
-                response.json({error: 1, message: '更新数据错误', data: null});
+                response.json({ error: 1, message: '更新数据错误', data: null });
             }
-        } catch(error) {
-            response.json({error: 1, message: '更新数据错误', data: null});
+        } catch (error) {
+            response.json({ error: 1, message: '更新数据错误', data: null });
         }
     }
 
 
-     /**
-     * 更改编办默认工程所在工
-     *
-     * @param request
-     * @param response
-     * @return {Promise.<void>}
-     */
-      async changeFreeUse(request, response) {
+    /**
+    * 更改编办默认工程所在工
+    *
+    * @param request
+    * @param response
+    * @return {Promise.<void>}
+    */
+    async changeFreeUse(request, response) {
         let compilationId = request.body.id;
         let freeUse = request.body.freeUse;
         try {
             let compilationModel = new CompilationModel();
             let result = await compilationModel.updateFreeUse(compilationId, freeUse);
             if (result) {
-                response.json({error: 0, message: '', data: null});
+                response.json({ error: 0, message: '', data: null });
             } else {
-                response.json({error: 1, message: '更新数据错误', data: null});
+                response.json({ error: 1, message: '更新数据错误', data: null });
             }
-        } catch(error) {
-            response.json({error: 1, message: '更新数据错误', data: null});
+        } catch (error) {
+            response.json({ error: 1, message: '更新数据错误', data: null });
         }
     }
 
-    async setEdition(request, response){
+    async setEdition(request, response) {
         let compilationId = request.body.id;
         let edition = request.body.edition;
-        try{
+        try {
             let compilationModel = new CompilationModel();
             await compilationModel.setEdition(compilationId, edition);
-            response.json({err: 0, msg: '', data: null});
+            response.json({ err: 0, msg: '', data: null });
+        }
+        catch (err) {
+            response.json({ err: 1, msg: err, data: null });
+        }
+    }
+    async setSerialNumber(request, response) {
+        let compilationId = request.body.id;
+        let serialNumber = request.body.serialNumber;
+        try {
+            let compilationModel = new CompilationModel();
+            await compilationModel.setSerialNumber(compilationId, serialNumber);
+            response.json({ err: 0, msg: '', data: null });
         }
-        catch (err){
-            response.json({err: 1, msg: err, data: null});
+        catch (err) {
+            response.json({ err: 1, msg: err, data: null });
         }
     }
 }

+ 70 - 51
modules/users/models/compilation_model.js

@@ -7,7 +7,7 @@
  */
 import mongoose from "mongoose";
 import BaseModel from "../../common/base/base_model";
-import  uuidV1  from 'uuid/v1';
+import uuidV1 from 'uuid/v1';
 
 class CompilationModel extends BaseModel {
 
@@ -36,7 +36,8 @@ class CompilationModel extends BaseModel {
      */
     async getCompilationList(fields = null) {
         // 筛选字段
-        let field = fields == null ? {_id: 1, name: 1, is_release: 1,release_time:1, defaultLocation:1,categoryID: 1, description: 1,overWriteUrl: 1,example: 1,edition: 1,freeUse:1,
+        let field = fields == null ? {
+            _id: 1, name: 1, is_release: 1, release_time: 1, defaultLocation: 1, categoryID: 1, description: 1, overWriteUrl: 1, example: 1, edition: 1, freeUse: 1,
             "ration_valuation.id": 1, "ration_valuation.name": 1, "ration_valuation.enable": 1,
             "suggestion_valuation.id": 1, "suggestion_valuation.name": 1, "suggestion_valuation.enable": 1,
             "feasibility_valuation.id": 1, "feasibility_valuation.name": 1, "feasibility_valuation.enable": 1,
@@ -44,10 +45,18 @@ class CompilationModel extends BaseModel {
             "bill_valuation.id": 1, "bill_valuation.name": 1, "bill_valuation.enable": 1,
             "estimation_valuation.id": 1, "estimation_valuation.name": 1, "estimation_valuation.enable": 1,
             "bill_valuation.fileTypes": 1
-            } : fields;
-        let compilationData = await this.findDataByCondition({name: {$ne: ''}}, field, false);
-
-        return compilationData === null ? [] : compilationData;
+        } : fields;
+        // 一定要查询序号,然后排序输出
+        field.serialNumber = 1;
+        let compilationData = await this.findDataByCondition({ name: { $ne: '' } }, field, false);
+        if (compilationData) {
+            // 按照序号排序
+            compilationData.sort((aa, bb) => {
+                return (aa.serialNumber || 99999) - (bb.serialNumber || 99999);
+            });
+            return compilationData;
+        }
+        return [];
     }
 
     /**
@@ -57,8 +66,8 @@ class CompilationModel extends BaseModel {
      */
     async getList() {
         // 筛选字段
-        let field = {_id: 1, name: 1, is_release: 1, description: 1, categoryID: 1};
-        let compilationData = await this.findDataByCondition({name: {$ne: ''}, is_release: true}, field, false);
+        let field = { _id: 1, name: 1, is_release: 1, description: 1, categoryID: 1 };
+        let compilationData = await this.findDataByCondition({ name: { $ne: '' }, is_release: true }, field, false);
 
         return compilationData === null ? [] : compilationData;
     }
@@ -70,9 +79,9 @@ class CompilationModel extends BaseModel {
      * @return {Promise}
      */
     async getCompilationById(id) {
-        let condition = {_id: id, is_release: true};
+        let condition = { _id: id, is_release: true };
         let compilationData = await this.findDataByCondition(condition);
-        if (!compilationData  || compilationData.bill_valuation === undefined) {
+        if (!compilationData || compilationData.bill_valuation === undefined) {
             return compilationData;
         }
 
@@ -141,14 +150,14 @@ class CompilationModel extends BaseModel {
     * @param {String} description
     * @return {Promise}
     * */
-    async setDescription(compilationId, description){
-        return await this.updateById(compilationId, {description: description});
+    async setDescription(compilationId, description) {
+        return await this.updateById(compilationId, { description: description });
     }
     /*
         设置代码覆盖路径
      */
-    async setOverWriteUrl(compilationId, overWriteUrl, priceProp, consumeAmtProp){
-        return await this.updateById(compilationId, {overWriteUrl: overWriteUrl, priceProperties: priceProp, consumeAmtProperties: consumeAmtProp});
+    async setOverWriteUrl(compilationId, overWriteUrl, priceProp, consumeAmtProp) {
+        return await this.updateById(compilationId, { overWriteUrl: overWriteUrl, priceProperties: priceProp, consumeAmtProperties: consumeAmtProp });
     }
 
     /*
@@ -164,7 +173,7 @@ class CompilationModel extends BaseModel {
                 data.push(parseInt(projId));
             }
         }
-        return await this.updateById(compilationId, {example: data});
+        return await this.updateById(compilationId, { example: data });
     }
 
     /**
@@ -176,7 +185,7 @@ class CompilationModel extends BaseModel {
      * @return {Promise}
      */
     async addValuation(id, section, data) {
-        let condition = {_id: id};
+        let condition = { _id: id };
         let compilationData = await this.findDataByCondition(condition);
         if (compilationData === null || compilationData.name === undefined) {
             throw '没有找到对应的数据';
@@ -240,7 +249,7 @@ class CompilationModel extends BaseModel {
         return result !== null && result.ok === 1;
     }
 
- 
+
     /**
      * 设置计价规则适用类型
      *
@@ -249,7 +258,7 @@ class CompilationModel extends BaseModel {
      * @param {String} setFileTypes
      * @return {Promise}
      */
-     async setFileTypes(valuationId, section, fileTypes) {
+    async setFileTypes(valuationId, section, fileTypes) {
         let sectionString = section + "_valuation";
         let condition = {};
         condition[sectionString + ".id"] = valuationId;
@@ -299,14 +308,14 @@ class CompilationModel extends BaseModel {
         if (this.sectionList.indexOf(section) < 0) {
             throw '数据有误';
         }
-        let compilationData = await this.findDataByCondition({_id: compilationId});
+        let compilationData = await this.findDataByCondition({ _id: compilationId });
         if (Object.keys(compilationData).length <= 0) {
             throw '编办数据有误';
         }
         let result = {};
         let sectionString = section + '_valuation';
 
-        for(let valuation of compilationData[sectionString]) {
+        for (let valuation of compilationData[sectionString]) {
             if (valuation.id.toString() === id) {
                 result = valuation;
                 break;
@@ -334,10 +343,10 @@ class CompilationModel extends BaseModel {
      * @return {Promise}
      */
     async deleteValuation(compilationId, valuationId, section) {
-        let condition = {_id: compilationId};
+        let condition = { _id: compilationId };
         let sectionString = section + '_valuation';
         let deleteData = {};
-        deleteData[sectionString] = {id: valuationId};
+        deleteData[sectionString] = { id: valuationId };
 
         // 利用pull删除嵌套数据
         let result = await this.db.deleteSet(condition, deleteData);
@@ -355,7 +364,7 @@ class CompilationModel extends BaseModel {
     async release(id, status) {
         // 如果是发布编办则需要判断配置的内容是否满足发布条件
         if (status) {
-            let compilationData = await this.findDataByCondition({_id: id});
+            let compilationData = await this.findDataByCondition({ _id: id });
             // 最少需要有一个计价规则存在
             if (compilationData.suggestion_valuation.length <= 0 &&
                 compilationData.feasibility_valuation.length <= 0 &&
@@ -405,8 +414,8 @@ class CompilationModel extends BaseModel {
             throw '不存在对应编办';
         }
         let valuationData = null;
-        for(let valuation of compilationData[sectionString]) {
-            if(valuation.id === valuationId) {
+        for (let valuation of compilationData[sectionString]) {
+            if (valuation.id === valuationId) {
                 valuationData = valuation;
             }
         }
@@ -418,7 +427,7 @@ class CompilationModel extends BaseModel {
         // 判断是否已有对应数据
         let engineeringList = valuationData.engineering_list;
         let engineeringLib = null;
-        for(let tmpEngineering of engineeringList) {
+        for (let tmpEngineering of engineeringList) {
             if (tmpEngineering.engineering === engineering) {
                 engineeringLib = tmpEngineering;
                 break;
@@ -456,42 +465,52 @@ class CompilationModel extends BaseModel {
      * @return {Promise}
      * */
     async updateCategory(compilationId, category) {
-        return await this.updateById(compilationId, {categoryID: category});
+        return await this.updateById(compilationId, { categoryID: category });
     }
 
-     /*
-     * 设置工程默认所在地
-     *
-     * @param {String} compilationId
-     * @param {int} location
-     * @return {Promise}
-     * */
+    /*
+    * 设置工程默认所在地
+    *
+    * @param {String} compilationId
+    * @param {int} location
+    * @return {Promise}
+    * */
     async updateLocation(compilationId, location) {
-        return await this.updateById(compilationId, {defaultLocation: location});
+        return await this.updateById(compilationId, { defaultLocation: location });
     }
 
-     /*
-     * 设置是否提供免费版
-     *
-     * @param {String} compilationId
-     * @param {int} location
-     * @return {Promise}
-     * */
-     async updateFreeUse(compilationId, freeUse) {
-        return await this.updateById(compilationId, {freeUse: freeUse});
+    /*
+    * 设置是否提供免费版
+    *
+    * @param {String} compilationId
+    * @param {int} location
+    * @return {Promise}
+    * */
+    async updateFreeUse(compilationId, freeUse) {
+        return await this.updateById(compilationId, { freeUse: freeUse });
+    }
+
+    /*
+      * 设置版本号
+      *
+      * @param {String} compilationId
+      * @param {String} edition
+      * @return {Promise}
+      * */
+    async setEdition(compilationId, edition) {
+        return await this.updateById(compilationId, { edition: edition });
     }
 
-  /*
-    * 设置版本号
+    /*
+    * 设置
     *
     * @param {String} compilationId
-    * @param {String} edition
+    * @param {Number} serialNumber
     * @return {Promise}
     * */
-  async setEdition(compilationId, edition){
-    return await this.updateById(compilationId, {edition: edition});
-   }
-
+    async setSerialNumber(compilationId, serialNumber) {
+        return await this.updateById(compilationId, { serialNumber: serialNumber });
+    }
 }
 
 export default CompilationModel;

+ 1 - 0
modules/users/routes/compilation_route.js

@@ -38,5 +38,6 @@ module.exports = function (app) {
     router.post('/changeLocation', compilationController.auth, compilationController.init, compilationController.changeLocation);
     router.post('/changeFreeUse', compilationController.auth, compilationController.init, compilationController.changeFreeUse);
     router.post('/setEdition', compilationController.auth, compilationController.init, compilationController.setEdition);
+    router.post('/setSerialNumber', compilationController.auth, compilationController.init, compilationController.setSerialNumber);
     app.use("/compilation", router);
 };

+ 1 - 1
web/maintain/price_info_lib/html/edit.html

@@ -24,7 +24,7 @@
 
         </nav>
     </div>
-    <div class="wrapper">
+    <div class="wrapper" style="overflow: hidden;">
         <div class="main">
             <div class="left">
                 <div class="top" id="area-spread"></div>

+ 35 - 20
web/maintain/price_info_lib/js/index.js

@@ -59,7 +59,10 @@ const locked = lockUtil.getLocked();
 const AREA_BOOK = (() => {
     const cache = areaList;
     const setting = {
-        header: [{ headerName: '地区', headerWidth: $('#area-spread').width(), dataCode: 'name', dataType: 'String', hAlign: 'center', vAlign: 'center' }]
+        header: [
+            { headerName: '序号', headerWidth: 60, dataCode: 'serialNo', dataType: 'Number', hAlign: 'center', vAlign: 'center' },
+            { headerName: '地区', headerWidth: $('#area-spread').width() - 80, dataCode: 'name', dataType: 'String', hAlign: 'center', vAlign: 'center' },
+        ]
     };
     // 初始化表格
     const workBook = initSheet($('#area-spread')[0], setting);
@@ -78,21 +81,33 @@ const AREA_BOOK = (() => {
     // 编辑处理
     async function handleEdit(changedCells) {
         const updateData = [];
+        let reSort = false;
         changedCells.forEach(({ row, col }) => {
+            const field = setting.header[col].dataCode;
+            let value = sheet.getValue(row, col);
+            if (field === 'serialNo') {
+                reSort = true;
+                value = +value;
+            }
             updateData.push({
                 row,
+                field,
+                value,
                 ID: cache[row].ID,
-                name: sheet.getValue(row, col)
             });
         });
         try {
             await ajaxPost('/priceInfo/editArea', { updateData }, TIME_OUT);
-            updateData.forEach(({ row, name }) => cache[row].name = name);
+            updateData.forEach(({ row, field, value }) => cache[row][field] = value);
+            if (reSort) {
+                cache.sort((a, b) => a.serialNo - b.serialNo);
+                showData(sheet, cache, setting.header);
+            }
         } catch (err) {
             // 恢复各单元格数据
             sheetCommonObj.renderSheetFunc(sheet, () => {
-                changedCells.forEach(({ row }) => {
-                    sheet.setValue(cache[row].name);
+                changedCells.forEach(({ row, col, field }) => {
+                    sheet.setValue(row, col, cache[row][field]);
                 });
             });
         }
@@ -645,19 +660,19 @@ const CLASS_BOOK = (() => {
 
 
 
-    $calcPriceIndex.click(_.debounce(async()=>{
+    $calcPriceIndex.click(_.debounce(async () => {
         $.bootstrapLoading.start();
         try {
-        const data = await ajaxPost('/priceInfo/calcPriceIndex', { libID, period:curLibPeriod,compilationID }, TIME_OUT);
-          //alert(data);
-          
-          if(data){
-              const htmlStr = data.replace(/\n/gm,'<br>'); //replaceAll('\n','<br>',data);
-              $("#result-info-body").html(htmlStr);
-              $("#result-info").modal('show');
-          }else{
-              alert('计算完成!')
-          }  
+            const data = await ajaxPost('/priceInfo/calcPriceIndex', { libID, period: curLibPeriod, compilationID }, TIME_OUT);
+            //alert(data);
+
+            if (data) {
+                const htmlStr = data.replace(/\n/gm, '<br>'); //replaceAll('\n','<br>',data);
+                $("#result-info-body").html(htmlStr);
+                $("#result-info").modal('show');
+            } else {
+                alert('计算完成!')
+            }
 
 
         } catch (error) {
@@ -700,7 +715,7 @@ const KEYWORD_BOOK = (() => {
     }
 
     return {
-        showKeywordData 
+        showKeywordData
     }
 })();
 
@@ -708,8 +723,8 @@ const KEYWORD_BOOK = (() => {
 const PRICE_BOOK = (() => {
     const setting = {
         header: [
-            { headerName: '编码', headerWidth: 100, dataCode: 'code', dataType: 'String', hAlign: 'left', vAlign: 'center' ,formatter: "@"},
-            { headerName: '别名编码', headerWidth: 70, dataCode: 'classCode', dataType: 'String', hAlign: 'left', vAlign: 'center' ,formatter: "@"},
+            { headerName: '编码', headerWidth: 100, dataCode: 'code', dataType: 'String', hAlign: 'left', vAlign: 'center', formatter: "@" },
+            { headerName: '别名编码', headerWidth: 70, dataCode: 'classCode', dataType: 'String', hAlign: 'left', vAlign: 'center', formatter: "@" },
             { headerName: '名称', headerWidth: 200, dataCode: 'name', dataType: 'String', hAlign: 'left', vAlign: 'center' },
             { headerName: '规格型号', headerWidth: 120, dataCode: 'specs', dataType: 'String', hAlign: 'left', vAlign: 'center' },
             { headerName: '单位', headerWidth: 80, dataCode: 'unit', dataType: 'String', hAlign: 'center', vAlign: 'center' },
@@ -740,7 +755,7 @@ const PRICE_BOOK = (() => {
         $.bootstrapLoading.start();
         try {
             cache = await ajaxPost('/priceInfo/getPriceData', { classIDList }, TIME_OUT);
-            cache = _.sortBy(cache,'classCode');
+            cache = _.sortBy(cache, 'classCode');
             showData(sheet, cache, setting.header, 5);
             const row = sheet.getActiveRowIndex();
             const keywordList = cache[row] && cache[row].keywordList || [];

+ 273 - 221
web/users/js/compilation.js

@@ -18,7 +18,7 @@ function delayKeyup(callback) {
     }, delayTime);
 }
 
-$(document).ready(function() {
+$(document).ready(function () {
     let isAdding = false;
     let model = '';
     let section = $(".nav-tabs li.active > a").text() === '建议估算' ? 'suggestion' : 'bill';
@@ -30,12 +30,12 @@ $(document).ready(function() {
     }
 
     // 计价类型选择
-    $(".nav-tabs li > a").click(function() {
+    $(".nav-tabs li > a").click(function () {
         section = $(this).attr("aria-controls");
     });
 
     // 新增编办
-    $("#add-compilation").click(function() {
+    $("#add-compilation").click(function () {
         try {
             let data = getAndValidData(model);
             let url = '/compilation/add'
@@ -44,14 +44,14 @@ $(document).ready(function() {
                 $.ajax({
                     url: url,
                     type: 'post',
-                    data: {name: data.name},
-                    error: function() {
+                    data: { name: data.name },
+                    error: function () {
                         isAdding = false;
                     },
-                    beforeSend: function() {
+                    beforeSend: function () {
                         isAdding = true;
                     },
-                    success: function(response) {
+                    success: function (response) {
                         isAdding = false;
                         if (response.err === 0) {
                             window.location.reload();
@@ -68,15 +68,15 @@ $(document).ready(function() {
                     id: data[model].id
                 };
                 // 判断是否有重复的数据
-                if ($("input:hidden[name='"+ model +"_lib'][data-id='"+ addLib.id +"']").length > 0) {
+                if ($("input:hidden[name='" + model + "_lib'][data-id='" + addLib.id + "']").length > 0) {
                     alert('重复添加数据!');
                     return false;
                 }
 
-                let removeHtml = '<a class="pull-right text-danger remove-lib" data-model="'+model+'" ' +
+                let removeHtml = '<a class="pull-right text-danger remove-lib" data-model="' + model + '" ' +
                     'title="移除"><span class="glyphicon glyphicon-remove"></span></a>';
                 let tmpHtml = '<p class="form-control-static">' + removeHtml + addLib.name +
-                    '<input type="hidden" data-id="'+ addLib.id +'" name=\'' + model + '_lib\' value=\'' + JSON.stringify(addLib) + '\'>' + '</p>';
+                    '<input type="hidden" data-id="' + addLib.id + '" name=\'' + model + '_lib\' value=\'' + JSON.stringify(addLib) + '\'>' + '</p>';
                 $("." + model + "-list").append(tmpHtml);
                 $('#addcompilation').modal('hide');
             }
@@ -96,37 +96,37 @@ $(document).ready(function() {
     });
 
     //新增计税组合
-    $("#add-group").click(function() {
-        let taxMap = {"1":"一般计税","2":"简易计税" };
+    $("#add-group").click(function () {
+        let taxMap = { "1": "一般计税", "2": "简易计税" };
         let actionType = $('#groupEditType').val();
         let groupData = getTaxGroupData();
         let groupIndex = getGroupIndex(groupData);//用来做重复判断
-        if(!_.isEmpty(groupData)){
+        if (!_.isEmpty(groupData)) {
             //重复判断 todo
-            if($("input[data-id = "+groupIndex+"]").length <= 0){
-                let taxName = groupData.taxType?taxMap[groupData.taxType]:'';
-                let p_name = groupData.program_lib?groupData.program_lib.displayName:"";
-                let t_name = groupData.template_lib?groupData.template_lib.name:"";
-                let c_name = groupData.col_lib?groupData.col_lib.name:"";
-                let f_name = groupData.fee_lib?groupData.fee_lib.name:"";
-                let htmlString = "<tr class='taxGroup_tr'><td><span>"+taxName+"</span></td>" +
-                    "<td><span>"+p_name+"</span></td>" +
-                    "<td><span>"+t_name+"</span></td>" +
-                    "<td><span>"+c_name+"</span></td>" +
-                    "<td><span>"+f_name+"</span></td>" +
+            if ($("input[data-id = " + groupIndex + "]").length <= 0) {
+                let taxName = groupData.taxType ? taxMap[groupData.taxType] : '';
+                let p_name = groupData.program_lib ? groupData.program_lib.displayName : "";
+                let t_name = groupData.template_lib ? groupData.template_lib.name : "";
+                let c_name = groupData.col_lib ? groupData.col_lib.name : "";
+                let f_name = groupData.fee_lib ? groupData.fee_lib.name : "";
+                let htmlString = "<tr class='taxGroup_tr'><td><span>" + taxName + "</span></td>" +
+                    "<td><span>" + p_name + "</span></td>" +
+                    "<td><span>" + t_name + "</span></td>" +
+                    "<td><span>" + c_name + "</span></td>" +
+                    "<td><span>" + f_name + "</span></td>" +
                     "<td> <a class='btn btn-link btn-sm' style='padding: 0px' onclick='editTaxGroup(this)'> 编辑</a>/<a class='btn btn-link btn-sm ' style='padding: 0px' onclick='deleteTableTr(this,\"taxGroup_tr\")'>删除</a> " +
-                    "<input type='hidden' name='tax_group' data-id ='"+groupIndex+"' value='"+JSON.stringify(groupData)+"'>"+
+                    "<input type='hidden' name='tax_group' data-id ='" + groupIndex + "' value='" + JSON.stringify(groupData) + "'>" +
                     "</td>" +
                     "</tr>";
-                if(actionType == "add"){
+                if (actionType == "add") {
                     $("#tax_group_tbody").append(htmlString);
-                }else if(actionType == "modify"){
+                } else if (actionType == "modify") {
                     let oldIndex = $("#groupIndex").val();
-                    let parentTr = $("input[data-id = "+oldIndex+"]").parents(".taxGroup_tr");
+                    let parentTr = $("input[data-id = " + oldIndex + "]").parents(".taxGroup_tr");
                     parentTr.after(htmlString);
                     parentTr.remove();
                 }
-            }else {
+            } else {
                 alert("已存在相同的组合!");
             }
         }
@@ -240,12 +240,12 @@ $(document).ready(function() {
         $(this).removeClass('highlight');
         $(this).after($(dragged));
     });
-    
+
 
 
 
     // 新增计价规则
-    $("#add-valuation").click(function() {
+    $("#add-valuation").click(function () {
         try {
             if (id === '') {
                 throw '页面数据有误';
@@ -258,14 +258,14 @@ $(document).ready(function() {
             $.ajax({
                 url: '/compilation/add-valuation',
                 type: 'post',
-                data: {name: name, id: id, section: section},
-                error: function() {
+                data: { name: name, id: id, section: section },
+                error: function () {
                     isAdding = false;
                 },
-                beforeSend: function() {
+                beforeSend: function () {
                     isAdding = true;
                 },
-                success: function(response) {
+                success: function (response) {
                     isAdding = false;
                     if (response.err === 0) {
                         window.location.reload();
@@ -282,7 +282,7 @@ $(document).ready(function() {
     });
 
     // 添加
-    $(".add-compilation").click(function() {
+    $(".add-compilation").click(function () {
         model = $(this).data('model');
         $("#addcompilation .modal-body > div").hide();
         switch (model) {
@@ -337,25 +337,25 @@ $(document).ready(function() {
             case 'billCode':
                 $("#billCode-area").show();
                 $("#add-compilation-title").text('添加递延清单库');
-                break;    
+                break;
         }
 
         $("#addcompilation").modal('show');
     });
 
     // 保存专业工程标准库
-    $("#save-lib").click(function() {
+    $("#save-lib").click(function () {
         if (validLib()) {
             $("form").submit();
         }
     });
     // 保存计价规则
-    $("#save-valuation").click(function() {
+    $("#save-valuation").click(function () {
         $("#saveValuation").submit();
     });
 
     // 移除操作
-    $(".bill-list, .ration-list, .glj-list, .fee-list, .artificial-list, .program-list, .billsGuidance-list,.feature-list,.info-list,.progressive-list,.vvTax-list,.billCode-list").on("click", ".remove-lib", function() {
+    $(".bill-list, .ration-list, .glj-list, .fee-list, .artificial-list, .program-list, .billsGuidance-list,.feature-list,.info-list,.progressive-list,.vvTax-list,.billCode-list").on("click", ".remove-lib", function () {
         $(this).parent().remove();
     });
 
@@ -366,8 +366,8 @@ $(document).ready(function() {
             url: '/compilation/setDescription',
             type: 'post',
             dataType: "json",
-            data: {id: id, description: description},
-            success: function(response) {
+            data: { id: id, description: description },
+            success: function (response) {
                 if (response.err !== 0) {
                     alert('更改失败');
                 }
@@ -378,13 +378,13 @@ $(document).ready(function() {
     //更改代码覆盖路径
     $('#overWriteUrl').change(function () {
         let overWriteUrl = $(this).val();
-        if(overWriteUrl=="") overWriteUrl = undefined;
+        if (overWriteUrl == "") overWriteUrl = undefined;
         $.ajax({
             url: '/compilation/setOverWriteUrl',
             type: 'post',
             dataType: "json",
-            data: {id: id, overWriteUrl: overWriteUrl},
-            success: function(response) {
+            data: { id: id, overWriteUrl: overWriteUrl },
+            success: function (response) {
                 if (response.err !== 0) {
                     alert('更改失败');
                 }
@@ -409,8 +409,8 @@ $(document).ready(function() {
                 url: '/compilation/setExample',
                 type: 'post',
                 dataType: "json",
-                data: {id: id, example: example},
-                success: function(response) {
+                data: { id: id, example: example },
+                success: function (response) {
                     if (response.err !== 0) {
                         alert('更改失败');
                     }
@@ -420,7 +420,7 @@ $(document).ready(function() {
     });
 
     // 计价规则启用/禁止
-    $(".enable").click(function() {
+    $(".enable").click(function () {
         let goingChangeStatus = switchChange($(this));
         let id = $(this).data('id');
         if (id === undefined || id === '' || isAdding) {
@@ -430,15 +430,15 @@ $(document).ready(function() {
             url: '/compilation/valuation/' + section + '/enable',
             type: 'post',
             dataType: "json",
-            data: {id: id, enable: goingChangeStatus},
-            error: function() {
+            data: { id: id, enable: goingChangeStatus },
+            error: function () {
                 isAdding = false;
                 switchChange($(this));
             },
-            beforeSend: function() {
+            beforeSend: function () {
                 isAdding = true;
             },
-            success: function(response) {
+            success: function (response) {
                 isAdding = false;
                 if (response.err !== 0) {
                     switchChange($(this));
@@ -450,45 +450,45 @@ $(document).ready(function() {
 
 
     // 设置适用类型
-    $(".fileType").change(function() {
-       
+    $(".fileType").change(function () {
+
         let id = $(this).data('id');
         if (id === undefined || id === '' || isAdding) {
             return false;
         }
         let fileTypes = [];
         let oldVal = $(this).attr("checked");
-        if(oldVal){
-            $(this).removeAttr("checked") 
-        }else{
-           $(this).attr("checked","checked")
+        if (oldVal) {
+            $(this).removeAttr("checked")
+        } else {
+            $(this).attr("checked", "checked")
         }
 
-        if($('#'+id+'_suggest_gusuan').attr("checked")) fileTypes.push(16);
-        if($('#'+id+'_gusuan').attr("checked")) fileTypes.push(15);
-        if($('#'+id+'_estimate').attr("checked")) fileTypes.push(5);
-        if($('#'+id+'_submission').attr("checked")) fileTypes.push(1);
-        if($('#'+id+'_three_bill_budget').attr("checked")) fileTypes.push(18);
-        if($('#'+id+'_bill_budget').attr("checked")) fileTypes.push(19);
-        if($('#'+id+'_changeBudget').attr("checked")) fileTypes.push(4);
-        if($('#'+id+'_settlement').attr("checked")) fileTypes.push(10);
+        if ($('#' + id + '_suggest_gusuan').attr("checked")) fileTypes.push(16);
+        if ($('#' + id + '_gusuan').attr("checked")) fileTypes.push(15);
+        if ($('#' + id + '_estimate').attr("checked")) fileTypes.push(5);
+        if ($('#' + id + '_submission').attr("checked")) fileTypes.push(1);
+        if ($('#' + id + '_three_bill_budget').attr("checked")) fileTypes.push(18);
+        if ($('#' + id + '_bill_budget').attr("checked")) fileTypes.push(19);
+        if ($('#' + id + '_changeBudget').attr("checked")) fileTypes.push(4);
+        if ($('#' + id + '_settlement').attr("checked")) fileTypes.push(10);
         let current = $(this);
 
-        console.log(id,this);
+        console.log(id, this);
         $.ajax({
             url: '/compilation/valuation/' + section + '/fileTypes',
             type: 'post',
             dataType: "json",
-            data: {id: id, fileTypes: fileTypes},
-            error: function() {
+            data: { id: id, fileTypes: fileTypes },
+            error: function () {
                 //恢复原值
-               if(oldVal){
-                current.attr("checked","checked")
-               }else{
-                current.removeAttr("checked") 
-               }
+                if (oldVal) {
+                    current.attr("checked", "checked")
+                } else {
+                    current.removeAttr("checked")
+                }
             },
-            success: function(response) {
+            success: function (response) {
                 if (response.err !== 0) {
                     switchChange($(this));
                     alert('更改失败');
@@ -509,7 +509,7 @@ $(document).ready(function() {
     });
 
     // 发布编办
-    $("#release").click(function() {
+    $("#release").click(function () {
         let id = $(this).data("id");
         let status = $(this).data("status");
         status = parseInt(status);
@@ -520,15 +520,15 @@ $(document).ready(function() {
         $.ajax({
             url: '/compilation/release',
             type: 'post',
-            data: {id: id, status: status},
+            data: { id: id, status: status },
             dataType: "json",
-            error: function() {
+            error: function () {
                 isAdding = false;
             },
-            beforeSend: function() {
+            beforeSend: function () {
                 isAdding = true;
             },
-            success: function(response) {
+            success: function (response) {
                 isAdding = false;
                 if (response.err === 0) {
                     window.location.reload();
@@ -542,24 +542,24 @@ $(document).ready(function() {
     });
 
     //添加工程专业
-    $("#addEngineerConfirm").click(async function() {
-        if($('#name').val() == ''){
+    $("#addEngineerConfirm").click(async function () {
+        if ($('#name').val() == '') {
             $("#nameError").show();
             return;
         }
-        if($('#feeName').val() == ''){
+        if ($('#feeName').val() == '') {
             $("#feeNameError").show();
             return;
         }
-        if($('#engineeringInput').val() == ''){
+        if ($('#engineeringInput').val() == '') {
             $("#engineeringError").show();
             return;
         }
-        if($('#projectEngineering').val() == ''){
+        if ($('#projectEngineering').val() == '') {
             $("#projectError").show();
             return;
         }
-        $("#addEngineerConfirm").attr("disabled",true);//防止重复提交
+        $("#addEngineerConfirm").attr("disabled", true);//防止重复提交
         $("#addEngineerForm").submit();
     });
     //
@@ -569,9 +569,9 @@ $(document).ready(function() {
         $.ajax({
             url: '/compilation/changeCategory',
             type: 'post',
-            data: {id: id, category: $(this).val()},
+            data: { id: id, category: $(this).val() },
             dataType: "json",
-            success: function(response) {
+            success: function (response) {
                 if (response.error !== 0) {
                     alert('更改失败');
                 }
@@ -584,9 +584,9 @@ $(document).ready(function() {
         $.ajax({
             url: '/compilation/changeLocation',
             type: 'post',
-            data: {id: id, location: $(this).val()},
+            data: { id: id, location: $(this).val() },
             dataType: "json",
-            success: function(response) {
+            success: function (response) {
                 if (response.error !== 0) {
                     alert('更改失败');
                 }
@@ -599,9 +599,9 @@ $(document).ready(function() {
         $.ajax({
             url: '/compilation/changeFreeUse',
             type: 'post',
-            data: {id: id, freeUse: $(this).prop('checked')},
+            data: { id: id, freeUse: $(this).prop('checked') },
             dataType: "json",
-            success: function(response) {
+            success: function (response) {
                 if (response.error !== 0) {
                     alert('更改失败');
                 }
@@ -624,6 +624,22 @@ $(document).ready(function() {
             }
         });
     });
+
+    //更改序号
+    $('#serialNumber').change(function () {
+        let serialNumber = Number($(this).val());
+        $.ajax({
+            url: '/compilation/setSerialNumber',
+            type: 'post',
+            dataType: "json",
+            data: { id: id, serialNumber: serialNumber },
+            success: function (response) {
+                if (response.err !== 0) {
+                    alert('更改失败');
+                }
+            }
+        });
+    });
 });
 
 /**
@@ -640,12 +656,12 @@ function initCompilation() {
     let programData = programList === undefined ? [] : JSON.parse(programList);
     let billsGuidanceData = billsGuidanceList === undefined ? [] : JSON.parse(billsGuidanceList);
     let billTemplateData = billTemplateList == undefined ? [] : JSON.parse(billTemplateList);
-    let mainTreeColData= mainTreeColList == undefined ? [] : JSON.parse(mainTreeColList);
-    let featureData = featureList == undefined?[]: JSON.parse(featureList);
+    let mainTreeColData = mainTreeColList == undefined ? [] : JSON.parse(mainTreeColList);
+    let featureData = featureList == undefined ? [] : JSON.parse(featureList);
     let infoData = infoList == undefined ? [] : JSON.parse(infoList);
-    let progressiveData = progressiveList == undefined?[]: JSON.parse(progressiveList);
-    let vvTaxData = vvTaxList == undefined?[]: JSON.parse(vvTaxList);
-    let billCodeData = billCodeList == undefined?[]: JSON.parse(billCodeList);
+    let progressiveData = progressiveList == undefined ? [] : JSON.parse(progressiveList);
+    let vvTaxData = vvTaxList == undefined ? [] : JSON.parse(vvTaxList);
+    let billCodeData = billCodeList == undefined ? [] : JSON.parse(billCodeList);
     /*mainTreeCol = mainTreeCol !== '' ? mainTreeCol.replace(/\n/g, '\\n') : mainTreeCol;
     billsTemplateData = billsTemplateData.replace(/\n/g, '\\n');
 
@@ -667,14 +683,14 @@ function initCompilation() {
 
     // 标准清单
     let html = '';
-    for(let tmp of billListData) {
+    for (let tmp of billListData) {
         let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
     $("select[name='standard_bill']").children("option").first().after(html);
     // 定额库
     html = '';
-    for(let tmp of rationLibData) {
+    for (let tmp of rationLibData) {
         let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
@@ -682,7 +698,7 @@ function initCompilation() {
 
     // 工料机库
     html = '';
-    for(let tmp of gljLibData) {
+    for (let tmp of gljLibData) {
         let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
@@ -690,7 +706,7 @@ function initCompilation() {
 
     // 清单指引库
     html = '';
-    for(let tmp of billsGuidanceData) {
+    for (let tmp of billsGuidanceData) {
         let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
@@ -699,7 +715,7 @@ function initCompilation() {
 
     // 人工系数标准库
     html = '';
-    for(let tmp of artificialCoefficientData) {
+    for (let tmp of artificialCoefficientData) {
         let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
@@ -707,7 +723,7 @@ function initCompilation() {
 
     // 计算程序标准库
     html = '';
-    for(let tmp of programData) {
+    for (let tmp of programData) {
         let tmpHtml = '<option value="' + tmp.id + '">' + tmp.displayName + '</option>';
         html += tmpHtml;
     }
@@ -715,14 +731,14 @@ function initCompilation() {
 
     //模板库
     html = '';
-    for(let tmp of billTemplateData) {
+    for (let tmp of billTemplateData) {
         let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
     $("select[name='template_lib']").children("option").first().after(html);
     //列设置
     html = '';
-    for(let tmp of mainTreeColData) {
+    for (let tmp of mainTreeColData) {
         let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
@@ -730,7 +746,7 @@ function initCompilation() {
 
     // 费率标准库
     html = '';
-    for(let tmp of feeLibData) {
+    for (let tmp of feeLibData) {
         let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
@@ -738,7 +754,7 @@ function initCompilation() {
 
     //工程特征库
     html = '';
-    for(let tmp of featureData){
+    for (let tmp of featureData) {
         let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
@@ -746,15 +762,15 @@ function initCompilation() {
 
     //基本信息库
     html = '';
-    for(let tmp of infoData){
+    for (let tmp of infoData) {
         let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
     $("select[name='info_lib']").children("option").first().after(html);
-    
+
     //累进区间库
     html = '';
-    for(let tmp of progressiveData){
+    for (let tmp of progressiveData) {
         let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
@@ -762,19 +778,19 @@ function initCompilation() {
 
     //车船税文件
     html = '';
-    for(let tmp of vvTaxData){
+    for (let tmp of vvTaxData) {
         let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
     $("select[name='vvTax_lib']").children("option").first().after(html);
 
-     //递延清单库文件
-     html = '';
-     for(let tmp of billCodeData){
-         let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + '</option>';
-         html += tmpHtml;
-     }
-     $("select[name='billCode_lib']").children("option").first().after(html);
+    //递延清单库文件
+    html = '';
+    for (let tmp of billCodeData) {
+        let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + '</option>';
+        html += tmpHtml;
+    }
+    $("select[name='billCode_lib']").children("option").first().after(html);
 }
 
 /**
@@ -788,7 +804,7 @@ function getAndValidData(model) {
     let standardBill = $("select[name='standard_bill']").children("option:selected").val();
     let rationLib = $("select[name='ration_lib']").children("option:selected").val();
     let gljLib = $("select[name='glj_lib']").children("option:selected").val();
-   // let feeLib = $("select[name='fee_lib']").children("option:selected").val();
+    // let feeLib = $("select[name='fee_lib']").children("option:selected").val();
     let artificialLib = $("select[name='artificial_lib']").children("option:selected").val();
     let programLib = $("select[name='program_lib']").children("option:selected").val();
     let billsGuidanceLib = $("select[name='billsGuidance_lib']").children("option:selected").val();
@@ -803,7 +819,7 @@ function getAndValidData(model) {
         throw '编办名字不能为空';
     }
 
-    if ( model === 'bill' && (standardBill === '' || standardBill === undefined)) {
+    if (model === 'bill' && (standardBill === '' || standardBill === undefined)) {
         throw '请选择标准清单库';
     }
 
@@ -843,7 +859,7 @@ function getAndValidData(model) {
     let standardBillString = $("select[name='standard_bill']").children("option:selected").text();
     let rationLibString = $("select[name='ration_lib']").children("option:selected").text();
     let gljLibString = $("select[name='glj_lib']").children("option:selected").text();
-  //  let feeLibString = $("select[name='fee_lib']").children("option:selected").text();
+    //  let feeLibString = $("select[name='fee_lib']").children("option:selected").text();
     let artificialString = $("select[name='artificial_lib']").children("option:selected").text();
     let programString = $("select[name='program_lib']").children("option:selected").text();
     let billsGuidanceString = $("select[name='billsGuidance_lib']").children("option:selected").text();
@@ -868,10 +884,10 @@ function getAndValidData(model) {
             id: gljLib,
             name: gljLibString
         },
-      /*  fee: {
-            id: feeLib,
-            name: feeLibString
-        },*/
+        /*  fee: {
+              id: feeLib,
+              name: feeLibString
+          },*/
         artificial: {
             id: artificialLib,
             name: artificialString
@@ -884,17 +900,17 @@ function getAndValidData(model) {
             id: billsGuidanceLib,
             name: billsGuidanceString
         },
-        feature:{
-            id:featureLib,
-            name:featrueString
+        feature: {
+            id: featureLib,
+            name: featrueString
         },
         info: {
             id: infoLib,
             name: infoString
         },
-        progressive:{
-            id:progressiveLib,
-            name:progressiveString
+        progressive: {
+            id: progressiveLib,
+            name: progressiveString
         },
         vvTax: {
             id: vvTaxLib,
@@ -927,33 +943,33 @@ function validLib() {
             throw '请选择工程专业';
         }
         //按新需求,清单库、定额库等不做非空验证
-      /*  if ($("input:hidden[name='bill_lib']").length <= 0) {
-            throw '请添加标准清单';
-        }
-
-        if ($("input:hidden[name='ration_lib']").length <= 0) {
-            throw '请添加定额库';
-        }
-
-        if ($("input:hidden[name='glj_lib']").length <= 0) {
-            throw '请添加人材机库';
-        }
-
-        if ($("input:hidden[name='fee_lib']").length <= 0) {
-            throw '请添加费率标准';
-        }
-
-        if ($("input:hidden[name='artificial_lib']").length <= 0) {
-            throw '请添加人工系数';
-        }
-
-        if ($("input:hidden[name='program_lib']").length <= 0) {
-            throw '请添加计算程序';
-        }
-
-        if ($("input:hidden[name='billsGuidance_lib']").length <= 0) {
-            throw '请添加清单指引库';
-        }*/
+        /*  if ($("input:hidden[name='bill_lib']").length <= 0) {
+              throw '请添加标准清单';
+          }
+  
+          if ($("input:hidden[name='ration_lib']").length <= 0) {
+              throw '请添加定额库';
+          }
+  
+          if ($("input:hidden[name='glj_lib']").length <= 0) {
+              throw '请添加人材机库';
+          }
+  
+          if ($("input:hidden[name='fee_lib']").length <= 0) {
+              throw '请添加费率标准';
+          }
+  
+          if ($("input:hidden[name='artificial_lib']").length <= 0) {
+              throw '请添加人工系数';
+          }
+  
+          if ($("input:hidden[name='program_lib']").length <= 0) {
+              throw '请添加计算程序';
+          }
+  
+          if ($("input:hidden[name='billsGuidance_lib']").length <= 0) {
+              throw '请添加清单指引库';
+          }*/
 
         result = true;
     } catch (error) {
@@ -992,55 +1008,91 @@ function switchChange(element) {
     return !currentStatus;
 }
 
-function editEngineer(selector) {
-    let engineerName =  $(selector).prev("span").text();
+/* function editEngineer(selector) {
+    let engineerName = $(selector).prev("span").text();
     let parentDiv = $(selector).parent("div");
     parentDiv.next("div").find("input").val(engineerName);
     parentDiv.hide();
     parentDiv.next("div").show();
+} */
+
+
+function editEngineer(selector, key) {
+    let editText = $(selector).prev("span").text();
+    let parentDiv = $(selector).parent("div");
+    let width = key == 'seq' ? 70 : 200;
+    parentDiv.next("div").css('width', width);
+    parentDiv.next("div").find("input").val(editText);
+    parentDiv.hide();
+    parentDiv.next("div").show();
 }
 
-function confirmUpdate(selector,engineerID) {
+/* function confirmUpdate(selector, engineerID) {
     let inputDiv = $(selector).parents(".input_group_div");
     let input = $(selector).parent(".input-group-btn").prev("input");
     let oldValue = inputDiv.prev("div").find("span").text();
     let newValue = input.val();
     let key = input.attr("name");
-    if(newValue == "" || newValue==oldValue || !engineerID){
+    if (newValue == "" || newValue == oldValue || !engineerID) {
         inputDiv.prev("div").show();
         inputDiv.hide();
         return;
     }
-     let updateData = {};
-     updateData[key] = newValue;
-     updateEngineer(engineerID,updateData,function () {
+    let updateData = {};
+    updateData[key] = newValue;
+    updateEngineer(engineerID, updateData, function () {
         inputDiv.prev("div").find("span").text(newValue);
-     });
-     inputDiv.prev("div").show();
-     inputDiv.hide();
+    });
+    inputDiv.prev("div").show();
+    inputDiv.hide();
+} */
+
+
+function confirmUpdate(selector, engineerID) {
+    let inputDiv = $(selector).parents(".input_group_div");
+    let input = $(selector).parent(".input-group-btn").prev("input");
+    let oldValue = inputDiv.prev("div").find("span").text();
+    let newValue = input.val();
+    let key = input.attr("name");
+    if (newValue == oldValue || !engineerID) {//不做非空判断
+        inputDiv.prev("div").show();
+        inputDiv.hide();
+        return;
+    }
+    let updateData = {};
+    updateData[key] = newValue;
+    updateEngineer(engineerID, updateData, function () {
+        if (key == 'seq') {
+            window.location.reload();
+        } else {
+            inputDiv.prev("div").find("span").text(newValue);
+        }
+    });
+    inputDiv.prev("div").show();
+    inputDiv.hide();
 }
 
-function deleteEngineerClick(engineerID,element) {
+function deleteEngineerClick(engineerID, element) {
     hintBox.infoBox('操作确认', '是否删除所选工程专业?', 2, async function () {
         try {
-            let result  = await ajaxPost('/compilation/delete-engineer',{id:engineerID});
+            let result = await ajaxPost('/compilation/delete-engineer', { id: engineerID });
             $(element).parent("td").parent("tr").remove();
-        }catch (err){
+        } catch (err) {
             console.log(err);
         }
-    }, null,['确定','取消'],false);
+    }, null, ['确定', '取消'], false);
 }
 
 
-function engineerVisibleChange(checkBox,engineerID) {
-    if(engineerID){
-        updateEngineer(engineerID,{visible:checkBox.checked});
+function engineerVisibleChange(checkBox, engineerID) {
+    if (engineerID) {
+        updateEngineer(engineerID, { visible: checkBox.checked });
     }
 }
 
-function updateEngineer(engineerID,data,callback) {
-    CommonAjax.post('/compilation/update-engineer',{id:engineerID,updateData:data},function (data) {
-        if(callback){
+function updateEngineer(engineerID, data, callback) {
+    CommonAjax.post('/compilation/update-engineer', { id: engineerID, updateData: data }, function (data) {
+        if (callback) {
             callback();
         }
     })
@@ -1050,13 +1102,13 @@ function editTaxGroup(ele) {
     $('#groupEditType').val("modify");
     let groupData = $(ele).nextAll("input[name = 'tax_group']").val();
     groupData = JSON.parse(groupData);
-    if(!_.isEmpty(groupData)){
-        $("#taxType").val(groupData.taxType?groupData.taxType:"");
-        $("#program_lib").val(groupData.program_lib?groupData.program_lib.id:"");
-        $("#template_lib").val(groupData.template_lib?groupData.template_lib.id:"");
-        $("#col_lib").val(groupData.col_lib?groupData.col_lib.id:"");
-        $("#fee_lib").val(groupData.fee_lib?groupData.fee_lib.id:"");
-    }else {
+    if (!_.isEmpty(groupData)) {
+        $("#taxType").val(groupData.taxType ? groupData.taxType : "");
+        $("#program_lib").val(groupData.program_lib ? groupData.program_lib.id : "");
+        $("#template_lib").val(groupData.template_lib ? groupData.template_lib.id : "");
+        $("#col_lib").val(groupData.col_lib ? groupData.col_lib.id : "");
+        $("#fee_lib").val(groupData.fee_lib ? groupData.fee_lib.id : "");
+    } else {
         $("#taxType").val("");
         $("#program_lib").val("");
         $("#template_lib").val("");
@@ -1064,68 +1116,68 @@ function editTaxGroup(ele) {
         $("#fee_lib").val("");
     }
     $("#groupIndex").val(getGroupIndex(groupData));
-    $("#addTaxGroup").modal({show:true});
+    $("#addTaxGroup").modal({ show: true });
 }
 
-function deleteTableTr(ele,classString) {
+function deleteTableTr(ele, classString) {
     let parentTr = $(ele).parents(`.${classString}`);
     parentTr.remove();
 }
 
 function getGroupIndex(groupData) {//用来做唯一标识
     let index = "";
-    if(groupData){
-        if(groupData.taxType) index = index + groupData.taxType;
-        if(groupData.program_lib) index = index + groupData.program_lib.id;
-        if(groupData.template_lib) index = index + groupData.template_lib.id;
-        if(groupData.col_lib) index = index + groupData.col_lib.id;
-        if(groupData.fee_lib) index = index + groupData.fee_lib.id;
+    if (groupData) {
+        if (groupData.taxType) index = index + groupData.taxType;
+        if (groupData.program_lib) index = index + groupData.program_lib.id;
+        if (groupData.template_lib) index = index + groupData.template_lib.id;
+        if (groupData.col_lib) index = index + groupData.col_lib.id;
+        if (groupData.fee_lib) index = index + groupData.fee_lib.id;
     }
     return index;
 }
 function getTaxGroupData() {
     let programData = programList === undefined ? [] : _.indexBy(JSON.parse(programList), 'id');
-    let billTemplateData = billTemplateList == undefined ? [] : _.indexBy(JSON.parse(billTemplateList),'ID');
-    let mainTreeColData= mainTreeColList == undefined ? [] :  _.indexBy(JSON.parse(mainTreeColList),'ID');
-    let feeLibData = feeRateList === undefined ? [] : _.indexBy(JSON.parse(feeRateList),'id');
+    let billTemplateData = billTemplateList == undefined ? [] : _.indexBy(JSON.parse(billTemplateList), 'ID');
+    let mainTreeColData = mainTreeColList == undefined ? [] : _.indexBy(JSON.parse(mainTreeColList), 'ID');
+    let feeLibData = feeRateList === undefined ? [] : _.indexBy(JSON.parse(feeRateList), 'id');
     let groupData = {};
-    if($("#taxType").val() !==""){
+    if ($("#taxType").val() !== "") {
         groupData.taxType = $("#taxType").val();
     }
-    if($("#program_lib").val() !==""){
-        let program =  programData[$("#program_lib").val()];
-        if(program){
+    if ($("#program_lib").val() !== "") {
+        let program = programData[$("#program_lib").val()];
+        if (program) {
             groupData.program_lib = {
-                id:program.id,
-                name:program.name,
-                displayName:program.displayName
+                id: program.id,
+                name: program.name,
+                displayName: program.displayName
             }
         }
     }
-    if($("#template_lib").val() !==""){
-        let template =  billTemplateData[$("#template_lib").val()];
-        if(template){
+    if ($("#template_lib").val() !== "") {
+        let template = billTemplateData[$("#template_lib").val()];
+        if (template) {
             groupData.template_lib = {
-                id:template.ID,
-                name:template.name
+                id: template.ID,
+                name: template.name
             }
         }
     }
-    if($("#col_lib").val() !==""){
-        let col =  mainTreeColData[$("#col_lib").val()];
-        if(col){
+    if ($("#col_lib").val() !== "") {
+        let col = mainTreeColData[$("#col_lib").val()];
+        if (col) {
             groupData.col_lib = {
-                id:col.ID,
-                name:col.name
+                id: col.ID,
+                name: col.name
             }
         }
     }
-    if($("#fee_lib").val() !==""){
-        let feeRate =  feeLibData[$("#fee_lib").val()];
-        if(feeRate){
+    if ($("#fee_lib").val() !== "") {
+        let feeRate = feeLibData[$("#fee_lib").val()];
+        if (feeRate) {
             groupData.fee_lib = {
-                id:feeRate.id,
-                name:feeRate.name
+                id: feeRate.id,
+                name: feeRate.name
             }
         }
     }
@@ -1133,12 +1185,12 @@ function getTaxGroupData() {
 }
 
 
-function intChecking(e,elemt) {//限制输入正整数
+function intChecking(e, elemt) {//限制输入正整数
     let code = e.which || e.keyCode;
-    if(code == 46 || code == 45){//不能输入小数点和-号
+    if (code == 46 || code == 45) {//不能输入小数点和-号
         e.preventDefault();
     }
-    if( elemt.value == ""&&code == 48){//当输入框为空时不能输入0
+    if (elemt.value == "" && code == 48) {//当输入框为空时不能输入0
         e.preventDefault();
     }
 

+ 11 - 0
web/users/views/compilation/add.html

@@ -34,6 +34,7 @@
                         <table class="table engineer_table">
                             <thead>
                             <tr>
+                                <th>序号</th>
                                 <th>工程专业</th>
                                 <th>费用标准</th>
                                 <th>定额取费专业</th>
@@ -49,6 +50,16 @@
                                 <% engineeringList.forEach(function(engineering) {%>
                                 <tr >
                                     <td>
+                                        <div><span><%= engineering.seq %></span> <a onclick='editEngineer(this,"seq")'><i class="glyphicon glyphicon-pencil"></i></a></div>
+                                        <div class="input-group input-group-sm input_group_div" style="width:200px;display: none">
+                                            <input class="form-control" name="seq">
+                                            <div class="input-group-btn">
+                                                <button type="button" class="btn btn-success" onclick='confirmUpdate(this,"<%= engineering._id.toString()%>")'>
+                                                    <span class="glyphicon glyphicon-ok"></span></button>
+                                            </div>
+                                        </div>
+                                    </td>
+                                    <td>
                                         <div><span><%= engineering.name %></span> <a onclick='editEngineer(this)'><i class="glyphicon glyphicon-pencil"></i></a></div>
                                         <div class="input-group input-group-sm input_group_div" style="width:200px;display: none">
                                             <input class="form-control" name="name">

+ 5 - 0
web/users/views/compilation/index.html

@@ -306,6 +306,11 @@
                     </td>
                 </tr>
                 <tr><td><span>版本号:</span><input class="form-control" type="text" id="edition" value="<%= selectedCompilation.edition%>"></td></tr>
+                <tr>
+                    <td><span>序号:</span><input class="form-control" type="number" id="serialNumber"
+                            value="<%= selectedCompilation.serialNumber%>">
+                    </td>
+                </tr>
             </table>
         </div>
         <input type="hidden" name="id" value="<%= selectedCompilation._id %>" id="compilation-id">