<%@ Page Language="C#" %>
<%@ Register TagPrefix="aspxform" Namespace="XFormDesigner.Framework.Web.UI" Assembly="XFormDesigner.Framework" %>
<script runat="server">

    // Insert page code here
    //

</script>
<html xmlns:XForm="xmlns:xform">
<head runat="server">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
      <link href="/Oimec/Styles/css/StyleSheet.css" rel="stylesheet" type="text/css" />
    <title>BPM Form</title>
    <style>
    BODY {FONT-SIZE: 12px; FONT-FAMILY: verdana}
    TABLE {border-collapse: collapse; FONT-SIZE: 12px; FONT-FAMILY: verdana}
    P {PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px; FONT-SIZE: 12px; FONT-FAMILY: verdana}
    TD {padding:1px}
    TD.NoPadding {PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px}
    /*INPUT {height: 15px}*/
    INPUT.UL {BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: #33ff33 1px solid}
    TEXTAREA {FONT-SIZE:12px}
    input {vertical-align:middle;/*margin-right:-3px*/}
    </style>

    <script>

        //提交事件
        agent.on('beforeSubmit', function () {
            var aDivquestionType = document.getElementsByName("questionType");//问题类型

            var aDivMultiChoiceRestriction = document.getElementsByName("MultiChoiceRestriction");//多选限制
            var aDivtb = document.getElementsByName("tb");
            
            for (var i = 0; i < aDivMultiChoiceRestriction.length; i++) {
                //多选限制
                var divMultiChoiceRestriction = aDivMultiChoiceRestriction[i];
                 var idMultiChoiceRestriction = divMultiChoiceRestriction.getElementsByTagName('select')[0].id;
                 var vMultiChoiceRestriction = document.getElementById(idMultiChoiceRestriction).value;

                //问题类型
                 var divquestionType = aDivquestionType[i];
                 var idquestionType = divquestionType.getElementsByTagName('input')[0].name;
                 var vquestionType = checkedVaule(idquestionType);

                 var divtb = aDivtb[i];
                 var tr = divtb.getElementsByTagName("tr");
                 if (vquestionType == "2" && vMultiChoiceRestriction!="不限") {//多选
                 
                     var trlen = tr.length - 1;
                     
                     if (vMultiChoiceRestriction > trlen) {
                         var ii = i + 1;
                         Ext.MessageBox.alert("提示", "问题第" + ii + "行,多选限制" + vMultiChoiceRestriction + "不能大于问题选项条数" + trlen + "");
                         return false;
                     }
                 }
                 
            }
          

        });

        function onchange_questionType()
        {
            //alert("AAA");
            //MultiChoiceRestriction
           // agent.Eles[document.getElementById("MultiChoiceRestriction").getAttribute("xform_xele_index")].setValue("");
        }

        //根据问题类型 清空多选限制
        function getMultiChoiceRestriction(questionType, MultiChoiceRestriction) {

            if (questionType == "2" && MultiChoiceRestriction == "必填" && MultiChoiceRestriction == "不必填") {
                return "";
            }
            if (questionType == "3" && MultiChoiceRestriction != "必填" && MultiChoiceRestriction != "不必填") {
                return "";
            }

        }


        //循环问题信息，问题类型为“问答”时，删除对应选项值
        function deleteOptions()
        {

            var tableQ = document.getElementById("tab_Question");
            for (var i = 2; i < tableQ.rows.length - 1; i++) {

            }
        }

        //单选获取选中的值
        function checkedVaule(name) {
            var obj = document.getElementsByName(name);
            for (var i = 0; i < obj.length; i++) {
                if (obj[i].checked) {
                    return obj[i].value;
                }
            }

        }


    </script>
</head>
<body>
    <form runat="server">
        <!-- Insert content here -->
        <table width="1250" align="center" class="head" border="0" cellspacing="0" cellpadding="0">
            <tbody>
                <tr>
                    <td class="logo">
                    </td>
                    <td class="biaoti" style="PADDING-LEFT: 30px">
                        <asp:Label id="Label1" runat="server" text="问卷信息"></asp:Label></td>
                    <td class="formno">
                         <asp:Label id="Label16" runat="server" text="表单号"></asp:Label>
                        <aspxform:XLabel id="XLabel3" runat="server" text="--系统自动生成--" XDataBind="DF_OA_QuestionnaireInfo.FormNo" BackColor="#8AB3DF" ValueToDisplayText Value></aspxform:XLabel>
                    </td>
                </tr>
            </tbody>
        </table>
        <br />
        <table width="1300" style="width:1250px;" align="center" class="table" border="0" cellspacing="0" cellpadding="0">
            <tbody>
                <tr class="title1">
                    <td height="21" colspan="4">
                        <asp:Label id="Label2" runat="server" text="基本信息"></asp:Label>
                        <aspxform:XTextBox id="XTextBox2" runat="server" HiddenInput="True" XDataBind="state" width="50px" BorderColor="#DCDCDC" BorderWidth="1"></aspxform:XTextBox>
                        <aspxform:XTextBox id="XTextBox3" runat="server" HiddenInput="True" XDataBind="DF_OA_QuestionnaireInfo.Id" width="50px" BorderColor="#DCDCDC" BorderWidth="1"></aspxform:XTextBox>
                    </td>
                </tr>
                <tr>
                    <td width="131" height="21" class="tsbottomlabel">
                        <asp:Label id="Label4" runat="server" text="操作人"></asp:Label>
                        <aspxform:XTextBox id="XTextBox1" runat="server" HiddenInput="True" XDataBind="DF_OA_QuestionnaireInfo.operatorId" width="20px" BorderColor="#DCDCDC" BorderWidth="1"></aspxform:XTextBox>
                    </td>
                    <td width="465" class="tsbottomtext">
                        <aspxform:XLabel id="XLabel2" runat="server" XDataBind="DF_OA_QuestionnaireInfo.operatorName" BackColor="#D4E4FE" ValueToDisplayText></aspxform:XLabel>
                    </td>
                    <td width="131" class="tsbottomlabel">
                        <asp:Label id="Label5" runat="server" text="创建日期"></asp:Label></td>
                    <td width="465" class="tsbottomtext">
                        <aspxform:XDateTimePicker id="XDateTimePicker1" runat="server" XDataBind="DF_OA_QuestionnaireInfo.createDate" BorderColor="#DCDCDC" BorderWidth="1" DisplayOnly="True" Width="300px" BackColor="#D4E4FE"></aspxform:XDateTimePicker>
                    </td>
                </tr>
                <tr>
                    <td height="23" class="tsbottomlabel">
                        <asp:Label id="Label10" runat="server" text="*" forecolor="Red"></asp:Label>&nbsp;<asp:Label id="Label3" runat="server" text="问卷标题"></asp:Label></td>
                    <td class="tsbottomtext" colspan="3">
                       
                        <aspxform:XDropDownList id="title" XDataSource="TableName:DF_OA_Questionnaire_QuestionCategoryOFF;Filter:CreateAccount->DF_OA_QuestionnaireInfo.operatorId" runat="server" HiddenInput="False" XDataBind="DF_OA_QuestionnaireInfo.questionnaireTitle" width="35%" BorderColor="Gainsboro" BorderWidth="1px" Max="0" Min="0" ValueToDisplayText Height="30px" DataMap="Id->DF_OA_QuestionnaireInfo.questionnaireID;" ValueColumn="questionnaireTitle" DisplayColumn="questionnaireTitle" PromptText="--请选择--"></aspxform:XDropDownList>
                    <aspxform:XTextBox runat="server" HiddenExpress="1" Width="100px" XDataBind="DF_OA_QuestionnaireInfo.questionnaireID"></aspxform:XTextBox>
                    </td>
                </tr>
            </tbody>
        </table>
        <br />
        <table width="1250" align="center" id="tab_Question" border="0" cellspacing="0" cellpadding="0" dynamicarea="2,1">
            <tbody>
                <tr class="title1">
                    <td width="1250" height="16" colspan="7">
                        <asp:Label id="Label6" runat="server" text="问题信息"></asp:Label></td>
                </tr>
                <tr align="center">
                    <td width="56" height="16" class="tds">
                        <asp:Label id="Label27" runat="server" text="序号"></asp:Label></td>
                    <td width="112" class="tds">
                        <asp:Label id="Label14" runat="server" text="*" forecolor="Red"></asp:Label><asp:Label id="Label11" runat="server" text="问题类型"></asp:Label></td>
                    <td width="112" class="tds">
                        <asp:Label id="Label12" runat="server" text="*" forecolor="Red"></asp:Label><asp:Label id="Label15" runat="server" text="问题分类"></asp:Label></td>
                    <td width="440" class="tds">
                        <asp:Label id="Label13" runat="server" text="*" forecolor="Red"></asp:Label>&nbsp;<asp:Label id="Label30" runat="server" text="问题内容"></asp:Label></td>
                    <td width="346" class="tds">
                        &nbsp;<asp:Label id="Label7" runat="server" text="问题选项"></asp:Label></td>
                     <td width="60" class="tds">
                        &nbsp;<asp:Label id="Label17" runat="server" text="多选限制"></asp:Label></td>
                    <td width="170" class="tds" hidden="hidden">
                        <asp:Label id="Label33" runat="server" text="考题答案"></asp:Label></td>
                </tr>
                <tr>
                    <td height="80" align="center" class="tds1">
                        <aspxform:XGridLineNo id="XGridLineNo1" runat="server" XDataBind="DF_OA_ExaminationQuestionInfo.QuestionsID" BorderWidth="1" BackColor="#e9f1f4" Width="100%" BorderStyle="None" TextAlign="Center">1</aspxform:XGridLineNo>
                    </td>
                    <td class="tds1">
                        <div onchange="onchange_questionType()">
                            <aspxform:XRadioButtonList id="questionType" name="questionType" runat="server" XDataBind="DF_OA_Questionnaire_QuestionInfo.questionType" RepeatDirection="Horizontal">
                                <asp:ListItem Value="1">单选</asp:ListItem>
                                <asp:ListItem Value="2">多选</asp:ListItem>
                                <asp:ListItem Value="3">问答</asp:ListItem>
                            </aspxform:XRadioButtonList>
                        </div>
                    </td>
                    <td align="left" class="tds1">
                        <aspxform:XDropDownList id="category" name="category" runat="server" XDataBind="DF_OA_Questionnaire_QuestionInfo.questionCategoryId" Width="100%" XDataSource="TableName:DF_OA_Questionnaire_QuestionCategory;Filter:CategoryOFFID->DF_OA_QuestionnaireInfo.questionnaireID" DisplayColumn="categoryName" ValueColumn="Id" PromptText="--请选择--"></aspxform:XDropDownList>
                    </td>
                    <td align="left" class="tds1">
                        <aspxform:XTextBox id="questionContent" runat="server" HiddenInput="False" XDataBind="DF_OA_Questionnaire_QuestionInfo.questionContent" BorderColor="Gainsboro" BorderWidth="1px" Max="0" Min="0" ValueToDisplayText Width="100%" Height="100%" TextAlign="left" Rows="2" TextMode="MultiLine"></aspxform:XTextBox>
                    </td>
                    <td class="tds1">
                        <table width="100%" name="tb" height="70" border="0" cellspacing="0" cellpadding="0" dynamicarea="1,1" hiddenexpress='DF_OA_Questionnaire_QuestionInfo.questionType!="1" &amp;&amp; DF_OA_Questionnaire_QuestionInfo.questionType!="2" '>
                            <tbody>
                                <tr align="center" class="tds1">
                                    <td width="15%" class="tds">
                                        <asp:Label id="Label8" runat="server" text="选项编号"></asp:Label></td>
                                    <td width="85%" class="tds">
                                        <asp:Label id="Label9" runat="server" text="选项内容"></asp:Label></td>
                                </tr>
                                <tr>
                                    <td align="center" class="tds1">
                                        <aspxform:XDropDownList id="XDropDownList1" name="optionId" runat="server" XDataBind="DF_OA_Questionnaire_QuestionOptions.optionId" Width="80px">
                                            <asp:ListItem Selected="True">A</asp:ListItem>
                                            <asp:ListItem>B</asp:ListItem>
                                            <asp:ListItem>C</asp:ListItem>
                                            <asp:ListItem>D</asp:ListItem>
                                            <asp:ListItem>E</asp:ListItem>
                                            <asp:ListItem>F</asp:ListItem>
                                              <asp:ListItem>G</asp:ListItem>
                                              <asp:ListItem>H</asp:ListItem>
                                              <asp:ListItem>I</asp:ListItem>
                                              <asp:ListItem>J</asp:ListItem>
                                              <asp:ListItem>K</asp:ListItem>
                                              <asp:ListItem>L</asp:ListItem>
											   <asp:ListItem>M</asp:ListItem>
											     <asp:ListItem>N</asp:ListItem>
												  <asp:ListItem>O</asp:ListItem>
												    <asp:ListItem>P</asp:ListItem>
													  <asp:ListItem>Q</asp:ListItem>
													    <asp:ListItem>R</asp:ListItem>
														   <asp:ListItem>S</asp:ListItem>
														      <asp:ListItem>T</asp:ListItem>
															    <asp:ListItem>U</asp:ListItem>
																<asp:ListItem>V</asp:ListItem>
																<asp:ListItem>W</asp:ListItem>
																<asp:ListItem>X</asp:ListItem>
																<asp:ListItem>Y</asp:ListItem>
																<asp:ListItem>Z</asp:ListItem>
                                        </aspxform:XDropDownList>
                                    </td>
                                    <td align="left" class="tds1">
                                        <aspxform:XTextBox id="optionContent" runat="server" XDataBind="DF_OA_Questionnaire_QuestionOptions.optionContent" BorderColor="#DCDCDC" BorderWidth="1" Width="100%" TextAlign="left" TextMode="MultiLine"></aspxform:XTextBox>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                     <td align="left" class="tds1">
                        <aspxform:XDropDownList id="MultiChoiceRestriction" name="MultiChoiceRestriction" runat="server" XDataBind="DF_OA_Questionnaire_QuestionInfo.MultiChoiceRestriction" PromptText="--请选择--" Express="javascript('getMultiChoiceRestriction',DF_OA_Questionnaire_QuestionInfo.questionType,DF_OA_Questionnaire_QuestionInfo.MultiChoiceRestriction)"  hiddenexpress='DF_OA_Questionnaire_QuestionInfo.questionType!="2"&& DF_OA_Questionnaire_QuestionInfo.questionType!="3"'>
                            <asp:ListItem hiddenexpress=' DF_OA_Questionnaire_QuestionInfo.questionType!="2" '>不限</asp:ListItem>
                             <asp:ListItem hiddenexpress=' DF_OA_Questionnaire_QuestionInfo.questionType!="2" '>1</asp:ListItem>
                            <asp:ListItem hiddenexpress=' DF_OA_Questionnaire_QuestionInfo.questionType!="2" '>2</asp:ListItem>
                             <asp:ListItem hiddenexpress=' DF_OA_Questionnaire_QuestionInfo.questionType!="2" '>3</asp:ListItem>
                             <asp:ListItem hiddenexpress=' DF_OA_Questionnaire_QuestionInfo.questionType!="2" '>4</asp:ListItem>
                             <asp:ListItem hiddenexpress=' DF_OA_Questionnaire_QuestionInfo.questionType!="2" '>5</asp:ListItem>
                             <asp:ListItem hiddenexpress=' DF_OA_Questionnaire_QuestionInfo.questionType!="2" '>6</asp:ListItem>
                             <asp:ListItem hiddenexpress=' DF_OA_Questionnaire_QuestionInfo.questionType!="2" '>7</asp:ListItem>
                             <asp:ListItem hiddenexpress=' DF_OA_Questionnaire_QuestionInfo.questionType!="2" '>8</asp:ListItem>
                             <asp:ListItem hiddenexpress=' DF_OA_Questionnaire_QuestionInfo.questionType!="3" '>必填</asp:ListItem>
                             <asp:ListItem hiddenexpress=' DF_OA_Questionnaire_QuestionInfo.questionType!="3" '>不必填</asp:ListItem>
                        </aspxform:XDropDownList>
                    <td align="center" class="tds1" hidden="hidden">
                        <aspxform:XTextBox id="XTextBox15" runat="server" XDataBind="DF_OA_Questionnaire_QuestionInfo.questionAnswer" BorderColor="#DCDCDC" BorderWidth="1" Width="100%" TextAlign="Center" Express='if(DF_OA_Questionnaire_QuestionInfo.questionType=="3","",DF_OA_Questionnaire_QuestionInfo.questionAnswer)'></aspxform:XTextBox>
                    </td>
                </tr>
            </tbody>
        </table>
        <aspxform:XRequiredFieldValidator id="XRequiredFieldValidator1" runat="server" Display="None" ForeColor="Red" ErrorMessage="请填写问卷标题" ControlToValidate="title">请填写问卷标题</aspxform:XRequiredFieldValidator>
        &nbsp; 
        <aspxform:XRequiredFieldValidator id="XRequiredFieldValidator2" runat="server" Display="None" ForeColor="Red" ErrorMessage="请选择问题类型" ControlToValidate="questionType">请选择问题类型</aspxform:XRequiredFieldValidator>
        &nbsp;<aspxform:XRequiredFieldValidator id="XRequiredFieldValidator5" runat="server" Display="None" ForeColor="Red" ErrorMessage="请选择问题分类" ControlToValidate="category">请选择问题分类</aspxform:XRequiredFieldValidator>
        &nbsp;<aspxform:XRequiredFieldValidator id="XRequiredFieldValidator3" runat="server" Display="None" ForeColor="Red" ErrorMessage="请填写问题内容" ControlToValidate="questionContent">请填写问题内容</aspxform:XRequiredFieldValidator>
        &nbsp;<aspxform:XRequiredFieldValidator id="XRequiredFieldValidator4" runat="server" Display="None" ForeColor="Red" ErrorMessage="请填写选项" ControlToValidate="optionContent" DisableExpress="DF_OA_Questionnaire_QuestionInfo.questionType!=1 &amp;&amp; DF_OA_Questionnaire_QuestionInfo.questionType!=2">请填写选项</aspxform:XRequiredFieldValidator>
         &nbsp;<aspxform:XRequiredFieldValidator id="XRequiredFieldValidator6" runat="server" Display="None" ForeColor="Red" ErrorMessage="请选择多选限制" ControlToValidate="MultiChoiceRestriction" DisableExpress="DF_OA_Questionnaire_QuestionInfo.questionType!=2&& DF_OA_Questionnaire_QuestionInfo.questionType!=3">请选择多选限制</aspxform:XRequiredFieldValidator>
    </form>
</body>
</html>
