intelligence.html 13 KB

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