MaintenanceInquiry.cshtml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. 
  2. @{
  3. ViewBag.Title = "MaintenanceInquiry";
  4. Layout = "~/Views/Shared/_MainLayoutPage.cshtml";
  5. }
  6. <style>
  7. </style>
  8. <div id="toolbar" style="padding:3px;">
  9. <form id="ff">
  10. 服务状态:<input class="easyui-combobox" id="LX" style="width: 70px;">
  11. 智能搜索:<input class="easyui-textbox" id="KsCx" style="width:200px;" data-options="prompt:'渠道、客户'">
  12. 渠道:<input id="QDID" name="QDID" panelheight="200px" class="easyui-combobox" style="width:200px;" />
  13. <a id="btnSelect" href="#" class="easyui-linkbutton c1" style="margin-left:30px"><i class="fa fa-search"></i> 查询记录</a>
  14. <a id="btnRefresh" href="#" class="easyui-linkbutton c8" data-options="plain:true"><i class="fa fa-refresh"></i> 刷新</a>
  15. <a onclick="GetExcel()" id="btn_Class" href="#" class="easyui-linkbutton c2" data-options="plain:true"><i class="fa fa-file-text-o"> 导出excel</i></a>
  16. </form>
  17. </div>
  18. <div id="Table"></div>
  19. @*<table id="Table">
  20. <thead>
  21. <tr>
  22. <th field="渠道名称" width="150" align="center">渠道名称</th>
  23. <th field="客户信息" width="150" align="center">客户信息</th>
  24. <th field="产品名称" width="150" align="center">产品名称</th>
  25. <th field="服务状态" width="80" align="center">服务状态</th>
  26. <th field="服务开始时间" width="80" align="center">开始时间</th>
  27. <th field="服务结束时间" width="80" align="center">结束时间</th>
  28. <th field="登记问题数量" width="80" align="center">问题数量</th>
  29. <th field="维保天数" width="80" align="center">维保天数</th>
  30. </tr>
  31. </thead>
  32. </table>*@
  33. <script>
  34. var type = "0";
  35. //原型记录
  36. var Params = {
  37. name: "",
  38. qdid: "",
  39. type: 0
  40. };
  41. $(function () {
  42. var Report = $('#Table');
  43. Report.datagrid({
  44. fit: true,
  45. showFooter: true,
  46. toolbar: '#toolbar',
  47. width: '100%',
  48. pageSize: 20,
  49. pageList: [10, 20, 30, 40, 50, 1000],
  50. rownumbers: true,
  51. pagination: true,
  52. border: false,
  53. remoteSort: true,
  54. singleSelect: true, //单行选择
  55. loadMsg: "正在查询数据,请稍候...",
  56. url: '/Report/GeMaintenanceInquiry',
  57. method: 'post',
  58. columns: [[
  59. { field: '渠道名称', title: '渠道名称', width: 150, align: 'left', fixed: true},
  60. { field: '客户信息', title: '客户信息', align: 'left', fixed: true, width: 150 },
  61. { field: '产品名称', title: '产品名称', align: 'left', fixed: true, width: 150 },
  62. {
  63. field: '服务状态', title: '服务状态', align: 'center', fixed: true, width: 80, styler: function (value, rowData, index) {
  64. if (rowData.服务状态 == '脱保') {
  65. return "color:red";
  66. }
  67. else {
  68. return "color: #4cd964";
  69. }
  70. },
  71. },
  72. { field: '服务开始时间', title: '服务开始时间', align: 'left', fixed: true, width: 150 },
  73. { field: '服务结束时间', title: '服务结束时间', align: 'left', fixed: true, width: 150 },
  74. { field: '登记问题数量', title: '问题数量(2月)', align: 'center', fixed: true, width: 100 },
  75. { field: '维保天数', title: '剩余天数', align: 'center', fixed: true, width: 80 },
  76. { field: '说明', title: '备注', align: 'left', fixed: true, width: 200 },
  77. ]]
  78. })
  79. $("#btnSelect").bind('click', function () {
  80. Params.name = $('#KsCx').textbox('getValue');
  81. Params.qdid = $('#QDID').textbox('getValue');
  82. $('#Table').datagrid('load', Params);
  83. })
  84. $("#btnRefresh").bind('click', function () {
  85. $('#Table').datagrid('reload');
  86. })
  87. //类型
  88. $("#LX").combobox({
  89. data: [{ ID: "0", MC: "全部" }, { ID: "1", MC: "在保" }, { ID: "2", MC: "脱保" }],
  90. valueField: "ID",
  91. textField: "MC",
  92. onSelect: function (data) {
  93. Params.type = data.ID;
  94. Params.name = $('#KsCx').textbox('getValue');
  95. Params.qdid = $('#QDID').textbox('getValue');
  96. $('#Table').datagrid('load', Params);
  97. },
  98. onLoadSuccess: function () {
  99. var data = $(this).combobox('getData')[0];
  100. if (data) {
  101. var vf = $(this).combobox('options').valueField;
  102. $('#LX').combobox('setValue', data.MC);
  103. }
  104. }
  105. });
  106. //项目
  107. $("#QDID").combobox({
  108. url: '/ProManager/Datagrid',
  109. valueField: 'ID',
  110. textField: '名称',
  111. limitToList: true,
  112. onSelect: function (data) {
  113. Params.qdid = data.ID;
  114. $('#Table').datagrid('load', Params);
  115. },
  116. })
  117. })
  118. function formatterSolve(val) {
  119. if (!val) return "";
  120. var arrEntities = {
  121. 'lt': '<',
  122. 'gt': '>',
  123. 'nbsp': ' ',
  124. 'amp': '&',
  125. 'quot': '"'
  126. };
  127. return val.replace(/<[^>]+>/g, "").replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) {
  128. return arrEntities[t];
  129. });
  130. }
  131. function GetExcel() {
  132. var location = top.ZLPMS.Loading("导出中,请稍等...");
  133. $.post("/Report/GeMaintenanceInquiry", Params, function (data) {
  134. top.ZLPMS.UnLoading(location);
  135. //大标题
  136. /* var Tname = ' <tr><td colspan="1" align="center">项目名称</td><td colspan="12" align="center">详细信息</td></tr>';*/
  137. var Tname = "";
  138. //获取标题
  139. var name = '<tr>';
  140. for (let Title in data.rows[0]) {
  141. //增加\t为了不让表格显示科学计数法或者其他格式
  142. name += `<td>${Title}</td>`;
  143. }
  144. name += '</tr>';
  145. let str = '';
  146. //循环遍历,每行加入tr标签,每个单元格加td标签
  147. for (let i = 0 ; i < data.rows.length ; i++) {
  148. str += '<tr>';
  149. for (let item in data.rows[i]) {
  150. //增加\t为了不让表格显示科学计数法或者其他格式
  151. str += `<td>${data.rows[i][item] + '\t'}</td>`;
  152. }
  153. str += '</tr>';
  154. }
  155. //合计
  156. /* var Total = ' <tr><td colspan="1" align="center">合计</td><td colspan="1" align="center">' + data.footer[0].问题分值 + '</td></tr>';*/
  157. str = Tname + name + str;
  158. let worksheet = '维保信息登记表'
  159. let uri = 'data:application/vnd.ms-excel;base64,';
  160. //下载的表格模板数据
  161. let template = `<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"> <head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet> <x:Name>${worksheet}</x:Name> <x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet> </x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--> </head><body><table>${str}</table></body></html>`;
  162. //下载模板
  163. window.location.href = uri + base64(template)
  164. })
  165. }
  166. function base64(s) { return window.btoa(unescape(encodeURIComponent(s))) }
  167. </script>