>[warning] 使用前請務必在js頁面引入**form.js imgpreview.js**
#### 文件上傳組件
>[info] plupload: function (id, success, error) {}
* id:表單ID
* success:上傳成功回調函數
* up:上傳文件的基本信息
* ret:上傳返回的狀態及文件的基本信息[在使用中主要用這個里面的數據]
* file:
* error:上傳失敗回調函數
>[success]上傳成功回調函數
上傳成功后的回調函數主要讀取ret中的數據,ret返回數據格式如下:
```php
{
"code":1,
"msg":"上傳成功",
"data":
{
"fileId":"1",
"title":"1dcc5e90f603738d8a0c27ddbd1bb051fa19ecdc",
"url":"\/uploads\/20190708\/3e72e1066f353e8da7caf7aeabfbb4f0.gif",
"path":"\/uploads\/20190708\/3e72e1066f353e8da7caf7aeabfbb4f0.gif",
"thumbPath":"\/uploads\/20190708\/3e72e1066f353e8da7caf7aeabfbb4f0.gif",
"fullPath":"http:\/\/www.yun.com:8091\/uploads\/20190708\/3e72e1066f353e8da7caf7aeabfbb4f0.gif",
"hash":"4ba48c37508019cdca6cf935f38cbac8ac59fdd0",
"size":20971520,
"type":"gif"
},
"url":"",
"wait":3
}
}
```
>[success]示例代碼
表單頁面代碼【說明:在上傳文件表單中需要在class中添加plupload data-list-box-id必須存在且有值,還要加上data-moduleno[其值為模塊名稱]、data-relid[關聯的單據編號]。同時需要添加一個顯示文件內容的div,其id為imgpreview,class添加imgpreview_edit】
```html
<div class="form-group">
<label class="col-xs-12 col-sm-2 control-label">相關附件:</label>
<div class="col-xs-12 col-sm-8">
<a href="javascript:;" id="btnUploader" data-filetype="file" data-list-box-id="imgpreview"
data-moduleno="TASK" data-relid="TTASK2019060001" class="plupload btn btn-info">
<i
class="fa fa-upload "></i>
上傳附件</a>
</div>
</div>
<div class="form-group">
<ul class="col-xs-10 col-xs-offset-2 imgpreview_edit" id="imgpreview">
</ul>
</div>
```
js頁面代碼【在調用上傳方法時,需要重新綁定一下上傳事件( ImgPreview.api.bindevent();)】
```js
add:function(){
//代碼內容...
ImgPreview.api.bindevent();
},
```
- 空白目錄
- 簡介
- 前端
- 組件
- 文件上傳
- 用戶選擇
- 組織機構選擇
- 角色崗位選擇
- 崗位選擇
- 用戶組選擇
- 高拍儀上傳
- 公共類庫
- 組織機構
- bindToOrg
- bindusertoremote
- getAncestors
- getAllChildIds
- getByOrgId
- getByThirdAppPkId
- getChilds
- getChildsCount
- getMasterOrg
- getOrgUserById
- getOrgUser
- getOrgRoleData
- getOrgRoleQuota
- getOrgRoleUserCount
- getParents
- getPosteritys
- getTreeArray
- getUserOrgs
- getUserOrgCount
- getUserOrgRoleInfo
- hasChild
- hasMasterOrg
- hasBind
- isOrgUser
- updateOrg
- 用戶管理
- getAuthorInfo
- getByDuty
- getByGroup
- getByMobile
- getByOrg
- getByUserId
- getByUserName
- getByRole
- getByToken
- getByThirdUserId
- getUserOrgs
- getUserRoles
- getUserList
- 統一待辦
- createTodo
- createHandle
- createRead
- removeTodo
- getTodoList
- setReaded