zm
2020-08-21 325e0c9c69a3e923fb73f5096477bbcbe86818ef
添加附件功能
6 files added
3 files modified
334 ■■■■■ changed files
doc/00_二次开发/功能列表.xlsx patch | view | raw | blame | history
src/web/Application/Home/Common/FIdConst.class.php 7 ●●●● patch | view | raw | blame | history
src/web/Application/Home/Controller/AttachmentController.class.php 34 ●●●●● patch | view | raw | blame | history
src/web/Application/Home/DAO/AttachmentDAO.class.php 69 ●●●●● patch | view | raw | blame | history
src/web/Application/Home/Service/AttachmentService.class.php 29 ●●●●● patch | view | raw | blame | history
src/web/Application/Home/View/Attachment/index.html 20 ●●●●● patch | view | raw | blame | history
src/web/Application/Home/View/Sale/wsIndex.html 2 ●●●●● patch | view | raw | blame | history
src/web/Public/Scripts/PSI/Attachment/AttachmentList.js 151 ●●●●● patch | view | raw | blame | history
src/web/Public/Scripts/PSI/Sale/WSMainForm.js 22 ●●●●● patch | view | raw | blame | history
doc/00_二次开发/功能列表.xlsx
Binary files differ
src/web/Application/Home/Common/FIdConst.class.php
@@ -1209,6 +1209,11 @@
  /**
   * 销售订单状态跟踪表-卸货
   */
  const SO_BILL_TRACKING_UNLOAD = "C001-06";
  const SO_BILL_TRACKING_UNLOAD = "C001-06";
  
  /**
   * 附件
   */
  const ATTACHMENT = "C100";
}
src/web/Application/Home/Controller/AttachmentController.class.php
New file
@@ -0,0 +1,34 @@
<?php
namespace Home\Controller;
use Home\Common\FIdConst;
use Home\Service\AttachmentService;
use Home\Service\UserService;
/**
 * 附件Controller
 *
 * @author iem
 *
 */
class AttachmentController extends PSIBaseController
{
  /**
   * 附件列表
   */
  public function attachmentList()
  {
    if (IS_POST) {
      $us = new UserService();
      if (!$us->hasPermission(FIdConst::ATTACHMENT)) {
        die("没有权限");
      }
      $linkTableName = I("post.linkTableName");
      $linkDataId = I("post.linkDataId");
      $params =array("linkTableName"=>$linkTableName,"linkDataId"=>$linkDataId);
      $this->ajaxReturn((new AttachmentService())->attachmentList($params));
    }
  }
}
src/web/Application/Home/DAO/AttachmentDAO.class.php
New file
@@ -0,0 +1,69 @@
<?php
namespace Home\DAO;
use Home\Common\FIdConst;
/**
 * 附件 DAO
 *
 * @author iem
 */
class AttachmentDAO extends PSIBaseExDAO
{
  /**
   * 附件列表
   *
   * @param array $params
   * @return array
   */
  public function attachmentList($params)
  {
    $db = $this->db;
    $loginUserId = $params["loginUserId"];
    // 查询条件
    $linkTableName = $params["linkTableName"];
    $linkDataId = $params["linkDataId"];
    $sql = "select id,file_name,full_name,file_type,link_table_name,link_data_id,create_by,create_on,status
            from t_c_attachment a
            where (1 = 1) ";
    $queryParams = [];
    $ds = new DataOrgDAO($db);
    $rs = $ds->buildSQL(FIdConst::ATTACHMENT, "a", $loginUserId);
    if ($rs) {
      $sql .= " and " . $rs[0];
      $queryParams = array_merge($queryParams, $rs[1]);
    }
    $sql .= " and link_table_name = '%s' ";
    $queryParams[] = "$linkTableName";
    $sql .= " and link_data_id = '%s' ";
    $queryParams[] = "$linkDataId";
    $sql .= " and (a.status is null or a.status = 0)    order by a.create_on desc ";
    $data = $db->query($sql, $queryParams);
    $result = [];
    foreach ($data as $v) {
      $result[] = [
        "id" => $v["id"],
        "file_name" => $v["file_name"],
        "full_name" => $v["full_name"],
        "file_type" => $v["file_type"],
        "link_table_name" => $v["link_table_name"],
        "link_data_id" => $v["link_data_id"],
        "create_by" => $v["create_by"],
        "create_on" => $v["create_on"],
        "status" => $v["status"]
      ];
    }
    return $result;
  }
}
src/web/Application/Home/Service/AttachmentService.class.php
New file
@@ -0,0 +1,29 @@
<?php
namespace Home\Service;
use Home\DAO\AttachmentDAO;
/**
 * 附件 Service
 *
 * @author iem
 */
class AttachmentService extends PSIBaseExService
{
  private $LOG_CATEGORY = "附件管理";
  public function attachmentList($params)
  {
    if ($this->isNotOnline()) {
      return $this->emptyResult();
    }
    $params["loginUserId"] = $this->getLoginUserId();
    $dao = new AttachmentDAO($this->db());
    return $dao->attachmentList($params);
  }
}
src/web/Application/Home/View/Attachment/index.html
New file
@@ -0,0 +1,20 @@
<layout name="layout" />
<script src="{$uri}Public/Scripts/PSI/Attachment/Attachment.js?dt={$dtFlag}" type="text/javascript"></script>
<script>
  Ext.onReady(function () {
    var app = Ext.create("PSI.App", {
      userName: "{$loginUserName}",
      productionName: "{$productionName}",
      appHeaderInfo: {
        title: "{$title}",
        iconCls: "PSI-fid-8996"
      }
    });
    app.add(Ext.create("PSI.Attachment.AttachmentList", {
    }));
  });
</script>
src/web/Application/Home/View/Sale/wsIndex.html
@@ -20,6 +20,8 @@
<script src="{$uri}Public/Lodop/LodopFuncs.js?dt={$dtFlag}" type="text/javascript"></script>
<script src="{$uri}Public/Scripts/PSI/Attachment/AttachmentList.js?dt={$dtFlag}" type="text/javascript"></script>
<script>
  Ext.onReady(function () {
    var app = Ext.create("PSI.App", {
src/web/Public/Scripts/PSI/Attachment/AttachmentList.js
New file
@@ -0,0 +1,151 @@
/**
 * 选择用户
 */
Ext.define("PSI.Attachment.AttachmentList", {
  extend: "PSI.AFX.BaseDialogForm",
  config: {
    parentForm: null,
    linkTableName: "",
    linkDataId:""
  },
  title: "附件列表",
  width: 800,
  height: 600,
  modal: true,
  layout: "fit",
  initComponent: function () {
    var me = this;
    Ext.define("PSIAttachment_AttachmentList", {
      extend: "Ext.data.Model",
      fields: ["id", "fileName", "fullName", "fileType","linkTableName","linkDataId","createOn"]
    });
    var userStore = Ext.create("Ext.data.Store", {
      model: "PSIAttachment_AttachmentList",
      autoLoad: false,
      data: []
    });
    var grid = Ext.create("Ext.grid.Panel", {
      cls: "PSI",
      header: {
        height: 30,
        title: me.formatGridHeaderTitle("附件")
      },
      padding: 5,
      selModel: {
        mode: "MULTI"
      },
      selType: "checkboxmodel",
      viewConfig: {
        deferEmptyText: false,
        emptyText: "请选择附件。"
      },
      store: userStore,
      columnLines: true,
      columns: [{
        header: "附件名",
        dataIndex: "fileName",
        width: 300,
        menuDisabled: true
      }, {
        header: "附件类型",
        dataIndex: "fileType",
        width: 120,
        menuDisabled: true
      }, {
        header: "上传时间",
        dataIndex: "createOn",
        width: 170,
        menuDisabled: true
      }]
    });
    me.__grid = grid;
    Ext.apply(me, {
      items: [grid],
      buttons: [{
        text: "添加附件",
        formBind: true,
        iconCls: "PSI-button-add",
        handler: me.onOK,
        scope: me
      }, {
        text: "关闭",
        handler: function () {
          me.close();
        },
        scope: me
      }],
      listeners: {
        show: {
          fn: me.onWndShow,
          scope: me
        }
      }
    });
    me.callParent(arguments);
  },
  onWndShow: function () {
    var me = this;
    var pLinkTableName = me.getLinkTableName();
    var pLinkDataId = me.getLinkDataId();
    var userStore = me.__grid.getStore();
    var el = me.getEl() || Ext.getBody();
    el.mask("数据加载中...");
    Ext.Ajax.request({
      url: PSI.Const.BASE_URL
        + "Home/Attachment/attachmentList",
      params: {
        linkTableName: pLinkTableName,
        linkDataId:pLinkDataId
      },
      method: "POST",
      callback: function (options, success, response) {
        if (success) {
          var data = Ext.JSON
            .decode(response.responseText);
          for (var i = 0; i < data.length; i++) {
            var item = data[i];
            userStore.add({
              id: item.id,
              fileName: item.file_name,
              fullName: item.full_Name,
              fileType: item.file_type,
              linkTableName:item.link_table_name,
              linkDataId:item.link_data_id,
              createOn:item.create_on
            });
          }
        }
        el.unmask();
      }
    });
  },
  onOK: function () {
    var grid = this.__grid;
    var items = grid.getSelectionModel().getSelection();
    if (items == null || items.length == 0) {
      PSI.MsgBox.showInfo("没有选择用户");
      return;
    }
    if (this.getParentForm()) {
      this.getParentForm().setSelectedUsers(items);
    }
    this.close();
  }
});
src/web/Public/Scripts/PSI/Sale/WSMainForm.js
@@ -90,6 +90,12 @@
      scope: me,
      handler: me.onCommit
    }, {
      text: "附件",
      // hidden: me.getPermission().commit == "0",
      id: "buttonAttachment",
      scope: me,
      handler: me.onAttachment
    }, {
      hidden: me.getPermission().commit == "0",
      xtype: "tbseparator"
    }, {
@@ -856,6 +862,22 @@
    });
  },
  onAttachment: function () {
    var item = this.getMainGrid().getSelectionModel().getSelection();
    if (item == null || item.length != 1) {
      PSI.MsgBox.showInfo("请选择一条出库单");
      return;
    }
    var bill = item[0];
    var form = Ext.create("PSI.Attachment.AttachmentList", {
      parentForm: this,
      linkTableName: "t_ws_bill",
      linkDataId:bill.get("id")
    });
    form.show();
  },
  gotoMainGridRecord: function (id) {
    var me = this;
    var grid = me.getMainGrid();