瀏覽代碼

feat: 清单规则编辑器添加类别列

vian 2 年之前
父節點
當前提交
b0307fca04

+ 9 - 9
modules/all_models/bills.js

@@ -15,15 +15,15 @@ let billsSchema = new Schema({
     billsLibId: Number,
     code: String,
     fullCode: String,
-    type:{type: Number,default:4},//1 :大项费用 2:分部 3分项 4清单;5补项
-    isAdd:{type: Number,default:0},//1 true 0 false是否新增
+    type: { type: Number, default: 4 },//1 :大项费用 2:分部 3分项 4清单;5补项
+    isAdd: { type: Number, default: 0 },//1 true 0 false是否新增
     name: String,
     unit: String,
     quantity: String, // Decimal
-    quantityEXP:String,//工程量表达式
-    feeRateID:Number,
-    feeRate:String,
-    isFromDetail:{type: Number,default:0},//1 true 0 false
+    quantityEXP: String,//工程量表达式
+    feeRateID: Number,
+    feeRate: String,
+    isFromDetail: { type: Number, default: 0 },//1 true 0 false
     programID: Number,
     calcBase: String,
     calcBaseValue: String,     // 计算基数表达式的值
@@ -55,10 +55,10 @@ let billsSchema = new Schema({
     fees: [subSchema.feesSchema],
     // 标记字段
     flags: [subSchema.flagsSchema],
-    installationKey:String,//用来记录安装增加费的关联字段
+    installationKey: String,//用来记录安装增加费的关联字段
     deleteInfo: deleteSchema,
-    isEstimate:{type: Number,default:0},       // 1 true 0 false 是否暂估
-    remark:String
+    isEstimate: { type: Number, default: 0 },       // 1 true 0 false 是否暂估
+    remark: String,
 });
 
 mongoose.model("bills", billsSchema);

+ 20 - 19
modules/all_models/stdBills_bills.js

@@ -5,25 +5,26 @@
 const mongoose = require('mongoose');
 const Schema = mongoose.Schema;
 const stdBills_bills = new Schema({
-            ID: String,
-            ParentID: String,
-            NextSiblingID: String,
-            code: String,
-            name: String,
-            unit: String,
-            ruleText: String,
-            engineering: Number, //工程专业,填计算程序工程专业ID
-            fixedFlag: Number,  //固定ID
-            Expression: String,
-            comment: String, //备注,清单精灵处输入
-            jobs: [],
-            items: [],
-            recharge:String,
-            billsLibId: {type:Number,index:true},
-            sectionInfo: Schema.Types.Mixed,
-            deleted: Boolean
-    },
-    {versionKey: false}
+    ID: String,
+    ParentID: String,
+    NextSiblingID: String,
+    code: String,
+    name: String,
+    unit: String,
+    ruleText: String,
+    engineering: Number, //工程专业,填计算程序工程专业ID
+    fixedFlag: Number,  //固定ID
+    Expression: String,
+    comment: String, //备注,清单精灵处输入
+    jobs: [],
+    items: [],
+    recharge: String,
+    billsLibId: { type: Number, index: true },
+    sectionInfo: Schema.Types.Mixed,
+    deleted: Boolean,
+    kind: Number, // 前台里(重构、微前端)BRType: 1: 大项费用、 8:XMJ 4:清单
+},
+    { versionKey: false }
 );
 
 mongoose.model('std_bills_lib_bills', stdBills_bills, 'std_bills_lib_bills');

+ 48 - 8
web/maintain/bills_lib/html/qingdan.html

@@ -386,6 +386,11 @@
     let itemsSpread = new GC.Spread.Sheets.Workbook($("#spreadItems")[0], {sheetCount: 1});
     itemsSpread.options.allowUserDragFill = false;
     sheetCommonObj.bindEscKey(itemsSpread, [{sheet: itemsSpread.getSheet(0), editStarting: itemsController.onEditStart, editEnded: itemsController.onEditEnded}]);
+    const billKindComboList = [
+        { name: '大项费用', value: 1 },
+        { name: '项目节', value: 8 },
+        { name: '清单', value: 4 },
+    ];
     $(document).ready(function(){
         $("#aStdJobs").attr('href', function(){
             return `stdJobs?billsLibId=${billsLibId}&locked=${locked}`;
@@ -490,6 +495,12 @@
                     data.fixedFlag = findData.name;
                 }
             }
+            if (data.kind) {
+                const kindItem = billKindComboList.find(item => item.value === data.kind);
+                if (kindItem) {
+                    data.kind = kindItem.name;
+                }
+            }
         }
         billsTree.loadDatas(datas);
         let controller = TREE_SHEET_CONTROLLER.createNew(billsTree.tree, billsSpread.getActiveSheet(), setting);
@@ -523,6 +534,11 @@
                 nodeOpration(controller, totalJobs, totalItems);
             });
         });
+        // 设置类别下拉
+        const kindCol = setting.cols.findIndex((data) => data.data.field === 'kind');
+        const kindList = billKindComboList.map(item => item.name);
+        setCombo(billsSheet, kindCol, kindList);
+        // 设置固定清单下拉
         let nameList = BillsFixedFlagList.map((data) => data.name);
         let comboCol = setting.cols.findIndex((data) => data.data.field === 'fixedFlag');
         setCombo(billsSheet, comboCol, nameList);
@@ -824,12 +840,13 @@
                 }
                 else if(i < controller.tree.items.length && j>= validDatas.length){
                     //reshow orgDatas
-                    sheet.setValue(i, 0, sheetBillsDatas.datasIdx['rowIdx'+ i].code + '');
-                    sheet.setValue(i, 1, sheetBillsDatas.datasIdx['rowIdx'+ i].name);
-                    sheet.setValue(i, 2, sheetBillsDatas.datasIdx['rowIdx'+ i].unit);
-                    sheet.setValue(i, 3, sheetBillsDatas.datasIdx['rowIdx'+ i].ruleText);
-                    sheet.setValue(i, 4, sheetBillsDatas.datasIdx['rowIdx'+ i].engineering);
-                    sheet.setValue(i, 5, sheetBillsDatas.datasIdx['rowIdx'+ i].fixedFlag);
+                    sheet.setValue(i, 0, sheetBillsDatas.datasIdx['rowIdx'+ i].kind);
+                    sheet.setValue(i, 1, sheetBillsDatas.datasIdx['rowIdx'+ i].code + '');
+                    sheet.setValue(i, 2, sheetBillsDatas.datasIdx['rowIdx'+ i].name);
+                    sheet.setValue(i, 3, sheetBillsDatas.datasIdx['rowIdx'+ i].unit);
+                    sheet.setValue(i, 4, sheetBillsDatas.datasIdx['rowIdx'+ i].ruleText);
+                    sheet.setValue(i, 5, sheetBillsDatas.datasIdx['rowIdx'+ i].engineering);
+                    sheet.setValue(i, 6, sheetBillsDatas.datasIdx['rowIdx'+ i].fixedFlag);
                 }
                 else {
                     sheet.clear(i, 0, 1, sheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport,GC.Spread.Sheets.StorageType.data);
@@ -860,16 +877,39 @@
                 }
                 curRow = row;
                 const field = setting.cols[col].data.field;
-                const value = sheet.getValue(row, col);
+                let value = sheet.getValue(row, col);
+                if (field === 'fixedFlag') {
+                    const findData = BillsFixedFlagList.find((x) => x.name === value);
+                    if (findData) {
+                        value = findData.value;
+                    }
+                } else if (field === 'kind') {
+                    const kindItem = billKindComboList.find(item => item.name === value);
+                    if (kindItem) {
+                        value = kindItem.value;
+                    }
+                }
                 curData[field] = value;
             });
             billsAjax.pasteBills(userAccount, billsLibId, postData, function () {
                 info.changedCells.forEach(({ row, col }) => {
                     const node = controller.tree.items[row];
                     const field = setting.cols[col].data.field;
-                    const value = sheet.getValue(row, col);
+                    let value = sheet.getValue(row, col);
+                    if (field === 'fixedFlag') {
+                        const findData = BillsFixedFlagList.find((x) => x.value === value);
+                        if (findData) {
+                        value = findData.name;
+                    }
+                    } else if (field === 'kind') {
+                        const kindItem = billKindComboList.find(item => item.value === value);
+                        if (kindItem) {
+                            value = kindItem.name;
+                        }
+                    }
                     node.data[field] = value;
                     sheetBillsDatas.datasIdx['rowIdx' + row][field] = value;
+                    sheet.setValue(row, col, node.data[field] || '');
                 });
             }, function () {
                 info.changedCells.forEach(({ row, col }) => {

+ 6 - 0
web/maintain/bills_lib/scripts/bills_lib_ajax.js

@@ -310,6 +310,12 @@ var billsAjax = {
                 data = findData.value;
             }
         }
+        if (field === 'kind') {
+            const kindItem = billKindComboList.find(item => item.name === data);
+            if (kindItem) {
+                data = kindItem.value;
+            }
+        }
         $.ajax({
             type: 'post',
             url: 'stdBillsEditor/updateBills',

+ 24 - 7
web/maintain/bills_lib/scripts/bills_lib_setting.js

@@ -2,7 +2,24 @@
  * Created by vian on 2017/4/10.
  */
 var billsLibSetting = {
-    cols:[
+    cols: [
+        {
+            head: {
+                titleNames: ['类别'],
+                spanCols: [1],
+                spanRows: [2],
+                vAlign: [1, 1],
+                hAlign: [1, 1],
+                font: 'Arial'
+            },
+            data: {
+                field: 'kind',
+                vAlign: 1,
+                hAlign: 0,
+                font: 'Arial'
+            },
+            width: 80
+        },
         {
             head: {
                 titleNames: ['编码'],
@@ -109,11 +126,11 @@ var billsLibSetting = {
     headRows: 1,
     headRowHeight: [47],
     emptyRows: 0,
-    treeCol: 0
+    treeCol: 1
 };
 
 var jobsSetting = {
-    cols:[
+    cols: [
         {
             head: {
                 titleNames: ['编号'],
@@ -156,7 +173,7 @@ var jobsSetting = {
 };
 
 var itemsSetting = {
-    cols:[
+    cols: [
         {
             head: {
                 titleNames: ['编号'],
@@ -199,7 +216,7 @@ var itemsSetting = {
 };
 
 var totalJobsSetting = {
-    cols:[
+    cols: [
         {
             head: {
                 titleNames: ['编号'],
@@ -242,7 +259,7 @@ var totalJobsSetting = {
 };
 
 var totalItemsSetting = {
-    cols:[
+    cols: [
         {
             head: {
                 titleNames: ['编号'],
@@ -285,7 +302,7 @@ var totalItemsSetting = {
 };
 
 var eigenValueSetting = {
-    cols:[
+    cols: [
         {
             head: {
                 titleNames: ['编号'],

File diff suppressed because it is too large
+ 662 - 655
web/maintain/bills_lib/scripts/db_controller.js