intelligence.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="keywords" content="dongke,mes,ibossmes">
  6. <meta name="description" content="制造企业生产过程执行管理系统">
  7. <meta name="author" content="xuwei">
  8. <title>东科软件</title>
  9. <link rel="shortcut icon" href="/img/logo.png" />
  10. <link rel="bookmark" href="/img/logo.png" />
  11. <link rel="stylesheet" type="text/css" href="/plugins/easyui/themes/dongke/easyui.css">
  12. <link rel="stylesheet" type="text/css" href="/plugins/easyui/themes/icon.css">
  13. <link rel="stylesheet" type="text/css" href="/plugins/xeasyui/xuwell.css">
  14. <script type="text/javascript" src="/plugins/easyui/jquery.min.js"></script>
  15. <script type="text/javascript" src="/plugins/easyui/jquery.easyui.min.js"></script>
  16. <script type="text/javascript" src="/plugins/easyui/locale/easyui-lang-zh_CN.js"></script>
  17. <script type="text/javascript" src="/plugins/xeasyui/xuwell.js"></script>
  18. <link href="/plugins/xeasyui/toolbar.min.css" rel="stylesheet" />
  19. <style>
  20. .inp {
  21. width: 120px;
  22. height: 28px;
  23. border: 0;
  24. }
  25. .combobox {
  26. color: #fff;
  27. background-color: #444;
  28. }
  29. </style>
  30. </head>
  31. <body class="easyui-layout">
  32. <div id="toolbarLayout" data-options="border:false,region:'north',title:'',iconCls:'icon-grid'">
  33. <!--工具条-->
  34. <div id="tb" class="i-toolbar">
  35. <a class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="jump()">添加</a>
  36. <a class="easyui-linkbutton" iconcls="icon-edit" plain="true" onclick="tbReportEdit()">修改</a>
  37. <a class="easyui-linkbutton" iconcls="icon-excel" plain="true" onclick="tbExport()">导出</a>
  38. <a class="easyui-linkbutton" iconcls="icon-reload" plain="true" onclick="restore()">刷新</a>
  39. <a class="easyui-linkbutton" iconcls="icon-print" plain="true" onclick="downfile()">下载附件</a>
  40. <div id="tbSearchDiv" style="display: block; padding: 10px;">
  41. <div>
  42. 时间:
  43. <input id="opentime" type="text" class="easyui-datebox" style="width:165px; height:32px;">
  44. -
  45. <input id="closetime" type="text" class="easyui-datebox" style="width:165px; height:32px;">
  46. </div>
  47. <div style="padding-top:10px;">
  48. 项目名称:
  49. <input id="name" class="inp">
  50. 参与人员:
  51. <input id="people" class="inp" placeholder="多人请用/进行连接">
  52. <select id="modelSelect" class="combobox inp">
  53. <option selected value="">请选择型号</option>
  54. </select>
  55. <a class="easyui-linkbutton" onclick="select()">搜索</a>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. <div id="tableLayout" data-options="singleSelect:true,border:false,region:'center',split:true,title:'',iconCls:'icon-grid'" title="East" style="width:700px;">
  61. <div id="tableTabs" class="easyui-tabs" data-options="singleSelect:true,border:false" style="width: 100%; height: 100%">
  62. <div title="质量经验库">
  63. <table id="myTable" class="easyui-datagrid" data-options="method:'get',border:false,fit:true,fitColumns:true">
  64. <thead>
  65. <tr>
  66. <th data-options="field:'id',title:'id',align:'center',sortable:false,hidden:true"></th>
  67. <th data-options="field:'name',title:'项目名称',align:'center',sortable:false"></th>
  68. <th data-options="field:'modelid',title:'产品ID',align:'center',sortable:false,hidden:true"></th>
  69. <th data-options="field:'modelname',title:'产品编码',align:'center',sortable:false"></th>
  70. <th data-options="field:'participants',title:'参与人员',align:'center',sortable:false"></th>
  71. <th data-options="field:'problem',title:'问题',align:'center',sortable:false"></th>
  72. <th data-options="field:'solution',title:'解决方式',align:'center',sortable:false"></th>
  73. <th data-options="field:'solutioneffect',title:'解决效果',align:'center',sortable:false"></th>
  74. <th data-options="field:'showannex',title:'项目相关资料',align:'center',sortable:false"></th>
  75. <th data-options="field:'createtime',title:'创建时间',align:'center',sortable:false"></th>
  76. <th data-options="field:'username',title:'创建人',align:'center',sortable:false"></th>
  77. </tr>
  78. </thead>
  79. </table>
  80. </div>
  81. </div>
  82. </div>
  83. <script>
  84. /**加载前调用*/
  85. $(document).ready(function () {
  86. getcontent();
  87. getproductmodel();
  88. });
  89. /**导出*/
  90. const tbExport=() =>{
  91. /**中文标题映射 */
  92. const fieldMap = {
  93. 'name': '项目名称',
  94. 'modelname': '产品编码',
  95. 'participants': '参与人员',
  96. 'problem': '问题',
  97. 'solution': '解决方式',
  98. 'solutioneffect': '解决效果',
  99. 'showannex': '项目相关资料',
  100. 'createtime': '创建时间',
  101. 'username': '创建人'
  102. };
  103. //加载表头
  104. const fields = $('#myTable').datagrid('getColumnFields');
  105. const headers = [];
  106. for (var i = 0; i < fields.length; i++) {
  107. var chineseHeader = fieldMap[fields[i]] || fields[i];
  108. headers.push(chineseHeader);
  109. }
  110. $('#myTable').datagridExport({
  111. headers: headers,
  112. fileName: '导出数据(质量经验库).xls',
  113. workSheet: '导出数据(质量经验库)'
  114. //,dataType: 'text'
  115. });
  116. };
  117. /**添加 */
  118. const jump = () => {
  119. parent.window.location.href = 'Richtext.html';
  120. };
  121. /**获取所有内容 */
  122. const getcontent = () => {
  123. $.get("/mes/pc/intelligence/Richtext.ashx?m=get", function (data) {
  124. /**填充表格*/
  125. toshow(data);
  126. })
  127. };
  128. /**刷新 */
  129. const restore = () => {
  130. /**重置data输入框*/
  131. $('#opentime, #closetime').datebox();
  132. /** 重置文本输入框的值*/
  133. document.getElementById('name').value = '';
  134. document.getElementById('people').value = '';
  135. /**重置下拉选择框的值(选择第一个选项,即默认选项)*/
  136. var selectElement = document.getElementById('modelSelect');
  137. selectElement.selectedIndex = 0;
  138. /** 使read恢复初始状态 */
  139. read = Object.assign({}, {
  140. opentime: '',
  141. closetime: '',
  142. name: '',
  143. people: '',
  144. modelid: ''
  145. });
  146. /**获取所有内容*/
  147. getcontent();
  148. }
  149. /**填充表格*/
  150. const toshow = (data) => {
  151. //将数据转换成json
  152. var json = JSON.parse(data);
  153. //遍历数据
  154. json.forEach(ex => {
  155. //获取问题的文本内容(网页换成文本)
  156. ex.problem = extractTextFromHTML(ex.problem);
  157. //表格展示文件名称
  158. ex.showannex = ex.annex.substr(ex.annex.lastIndexOf('/') + 1);
  159. //文件下载路径
  160. ex.annex = ex.annex;
  161. })
  162. //填充表格
  163. $('#myTable').datagrid({
  164. data: json,
  165. //配置项,显示选中行数据
  166. onSelect: function (rowIndex, rowData) {
  167. }
  168. });
  169. }
  170. /** 将问题过滤成文本内容*/
  171. const extractTextFromHTML = (htmlString) => {
  172. const parser = new DOMParser();
  173. const doc = parser.parseFromString(htmlString, 'text/html');
  174. // 使用 textContent 直接获取所有文本
  175. const textContent = doc.body.textContent || '';
  176. return textContent.trim();
  177. };
  178. /**下载附件 */
  179. const downfile = () => {
  180. var selectedRow = $('#myTable').datagrid('getSelected');
  181. if (selectedRow) {
  182. var a = document.createElement("a");
  183. a.href = selectedRow.annex;
  184. a.download = selectedRow.annex.substr(selectedRow.annex.lastIndexOf('/') + 1);
  185. document.body.appendChild(a);
  186. a.click();
  187. document.body.removeChild(a);
  188. }
  189. };
  190. /**修改 */
  191. const tbReportEdit = () => {
  192. var selectedRow = $('#myTable').datagrid('getSelected');
  193. if (selectedRow) {
  194. parent.window.location.href = 'Richtext.html?id=' + selectedRow.id;
  195. }
  196. };
  197. // 响应式数据:产品型号列表
  198. let models = [];
  199. /** 获取产品型号 */
  200. const getproductmodel = () => {
  201. $.get("Richtext.ashx?m=getproductmodel", function (data) {
  202. var json = JSON.parse(data);
  203. models = json;
  204. loadModelsToSelect();
  205. })
  206. };
  207. /** 加载型号到 select 元素中 */
  208. const loadModelsToSelect = () => {
  209. const select = document.getElementById('modelSelect');
  210. // 遍历模型数组并添加选项
  211. models.forEach(model => {
  212. const option = document.createElement('option');
  213. option.value = model.ID;
  214. option.textContent = model.GOODSCODE;
  215. select.appendChild(option);
  216. });
  217. // 监听选择变化
  218. select.addEventListener('change', function () {
  219. read.modelid = this.value;
  220. });
  221. };
  222. /**搜索*/
  223. const select = () => {
  224. $.ajax({
  225. url: "intelligence.ashx?m=getcontent",
  226. type: "POST",
  227. data: read,
  228. //要传递json时
  229. // contentType: "application/json; charset=utf-8",
  230. // data: JSON.stringify(formData),
  231. success: function (data) {
  232. toshow(data);
  233. },
  234. error: function (xhr, status, error) {
  235. console.error("请求失败: " + error);
  236. }
  237. });
  238. }
  239. /**搜索对象 */
  240. let read = {
  241. /**开始时间*/
  242. opentime:'',
  243. /**结束时间*/
  244. closetime:'',
  245. /**项目名称*/
  246. name:'',
  247. /** 参与人员*/
  248. people:'',
  249. /**产品型号*/
  250. modelid:''
  251. }
  252. // 监听普通文本框的变化
  253. $('#name, #people').on('input', function () {
  254. const key = this.id;
  255. read[key] = $(this).val();
  256. });
  257. // 监听easyui-datebox的变化
  258. $('#opentime, #closetime').datebox({
  259. onChange: function (newValue, oldValue) {
  260. const key = this.id;
  261. read[key] = newValue; // 或者根据需要转换为字符串
  262. }
  263. });
  264. // 监听easyui-combobox的变化
  265. $('#modelid').combobox({
  266. onChange: function (newValue, oldValue) {
  267. read.modelid = newValue;
  268. }
  269. });
  270. </script>
  271. </body>
  272. </html >