Farms.cshtml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. 
  2. @{
  3. Layout = null;
  4. }
  5. <!DOCTYPE html>
  6. <html>
  7. <head>
  8. <meta name="viewport" content="width=device-width" />
  9. <title>Farms</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:'ShortNames'">单位简称</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:'FarmID',width:50">编号</th>
  82. <th data-options="field:'ShortNames',width:80,">简称</th>
  83. <th data-options="field:'LinkMan',width:50,">联系人</th>
  84. <th data-options="field:'Telephone',width:50,">电话</th>
  85. </tr>
  86. </thead>
  87. </table>
  88. </section>
  89. <section>
  90. <div id="winModal" class="easyui-window winModal" title="单位信息维护" style="width: 600px; height: 450px;padding:5px;"
  91. iconCls="icon-save" data-options="modal:true,closed:true">
  92. <div class="easyui-layout" data-options="fit:true" style="height:400px">
  93. <div data-options="region:'center'" style="padding:5px 5px 1px; height:385px">
  94. <table cellpadding="10" cellspacing="0" style="margin-left:10px">
  95. <tr>
  96. <td class="td_1">地区</td>
  97. <td class="td_1">
  98. <input class="easyui-combotree" id="RegionID" data-options="url:'/BaseInfo/GetTreeRegion',method:'post',loadFilter: function (rows) {
  99. return convert(rows);
  100. }" style="width:200px;height:20px" />
  101. </td>
  102. <td class="td_1">单位系列</td>
  103. <td class="td_1">
  104. <select id="SeriesType" class="easyui-combobox" name="SeriesType" style="width:200px;height:20px">
  105. @Html.Raw(ViewBag.SelSeriesType)
  106. </select>
  107. </td>
  108. </tr>
  109. <tr>
  110. <td class="td_1">单位编号</td>
  111. <td class="td_1"><input class="easyui-textbox" type="text" id="FarmID" name="FarmID" data-options="required:true" style="width:200px;height:20px" /></td>
  112. <td class="td_1">简称</td>
  113. <td class="td_1">
  114. <input class="easyui-textbox" type="text" id="ShortNames" name="ShortNames" data-options="required:true" style="width:200px;height:20px" />
  115. </td>
  116. </tr>
  117. <tr>
  118. <td class="td_1">地址</td>
  119. <td class="td_1"><input class="easyui-textbox" type="text" id="Address" name="Address" style="width:200px;height:20px" /></td>
  120. <td class="td_1">单位全称</td>
  121. <td class="td_1">
  122. <input class="easyui-textbox" type="text" id="Names" name="Names" data-options="required:true" style="width:200px;height:20px" />
  123. </td>
  124. </tr>
  125. <tr>
  126. <td class="td_1">联系人</td>
  127. <td class="td_1">
  128. <input class="easyui-textbox" type="text" id="LinkMan" name="LinkMan" style="width:200px;height:20px" />
  129. </td>
  130. <td class="td_1">电话</td>
  131. <td class="td_1">
  132. <input class="easyui-textbox" type="text" id="Telephone" name="Telephone" style="width:200px;height:20px" />
  133. </td>
  134. </tr>
  135. <tr>
  136. <td class="td_1">邮编</td>
  137. <td class="td_1"><input class="easyui-textbox" type="text" id="ZIP" name="ZIP" style="width:200px;height:20px;" data-options="validType:{length:[0,10]},invalidMessage:'不能超过10个字符!'" /></td>
  138. <td class="td_1">网址</td>
  139. <td class="td_1">
  140. <input class="easyui-textbox" type="text" id="FarmURL" name="FarmURL" style="width:200px;height:20px" />
  141. </td>
  142. </tr>
  143. <tr>
  144. <td class="td_1">是否能进行商品检测</td>
  145. <td class="td_1" colspan="3" align="left"><input type="checkbox" id="IsSystem" name="IsSystem" style="width:20px;height:20px;" checked/></td>
  146. </tr>
  147. <tr>
  148. <td class="td_1">备注</td>
  149. <td class="td_1" colspan="3">
  150. <textarea id="Remark" rows="4" style="width:467px"></textarea>
  151. </td>
  152. </tr>
  153. </table>
  154. </div>
  155. <div data-options="region:'south',border:false" style="text-align:right; padding: 12px 20px ;height:52px;">
  156. <a class="easyui-linkbutton" id="Save" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="Save()" style="width:80px">确认</a>
  157. <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="$('#winModal').window('close');" style="width:80px">取消</a>
  158. </div>
  159. </div>
  160. </div>
  161. </section>
  162. <script>
  163. //切换显示不同状态数据
  164. $("#DataToggle").on("click",
  165. function () {
  166. if ($('#hid_IsLock').val() === "0") {
  167. $('#hid_IsLock').val("1");
  168. $("#CurdTool").hide();
  169. $("#ResetTool").show();
  170. } else {
  171. $('#hid_IsLock').val("0");
  172. $("#ResetTool").hide();
  173. $("#CurdTool").show();
  174. }
  175. window.LoadTable();
  176. });
  177. //添加
  178. function btn_Add() {
  179. $("#hid_Type").val("Add");
  180. $("#FarmID").textbox("setValue", "");
  181. $("#ShortNames").textbox("setValue", "");
  182. $("#Address").textbox("setValue", "");
  183. $("#Names").textbox("setValue", "");
  184. $("#Telephone").textbox("setValue", "");
  185. $("#FarmURL").textbox("setValue", "");
  186. $("#LinkMan").textbox("setValue", "");
  187. $("#ZIP").textbox("setValue", "");
  188. $("#IsSystem").attr('checked','checked');
  189. $("#Remark").val("");
  190. $('#winModal').window('open');
  191. }
  192. //修改
  193. function btn_Edit() {
  194. $("#hid_Type").val("Edit");
  195. var row = $('#dgTable').datagrid('getSelected');
  196. if (row) {
  197. $("#FarmID").textbox("setValue", row.FarmID);
  198. $("#ShortNames").textbox("setValue", row.ShortNames);
  199. $("#Address").textbox("setValue", row.Address);
  200. $("#Names").textbox("setValue", row.Names);
  201. $("#Telephone").textbox("setValue", row.Telephone);
  202. $("#FarmURL").textbox("setValue", row.FarmURL);
  203. $("#LinkMan").textbox("setValue", row.LinkMan);
  204. $("#ZIP").textbox("setValue", row.ZIP);
  205. $("#Remark").val(row.Remark);
  206. $("#IsSystem").attr('checked', row.IsSystem == "1" ? true : false);
  207. $("#RegionID").combotree('setValue', row.RegionID);
  208. $("#SeriesType").combobox('setValue', row.SeriesType);
  209. $('#winModal').window('open');
  210. } else {
  211. layer.alert('请选择一条记录进行设置', { icon: 7, title: '提示信息' });
  212. }
  213. }
  214. function DelOrRetore(type) {
  215. var FarmID = $('#dgTable').datagrid('getSelections')[0].FarmID;
  216. if (!FarmID) {
  217. layer.alert('请选择一条记录进行设置', { icon: 7, title: '提示信息' });
  218. return;
  219. }
  220. if (type == 'Del' || type === "ReDel" ) {
  221. $.messager.confirm('删除或恢复', '确定删除或恢复这条记录?', function (r) {
  222. if (r) {
  223. $.ajax({
  224. url: "@Url.Action("FarmsListOper", "BaseInfo")",
  225. type: "post",
  226. data: {
  227. Type: type,
  228. FarmID: FarmID
  229. },
  230. success: function (data) {
  231. if (CheckAajxData(data) == false) {
  232. return;
  233. }
  234. var msg = JSON.parse(data);
  235. if (msg != null && msg.Success == true) {
  236. LoadTable();
  237. layer.alert("操作成功!", { title: '提示信息' });
  238. } else {
  239. layer.alert(msg.ErrorInfo, { title: '提示信息' });
  240. }
  241. }
  242. });
  243. }
  244. })
  245. }
  246. }
  247. //提交
  248. function Save(type) {
  249. if ($("#ZIP").textbox("getValue").length > 10) {
  250. $.messager.alert('错误提示', '邮编长度不能超过10!', 'error');
  251. return;
  252. }
  253. if ($("#FarmID").textbox("getValue").length <= 0) {
  254. $.messager.alert('错误提示', '单位编号不能为空!', 'error');
  255. return;
  256. }
  257. if ($("#Names").textbox("getValue").length <= 0) {
  258. $.messager.alert('错误提示', '单位全称不能为空!', 'error');
  259. return;
  260. }
  261. type = type || $("#hid_Type").val();
  262. var FarmID = (type === "Edit" || type === "Del" || type === "ReDel") ? $('#dgTable').datagrid('getSelections')[0].FarmID : "";
  263. $.ajax({
  264. url: "@Url.Action("FarmsListOper", "BaseInfo")",
  265. type: "post",
  266. data: {
  267. Type: type,
  268. FarmID: $("#FarmID").textbox("getValue"),
  269. ShortNames: $("#ShortNames").textbox("getValue"),
  270. LinkMan: $("#LinkMan").textbox("getValue"),
  271. Address: $("#Address").textbox("getValue"),
  272. Telephone: $("#Telephone").textbox("getValue"),
  273. ZIP: $("#ZIP").textbox("getValue"),
  274. FarmURL: $("#FarmURL").textbox("getValue"),
  275. Remark: $("#Remark").val(),
  276. Names: $("#Names").textbox("getValue"),
  277. IsSystem: $('#IsSystem').is(':checked') ? "1" : "0",
  278. RegionID: $("#RegionID").combotree('getValue'),
  279. SeriesType: $("#SeriesType").combobox('getValue')
  280. },
  281. success: function (data) {
  282. if (CheckAajxData(data) == false) {
  283. return;
  284. }
  285. var msg = JSON.parse(data);
  286. if (msg != null && msg.Success == true) {
  287. LoadTable();
  288. $('#winModal').window('close');
  289. layer.alert("操作成功!", { title: '提示信息' });
  290. } else {
  291. layer.alert(msg.ErrorInfo, { title: '提示信息' });
  292. }
  293. }
  294. });
  295. }
  296. //modal赋值
  297. function SetModalVal() {
  298. var rows = $('#dgTable').datagrid('getSelections');
  299. if (rows.length === 1) {
  300. var row = rows[0];
  301. //console.log(row);
  302. $("#FarmID").val(row.FarmID),
  303. $("#ShortNames").val(row.ShortNames),
  304. $("#LinkMan").val(row.LinkMan),
  305. $("#Telephone").val(row.Telephone),
  306. $("#modal").modal("show");
  307. } else {
  308. layer.alert('请选择一条记录进行设置', { icon: 7, title: '提示信息' });
  309. }
  310. }
  311. //加载表格数据
  312. function LoadTable(value, item) {
  313. $('#dgTable').datagrid({
  314. url: '@Url.Action("GetFarmsList", "BaseInfo")',
  315. queryParams:{
  316. IsLock: $('#hid_IsLock').val(),
  317. ShortNames: value
  318. },
  319. onDblClickRow: function () {
  320. if ($('#hid_IsLock').val() === "0") {
  321. btn_Edit();
  322. }
  323. }
  324. });
  325. }
  326. $(function () {
  327. //加载表格数据
  328. var value = $(".textbox.searchbox .textbox-value").val(), item = $(".textbox.searchbox .textbox-value").attr("name");
  329. window.LoadTable(value, item);
  330. //加载日历控件
  331. //laydate({
  332. // elem: '#PractiseTime',
  333. // format: "YYYY-MM-DD",
  334. // min: "1980-01-01",
  335. // event: "focus"
  336. //});
  337. });
  338. function convert(rows) {
  339. function exists(rows, parentId) {
  340. for (var i = 0; i < rows.length; i++) {
  341. if (rows[i].id == parentId) return true;
  342. }
  343. return false;
  344. }
  345. var nodes = [];
  346. // get the top level nodes
  347. for (var i = 0; i < rows.length; i++) {
  348. var row = rows[i];
  349. if (!exists(rows, row.parentId)) {
  350. nodes.push({
  351. id: row.id,
  352. text: row.name
  353. });
  354. }
  355. }
  356. var toDo = [];
  357. for (var i = 0; i < nodes.length; i++) {
  358. toDo.push(nodes[i]);
  359. }
  360. while (toDo.length) {
  361. var node = toDo.shift(); // the parent node
  362. // get the children nodes
  363. for (var i = 0; i < rows.length; i++) {
  364. var row = rows[i];
  365. if (row.parentId == node.id) {
  366. var child = { id: row.id, text: row.name };
  367. if (node.children) {
  368. node.children.push(child);
  369. } else {
  370. node.children = [child];
  371. }
  372. toDo.push(child);
  373. }
  374. }
  375. }
  376. return nodes;
  377. }
  378. </script>
  379. </body>
  380. </html>