Prechádzať zdrojové kódy

质量经验库按要求修改

李士越 1 rok pred
rodič
commit
6e469eccaf

+ 38 - 23
wwwroot/mes/pc/intelligence/Richtext.ashx

@@ -28,7 +28,7 @@ public class Richtext : IHttpHandler, IReadOnlySessionState
             context.Request.Files[0].SaveAs(diskFileName);
             Dictionary<string, object> result = new Dictionary<string, object>();
             result.Add("errno", 0);
-            result.Add("data", new Dictionary<string, string>() { {"url","http://172.18.32.32:9000/"+fileName }  });
+            result.Add("data", new Dictionary<string, string>() { {"url","http://172.18.32.31:9000/"+fileName }  });
             context.Response.Write(JsonConvert.SerializeObject(result, Formatting.Indented));
         }
         //获取产品型号
@@ -48,15 +48,20 @@ public class Richtext : IHttpHandler, IReadOnlySessionState
             var formData = context.Request.Form;
             using (IDataAccess conn = DataAccess.Create())
             {
-                if (formData["id"].ToString() != "")
+                try
                 {
-                    conn.ExecuteNonQuery(
-                      " UPDATE  TP_PM_QUALITYLIBRARY SET " +
-                      "VALUEFLAG=0 WHERE LIBRARYID=" + formData["id"].ToString());
-                }
-                //创建记录
-                DataTable dt = conn.ExecuteDatatable(@"SELECT SEQ_PM_QUALITYLIBRARY_ID.nextval  FROM dual");
-                int result = conn.ExecuteNonQuery(@"
+                    //开启事务
+                    conn.BeginTransaction();
+
+                    if (formData["id"].ToString() != "")
+                    {
+                        conn.ExecuteNonQuery(
+                          " UPDATE  TP_PM_QUALITYLIBRARY SET " +
+                          "VALUEFLAG=0 WHERE LIBRARYID=" + formData["id"].ToString());
+                    }
+                    //创建记录
+                    DataTable dt = conn.ExecuteDatatable(@"SELECT SEQ_PM_QUALITYLIBRARY_ID.nextval  FROM dual");
+                    int result = conn.ExecuteNonQuery(@"
                 INSERT INTO TP_PM_QUALITYLIBRARY (
                     LIBRARYID,--总单ID
                     LIBRARYNAME, --项目名称
@@ -81,21 +86,31 @@ public class Richtext : IHttpHandler, IReadOnlySessionState
                     @ACCOUNTID@,@CREATEUSERID@,@UPDATEUSERID@
                 )
                 ",
-               new CDAParameter("LIBRARYID", dt.Rows[0][0]),
-               new CDAParameter("LIBRARYNAME", formData["name"]),
-               new CDAParameter("GOODSID", formData["modelid"]),
-               new CDAParameter("GOODSCODE", formData["modelname"]),
-               new CDAParameter("PARTICIPANTS", formData["participants"]),
-               new CDAParameter("QUESTION", formData["problem"]),
-               new CDAParameter("SOLUTION", formData["solution"]),
-               new CDAParameter("SOLUTIONEFFECT", formData["solutioneffect"]),
-               new CDAParameter("ANNEX", formData["annex"]),
-               new CDAParameter("ACCOUNTID", HttpContext.Current.Session["accountId"]),
-               new CDAParameter("CREATEUSERID", HttpContext.Current.Session["userId"]),
-               new CDAParameter("UPDATEUSERID", HttpContext.Current.Session["userId"]));
-                context.Response.Write(JsonConvert.SerializeObject(result == 1 ? dt.Rows[0][0] : "false", Formatting.Indented));
+                   new CDAParameter("LIBRARYID", dt.Rows[0][0]),
+                   new CDAParameter("LIBRARYNAME", formData["name"]),
+                   new CDAParameter("GOODSID", formData["modelid"]),
+                   new CDAParameter("GOODSCODE", formData["modelname"]),
+                   new CDAParameter("PARTICIPANTS", formData["participants"]),
+                   new CDAParameter("QUESTION", formData["problem"]),
+                   new CDAParameter("SOLUTION", formData["solution"]),
+                   new CDAParameter("SOLUTIONEFFECT", formData["solutioneffect"]),
+                   new CDAParameter("ANNEX", formData["annex"]),
+                   new CDAParameter("ACCOUNTID", HttpContext.Current.Session["accountId"]),
+                   new CDAParameter("CREATEUSERID", HttpContext.Current.Session["userId"]),
+                   new CDAParameter("UPDATEUSERID", HttpContext.Current.Session["userId"]));
+                    //提交事务
+                    conn.Commit();
+                    context.Response.Write(JsonConvert.SerializeObject(result == 1 ? dt.Rows[0][0] : false, Formatting.Indented));
+                }
+                catch
+                {
+                    //回滚事务
+                    conn.Rollback();
+                    context.Response.Write(JsonConvert.SerializeObject(false, Formatting.Indented));
+                }
             }
 
+
         }
         //获取所有(单个记录)
         if (context.Request["m"].ToString() == "get")
@@ -112,7 +127,7 @@ public class Richtext : IHttpHandler, IReadOnlySessionState
                 }
                 sqlStr += "ORDER BY q.CREATETIME DESC";
                 DataTable dt = conn.ExecuteDatatable(sqlStr);
-                List<Dictionary<string, string>> result = new List<Dictionary<string, string>>(); 
+                List<Dictionary<string, string>> result = new List<Dictionary<string, string>>();
                 for (int i = 0; i < dt.Rows.Count; i++)
                 {
                     Dictionary<string, string> content = new Dictionary<string, string>();

+ 17 - 14
wwwroot/mes/pc/intelligence/Richtext.html

@@ -78,7 +78,7 @@
         }
 
         #editor-container {
-            height: 450px;
+            height: 100%; 
         } 
     </style>
 </head>
@@ -235,7 +235,7 @@
         });
         
         /** 添加/修改按钮  */
-        const add = () => { 
+        const add = async() => {
             if (addsb.name == '') {
                 alert('请填写产品名称');
                 return;
@@ -244,21 +244,20 @@
                 alert('请填写产品型号');
                 return;
             }
-            $.ajax({
+            const data= await $.ajax({
                 url: "Richtext.ashx?m=add",
                 type: "POST",
                 data: addsb,
-                //要传递json时
-                // contentType: "application/json; charset=utf-8",  
-                // data: JSON.stringify(formData),  
-                success: function (data) { 
-                    history.pushState(null, null, '?id=' + parseInt(data, 10)); 
-                    getQueryParam();
-                },
-                error: function (xhr, status, error) {
-                    console.error("请求失败: " + error);
-                } 
-            });
+                dataType: "json" 
+            }); 
+            if (data != false) {
+                await $.messager.alert("保存", "保存成功");
+                await history.pushState(null, null, '?id=' + parseInt(data, 10));
+                await getQueryParam();
+            }
+            else {
+                await $.messager.alert("保存", "保存失败");
+            }
         }
         /** 上传附件 */
         const submitForm = () => {
@@ -285,17 +284,21 @@
                             /**设置addsb.annex为响应中的url  */
                             addsb.annex = responseData.data.url;
                             messager(true);
+                            $.messager.alert("上传附件", "上传成功");
                         } else {
                             console.error('请求成功但发生错误', responseData.errno);
                             messager(false);
+                            $.messager.alert("上传附件", "上传失败");
                         }
                     } catch (e) {
                         console.error('解析JSON失败', e);
                         messager(false);
+                        $.messager.alert("上传附件", "上传失败");
                     }
                 } else {
                     console.error('请求失败', xhr.status);
                     messager(false);
+                    $.messager.alert("上传附件", "上传失败");
                 }
             }
         };

+ 51 - 26
wwwroot/mes/pc/intelligence/intelligence.html

@@ -33,7 +33,7 @@
         <!--工具条-->
         <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-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>
@@ -42,21 +42,24 @@
                     时间:
                     <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;">
+                    <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> 
+                    <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>
+        <table id="fqcitemsDatagrid" data-options="toolbar: '#fqcitemsToolbar',onDblClickRow: fqcitemsDatagridDblClickRow,showFooter:false">
+        
+        </table>
     </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%">
@@ -64,17 +67,17 @@
                 <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>
+                            <th data-options="field:'id',title:'id',align:'center',sortable:true,checkbox:true,hidden:true"></th>
+                            <th data-options="field:'name',title:'项目名称',align:'center',sortable:true"></th>
+                            <th data-options="field:'modelid',title:'产品ID',align:'center',sortable:true,hidden:true"></th>
+                            <th data-options="field:'modelname',title:'产品编码',align:'center',sortable:true"></th>
+                            <th data-options="field:'participants',title:'参与人员',align:'center',sortable:true"></th>
+                            <th data-options="field:'problem',title:'问题',align:'center',sortable:true"></th>
+                            <th data-options="field:'solution',title:'解决方式',align:'center',sortable:true"></th>
+                            <th data-options="field:'solutioneffect',title:'解决效果',align:'center',sortable:true"></th> 
+                            <th data-options="field:'showannex',title:'项目相关资料',align:'center',sortable:true"></th>
+                            <th data-options="field:'createtime',title:'创建时间',align:'center',sortable:true"></th>
+                            <th data-options="field:'username',title:'创建人',align:'center',sortable:true"></th>
                         </tr>
                     </thead> 
                 </table>
@@ -116,8 +119,13 @@
             });
         };
         /**添加 */
-        const jump = () => {
-            parent.window.location.href = 'Richtext.html';
+        const jump = () => { 
+            $('#myTable').datagridDialog({
+                title: '编辑数据',
+                width: window.screen.width - 100,
+                height: window.screen.height - 200,
+                url: 'Richtext.html'
+            });
         };
         /**获取所有内容 */
         const getcontent = () => {
@@ -162,9 +170,23 @@
             })
             //填充表格
             $('#myTable').datagrid({
-                data: json,
+                data: json, 
                 //配置项,显示选中行数据
-                onSelect: function (rowIndex, rowData) { 
+                onSelect: function (rowIndex, rowData) {
+                    // 获取当前datagrid对象  
+                    var dg = $(this); 
+                    // 获取所有行的索引  
+                    var rows = dg.datagrid('getRows');
+                    var rowIndices = $.map(rows, function (row, index) {
+                        return index;
+                    }); 
+                    // 遍历所有行,取消选中状态(如果有的话)  
+                    $.each(rowIndices, function (i, index) {
+                        // 取消选中所有行(除了当前点击的行)  
+                        if (index !== rowIndex) {
+                            dg.datagrid('unselectRow', index);
+                        }
+                    });
                 }
             });
         }
@@ -189,12 +211,15 @@
             }
         };
         /**修改 */
-        const tbReportEdit = () => {
+        const tbReportEdit=()=> {
             var selectedRow = $('#myTable').datagrid('getSelected');
-            if (selectedRow) {
-                parent.window.location.href = 'Richtext.html?id=' + selectedRow.id;
-            }
-        };
+            $('#myTable').datagridDialog({
+                title: '编辑数据',
+                width: window.screen.width - 100,
+                height: window.screen.height - 200,
+                url: 'Richtext.html?id=' + selectedRow.id
+            });
+        }
         // 响应式数据:产品型号列表
         let models = [];
         /** 获取产品型号 */