瀏覽代碼

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

laiguoran 4 年之前
父節點
當前提交
9ed41ace89

+ 2 - 2
app/controller/tender_controller.js

@@ -885,8 +885,8 @@ module.exports = app => {
         async copyTender(ctx) {
             try {
                 const id = ctx.tender.data.id;
-                const { id: copy_id } = JSON.parse(ctx.request.body.data);
-                await ctx.service.tenderInfo.copyTenderHandler(id, copy_id);
+                const { id: copy_id = '', type: typeArr = [] } = JSON.parse(ctx.request.body.data);
+                await ctx.service.tenderInfo.copyTenderHandler(id, copy_id, typeArr);
                 ctx.body = { err: 0, msg: '' };
             } catch (error) {
                 this.log(error);

+ 12 - 1
app/public/js/tender_copy_setting.js

@@ -159,10 +159,21 @@ $(document).ready(function () {
         $(this).prop("checked", true);
     });
 
+    $('#setting-custom').on('click', '.custom-checkbox', function () {
+        const isChecked = $(this).find('input').prop("checked");
+        $(this).find('input').prop("checked", !isChecked);
+    })
     $('#copy_comfirm_btn').click(function() {
+        const type = []
+        $('#setting-custom').find('input:checked').each(function() {
+            type.push($(this).data('type'))
+        })
+        if (!type.length) {
+            return toastr.error('请勾选需要拷贝的属性')
+        }
         const id = $('#copyModalContent').find('input:checked').data('tid');
         if (id) {
-            postData(window.location.pathname + '/copy-setting', { id }, function() {
+            postData(window.location.pathname + '/copy-setting', { id, type }, function() {
                 window.location.reload()
             })
         }

+ 14 - 2
app/service/tender_info.js

@@ -355,13 +355,25 @@ module.exports = app => {
          * 拷贝标段数据至当前标段
          * @param {number} id - 当前标段id
          * @param {number} copy_id - 被拷贝的标段id
+         * @param {Array} typeArr - 需要拷贝的类型数组
          */
-        async copyTenderHandler(id, copy_id) {
+        async copyTenderHandler(id, copy_id, typeArr) {
+            const columns = [];
+            typeArr.forEach(item => {
+                if (item === 'tender') {
+                    columns.push('deal_info', 'construction_unit', 'tech_param');
+                } else if (item === 'chapter') {
+                    columns.push('chapter');
+                } else if (item === 'pay_account') {
+                    columns.push('pay_account');
+                }
+            });
+            if (!columns.length) throw '未选择需要拷贝的设置';
             const [data] = await this.getAllDataByCondition({
                 where: {
                     tid: copy_id,
                 },
-                columns: ['deal_info', 'construction_unit', 'tech_param', 'chapter', 'pay_account'],
+                columns,
             });
             const isUpdate = await this.update(data, { tid: id });
             if (isUpdate) {

+ 4 - 4
app/view/tender/detail_modal.ejs

@@ -623,22 +623,22 @@
             </div>
             <div class="modal-body">
                 <div class="alert alert-warning mb-1">从以下标段拷贝设置</div>
-                <div class=" mb-1">
+                <div class="mb-1" id="setting-custom">
                 <a class="btn btn-sm btn-light">
                     <div class="custom-control custom-checkbox">
-                    <input type="checkbox" class="custom-control-input" id="customCheckDisabld" checked="">
+                    <input type="checkbox" class="custom-control-input" checked data-type="tender">
                     <label class="custom-control-label text-primary" for="customCheckDisabld">标段属性</label>
                     </div>
                 </a>
                 <a class="btn btn-sm btn-light">
                     <div class="custom-control custom-checkbox">
-                    <input type="checkbox" class="custom-control-input" id="customCheckDisabld2" checked="">
+                    <input type="checkbox" class="custom-control-input"  checked data-type="chapter">
                     <label class="custom-control-label text-primary" for="customCheckDisabld2">章节设置</label>
                     </div>
                 </a>
                 <a class="btn btn-sm btn-light">
                     <div class="custom-control custom-checkbox">
-                    <input type="checkbox" class="custom-control-input" id="customCheckDisabld3" checked="">
+                    <input type="checkbox" class="custom-control-input" checked data-type="pay_account">
                     <label class="custom-control-label text-primary" for="customCheckDisabld3">付款账号</label>
                     </div>
                 </a>