<div ms-controller="marketingsalesopportunities">
    <table border="0" align="center" cellpadding="0" cellspacing="0" id="mian">
        <tbody>
            <tr>
                <td width="198" height="450" valign="top" id="tdleft">
                    <!--leftNav-->
                    <div id="left" ms-widget="leftMenu">
                    </div>
                    <!--End leftNav-->
                </td>
                <td valign="top" id="right" class="addrightbg">
                    <div ms-visible="action=='list'" style="margin-bottom: 10px;">
                        <div class="boxtip" id="boxtip">
                            <h1>{{lang.SalesOpportunities}}</h1>
                            <p>{{lang.SalesOpportunitiesDepartment}}</p>
                            <!--<a href="javascript:history.go(-1)" class="btn_back"></a>-->
                        </div>
                        <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="seacrhTable">
                            <tbody>
                                <tr>
                                    <td width="460" class="searchico">
                                        <div class="input-append" style="margin-bottom: 10px;">
                                            <input type="text" class="span4" ms-duplex="queryData.key.val" ms-attr-placeholder="lang.SearchKeyWordForSalesOpportunities" ms-enter="addQuery('key',queryData.key.val,queryData.key.val)">
                                            <button class="add-on ibtsearch" type="button" id="btnsel" ms-click="addQuery('key',queryData.key.val,queryData.key.val)" style="height: 28px; font-size: 12px; padding: 3px 12px;">
                                                {{lang.SearchBtn}}
                                            </button>
                                            <button class="add-on ibtsearch clearall" type="button" ms-click="clearQuery" style="height: 28px; font-size: 12px; padding: 3px 12px;">
                                                {{lang.ShowAllBtn}}</button>
                                        </div>
                                    </td>
                                    <td class="fgray"></td>
                                </tr>
                            </tbody>
                        </table>
                        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="seacrhField">
                            <tbody>
                                <tr ms-class="quickword {{$val.hide?'hide':''}}" ms-repeat="queryData" ms-if-loop="$val.items && !$val.jump">
                                    <td ms-attr-colspan="$val.next?1:2" ms-width="$val.next?'50%':'100%'">
                                        <span>{{$val.label}}</span>
                                        <div style="display: inline;">
                                            <a ms-repeat-r='$val.items' href="javascript:void(0)" ms-click='addQuery($key, r.val, r.label)' ms-class-selected="r.curr" ms-html='r.label'></a>
                                        </div>
                                    </td>
                                    <td ms-if="$val.next" width="50%">
                                        <span>{{queryData[$val.next].label}}</span>
                                        <div style="display: inline;">
                                            <a ms-repeat-r="queryData[$val.next].items" href="javascript:void(0)" ms-click='addQuery($val.next, r.val, r.label)' ms-class-selected="r.curr" ms-html='r.label'></a>
                                        </div>
                                    </td>
                                </tr>
                                <tr ms-if="queryMore">
                                    <td colspan="2">
                                        <ul class="quickwordul">
                                            <li>
                                                <div class="quickwordmore" isshow="flase" onclick="quickwordShow()">更多选项<span class="quickdown"></span></div>
                                            </li>
                                        </ul>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2" class="seabox">
                                        <span class="first" ms-html='lang.CurrSearchCondition'></span>
                                        <div style="display: inline; float: left;" ms-repeat="queryData">
                                            <span class="searchItem" ms-if-loop='$val.valLabel'>{{$val.valLabel}}
                                        <i><a href="javascript:void(0)" ms-click='removeQuery($key)'></a></i>
                                            </span>
                                        </div>
                                        <span class="last" ms-visible='hasQuery' ms-click='clearQuery'><a href="javascript:void(0)" ms-html='lang.ClearAll'></a></span>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <div>
                            <ul class="tabWarp tlist" style="margin-top: 10px; margin-bottom: -1px;">
                                <li ms-repeat-r="listTabs" ms-class-1="{{listtab==r.val?'hover':'normal'}}" ms-click="listtabChange(r.val)">{{r.label}}</li>
                            </ul>
                        </div>
                        <table width="100%" border="0" cellspacing="1" cellpadding="0" class="tableList" id="tableList">
                            <thead>
                                <tr class="dobtn" style="background-color: rgba(0, 0, 0, 0);">
                                    <td ms-attr-colspan="grid1.colCount" bgcolor="#FFFFFF">
                                        <a ms-if="ADD" href="javascript:void(0)" class="doadd" ms-click="doadd">{{lang.AddBtn}}</a>
                                        <a ms-if="DELETE" href="javascript:void(0)" class="doalldel" ms-click="doalldel">{{lang.BtachDelBtn}}</a>
                                    </td>
                                </tr>
                                <tr class="head" style="background-color: rgba(0, 0, 0, 0);">
                                    <td width="3%" align="center">
                                        <input type="checkbox" ms-duplex-radio="grid1.checkall">
                                    </td>

                                    <td width="20%" align="center">{{lang.OpportunitiesTheme}}
                                    </td>
                                    <td width="10%" align="center" ms-if="grid1.showCustomer">{{lang.Customer}}
                                    </td>
                                    <td width="10%" align="center">{{lang.CustomerSource}}
                                    </td>
                                    <td width="6%" align="center">{{lang.OpportunitiesState}}
                                    </td>
                                    <td width="6%" align="center">{{lang.OpportunitiesFollow}}
                                    </td>
                                    <td width="7%" align="center">{{lang.DiscoverDate}}
                                    </td>
                                    <td width="7%" align="center">{{lang.ExpectSigningDate}}
                                    </td>
                                    <td width="6%" align="center">{{lang.Operate}}
                                    </td>
                                </tr>
                            </thead>
                            <tbody ms-each-item="grid1.list">
                                <tr style="background: #FFF;">
                                    <td align="center">
                                        <input type="checkbox" ms-duplex-radio="item.checked">
                                    </td>
                                    <td align="left">
                                        <span ms-if="item.Isoffer==true">
                                            <a ms-if="showindex == $index" href="javascript:void(0);" class="notexpand" title="展开更多信息" ms-click="showmore($index,item.Id)">&nbsp;</a>
                                            <a ms-if="showindex != $index" href="javascript:void(0);" class="expand" title="展开更多信息" ms-click="showmore($index,item.Id)"></a>
                                        </span>
                                        <a href="javascript:void(0)" ms-click="doview(item.Id)">{{item.Title}}</a>
                                    </td>
                                    <td align="left" ms-if="grid1.showCustomer">
                                        <a href='javascript:void(0)' ms-click="viewCustomer(item.Customer)" ms-title='item.CustomerDisplay'>{{item.CustomerDisplay|truncate(20,'...')}}
                                        </a>
                                    </td>
                                    <td align="left">{{item.CustomerSourceDisplay}}
                                    </td>
                                    <td align="center">
                                        <span ms-if="item.State==10301">{{item.StateDisplay}}</span>
                                        <span ms-if="item.State==10302" style="color: green;">{{item.StateDisplay}}</span>
                                        <span ms-if="item.State==10303 || item.State==10304 || item.State ==10305" style="color: #c3c0c0;">{{item.StateDisplay}}</span>
                                    </td>
                                    <td align="center">
                                        <a href="javascript:void(0);" ms-text="item.OpportunitiesFollowDisplay" ms-widget='userCard' ms-data-userid="item.OpportunitiesFollow"></a>
                                    </td>
                                    <td align="center">{{item.DiscoverDate | truncate(10,'')}}
                                    </td>
                                    <td align="center">{{item.ExpectSigningDate | truncate(10,'')}}
                                    </td>
                                    <td align="center">
                                        <a href="javascript:void(0)" class="doview" ms-click="doview(item.Id)" ms-title="lang.ViewBtn"></a>
                                        <a ms-if="item.EDIT" href="javascript:void(0)" class="doedit" ms-click="doedit(item.Id)" ms-title="lang.EditBtn"></a>
                                        <a ms-if="!item.EDIT" href="javascript:void(0)" class="noedit" ms-title="lang.EditBtn"></a>
                                        <a ms-if="item.DELETE" href="javascript:void(0)" class="dodel" ms-click="dodel(item.Id)" ms-title="lang.DelBtn"></a>
                                        <a ms-if="!item.DELETE" href="javascript:void(0)" class="nodel" ms-title="lang.DelBtn"></a>
                                    </td>
                                </tr>
                                <tr ms-if="showindex == $index" style="background: #FFF;">
                                    <td ms-attr-colspan="grid1.colCount">
                                        <div class="Tab_box">
                                            <i></i>
                                            <dl ms-repeat-con="decumentaryofferlist">
                                                <dt><strong  ms-widget='userCard' ms-data-userid="con.DocumentaryEmployee">{{con.DocumentaryEmployeeDisplay}}</strong><span>{{con.OfferDate}}</span>
                                                    <a ms-click="viewOffer(con.Id,item.Id)" href='javascript:void(0);'>
                                                        <b></b>
                                                        {{con.CommentCount}}
                                                    </a>
                                                    <div class="clear"></div>
                                                </dt>
                                                <dd>
                                                    <a href='javascript:void(0);' ms-click="viewOffer(con.Id,item.Id)">
                                                        <strong>{{con.Title}}</strong><span ms-class="{{con.IsSign?'acceses':'unacceses'}}"></span>
                                                        <div class="clear"></div>
                                                        <font>{{con.ReportSummry}}</font>
                                                    </a>
                                                </dd>
                                            </dl>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                            <tfoot>
                                <tr ms-if="grid1.gridmsg">
                                    <td ms-attr-colspan="grid1.colCount" class="gridmsg">{{grid1.gridmsg|html}}</td>
                                </tr>
                                <tr>
                                    <td ms-attr-colspan="grid1.colCount" ms-widget='paging' data-gridid="grid1"></td>
                                </tr>
                            </tfoot>
                        </table>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>

    <!-- 新增或者修改--->
    <noscript type="text/avalon" id="saleformTemplate">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="commontable shortSelect">
            <tbody>
                <tr>
                    <th width="80">{{lang.BelongToCampaign}}：
                    </th>
                    <td width="360">
                        <input type="hidden" ms-duplex="entity.MarketingCampaign" />
                        <input type="text" ms-duplex="entity.MarketingCampaignDisplay" readonly="readonly">
                        <button type="button" class="myfbt" ms-click="selectCampaign">
                            <i class="customer"></i>
                        </button>
                        <div ms-visible="campaignPanel" class="dropdownPanel" style="width: 610px; position: absolute;" ms-mousedown="mousedownstop">
                            <div>
                                <div class="boxTitlenob" style="margin-left: 0;">
                                    <h2>
                                        <span class="rseachbox">
                                            <input style="margin-bottom: 0px;" ms-duplex="campaignKey" type="text">
                                            <button type="button" class="inputbt" ms-click="searchCampaign">
                                            </button>
                                        </span>
                                        <span style="float: right">
                                            <button type="button" ms-click="closeCampaignPanel">{{lang.Close}}</button>
                                            <button type="button" ms-click="clearCampaignValue">清空</button>
                                        </span>
                                    </h2>
                                </div>
                                <div style="height: 200px; overflow: auto; background-color: rgb(255, 255, 255);">
                                    <table width="100%" align="center" border="0" cellspacing="1" cellpadding="0" class="tableList">
                                        <thead>
                                            <tr class="head">
                                                <td width="20%" align="center">{{lang.CampaignTitle}}</td>
                                                <td width="8%" align="center">{{lang.CampaignType}}</td>
                                                <td width="10%" align="center">{{lang.StartDate}}</td>
                                                <td width="10%" align="center">{{lang.EndDate}}</td>
                                                <td width="7%" align="center">{{lang.CampaignSponsor}}</td>
                                            </tr>
                                        </thead>
                                        <tbody ms-each-item="campaignList">
                                            <tr style="background-color: rgb(255, 255, 255); cursor: pointer;" ms-live-click="clickCampaign" ms-attr-key="item.Id" ms-attr-alt="item.CampaignTheme" title="点击选择">
                                                <td align="center">{{item.CampaignTheme}}
                                                </td>
                                                <td align="center">{{item.CampaignTypeDisplay}}
                                                </td>
                                                <td align="center">{{item.StartDate | truncate(10,'')}}
                                                </td>
                                                <td align="center">{{item.EndDate | truncate(10,'')}}
                                                </td>
                                                <td align="center">{{item.CampaignSponsorDisplay}}
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </td>
                    <th width="80">{{lang.BelongToActivity}}：
                    </th>
                    <td width="*">
                        <input type="hidden" ms-duplex="entity.MarketActivity" />
                        <input type="text" ms-duplex="entity.MarketActivityDisplay" readonly="readonly">
                        <button type="button" class="myfbt" ms-click="selectActivity">
                            <i class="customer"></i>
                        </button>
                        <div ms-visible="activityPanel" class="dropdownPanel" style="width: 610px; right: 80px; position: absolute;" ms-mousedown="mousedownstop">
                            <div>
                                <div class="boxTitlenob" style="margin-left: 0;">
                                    <h2>
                                        <span class="rseachbox">
                                            <input style="margin-bottom: 0px;" ms-duplex="activityKey" type="text">
                                            <button type="button" class="inputbt" ms-click="searchActivity">
                                            </button>
                                        </span>
                                        <span style="float: right">
                                            <button type="button" ms-click="closeActivityPanel">{{lang.Close}}</button>
                                            <button type="button" ms-click="clearActivityValue">清空</button>
                                        </span>
                                    </h2>
                                </div>
                                <div style="height: 200px; overflow: auto; background-color: rgb(255, 255, 255);">
                                    <table width="100%" align="center" border="0" cellspacing="1" cellpadding="0" class="tableList">
                                        <thead>
                                            <tr class="head">
                                                <td width="20%" align="center">{{lang.ActivityTheme}}</td>
                                                <td width="8%" align="center">{{lang.ActivityType}}</td>
                                                <td width="15%" align="center">{{lang.ConscientiousPerson}}</td>
                                                <td width="8%" align="center">{{lang.CostBudget}}</td>
                                                <td width="10%" align="center">{{lang.DiscountType}}</td>
                                                <td width="15%" align="center">{{lang.StartDate}}</td>
                                                <td width="15%" align="center">{{lang.EndDate}}</td>
                                            </tr>
                                        </thead>
                                        <tbody ms-each-item="activityList">
                                            <tr style="background-color: rgb(255, 255, 255); cursor: pointer;" ms-live-click="clickActivity" ms-attr-key="item.Id" ms-attr-alt="item.ActivityTheme" title="点击选择">
                                                <td style="height: 30px;" align="center">{{item.ActivityTheme}}
                                                </td>
                                                <td style="height: 30px;" align="center">{{item.ActivityTypeDisplay}}
                                                </td>
                                                <td style="height: 30px;" align="center">{{item.ConscientiousPersonDisplay}}
                                                </td>
                                                <td style="height: 30px;" align="right">{{item.CostBudget}}
                                                </td>
                                                <td style="height: 30px;" align="center">{{item.DiscountType}}
                                                </td>
                                                <td style="height: 30px;" align="center">{{item.StartDate|truncate(10,'')}}
                                                </td>
                                                <td style="height: 30px;" align="center">{{item.EndDate|truncate(10,'')}}
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th>客户：</th>
                    <td>
                        <input type="text" ms-duplex="entity.CustomerDisplay" readonly="readonly">
                        <button  ms-if="grid1.showCustomer" id="btnSelectCustomerContact" class="myfbt" type="button" ms-click="selectCustomer">
                            <i class="customer"></i>
                        </button>
                        <span class="must">*</span>
                    </td>
                    <th>客户联系人：
                    </th>
                    <td>
                        <input type="text" ms-duplex="entity.CustomerContactDisplay" style="width: 90px;">
                        <select style="width: 100px;" ms-change="contactChange">
                            <option value="">选择联系人</option>
                            <option ms-repeat-con="CustomerContactData" ms-value="con.Id">{{con.Name}}</option>
                        </select>
                        <span class="must">*</span>
                        <a href="javascript:void(0);" ms-click="addContact()" class="acolor">+新增联系人</a>
                    </td>
                </tr>
                <tr>
                    <th>{{lang.OpportunitiesTheme}}：
                    </th>
                    <td>
                        <input type="text" ms-duplex="entity.Title" style="width: 236px;" id="title">
                        <span class="must">*</span>
                    </td>
                    <th>{{lang.OpportunitiesSource}}：
                    </th>
                    <td>
                        <select ms-duplex="entity.CustomerSource" style="width: 110px;" ms-each-item="customersourcedata">
                            <option ms-value="item.Id">{{item.Data}}</option>
                        </select>
                        <span class="helptip" title="机会来源在 [数据字典]-[客户]-[客户来源]里面设置"></span>
                    </td>
                </tr>
                <tr>
                    <th>签单可能性：
                    </th>
                    <td ms-widget='processbar,hotprocessbar,hotOpts'></td>
                    <th>机会提供人：
                    </th>
                    <td>
                        <input type="text" ms-duplex="entity.InfoProvider" style="width: 140px">
                    </td>
                </tr>
                <tr>
                    <th>预签单日期：
                    </th>
                    <td>
                        <input type="text" ms-duplex="entity.ExpectSigningDate" style="width: 90px;" readonly="readonly" ms-widget="date,expectsigningdate,expectsigningdateOpts">
                    </td>
                    <th>预签金额：
                    </th>
                    <td>
                        <div class="input-append">
                            <input type="text" ms-duplex="entity.ExpectAmount" style="width: 113px">
                            <span class="add-on">{{lang.Yuan}}</span>
                            <span class="must">*</span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th>{{lang.FollowStage}}：
                    </th>
                    <td colspan="3" style="height: 80px;" ms-widget='followStage,followStage,stageOpts'></td>
                </tr>
                <tr>
                    <th>跟单标签：
                    </th>
                    <td colspan="3" style="padding-bottom: 5px;">
                        <label ms-repeat-item="followservertagdata">
                            <input type="checkbox" ms-duplex="entity.FollowServerTag" ms-value="item.Id">{{item.Data}}&nbsp;</label>
                    </td>
                </tr>
                <tr>
                    <th>机会描述：
                    </th>
                    <td colspan="3">
                        <textarea id="salesCustomerDemand" rows="5" cols="10" style="width: 100%; height: 60px;" ms-duplex="entity.CustomerDemand"></textarea>
                    </td>
                    <!--<th>{{lang.Remark}}：
                    </th>
                    <td>
                        <textarea rows="5" cols="10" style="width: 300px; height: 60px" ms-duplex="entity.Remark"></textarea>
                    </td>-->
                </tr>
                <tr>
                    <th>附件：</th>
                    <td>
                        <span ms-if="entity.AttachmentPath">{{entity.AttachmentName}}<a ms-click="delAtta()" href="javascript:void(0)" class="dodel" title="移除附件"></a> </span>
                        <button type="button" class="btnsimple" ms-click="uploadAtta()">
                            上传附件
                        </button>
                    </td>
                    <th>{{lang.OpportunitiesState}}：
                    </th>
                    <td>
                        <label ms-repeat-item="opportunitiesstatedata">
                            <input class="State" type="radio" ms-duplex-text="entity.State" ms-value="item.Id" ms-change="stateChange(item)" style="margin-right: 1px;">{{item.Data}}</label>
                    </td>
                </tr>
                <tr>
                    <th>{{lang.OpportunitiesFollow}}：
                    </th>
                    <td>
                        <input type="text" ms-duplex="entity.OpportunitiesFollowDisplay" readonly="readonly" style="width: 90px;" />
                        <button type="button" class="myfbt" ms-click="selectopportunitiesFollow()"><i class="iadduser"></i></button>
                    </td>
                    <th>发现时间：
                    </th>
                    <td>
                        <input type="text" ms-duplex="entity.DiscoverDate" style="width: 140px" ms-widget="date,discoverdate,discoverdateOpts">
                        <span class="must">*</span>
                    </td>
                </tr>
            </tbody>
        </table>
    </noscript>
</div>
