SmartIndex.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. 
  2. //智能表单
  3. var Params = {
  4. pageNumber: 1,
  5. pageSize: 999,
  6. FLID: 0,
  7. FLMC:""
  8. };
  9. var viewModel = function () {
  10. //初始化表格
  11. this.init = function () {
  12. $("#tree").tree({
  13. lines: true,
  14. animate: true,
  15. method: "get",
  16. idField: 'id',
  17. treeField: 'text',
  18. /* url: '/ViewModels/tree_data.json',*/
  19. url: '/SmartForm/GetCategory',
  20. onSelect: eventData.TreeNodeClick,
  21. onDblClick: function (node) {
  22. //双击收起或展开
  23. $(this).tree("collapse", node.target);
  24. },
  25. onClick: function (node) {
  26. Params.FLID = node.id;
  27. Params.FLMC = node.text;
  28. $('#grid').datagrid('reload', Params);
  29. },
  30. onLoadSuccess: function (node, data) {
  31. if (node) {
  32. //加载某个节点
  33. if (curOrg && curOrg.id) {
  34. $("#tree").tree("select", $("#tree").tree("find", curOrg.id).target);
  35. }
  36. } else {
  37. //初始化加载
  38. //展开第一个根节点
  39. var roots = $(this).tree("getRoots");
  40. if (roots.length > 0) {
  41. $(this).tree("expand", roots[0].target);
  42. //找到第一个元素
  43. var n = $('#tree').tree('find', data[0].id);
  44. //调用选中事件
  45. $('#tree').tree('select', n.target);
  46. Params.FLID = data[0].id;
  47. Params.FLMC = data[0].text;
  48. List.loadGrid();
  49. }
  50. }
  51. },
  52. onBeforeLoad: function (node, param) {
  53. if (node)
  54. return false;
  55. },
  56. loadFilter: function (data, parent) {
  57. //无数据则显示为叶子节点
  58. if (parent && data.length == 0) {
  59. var node = $(this).tree("getSelected");
  60. if (node) {
  61. $(this).tree("update", {
  62. target: node.target,
  63. state: "open",
  64. iconCls: "tree-file"
  65. });
  66. }
  67. }
  68. if (data) {
  69. return eval(data);
  70. }
  71. }
  72. });
  73. //增加
  74. $('#btn-add').click(function () {
  75. top.ZLPMS.OpenNewWindow("新增分类", "/SmartForm/AddClass?id=&type=1", "600px", "300px", function (callback) {
  76. $('#tree').tree('reload');
  77. })
  78. });
  79. //编辑
  80. $('#btn-edit').click(function () {
  81. if (Params.FLMC != null) {
  82. top.ZLPMS.OpenNewWindow("修改分类", encodeURI("/SmartForm/AddClass?id=" + Params.FLID + "&type=2&name=" + Params.FLMC), "600px", "300px", function (callback) {
  83. $('#tree').tree('reload');
  84. })
  85. } else {
  86. top.ZLPMS.Msg("请选择一行记录后执行操作", 0);
  87. }
  88. });
  89. //刷新
  90. $('#btn-ref').click(function () {
  91. $('#tree').tree('reload');
  92. });
  93. /*表单增加*/
  94. //增加
  95. $('#fbtn-add').click(function () {
  96. top.ZLPMS.OpenNewWindow("新增表单", "/SmartForm/AddSmartForm?id=&type=1", "80%", "765px", function () {
  97. console.log("回调")
  98. })
  99. //top.ZLPMS.OpenWindow({
  100. // url: '/SmartForm/AddSmartForm',
  101. // title: '表单编辑',
  102. // btn: ['确定', '取消'],
  103. // area: ['80%', '765px'],
  104. // yes: function (index, layero) {
  105. // Forms.Submit(index, layero);
  106. // },
  107. //});
  108. });
  109. /*表单修改*/
  110. $('#fbtn-edit').click(function () {
  111. var row = $('#grid').datagrid('getSelected');
  112. if (!row) {
  113. top.ZLPMS.Msg("请选择列");
  114. return;
  115. }
  116. top.ZLPMS.OpenNewWindow("编辑表单", "/SmartForm/AddSmartForm?id=" + row.ID + "&type=2", "80%", "765px", function () {
  117. console.log("回调")
  118. })
  119. });
  120. //刷新表单
  121. $('#fbtn-ref').click(function () {
  122. $('#grid').datagrid('reload');
  123. });
  124. //复制表单
  125. $('#fbtn-copy').click(function () {
  126. var row = $('#grid').datagrid('getSelected');
  127. if (!row) {
  128. top.ZLPMS.Msg("请选择列");
  129. return;
  130. }
  131. $.ajax({
  132. url: '/SmartForm/CopySmartForm/' + row.ID,
  133. method: 'post',
  134. success: function (data) {
  135. if (data.code == 200) {
  136. top.ZLPMS.Msg(data.msg);
  137. $('#grid').datagrid('reload');
  138. } else {
  139. ZLPMS.Msg(data.msg, 2);
  140. }
  141. }
  142. })
  143. });
  144. //分享
  145. $('#fbtn-share').click(function () {
  146. var row = $('#grid').datagrid('getSelected');
  147. if (!row) {
  148. top.ZLPMS.Msg("请选择列");
  149. return;
  150. }
  151. let copy_text ="登录后请打开此地址填写信息《"+row.MC +"》https://zlpms.zlsoft.com:8078/MobileProblem/SelectProblemItem?id="+ row.ID;//拿到想要复制的值
  152. let input_dom = document.createElement('input');//创建input元素
  153. input_dom.value = copy_text;//添加需要复制的内容到value属性
  154. document.body.appendChild(input_dom);//向页面底部追加输入框
  155. input_dom.select();//选择input元素
  156. document.execCommand("Copy");//执行复制命令
  157. top.ZLPMS.Msg("地址已复制成功,使用CTRL+V进行粘贴");
  158. //复制之后再删除元素,否则无法成功赋值
  159. input_dom.remove();//删除动态创建的节点
  160. });
  161. }
  162. }
  163. //列表操作
  164. var List = {
  165. //重新加载
  166. loadGrid: function () {
  167. $("#grid").datagrid({
  168. fit: true,
  169. width: '100%',
  170. toolbar: '#toolbar',
  171. pageSize: 20,
  172. pageList: [10, 20, 30, 40, 50, 1000],
  173. rownumbers: true,
  174. pagination: true,
  175. border: true,
  176. remoteSort: true,
  177. singleSelect: true, //单行选择
  178. queryParams: Params,
  179. loadMsg: "正在查询数据,请稍候...",
  180. url: '/SmartForm/BdxxSelectList',
  181. method: "post",
  182. columns: [[
  183. { field: 'ID', title: 'ID', width: 20, align: 'center', fixed: true, hidden: true },
  184. { field: 'FLID', title: '分类id', width: 20, align: 'center', fixed: true, hidden: true },
  185. { field: 'MC', title: '表单名称', align: 'left', fixed: true, width: 150 },
  186. /* { field: 'TXTS', title: '填写提示', align: 'left', fixed: true, width: 200 },*/
  187. {
  188. field: 'TXXZ', title: '填写限制', align: 'left', fixed: true, width: 80,
  189. formatter: function (value, rowData, index) {
  190. return rowData.TXXZ == 0 ? '无限制' : '可填写' + rowData.TXXZ + '次';
  191. }
  192. },
  193. {
  194. field: 'CLMS', title: '处理模式', align: 'center', fixed: true, width: 80,
  195. formatter: function (value, rowData, index) {
  196. return rowData.CLMS == 0 ? '无需处理' : '需要处理';
  197. }
  198. },
  199. { field: 'TXHM', title: '提醒号码', align: 'left', fixed: true, width: 120 },
  200. { field: 'YJTS', title: '邮件推送', align: 'left', fixed: true, width: 120 },
  201. {
  202. field: 'JLSJ', title: '建立时间', width: 135, align: 'center', fixed: true,
  203. },
  204. { field: 'BZ', title: '备注', align: 'left', fixed: true, width: 300 },
  205. {
  206. field: 'ZT', title: '状态', align: 'left', fixed: true, width: 80,
  207. formatter: function (value, rowData, index) {
  208. return rowData.ZT == 0 ? '停用' : '启用';
  209. }
  210. },
  211. ]],
  212. rowStyler: function (index, row) {
  213. },
  214. onDblClickRow: function (rowIndex, rowData) {
  215. }
  216. });
  217. },
  218. //删除指定的模块菜单
  219. Del: function (id) {
  220. }
  221. }
  222. //树形操作
  223. var eventData = {
  224. //树节点单击事件
  225. TreeNodeClick: function (node) {
  226. //console.log(node);
  227. }
  228. }