Browse Source

后台清单规则功能新增规则类型字段,包括复制等相关功能

lishihao 3 năm trước cách đây
mục cha
commit
fc3e9d9eda

+ 2 - 1
modules/all_models/stdBills_lib.js

@@ -12,7 +12,8 @@ const stdBills_lib = new Schema({
 
         billsLibId: Number,
         billsLibName: String,
-        deleted: Boolean
+        deleted: Boolean,
+        libType:String
     },
     {versionKey: false}
 );

+ 2 - 1
modules/bills_lib/controllers/bills_lib_controllers.js

@@ -15,7 +15,8 @@ module.exports = {
             const userName = req.session.managerData.username;
             const libName = data.libName;
             const libId = data.libId;
-            const newLibData = await billsLibDao.copyLib(userName, libName, libId);
+            const libType = data.libType;
+            const newLibData = await billsLibDao.copyLib(userName, libName, libId,libType);
             callback(req, res, 0, 'copyLib success', [newLibData]);
         } catch (err) {
             callback(req, res, 1, 'copyLib fail', null);

+ 5 - 3
modules/bills_lib/models/bills_lib_interfaces.js

@@ -14,8 +14,8 @@ const engLibModel = mongoose.model('engineering_lib');
 let uuid = require('uuid');
 let billsLibDao = function(){};
 
-billsLibDao.prototype.copyLib = async function (userName, libName, fromLibId) {
-    const libData = await this.createStdBillsLibSync(userName, libName);
+billsLibDao.prototype.copyLib = async function (userName, libName, fromLibId ,libType) {
+    const libData = await this.createStdBillsLibSync(userName, libName ,libType);
     const newLibId = libData.billsLibId;
     //插入工作内容
     let orgJobs = await JobContent.find({billsLibId: fromLibId}).lean();
@@ -150,7 +150,7 @@ billsLibDao.prototype.getStdBillsLib = function(callback){
     });
 };
 
-billsLibDao.prototype.createStdBillsLibSync = async function (userName, libName) {
+billsLibDao.prototype.createStdBillsLibSync = async function (userName, libName ,libType) {
     const counterRst = await counter.counterDAO.getIDAfterCount(counter.moduleName.billsLib, 1);
     const dateStr = moment().format('YYYY-MM-DD HH:mm:ss');
     const libData = {
@@ -159,6 +159,7 @@ billsLibDao.prototype.createStdBillsLibSync = async function (userName, libName)
         recentOpr: [{operator: userName, operateDate: dateStr}],
         billsLibId: counterRst.sequence_value,
         billsLibName: libName,
+        libType,
         deleted: false
     };
     await StdBillsLib.create(libData);
@@ -177,6 +178,7 @@ billsLibDao.prototype.createStdBillsLib = function(clibData, callback){
             recentOpr: [{operator: userAccount, operateDate: dateStr}],
             billsLibId: billsLibId,
             billsLibName: billsLibName,
+            libType:clibData.libType,
             deleted: false
         };
         StdBillsLib.create(newStdBillsLib, function(err){

+ 1 - 1
modules/bills_template_lib/controllers/bills_template_controller.js

@@ -158,7 +158,7 @@ class BillsTemplateController extends BaseController {
         try {
             const data = JSON.parse(req.body.data);
             const userName = req.session.managerData.username;
-            await billsTemplateFacade.copyLib(data.libID, data.name, userName);
+            await billsTemplateFacade.copyLib(data.libID, data.name, userName ,data.libType);
             res.json({error: 0, data: null, message: 'success'})
         } catch (err) {
             console.log(err);

+ 2 - 1
modules/bills_template_lib/facade/bills_template_facade.js

@@ -96,13 +96,14 @@ async function addLib(data){
     }
 }
 
-async function copyLib(libID, name, userName) {
+async function copyLib(libID, name, userName,libType) {
     const lib = await billTemplateLibModel.findOne({ID: libID}, '-_id').lean();
     const libItems = await billTemplateItemsModel.find({libID}, '-_id').lean();
     lib.creator = userName;
     lib.createDate = Date.now();
     lib.recentOpr = [{operator: userName, operator: moment(lib.createDate).format('YYYY-MM-D HH:mm:ss')}];
     lib.name = name;
+    lib.libType=libType;
     lib.ID = uuidV1();
     await billTemplateLibModel.create(lib);
     libItems.forEach(item => {

+ 1 - 1
web/maintain/bill_template_lib/js/bills_template.js

@@ -67,7 +67,7 @@ $(document).ready(function() {
             return;
         }
         $.bootstrapLoading.start();
-        CommonAjax.post('/billsTemplate/copyLib', {libID, name}, function () {
+        CommonAjax.post('/billsTemplate/copyLib', {libID, name,libType}, function () {
             $.bootstrapLoading.end();
             window.location.reload();
         }, function () {

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 499 - 332
web/maintain/billsGuidance_lib/js/billsGuidance.js


+ 25 - 2
web/maintain/bills_lib/html/main.html

@@ -35,6 +35,7 @@
                         <thead>
                             <tr>
                                 <th>清单规则名称</th>
+                                <th>清单规则类型</th>
                                 <th width="160">添加时间</th>
                                 <th width="70">操作</th>
                                 <th width="90">导入</th>
@@ -66,7 +67,24 @@
                       <label>清单规则名称</label>
                       <input id="createText" class="form-control" placeholder="输入清单规则名称" type="text">
                     </div>
+                    <div class="form-group">
+                        <label>清单规则类型</label>
+                        <div>
+                            <div class="form-check form-check-inline">
+                            <label class="form-check-label">
+                                <input class="form-check-input" type="radio" checked name="inlineRadioOptions" id="inlineRadio1" value="1"> 标准清单
+                            </label>
+                            </div>
+                            <div class="form-check form-check-inline">
+                            <label class="form-check-label">
+                                <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="2">
+                                指标项目表
+                            </label>
+                            </div>
+                        </div>
+                    </div>
                   </form>
+
                 </div>
                 <div class="modal-footer">
                     <a id="createA"  href="javascript:void(0);" class="btn btn-primary">确定</a>
@@ -199,10 +217,11 @@
         //main 增删改
         $("#createA").click(function(){
             let billsLibName = $("#createText").val();
+            let billsLibType = $('[name=inlineRadioOptions]:checked').val();
             if(billsLibName.trim().length === 0){
                 alert("请输入清单规则名称!");
             } else {
-                mainAjax.createStdBillsLib(userAccount, billsLibName);
+                mainAjax.createStdBillsLib(userAccount, billsLibName,billsLibType);
                 $("#createText").val("");
             }
         });
@@ -285,6 +304,7 @@
             $("input[name='import_data']").val('');
         });
         let selLibId = -1;
+        let selLibType='1';
         $("#showArea").on("click", ".import-data", function () {
             let id = $(this).data("id");
             id = parseInt(id);
@@ -349,17 +369,20 @@
         // 复制库
         $("#showArea").on("click", ".copy-data", function () {
             let id = $(this).data("id");
+            let type = $(this).data("type");
             id = parseInt(id);
             if (isNaN(id) || id <= 0) {
                 return false;
             }
             selLibId = id;
+            selLibType=type;
             $("#copy").modal("show");
         });
         $('#copyA').click(function () {
             const libId = selLibId;
             const libName = $('#copyName').val();
-            mainAjax.copyBillsLib(libId, libName);
+            const libType=selLibType;
+            mainAjax.copyBillsLib(libId, libName,libType);
         });
     });
 </script>

+ 8 - 5
web/maintain/bills_lib/scripts/bills_lib_ajax.js

@@ -53,11 +53,14 @@ var mainAjax = {
     getLibsHtml: function (data) {
         const libHtml = data.reduce((acc, libData) => {
             const id = libData.billsLibId;
+            const libType=libData.libType?libData.libType:"1";
+            const libTypeName = libData.libType==="2"?'指标':'清单';
             const billsLibName = libData.billsLibName;
             const createDateFmt = new Date(libData.createDate).format("yyyy-MM-dd");
             const html = 
                 `<tr id="${id}">
                     <td><a href="/stdBills?billsLibId=${id}&locked=true">${billsLibName}</a></td>
+                    <td>${libTypeName}</td>
                     <td>${createDateFmt}</td>
                     <td>
                         <a class="lock-btn-control disabled" data-toggle="modal" data-target="#edit" href="javascript:void(0);" title="编辑"><i class="fa fa-pencil-square-o"></i></a>
@@ -68,7 +71,7 @@ var mainAjax = {
                         <a class="btn btn-secondary btn-sm import-data lock-btn-control disabled" data-id="${id}" href="javascript:void(0);" title="导入数据"><i class="fa fa-sign-in fa-rotate-90"></i>导入</a>
                     </td>
                     <td>
-                        <a class="btn btn-secondary btn-sm copy-data lock-btn-control disabled" data-id="${id}" href="javascript:void(0);" title="复制数据"><i class="fa fa-clone"></i>复制</a>
+                        <a class="btn btn-secondary btn-sm copy-data lock-btn-control disabled" data-id="${id}" data-type="${libType}" href="javascript:void(0);" title="复制数据"><i class="fa fa-clone"></i>复制</a>
                     </td>
                  </tr>`;
             return acc += html;
@@ -88,12 +91,12 @@ var mainAjax = {
             }
         });
     },
-    createStdBillsLib: function(userAccount, billsLibName){
+    createStdBillsLib: function(userAccount, billsLibName,billsLibType){
         const me = this;
         $.ajax({
             type: "POST",
             url: "/stdBillsEditor/createStdBillsLib",
-            data: {data: JSON.stringify({userAccount: userAccount, name: billsLibName}) },
+            data: {data: JSON.stringify({userAccount: userAccount, name: billsLibName,libType:billsLibType}) },
             dataType: "json",
             success: function(result){
                 if(!result.error){
@@ -103,12 +106,12 @@ var mainAjax = {
             }
         });
     },
-    copyBillsLib: function (libId, libName) {
+    copyBillsLib: function (libId, libName,libType) {
         const me = this;
         $.ajax({
             type: 'post',
             url: '/stdBillsEditor/copyStdBillsLib',
-            data: {data: JSON.stringify({libId, libName})},
+            data: {data: JSON.stringify({libId, libName,libType})},
             dataType: 'json',
             timeout: 150000,
             beforeSend: function () {