## 交互插件
#### 日期選擇:`DateSwitch`
**生成兩個日期選擇控件(“開始日期”,“結束日期”),以及下拉菜單(今日,本周,本月等)。**
```javascript
$.fn.DateSwitch
//e.g.
$(".dateSwitch").DateSwitch
```
*容器的`data-init`屬性控制是否有初始時間范圍,默認為`true`,有初始值(本月)。*
---------
####消息提示:`MsgBox`
**展示浮動消息提示,通常在操作行為后顯示(提交、保存等)**
```typescript
interface AjaxResult {
IsSuccess: Boolean,//是否成成功
Data: any,//返回數據
Msg: string;//消息
}
//根據返回結果顯示消息,成功后執行方法
MsgBox.Show(result:Sail.AjaxResult,successText:string,act?:Function)
ShowMessage(result:Sail.AjaxResult,successText:string,act?:Function)
//successText為成功后提示的文本,為空時顯示默認消息(result.Msg)
//成功后執行方法
MsgBox.Action(result: Sail.AjaxResult, act?: Function)
//顯示信息(藍色)
MsgBox.Info(text:string)
ShowInfo(text:string);
//顯示成功消息(綠色)
MsgBox.Success(text:string)
ShowSuccess(text:string);
//顯示錯誤消息(紅色)
MsgBox.Error(text:string)
ShowError(text:string);
//e.g.
var result = {
IsSuccess:true,
Data:[],
Msg:'hello'
};
MsgBox.Show(result,function(result){console.log(result.Msg);});
/*顯示浮動消息"hello"(綠色)
'hello'*/
MsgBox.Action(result,function(result){console.log(result.Msg);});
//效果同上
MsgBox.Info('hello');
//顯示浮動消息"hello"(藍色)
MsgBox.Success('hello');
//顯示浮動消息"hello"(綠色)
MsgBox.Error('hello');
//顯示浮動消息"hello"(紅色)
```
*text為提示的文本信息;*
---------
####彈窗選擇:`SelectModal`
**分頁列表,點擊按鈕后彈窗顯示,可查詢/選擇。**
```typescript
$.fn.ModalSelect(set: Sail.IModalSelectSetting);
interface IModalSelectSetting {
defaultId: string,//預設model.Id
id: string;//彈窗Id
resultTarget: string;//選擇后渲染的容器,默認為輸入框
resultTmpl: string;//選擇后渲染模板
title: string;//標題
modalTmpl: string;//彈窗模板
api: string;//api
href: string;//新增按鈕跳轉鏈接(如果有)
pageSet: IPaginationSetting;//彈窗列表分頁設置
onSelect: Function;//選擇后執行的函數
onClear: Function;//清除后執行的函數;
isAllowClear: boolean;//是否允許清除,默認true
}
interface IPaginationSetting {
bodyContainer?: any;//列表容器
getPostKey?: Function;//設置ajax參數
pageSize?: number;//分頁大小
handleName: any;//ajax路徑
headContainer?: any;//列表標題容器
footContainer?: any;//頁腳容器
ajaxType?: Function;//ajax類型,默認get
bodyTmpl?: any;//列表模板
footTmpl?: any;//頁腳模板
queryed?: any;//查詢后行為
titles?: Array<string>;//列表標題
titleWidth?: Array<number>;//列表標題寬度
events?: Array<IEvent>;//事件定義
reQueryHandle?: string;//查詢按鈕
}
//e.g.
$("[data-target=ProjectId]").ModalSelect({
id: "ProjectModal",
title: "選擇監管項目",
modalTmpl: "#ProjectModalTmpl",
pageSet: {
titles: ["項目名稱", "項目地址"],
handleName: "/api/project/GetModalList",
bodyTmpl: "#ProjectListTmpl"
},
onSelect: function (data) {
console.log(data);
$(tool.$Editor).find("#DeveloperId").SetValue(data.DeveloperId);
$(tool.$Editor).find("#EnterpriseName").SetValue(data.Developer.EnterpriseName);
$(tool.$Editor).find("#Purpose").SetValue(data.Purpose);
}
});
```