intelligence.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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-search" plain="true" onclick="showReport()">预览</a>
  38. <a class="easyui-linkbutton" iconcls="icon-excel" plain="true" onclick="tbExport()">导出</a>
  39. <a class="easyui-linkbutton" iconcls="icon-reload" plain="true" onclick="restore()">刷新</a>
  40. <a class="easyui-linkbutton" iconcls="icon-print" plain="true" onclick="downfile()">下载附件</a>
  41. <div id="tbSearchDiv" style="display: block; padding: 10px;">
  42. <div>
  43. 时间:
  44. <input id="opentime" type="text" class="easyui-datebox" style="width:165px; height:32px;">
  45. -
  46. <input id="closetime" type="text" class="easyui-datebox" style="width:165px; height:32px;">
  47. </div>
  48. <div style="padding-top:10px;">
  49. 项目名称:
  50. <input id="name" class="inp">
  51. 参与人员:
  52. <input id="people" class="inp" placeholder="多人请用/进行连接">
  53. <select id="modelSelect" class="combobox inp">
  54. <option selected value="">请选择型号</option>
  55. </select>
  56. <a class="easyui-linkbutton" onclick="select()">搜索</a>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. <div id="tableLayout" data-options="singleSelect:true,border:false,region:'center',split:true,title:'',iconCls:'icon-grid'" title="East" style="width:700px;">
  62. <div id="tableTabs" class="easyui-tabs" data-options="singleSelect:true,border:false" style="width: 100%; height: 100%">
  63. <div title="质量经验库">
  64. <table id="myTable" class="easyui-datagrid" data-options="method:'get',border:false,fit:true,fitColumns:true">
  65. <thead>
  66. <tr>
  67. <th data-options="field:'id',title:'id',align:'center',sortable:false,checkbox:true,hidden:true"></th>
  68. <th data-options="field:'name',title:'项目名称',align:'center',sortable:false"></th>
  69. <th data-options="field:'modelid',title:'产品ID',align:'center',sortable:false,hidden:true"></th>
  70. <th data-options="field:'modelname',title:'产品编码',align:'center',sortable:false"></th>
  71. <th data-options="field:'participants',title:'参与人员',align:'center',sortable:false"></th>
  72. <th data-options="field:'problem',title:'问题',align:'center',sortable:false"></th>
  73. <th data-options="field:'solution',title:'解决方式',align:'center',sortable:false"></th>
  74. <th data-options="field:'solutioneffect',title:'解决效果',align:'center',sortable:false"></th>
  75. <th data-options="field:'showannex',title:'项目相关资料',align:'center',sortable:false"></th>
  76. <th data-options="field:'createtime',title:'创建时间',align:'center',sortable:false"></th>
  77. <th data-options="field:'username',title:'创建人',align:'center',sortable:false"></th>
  78. </tr>
  79. </thead>
  80. </table>
  81. </div>
  82. </div>
  83. </div>
  84. <script>
  85. var width = 1280;
  86. var height = 720;
  87. /**加载前调用*/
  88. $(document).ready(function () {
  89. getcontent();
  90. getproductmodel();
  91. });
  92. /**导出*/
  93. const tbExport=() =>{
  94. /**中文标题映射 */
  95. const fieldMap = {
  96. 'name': '项目名称',
  97. 'modelname': '产品编码',
  98. 'participants': '参与人员',
  99. 'problem': '问题',
  100. 'solution': '解决方式',
  101. 'solutioneffect': '解决效果',
  102. 'showannex': '项目相关资料',
  103. 'createtime': '创建时间',
  104. 'username': '创建人'
  105. };
  106. //加载表头
  107. const fields = $('#myTable').datagrid('getColumnFields');
  108. const headers = [];
  109. for (var i = 0; i < fields.length; i++) {
  110. var chineseHeader = fieldMap[fields[i]] || fields[i];
  111. headers.push(chineseHeader);
  112. }
  113. $('#myTable').datagridExport({
  114. headers: headers,
  115. fileName: '导出数据(质量经验库).xls',
  116. workSheet: '导出数据(质量经验库)'
  117. //,dataType: 'text'
  118. });
  119. };
  120. /**添加 */
  121. const jump = () => {
  122. $('#myTable').datagridDialog({
  123. title: '编辑数据',
  124. //width: window.screen.width - 100,
  125. //height: window.screen.height - 200,
  126. width: width,
  127. height: height,
  128. url: 'Richtext.html'
  129. });
  130. };
  131. /**获取所有内容 */
  132. const getcontent = () => {
  133. $.get("/mes/pc/intelligence/Richtext.ashx?m=get", function (data) {
  134. /**填充表格*/
  135. toshow(data);
  136. })
  137. };
  138. /**刷新 */
  139. const restore = () => {
  140. /**重置data输入框*/
  141. $('#opentime, #closetime').datebox();
  142. /** 重置文本输入框的值*/
  143. document.getElementById('name').value = '';
  144. document.getElementById('people').value = '';
  145. /**重置下拉选择框的值(选择第一个选项,即默认选项)*/
  146. var selectElement = document.getElementById('modelSelect');
  147. selectElement.selectedIndex = 0;
  148. /** 使read恢复初始状态 */
  149. read = Object.assign({}, {
  150. opentime: '',
  151. closetime: '',
  152. name: '',
  153. people: '',
  154. modelid: ''
  155. });
  156. /**获取所有内容*/
  157. getcontent();
  158. }
  159. /**填充表格*/
  160. const toshow = (data) => {
  161. //将数据转换成json
  162. var json = JSON.parse(data);
  163. //遍历数据
  164. json.forEach(ex => {
  165. //获取问题的文本内容(网页换成文本)
  166. ex.problem = extractTextFromHTML(ex.problem);
  167. //表格展示文件名称
  168. ex.showannex = ex.annex.substr(ex.annex.lastIndexOf('/') + 1);
  169. //文件下载路径
  170. ex.annex = ex.annex;
  171. })
  172. //填充表格
  173. $('#myTable').datagrid({
  174. data: json,
  175. //配置项,显示选中行数据
  176. onSelect: function (rowIndex, rowData) {
  177. // 获取当前datagrid对象
  178. var dg = $(this);
  179. // 获取所有行的索引
  180. var rows = dg.datagrid('getRows');
  181. var rowIndices = $.map(rows, function (row, index) {
  182. return index;
  183. });
  184. // 遍历所有行,取消选中状态(如果有的话)
  185. $.each(rowIndices, function (i, index) {
  186. // 取消选中所有行(除了当前点击的行)
  187. if (index !== rowIndex) {
  188. dg.datagrid('unselectRow', index);
  189. }
  190. });
  191. }
  192. });
  193. }
  194. /** 将问题过滤成文本内容*/
  195. const extractTextFromHTML = (htmlString) => {
  196. const parser = new DOMParser();
  197. const doc = parser.parseFromString(htmlString, 'text/html');
  198. // 使用 textContent 直接获取所有文本
  199. const textContent = doc.body.textContent || '';
  200. return textContent.trim();
  201. };
  202. /**下载附件 */
  203. const downfile = () => {
  204. var selectedRow = $('#myTable').datagrid('getSelected');
  205. if (selectedRow) {
  206. var a = document.createElement("a");
  207. a.href = selectedRow.annex;
  208. a.download = selectedRow.annex.substr(selectedRow.annex.lastIndexOf('/') + 1);
  209. document.body.appendChild(a);
  210. a.click();
  211. document.body.removeChild(a);
  212. }
  213. };
  214. /**修改 */
  215. const tbReportEdit=()=> {
  216. var selectedRow = $('#myTable').datagrid('getSelected');
  217. $('#myTable').datagridDialog({
  218. title: '编辑数据',
  219. //width: window.screen.width - 100,
  220. //height: window.screen.height - 200,
  221. width: width,
  222. height: height,
  223. url: 'Richtext.html?id=' + selectedRow.id
  224. });
  225. }
  226. /**查看 */
  227. const showReport = () => {
  228. var selectedRow = $('#myTable').datagrid('getSelected');
  229. $('#myTable').datagridDialog({
  230. title: '预览数据',
  231. width: width,
  232. height: height,
  233. url: 'Richtext.html?id=' + selectedRow.id+'&show=true'
  234. });
  235. }
  236. // 响应式数据:产品型号列表
  237. let models = [];
  238. /** 获取产品型号 */
  239. const getproductmodel = () => {
  240. $.get("Richtext.ashx?m=getproductmodel", function (data) {
  241. var json = JSON.parse(data);
  242. models = json;
  243. loadModelsToSelect();
  244. })
  245. };
  246. /** 加载型号到 select 元素中 */
  247. const loadModelsToSelect = () => {
  248. const select = document.getElementById('modelSelect');
  249. // 遍历模型数组并添加选项
  250. models.forEach(model => {
  251. const option = document.createElement('option');
  252. option.value = model.ID;
  253. option.textContent = model.GOODSCODE;
  254. select.appendChild(option);
  255. });
  256. // 监听选择变化
  257. select.addEventListener('change', function () {
  258. read.modelid = this.value;
  259. });
  260. };
  261. /**搜索*/
  262. const select = () => {
  263. $.ajax({
  264. url: "intelligence.ashx?m=getcontent",
  265. type: "POST",
  266. data: read,
  267. //要传递json时
  268. // contentType: "application/json; charset=utf-8",
  269. // data: JSON.stringify(formData),
  270. success: function (data) {
  271. toshow(data);
  272. },
  273. error: function (xhr, status, error) {
  274. console.error("请求失败: " + error);
  275. }
  276. });
  277. }
  278. /**搜索对象 */
  279. let read = {
  280. /**开始时间*/
  281. opentime:'',
  282. /**结束时间*/
  283. closetime:'',
  284. /**项目名称*/
  285. name:'',
  286. /** 参与人员*/
  287. people:'',
  288. /**产品型号*/
  289. modelid:''
  290. }
  291. // 监听普通文本框的变化
  292. $('#name, #people').on('input', function () {
  293. const key = this.id;
  294. read[key] = $(this).val();
  295. });
  296. // 监听easyui-datebox的变化
  297. $('#opentime, #closetime').datebox({
  298. onChange: function (newValue, oldValue) {
  299. const key = this.id;
  300. read[key] = newValue; // 或者根据需要转换为字符串
  301. }
  302. });
  303. // 监听easyui-combobox的变化
  304. $('#modelid').combobox({
  305. onChange: function (newValue, oldValue) {
  306. read.modelid = newValue;
  307. }
  308. });
  309. </script>
  310. </body>
  311. </html >