Habitat.cshtml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. 
  2. @{
  3. Layout = null;
  4. }
  5. <!DOCTYPE html>
  6. <html>
  7. <head>
  8. <meta name="viewport" content="width=device-width" />
  9. <title>Habitat</title>
  10. <link href="~/easyui/themes/bootstrap/easyui.css" rel="stylesheet" />
  11. <link href="~/easyui/themes/icon.css" rel="stylesheet" />
  12. <link href="~/Content/css/bootstrap.min.css" rel="stylesheet" />
  13. <link href="~/Content/js/plugins/layer/skin/layer.css" rel="stylesheet" />
  14. <script src="~/Content/js/jquery.min.js"></script>
  15. <script src="~/Content/js/bootstrap.min.js"></script>
  16. <script src="~/easyui/jquery.easyui.min.js"></script>
  17. <script src="~/easyui/jquery.easyui.mobile.js"></script>
  18. <script src="~/easyui/locale/easyui-lang-zh_CN.js"></script>
  19. <script src="~/Content/js/plugins/layer/laydate/laydate.js"></script>
  20. <script src="~/Content/js/plugins/layer/layer.min.js"></script>
  21. <script src="~/js/Utils.js"></script>
  22. <link href="~/Content/css/Style/Markets.css" rel="stylesheet" />
  23. <style>
  24. .td_1 {
  25. padding-bottom: 5px;
  26. padding-left: 5px;
  27. }
  28. </style>
  29. </head>
  30. <body>
  31. <section class="hidden">
  32. <input id="hid_Type" name="hid_Type" type="hidden" value="0" />
  33. <input id="hid_IsLock" name="IsLock" type="hidden" value="0" />
  34. <input id="hid_MarketType" name="hid_MarketType" type="hidden" value="0" />
  35. </section>
  36. @*<section class="text-center title">
  37. <h2>市场信息</h2>
  38. </section>*@
  39. <section class="container-fluid" style="height: 100vh; padding-top: 20px;">
  40. <div class="row tbToolBar" id="tbToolBar">
  41. <div class="toolbar">
  42. <label>
  43. <input type="checkbox" id="DataToggle"> 显示已删除记录
  44. </label>
  45. </div>
  46. <div class="toolbar" id="CurdTool" style="float:left">
  47. <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="btn_Add()">添加</a>
  48. <span class="shuxian"></span>
  49. <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="btn_Edit()">修改</a>
  50. <span class="shuxian"></span>
  51. <a href="#" class="easyui-linkbutton" iconCls="icon-no" plain="true" onclick="DelOrRetore('Del')">删除</a>
  52. @*<input class="btn btn-primary" id="btn_back" type="button" value="返回" onclick="btn_Back()"/>*@
  53. </div>
  54. <div class="col-sm-3" id="ResetTool">
  55. <a href="#" class="easyui-linkbutton" iconCls="icon-undo" plain="true" onclick="DelOrRetore('ReDel')">恢复删除</a>
  56. </div>
  57. <div class="toolbar-search">
  58. <span>【请选择查询条件】</span>
  59. <input class="easyui-searchbox" data-options="prompt:'请输入查询条件...',menu:'#search',searcher:LoadTable" style="width: 300px;height:25px;" />
  60. <div id="search">
  61. <div data-options="name:'Names'">产地名称</div>
  62. </div>
  63. </div>
  64. </div>
  65. <table id="dgTable" class="easyui-datagrid" style="height: 100%;"
  66. data-options="singleSelect: true,
  67. method: 'post',
  68. multiSort: false,
  69. toolbar: '#tbToolBar',
  70. fitColumns: true,
  71. rownumbers: true,
  72. remoteSort: false,
  73. loadFilter: pagerFilter,
  74. pagination: true,
  75. pageSize: 15,
  76. pageList: [15, 25, 50, 100]
  77. ">
  78. <thead>
  79. <tr>
  80. @*hid_IsLock<th data-options="field:'TradeTypeID'" class="hidden">行业类型</th>*@
  81. <th data-options="field:'HabitatID',width:50">产地编号</th>
  82. <th data-options="field:'Names',width:80,">产地名称</th>
  83. </tr>
  84. </thead>
  85. </table>
  86. </section>
  87. <section>
  88. <div id="winModal" class="easyui-window winModal" title="单位信息维护" style="width: 520px; height: 220px;padding:5px;"
  89. iconCls="icon-save" data-options="modal:true,closed:true">
  90. <div class="easyui-layout" data-options="fit:true" style="height:400px">
  91. <div data-options="region:'center'" style="padding:5px 5px 1px; height:385px">
  92. <table cellpadding="10" cellspacing="0" style="margin-left:10px">
  93. <tr>
  94. <td class="td_1">产地编号</td>
  95. <td class="td_1">
  96. <input class="easyui-textbox" type="text" id="HabitatID" name="HabitatID" data-options="required:true" style="width:400px;height:20px" />
  97. </td>
  98. </tr>
  99. <tr>
  100. <td class="td_1">产地名称</td>
  101. <td class="td_1"><input class="easyui-textbox" type="text" id="Names" name="Names" data-options="required:true" style="width:400px;height:20px" /></td>
  102. </tr>
  103. <tr>
  104. </tr>
  105. <tr>
  106. <td class="td_1">是否国内</td>
  107. <td class="td_1">
  108. <select id="HabitatType" class="easyui-combobox" name="HabitatType" style="width:400px;height:20px">
  109. <option value="1">国内</option>
  110. <option value="2">国外</option>
  111. </select>
  112. </td>
  113. </tr>
  114. </table>
  115. </div>
  116. <div data-options="region:'south',border:false" style="text-align:right; padding: 12px 20px ;height:52px;">
  117. <a class="easyui-linkbutton" id="Save" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="Save()" style="width:80px">确认</a>
  118. <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="$('#winModal').window('close');" style="width:80px">取消</a>
  119. </div>
  120. </div>
  121. </div>
  122. </section>
  123. <script>
  124. //切换显示不同状态数据
  125. $("#DataToggle").on("click",
  126. function () {
  127. if ($('#hid_IsLock').val() === "0") {
  128. $('#hid_IsLock').val("1");
  129. $("#CurdTool").hide();
  130. $("#ResetTool").show();
  131. } else {
  132. $('#hid_IsLock').val("0");
  133. $("#ResetTool").hide();
  134. $("#CurdTool").show();
  135. }
  136. window.LoadTable();
  137. });
  138. //添加
  139. function btn_Add() {
  140. $("#hid_Type").val("Add");
  141. $("#HabitatID").textbox('setValue', "");
  142. $("#HabitatID").textbox('enable')
  143. $("#Names").textbox('setValue', "");
  144. $('#winModal').window('open')
  145. }
  146. //修改
  147. function btn_Edit() {
  148. $("#hid_Type").val("Edit");
  149. var row = $('#dgTable').datagrid('getSelected');
  150. if (row) {
  151. $("#HabitatID").textbox('setValue', row.HabitatID);
  152. $("#HabitatID").textbox('disable')
  153. $("#Names").textbox('setValue', row.Names);
  154. $("#HabitatType").combobox('setValue', row.Type);
  155. $('#winModal').window('open')
  156. } else {
  157. layer.alert('请选择一条记录进行设置', { icon: '0', title: '提示信息' });
  158. }
  159. }
  160. function DelOrRetore(type) {
  161. var HabitatID = $('#dgTable').datagrid('getSelections')[0].HabitatID;
  162. if (!HabitatID) {
  163. layer.alert('请选择一条记录进行设置', { icon:'0',title: '提示信息' });
  164. return;
  165. }
  166. if (type == 'Del' || type === "ReDel") {
  167. $.messager.confirm('删除或恢复', '确定删除或恢复这条记录?', function (r) {
  168. if (r) {
  169. $.ajax({
  170. url: "@Url.Action("HabitatListOper", "BaseInfo")",
  171. type: "post",
  172. data: {
  173. Type: type,
  174. HabitatID: HabitatID
  175. },
  176. success: function (data) {
  177. if (CheckAajxData(data) == false) {
  178. return;
  179. }
  180. var msg = JSON.parse(data);
  181. if (msg != null && msg.Success == true) {
  182. LoadTable();
  183. layer.alert("操作成功!", { icon: '1', title: '提示信息' });
  184. } else {
  185. layer.alert(msg.ErrorInfo, { icon: '2', title: '提示信息' });
  186. }
  187. }
  188. });
  189. }
  190. })
  191. }
  192. }
  193. //提交
  194. function Save(type) {
  195. if ($("#HabitatID").textbox("getValue").length <= 0) {
  196. layer.alert('产地编号不能为空!', { icon: '2', title: '提示信息' });
  197. return;
  198. }
  199. if ($("#Names").textbox("getValue").length <= 0) {
  200. layer.alert('产地名称不能为空!', { icon: '2', title: '提示信息' });
  201. return;
  202. }
  203. type = type || $("#hid_Type").val();
  204. var HabitatID = (type === "Edit" || type === "Del" || type === "ReDel") ? $('#dgTable').datagrid('getSelections')[0].HabitatID : "";
  205. $.ajax({
  206. url: "@Url.Action("HabitatListOper", "BaseInfo")",
  207. type: "post",
  208. data: {
  209. Type: type,
  210. HabitatID: $("#HabitatID").textbox('getValue'),
  211. Names: $("#Names").textbox('getValue'),
  212. HabitatType: $('#HabitatType').combobox('getValue')
  213. },
  214. success: function (data) {
  215. if (CheckAajxData(data) == false) {
  216. return;
  217. }
  218. var msg = JSON.parse(data);
  219. if (msg != null && msg.Success == true) {
  220. LoadTable();
  221. $('#winModal').window('close')
  222. layer.alert("操作成功!", { icon: '1', title: '提示信息' });
  223. } else {
  224. layer.alert(msg.ErrorInfo, { icon: '2', title: '提示信息' });
  225. }
  226. }
  227. });
  228. }
  229. //modal赋值
  230. function SetModalVal() {
  231. var rows = $('#dgTable').datagrid('getSelections');
  232. if (rows.length === 1) {
  233. var row = rows[0];
  234. //console.log(row);
  235. $("#HabitatID").val(row.HabitatID),
  236. $("#Names").val(row.Names),
  237. $("#Sort").val(row.Sort),
  238. $("#modal").modal("show");
  239. } else {
  240. layer.alert('请选择一条记录进行设置', { icon: 7, title: '提示信息' });
  241. }
  242. }
  243. //加载表格数据
  244. function LoadTable(value, item) {
  245. $('#dgTable').datagrid({
  246. url: '@Url.Action("GetHabitatList", "BaseInfo")' + '?IsLock=' + $('#hid_IsLock').val() + '&&' + item + '=' + escape(value),
  247. onDblClickRow: function () {
  248. if ($('#hid_IsLock').val() === "0") {
  249. btn_Edit();
  250. }
  251. }
  252. });
  253. }
  254. $(function () {
  255. //加载表格数据
  256. var value = $(".textbox.searchbox .textbox-value").val(), item = $(".textbox.searchbox .textbox-value").attr("name");
  257. window.LoadTable(value, item);
  258. //加载日历控件
  259. //laydate({
  260. // elem: '#PractiseTime',
  261. // format: "YYYY-MM-DD",
  262. // min: "1980-01-01",
  263. // event: "focus"
  264. //});
  265. });
  266. </script>
  267. </body>
  268. </html>