| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <meta name="keywords" content="dongke,mes,ibossmes">
- <meta name="description" content="制造企业生产过程执行管理系统">
- <meta name="author" content="xuwei">
- <title>东科软件</title>
- <link rel="shortcut icon" href="/img/logo.png" />
- <link rel="bookmark" href="/img/logo.png" />
- <link rel="stylesheet" type="text/css" href="/plugins/easyui/themes/dongke/easyui.css">
- <link rel="stylesheet" type="text/css" href="/plugins/easyui/themes/icon.css">
- <link rel="stylesheet" type="text/css" href="/plugins/xeasyui/xuwell.css">
- <script type="text/javascript" src="/plugins/easyui/jquery.min.js"></script>
- <script type="text/javascript" src="/plugins/easyui/jquery.easyui.min.js"></script>
- <script type="text/javascript" src="/plugins/easyui/locale/easyui-lang-zh_CN.js"></script>
- <script type="text/javascript" src="/plugins/xeasyui/xuwell.js"></script>
- <link href="/plugins/xeasyui/toolbar.min.css" rel="stylesheet" />
- <style>
- .inp {
- width: 120px;
- height: 28px;
- border: 0;
- }
- .combobox {
- color: #fff;
- background-color: #444;
- }
- </style>
- </head>
- <body class="easyui-layout">
- <div id="toolbarLayout" data-options="border:false,region:'north',title:'',iconCls:'icon-grid'">
- <!--工具条-->
- <div id="tb" class="i-toolbar">
- <a class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="jump()">添加</a>
- <a class="easyui-linkbutton" iconcls="icon-edit" plain="true" onclick="tbReportEdit()">修改</a>
- <a class="easyui-linkbutton" iconcls="icon-excel" plain="true" onclick="tbExport()">导出</a>
- <a class="easyui-linkbutton" iconcls="icon-reload" plain="true" onclick="restore()">刷新</a>
- <a class="easyui-linkbutton" iconcls="icon-print" plain="true" onclick="downfile()">下载附件</a>
- <div id="tbSearchDiv" style="display: block; padding: 10px;">
- <div>
- 时间:
- <input id="opentime" type="text" class="easyui-datebox" style="width:165px; height:32px;">
- -
- <input id="closetime" type="text" class="easyui-datebox" style="width:165px; height:32px;">
- </div>
- <div style="padding-top:10px;">
- 项目名称:
- <input id="name" class="inp">
- 参与人员:
- <input id="people" class="inp" placeholder="多人请用/进行连接">
- <select id="modelSelect" class="combobox inp">
- <option selected value="">请选择型号</option>
- </select>
- <a class="easyui-linkbutton" onclick="select()">搜索</a>
- </div>
- </div>
- </div>
- </div>
- <div id="tableLayout" data-options="singleSelect:true,border:false,region:'center',split:true,title:'',iconCls:'icon-grid'" title="East" style="width:700px;">
- <div id="tableTabs" class="easyui-tabs" data-options="singleSelect:true,border:false" style="width: 100%; height: 100%">
- <div title="质量经验库">
- <table id="myTable" class="easyui-datagrid" data-options="method:'get',border:false,fit:true,fitColumns:true">
- <thead>
- <tr>
- <th data-options="field:'id',title:'id',align:'center',sortable:false,hidden:true"></th>
- <th data-options="field:'name',title:'项目名称',align:'center',sortable:false"></th>
- <th data-options="field:'modelid',title:'产品ID',align:'center',sortable:false,hidden:true"></th>
- <th data-options="field:'modelname',title:'产品编码',align:'center',sortable:false"></th>
- <th data-options="field:'participants',title:'参与人员',align:'center',sortable:false"></th>
- <th data-options="field:'problem',title:'问题',align:'center',sortable:false"></th>
- <th data-options="field:'solution',title:'解决方式',align:'center',sortable:false"></th>
- <th data-options="field:'solutioneffect',title:'解决效果',align:'center',sortable:false"></th>
- <th data-options="field:'showannex',title:'项目相关资料',align:'center',sortable:false"></th>
- <th data-options="field:'createtime',title:'创建时间',align:'center',sortable:false"></th>
- <th data-options="field:'username',title:'创建人',align:'center',sortable:false"></th>
- </tr>
- </thead>
- </table>
- </div>
- </div>
- </div>
- <script>
- /**加载前调用*/
- $(document).ready(function () {
- getcontent();
- getproductmodel();
- });
- /**导出*/
- const tbExport=() =>{
- /**中文标题映射 */
- const fieldMap = {
- 'name': '项目名称',
- 'modelname': '产品编码',
- 'participants': '参与人员',
- 'problem': '问题',
- 'solution': '解决方式',
- 'solutioneffect': '解决效果',
- 'showannex': '项目相关资料',
- 'createtime': '创建时间',
- 'username': '创建人'
- };
- //加载表头
- const fields = $('#myTable').datagrid('getColumnFields');
- const headers = [];
- for (var i = 0; i < fields.length; i++) {
- var chineseHeader = fieldMap[fields[i]] || fields[i];
- headers.push(chineseHeader);
- }
- $('#myTable').datagridExport({
- headers: headers,
- fileName: '导出数据(质量经验库).xls',
- workSheet: '导出数据(质量经验库)'
- //,dataType: 'text'
- });
- };
- /**添加 */
- const jump = () => {
- parent.window.location.href = 'Richtext.html';
- };
- /**获取所有内容 */
- const getcontent = () => {
- $.get("/mes/pc/intelligence/Richtext.ashx?m=get", function (data) {
- /**填充表格*/
- toshow(data);
- })
- };
- /**刷新 */
- const restore = () => {
- /**重置data输入框*/
- $('#opentime, #closetime').datebox();
- /** 重置文本输入框的值*/
- document.getElementById('name').value = '';
- document.getElementById('people').value = '';
- /**重置下拉选择框的值(选择第一个选项,即默认选项)*/
- var selectElement = document.getElementById('modelSelect');
- selectElement.selectedIndex = 0;
- /** 使read恢复初始状态 */
- read = Object.assign({}, {
- opentime: '',
- closetime: '',
- name: '',
- people: '',
- modelid: ''
- });
- /**获取所有内容*/
- getcontent();
- }
- /**填充表格*/
- const toshow = (data) => {
- //将数据转换成json
- var json = JSON.parse(data);
- //遍历数据
- json.forEach(ex => {
- //获取问题的文本内容(网页换成文本)
- ex.problem = extractTextFromHTML(ex.problem);
- //表格展示文件名称
- ex.showannex = ex.annex.substr(ex.annex.lastIndexOf('/') + 1);
- //文件下载路径
- ex.annex = ex.annex;
- })
- //填充表格
- $('#myTable').datagrid({
- data: json,
- //配置项,显示选中行数据
- onSelect: function (rowIndex, rowData) {
- }
- });
- }
- /** 将问题过滤成文本内容*/
- const extractTextFromHTML = (htmlString) => {
- const parser = new DOMParser();
- const doc = parser.parseFromString(htmlString, 'text/html');
- // 使用 textContent 直接获取所有文本
- const textContent = doc.body.textContent || '';
- return textContent.trim();
- };
- /**下载附件 */
- const downfile = () => {
- var selectedRow = $('#myTable').datagrid('getSelected');
- if (selectedRow) {
- var a = document.createElement("a");
- a.href = selectedRow.annex;
- a.download = selectedRow.annex.substr(selectedRow.annex.lastIndexOf('/') + 1);
- document.body.appendChild(a);
- a.click();
- document.body.removeChild(a);
- }
- };
- /**修改 */
- const tbReportEdit = () => {
- var selectedRow = $('#myTable').datagrid('getSelected');
- if (selectedRow) {
- parent.window.location.href = 'Richtext.html?id=' + selectedRow.id;
- }
- };
- // 响应式数据:产品型号列表
- let models = [];
- /** 获取产品型号 */
- const getproductmodel = () => {
- $.get("Richtext.ashx?m=getproductmodel", function (data) {
- var json = JSON.parse(data);
- models = json;
- loadModelsToSelect();
- })
- };
- /** 加载型号到 select 元素中 */
- const loadModelsToSelect = () => {
- const select = document.getElementById('modelSelect');
- // 遍历模型数组并添加选项
- models.forEach(model => {
- const option = document.createElement('option');
- option.value = model.ID;
- option.textContent = model.GOODSCODE;
- select.appendChild(option);
- });
- // 监听选择变化
- select.addEventListener('change', function () {
- read.modelid = this.value;
- });
- };
- /**搜索*/
- const select = () => {
- $.ajax({
- url: "intelligence.ashx?m=getcontent",
- type: "POST",
- data: read,
- //要传递json时
- // contentType: "application/json; charset=utf-8",
- // data: JSON.stringify(formData),
- success: function (data) {
- toshow(data);
- },
- error: function (xhr, status, error) {
- console.error("请求失败: " + error);
- }
- });
-
- }
- /**搜索对象 */
- let read = {
- /**开始时间*/
- opentime:'',
- /**结束时间*/
- closetime:'',
- /**项目名称*/
- name:'',
- /** 参与人员*/
- people:'',
- /**产品型号*/
- modelid:''
- }
- // 监听普通文本框的变化
- $('#name, #people').on('input', function () {
- const key = this.id;
- read[key] = $(this).val();
- });
- // 监听easyui-datebox的变化
- $('#opentime, #closetime').datebox({
- onChange: function (newValue, oldValue) {
- const key = this.id;
- read[key] = newValue; // 或者根据需要转换为字符串
- }
- });
- // 监听easyui-combobox的变化
- $('#modelid').combobox({
- onChange: function (newValue, oldValue) {
- read.modelid = newValue;
- }
- });
- </script>
- </body>
- </html >
|