diff --git a/Temp/UserNoPostionTemp.aspx b/Temp/UserNoPostionTemp.aspx new file mode 100644 index 0000000..89bcd60 --- /dev/null +++ b/Temp/UserNoPostionTemp.aspx @@ -0,0 +1,388 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UserNoPostionTemp.aspx.cs" Inherits="Temp_UserNoPostionTemp" %> + + + + + + + 导入外部答题卡制作模板 + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ <% if (PageIndex == "1") { %> +
第一页
+ <% } + else + { %> +
第一页
+ <% } %> + + + <% if (PageCount >1) { %> + + <% if (PageIndex == "2") { %> +
第二页
+ <% } + else + { %> +
第二页
+ <% } %> + + + <% } %> + + + + + + + + +
+ +
+
+ + +
+
+ +
+
折叠
+ + + + + + + + + + diff --git a/Temp/UserNoPostionTemp.aspx.cs b/Temp/UserNoPostionTemp.aspx.cs new file mode 100644 index 0000000..67018bf --- /dev/null +++ b/Temp/UserNoPostionTemp.aspx.cs @@ -0,0 +1,1079 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Data.SqlClient; +using System.Data; +using Lucee.WebBase.Utils; +using Lucee.WebBase.Data; +using System.Drawing; +using Emgu.CV; +using Emgu.CV.Util; +using Emgu.CV.Structure; +using System.Drawing.Drawing2D; +using System.Net; +using Newtonsoft; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json; +using System.Web.Script.Serialization; +using MySql.Data.MySqlClient; +using Emgu.CV.Flann; +using System.Data.SqlTypes; +using System.Security.AccessControl; +using System.Security.Cryptography; + +public partial class Temp_UserNoPostionTemp : System.Web.UI.Page +{ + public long TempID = 0; + public long AnotherTempID = 0; + public string PageIndex = "0"; + public string Bindlist = ""; + public string imgage = ""; + public string ExamNO = ""; + public string isLocked = ""; + public string HideAreaText = ""; + public string IsPostionValue = ""; + public long tenant = 0; + public string pager = ""; + public int isHand = 0; + public string MainTempId = "0"; + public int PageCount = 0; + public string UserID = ""; + public string Rotate = ""; + public string BatchID = ""; + public string GroupNo = ""; + + protected void Page_Load(object sender, EventArgs e) + { + + int action = Globals.Request("action") == "" ? 0 : Convert.ToInt32(Globals.Request("action")); + tenant = Globals.Request("tenant") == "" ? 0 : Convert.ToInt64(Globals.Request("tenant")); + isHand = Globals.Request("isHand") == "" ? 0 : Convert.ToInt32(Globals.Request("isHand")); + BatchID = Globals.Request("BatchID"); + pager = Globals.Request("pager").ToLower(); + GroupNo = Globals.Request("GroupNo"); + + if (action != 0) + { + Response.Clear(); + switch (action) + { + case 1: + UpdateTempData(); + break; + case 2: + LockTemp(); + break; + } + Response.End(); + } + else + { + TempID = Globals.Request("TempID") == "" ? 0 : Convert.ToInt32(Globals.Request("TempID"));//获取小模板ID + //if (TempID == 0) + //{ + // Response.Write(""); + // return; + //} + + + UserID = Globals.Decrypt(Globals.Request("UserID")); + if (string.IsNullOrEmpty(UserID)) + { + Response.Write(""); + return; + } + string sql = ""; + + + sql = "select * from MK_TempleteDataUser where DetaID_bigint=" + TempID + " AND UserID_bigint=" + UserID; + + if (!string.IsNullOrEmpty(GroupNo)) + { + sql = "select * from MK_TempleteDataUserOnePaper where DetaID_bigint=" + TempID + " AND UserID_bigint=" + UserID + " AND GroupNo_varchar='" + GroupNo + "'"; + + } + //if (!string.IsNullOrEmpty(BatchID)) + //{ + // sql = "select * from MK_TempleteDataUserBatch where DetaID_bigint=" + TempID + " AND UserID_bigint=" + UserID + " AND BatchID_nvarchar='" + BatchID + "'"; + //} + + + + // string sql = "select * from MK_TempleteData where ID_bigint=" + TempID; + + DataTable dtx = new MysqlDBHelper(tenant).ExecuteQuery(sql); + + + + if (dtx.Rows.Count > 0) + { + Bindlist = dtx.Rows[0]["TempValue_nvarchar"].ToString(); + imgage = dtx.Rows[0]["TempPicture64_nvarchar"].ToString(); + //isLocked = dtx.Rows[0]["islock_bit"] == null ? "" : dtx.Rows[0]["islock_bit"].ToString(); + + HideAreaText = dtx.Rows[0]["HideAreaPostionList_nvarchar"] == null ? "" : dtx.Rows[0]["HideAreaPostionList_nvarchar"].ToString(); + //IsPostionValue = dtx.Rows[0]["HideAreaPostionList_nvarchar"] == null ? "" : dtx.Rows[0]["HideAreaPostionList_nvarchar"].ToString(); + Rotate = dtx.Rows[0]["Rotate_float"].ToString(); + PageIndex = dtx.Rows[0]["PageIndex_int"] == null ? "" : dtx.Rows[0]["PageIndex_int"].ToString(); + MainTempId = dtx.Rows[0]["MainID_bigint"].ToString(); + + sql = "select MainPage_int,HasPosition from MK_TempleteMain where ID_bigint=" + MainTempId; + var maindt = new MysqlDBHelper(tenant).ExecuteQuery(sql); + if (maindt == null || maindt.Rows.Count <= 0) + { + Response.Write(""); + return; + } + PageCount = Convert.ToInt32(maindt.Rows[0]["MainPage_int"]); + IsPostionValue = maindt.Rows[0]["HasPosition"].ToString(); + + if (PageCount > 1) + { + sql = "select ID_bigint from MK_TempleteData where MainID_bigint=" + MainTempId + " and ID_bigint!=" + TempID; + AnotherTempID = Convert.ToInt32(new MysqlDBHelper(tenant).ExecuteScalar(sql)); + } + } + } + + } + + private void UpdateTempData() + { + TempID = Globals.Request("TempID") == "" ? 0 : Convert.ToInt32(Globals.Request("TempID"));//获取小模板ID + string totalHtml = Server.UrlDecode(Globals.Request("totalHtml")); + string HideAreaPostionList = Server.UrlDecode(Globals.Request("HideAreaPostionList")); + string UserID = Globals.Request("UserID"); + double roteX = Convert.ToDouble(Globals.Request("roteX")); + string BatchID = Globals.Request("BatchID"); + string GroupNo = Globals.Request("GroupNo"); + if (AnsyTemp(HideAreaPostionList, totalHtml, UserID)) + { + //string sql = "Update MK_TempleteData SET TempValue_nvarchar=@TempValue_nvarchar,HideAreaPostionList_nvarchar=@HideAreaPostionList_nvarchar where ID_bigint=" + TempID; + //MySqlParameter[] sp = new MySqlParameter[] { + // new MySqlParameter("@TempValue_nvarchar",totalHtml), + // new MySqlParameter("@HideAreaPostionList_nvarchar",HideAreaPostionList) + //}; + //string[] totalHtmlList = totalHtml.Split('$'); + //new MysqlDBHelper(tenant).ExecuteNoQuery(sql, sp); + string sql = ""; + MySqlParameter[] sp; + if (BatchID != "") + { + sql = "Update MK_TempleteDataUserBatch SET Rotate_float=@Rotate_float, TempValue_nvarchar=@TempValue_nvarchar,HideAreaPostionList_nvarchar=@HideAreaPostionList_nvarchar,islocked_int=1 where DetaID_bigint=" + TempID + " AND UserID_bigint=" + Convert.ToInt64(UserID) + " AND BatchID_nvarchar='" + BatchID + "'"; + sp = new MySqlParameter[] { + new MySqlParameter("@TempValue_nvarchar",totalHtml), + new MySqlParameter("@HideAreaPostionList_nvarchar",HideAreaPostionList), + new MySqlParameter("@Rotate_float",roteX) + }; + } + else if (GroupNo != "") + { + + sql = "Update MK_TempleteDataUserOnePaper SET Rotate_float=@Rotate_float, TempValue_nvarchar=@TempValue_nvarchar,HideAreaPostionList_nvarchar=@HideAreaPostionList_nvarchar,islocked_int=1 where DetaID_bigint=" + TempID + " AND UserID_bigint=" + Convert.ToInt64(UserID) + " AND GroupNo_varchar='" + GroupNo + "'"; + sp = new MySqlParameter[] { + new MySqlParameter("@TempValue_nvarchar",totalHtml), + new MySqlParameter("@HideAreaPostionList_nvarchar",HideAreaPostionList), + new MySqlParameter("@Rotate_float",roteX) + }; + } + else + { + sql = "Update MK_TempleteDataUser SET Rotate_float=@Rotate_float, TempValue_nvarchar=@TempValue_nvarchar,HideAreaPostionList_nvarchar=@HideAreaPostionList_nvarchar,islocked_int=1 where DetaID_bigint=" + TempID + " AND UserID_bigint=" + Convert.ToInt64(UserID); + sp = new MySqlParameter[] { + new MySqlParameter("@TempValue_nvarchar",totalHtml), + new MySqlParameter("@HideAreaPostionList_nvarchar",HideAreaPostionList), + new MySqlParameter("@Rotate_float",roteX) + }; + } + + + + + if (new MysqlDBHelper(tenant).ExecuteNoQuery(sql, sp) == 1) + { + Response.Write("ok"); + } + else + { + Response.Write("erro"); + } + } + + + + + //if (new MysqlDBHelper(tenant).ExecuteNoQuery(sql, sp) == 1) + //{ + // if (totalHtmlList[0] == "") + // { + // Response.Write("ok"); + // } + // else + // { + // AnsyTemp(HideAreaPostionList); + // } + //} + //else { + // Response.Write("0"); + //} + + } + + private void LockTemp() + { + TempID = Globals.Request("TempID") == "" ? 0 : Convert.ToInt32(Globals.Request("TempID"));//获取小模板ID + string totalHtml = Server.UrlDecode(Globals.Request("totalHtml")); + string HideAreaPostionList = Server.UrlDecode(Globals.Request("HideAreaPostionList")); + string[] totalHtmlList = totalHtml.Split('$'); + string userID = Globals.Request("userID"); + if (AnsyTemp(HideAreaPostionList, totalHtml, userID)) + { + string sql = "Update MK_TempleteData SET TempValue_nvarchar=@TempValue_nvarchar,HideAreaPostionList_nvarchar=@HideAreaPostionList_nvarchar,islock_bit=1 where ID_bigint=" + TempID; + MySqlParameter[] sp = new MySqlParameter[] { + new MySqlParameter("@TempValue_nvarchar",totalHtml), + new MySqlParameter("@HideAreaPostionList_nvarchar",HideAreaPostionList) + }; + AddQuestionData(totalHtml); + new MysqlDBHelper(tenant).ExecuteNoQuery(sql, sp); + } + //if (new MysqlDBHelper(tenant).ExecuteNoQuery(sql, sp) == 1) + //{ + // if (totalHtmlList[0] == "") + // { + // Response.Write("ok"); + // } + // else { + // AnsyTemp(HideAreaPostionList); + // } + //} + //else + //{ + // Response.Write("0"); + //} + } + + private void AddQuestionData(string totalHtml) + { + TempID = Convert.ToInt64(Globals.Request("TempID")); + string[] totalHtmlList = totalHtml.Split('$'); + string kg = totalHtmlList[2]; + string zg = totalHtmlList[3]; + + string[] questionlist = kg.Trim('^').Split('^'); + string[] zglist = zg.Trim('^').Split('^'); + string sql = ""; + if (kg != "") + { + for (int i = 0; i < questionlist.Length; i++) + { + string[] detailtList = questionlist[i].Split(','); + string starNum = detailtList[4].ToUpper(); + string endNum = detailtList[5].ToUpper(); + + string score = detailtList[9]; + if (score == "") + { + score = "0"; + } + string selectNum = detailtList[6]; + string isselectmore = detailtList[8]; + + + + string bigNum = ""; + if (starNum.Contains("M")) + { + bigNum = starNum.Split('M')[0]; + int startSmallNum = Convert.ToInt32(starNum.Split('M')[1]); + int endSmallNum = Convert.ToInt32(endNum.Split('M')[1]); + for (int j = Convert.ToInt32(startSmallNum); j <= Convert.ToInt32(endSmallNum); j++) + { + sql = "SELECT COUNT(1) FROM MK_TempQuestionData WHERE TempID_bigint=" + TempID + " AND QuestionIndex_int='" + (bigNum + "." + j) + "'"; + if (new MysqlDBHelper(tenant).ExecuteScalar(sql).ToString() == "0") + { + sql = "INSERT INTO MK_TempQuestionData(TempID_bigint,QuestionIndex_int,SmallQuestionDetail_nvarchar,Score_float,createdtime_datetime,smallQuestionNum_int,questiontype_int,selectNum_int,selecttype_int) VALUES(@TempID_bigint,@QuestionIndex_int,@SmallQuestionDetail_nvarchar,@Score_float,'" + DateTime.Now + "',@smallQuestionNum_int,0,@selectNum_int,@selecttype_int)"; + MySqlParameter[] sp = new MySqlParameter[] { + new MySqlParameter("@TempID_bigint",TempID), + new MySqlParameter("@QuestionIndex_int",bigNum+"."+j), + new MySqlParameter("@SmallQuestionDetail_nvarchar",""), + new MySqlParameter("@smallQuestionNum_int","1"), + new MySqlParameter("@Score_float",score), + new MySqlParameter("@selectNum_int",selectNum), + new MySqlParameter("@selecttype_int",isselectmore), + + }; + new MysqlDBHelper(tenant).ExecuteNoQuery(sql, sp); + } + } + + } + else + { + for (int j = Convert.ToInt32(starNum); j <= Convert.ToInt32(endNum); j++) + { + sql = "SELECT COUNT(1) FROM MK_TempQuestionData WHERE TempID_bigint=" + TempID + " AND QuestionIndex_int='" + j + "'"; + if (new MysqlDBHelper(tenant).ExecuteScalar(sql).ToString() == "0") + { + sql = "INSERT INTO MK_TempQuestionData(TempID_bigint,QuestionIndex_int,SmallQuestionDetail_nvarchar,Score_float,createdtime_datetime,smallQuestionNum_int,questiontype_int,selectNum_int,selecttype_int) VALUES(@TempID_bigint,@QuestionIndex_int,@SmallQuestionDetail_nvarchar,@Score_float,'" + DateTime.Now + "',@smallQuestionNum_int,0,@selectNum_int,@selecttype_int)"; + MySqlParameter[] sp = new MySqlParameter[] { + new MySqlParameter("@TempID_bigint",TempID), + new MySqlParameter("@QuestionIndex_int",j), + new MySqlParameter("@SmallQuestionDetail_nvarchar",""), + new MySqlParameter("@smallQuestionNum_int","1"), + new MySqlParameter("@Score_float",score), + new MySqlParameter("@isSelectMore_bit",isselectmore), + new MySqlParameter("@selectNum_int",selectNum), + new MySqlParameter("@selecttype_int",isselectmore), + + }; + new MysqlDBHelper(tenant).ExecuteNoQuery(sql, sp); + } + } + } + } + } + if (zg != "") + { + for (int i = 0; i < zglist.Length; i++) + { + string[] detailtList = zglist[i].Split(','); + bool issplit = false; + if (detailtList[4].Contains("X")) + { + issplit = true; + detailtList[4] = detailtList[4].Split('X')[0]; + } + + //sql = "SELECT COUNT(1) FROM MK_TempQuestionData WHERE TempID_bigint=" + TempID + " AND QuestionIndex_int='" + detailtList[4] + "'"; + sql = String.Format("SELECT COUNT(1) FROM MK_TempQuestionData where TempID_bigint in(select ID_bigint from MK_TempleteData where MainID_bigint =(SELECT MainID_bigint FROM " + + "`MK_TempleteData` where ID_bigint={0})) AND QuestionIndex_int='{1}';", TempID, detailtList[4]); + + + string mkscoretype = ""; + if (string.IsNullOrEmpty(detailtList[7])) + { + mkscoretype = "1"; + } + else + { + mkscoretype = detailtList[7]; + } + + + if (new MysqlDBHelper(tenant).ExecuteScalar(sql).ToString() == "0") + { + sql = "INSERT INTO MK_TempQuestionData(TempID_bigint,QuestionIndex_int,SmallQuestionDetail_nvarchar,Score_float,createdtime_datetime,smallQuestionNum_int,questiontype_int,mkscoretype_float,is_split) VALUES(@TempID_bigint,@QuestionIndex_int,@SmallQuestionDetail_nvarchar,@Score_float,'" + DateTime.Now + "',@smallQuestionNum_int,1,@mkscoretype_float,@is_split)"; + MySqlParameter[] sp = new MySqlParameter[] { + new MySqlParameter("@TempID_bigint",TempID), + new MySqlParameter("@QuestionIndex_int",detailtList[4]), + new MySqlParameter("@SmallQuestionDetail_nvarchar",""), + new MySqlParameter("@Score_float",detailtList[6]==""? "0" : detailtList[6]), + new MySqlParameter("@smallQuestionNum_int",detailtList[5]), + new MySqlParameter("@mkscoretype_float",mkscoretype), + new MySqlParameter("@is_split",issplit) + }; + new MysqlDBHelper(tenant).ExecuteNoQuery(sql, sp); + } + } + } + } + + /// + /// 锁定模板数据 + /// + public bool AnsyTemp(string HideAreaPostionList, string totalHtml, string UserID) + { + try + { + CommonUse commonUse = new CommonUse(); + long TempID = Convert.ToInt64(Globals.Request("TempID")); + string sql = "select * from MK_TempleteDataUser where DetaID_bigint=" + TempID + " AND UserID_bigint=" + UserID; + DataTable dt = new MysqlDBHelper(tenant).ExecuteQuery(sql); + if (dt.Rows.Count <= 0) + { + Response.Write("NO DATA"); + return false; + } + Bitmap PictureBoxBitMap = ImgGet(dt.Rows[0]["TempPicture64_nvarchar"].ToString()); + + //var PictureBoxBitMap = commonUse.RotateByOrientation(tempPictureBoxBitMap); + if (PictureBoxBitMap == null) + { + Response.Write("NO PICTURE"); + } + string[] GetData = totalHtml.Split('$'); + string PYPostionList = ""; + + + + + int width = Convert.ToInt32(GetData[6].Split(',')[0]); + int height = Convert.ToInt32(GetData[6].Split(',')[1]); + PictureBoxBitMap = ScaleToSize(PictureBoxBitMap, width, height); + Image imagex = new Image(PictureBoxBitMap); + Mat mat_threshold1 = new Mat(); + CvInvoke.Threshold(imagex, mat_threshold1, 160, 255, Emgu.CV.CvEnum.ThresholdType.BinaryInv); + Mat mat_dilate1 = commonUse.MyDilate(mat_threshold1); + VectorOfVectorOfPoint selected_contours1; + selected_contours1 = commonUse.GetUsefulContoursDingWei(mat_dilate1, 1); + Image currentFramext = new Image(PictureBoxBitMap); + + int PageIndex = Convert.ToInt32(Globals.Request("PageIndex")); + //if (PageIndex == 1) + //{ + // int mx = GetOtherBitmaplist(currentFramext.Mat, 160, PYPostionList.Split(','), GetData[9]); + // long MainTempId = Convert.ToInt64(Globals.Request("MainTempId")); + // if (mx == 0) + // { + // Response.Write("标准点数据错误,请重新框选"); + // return false; + // } + + //} + //计算模板图片参数 + //double xielv = 0; + //width = Convert.ToInt32(GetData[6].Split(',')[0]); + //height = Convert.ToInt32(GetData[6].Split(',')[1]); + //sql = "UPDATE MK_TempleteData SET XieLv_float =@XieLv_float,CutWidth_int=@CutWidth_int,CutHeight_int=@CutHeight_int,PyPPostion_nvarchar=@PyPPostion_nvarchar WHERE ID_bigint=" + TempID; + //MySqlParameter[] sp = new MySqlParameter[] { + // new MySqlParameter("@XieLv_float",xielv), + // new MySqlParameter("@CutWidth_int",width), + // new MySqlParameter("@CutHeight_int",height), + // new MySqlParameter("@PyPPostion_nvarchar",PYPostionList) + // }; + //if (new MysqlDBHelper(tenant).ExecuteNoQuery(sql, sp) > 0) + //{ + + //} + //PictureBoxBitMap.Dispose(); + return true; + + } + catch (Exception ex) + { + return false; + Response.Write("TEMPERRO"); + } + } + + /// + /// 获取其他截图 + /// + /// + /// + /// + /// + /// + /// + public static int GetOtherBitmaplist(Mat color_mat, int Threshold, string[] PYPostion, string postiontiaomaX) + { + CommonUse commonUse = new CommonUse(); + string[] quekao = postiontiaomaX.Split(','); + //int X = Convert.ToInt32(Convert.ToDouble(quekao[0])) - Convert.ToInt32(PYPostion[0]); + //int Y = Convert.ToInt32(Convert.ToDouble(quekao[1])) - Convert.ToInt32(PYPostion[1]); + int X = Convert.ToInt32(Convert.ToDouble(quekao[0])); + int Y = Convert.ToInt32(Convert.ToDouble(quekao[1])); + int W = Convert.ToInt32(Convert.ToDouble(quekao[2])); + int H = Convert.ToInt32(Convert.ToDouble(quekao[3])); + int xuanXiang = 1;//选项数量 + int tiliang = 1;//题量 + string mx = ""; + int wL = Convert.ToInt32(W / xuanXiang); + int hL = Convert.ToInt32(H / tiliang); + + Image bytimg = GetMatCutImg(color_mat.Bitmap, X, Y, W, H); + X = 0; Y = 0; + Mat src = bytimg.Mat; + Mat mat_threshold = new Mat(); + CvInvoke.Threshold(src, mat_threshold, Threshold, 254, Emgu.CV.CvEnum.ThresholdType.BinaryInv); + Mat mat_dilate = commonUse.MyDilate(mat_threshold); + VectorOfVectorOfPoint selected_contours; + int option_pixel_options = 0; + selected_contours = GetUsefulContoursSelectoOptionQK(mat_dilate, 1, out option_pixel_options); + + mx = GetValueAndDrawGrid_Other(src.Bitmap, selected_contours, X, wL, xuanXiang, Y, hL, tiliang, ""); + bytimg.Dispose(); + src.Dispose(); + return option_pixel_options; + } + + /// + /// 筛选图中符合给定条件的轮廓 + /// + /// 要提取轮廓的图片 + /// 轮廓外接矩形大于该宽度值 + /// 轮廓外接矩形小于该宽度值 + /// 轮廓外接矩形大于该高度值 + /// 轮廓外接矩形小于该高度值 + public static VectorOfVectorOfPoint GetUsefulContoursSelectoOptionQK(Mat mat, double ratio, out int option_pixel_options) + { + option_pixel_options = 0; + VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint();//所有的轮廓 + VectorOfVectorOfPoint selected_contours = new VectorOfVectorOfPoint();//用于存储筛选过后的轮廓 + CvInvoke.FindContours(mat, contours, null, Emgu.CV.CvEnum.RetrType.External, + Emgu.CV.CvEnum.ChainApproxMethod.ChainApproxSimple);//提取所有轮廓,操作过程中会对输入图像进行修改 + + //筛选轮廓。筛选条件:长宽比大于给定值 + for (int i = 0; i < contours.Size; i++) + { + Rectangle rect = CvInvoke.BoundingRectangle(contours[i]);//外接矩形 + Mat temp = new Mat(mat, rect);//提取ROI矩形区域 + int pxNums = CvInvoke.CountNonZero(temp);//计算图像内非零像素个数 + + double area = CvInvoke.ContourArea(contours[i]);//计算连通轮廓的面积 + double length = CvInvoke.ArcLength(contours[i], false); //计算连通轮廓的周长 + + VectorOfPoint approx_curve = new VectorOfPoint();//用于存放逼近的结果 + CvInvoke.ApproxPolyDP(contours[i], approx_curve, length * 0.02, true); + //bool bo = (area > 500 && area < 12000);//&& rect.Height<100 + //bool bo = ((area > 20 && area < 150000) && rect.Height > 8 ); + bool bo = ((area > 10 && area < 150000) && rect.Height > 5); + if (bo) + { + if (pxNums > (area * 0.7)) + { + option_pixel_options = pxNums; + selected_contours.Push(contours[i]); + } + } + } + return selected_contours; + } + + /// + /// 画出网格并返回填图结果 + /// + /// + /// + /// 左边距 + /// 方块长度 + /// 方块数量 + /// 上边距 + /// 方块高度 + /// 方块竖数量 + /// 输出文字 + /// + public static string GetValueAndDrawGrid_Other(Bitmap img, VectorOfVectorOfPoint contours, + int x_begin, int x_interval, int x_num, int y_begin, int y_interval, int y_num, string strText) + { + //画网格 + //Mat mat_grid = DrawGridByXY(img, x_begin, x_interval, x_num, y_begin, y_interval, y_num); + + + int[] intArray = GetTargetValues_L_Other(contours, x_begin, x_interval, x_num, y_begin, y_interval, y_num, img, strText); + int maxValue = GetMaxValueOfArray(intArray);//数组最大值 + + string str = ""; + //str += Environment.NewLine;//回车 + str += strText; + if (maxValue >= 4 && maxValue < 10) + { + str += GetStringOfIntArray(intArray, "ABCDEFGH"); + } + else + { + if (maxValue >= 10) + { + str += GetStringOfIntArray(intArray, "ABCDEFGH"); + } + else + { + str += GetStringOfIntArray(intArray, "ABCDEFGH"); + } + + } + + return str; + } + + /// + /// 拼接给定int数组内容,并返回拼接后字符串 + /// + /// + /// + public static string GetStringOfIntArray(int[] arr, string ss = "ABCD") + { + string str = ""; + //char[] ch = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G' }; + char[] ch = ss.ToCharArray(); + foreach (int a in arr) + { + /// + if (a >= 10) + { + string x = a.ToString(); + char[] cc = x.ToArray(); + + int[] result = new int[cc.Length]; + + for (int i = 0; i < cc.Length; i++) + { + result[i] = Convert.ToInt32(x.Substring(i, 1)); + } + Array.Sort(result); + + int[] finalResult = result; + for (int j = 0; j < finalResult.Length; j++) + { + if (finalResult[j] == -1) + { + str += "null"; + } + else + { + str += ch[finalResult[j]]; + } + } + str += " "; + } + else + { + if (a == -1) + { + str += "null ";//未识别时,标示为空 + } + else + { + str += ch[a] + " "; + } + + } + } + return str; + } + + + /// + /// 获取一维int数组中最大值 + /// + /// + /// + public static int GetMaxValueOfArray(int[] arr) + { + int[] dst = new int[arr.Length]; + Array.Copy(arr, dst, arr.Length);//深度复制数组,防止排序对原数组产生影响 + Array.Sort(dst);//数组排序 + int maxValue = dst[arr.Length - 1];//数组最大值 + return maxValue; + } + + // + /// 根据给定的轮廓及范围信息计算涂卡的结果,返回int数组 + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static int[] GetTargetValues_L_Other(VectorOfVectorOfPoint contours, int x_begin, int x_interval, int x_num, + int y_begin, int y_interval, int y_num, Bitmap img, string strText) + { + int[] result = new int[y_num];//结果数组 + //数组初值默认为-1 + for (int i = 0; i < y_num; i++) + { + result[i] = -1; + } + int x_max = x_begin + x_interval * x_num; + int y_max = y_begin + y_interval * y_num; + + + VectorOfVectorOfPoint targetContours = new VectorOfVectorOfPoint(); + Point[] gravity = GetGravityOfContours(contours);//轮廓中心点坐标 + for (int i = 0; i < contours.Size; i++) + { + VectorOfPoint contour = contours[i]; + + if (gravity[i].X < x_begin || gravity[i].X > x_max || gravity[i].Y < y_begin || gravity[i].Y > y_max) + { + continue;//判断中心点是否超出范围 + } + + int x_id = (int)Math.Floor((double)(gravity[i].Y - y_begin) / y_interval);//向右取整数 + int value = (int)Math.Floor((double)(gravity[i].X - x_begin) / x_interval); + + if (result[x_id] != -1) + { + + + } + else + { + + result[x_id] = value; + } + } + + return result; + } + + /// + /// 计算轮廓中心点坐标 + /// + /// 要计算中心点的轮廓 + /// + public static Point[] GetGravityOfContours(VectorOfVectorOfPoint selected_contours) + { + int ksize = selected_contours.Size; + + double[] m00 = new double[ksize]; + double[] m01 = new double[ksize]; + double[] m10 = new double[ksize]; + Point[] gravity = new Point[ksize];//用于存储轮廓中心点坐标 + MCvMoments[] moments = new MCvMoments[ksize]; + + for (int i = 0; i < ksize; i++) + { + VectorOfPoint contour = selected_contours[i]; + //计算当前轮廓的矩 + moments[i] = CvInvoke.Moments(contour, false); + + + m00[i] = moments[i].M00; + m01[i] = moments[i].M01; + m10[i] = moments[i].M10; + int x = Convert.ToInt32(m10[i] / m00[i]);//计算当前轮廓中心点坐标 + int y = Convert.ToInt32(m01[i] / m00[i]); + gravity[i] = new Point(x, y); + } + return gravity; + } + + + + + /// + /// 获取裁剪 L T W H + /// + /// + public static Image GetMatCutImg(Bitmap bmp, int sX, int sT, int sW, int sH) + { + List> postionimageCut = new List>(); + int L = sX; + int T = sT; + int W = sW; + int H = sH; + Rectangle rectangle = new Rectangle(L, T, W, H); + + Image Sub = new Image(bmp).GetSubRect(rectangle); + Image CropImage = new Image(Sub.Size); + CvInvoke.cvCopy(Sub, CropImage, IntPtr.Zero); + + return CropImage; + } + + + + /// + /// 检查边距是否合格 + /// + /// + private string TempV(string[] GetData, string PYPostionList, int oldWidth, int oldHeight, string HideAreaPostionList) + { + double pyLeft = Convert.ToInt32(PYPostionList.Split(',')[0]); + double pyTop = Convert.ToInt32(PYPostionList.Split(',')[1]); + double Xtop = 0; + double Xleft = 0; + double Xwidth = 0; + double Xheight = 0; + if (GetData[1] != "") + { + string[] list = GetData[1].Split(','); + Xleft = Convert.ToDouble(list[0]); + Xtop = Convert.ToDouble(list[1]); + Xwidth = Convert.ToDouble(list[2]); + Xheight = Convert.ToDouble(list[3]); + if (Xleft < pyLeft) + { + return "学号编辑框左边超过定位点边界!"; + + } + if (Xleft + Xwidth - pyLeft > oldWidth) + { + return "学号编辑框右边超过定位点边界!"; + } + if (Xtop < pyTop) + { + return "学号编辑框上边超过定位点边界!"; + } + + if (Xtop + Xheight - pyTop > oldHeight) + { + return "学号编辑框下边超过定位点边界!"; + } + } + + if (GetData[2] != "")//客观题 + { + string[] keguantiList = GetData[2].Split('^'); + foreach (string slist in keguantiList) + { + string[] list = slist.Split(','); + Xleft = Convert.ToDouble(list[0]); + Xtop = Convert.ToDouble(list[1]); + Xwidth = Convert.ToDouble(list[2]); + Xheight = Convert.ToDouble(list[3]); + string tihao = list[4] + "-" + list[5]; + if (Xleft < pyLeft) + { + return "客观题:[" + tihao + "] 编辑框左边超过定位点边界!"; + } + if (Xleft + Xwidth - pyLeft > oldWidth) + { + return "客观题:[" + tihao + "]编辑框右边超过定位点边界!"; + } + if (Xtop < pyTop) + { + return "客观题:[" + tihao + "] 编辑框上边超过定位点边界!"; + } + + if (Xtop + Xheight - pyTop > oldHeight) + { + return "客观题:[" + tihao + "] 编辑框下边超过定位点边界!"; + } + } + } + if (GetData[3] != "")//主观题 + { + string[] keguantiList = GetData[3].Split('^'); + foreach (string slist in keguantiList) + { + string[] list = slist.Split(','); + Xleft = Convert.ToDouble(list[0]); + Xtop = Convert.ToDouble(list[1]); + Xwidth = Convert.ToDouble(list[2]); + Xheight = Convert.ToDouble(list[3]); + string tihao = list[4]; + if (Xleft < pyLeft) + { + return "主观题:[" + tihao + "] 编辑框左边超过定位点边界!"; + } + if (Xleft + Xwidth - pyLeft > oldWidth) + { + return "主观题:[" + tihao + "] 编辑框右边超过定位点边界!"; + } + if (Xtop < pyTop) + { + return "主观题:[" + tihao + "] 编辑框上边超过定位点边界!"; + } + + if (Xtop + Xheight - pyTop > oldHeight) + { + return "主观题:[" + tihao + "] 编辑框下边超过定位点边界!"; + } + } + } + if (GetData[4] != "")//主观题 + { + string[] keguantiList = GetData[4].Split('^'); + foreach (string slist in keguantiList) + { + string[] list = slist.Split(','); + Xleft = Convert.ToDouble(list[0]); + Xtop = Convert.ToDouble(list[1]); + Xwidth = Convert.ToDouble(list[2]); + Xheight = Convert.ToDouble(list[3]); + string tihao = list[4]; + if (Xleft < pyLeft) + { + return "题号:[" + tihao + "] 编辑框左边超过定位点边界!"; + } + if (Xleft + Xwidth - pyLeft > oldWidth) + { + return "题号:[" + tihao + "] 编辑框右边超过定位点边界!"; + } + if (Xtop < pyTop) + { + return "题号:[" + tihao + "] 编辑框上边超过定位点边界!"; + } + + if (Xtop + Xheight - pyTop > oldHeight) + { + return "题号:[" + tihao + "] 编辑框下边超过定位点边界!"; + } + } + } + + if (GetData[5] != "") + { + string[] list = GetData[5].Split(','); + Xleft = Convert.ToDouble(list[0]); + Xtop = Convert.ToDouble(list[1]); + Xwidth = Convert.ToDouble(list[2]); + Xheight = Convert.ToDouble(list[3]); + if (Xleft < pyLeft) + { + return "条码编辑框左边超过定位点边界!"; + + } + if (Xleft + Xwidth - pyLeft > oldWidth) + { + return "条码编辑框右边超过定位点边界!"; + } + if (Xtop < pyTop) + { + return "条码编辑框上边超过定位点边界!"; + } + + if (Xtop + Xheight - pyTop > oldHeight) + { + return "条码编辑框下边超过定位点边界!"; + } + } + + if (GetData[7] != "") + { + string[] list = GetData[7].Split(','); + Xleft = Convert.ToDouble(list[0]); + Xtop = Convert.ToDouble(list[1]); + Xwidth = Convert.ToDouble(list[2]); + Xheight = Convert.ToDouble(list[3]); + if (Xleft < pyLeft) + { + return "条码编辑框左边超过定位点边界!"; + + } + if (Xleft + Xwidth - pyLeft > oldWidth) + { + return "条码编辑框右边超过定位点边界!"; + } + if (Xtop < pyTop) + { + return "条码编辑框上边超过定位点边界!"; + } + + if (Xtop + Xheight - pyTop > oldHeight) + { + return "条码编辑框下边超过定位点边界!"; + } + } + if (GetData[8] != "") + { + string[] list = GetData[8].Split(','); + Xleft = Convert.ToDouble(list[0]); + Xtop = Convert.ToDouble(list[1]); + Xwidth = Convert.ToDouble(list[2]); + Xheight = Convert.ToDouble(list[3]); + if (Xleft < pyLeft) + { + return "批阅分数编辑框左边超过定位点边界!"; + + } + if (Xleft + Xwidth - pyLeft > oldWidth) + { + return "批阅分数编辑框编辑框右边超过定位点边界!"; + } + if (Xtop < pyTop) + { + return "批阅分数编辑框编辑框上边超过定位点边界!"; + } + + if (Xtop + Xheight - pyTop > oldHeight) + { + return "批阅分数编辑框编辑框下边超过定位点边界!"; + } + } + if (HideAreaPostionList != "") + { + + JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer(); + List ht = javaScriptSerializer.Deserialize>(HideAreaPostionList); + int count = 0; + foreach (HideAreaData h in ht) + { + count++; + Xleft = Convert.ToDouble(h.left); + Xtop = Convert.ToDouble(h.top); + Xwidth = Convert.ToDouble(h.width); + Xheight = Convert.ToDouble(h.height); + if (Xleft < pyLeft) + { + return "屏蔽区" + count + "编辑框左边超过定位点边界!"; + + } + if (Xleft + Xwidth - pyLeft > oldWidth) + { + return "屏蔽区" + count + "编辑框右边超过定位点边界!"; + } + if (Xtop < pyTop) + { + return "屏蔽区" + count + "编辑框上边超过定位点边界!"; + } + + if (Xtop + Xheight - pyTop > oldHeight) + { + return "屏蔽区" + count + "编辑框下边超过定位点边界!"; + } + } + } + return "ok"; + } + + private Bitmap ScaleToSize(Bitmap bitmap, int width, int height) + { + if (bitmap == null) + { + return null; + } + if (bitmap.Width == width && bitmap.Height == height) + { + return bitmap; + } + + var scaledBitmap = new Bitmap(width, height); + using (var g = Graphics.FromImage(scaledBitmap)) + { + g.InterpolationMode = InterpolationMode.HighQualityBicubic; + g.DrawImage(bitmap, 0, 0, width, height); + } + return scaledBitmap; + } + + // + /// 图片另存为 + /// + /// 路径 + public Bitmap ImgGet(string url) + { + WebRequest imgRequest = WebRequest.Create(url); + + HttpWebResponse res; + try + { + res = (HttpWebResponse)imgRequest.GetResponse(); + } + catch (WebException ex) + { + + res = (HttpWebResponse)ex.Response; + } + + if (res.StatusCode.ToString() == "OK") + { + return new Bitmap((System.Drawing.Image)new Bitmap(imgRequest.GetResponse().GetResponseStream())); + } + else + { + return null; + } + } + + + + public class HideAreaData + { + public Double width { get; set; } + public Double height { get; set; } + public Double left { get; set; } + public Double top { get; set; } + } + + + +} diff --git a/js/indexNoPostion.js b/js/indexNoPostion.js new file mode 100644 index 0000000..cf37f98 --- /dev/null +++ b/js/indexNoPostion.js @@ -0,0 +1,1171 @@ +var IsPostionValue = $("#IsPostionValue").val(); + + +//设置页面大小 +function ChangePageSize(obj) { + $(".main_papermain").width(obj.value); +} + +//设定全卷遮挡区域 +function SetHideArea() { + var html = ""; + html += "
"; + html += "
屏蔽显示区
"; + html += "
X
"; + html += "
"; + $(".main_papermain").append(html); + $(".hidearea").draggable({ containment: ".main_papermain" }); + $(".hidearea").resizable({ containment: ".main_papermain", handles: 'all' });//设置缩放 +} +//删除全屏遮挡区域 +function CloseHideArea(obj) { + $(obj).parent().remove(); +} + +///设置锚点 +function SetMao(obj, index) { + if (IsPostionValue == "False") { + alert("无法设置定位点,请修改主模板数据."); + return; + } + if ($(obj).attr("class") == "maodian_hover") { + $("#draggable_" + index).remove(); + $(obj).attr("class", "maodian"); + return; + } + var style = ""; + var pright = parseInt($(".main_papermain").width()) - 120; + var pheight = parseInt($(".main_papermain").height()) - 100; + if (index == 0) { + style = "left:60px; top:40px;" + } + + if (index == 1) { + style = "left:" + pright + "px; top:30px;" + } + if (index == 2) { + style = "left:60px; top:" + pheight + "px;" + } + if (index == 3) { + style = "left:" + pright + "px; top:" + pheight + "px;" + } + $(obj).attr("class", "maodian_hover"); + + $(".main_papermain").append("
" + $(obj).html() + "
"); + + + $("#draggable_" + index).draggable({ containment: ".main_papermain" }); + $("#draggable_" + index).resizable({ containment: ".main_papermain", handles: 'all' });//设置缩放 +} +///设置锚点 +///设置学号 +function SetXuehao(obj) { + if ($(obj).attr("class") == "main_select_set_hover") { + $("#xuehaoTable").remove(); + $(obj).attr("class", "main_select_set"); + return; + } + $(obj).attr("class", "main_select_set_hover"); + var num = $("#xuehaonum").val(); + var html = ""; + for (var i = 0; i < 10; i++) { + html += ""; + for (var j = 0; j < num; j++) { + html += ""; + } + html += ""; + } + html += "
"; + + $(".main_papermain").append("
" + html + "
"); + $("#xuehaoTable").draggable({ containment: ".main_papermain" }); + $("#xuehaoTable").resizable({ containment: ".main_papermain", handles: 'all' });//设置缩放 +} +//设置学号 + + +/////////设置客观题////////////////// +function SetKeguanTi() { + var tihao = $("#tihao").val().toUpperCase().replace(".", "·").replace("(", "(").replace(")", ")").replace(")", ")").replace("=", "=").replace("@", "@");//题号 + var tihao_end = $("#tihao_end").val().toUpperCase().replace(".", "·").replace("(", "(").replace(")", ")").replace(")", ")").replace("=", "=").replace("@", "@"); + var tihaoM = tihao + "-" + tihao_end; + + var score = $("#questionscroe").val(); + var tihaoList = tihaoM.toString().split('-'); + + if (tihaoList.length != 2) { + alert("题号规则错误,请重新输入"); + return; + } + + + + if (document.getElementById("keguan_" + tihaoM) != undefined) { + alert("题目配置重复:" + tihaoM); + return; + } + + var rd_listtype = document.getElementsByName("listtype");//题目横竖向 + var listtype = 0; + var selectNum = $("#selectNum").val(); + + for (var i = 0; i < rd_listtype.length; i++) { + if (rd_listtype[i].checked) { + listtype = rd_listtype[i].value; + } + } + + var questiontype = $("#questiontype").val(); + + var startnum = parseInt(tihaoList[0]); + var endnum = parseInt(tihaoList[1]); + if (endnum == undefined) { + endnum = startnum; + } + var html = ""; + + var BigTihao = ""; + if (tihao.indexOf('M') > -1) { + BigTihao = tihaoList[0].split('M')[0] + "M"; + startnum = tihaoList[0].split('M')[1]; + endnum = tihaoList[1].split('M')[1]; + } + + if (listtype == 0)//横向 + { + for (var i = parseInt(startnum); i <= parseInt(endnum); i++) { + + html += ""; + for (var j = 0; j < selectNum; j++) { + html += ""; + } + html += ""; + } + } + else {//竖向 + for (var i = 0; i < selectNum; i++) { + html += ""; + for (var j = startnum; j <= endnum; j++) { + html += ""; + } + html += ""; + } + } + html += "
"; + var selectMore = 0; + + var questionHtml = "单选题"; + if (questiontype == 1) { + questionHtml = "多选题"; + } + if (questiontype == 2) { + questionHtml = "判断"; + } + + $(".main_papermain").append("
" + tihaoM + "
" + html + "
"); + $("#keguan_" + tihao).draggable({ containment: ".main_papermain" }); + $("#keguan_" + tihao).resizable({ containment: ".main_papermain", handles: 'all' });//设置缩放 + var listtypeText = listtype == 0 ? "横向" : "竖向"; + $("#NowSelect").append("
  • " + questionHtml + "
    " + tihaoM + "
    " + selectNum + "
    " + listtypeText + "
    " + score + "
    x
  • "); + +} +function DeleteKeguanti(tihao) { + $("#keguan_" + tihao).remove(); + $("#selectNow_" + tihao).remove(); + $("#pyti_" + tihao).remove(); + if (tihao.indexOf('X') > -1) { + $("#pyti_" + tihao.split('X')[0]).remove(); + } + GetZhuguantiScoreList(); +} +/////////设置客观题///////////// + +/////////////////设置主观题////////////////////// + +function SetZhuguanTi() { + + var zhuguan_tihao = $("#zhuguan_tihao").val().toUpperCase().replace(".", "·").replace("(", "(").replace(")", ")").replace(")", ")").replace("=", "=").replace("@", "@"); + + if (zhuguan_tihao == "") { + alert("主观题 题号不能为空"); + return; + } + var score = $("#zgquestionscroe").val(); + var scoretype = $("#questionscroetype").val(); + var questiontype_zg = $("#questiontype_zg").val(); + //var scoretypeText = scoretype == "1" ? "全分" : "半分"; + var scoretypeText = scoretype; + + if (document.getElementById("keguan_" + zhuguan_tihao) != undefined) { + alert("0题目配置重复:" + zhuguan_tihao); + return; + } + var zhuguan_xiaoti = $("#zhuguan_xiaoti").val(); + if (zhuguan_xiaoti == "") { + zhuguan_xiaoti = "0"; + } + var lineWh = "width:450px;height:250px;"; + var lineWhTx = "大题"; + if (questiontype_zg == "2") { + var lineWh = "width:200px;height:90px;"; + lineWhTx = "填空" + } + $(".main_papermain").append("
    " + lineWhTx + ":" + zhuguan_tihao + "
    "); + $("#keguan_" + zhuguan_tihao).draggable({ containment: ".main_papermain" }); + $("#keguan_" + zhuguan_tihao).resizable({ containment: ".main_papermain", handles: 'all' }); + + $("#NowSelect").append("
  • 主观题
    " + zhuguan_tihao + "
    " + zhuguan_xiaoti + "
    " + score + "
    " + scoretypeText + "
    x
  • "); + //如果是手阅 + GetZhuguantiScoreList(); +} +////////////////设置主观题////////////////////// + + +/////////////////设置条码识别区////////////////////// + +function SetTiaoMa(obj) { + if ($(obj).attr("class") == "tiaomasz_hover") { + $(obj).attr("class", "tiaomasz"); + DeleteKeguanti('tiaomashibie'); + return; + } + else { + $(obj).attr("class", "tiaomasz_hover"); + } + $(".main_papermain").append("
    条码
    "); + setTimeout(function () { + $("#keguan_tiaomashibie").draggable({ containment: ".main_papermain" }); + $("#keguan_tiaomashibie").resizable({ containment: ".main_papermain", handles: 'all' }); + }, 500); + +} + +////////////////设置条码识别区////////////////////// + + +/////////////////准考证号识别区////////////////////// + +function SetZunkaoZheng() { + if (document.getElementById("zhunkaozhenghaoshibie") != undefined) { + alert("准考证号配置重复"); + return; + } + $(".main_papermain").append("
    准考证号
    "); + $("#keguan_zhunkaozhenghaoshibie").draggable({ containment: ".main_papermain" }); + $("#keguan_zhunkaozhenghaoshibie").resizable({ containment: ".main_papermain", handles: 'all' }); + $("#NowSelect").append("
  • 准考证号删除
  • "); +} + +////////////////准考证号识别区////////////////////// + + + + + +/////////////////设置缺考标记////////////////////// + +function SetWenziQuyu(obj) { + var zhuguan_tihao = "缺考"; + if ($(obj).attr("class") == "quelapsz_hover") { + $(obj).attr("class", "quelapsz"); + DeleteKeguanti(zhuguan_tihao); + return; + } + else { + $(obj).attr("class", "quelapsz_hover"); + } + + if (document.getElementById("keguan_" + zhuguan_tihao) != undefined) { + alert("缺考已标记"); + return; + } + $(".main_papermain").append("
    " + zhuguan_tihao + "
    "); + $("#keguan_" + zhuguan_tihao).draggable({ containment: ".main_papermain" }); + $("#keguan_" + zhuguan_tihao).resizable({ containment: ".main_papermain", handles: 'all' }); +} + + +////////////////设置文字区域////////////////////// + +/////////////////设置标准店////////////////////// + +function SetBiaoZhunDian(obj) { + var zhuguan_tihao = "标准点"; + + if ($(obj).attr("class") == "biaozhundian_hover") { + $(obj).attr("class", "biaozhundian"); + DeleteKeguanti(zhuguan_tihao); + return; + } + else { + $(obj).attr("class", "biaozhundian_hover"); + } + if (document.getElementById("keguan_" + zhuguan_tihao) != undefined) { + alert("标准点已标记"); + return; + } + $(".main_papermain").append("
    " + zhuguan_tihao + "
    "); + $("#keguan_" + zhuguan_tihao).draggable({ containment: ".main_papermain" }); + $("#keguan_" + zhuguan_tihao).resizable({ containment: ".main_papermain", handles: 'all' }); +} + + + + + + +////设置先批后阅////// +function SetPYPostion(type) { + + var py_tihao = $("#py_tihao").val(); + var isHaveX = false; + if (document.getElementById("pyti_" + py_tihao) != null) { + alert("已有先批后阅该主观题"); + return; + } + if (document.getElementById("keguan_" + py_tihao) == null) { + if (document.getElementById("keguan_" + py_tihao + "X1") == null) { + alert("找不到该主观题题号"); + return; + } + else { + isHaveX = true; + } + } + var lineWhTx = "填空题打分"; + var score = 0; + + if (isHaveX) { + score = $("#keguan_" + py_tihao + "X1").attr("score"); + type = $("#keguan_" + py_tihao + "X1").attr("questiontype_zg"); + } + else { + score = $("#keguan_" + py_tihao).attr("score"); + type = $("#keguan_" + py_tihao).attr("questiontype_zg"); + } + ///如果是填空题,批阅类型为0 + if (type == "2") { + type = "0"; + } + + var lineWh = "width:35px;height:35px;"; + + + + + if (type == "") { + type == "1"; + } + + + if (type == 1) { + lineWhTx = "主观题打分"; + lineWh = "width:736px;height:30px;"; + } + + if (score.indexOf(".") > -1) { + alert("题目分数不能有小数点"); + return; + } + + var html = ""; + + html += "
    "; + html += "
    " + lineWhTx + ":" + py_tihao + "x
    "; + html += "
    "; + html += "
    "; + html += "
    "; + $(".main_papermain").append(html); + $("#pyti_" + py_tihao).draggable({ containment: ".main_papermain" }); + $("#pyti_" + py_tihao).resizable({ containment: ".main_papermain", handles: 'all' }); + GetZhuguantiScoreList(); +} + +function closepy_hi(obj) { + $(obj).parent().parent().remove(); + GetZhuguantiScoreList(); +} +////设置先批后阅////// + + +///////////////////统计数据////////////////////////// +//获取锚点位置 +function GetMaoPostion() { + if ($(".maodian_hover").length == 0) { + return ""; + } + var xy = ""; + if ($(".maodian_hover").length == 4) { + for (var i = 0; i < 4; i++) { + xy += parseFloat($("#draggable_" + i).position().left) + "," + parseFloat($("#draggable_" + i).position().top) + "," + parseFloat($("#draggable_" + i).width()) + "," + parseFloat($("#draggable_" + i).height()) + "^"; + } + } + else { + //alert("锚点未设置完成"); + return ""; + } + + return xy.trim('^');; +} + +//获取学号数据 +function GetXuehaoPostion() { + if (document.getElementById("xuehaoTable") == undefined) { + return ""; + } + var xy = ""; + xy = parseFloat($("#xuehaoTable").position().left) + "," + parseFloat($("#xuehaoTable").position().top) + "," + parseFloat($("#xuehaoTable").width()) + "," + parseFloat($("#xuehaoTable").height()) + "," + $("#xuehaoTable").attr("listNum"); + return xy; +} +//获取客观题 +function GetKeguanPostion() { + if ($(".keguanti").length == 0) { + return ""; + } + var xy = ""; + $(".keguanti").each(function () { + xy += parseFloat($(this).position().left) + "," + parseFloat($(this).position().top) + "," + parseFloat($(this).width()) + "," + parseFloat($(this).height()) + "," + $(this).attr("startnum") + "," + $(this).attr("endNum") + "," + $(this).attr("selectNum") + "," + $(this).attr("listtype") + "," + $(this).attr("questiontype") + "," + $(this).attr("score") + "^"; + }) + return xy.trim('^'); +} + +//获取主观题 +function GetZhuguanPostion() { + var xy = ""; + if ($(".zhuguanti").length == 0) { + return ""; + } + $(".zhuguanti").each(function () { + xy += parseFloat($(this).position().left) + "," + parseFloat($(this).position().top) + "," + parseFloat($(this).width()) + "," + parseFloat($(this).height()) + "," + $(this).attr("tihaovalue") + "," + $(this).attr("zhuguan_xiaoti") + "," + $(this).attr("score") + "," + $(this).attr("scoretype") + "," + $(this).attr("questiontype_zg") + "^"; + }) + return xy.trim('^'); +} +//获取条码 +function GettiaomaPostion() { + var xy = ""; + if (document.getElementById("keguan_tiaomashibie") == undefined) { + return ""; + } + xy += parseFloat($("#keguan_tiaomashibie").position().left) + "," + parseFloat($("#keguan_tiaomashibie").position().top) + "," + parseFloat($("#keguan_tiaomashibie").width()) + "," + parseFloat($("#keguan_tiaomashibie").height()); + return xy.trim('^'); +} +//获取准考证号 +function GetZKZHPostion() { + var xy = ""; + if (document.getElementById("keguan_zhunkaozhenghaoshibie") == undefined) { + return ""; + } + xy += parseFloat($("#keguan_zhunkaozhenghaoshibie").position().left) + "," + parseFloat($("#keguan_zhunkaozhenghaoshibie").position().top) + "," + parseFloat($("#keguan_zhunkaozhenghaoshibie").width()) + "," + parseFloat($("#keguan_zhunkaozhenghaoshibie").height()); + return xy.trim('^'); +} + +//获取文字截获 +function GetWenziPostion() { + var xy = ""; + if ($(".wenzimiaoshu").length == 0) { + return ""; + } + $(".wenzimiaoshu").each(function () { + xy += parseFloat($(this).position().left) + "," + parseFloat($(this).position().top) + "," + parseFloat($(this).width()) + "," + parseFloat($(this).height()) + "," + $(this).attr("wenzimiaoshu") + "^"; + }) + return xy.trim('^'); +} + +//获取标准点 +function GetBiaoZhunDianPostion() { + var xy = ""; + if ($(".biaozhundian_select").length == 0) { + return ""; + } + $(".biaozhundian_select").each(function () { + xy += parseFloat($(this).position().left) + "," + parseFloat($(this).position().top) + "," + parseFloat($(this).width()) + "," + parseFloat($(this).height()) + "," + $(this).attr("wenzimiaoshu") + "^"; + }) + return xy.trim('^'); +} + + +//获取屏蔽区数据 +function GetHideAreaPostion() { + var xy = ""; + if ($(".hidearea").length == 0) { + return ""; + } + var jsonstr = []; + $(".hidearea").each(function () { + xy += parseFloat($(this).position().left) + "," + parseFloat($(this).position().top) + "," + parseFloat($(this).width()) + "," + parseFloat($(this).height()) + "^"; + var json = {}; + json.width = parseFloat($(this).width()); + json.height = parseFloat($(this).height()); + json.left = parseFloat($(this).position().left); + json.top = parseFloat($(this).position().top); + jsonstr.push(json); + }) + return JSON.stringify(jsonstr); +} +//获取先批后阅数学 +function GetPyAreaPostion() { + var xy = ""; + if ($(".pyti").length == 0) { + return ""; + } + $(".pyti").each(function () { + xy += parseFloat($(this).position().left) + "," + parseFloat($(this).position().top) + "," + parseFloat($(this).width()) + "," + parseFloat($(this).height()) + "," + $(this).attr("tihaovalue") + "," + $(this).attr("score") + "," + $(this).attr("piyueType") + "^"; + }) + + return xy.trim('^'); +} + + + +///////////////////统计数据////////////////////////// +function GetDataTotal(objvalue, tenant) { + if ($("#hd_isHand").val() == "1") { + if ($("#py_tihao").val() != "all") { + alert("主观题有未批阅分数,请先配置好主观题分数选择框!"); + return; + } + } + + var maodian = GetMaoPostion();//左边距,右边距,长,高 + var xuehao = GetXuehaoPostion();//左边距,右边距,长,高,学号数量 + var keguanti = GetKeguanPostion(); //左边距,右边距,长,高,题号开始,题号结束,选择几项,横排还是竖排,单选多选或者判断 + var zhuguanti = GetZhuguanPostion();//左边距,右边距,长,高,题号,小题数量 + var wenzimiaoshu = GetWenziPostion();//左边距,右边距,长,高,文字描述 + var tiaoma = GettiaomaPostion();////左边距,右边距,长,高 + var zhunkaozhenghao = GetZKZHPostion();///获取准考证号识别区域 + var hideArea = GetHideAreaPostion();//获取屏蔽区数据 + var pytiArea = GetPyAreaPostion();//获取批阅条件 + var biaoZhunDian = GetBiaoZhunDianPostion();//设置标准点 + var UserID = $("#UserID").val(); + var roteX = rote; + var BatchID = $("#BatchID").val(); + var GroupNo = $("#GroupNo").val(); + var selectPageSize = $("#selectPageSize").val(); + if (selectPageSize == null) { + $("#selectPageSize").focus(); + alert("请选择版面"); + return; + } + + if (document.getElementById("keguan_标准点") == undefined && $("#PageIndex").val() == "1") { + alert("您尚未设置标准点,无法保存数据"); + return; + } + + //if (document.getElementById("keguan_缺考") == undefined && $("#PageIndex").val() == "1") { + // if (confirm("您尚未设置缺考标记,无需设置点击取消按钮")) { + // return; + // } + //} + + + var PageIndex = $("#PageIndex").val(); + var MainTempId = $("#MainTempId").val(); + var WandH = parseFloat($("#SelectImg").width()) + "," + parseFloat($("#SelectImg").height()); + var totalHtml = maodian + "$" + xuehao + "$" + keguanti + "$" + zhuguanti + "$" + wenzimiaoshu + "$" + tiaoma + "$" + WandH + "$" + zhunkaozhenghao + "$" + pytiArea + "$" + biaoZhunDian; + if (maodian == "") { + //alert("必须设置4个锚点"); + //return; + } + if (objvalue == "1") { + if (confirm("锁定模板后,仅可修改识别区域,无法增删主客观题!")) { + $("#ansyButton").attr("disabled", "disabled"); + $("#ansyButton").attr("value", "正在更新数据"); + $.post("UserNoPostionTemp.aspx", { action: "2", rd: Math.round(), MainTempId: MainTempId, PageIndex: PageIndex, totalHtml: encodeURIComponent(totalHtml), TempID: $("#TempID").val(), HideAreaPostionList: encodeURIComponent(hideArea), tenant: tenant }, function (res) { + if (res == "ok") { + $("#ansyButton").attr("disabled", "disabled"); + $("#ansyButton").attr("value", "模板已锁定"); + alert("数据更新成功"); + LockFunction(1); + } + + else { + $("#ansyButton").removeAttr("disabled"); + $("#ansyButton").attr("value", "锁定模板"); + alert(res + "更新失败"); + } + }) + } + } + else { + $("#noButtonK").attr("disabled", "disabled"); + $("#noButtonK").attr("value", "正在更新数据"); + $.post("UserNoPostionTemp.aspx", { action: "1", rd: Math.round(), GroupNo: GroupNo, BatchID: BatchID, UserID: UserID, MainTempId: MainTempId, PageIndex: PageIndex, totalHtml: encodeURIComponent(totalHtml), TempID: $("#TempID").val(), HideAreaPostionList: encodeURIComponent(hideArea), tenant: tenant, roteX: roteX.toFixed(2) }, function (res) { + $("#noButtonK").removeAttr("disabled"); + $("#noButtonK").attr("value", "保存数据"); + if (res == "ok") { + alert("数据更新成功"); + } + else { + + alert(res + "或更新失败,定位点错误"); + } + }) + } +} + + +///////////////////统计数据////////////////////////// + + +//初始化绑定数据 +function BaseDataBind() { + + + + var Bindlist = $("#Bindlist").val() + var list = Bindlist.split('$'); + var maodian = "";//左边距,右边距,长,高 + var xuehao = "";//左边距,右边距,长,高,学号数量 + var keguanti = ""; //左边距,右边距,长,高,题号开始,题号结束,横排还是竖排 + var zhuguanti = "";//左边距,右边距,长,高,题号,小题数量 + var wenzimiaoshu = "";//左边距,右边距,长,高,文字描述 + var tiaoma = "";//左边距,右边距,长,高,文字描述 + var pageWidth = ""; + var HideAreaText = $("#HideAreaText").val(); + var piyueList = ""; + var zhunkaozhenghao = ""; + var biaozhundian = ""; + if (Bindlist != "") { + maodian = list[0].trim('^');//左边距,右边距,长,高 + xuehao = list[1].trim('^');//左边距,右边距,长,高,学号数量 + keguanti = list[2].trim('^'); //左边距,右边距,长,高,题号开始,题号结束,横排还是竖排 + zhuguanti = list[3].trim('^');//左边距,右边距,长,高,题号,小题数量 + wenzimiaoshu = list[4].trim('^');//左边距,右边距,长,高,文字描述 + tiaoma = list[5].toString().trim('^');//左边距,右边距,长,高,文字描述 + pageWidth = list[6].toString().trim('^').split(',')[0]; + if (list[7] != undefined) { + zhunkaozhenghao = list[7].toString().trim('^'); + } + if (list[8] != undefined) { + piyueList = list[8].toString().trim('^'); + } + if (list[9] != undefined) { + biaozhundian = list[9].toString().trim('^'); + } + } + + if (pageWidth == 1200 || pageWidth == 1199 || pageWidth == 1198 || pageWidth == 1201) { + pageWidth = 1200; + } + if (pageWidth == 1570 || pageWidth == 1569 || pageWidth == 1571 || pageWidth == 1572 || pageWidth == 1573) { + pageWidth = 1570; + } + + //if(pageWidth==""){ + var pageType = $("#pager_A").val(); + if (pageType == "a3") { + pageWidth = 1570; + } + else { + pageWidth = 1200; + } + //} + + + $(".main_papermain").width(pageWidth + "px"); + if ($("#pager_A").val() == "a3") { + + $("#selectPageSize").val("1570"); + } + if ($("#pager_A").val() == "a4") { + $("#selectPageSize").val("1200"); + } + + + $("#selectPageSize").val(pageWidth); + $("#selectPageSize").change(); + + SetMaoPostion(maodian); + SetXuehaoPostion(xuehao); + SetKeguanTiPostion(keguanti); + SetZhuguanTiPostion(zhuguanti); + SetWenziQuyuPostion(wenzimiaoshu); + SetTiaomaPostion(tiaoma); + SetZhunkaozhengPostion(zhunkaozhenghao); + SetHideAreaBind(HideAreaText); + SetPyPostion(piyueList); + GetZhuguantiScoreList(); + SetBiaoZhunDianPostion(biaozhundian); +} + + +/////////////////批阅////////////////////// +function SetPyPostion(PostionData) { + //alert(PostionData); + // $(this).attr("tihaovalue") + "," + $(this).attr("score") + "," + $(this).attr("piyueType")+"^"; + + if (PostionData == "" || PostionData == undefined) { + return; + } + //左边距,右边距,长,高,题号,小题数量 + var listdata = PostionData.split('^'); + + for (var i = 0; i < listdata.length; i++) { + var zhuguanList = listdata[i].split(','); + var py_tihao = zhuguanList[4]; + var score = zhuguanList[5] == undefined ? "" : zhuguanList[5]; + var type = zhuguanList[6] == undefined ? "1" : zhuguanList[6]; + + + + + + var lineWhTx = "大题批阅"; + if (type == "0") { + lineWhTx = "填空批阅" + } + var style = ""; + style = "left:" + zhuguanList[0] + "px; top: " + zhuguanList[1] + "px; width:" + zhuguanList[2] + "px;height:" + zhuguanList[3] + "px;"; + var html = ""; + html += "
    "; + html += "
    " + lineWhTx + ":" + py_tihao + "x
    "; + html += "
    "; + html += "
    "; + html += "
    "; + $(".main_papermain").append(html); + $("#pyti_" + py_tihao).draggable({ containment: ".main_papermain" }); + $("#pyti_" + py_tihao).resizable({ containment: ".main_papermain", handles: 'all' }); + + + + } +} +////////////////设置主观题////////////////////// + + +//设置屏蔽区 +function SetHideAreaBind(data) { + if (data == "") { + return; + } + var json = JSON.parse(data); + var html = ""; + for (var i = 0; i < json.length; i++) { + var style = "left:" + json[i].left + "px; top: " + json[i].top + "px; width:" + json[i].width + "px;height:" + json[i].height + "px;"; + html += "
    "; + html += "
    屏蔽显示区
    "; + html += "
    x
    "; + html += "
    "; + } + $(".main_papermain").append(html); + $(".hidearea").draggable({ containment: ".main_papermain" }); + $(".hidearea").resizable({ containment: ".main_papermain", handles: 'all' });//设置缩放 +} + +///设置锚点 +function SetMaoPostion(postiondata) { + //alert(postiondata); + //alert(IsPostionValue); + + if (postiondata == "") { + if (IsPostionValue == "1") { + SetMao(document.getElementById("point_0"), 0); + SetMao(document.getElementById("point_1"), 1); + SetMao(document.getElementById("point_2"), 2); + SetMao(document.getElementById("point_3"), 3); + } + return; + } + if (IsPostionValue == "0") { + $("#draggable_0").remove(); + $("#draggable_1").remove(); + $("#draggable_2").remove(); + $("#draggable_3").remove(); + return; + } + + + var list = postiondata.split('^'); + for (var i = 0; i < list.length; i++) { + var obj = document.getElementById("point_" + i); + //左边距,右边距,长,高 + if ($(obj).attr("class") == "maodian_hover") { + $("#draggable_" + i).remove(); + $(obj).attr("class", "maodian"); + return; + } + var postionList = list[i].split(','); + var style = ""; + style = "left:" + postionList[0] + "px; top: " + postionList[1] + "px; width:" + postionList[2] + "px;height:" + postionList[3] + "px;"; + $(obj).attr("class", "maodian_hover"); + $(".main_papermain").append("
    " + $(obj).html() + "
    "); + $("#draggable_" + i).draggable({ containment: ".main_papermain" }); + $("#draggable_" + i).resizable({ containment: ".main_papermain", handles: 'all' }); + } +} + +///设置学号 +function SetXuehaoPostion(postionData) { + if (postionData == "") { + return; + } + var obj = document.getElementById("main_select_set"); + var postionList = postionData.split(','); + if ($(obj).attr("class") == "main_select_set_hover") { + $("#xuehaoTable").remove(); + $(obj).attr("class", "main_select_set"); + return; + } + //左边距,右边距,长,高,学号数量 + $(obj).attr("class", "main_select_set_hover"); + var num = postionList[4]; + $("#xuehaonum").val(num); + var html = ""; + for (var i = 0; i < 10; i++) { + html += ""; + for (var j = 0; j < num; j++) { + html += ""; + } + html += ""; + } + html += "
    "; + $(".main_papermain").append("
    " + html + "
    "); + $("#xuehaoTable").draggable({ containment: ".main_papermain" }); + $("#xuehaoTable").resizable({ containment: ".main_papermain", handles: 'all' });//设置缩放 +} +//设置学号 + +/////////设置客观题////////////////// +function SetKeguanTiPostion(PostionData) { + if (PostionData == "") { + return; + } + //左边距,右边距,长,高,题号开始,题号结束,横排还是竖排 + + var listOption = PostionData.split('^') + for (var jt = 0; jt < listOption.length; jt++) { + var listpostion = listOption[jt].split(','); + var tihao = listpostion[4].replace(".", "·").replace("(", "(").replace(")", ")").replace(")", ")").replace("=", "=").replace("@", "@") + "-" + listpostion[5].replace(".", "·").replace("(", "(").replace(")", ")").replace(")", ")").replace("=", "=").replace("@", "@");//题号 + + if (document.getElementById("keguan_" + tihao) != undefined) { + alert("题目配置重复:" + tihao); + return; + } + var rd_listtype = document.getElementsByName("listtype");//题目横竖向 + var listtype = listpostion[7]; + var selectNum = listpostion[6]; + var questiontype = listpostion[8]; + var score = listpostion[9] == undefined ? "" : listpostion[9]; + for (var i = 0; i < rd_listtype.length; i++) { + if (rd_listtype[i].value == listtype) { + rd_listtype[i].checked + } + } + + + var tihaolist = tihao.split('-'); + + + var startnum = tihaolist[0]; + var endnum = tihaolist[1]; + if (endnum == undefined) { + endnum = startnum; + } + var BigTihao = ""; + if (tihao.indexOf('M') > -1) { + BigTihao = tihaolist[0].split('M')[0] + "M"; + startnum = tihaolist[0].split('M')[1]; + endnum = tihaolist[1].split('M')[1]; + } + var html = ""; + if (listtype == 0)//横向 + { + + for (var i = parseInt(startnum); i <= parseInt(endnum); i++) { + + html += ""; + for (var j = 0; j < selectNum; j++) { + html += ""; + } + html += ""; + } + } + else {//竖向 + for (var i = 0; i < selectNum; i++) { + html += ""; + for (var j = parseInt(startnum); j <= parseInt(endnum); j++) { + html += ""; + } + html += ""; + } + } + html += "
    "; + var questionHtml = "单选题"; + if (questiontype == 1) { + questionHtml = "多选题"; + } + if (questiontype == 2) { + questionHtml = "判断"; + } + + $(".main_papermain").append("
    " + tihao + "
    " + html + "
    "); + $("#keguan_" + tihao).draggable({ containment: ".main_papermain" }); + $("#keguan_" + tihao).resizable({ containment: ".main_papermain", handles: 'all' });//设置缩放 + var listtypeText = listtype == 0 ? "横向" : "竖向"; + $("#NowSelect").append("
  • " + questionHtml + "
    " + tihao + "
    " + selectNum + "
    " + listtypeText + "
    " + score + "
    x
  • "); + } + +} + +/////////////////设置主观题////////////////////// +function SetZhuguanTiPostion(PostionData) { + + if (PostionData == "" || PostionData == undefined) { + return; + } + //左边距,右边距,长,高,题号,小题数量 + var listdata = PostionData.split('^'); + + for (var i = 0; i < listdata.length; i++) { + var zhuguanList = listdata[i].split(','); + var zhuguan_tihao = zhuguanList[4].toUpperCase().replace(".", "·").replace("(", "(").replace(")", ")").replace(")", ")").replace("=", "=").replace("@", "@"); + var score = zhuguanList[6] == undefined ? "" : zhuguanList[6]; + + var scoretype = zhuguanList[7] == undefined ? "1" : zhuguanList[7]; + + //var scoretypetext = scoretype; + var scoretypetext = scoretype; + var questiontype_zg = zhuguanList[8] == undefined ? "1" : zhuguanList[8]; + + + if (document.getElementById("keguan_" + zhuguan_tihao) != undefined && document.getElementById("keguan_" + zhuguan_tihao) != null) { + alert("2题目配置重复:" + zhuguan_tihao); + return; + } + var lineWhTx = "大题"; + if (questiontype_zg == "2") { + lineWhTx = "填空" + } + var zhuguan_xiaoti = zhuguanList[5]; + $(".main_papermain").append("
    " + lineWhTx + ":" + zhuguan_tihao + "
    "); + $("#keguan_" + zhuguan_tihao).draggable({ containment: ".main_papermain" }); + $("#keguan_" + zhuguan_tihao).resizable({ containment: ".main_papermain", handles: 'all' }); + $("#NowSelect").append("
  • 主观题
    " + zhuguan_tihao + "
    " + zhuguan_xiaoti + "
    " + score + "
    " + scoretypetext + "
    x
  • "); + } +} +////////////////设置主观题////////////////////// + +/////////////////设置文字区域////////////////////// + +function SetWenziQuyuPostion(PostionData) { + if (PostionData == "" || PostionData == undefined) { + return; + } + //左边距,右边距,长,高,题号,小题数量 + var listdata = PostionData.split('^'); + for (var i = 0; i < listdata.length; i++) { + var zhuguanList = listdata[i].split(','); + var zhuguan_tihao = zhuguanList[4]; + if (document.getElementById("keguan_缺考") != undefined) { + alert("缺考配置重复"); + return; + } + $(".main_papermain").append("
    " + zhuguan_tihao + "
    "); + $("#keguan_" + zhuguan_tihao).draggable({ containment: ".main_papermain" }); + $("#keguan_" + zhuguan_tihao).resizable({ containment: ".main_papermain", handles: 'all' }); + $(".quelapsz").attr("class", "quelapsz_hover"); + } +} + + +////////////////设置文字区域////////////////////// + + +/////////////////设置标准点////////////////////// + +function SetBiaoZhunDianPostion(PostionData) { + if (PostionData == "" || PostionData == undefined) { + return; + } + //左边距,右边距,长,高,题号,小题数量 + var listdata = PostionData.split('^'); + for (var i = 0; i < listdata.length; i++) { + var zhuguanList = listdata[i].split(','); + var zhuguan_tihao = zhuguanList[4]; + if (document.getElementById("keguan_标准点") != undefined) { + alert("标准点配置重复"); + return; + } + $(".main_papermain").append("
    " + zhuguan_tihao + "
    "); + $("#keguan_" + zhuguan_tihao).draggable({ containment: ".main_papermain" }); + $("#keguan_" + zhuguan_tihao).resizable({ containment: ".main_papermain", handles: 'all' }); + $(".biaozhundian").attr("class", "biaozhundian_hover"); + } +} + +////////////////设置文字区域////////////////////// + + + +/////////////////设置条码////////////////////// + +function SetTiaomaPostion(PostionData) { + + if (PostionData == "") { + return; + } + var zhuguanList = PostionData.split(','); + $(".main_papermain").append("
    条码
    "); + $(".tiaomasz").attr("class", "tiaomasz_hover"); + $("#keguan_tiaomashibie").resizable({ containment: ".main_papermain", handles: 'all' }); + $("#keguan_tiaomashibie").draggable({ containment: ".main_papermain" }); +} + + +/////////////////设置准考证号////////////////////// + +function SetZhunkaozhengPostion(PostionData) { + if (PostionData == "") { + return; + } + var zhuguanList = PostionData.split(','); + $(".main_papermain").append("
    准考证号
    "); + $("#keguan_zhunkaozhenghaoshibie").draggable({ containment: ".main_papermain" }); + $("#keguan_zhunkaozhenghaoshibie").resizable({ containment: ".main_papermain", handles: 'all' }); + $("#NowSelect").append("
  • 准考证号删除
  • "); +} + + +////////////////设置文字区域////////////////////// +//初始化绑定数据 +BaseDataBind(); + +function LockFunction(flag) { + var islocked = $("#isLocked").val(); + if (islocked == true || islocked == "True" || flag == 1) { + $("#ansyButton").attr("disabled", "disabled"); + $("#ansyButton").attr("value", "模板已锁定"); + $(".sd").hide(); + $(".lockHide").hide(); + } + +} +LockFunction(); + +var hd_isHand = $("#hd_isHand").val(); +if (hd_isHand == 0) { + $("#isHand_Py").hide(); +} +//批阅判定 +function GetZhuguantiScoreList() { + if ($("#hd_isHand").val() == "1") { + var py_tihao = ""; + var git = document.getElementById("py_tihao"); + var i = 0; + var isallPY = true; + var html = ""; + $(".zhuguanti").each(function () { + var tihaovalue = $(this).attr("tihaovalue").toUpperCase(); + //如果有分割 + + if (tihaovalue.indexOf("X") > -1) { + var mx = tihaovalue.split('X'); + if (mx[1] != 1) { + return true; + } + } + var isok = true; + + if ($(".pyti").each(function () { + if ($(this).attr("tihaovalue") == tihaovalue) { + isok = false; + } + })) + if (isok) { + if (tihaovalue.indexOf("X") > -1) { + html += ""; + } + else { + html += ""; + } + + // git.options[i] = new Option("主观题" + tihaovalue, tihaovalue); + isallPY = false; + } + i++; + }) + if (isallPY) { + $("#py_tihao").html(""); + $("#pytimups").attr("disabled", "disabled"); + } + else { + $("#py_tihao").html(html); + $("#pytimups").removeAttr("disabled"); + } + + } +} + + + +function UpdateBaseData(type, score, selectID, title) { + $("#scoreShow").hide(); + $("#dfxShow").hide(); + $("#git_fix").val(score); + $("#TiMU_num").val(selectID); + $("#TiMU_Type").val(type); + //客观题 + if (type == 1) { + $("#git_fix").val(score); + $("#scoreShow").show(); + } + if (type == 2) { + $("#git_sd_fix").val(score); + $("#dfxShow").show(); + } + $("#divbig_title").html(title + ":" + selectID) + $(".backgroundGo").show(500); +} + +function GoChange() { + var selectID = $("#TiMU_num").val(); + var type = $("#TiMU_Type").val(); + var score = $("#git_fix").val(); + var sdscore = $("#git_sd_fix").val(); + if (type == "1") { + $("#ss_" + selectID).html(score); + $("#keguan_" + selectID).attr("score", score); + } + + if (type == "2") { + if (sdscore == "0") { + //$("#ssd_" + selectID).html("半分"); + } + else { + //$("#ssd_" + selectID).html("全分"); + } + $("#ssd_" + selectID).html(sdscore); + $("#keguan_" + selectID).attr("scoretype", sdscore); + } + + + DeleteUpdateBaseData(); +} + +function DeleteUpdateBaseData() { + $(".backgroundGo").hide(500); +} + +//扩展方法 +String.prototype.trim = function (char, type) { + if (char) { + if (type == 'left') { + return this.replace(new RegExp('^\\' + char + '+', 'g'), ''); + } else if (type == 'right') { + return this.replace(new RegExp('\\' + char + '+$', 'g'), ''); + } + return this.replace(new RegExp('^\\' + char + '+|\\' + char + '+$', 'g'), ''); + } + return this.replace(/^\s+|\s+$/g, ''); +}; + +//////////// 切换页数 //////////////// +function ChangePageNum(anotherTempID) { + //if (confirm("当前页未保存,是否继续切换?")){ + var currentURL = window.location.href; + var newUrl = currentURL.replace(/(TempID=)\d+/, "$1" + anotherTempID); + window.location.href = newUrl; + //} + +} \ No newline at end of file