MedicalRecordIndex.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. 
  2. //原型记录
  3. var Params = {
  4. pageNumber: 1,
  5. pageSize: 999,
  6. 类型: 1,
  7. 状态: -1,
  8. 名称:"",
  9. 分类ID: "",
  10. 是否所有分类: "",
  11. 分类名称: ""
  12. };
  13. var viewModel = function () {
  14. //初始化表格
  15. this.init = function () {
  16. $("#tree").tree({
  17. lines: true,
  18. animate: true,
  19. method: "post",
  20. idField: 'id',
  21. treeField: 'text',
  22. queryParams: { "类型":Params.类型 },
  23. url: '/MedicalRecordManager/GetCategory',
  24. onSelect: eventData.TreeNodeClick,
  25. onDblClick: function (node) {
  26. //双击收起或展开
  27. $(this).tree("collapse", node.target);
  28. },
  29. onClick: function (node) {
  30. Params.分类ID = node.id;
  31. Params.分类名称 = node.text;
  32. Params.是否所有分类 = Params.分类ID;//记录选中分类
  33. $('#grid').datagrid('reload', Params);
  34. },
  35. onLoadSuccess: function (node, data) {
  36. if (node) {
  37. //加载某个节点
  38. if (curOrg && curOrg.id) {
  39. $("#tree").tree("select", $("#tree").tree("find", curOrg.id).target);
  40. }
  41. } else {
  42. //初始化加载
  43. //展开第一个根节点
  44. var roots = $(this).tree("getRoots");
  45. if (roots.length > 0) {
  46. $(this).tree("expand", roots[0].target);
  47. //找到第一个元素
  48. var n = $('#tree').tree('find', data[0].id);
  49. //调用选中事件
  50. $('#tree').tree('select', n.target);
  51. Params.分类ID = data[0].id;
  52. Params.分类名称 = data[0].text;
  53. List.loadGrid();
  54. }
  55. else {
  56. Params.分类ID = "";
  57. Params.分类名称 = "";
  58. List.loadGrid();
  59. }
  60. }
  61. },
  62. onBeforeLoad: function (node, param) {
  63. if (node)
  64. return false;
  65. },
  66. loadFilter: function (data, parent) {
  67. //无数据则显示为叶子节点
  68. if (parent && data.length == 0) {
  69. var node = $(this).tree("getSelected");
  70. if (node) {
  71. $(this).tree("update", {
  72. target: node.target,
  73. state: "open",
  74. iconCls: "tree-file"
  75. });
  76. }
  77. }
  78. if (data) {
  79. return eval(data);
  80. }
  81. }
  82. });
  83. //类型
  84. $("#LX").combobox({
  85. data: [{ ID: "1", MC: "个人" }, { ID: "2", MC: "渠道" }, { ID: "3", MC: "总部" }],
  86. valueField: "ID",
  87. textField: "MC",
  88. onSelect: function (data) {
  89. Params.类型 = data.ID;
  90. $('#tree').tree("options").queryParams = { "类型": Params.类型 };
  91. $('#tree').tree('reload');
  92. if (Params.类型 == 3) {//
  93. $("#btnSH").attr("style", "");//审核显示
  94. $("#btnQX").attr("style", "");
  95. $("#btnQY").attr("style", "display:none;");
  96. $("#btnTY").attr("style", "display:none;");//启用隐藏
  97. }
  98. else {
  99. $("#btnQY").attr("style", "");//启用显示
  100. $("#btnTY").attr("style", "");
  101. $("#btnSH").attr("style", "display:none;");//审核隐藏
  102. $("#btnQX").attr("style", "display:none;");
  103. }
  104. },
  105. onLoadSuccess: function () {
  106. var data = $(this).combobox('getData')[0];
  107. if (data) {
  108. var vf = $(this).combobox('options').valueField;
  109. $('#LX').combobox('setValue', data.MC);
  110. }
  111. if (Params.类型 == 3) {//
  112. $("#btnSH").attr("style", "");//审核显示
  113. $("#btnQX").attr("style", "");
  114. $("#btnQY").attr("style", "display:none;");
  115. $("#btnTY").attr("style", "display:none;");//启用隐藏
  116. }
  117. else {
  118. $("#btnQY").attr("style", "");//启用显示
  119. $("#btnTY").attr("style", "");
  120. $("#btnSH").attr("style", "display:none;");//审核隐藏
  121. $("#btnQX").attr("style", "display:none;");
  122. }
  123. }
  124. });
  125. //性质
  126. $("#XZ").combobox({
  127. url: '/MedicalRecordManager/SelectNature?ID=ACA9B395-0B88-412A-89F0-91FEF1D7D27C',
  128. valueField: "ID",
  129. textField: "名称",
  130. onSelect: function (data) {
  131. Params.性质 = data.ID;
  132. $('#grid').datagrid('reload', Params);
  133. }
  134. });
  135. //状态
  136. $("#ZT").combobox({
  137. data: [{ ID: "-1", MC: "全部" },{ ID: "0", MC: "停用" }, { ID: "1", MC: "启用" }],
  138. valueField: "ID",
  139. textField: "MC",
  140. onSelect: function (data) {
  141. Params.状态 = data.ID;
  142. $('#grid').datagrid('reload', Params);
  143. },
  144. onLoadSuccess: function () {
  145. var data = $(this).combobox('getData')[0];
  146. if (data) {
  147. var vf = $(this).combobox('options').valueField;
  148. $('#ZT').combobox('setValue', data.MC);
  149. }
  150. }
  151. });
  152. //分类增加
  153. $('#btn-add').click(function () {
  154. top.ZLPMS.OpenNewWindow("新增分类", "/MedicalRecordManager/AddClass?id=&type=1&lx=" + Params.类型, "600px", "300px", function (callback) {
  155. $('#tree').tree('reload');
  156. }, function (endcallback) {
  157. })
  158. });
  159. //添加评论
  160. $('#AddComment').click(function () {
  161. var row = $('#grid').datagrid('getSelected');
  162. if (!row) {
  163. top.ZLPMS.Msg("请选择列");
  164. return;
  165. }
  166. top.ZLPMS.OpenNewWindow("新增评论", "/MedicalRecordManager/AddComment?id=" + row.ID, "600px", "300px", function (callback) {
  167. DealProcess(row.ID);
  168. }, function (endcallback) {
  169. })
  170. });
  171. //分类编辑
  172. $('#btn-edit').click(function () {
  173. if (Params.分类名称 != null) {
  174. top.ZLPMS.OpenNewWindow("修改分类", encodeURI("/MedicalRecordManager/AddClass?id=" + Params.分类ID + "&type=2&name=" + Params.分类名称 + "&lx=" + Params.类型), "600px", "300px", function (callback) {
  175. $('#tree').tree('reload');
  176. })
  177. } else {
  178. top.ZLPMS.Msg("请选择一行记录后执行操作", 0);
  179. }
  180. });
  181. //分类刷新
  182. $('#btn-ref').click(function () {
  183. $('#tree').tree('reload');
  184. });
  185. //分类删除
  186. $('#btn-del').click(function () {
  187. $.post("/MedicalRecordManager/DelCategory", { ID: Params.分类ID}, function (data) {
  188. top.ZLPMS.Msg(data.msg);
  189. $('#tree').tree('reload');
  190. })
  191. });
  192. /*原型记录*/
  193. //查询
  194. $('#btnSelect').click(function () {
  195. Params.名称 = $('#KsCx').textbox('getValue');
  196. Params.分类ID = $("#terminissues").checkbox('options').checked == true ? '' : Params.是否所有分类
  197. $('#grid').datagrid('reload');
  198. });
  199. }
  200. }
  201. //更新状态
  202. function UpdateState(type, state) {
  203. var row = $('#grid').datagrid('getSelected');
  204. if (!row) {
  205. top.ZLPMS.Msg("请选择列");
  206. return;
  207. }
  208. $.ajax({
  209. url: '/MedicalRecordManager/UpdateSate?type=' + type + "&id=" + row.ID + "&state=" + state,
  210. method: 'post',
  211. success: function (data) {
  212. if (data.code == 200) {
  213. top.ZLPMS.Msg(data.msg);
  214. $('#grid').datagrid('reload');
  215. } else {
  216. ZLPMS.Msg(data.msg, 2);
  217. }
  218. }
  219. })
  220. };
  221. ///获取评价过程
  222. function DealProcess(ID) {
  223. /* ID ='eecac372-cc3e-482b-b71f-8d49ce15136c'*/
  224. var url = "/MedicalRecordManager/GetProcessRecords?ID=" + ID;
  225. $.post(url, {}, function (data) {
  226. $("#timeLine").empty();
  227. $.each(data, function (idx, json) {
  228. if (json != undefined) {
  229. var attfile = "";
  230. if (json.附件 != undefined) {
  231. attfile = "<i class='fa fa-paperclip' style='color:blue' title='包含过程附件'></i>";
  232. }
  233. json.评论内容 = json.评论内容 != undefined ? json.评论内容 : "无";
  234. if (json.评论内容 != "无") {
  235. var arrEntities = {
  236. 'lt': '<',
  237. 'gt': '>',
  238. 'nbsp': ' ',
  239. 'amp': '&',
  240. 'quot': '"'
  241. };
  242. json.评论内容 = json.评论内容.replace(/<[^>]+>/g, "").replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) {
  243. return arrEntities[t]
  244. });
  245. if (json.评论内容.length == 0) {
  246. json.评论内容 = "内有图片,点击该过程即可查看";
  247. }
  248. }
  249. if (json.评论内容.length > 25) {
  250. json.评论内容 = json.评论内容.substring(0, 25) + "...";
  251. }
  252. var html = "<li onclick='viewProcess(\"" + json.ID + "\")' class='layui-timeline-item timelineDetail'><i class='layui-icon layui-timeline-axis'></i><div class='layui-timeline-content layui-text'><h3 class='layui-timeline-title'><a href='#' ></a> " + attfile + "</h3><p>" + json.评论日期 + "<br> <strong>" + json.评论人 + "</strong><br>" + "评论:" + (json.评论内容) + "</p></div></li>";
  253. $("#timeLine").append(html);
  254. }
  255. });
  256. });
  257. };
  258. function viewData(ID) {
  259. top.ZLPMS.OpenNewWindow("原型预览", "/MedicalRecordManager/Preview?id=" + ID, "80%", "90%", function (callback) {
  260. }, function (endcallback) {
  261. })
  262. }
  263. //列表操作
  264. var List = {
  265. //重新加载
  266. loadGrid: function () {
  267. $("#grid").datagrid({
  268. fit: true,
  269. width: '100%',
  270. toolbar: '#toolbar',
  271. pageSize: 20,
  272. pageList: [10, 20, 30, 40, 50, 1000],
  273. rownumbers: true,
  274. pagination: true,
  275. border: true,
  276. remoteSort: true,
  277. singleSelect: true, //单行选择
  278. queryParams: Params,
  279. loadMsg: "正在查询数据,请稍候...",
  280. url: '/MedicalRecordManager/PrototypeRecordSelect',
  281. method: "post",
  282. columns: [[
  283. { field: 'ID', title: 'ID', width: 20, align: 'center', fixed: true, hidden: true },
  284. { field: 'FLID', title: '分类id', width: 20, align: 'center', fixed: true, hidden: true },
  285. { field: '原型预览地址', title: '原型预览地址', width: 20, align: 'center', fixed: true, hidden: true },
  286. { field: '序号', title: '序号', align: 'left', fixed: true, width: 40 },
  287. { field: '性质', title: '性质', align: 'left', fixed: true, width: 150 },
  288. {
  289. field: '名称', title: '名称', align: 'left', fixed: true, width: 200, formatter: function (value, rowData, index) {
  290. return '<a onclick=viewData("' + rowData.ID + '") href="#"> <span style=color:green; >' + rowData.名称 + '</span></a>';
  291. } },
  292. {
  293. field: '登记日期', title: '上传时间', width: 135, align: 'center', fixed: true,
  294. },
  295. { field: '登记人', title: '上传人', align: 'left', fixed: true, width: 120 },
  296. {
  297. field: '审核日期', title: '审核日期', width: 135, align: 'center', fixed: true,
  298. },
  299. { field: '审核人', title: '审核人', align: 'left', fixed: true, width: 120 },
  300. { field: '下载次数', title: '下载次数', align: 'left', fixed: true, width: 60 },
  301. {
  302. field: '最后下载日期', title: '最后下载日期', width: 135, align: 'center', fixed: true,
  303. },
  304. {
  305. field: '是否审核', title: '是否审核', align: 'left', fixed: true, width: 80,
  306. formatter: function (value, rowData, index) {
  307. return rowData.是否审核 == 1 ? '审核' : '未审核';
  308. }
  309. },
  310. {
  311. field: '状态', title: '状态', align: 'left', fixed: true, width: 80,
  312. formatter: function (value, rowData, index) {
  313. return rowData.状态 == 1 ? '正常' : '停用';
  314. }
  315. },
  316. ]],
  317. rowStyler: function (index, row) {
  318. },
  319. onDblClickRow: function (rowIndex, rowData) {
  320. },
  321. onSelect: function (rowIndex, rowData) {
  322. DealProcess(rowData["ID"]);
  323. }
  324. });
  325. },
  326. }
  327. //树形操作
  328. var eventData = {
  329. //树节点单击事件
  330. TreeNodeClick: function (node) {
  331. //console.log(node);
  332. }
  333. }