Bladeren bron

Merge branch 'feature/附件功能完善' into develop

# Conflicts:
#	protected/config/routes.conf.php
#	protected/config/ver.conf.php
#	protected/controller/ClientController.php
#	protected/module/admin/model/aconfig.php
NoNZero 8 jaren geleden
bovenliggende
commit
05b41a3554

+ 13 - 1
protected/class/itemmeasurenum.php

@@ -30,7 +30,7 @@ class ItemMeasureNumpofper
 
     public function getItemMeasureNum($tenderid)
     {
-        return $this->__itemMeasureNum->find(array('where' => 'pmid=?', 'param' => array($tenderid), 'asArray' => TRUE));
+        return $this->__itemMeasureNum->find(array('where' => 'pmid=? AND isdel=0', 'param' => array($tenderid), 'asArray' => TRUE));
     }
 
     public function getRowData($imnid)
@@ -44,6 +44,18 @@ class ItemMeasureNumpofper
         return $this->__itemMeasureNum->update(array('where' => 'imnid=?', 'param' => array($id)));
     }
 
+    public function deleteItem($id)
+    {
+        return $this->__itemMeasureNum->delete(array('where' => 'imnid=?', 'param' => array($id)));
+    }
+
+    public function updateDeltag($id)
+    {
+        $this->__itemMeasureNum->isdel = 1;
+        return $this->__itemMeasureNum->update(array('where' => 'imnid=?', 'param' => array($id)));
+    }
+
+
     public function delItemFields($imnid)
     {
         return $this->__itemMeasureNum->delete(array('where' => 'imnid=?', 'param' => array($imnid)));

+ 28 - 0
protected/controller/ProjectController.php

@@ -355,6 +355,25 @@ class ProjectController extends DooController
 
     function proSectionFiles()
     {
+        if (isset($_POST['optype']) && ($_POST['optype'] == 'del') && isset($_POST['imnid'])) {
+            $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
+            if ($imnidArray['iaid'] > 0) {
+                $this->itemmeasurenum->updateDeltag($_POST['imnid']);
+                echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
+                die();
+            }
+        }
+        if (isset($_POST['filename']) && isset($_POST['filedesc']) && isset($_POST['upimnid'])) {
+            $filename = $_POST['filename'];
+            $filedesc = $_POST['filedesc'];
+            $imnidArray = $this->itemmeasurenum->getRowData($_POST['upimnid']);
+            if ($imnidArray['iaid'] > 0) {
+                $this->itemmeasurenum->updateItemFields($_POST['upimnid'], $filedesc);
+                $this->itemfle->updateItemFields($imnidArray['iaid'], $filename);
+                echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
+                die();
+            }
+        }
         // 面包屑导航项目
         $this->data['currproArray'] = $this->data['allproArray'] = NULL;
         $this->data['pmid'] = $this->params['pmid'];
@@ -455,6 +474,15 @@ class ProjectController extends DooController
             $this->data['itematta'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
             $this->data['itematta'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
         }
+        $this->data['itemMeasureArray'] = $this->itemmeasurenum->getItemMeasureNum($this->params['pmid']);
+        foreach ($this->data['itemMeasureArray'] as $k => $v) {
+            $fileArray = $this->itemfle->getItemFile($v['iaid']);
+            $this->data['itemMeasureArray'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
+            $this->data['itemMeasureArray'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
+            $this->data['itemMeasureArray'][$k]['filename'] = $fileArray['filename'];
+            $this->data['itemMeasureArray'][$k]['fileext'] = $fileArray['fileext'];
+            $this->data['itemMeasureArray'][$k]['tips'] = $v['tips'];
+        }
         $this->data['pid'] = $this->params['pid'];
         $this->data['pmid'] = $this->params['pmid'];
         $this->data['mpid'] = $this->params['mpid'];

+ 48 - 9
protected/view/w-project-section-files.html

@@ -34,7 +34,8 @@
                         </a>
                         <ul class="dropdown-menu">
                             <!-- loop allconArray -->
-                            <li><a href="{{rootUrl}}project/{{currproArray.pid}}/section">{{allconArray' value.stname}}</a></li>
+                            <li><a href="{{rootUrl}}project/{{currproArray.pid}}/section">{{allconArray'
+                                value.stname}}</a></li>
                             <!-- endloop -->
                         </ul>
                     </li>
@@ -117,7 +118,8 @@
                             <td width="">{{formatDate(itemMeasureArray' value.intime,'Y-m-d')}}</td>
                             <td>
                                 <div class="btn-group">
-                                    <a class="btn btn-mini dropdown-toggle" data-toggle="dropdown" href="#">
+                                    <a imnid="{{itemMeasureArray' value.imnid}}" id="dropdown_{{itemMeasureArray' value.imnid}}"
+                                       class="btn btn-mini dropdown-toggle" data-toggle="dropdown" href="#">
                                         <span class="caret"></span>
                                     </a>
                                     <ul class="dropdown-menu">
@@ -143,7 +145,7 @@
                         </ul>
                     </div>
                 </div>
-                <div class="filesDetail">
+                <div class="filesDetail hide">
                     <table class="table table-striped">
                         <thead>
                         <tr>
@@ -180,7 +182,7 @@
                                         data-toggle="modal"><i class="icon-time icon-white"></i>历史版本
                                 </button>
                                 &nbsp;&nbsp;&nbsp;&nbsp;
-                                <button id="deletefile" class="btn btn-mini btn-danger" type="button" href="#file-del"
+                                <button id="del_{{itemMeasureArray' value.imnid}}" imnid="{{itemMeasureArray' value.imnid}}" class="btn btn-mini btn-danger" type="button" href="#file-del"
                                         data-toggle="modal"><i class="icon-remove icon-white"></i>删除
                                 </button>
                             </td>
@@ -203,17 +205,17 @@
     <div class="modal-body">
         <div class="form">
             <form class="form-horizontal">
+                <input type="hidden" id="upimnid" name="upimnid" value=""/>
                 <div class="control-group">
                     <label class="control-label" for="inputEmail">文件名称</label>
                     <div class="controls">
-                        <input name="filename" id="filename" type="text">
+                        <input name="upfilename" id="upfilename" type="text"/>
                     </div>
                 </div>
-                </div>
                 <div class="control-group">
                     <label class="control-label" for="inputEmail">备注/描述</label>
                     <div class="controls">
-                        <textarea name="filedesc" id="filedesc"></textarea>
+                        <textarea name="upfiledesc" id="upfiledesc"></textarea>
                     </div>
                 </div>
             </form>
@@ -221,7 +223,7 @@
     </div>
     <div class="modal-footer">
         <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
-        <button class="btn btn-primary">确定修改</button>
+        <button id="updateFileDesc" class="btn btn-primary">确定修改</button>
     </div>
 </div>
 <!-- 编辑弹出 -->
@@ -316,9 +318,46 @@
             $("#intime").html(intime);
             $("#tips").html(tips);
             $("#numpname").html(numpname);
+            $(".filesDetail").show();
+        });
+
+        $("a[id^='dropdown_']").click(function () {
+            var imnid = $(this).attr('imnid');
+            $("#upimnid").val(imnid);
+        });
+
+        $("button[id^='del_']").click(function () {
+            var imnid = $(this).attr('imnid');
+            $.ajax({
+                type: "POST",
+                dataType: "json",
+                cache: false,
+                data: {"imnid": imnid, "optype": 'del'},
+                url: "/project/{{pid}}/section/{{pmid}}/files",
+                success: function (data) {
+                    if (data['status'] == 1) {
+                        window.location.href = "{{rootUrl}}project/{{pid}}/section/{{pmid}}/files";
+                    }
+                }
+            });
         });
-        $("#deletefile").click(function () {
 
+        $("#updateFileDesc").click(function () {
+            var upfilename = $("#upfilename").val();
+            var upfiledesc = $("#upfiledesc").val();
+            var imnid = $("#upimnid").val();
+            $.ajax({
+                type: "POST",
+                dataType: "json",
+                cache: false,
+                data: {"upimnid": imnid, "filename": upfilename, "filedesc": upfiledesc},
+                url: "/project/{{pid}}/section/{{pmid}}/files",
+                success: function (data) {
+                    if (data['status'] == 1) {
+                        window.location.href = "{{rootUrl}}project/{{pid}}/section/{{pmid}}/files";
+                    }
+                }
+            });
         });
     });
 </script>