ModalInputViewModel.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using System.Web.Mvc;
  4. using Abp.Localization;
  5. using IwbZero;
  6. namespace ContractService.Views.Shared.Modals
  7. {
  8. public class ModalInputViewModel
  9. {
  10. public ModalInputViewModel(List<Input> inputs, List<SpecialInputModel> specials)
  11. {
  12. Specials = specials;
  13. Inputs = inputs;
  14. }
  15. public List<SpecialInputModel> Specials { get; set; }
  16. public List<Input> Inputs { get; set; }
  17. }
  18. public class ModalTabInputViewModel
  19. {
  20. public ModalTabInputViewModel(List<ModalTabViewModel> tabs, List<SpecialInputModel> specials)
  21. {
  22. Tabs = tabs;
  23. Specials = specials;
  24. }
  25. public List<ModalTabViewModel> Tabs { get; set; }
  26. public List<SpecialInputModel> Specials { get; set; }
  27. }
  28. #region ModalBody
  29. public class Input
  30. {
  31. public Input()
  32. {
  33. InputType = InputTypes.Text;
  34. LayoutClassDefault = true;
  35. DivClassDefault = true;
  36. }
  37. public Input(string id, string displayName = "", InputTypes inputType = InputTypes.Text, string placeholder = "", string name = null, string value = "", string @class = "", string dataOptions = "", string events = "", string styles = "", string other = "", bool hide = false, string label = "", string help = "") : this()
  38. {
  39. Id = id;
  40. Name = string.IsNullOrEmpty(name) ? id : name;
  41. DisplayName = string.IsNullOrEmpty(displayName) ? L(id) : displayName;
  42. InputType = inputType;
  43. _placeholder = placeholder;
  44. Value = value;
  45. _class = @class;
  46. DataOptions = dataOptions;
  47. Events = events;
  48. Styles = styles;
  49. Other = other;
  50. IsHidden = hide;
  51. IsRequired = !hide;
  52. IsDisabled = false;
  53. IsReadOnly = false;
  54. _label = label;
  55. Help = help;
  56. IsSm = true;
  57. }
  58. #region 方法
  59. public Input SetType(InputTypes inputType = InputTypes.Text)
  60. {
  61. InputType = inputType;
  62. return this;
  63. }
  64. public Input SetList()
  65. {
  66. InputType = InputTypes.List;
  67. return this;
  68. }
  69. public Input SetList(List<SelectListItem> selectOptions, bool isMultiple = false,
  70. bool isAddBlank = false)
  71. {
  72. return SetSelectOptions(selectOptions, isMultiple, isAddBlank);
  73. }
  74. public Input SetList(string selectOptions, bool isMultiple = false, bool isAddBlank = false)
  75. {
  76. return SetSelectOptions(selectOptions, isMultiple, isAddBlank);
  77. }
  78. public Input SetSelectOptions(List<SelectListItem> selectOptions, bool isMultiple = false, bool isAddBlank = false)
  79. {
  80. string str = isAddBlank ? "<option value=\"\" selected>请选择</option>" : "";
  81. IsMultiple = isMultiple;
  82. if (selectOptions != null && selectOptions.Any())
  83. {
  84. foreach (var s in selectOptions)
  85. {
  86. str += "<option value=\"" + s.Value + "\">" + s.Text + "</option>\r\n";
  87. }
  88. }
  89. SelectOptions = str;
  90. InputType = InputTypes.List;
  91. return this;
  92. }
  93. public Input SetSelectOptions(string selectOptions, bool isMultiple = false, bool isAddBlank = false)
  94. {
  95. string str = isAddBlank ? "<option value=\"\" selected>请选择</option>" : "";
  96. IsMultiple = isMultiple;
  97. if (!string.IsNullOrEmpty(selectOptions))
  98. {
  99. str += selectOptions;
  100. }
  101. SelectOptions = str;
  102. InputType = InputTypes.List;
  103. return this;
  104. }
  105. public Input SetDataOptions(string dataOptions)
  106. {
  107. DataOptions = dataOptions;
  108. return this;
  109. }
  110. public Input SetOthers(string other)
  111. {
  112. Other = other;
  113. return this;
  114. }
  115. public Input SetStyles(string styles)
  116. {
  117. Styles = styles;
  118. return this;
  119. }
  120. public Input SetEvents(string events)
  121. {
  122. Events = events;
  123. return this;
  124. }
  125. public Input SetName(string name)
  126. {
  127. Name = name;
  128. return this;
  129. }
  130. public Input SetHelp(string help)
  131. {
  132. Help = help;
  133. return this;
  134. }
  135. public Input SetMaxLength(int maxLength)
  136. {
  137. MaxLength = maxLength;
  138. return this;
  139. }
  140. public Input SetMinLength(int minLength)
  141. {
  142. MinLength = minLength;
  143. return this;
  144. }
  145. public Input SetHidden()
  146. {
  147. IsHidden = true;
  148. return this;
  149. }
  150. public Input SetLabel(string label)
  151. {
  152. _label = label;
  153. return this;
  154. }
  155. public Input SetLabelName(string label)
  156. {
  157. _label = "<label class=\"iwb-label col-md-2 form-control-label\" for=\"" + Id + "\">" + label +
  158. "</label>";
  159. return this;
  160. }
  161. public Input SetLabelNameRequired(string label)
  162. {
  163. _label = "<label class=\"iwb-label col-md-2 form-control-label iwb-label-required\" for=\"" + Id + "\">" + label +
  164. "</label>";
  165. return this;
  166. }
  167. public Input SetSpecial(string special)
  168. {
  169. Special = special;
  170. return this;
  171. }
  172. public Input SetNotRequired()
  173. {
  174. IsRequired = false;
  175. return this;
  176. }
  177. public Input SetDisabled()
  178. {
  179. IsDisabled = true;
  180. return this;
  181. }
  182. public Input SetReadonly()
  183. {
  184. IsReadOnly = true;
  185. return this;
  186. }
  187. public Input SetLayout(string labelLayout, string inputLayout)
  188. {
  189. LabelLayoutClass = labelLayout;
  190. InputLayoutClass = inputLayout;
  191. LayoutClassDefault = false;
  192. return this;
  193. }
  194. //public Input SetLayout(int labelLayout, int? inputLayout = null, string layoutPrefix = "col-md-")
  195. //{
  196. // inputLayout = inputLayout ?? 12 - labelLayout;
  197. // LabelLayout = $"{layoutPrefix}{labelLayout}";
  198. // InputLayout = $"{layoutPrefix}{inputLayout}";
  199. // return this;
  200. //}
  201. public Input SetDivId(string id)
  202. {
  203. DivId = id;
  204. return this;
  205. }
  206. public Input SetDivClass(string classStr, string other = "")
  207. {
  208. DivClass = classStr;
  209. DivOther = other;
  210. DivClassDefault = false;
  211. return this;
  212. }
  213. /// <summary>
  214. /// 外层上面其他标签
  215. /// </summary>
  216. /// <param name="beforeStr"></param>
  217. /// <returns></returns>
  218. public Input SetOuterBefore(string beforeStr)
  219. {
  220. DivOutBefore = beforeStr;
  221. return this;
  222. }
  223. /// <summary>
  224. /// 外层下面其他标签
  225. /// </summary>
  226. /// <param name="afterStr"></param>
  227. /// <returns></returns>
  228. public Input SetOuterAfter(string afterStr)
  229. {
  230. DivOutAfter = afterStr;
  231. return this;
  232. }
  233. /// <summary>
  234. /// 内层上面其他标签
  235. /// </summary>
  236. /// <param name="beforeStr"></param>
  237. /// <returns></returns>
  238. public Input SetInterBefore(string beforeStr)
  239. {
  240. DivInterBefore = beforeStr;
  241. return this;
  242. }
  243. /// <summary>
  244. /// 内层下面其他标签
  245. /// </summary>
  246. /// <param name="afterStr"></param>
  247. /// <returns></returns>
  248. public Input SetInterAfter(string afterStr)
  249. {
  250. DivInterAfter = afterStr;
  251. return this;
  252. }
  253. /// <summary>
  254. /// 添加搜索按钮
  255. /// </summary>
  256. /// <param name="searchModalId"></param>
  257. /// <param name="target"></param>
  258. /// <param name="clear"></param>
  259. /// <returns></returns>
  260. public Input SetSearchIcon(string searchModalId)
  261. {
  262. SearchModalId = searchModalId;
  263. return this;
  264. }
  265. /// <summary>
  266. /// 添加搜索按钮
  267. /// </summary>
  268. /// <param name="searchModalId"></param>
  269. /// <param name="target"></param>
  270. /// <param name="clear"></param>
  271. /// <returns></returns>
  272. public Input SetSearchIcon(string searchModalId, string target, string clear = "")
  273. {
  274. SearchModalId = searchModalId;
  275. _target = target;
  276. if (!string.IsNullOrEmpty(clear))
  277. {
  278. SetSearchClear(clear, true);
  279. }
  280. return this;
  281. }
  282. /// <summary>
  283. /// 添加搜索范围Class
  284. /// </summary>
  285. /// <param name="class"></param>
  286. /// <returns></returns>
  287. public Input SetSearchClass(string @class)
  288. {
  289. DivSearchClass = @class;
  290. return this;
  291. }
  292. /// <summary>
  293. /// 添加搜索按钮
  294. /// </summary>
  295. /// <param name="searchModalId"></param>
  296. /// <param name="class"></param>
  297. /// <param name="clear"></param>
  298. /// <returns></returns>
  299. public Input SetSearchIconWithClass(string searchModalId, string @class, string clear = "")
  300. {
  301. SearchModalId = searchModalId;
  302. _target = "." + @class;
  303. DivSearchClass = @class;
  304. if (!string.IsNullOrEmpty(clear))
  305. {
  306. SetSearchClear(clear, true);
  307. }
  308. return this;
  309. }
  310. /// <summary>
  311. /// 配置需要清空的INPUT Id
  312. /// </summary>
  313. /// <param name="clear"></param>
  314. /// <param name="isDefault"></param>
  315. /// <returns></returns>
  316. public Input SetSearchClear(string clear, bool isDefault = false)
  317. {
  318. Clear = isDefault ? $"{clear}No,{clear}Name" : clear;
  319. return this;
  320. }
  321. /// <summary>
  322. /// 输入提示
  323. /// </summary>
  324. /// <param name="placeholder"></param>
  325. /// <returns></returns>
  326. public Input SetPlaceholder(string placeholder)
  327. {
  328. _placeholder = placeholder;
  329. return this;
  330. }
  331. public Input SetNotSmall()
  332. {
  333. IsSm = false;
  334. return this;
  335. }
  336. #endregion
  337. #region 字段属性
  338. public string Id { get; set; }
  339. public string Name { get; set; }
  340. public string DisplayName { get; set; }
  341. public string Help { get; set; }
  342. private string PlaceholderPrefix => InputType == InputTypes.List ? L("PlaceholderSelectHeader") : L("PlaceholderHeader");
  343. private string _placeholder;
  344. public string Placeholder => string.IsNullOrEmpty(_placeholder) ? $"{PlaceholderPrefix}{DisplayName}..." : _placeholder;
  345. public InputTypes InputType { get; set; }
  346. public string TypeStr
  347. {
  348. get
  349. {
  350. switch (InputType)
  351. {
  352. case InputTypes.Text:
  353. return "text";
  354. case InputTypes.Password:
  355. return "password";
  356. case InputTypes.Checkbox:
  357. return "checkbox";
  358. case InputTypes.Radio:
  359. return "radio";
  360. case InputTypes.File:
  361. return "file";
  362. case InputTypes.Number:
  363. return "number";
  364. default:
  365. return "text";
  366. }
  367. }
  368. }
  369. public DateTypes DateType { get; set; }
  370. public bool IsSm { get; set; }
  371. public string Number { get; set; }
  372. public int? MinLength { get; set; }
  373. public int? MaxLength { get; set; }
  374. public int? Min { get; set; }
  375. public int? Max { get; set; }
  376. public string Value { get; set; }
  377. public string SelectOptions { get; private set; }
  378. private string _class;
  379. public string Class
  380. {
  381. get
  382. {
  383. var classStr = $"form-control {_class}";
  384. if (IsDisabled)
  385. {
  386. classStr += " disabled ";
  387. }
  388. if (IsReadOnly)
  389. {
  390. classStr += " readonly ";
  391. }
  392. if (InputType == InputTypes.Number)
  393. {
  394. classStr += $" {Number} ";
  395. }
  396. if (InputType == InputTypes.Date)
  397. {
  398. classStr += DateType == DateTypes.DateTime ? " iwb-date-time " : " iwb-date ";
  399. }
  400. return classStr;
  401. }
  402. set => _class = value;
  403. }
  404. public string DataOptions { get; set; }
  405. public string Events { get; set; }
  406. public string Styles { get; set; }
  407. private string _other;
  408. public string Other
  409. {
  410. get
  411. {
  412. if (MinLength != null)
  413. {
  414. _other += $" minlength={MinLength}";
  415. }
  416. if (MaxLength != null)
  417. {
  418. _other += $" maxlength={MaxLength}";
  419. }
  420. if (Min != null)
  421. {
  422. _other += $" min={Min}";
  423. }
  424. if (Max != null)
  425. {
  426. _other += $" max={Max}";
  427. }
  428. return _other;
  429. }
  430. set => _other = value;
  431. }
  432. public bool IsHidden { get; set; }
  433. public bool IsRequired { get; set; }
  434. public bool IsDisabled { get; set; }
  435. public bool IsReadOnly { get; set; }
  436. public bool IsMultiple { get; private set; }
  437. public string Required => IsHidden ? "" : (IsRequired ? " required" : "");
  438. public string DivId { get; set; }
  439. public string DivClass { get; set; }
  440. public string DivSearchClass { get; set; }
  441. public bool DivClassDefault { get; set; }
  442. public string DivOther { get; set; }
  443. public string DivOutBefore { get; set; }
  444. public string DivOutAfter { get; set; }
  445. public string DivInterBefore { get; set; }
  446. public string DivInterAfter { get; set; }
  447. public string SearchModalId { get; set; }
  448. public string LabelLayoutClass { get; set; }
  449. public string InputLayoutClass { get; set; }
  450. public bool LayoutClassDefault { get; set; }
  451. private string _label;
  452. public string Label => IsHidden
  453. ? ""
  454. : string.IsNullOrEmpty(_label)
  455. ? (IsRequired
  456. ? $"<label class=\"{LabelLayoutClass} iwb-label {(IsSm ? "iwb-label-sm" : "col-form-label")} iwb-label-required\" for=\"{Id}\">{DisplayName}</label>"
  457. : $"<label class=\"{LabelLayoutClass} iwb-label {(IsSm ? "iwb-label-sm" : "col-form-label")} \" for=\"{Id}\">{DisplayName}</label>")
  458. : _label;
  459. public string Disabled => IsDisabled ? "disabled=\"disabled\"" : "";
  460. public string ReadOnly => IsReadOnly ? "readonly=\"readonly\"" : "";
  461. public FileInputOption FileOption { get; set; }
  462. private string _target;
  463. public string Target =>
  464. string.IsNullOrEmpty(_target) ? DefaultTarget ?? "" :
  465. _target.StartsWith(".") ? _target :
  466. _target.StartsWith("#") ? _target : $"#{_target}";
  467. public string DefaultTarget { get; set; }
  468. public string Clear { get; set; }
  469. public string Special { get; set; }
  470. public bool IsAjaxSelect { get; protected set; }
  471. public string TableKey { get; protected set; }
  472. public string ColumnKey { get; protected set; }
  473. public int TakeCount { get; protected set; }
  474. /// <summary>
  475. /// 展示模板函数
  476. /// </summary>
  477. public string FunResultTemplateName { get; protected set; }
  478. #endregion
  479. private static string L(string name)
  480. {
  481. var str = LocalizationHelper.GetSource(IwbZeroConsts.LocalizationSourceName).GetString(name);
  482. return str;
  483. }
  484. }
  485. public class InputHide : Input
  486. {
  487. public InputHide(string id, string displayName = "", string placeholder = "", string name = "", string value = "", string @class = "", string dataOptions = "", string events = "", string styles = "", string other = "", string label = "")
  488. : base(id, displayName, InputTypes.Textarea, placeholder, name, value, @class, dataOptions, events, styles, other, true, label)
  489. {
  490. }
  491. }
  492. public class InputTextarea : Input
  493. {
  494. public InputTextarea(string id, string displayName = "", string placeholder = "", string name = "", string value = "", string @class = "", string dataOptions = "", string events = "", string styles = "", string other = "", bool hide = false, string label = "")
  495. : base(id, displayName, InputTypes.Textarea, placeholder, name, value, @class, dataOptions, events, styles, other, hide, label)
  496. {
  497. }
  498. }
  499. public class InputKindeditor : InputTextarea
  500. {
  501. public InputKindeditor(string id, string displayName = "", string placeholder = "", string name = "", string value = "", string dataOptions = "", string events = "", string styles = "", string other = "", bool hide = false, string label = "")
  502. : base(id, displayName, placeholder, name, value, "kindeditor", dataOptions, events, styles, other, hide, label)
  503. {
  504. }
  505. }
  506. public class InputWangEditor : Input
  507. {
  508. public InputWangEditor(string id, string displayName = "", string placeholder = "", string name = "", string value = "", string @class = "", string dataOptions = "head,bold,fontSize,fontName,italic,underline,strikeThrough,indent,lineHeight,foreColor,backColor,justify,image", string events = "", string styles = "", string other = "", bool hide = false, string label = "")
  509. : base(id, displayName, InputTypes.WangEditor, placeholder, name, value, @class, dataOptions, events, styles, dataOptions, hide, label)
  510. {
  511. IsRequired = false;
  512. }
  513. public InputWangEditor SetMenus(string menu)
  514. {
  515. Other = menu;
  516. return this;
  517. }
  518. public InputWangEditor SetOptions(string opts)
  519. {
  520. DataOptions = opts;
  521. return this;
  522. }
  523. }
  524. public class InputDate : Input
  525. {
  526. public InputDate(string id, string displayName = "", DateTypes date = DateTypes.Date, string placeholder = "", string name = "", string value = "", string @class = "", string dataOptions = "", string events = "", string styles = "", string other = "", bool hide = false, string label = "")
  527. : base(id, displayName, InputTypes.Date, placeholder, name, value, @class, dataOptions, events, styles, other, hide, label)
  528. {
  529. DateType = date;
  530. }
  531. public InputDate SetDateType(DateTypes date)
  532. {
  533. DateType = date;
  534. return this;
  535. }
  536. public InputDate SetDateTime()
  537. {
  538. DateType = DateTypes.DateTime;
  539. return this;
  540. }
  541. }
  542. public class InputDateTime : Input
  543. {
  544. public InputDateTime(string id, string displayName = "", DateTypes date = DateTypes.DateTime, string placeholder = "", string name = "", string value = "", string @class = "", string dataOptions = "", string events = "", string styles = "", string other = "", bool hide = false, string label = "")
  545. : base(id, displayName, InputTypes.Date, placeholder, name, value, @class, dataOptions, events, styles, other, hide, label)
  546. {
  547. DateType = date;
  548. }
  549. public InputDateTime SetDateType(DateTypes date)
  550. {
  551. DateType = date;
  552. return this;
  553. }
  554. public InputDateTime SetDate()
  555. {
  556. DateType = DateTypes.Date;
  557. return this;
  558. }
  559. }
  560. public class InputNumber : Input
  561. {
  562. /// <summary>
  563. ///
  564. /// </summary>
  565. /// <param name="id"></param>
  566. /// <param name="displayName"></param>
  567. /// <param name="numberType">0是整数,其他是小数</param>
  568. /// <param name="min"></param>
  569. /// <param name="max"></param>
  570. /// <param name="placeholder"></param>
  571. /// <param name="name"></param>
  572. /// <param name="value"></param>
  573. /// <param name="class"></param>
  574. /// <param name="dataOptions"></param>
  575. /// <param name="events"></param>
  576. /// <param name="styles"></param>
  577. /// <param name="other"></param>
  578. /// <param name="hide"></param>
  579. /// <param name="label"></param>
  580. public InputNumber(string id, string displayName = "", int numberType = 0, int? min = null, int? max = null, string placeholder = "", string name = "", string value = "", string @class = "", string dataOptions = "", string events = "", string styles = "", string other = "", bool hide = false, string label = "")
  581. : base(id, displayName, InputTypes.Number, placeholder, name, value, @class, dataOptions, events, styles, other, hide, label)
  582. {
  583. Number = numberType == 0 ? "number" : "digits";
  584. Min = min;
  585. Max = max;
  586. }
  587. public InputNumber SetRange(int? min = null, int? max = null, int numberType = 1)
  588. {
  589. Min = min;
  590. Max = max;
  591. Number = numberType == 0 ? "number" : "digits";
  592. return this;
  593. }
  594. public InputNumber SetNumberType(int numberType = 1, int? min = null, int? max = null)
  595. {
  596. Number = numberType == 0 ? "number" : "digits";
  597. Min = min;
  598. Max = max;
  599. return this;
  600. }
  601. public InputNumber SetMin(int min)
  602. {
  603. Min = min;
  604. return this;
  605. }
  606. public InputNumber SetMax(int max)
  607. {
  608. Max = max;
  609. return this;
  610. }
  611. }
  612. public class AjaxSelect : Input
  613. {
  614. public AjaxSelect(string id, string displayName, string tableKey, string columnKey, string searchModalId, string clear = "", int takeCount = 10, string placeholder = "", string name = "", string value = "", string @class = "", string dataOptions = "",
  615. string events = "", string styles = "", string other = "", bool hide = false, string label = "")
  616. : base(id, displayName, InputTypes.List, placeholder, name, value, @class, dataOptions, events, styles,
  617. other, hide, label)
  618. {
  619. IsAjaxSelect = true;
  620. TableKey = tableKey;
  621. ColumnKey = columnKey;
  622. TakeCount = takeCount;
  623. SearchModalId = searchModalId;
  624. if (string.IsNullOrEmpty(clear))
  625. {
  626. SetSearchClear(id);
  627. }
  628. else
  629. {
  630. SetSearchClear(clear, true);
  631. }
  632. }
  633. public AjaxSelect SetResultTemplateName(string resultTemplateName)
  634. {
  635. FunResultTemplateName = resultTemplateName;
  636. return this;
  637. }
  638. }
  639. public class InputFile : Input
  640. {
  641. public InputFile(string id, string displayName = "", string placeholder = "", string name = "", string value = "", string @class = "", string dataOptions = "", string events = "", string styles = "", string other = "", bool hide = false, string label = "")
  642. : base(id, displayName, InputTypes.File, placeholder, name, value, @class, dataOptions, events, styles, other, hide, label)
  643. {
  644. FileOption = new FileInputOption(id);
  645. }
  646. /// <summary>
  647. /// 文件选择框设置信息
  648. /// </summary>
  649. /// <param name="opt"></param>
  650. /// <returns></returns>
  651. public InputFile SetFileOption(FileInputOption opt)
  652. {
  653. opt.FileInfoField = string.IsNullOrEmpty(opt.FileInfoField) ? Id : opt.FileInfoField;
  654. FileOption = opt;
  655. InputType = InputTypes.File;
  656. return this;
  657. }
  658. /// <summary>
  659. /// 文件选择框设置信息
  660. /// </summary>
  661. /// <returns></returns>
  662. public InputFile SetFileOption(string fileInfoField = "", string fileNameField = "", string fileExtField = "", int maxSize = 5)
  663. {
  664. fileInfoField = string.IsNullOrEmpty(fileInfoField) ? Id : fileInfoField;
  665. FileOption = new FileInputOption(fileInfoField, fileNameField, fileExtField, false, maxSize);
  666. return this;
  667. }
  668. /// <summary>
  669. /// 图片选择框设置信息
  670. /// </summary>
  671. /// <returns></returns>
  672. public InputFile SetImageOption(string fileInfoField = "", string fileNameField = "", string fileExtField = "", int maxSize = 5)
  673. {
  674. fileInfoField = string.IsNullOrEmpty(fileInfoField) ? Id : fileInfoField;
  675. FileOption = new FileInputOption(fileInfoField, fileNameField, fileExtField, true, maxSize);
  676. return this;
  677. }
  678. }
  679. public class SpecialInputModel
  680. {
  681. public string Id { get; set; }
  682. public string InputStr { get; set; }
  683. }
  684. public class FileInputOption
  685. {
  686. public FileInputOption(string fileInfoField, string fileNameField = "", string fileExtField = "", bool isImage = true, int maxSize = 5, string fileIdField = null)
  687. {
  688. FileInfoField = fileInfoField;
  689. FileNameField = fileNameField;
  690. FileExtField = fileExtField;
  691. IsImage = isImage;
  692. MaxSize = maxSize;
  693. FileIdField = fileIdField;
  694. }
  695. public string FileIdField { get; set; }
  696. public string FileInfoField { get; set; }
  697. public string FileNameField { get; set; }
  698. public string FileExtField { get; set; }
  699. public bool IsImage { get; set; }
  700. /// <summary>
  701. /// 文件最大M(默认5M)
  702. /// </summary>
  703. public int MaxSize { get; set; }
  704. }
  705. public enum InputTypes
  706. {
  707. Text, List, Checkbox, Radio, Password, Textarea, File, Number, Date, WangEditor
  708. }
  709. public enum DateTypes
  710. {
  711. Date, DateTime
  712. }
  713. #endregion
  714. }