productEdit.jsp 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260
  1. <%@ page import="com.thinkgem.jeesite.common.config.Global" %>
  2. <%@ taglib prefix="input" uri="/struts-tags" %>
  3. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  4. <%@ include file="/WEB-INF/views/include/taglib.jsp"%>
  5. <html>
  6. <head>
  7. <title>编辑商品</title>
  8. <meta name="decorator" content="default"/>
  9. <style>
  10. .red{color:red;}
  11. .blue{color:rgb(0, 100, 180);}
  12. #inputForm{max-width: 1200px;width: 100%;}
  13. #inputForm table{width:100%;line-height:18px;margin-bottom:50px;}
  14. #inputForm th,#inputForm td{ font-weight: normal; text-align: left; padding: 8px 5px; border-bottom: 1px solid rgb(238, 238, 238); }
  15. #inputForm th{width:15%;text-align:right;white-space:nowrap;font-weight:bold;}
  16. #inputForm td input[type="text"]{width:320px;height:16px; line-height:16px; }
  17. #inputForm td input.short{width:110px;}
  18. #inputForm td b.line{margin:0 15px 0 20px;font-weight:normal}
  19. #allAreaInput {padding: 10px 0 0 100px;}
  20. #inputForm .item{line-height:28px;}
  21. #ladderPriceBox{border-top:1px solid rgb(238, 238, 238);margin-top:8px;padding-top:8px;}
  22. #ladderPriceBox>div {margin-bottom: 5px;}
  23. .priceIcon:before{content:'\2729';color: #aaa;font-size: 18px;font-style:normal;}
  24. .priceIcon.full:before{content:'\272E';color: #ffbd14;}
  25. #slider{width:335px;}
  26. .skword input{margin:2px 0;}
  27. .skword p{margin: 2px 0;}
  28. .params input{margin:2px 0;}
  29. .tags input{margin:2px 0;}
  30. #tagsList{margin: 2px 0;display: none;width:600px;}
  31. .tags-li{margin:10px;display: inline-block;padding: 5px 10px;line-height: 16px;text-align: center;position: relative;font-size: 12px;border: 1px solid #EBEBEB;border-radius: 4px;}
  32. .tags-li i{font-style: normal;line-height: 20px;display: block;position: absolute;width: 16px;height: 16px;text-align: center;background: rgba(0,0,0,0.2);border-radius: 50%;top: -8px;right:-7px;cursor: pointer;}
  33. .tags-li .tags-s{background: #FFF;width: auto !important;outline:none;border:none;}
  34. </style>
  35. </head>
  36. <body>
  37. <ul class="nav nav-tabs">
  38. <li><a href="${ctx}/product/new/list">商品信息列表</a></li>
  39. <li class="active"><a href="${ctx}/product/new/productEdit?id=${product.id}">商品信息编辑</a></li>
  40. </ul>
  41. <form:form id="inputForm" modelAttribute="product" action="${ctx}/product/new/productSave?searchName=${product.searchName}&searchShopID=${product.searchShopID}&searchShopName=${product.searchShopName}&searchBigTypeID=${product.searchBigTypeID}&searchSmallTypeID=${product.searchSmallTypeID}&searchTinyTypeID=${product.searchTinyTypeID}&searchValidFlag=${product.searchValidFlag}&searchActStatus=${product.searchActStatus}&searchProductType=${product.searchProductType}&searchBrandID=${product.searchBrandID}&searchPreferredFlag=${product.searchPreferredFlag}&searchProductCategory=${product.searchProductCategory}&editFlag=${product.editFlag}" method="post" class="form-horizontal">
  42. <form:hidden path="id"/>
  43. <sys:message content="${message}"/>
  44. <table border="0" cellspacing="0" cellpadding="0" width="100%">
  45. <tr><th><b class="blue">商品基本信息:</b></th><td colspan="3"></td></tr>
  46. <tr>
  47. <th><span class="red">*</span>商品显示名:</th>
  48. <td colspan="3">
  49. <form:input path="name" maxlength="100" onchange="checkmaxlength(this.value)" class="input-small required"/>
  50. <span>
  51. <span style="font-weight: bold;">商品编码:</span>
  52. <span><form:input path="productCode" maxlength="100"/></span>
  53. </span>
  54. </td>
  55. </tr>
  56. <tr>
  57. <th><span class="red">*</span>内部商品名:</th>
  58. <td colspan="3">
  59. <form:input path="aliasName" maxlength="100" onchange="checkmaxlength(this.value)" class="input-small required"/>
  60. <span>
  61. <span style="font-weight: bold;">商品备注:</span>
  62. <span><form:input path="productRemarks" maxlength="60" onchange="checkmaxlengths(this.value,60)" class="input-small"/></span>
  63. </span>
  64. </td>
  65. </tr>
  66. <tr>
  67. <th>搜索关键字:</th>
  68. <td colspan="3" class="skword">
  69. <form:input path="searchKeyList[0]" maxlength="32" placeholder="建议输入品牌关键词" onchange="checkmaxlengthsBySearch(this,this.value,32)" class="input-small"/>
  70. <form:input path="searchKeyList[1]" maxlength="32" placeholder="建议输入商品学名关键词" onchange="checkmaxlengthsBySearch(this,this.value,32)" class="input-small"/>
  71. <form:input path="searchKeyList[2]" maxlength="32" placeholder="建议输入商品别名/市场称呼关键词" onchange="checkmaxlengthsBySearch(this,this.value,32)" class="input-small"/>
  72. <form:input path="searchKeyList[3]" maxlength="32" placeholder="建议输入商品大分类关键词" onchange="checkmaxlengthsBySearch(this,this.value,32)" class="input-small"/>
  73. <form:input path="searchKeyList[4]" maxlength="32" placeholder="建议输入商品小分类关键词" onchange="checkmaxlengthsBySearch(this,this.value,32)" class="input-small"/>
  74. <p>请务必准确定义关键词,关键词会影响商品的搜索结果,建议从品牌,商品学名,商品别名,商品大类别和商品小类别5个方面考虑,每个关键词不超过16个汉字。</p>
  75. </td>
  76. </tr>
  77. <tr>
  78. <th>相关参数:</th>
  79. <td colspan="3" class="params">
  80. <div id="addParamsItems">
  81. <%--相关参数层--%>
  82. <input type="hidden" value="${fn:length(product.productParametersList)}" id="productParametersLength">
  83. <c:forEach items="${product.productParametersList}" var="item" varStatus="varIndex">
  84. <div id="paramsItem" class="paramsItem">
  85. <form:input path="productParametersList[${varIndex.index}].paramsName" id="paramsName" cssStyle="width:142px" maxlength="10" placeholder="参数名称" class="input-small"/>
  86. <form:input path="productParametersList[${varIndex.index}].paramsContent" id="paramsContent" cssStyle="width:680px" maxlength="50" placeholder="请输入参数信息" class="input-small"/>
  87. <span type="button" style="cursor: pointer;color: #0B61A4" onclick="deleteParams(this)">删除</span>
  88. </div>
  89. </c:forEach>
  90. </div>
  91. <button class="addParams" onclick="return false">添加参数</button>
  92. </td>
  93. </tr>
  94. <tr>
  95. <th>品牌:</th>
  96. <td colspan="3">
  97. <form:select path="brandID" class="input-small">
  98. <form:option value="" label="请选择"/>
  99. <form:options items="${brandList}" itemLabel="name" itemValue="id" htmlEscape="false"/>
  100. </form:select>
  101. </td>
  102. </tr>
  103. <tr>
  104. <th>组合名称:</th>
  105. <td colspan="3">
  106. <form:select path="combinationID" class="input-small">
  107. <form:option value="" label="请选择"/>
  108. <form:options items="${combinationList}" itemLabel="name" itemValue="id" htmlEscape="false"/>
  109. </form:select>
  110. </td>
  111. </tr>
  112. <tr>
  113. <th><span class="red">*</span>商品标签:</th>
  114. <td colspan="3">
  115. <input id="inputTags" maxlength="15" style="width:217px;border-radius:5px" placeholder="请输入商品标签" class="input-small"/>
  116. <button class="addTags" onclick="return false">添加标签</button>
  117. <p style="margin-top: 5px">简述商品功效和特性,最多可添加6个标签,每个标签字数不超过15个汉字(如:美白祛斑,消除皱纹)</p>
  118. <div id="tagsList">
  119. <input type="hidden" name="tagsLists" value="${product.tags}" id="tagsLists">
  120. <%--标签--%>
  121. </div>
  122. </td>
  123. </tr>
  124. <tr>
  125. <th><span class="red">*</span>商品属性:</th>
  126. <td colspan="3">
  127. <label><input type="radio" name="commodityType" value="1" onchange="loadBigType()" ${product.commodityType == "1" ? "checked" : ""} />产品<b class="line">|</b></label>
  128. <label><input type="radio" name="commodityType" value="2" onchange="loadBigType()" ${product.commodityType == "2" ? "checked" : ""} />仪器</label>
  129. </td>
  130. </tr>
  131. <tr class="training" hidden>
  132. <th><span class="red">*</span>培训方式:</th>
  133. <td colspan="3">
  134. <label><input type="radio" name="trainingMethod" value="1" ${empty product.trainingMethod || product.trainingMethod == 1 ? "checked" : ""} />线上培训<b class="line">|</b></label>
  135. <label><input type="radio" name="trainingMethod" value="2" ${product.trainingMethod == 2 ? "checked" : ""} />线下培训</label>
  136. </td>
  137. </tr>
  138. <tr class="training" hidden>
  139. <th><span class="red">*</span>培训费用:</th>
  140. <td colspan="3">
  141. <label><input type="radio" name="trainingType" value="1" ${empty product.trainingType || product.trainingType == 1 ? "checked" : ""} onchange="trainingShow()"/>售价未包含<b class="line">|</b></label>
  142. <label><input type="radio" name="trainingType" value="2" ${product.trainingType == 2 ? "checked" : ""} onchange="trainingShow()"/>售价已包含</label>
  143. </td>
  144. </tr>
  145. <tr id="trainingFee" hidden>
  146. <th></th>
  147. <td colspan="3">
  148. <input type="number" name="trainingFee" value="${product.trainingFee}" style="width: 250px" min="0" placeholder="请填写包含食宿,交通等各项费用的总金额"/>
  149. </td>
  150. </tr>
  151. <tr>
  152. <th><span class="red">*</span>分类:</th>
  153. <td colspan="3">
  154. <form:select path="bigTypeID" class="input-small required" id="bigType" onchange="loadSmallType()">
  155. <form:option value="" label="请选择"/>
  156. <form:options items="${classify.bigTypeList}" itemLabel="name" itemValue="bigTypeID" htmlEscape="false"/>
  157. </form:select>
  158. <form:select path="smallTypeID" class="input-small" id="smallType" onchange="loadTinyType()">
  159. <form:option value="" label="请选择"/>
  160. <c:forEach items="${classify.smalltypeList}" var="smallType">
  161. <form:option value="${smallType.smallTypeID}" label="${smallType.name}" bigTypeID="${smallType.bigTypeID}"/>
  162. </c:forEach>
  163. </form:select>
  164. <form:select path="tinyTypeID" class="input-small" id="tinyType">
  165. <form:option value="" label="请选择"/>
  166. <c:forEach items="${classify.tinytypeList}" var="tinyType">
  167. <form:option value="${tinyType.tinyTypeID}" label="${tinyType.name}" bigTypeID="${tinyType.smallTypeID}"/>
  168. </c:forEach>
  169. </form:select>
  170. </td>
  171. </tr>
  172. <tr>
  173. <th><span class="red">*</span>商品类型:</th>
  174. <td colspan="3">
  175. <form:select path="productType" class="input-small required" onclick="changeMachine(this)">
  176. <form:option value="" label="请选择"/>
  177. <form:option value="1" label="妆字号"/>
  178. <form:option value="2" label="械字号"/>
  179. <form:option value="0" label="其它" />
  180. </form:select>
  181. <span class="machineType">
  182. <form:select path="machineType" class="input-small">
  183. <form:option value="" label="请选择"/>
  184. <form:option value="1" label="一类"/>
  185. <form:option value="2" label="二类"/>
  186. <form:option value="3" label="三类"/>
  187. </form:select>
  188. </span>
  189. </td>
  190. </tr>
  191. <tr id="xiezihao" class="machineType">
  192. <th><span class="red">*</span>资质证书:</th>
  193. <td colspan="3">
  194. <%-- 械字号医疗证书--%>
  195. <form:hidden id="qualificationImg" path="qualificationImg" htmlEscape="false" maxlength="255" class="input-xlarge"/>
  196. <sys:ckfinder input="qualificationImg" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
  197. </td>
  198. </tr>
  199. <tr>
  200. <th><span class="red">*</span>市场价:</th>
  201. <td colspan="3"><form:input path="normalPrice" type="number" maxlength="11" class="short input-small required" />元</td>
  202. </tr>
  203. <tr>
  204. <th><span class="red">*</span>商品展示价格:</th>
  205. <td colspan="3">
  206. <label><input type="radio" name="ladderPriceFlag" value="0" onchange="changeLadderPrice()" ${product.ladderPriceFlag == "0" ? "checked" : ""} />不使用阶梯价格<b class="line">|</b></label>
  207. <label><input type="radio" name="ladderPriceFlag" value="1" onchange="changeLadderPrice()" ${product.ladderPriceFlag == "1" ? "checked" : ""} />使用阶梯价格</label>
  208. </td>
  209. </tr>
  210. <tr>
  211. <th style="vertical-align:top;padding-top:15px;"><span class="red">*</span>机构价:</th>
  212. <td colspan="3">
  213. <div class="item">
  214. <div id="normalPriceBox">
  215. <form:input path="price1" type="number" id="price1" maxlength="11" class="short computedPrice required" onkeyup="computedPriceLevel(this.value)" />
  216. <b class="line">|</b>游客展示等级:<span>
  217. <i class="priceIcon"></i>
  218. <i class="priceIcon"></i>
  219. <i class="priceIcon"></i>
  220. <i class="priceIcon"></i>
  221. <i class="priceIcon"></i>
  222. </span>
  223. </div>
  224. <div id="ladderPriceBox">
  225. <div id="ladderPrice1">
  226. 起订量:<form:input path="ladderPriceList[0].buyNum" min="1" type="number" maxlength="11" class="short number" onblur="checkBuyNum(this, 0)"/>(${product.unit})及以上,
  227. <form:input path="ladderPriceList[0].buyPrice" type="number" maxlength="11" class="short price" onblur="checkBuyPrice(this, 0)" />元/(${product.unit})
  228. <span class="showBtn ${null != product.ladderPriceList[1] && null != product.ladderPriceList[1].buyNum ? "hide" : ""}">
  229. <a class="addBtn" href="javascript:;">添加</a>
  230. <form:hidden path="ladderPriceList[0].id"/>
  231. <form:hidden path="ladderPriceList[0].delFlag" id="delFlag1"/>
  232. </span>
  233. </div>
  234. <div id="ladderPrice2" ${null == product.ladderPriceList[1] && null == product.ladderPriceList[1].buyNum ? "class='hide'" : ""}>
  235. 起订量:<form:input path="ladderPriceList[1].buyNum" type="number" maxlength="11" class="short number" onblur="checkBuyNum(this, 1)" />(${product.unit})及以上,
  236. <form:input path="ladderPriceList[1].buyPrice" type="number" maxlength="11" class="short price" onblur="checkBuyPrice(this, 1)"/>元/(${product.unit})
  237. <span class="showBtn ${null != product.ladderPriceList[2] && null != product.ladderPriceList[2].buyNum ? "hide" : ""}">
  238. <a class="delBtn" href="javascript:;">删除</a> / <a class="addBtn" href="javascript:;">添加</a>
  239. <form:hidden path="ladderPriceList[1].id"/>
  240. <form:hidden path="ladderPriceList[1].delFlag" id="delFlag2"/>
  241. </span>
  242. </div>
  243. <div id="ladderPrice3" ${null == product.ladderPriceList[2] && null == product.ladderPriceList[2].buyNum ? "class='hide'" : ""}>
  244. 起订量:<form:input path="ladderPriceList[2].buyNum" type="number" maxlength="11" class="short number" onblur="checkBuyNum(this, 2)" />(${product.unit})及以上,
  245. <form:input path="ladderPriceList[2].buyPrice" type="number" maxlength="11" class="short price" onblur="checkBuyPrice(this, 2)"/>元/(${product.unit})
  246. <span class="showBtn"><a class="delBtn" href="javascript:;">删除</a></span>
  247. <form:hidden path="ladderPriceList[2].id"/>
  248. <form:hidden path="ladderPriceList[2].delFlag" id="delFlag3"/>
  249. </div>
  250. </div>
  251. </div>
  252. </td>
  253. </tr>
  254. <tr>
  255. <th><span class="red">*</span>是否含税:</th>
  256. <td >
  257. <label><input type="radio" name="includedTax" value="1" onclick="chageIncludedTax(${product.taxPoint})" ${product.includedTax == "1" ? "checked" : ""}>含税<b class="line">|</b></label>
  258. <label><input type="radio" name="includedTax" value="0" onclick="chageIncludedTax(${product.taxPoint})" ${product.includedTax == "0" ? "checked" : ""}>不含税<b class="line">|</b></label>
  259. <label><input type="radio" name="includedTax" value="2" onclick="chageIncludedTax(${product.taxPoint})" ${product.includedTax == "2" ? "checked" : ""}>未知</label>
  260. </td>
  261. </tr>
  262. <tr id="invoiceItem">
  263. <th></th>
  264. <td>
  265. <span class="invoice">
  266. <label><input type="radio" name="invoiceType" value="1" onclick="changeInvoiceType(${product.taxPoint})" ${product.invoiceType == "1" ? "checked" : ""}>开增值税专用发票<b class="line">|</b></label>
  267. <label><input type="radio" name="invoiceType" value="2" onclick="changeInvoiceType(${product.taxPoint})" ${product.invoiceType == "2" ? "checked" : ""}>开增值税普通发票</label>
  268. </span>
  269. <span class="notInvoice">
  270. <b class="line">|</b>
  271. <label><input type="radio" name="invoiceType" value="3" onclick="changeInvoiceType(${product.taxPoint})" ${product.invoiceType == "3" ? "checked" : ""}>不能开票</label>
  272. </span>
  273. </td>
  274. </tr>
  275. <tr id="taxPointDiv">
  276. <th><span class="red">*</span>机构税率:</th>
  277. <td>
  278. <span><form:input path="taxPoint" maxlength="5" cssStyle="width: 35PX" class="number" onchange="setTwoNumberDecimal(this)" />%</span>
  279. </td>
  280. </tr>
  281. <tr id="supplierTaxPointDiv">
  282. <th><span class="red">*</span>供应商税率:</th>
  283. <td>
  284. <span><form:input path="supplierTaxPoint" maxlength="5" cssStyle="width: 35PX" class="number" onchange="setTwoNumberDecimal(this)" />%</span>
  285. </td>
  286. </tr>
  287. <tr id="priceMinNumber">
  288. <th><span class="red">*</span>起订量:</th>
  289. <td colspan="3"><form:input path="minBuyNumber" maxlength="11" class="short" /></td>
  290. </tr>
  291. <tr>
  292. <th><span class="red">*</span>商品可见度:</th>
  293. <td colspan="3">
  294. <form:select path="visibility" class="input-large required" id="visibility">
  295. <form:option value="3" label="所有人可见"/>
  296. <form:option value="2" label="所有机构可见"/>
  297. <form:option value="1" label="仅会员机构可见"/>
  298. </form:select>
  299. </td>
  300. </tr>
  301. <tr>
  302. <th><span class="red">*</span>价格可见度:</th>
  303. <td>
  304. <form:select path="price1TextFlag" class="input-small required hide" id="price1TextFlag">
  305. <form:option value="1" label="所有机构都不可见"/>
  306. <form:option value="2" label="仅会员机构可见"/>
  307. <form:option value="0" label="所有机构都可见"/>
  308. </form:select>
  309. </td>
  310. <td colspan="2">
  311. <span id="textFlagNote" style="color:#ab1e1e;">
  312. ${product.price1TextFlag == "1" ? "所有机构都不可见" : ""}
  313. ${product.price1TextFlag == "2" ? "仅会员机构可见" : ""}
  314. ${product.price1TextFlag == "0" ? "所有机构都可见" : ""}
  315. </span>
  316. <%--<input type="radio" name="price1TextFlag" value="0" ${product.price1TextFlag == "0" ? "checked" : ""} />公开<b class="line">|</b>
  317. <input type="radio" name="price1TextFlag" value="1" ${product.price1TextFlag == "1" ? "checked" : ""} />不公开--%>
  318. </td>
  319. </tr>
  320. <tr>
  321. <th><span class="red">*</span>成本:</th>
  322. <td colspan="3">
  323. <label><input type="radio" name="costCheckFlag" value="1" onchange="changeCostPriceShow()" ${product.costCheckFlag == "1" ? "checked" : ""} />固定成本<b class="line">|</b></label>
  324. <label><input type="radio" name="costCheckFlag" value="2" onchange="changeCostPriceShow()" ${product.costCheckFlag == "1" ? "" : "checked"} />比例成本</label>
  325. </td>
  326. </tr>
  327. <tr id="costPriceShow">
  328. <th><span class="red">*</span><b class="costFlagText">成本价</b>:</th>
  329. <td colspan="3"><form:input path="costPrice" id="costPrice" type="number" maxlength="11" class="short" /> 元</td>
  330. </tr>
  331. <tr id="costPropShow">
  332. <th><span class="red">*</span>比例成本百分比:</th>
  333. <td colspan="3"><form:input path="costProportional" id="costProportional" type="number" maxlength="11" class="short" /> %</td>
  334. </tr>
  335. <tr>
  336. <th>库存:</th>
  337. <td colspan="3"><form:input path="stock" type="number" maxlength="11" class="short" /></td>
  338. </tr>
  339. <tr>
  340. <th><span class="red">*</span>购买数量:</th>
  341. <td colspan="3">
  342. <label><input type="radio" name="step" value="1" ${product.step == "1" ? "checked" : ""}>逐步增长<b class="line">|</b></label>
  343. <label><input type="radio" name="step" value="2" ${product.step == "2" ? "checked" : ""}>以起订量增长</label>
  344. </td>
  345. </tr>
  346. <tr>
  347. <th><span class="red">*</span>运费:</th>
  348. <%--<td colspan="3">
  349. <label><input type="radio" name="byFlag" value="0" ${product.byFlag == "0" ? "checked" : ""}>买家承担<b class="line">|</b></label>
  350. <label><input type="radio" name="byFlag" value="1" ${product.byFlag == "1" ? "checked" : ""}>卖家承担</label>
  351. </td>--%>
  352. <td colspan="3">
  353. <label><input type="radio" name="freePostFlag" value="2" ${(empty product.freePostFlag || product.freePostFlag eq "2") ? "checked" : ""}>默认(遵循运费规则)<b class="line">|</b></label>
  354. <label><input type="radio" name="freePostFlag" value="0" ${product.freePostFlag == "0" ? "checked" : ""}>包邮<b class="line">|</b></label>
  355. <label><input type="radio" name="freePostFlag" value="1" ${product.freePostFlag == "1" ? "checked" : ""}>到付</label>
  356. </td>
  357. </tr>
  358. <tr>
  359. <th><span class="red">*</span>包装规格:</th>
  360. <td><form:input path="unit" maxlength="20" class="short required" /></td>
  361. </tr>
  362. <tr>
  363. <th><span class="red">*</span>销售区域:</th>
  364. <td colspan="3">
  365. <label><input type="radio" name="allAreaFlag" value="1" onchange="changeAreaFlag()" ${product.allAreaFlag == "1" ? "checked" : ""}>全部区域<b class="line">|</b></label>
  366. <label><input type="radio" name="allAreaFlag" value="0" onchange="changeAreaFlag()" ${product.allAreaFlag == "1" ? "" : "checked"}>指定区域</label>
  367. </td>
  368. </tr>
  369. <tr id="allAreaInput">
  370. <th></th>
  371. <td>
  372. <span>
  373. <form:checkboxes path="provinceIDs" items="${provinceList}" itemLabel="name" itemValue="id" />
  374. </span>
  375. </td>
  376. </tr>
  377. <tr>
  378. <th><span class="red">*</span>商品详细信息:</th>
  379. <td colspan="3">
  380. <form:textarea path="detailInfo" htmlEscape="false" class="input-xlarge required hide" />
  381. <!-- 富文本编辑器 -->
  382. <div id="detailInfoEditor">${product.detailInfo}</div>
  383. </td>
  384. </tr>
  385. <tr>
  386. <th>订购方案:</th>
  387. <td colspan="3">
  388. <form:textarea path="orderInfo" class="input-xlarge hide" />
  389. <!-- 富文本编辑器 -->
  390. <div id="orderInfoEditor">${product.orderInfo}</div>
  391. </td>
  392. </tr>
  393. <tr>
  394. <th>服务详情:</th>
  395. <td colspan="3">
  396. <form:textarea path="serviceInfo" class="input-xlarge hide" />
  397. <!-- 富文本编辑器 -->
  398. <div id="serviceInfoEditor">${product.serviceInfo}</div>
  399. </td>
  400. </tr>
  401. <tr><td colspan="4" style="text-align:center;">
  402. <shiro:hasPermission name="product:product:edit">
  403. <input id="btnSave" class="btn btn-primary" type="submit" value="保 存" onclick="checkInfo()"/>
  404. </shiro:hasPermission>
  405. <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
  406. </td></tr>
  407. </table>
  408. </form:form>
  409. <!-- 富文本编辑器 -->
  410. <% request.setAttribute("caimeiSpi", Global.getConfig("caimei.spi"));%>
  411. <% request.setAttribute("caimeiCore", Global.getConfig("caimei.core"));%>
  412. <script type="text/javascript" src="${ctxStatic}/ckeditor5-new/ckeditor.js"></script>
  413. <script type="text/javascript">
  414. $(document).ready(function() {
  415. //$("#name").focus();
  416. $("#inputForm").validate({
  417. ignore:"",
  418. submitHandler: function(form){
  419. var commodityType = $("input[name='commodityType']:checked").val();
  420. if(commodityType == '' || commodityType == null){
  421. alertx("请选择商品属性");
  422. return false;
  423. }
  424. var costCheckFlag = $("input[name='costCheckFlag']:checked").val();
  425. if(costCheckFlag*1===1){
  426. if ($("#costPrice").val() == '') {
  427. alertx("请输入成本价");
  428. return false;
  429. };
  430. }else{
  431. if ($("#costProportional").val() == '') {
  432. alertx("请输入成本比例");
  433. return false;
  434. };
  435. }
  436. if ($('#minBuyNumber:visible').length>0){
  437. var minBuyNumber = $('#minBuyNumber').val();
  438. if(minBuyNumber<=0 || minBuyNumber == ''){
  439. alertx("请输入起订量");
  440. return false;
  441. }
  442. }
  443. if ($('input[name="ladderPriceList[0].buyNum"]:visible').length>0){
  444. var buyNum = $('input[name="ladderPriceList[0].buyNum"]').val();
  445. var buyPrice = $('input[name="ladderPriceList[0].buyPrice"]').val();
  446. if(buyNum<=0 || buyNum == '' || buyPrice<=0 || buyPrice == ''){
  447. alertx("请输入正确的阶梯价格");
  448. return false;
  449. }
  450. }
  451. if ($('input[name="ladderPriceList[1].buyNum"]:visible').length>0){
  452. var buyNum1 = $('input[name="ladderPriceList[1].buyNum"]').val();
  453. var buyPrice1 = $('input[name="ladderPriceList[1].buyPrice"]').val();
  454. if(buyNum1<=0 || buyNum1 == '' || buyPrice1<=0 || buyPrice1 == ''){
  455. alertx("请输入正确的阶梯价格");
  456. return false;
  457. }
  458. }
  459. if ($('input[name="ladderPriceList[2].buyNum"]:visible').length>0){
  460. var buyNum2 = $('input[name="ladderPriceList[2].buyNum"]').val();
  461. var buyPrice2 = $('input[name="ladderPriceList[2].buyPrice"]').val();
  462. if(buyNum2<=0 || buyNum2 == '' || buyPrice2<=0 || buyPrice2 == ''){
  463. alertx("请输入正确的阶梯价格");
  464. return false;
  465. }
  466. }
  467. var detailInfo=detailInfoEditor.getData();
  468. if (detailInfo == ''){
  469. alertx("请输入商品详细信息");
  470. return false;
  471. }
  472. var includedTax = $("input[name='includedTax']:checked").val();
  473. if(includedTax == '' || includedTax == null){
  474. alertx("请选择是否含税");
  475. return false;
  476. }
  477. var invoiceType = $("input[name='invoiceType']:checked").val();
  478. if ((includedTax == 0 || includedTax == 1) && (invoiceType == 1 || invoiceType == 2)) {
  479. var taxPoint = $("#taxPoint").val();
  480. var supplierTaxPoint = $("#supplierTaxPoint").val();
  481. if (taxPoint == '' || taxPoint == null) {
  482. alertx("请输入机构税率");
  483. return false;
  484. }
  485. if (supplierTaxPoint == '' || supplierTaxPoint == null) {
  486. alertx("请输入供应商税率");
  487. return false;
  488. }
  489. }
  490. if (includedTax != ${product.includedTax} || invoiceType != ${product.invoiceType}) {
  491. top.$.jBox.confirm("目前含税信息为:${product.includedTax eq 0?'不含税':product.includedTax eq 1?'含税':'未知'}${product.includedTax eq 2?'':product.invoiceType eq 1?'-开增值税专用发票':product.invoiceType eq 2?'-开增值税普通发票':'不开发票'},确定修改为:" + (includedTax == 0 ? '不含税' : includedTax == 1 ? '含税' : '未知') + (includedTax == 2 ? '' : invoiceType == 1 ? '-开增值税专用发票' : invoiceType == 2 ? '-开增值税普通发票' : '-不能开票') + "吗?", '保存商品提示', function (v, h, f) {
  492. if (v == 'ok') {
  493. // 提交订单
  494. loading('正在提交,请稍等...');
  495. form.submit();
  496. }
  497. }, {
  498. buttonsFocus: 1, closed: function () {
  499. if (typeof closed == 'function') {
  500. closed();
  501. }
  502. }
  503. });
  504. } else {
  505. loading('正在提交,请稍等...');
  506. form.submit();
  507. }
  508. },
  509. errorContainer: "#messageBox",
  510. errorPlacement: function(error, element) {
  511. $("#messageBox").text("输入有误,请先更正。");
  512. if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
  513. error.appendTo(element.parent().parent());
  514. } else {
  515. error.insertAfter(element);
  516. }
  517. }
  518. });
  519. });
  520. // 商品可见度
  521. /*$(function() {
  522. var initValue = ${(product.visibility <= 0) ? 3 : ((product.visibility >= 3) ? 3 : product.visibility)}
  523. var select = $("#visibility");
  524. var slider = $("<div id='slider'></div>").insertAfter(select).slider({
  525. min: 1,
  526. max: 3,
  527. range: "min",
  528. value: initValue,
  529. slide: function(event, ui) {
  530. if (ui.value*1 === 1){
  531. // 所有可见
  532. select.val(1);
  533. } else if (ui.value*1 === 2){
  534. // 会员可见
  535. select.val(2);
  536. } else{
  537. // 不可见
  538. select.val(3);
  539. }
  540. $("#visibilityNote").text(select.find("option:selected").text());
  541. }
  542. });
  543. });*/
  544. // 价格可见度
  545. $(function() {
  546. var initValue = ${(product.price1TextFlag eq 0) ? 2 : ((product.price1TextFlag eq 2) ? 1 : 0)}
  547. var select = $("#price1TextFlag");
  548. var slider = $("<div id='slider'></div>").insertAfter(select).slider({
  549. min: 0,
  550. max: 2,
  551. range: "min",
  552. value: initValue,
  553. slide: function(event, ui) {
  554. if (ui.value*1 === 2){
  555. // 所有可见
  556. select.val(0);
  557. } else if (ui.value*1 === 1){
  558. // 会员可见
  559. select.val(2);
  560. } else{
  561. // 不可见
  562. select.val(1);
  563. }
  564. //select[0].selectedIndex = ui.value;
  565. $("#textFlagNote").text(select.find("option:selected").text());
  566. }
  567. });
  568. });
  569. //初始化标签
  570. $(function () {
  571. var html = '';
  572. //解析参数
  573. var tagsLists = $("#tagsLists").val();
  574. if(tagsLists != null && tagsLists != ""){
  575. var tagsArray = tagsLists.split(',');
  576. for (var j = 0; j < tagsArray.length; j++) {
  577. html += '<div class="tags-li"><input id="tags" name="tags" value="'+tagsArray[j]+'" class="tags-s" readonly/><i onclick="removerX(this)">X</i></div>';
  578. }
  579. $("#tagsList").append(html).show();
  580. }
  581. });
  582. $(window).load(function(){
  583. loadInitType();
  584. });
  585. var step = ${product.step};
  586. var areaFlag = ${product.allAreaFlag};
  587. var ladderPriceFlag = ${product.ladderPriceFlag};
  588. var normalPrice = ${product.price1};
  589. $(document).ready(function() {
  590. step*1>1 ? $("#setpInput").show() : $("#setpInput").hide();
  591. areaFlag*1>0 ? $("#allAreaInput").hide() : $("#allAreaInput").show();
  592. computedPriceLevel(normalPrice);
  593. if(ladderPriceFlag*1>0){
  594. $("#ladderPriceBox").show();
  595. $("#priceMinNumber").hide();
  596. }else{
  597. $("#ladderPriceBox").hide();
  598. $("#priceMinNumber").show();
  599. }
  600. changeCostPriceShow();
  601. //富文本框
  602. ClassicEditor.create(document.querySelector('#detailInfoEditor'), {
  603. ckfinder: {
  604. uploadUrl: '${caimeiSpi}/formData/ckeditorImage'
  605. }
  606. }).then(function(editor) {
  607. window.detailInfoEditor = editor;
  608. }).catch(function(error){
  609. console.log(error);
  610. });
  611. ClassicEditor.create(document.querySelector('#orderInfoEditor'), {
  612. ckfinder: {
  613. uploadUrl: '${caimeiSpi}/formData/ckeditorImage'
  614. }
  615. }).then(function(editor) {
  616. window.orderInfoEditor = editor;
  617. }).catch(function(error){
  618. console.log(error);
  619. });
  620. ClassicEditor.create(document.querySelector('#serviceInfoEditor'), {
  621. ckfinder: {
  622. uploadUrl: '${caimeiSpi}/formData/ckeditorImage'
  623. }
  624. }).then(function(editor) {
  625. window.serviceInfoEditor = editor;
  626. }).catch(function(error){
  627. console.log(error);
  628. });
  629. });
  630. //富文本框编辑
  631. function checkInfo(){
  632. var detailInfo=detailInfoEditor.getData();
  633. $("#detailInfo").val(detailInfo);
  634. console.log(detailInfo);
  635. var orderInfo=orderInfoEditor.getData();
  636. $("#orderInfo").val(orderInfo);
  637. console.log(orderInfo);
  638. var serviceInfo=serviceInfoEditor.getData();
  639. $("#serviceInfo").val(serviceInfo);
  640. console.log(serviceInfo);
  641. }
  642. $("#ladderPrice1").on("click", ".addBtn", function(){
  643. $("#ladderPrice2").removeClass("hide");
  644. $("#delFlag2").val("0");
  645. $("#ladderPrice1").find(".showBtn").addClass("hide");
  646. });
  647. $("#ladderPrice2").on("click", ".addBtn", function(){
  648. $("#ladderPrice3").removeClass("hide");
  649. $("#delFlag3").val("0");
  650. $("#ladderPrice2").find(".showBtn").addClass("hide");
  651. }).on("click", ".delBtn", function(){
  652. $("#ladderPrice2").addClass("hide");
  653. $("#ladderPrice1").find(".showBtn").removeClass("hide");
  654. $("#delFlag2").val("1");
  655. });
  656. $("#ladderPrice3").on("click", ".delBtn", function(){
  657. $("#ladderPrice3").addClass("hide");
  658. $("#ladderPrice2").find(".showBtn").removeClass("hide");
  659. $("#delFlag3").val("1");
  660. });
  661. //计算游客用户价格等级
  662. function computedPriceLevel(price){
  663. var priceLevel = 1;
  664. $(".priceIcon").removeClass("full");
  665. $(".priceIcon").eq(0).addClass("full");
  666. if (price*1>2.5*10000 && price*1<=10*10000) {
  667. priceLevel = 2;
  668. $(".priceIcon").addClass("full");
  669. if($(".priceIcon").eq(2).hasClass("full")){$(".priceIcon").eq(2).removeClass("full");}
  670. if($(".priceIcon").eq(3).hasClass("full")){$(".priceIcon").eq(3).removeClass("full");}
  671. if($(".priceIcon").eq(4).hasClass("full")){$(".priceIcon").eq(4).removeClass("full");}
  672. }
  673. if (price*1>10*10000 && price*1<=25*10000) {
  674. priceLevel = 3;
  675. $(".priceIcon").addClass("full");
  676. if($(".priceIcon").eq(3).hasClass("full")){$(".priceIcon").eq(3).removeClass("full");}
  677. if($(".priceIcon").eq(4).hasClass("full")){$(".priceIcon").eq(4).removeClass("full");}
  678. }
  679. if (price*1>25*10000 && price*1<=50*10000) {
  680. priceLevel = 4;
  681. $(".priceIcon").addClass("full");
  682. if($(".priceIcon").eq(4).hasClass("full")){$(".priceIcon").eq(4).removeClass("full");}
  683. }
  684. if (price*1>50*10000) {
  685. priceLevel = 5;
  686. $(".priceIcon").addClass("full");
  687. }
  688. }
  689. // 检查阶梯数量
  690. function checkBuyNum(input, index) {
  691. if(index>0){
  692. var beforeNum = $('input[name="ladderPriceList['+(index-1)+'].buyNum"]').val()*1;
  693. if(input.value*1 <= beforeNum){
  694. alertx("请输入大于上一阶起订量的值");
  695. $(input).val(input.value*1+beforeNum);
  696. }
  697. } else {
  698. var minNum = $('input[name="ladderPriceList[0].buyNum"]').val()*1;
  699. $('#minBuyNumber').val(minNum);
  700. }
  701. }
  702. // 检查阶梯价格
  703. function checkBuyPrice(input, index) {
  704. if (index > 0) {
  705. var beforePrice = $('input[name="ladderPriceList['+(index-1)+'].buyPrice"]').val()*1;
  706. if(input.value*1 > beforePrice){
  707. $(input).val('');
  708. alertx("请输入小于前一个价格的值");
  709. }
  710. } else {
  711. var price1 = $('#price1').val();
  712. if(input.value*1 > price1){
  713. $(input).val('');
  714. alertx("第一个阶梯价格不能大于机构价");
  715. }
  716. }
  717. }
  718. // 是否使用阶梯价格
  719. function changeLadderPrice(){
  720. var ladderPriceFlag = $("input[name='ladderPriceFlag']:checked").val();
  721. if(ladderPriceFlag*1>0){
  722. $("#ladderPriceBox").show();
  723. $("#priceMinNumber").hide();
  724. $("#delFlag1").val("0");
  725. $('input[name="ladderPriceList[0].buyNum"]').val($('#minBuyNumber').val()*1);
  726. }else{
  727. $("#ladderPriceBox").hide();
  728. $("#priceMinNumber").show();
  729. }
  730. }
  731. // 是否固定成本
  732. function changeCostPriceShow() {
  733. var costCheckFlag = $("input[name='costCheckFlag']:checked").val();
  734. if(costCheckFlag*1===1){
  735. $("#costPriceShow").show();
  736. $("#costPropShow").hide();
  737. }else{
  738. $("#costPriceShow").hide();
  739. $("#costPropShow").show();
  740. }
  741. }
  742. // 全部区域
  743. function changeAreaFlag() {
  744. var areaFlag = $("input[name='allAreaFlag']:checked").val();
  745. areaFlag*1>0 ? $("#allAreaInput").hide() : $("#allAreaInput").show();
  746. }
  747. // 网站分类
  748. var currentBigtype = ${product.bigTypeID};
  749. var currentSmalltype = ${product.smallTypeID};
  750. var currentTinytype = ${product.tinyTypeID};
  751. var currentCommodityType = ${product.commodityType}; //商品属性
  752. var bigTypeList = [
  753. <c:forEach items="${classify.bigTypeList}" var="bigType" varStatus="index">
  754. <c:if test="${index.index > 0}">,</c:if>
  755. {
  756. bigTypeID: ${bigType.bigTypeID},
  757. name: "${bigType.name}",
  758. typeSort: ${bigType.typeSort}
  759. }
  760. </c:forEach>
  761. ];
  762. var smalltypeList = [
  763. <c:forEach items="${classify.smalltypeList}" var="smalltype" varStatus="index">
  764. <c:if test="${index.index > 0}">,</c:if>
  765. {
  766. smallTypeID: ${smalltype.smallTypeID},
  767. name: "${smalltype.name}",
  768. bigTypeID: ${smalltype.bigTypeID},
  769. }
  770. </c:forEach>
  771. ];
  772. var tinytypeList = [
  773. <c:forEach items="${classify.tinytypeList}" var="tinytype" varStatus="index">
  774. <c:if test="${index.index > 0}">,</c:if>
  775. {
  776. tinyTypeID: ${tinytype.tinyTypeID},
  777. name: "${tinytype.name}",
  778. smallTypeID: ${tinytype.smallTypeID}
  779. }
  780. </c:forEach>
  781. ];
  782. // 初始分类
  783. function loadInitType(){
  784. if (currentCommodityType == null || typeof (currentCommodityType) == "undefined" || currentCommodityType == '0') {
  785. $("#bigType").html("");
  786. $("#bigType").prev().find(".select2-chosen").text("请选择");
  787. $("#bigType").append("<option value=''>请选择</option>");
  788. $("#smallType").html("");
  789. $("#smallType").prev().find(".select2-chosen").text("请选择");
  790. $("#smallType").append("<option value=''>请选择</option>");
  791. $("#tinyType").html("");
  792. $("#tinyType").prev().find(".select2-chosen").text("请选择");
  793. $("#tinyType").append("<option value=''>请选择</option>");
  794. document.getElementById("s2id_tinyType").style.cssText = "display: none";
  795. }else if(currentBigtype != null && typeof(currentBigtype) != "undefined"){
  796. setTimeout(function(){
  797. loadBigType();
  798. },0);
  799. }
  800. }
  801. // 分类联动
  802. function loadBigType(){
  803. var commodityType = $("input[name='commodityType']:checked").val();
  804. $("#bigType").html("");
  805. $("#bigType").prev().find(".select2-chosen").text("请选择");
  806. $("#bigType").append("<option value=''>请选择</option>");
  807. $("#smallType").html("");
  808. $("#smallType").prev().find(".select2-chosen").text("请选择");
  809. $("#smallType").append("<option value=''>请选择</option>");
  810. $("#tinyType").html("");
  811. $("#tinyType").prev().find(".select2-chosen").text("请选择");
  812. $("#tinyType").append("<option value=''>请选择</option>");
  813. if(typeof(commodityType) != "undefined") {
  814. $("#bigType").html("");
  815. $("#bigType").prev().find(".select2-chosen").text("请选择");
  816. $("#bigType").append("<option value=''>请选择</option>");
  817. $("#smallType").html("");
  818. $("#smallType").prev().find(".select2-chosen").text("请选择");
  819. $("#smallType").append("<option value=''>请选择</option>");
  820. $("#tinyType").html("");
  821. $("#tinyType").prev().find(".select2-chosen").text("请选择");
  822. $("#tinyType").append("<option value=''>请选择</option>");
  823. for(var i=0; i<bigTypeList.length; i++){
  824. if (commodityType == bigTypeList[i].typeSort) {
  825. if (currentBigtype != null && typeof (currentBigtype) != "undefined" && currentBigtype == bigTypeList[i].bigTypeID) {
  826. $("#bigType").append("<option selected value='"+bigTypeList[i].bigTypeID+"'>"+bigTypeList[i].name+"</option>");
  827. $("#bigType").prev().find(".select2-chosen").text(bigTypeList[i].name);
  828. setTimeout(function(){
  829. loadSmallType();
  830. },500);
  831. }else{
  832. $("#bigType").append("<option value='"+bigTypeList[i].bigTypeID+"'>"+bigTypeList[i].name+"</option>");
  833. }
  834. }
  835. }
  836. }
  837. loadSmallType();
  838. trainingShow();
  839. }
  840. function loadSmallType(id){
  841. if(id){
  842. $("#bigType").val(id);
  843. $("#bigType").prev().find(".select2-chosen").text($("#bigType option:selected").text());
  844. }
  845. var bigType = $("#bigType").val();
  846. $("#smallType").html("");
  847. $("#smallType").prev().find(".select2-chosen").text("请选择");
  848. $("#smallType").append("<option value=''>请选择</option>");
  849. $("#tinyType").html("");
  850. $("#tinyType").prev().find(".select2-chosen").text("请选择");
  851. $("#tinyType").append("<option value=''>请选择</option>");
  852. if(typeof(bigType) != "undefined" && bigType != "") {
  853. var smallTypeNum = 0;
  854. for(var i=0; i<smalltypeList.length; i++){
  855. if (bigType == smalltypeList[i].bigTypeID) {
  856. smallTypeNum = smallTypeNum + 1;
  857. if(currentSmalltype != null && typeof(currentSmalltype) != "undefined" && currentSmalltype == smalltypeList[i].smallTypeID) {
  858. $("#smallType").append("<option selected value='"+smalltypeList[i].smallTypeID+"'>"+smalltypeList[i].name+"</option>");
  859. $("#smallType").prev().find(".select2-chosen").text(smalltypeList[i].name);
  860. setTimeout(function(){
  861. loadTinyType(currentSmalltype);
  862. },500);
  863. }else{
  864. $("#smallType").append("<option value='"+smalltypeList[i].smallTypeID+"'>"+smalltypeList[i].name+"</option>");
  865. }
  866. }
  867. }
  868. if (smallTypeNum == 0) {
  869. $("#smallType").removeClass("required");
  870. document.getElementById("s2id_smallType").style.cssText = "display: none";
  871. }else {
  872. $("#smallType").addClass("required");
  873. document.getElementById("s2id_smallType").style.cssText = "display: inline-block";
  874. }
  875. } else {
  876. $("#smallType").removeClass("required");
  877. document.getElementById("s2id_smallType").style.cssText = "display: none";
  878. }
  879. loadTinyType();
  880. }
  881. function loadTinyType(id) {
  882. if(id){
  883. $("#smallType").val(id);
  884. $("#smallType").prev().find(".select2-chosen").text($("#smallType option:selected").text());
  885. }
  886. var smallType = $("#smallType option:selected").val();
  887. $("#tinyType").html("");
  888. $("#tinyType").prev().find(".select2-chosen").text("请选择");
  889. $("#tinyType").append("<option value=''>请选择</option>");
  890. if(typeof(smallType) != "undefined" && smallType != "") {
  891. var tinyTypeNum = 0;
  892. for(var i=0; i<tinytypeList.length; i++){
  893. if (smallType == tinytypeList[i].smallTypeID) {
  894. tinyTypeNum = tinyTypeNum + 1;
  895. if(currentTinytype != null && typeof(currentTinytype) != "undefined" && currentTinytype == tinytypeList[i].tinyTypeID) {
  896. $("#tinyType").append("<option selected value='"+tinytypeList[i].tinyTypeID+"'>"+tinytypeList[i].name+"</option>");
  897. $("#tinyType").prev().find(".select2-chosen").text(tinytypeList[i].name);
  898. }else{
  899. $("#tinyType").append("<option value='"+tinytypeList[i].tinyTypeID+"'>"+tinytypeList[i].name+"</option>");
  900. }
  901. }
  902. }
  903. if (tinyTypeNum == 0) {
  904. $("#tinyType").removeClass("required");
  905. document.getElementById("s2id_tinyType").style.cssText = "display: none";
  906. }else {
  907. $("#tinyType").addClass("required");
  908. document.getElementById("s2id_tinyType").style.cssText = "display: inline-block";
  909. }
  910. } else {
  911. document.getElementById("s2id_tinyType").style.cssText = "display: none";
  912. $("#tinyType").removeClass("required");
  913. }
  914. }
  915. //验证字符串最大长度
  916. function checkmaxlength(str) {
  917. var realLength = 0;
  918. for (var i = 0; i < str.length; i++)
  919. {
  920. charCode = str.charCodeAt(i);
  921. if (charCode >= 0 && charCode <= 128)
  922. realLength += 1;
  923. else
  924. realLength += 2;
  925. }
  926. if(realLength > 100){
  927. alertx("商品名称最多50个汉字,即100个字符!当前输入长度为"+realLength);
  928. }
  929. }
  930. //验证字符串最大长度
  931. function checkmaxlengths(str,maxlength) {
  932. var realLength = 0;
  933. for (var i = 0; i < str.length; i++)
  934. {
  935. charCode = str.charCodeAt(i);
  936. if (charCode >= 0 && charCode <= 128)
  937. realLength += 1;
  938. else
  939. realLength += 2;
  940. }
  941. if(realLength > maxlength){
  942. alertx("商品名称最多30个汉字,即60个字符!当前输入长度为"+realLength);
  943. }
  944. }
  945. function checkmaxlengthsBySearch(searckThis,str,maxlength) {
  946. var realLength = 0;
  947. var maxChange = "1";
  948. for (var i = 0; i < str.length; i++)
  949. {
  950. charCode = str.charCodeAt(i);
  951. if (charCode >= 0 && charCode <= 128)
  952. realLength += 1;
  953. else{
  954. realLength += 2;
  955. maxChange = "2";
  956. }
  957. }
  958. if(maxChange == "2"){
  959. var s = str.substr(0,16);
  960. $(searckThis).val(s);
  961. }
  962. if(realLength > maxlength){
  963. alertx("关键字最多16个汉字,即32个字符!");
  964. }
  965. }
  966. function checkPrecisehKeyLength(str) {
  967. var realLength = 0;
  968. for (var i = 0; i < str.length; i++)
  969. {
  970. charCode = str.charCodeAt(i);
  971. if (charCode >= 0 && charCode <= 128)
  972. realLength += 1;
  973. else
  974. realLength += 2;
  975. }
  976. if(realLength > 160){
  977. alertx("精确关键词最多80个汉字,即160个字符!当前输入长度为"+realLength);
  978. }
  979. }
  980. // 添加相关参数
  981. var productParametersIndex = $('#productParametersLength').val() - 1;
  982. $(".addParams").click(function(){
  983. var val = $("#paramsName").val();
  984. // alertx("+++++"+val.length)
  985. productParametersIndex++;
  986. var html = '<div id="paramsItem" class="paramsItem">';
  987. html += '<input name="productParametersList['+[productParametersIndex]+'].paramsName" id="paramsName" style="width:142px" maxlength="10" placeholder="参数名称" type="text" class="input-small"/>&nbsp;';
  988. html += '<input name="productParametersList['+[productParametersIndex]+'].paramsContent" id="paramsContent" style="width:680px" maxlength="50" placeholder="请输入参数信息" type="text" class="input-small"/>&nbsp;';
  989. html += '<span type="button" style="cursor: pointer;color: #0B61A4" onclick="deleteParams(this)"">删除</span>';
  990. html += '</div>';
  991. $("#addParamsItems").append(html).show();
  992. var paramsItemLength = $('.paramsItem').length;
  993. if(paramsItemLength === 50){
  994. $(this).hide();
  995. return
  996. }
  997. });
  998. //添加标签
  999. $(".addTags").click(function(){
  1000. // 获取输入新标签
  1001. var val = $("#inputTags").val();
  1002. // 清空输入框输入
  1003. $("#inputTags").val("");
  1004. if(null === val || "" === val){
  1005. alertx("请输入商品标签");
  1006. return;
  1007. }
  1008. // 添加新标签
  1009. $("#tagsList").append('<div class="tags-li"><input id="tags" name="tags" value="'+val+'" class="tags-s" readonly/><i onclick="removerX(this)">X</i></div>').show();
  1010. var tagsLength = $('.tags-li').length;
  1011. if(tagsLength === 6){
  1012. $(this).hide();
  1013. return
  1014. }
  1015. });
  1016. /**
  1017. * 删除对于标签
  1018. */
  1019. function removerX(ithis) {
  1020. $(ithis).parent().remove();
  1021. var tagsLength = $('.tags-li').length;
  1022. if(tagsLength < 6){
  1023. $('.addTags').show();
  1024. }
  1025. }
  1026. //初始化商品类型
  1027. $(function () {
  1028. changeMachine();
  1029. })
  1030. function changeMachine() {
  1031. var val = $("#productType").val();
  1032. // 0其它,1妆字号,2械字号
  1033. if(val == 1 || val == 0){
  1034. //隐藏械字号
  1035. $(".machineType").hide();
  1036. }else if(val == 2){
  1037. // 显示械字号
  1038. $(".machineType").show();
  1039. }
  1040. }
  1041. //初始化含税信息
  1042. $(function () {
  1043. var includedTax = $("input[name='includedTax']:checked").val();
  1044. var invoiceType = $("input[name='invoiceType']:checked").val();
  1045. var taxPoint = $("#taxPoint").val();
  1046. //1含税,0不含税
  1047. if(includedTax == 1){
  1048. $("#invoiceItem").show().find(".invoice").show().siblings(".notInvoice").hide();
  1049. $("#taxPointDiv").show();
  1050. $("#supplierTaxPointDiv").show();
  1051. }
  1052. if(includedTax == 0){
  1053. $("#invoiceItem").show().find(".invoice").show().siblings(".notInvoice").show();
  1054. // 选择增值税且不为不开发票
  1055. if(invoiceType == 3){
  1056. $("#taxPointDiv").hide();
  1057. $("#supplierTaxPointDiv").hide();
  1058. }else{
  1059. $("#taxPointDiv").show();
  1060. $("#supplierTaxPointDiv").show();
  1061. }
  1062. }
  1063. if(includedTax == 2){
  1064. $("#invoiceItem").hide();
  1065. $("#taxPointDiv").hide();
  1066. $("#supplierTaxPointDiv").hide();
  1067. }
  1068. if(includedTax == "" || includedTax == null){
  1069. $("#invoiceItem").hide();
  1070. $("#taxPointDiv").hide();
  1071. $("#supplierTaxPointDiv").hide();
  1072. }
  1073. //发票初始化
  1074. if(includedTax == 0 && (invoiceType == 1 || invoiceType == 2)){
  1075. $("#taxPointDiv").show();
  1076. $("#supplierTaxPointDiv").show();
  1077. }
  1078. if(includedTax == 1){//含税
  1079. // 一个都没选中默认选中增值税
  1080. if(invoiceType != 1 && invoiceType != 2){
  1081. $("input[name='invoiceType']:eq(0)").attr("checked",'checked');
  1082. }
  1083. }else if (includedTax == 0){//不含税
  1084. // 一个都没选中默认选中增值税
  1085. if(invoiceType != 1 && invoiceType != 2 && invoiceType != 3){
  1086. $("input[name='invoiceType']:eq(0)").attr("checked",'checked');
  1087. }
  1088. if(invoiceType == 1){//增值税
  1089. // 如果税点为空,如果选择的是1(增值:默认13%)、2(普通:6%)
  1090. if(taxPoint == null || taxPoint == ""){
  1091. $("#taxPoint").val(13);
  1092. }
  1093. }else if(invoiceType == 2){//普通发票
  1094. // 如果税点为空,如果选择的是1(增值:默认13%)、2(普通:6%)
  1095. if(taxPoint == null || taxPoint == ""){
  1096. $("#taxPoint").val(6);
  1097. }
  1098. }
  1099. }
  1100. });
  1101. /**
  1102. * @param obj
  1103. * jquery控制input只能输入数字
  1104. */
  1105. function onlynum(obj) {
  1106. obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
  1107. }
  1108. function chageIncludedTax(taxPointValue) {
  1109. //修改选择项
  1110. var includedTax = $("input[name='includedTax']:checked").val();
  1111. var invoiceType = $("input[name='invoiceType']:checked").val();
  1112. var taxPoint = taxPointValue;
  1113. //1含税,0不含税,2未知
  1114. if(includedTax == 1){
  1115. $("#invoiceItem").show().find(".invoice").show().siblings(".notInvoice").hide();
  1116. $("#taxPointDiv").show();
  1117. $("#supplierTaxPointDiv").show();
  1118. }
  1119. if(includedTax == 0){
  1120. $("#invoiceItem").show().find(".invoice").show().siblings(".notInvoice").show();
  1121. // 选择增值税且不为不开发票
  1122. if(invoiceType == 3){
  1123. $("#taxPointDiv").hide();
  1124. $("#supplierTaxPointDiv").hide();
  1125. }else{
  1126. $("#taxPointDiv").show();
  1127. $("#supplierTaxPointDiv").show();
  1128. }
  1129. }
  1130. if(includedTax == 2){
  1131. $("#invoiceItem").hide();
  1132. $("#taxPointDiv").hide();
  1133. $("#supplierTaxPointDiv").hide();
  1134. }
  1135. if(includedTax == "" || includedTax == null){
  1136. $("#invoiceItem").hide();
  1137. $("#taxPointDiv").hide();
  1138. $("#supplierTaxPointDiv").hide();
  1139. }
  1140. if(includedTax == 1){//含税
  1141. // 一个都没选中默认选中增值税
  1142. if(invoiceType != 1 && invoiceType != 2){
  1143. $("input[name='invoiceType']:eq(0)").attr("checked",'checked');
  1144. }
  1145. }else if (includedTax == 0){//不含税
  1146. // 一个都没选中默认选中增值税
  1147. if(invoiceType != 1 && invoiceType != 2 && invoiceType != 3){
  1148. $("input[name='invoiceType']:eq(0)").attr("checked",'checked');
  1149. }
  1150. }
  1151. invoiceType = $("input[name='invoiceType']:checked").val();
  1152. if(invoiceType == 1){//增值税
  1153. // 如果税点为空,如果选择的是1(增值:默认13%)、2(普通:6%)
  1154. if(taxPoint == null || taxPoint == ""){
  1155. $("#taxPoint").val(13);
  1156. $("#supplierTaxPoint").val(13);
  1157. }
  1158. }else if(invoiceType == 2){//普通发票
  1159. // 如果税点为空,如果选择的是1(增值:默认13%)、2(普通:6%)
  1160. if(taxPoint == null || taxPoint == ""){
  1161. $("#taxPoint").val(6);
  1162. $("#supplierTaxPoint").val(6);
  1163. }
  1164. }
  1165. }
  1166. //选择发票类型
  1167. function changeInvoiceType(taxPointValue) {
  1168. var taxPoint = taxPointValue;
  1169. var includedTax = $("input[name='includedTax']:checked").val();
  1170. //选择发票类型:1增值税票,2普通票, 3不能开票
  1171. var invoiceType = $("input[name='invoiceType']:checked").val();
  1172. //只有在选择了不含税才使用税点,不含税里面的
  1173. if( (includedTax == 0 || includedTax == 1) && (invoiceType == 1 || invoiceType == 2)){
  1174. $("#taxPointDiv").show();
  1175. $("#supplierTaxPointDiv").show();
  1176. }else{
  1177. $("#taxPointDiv").hide();
  1178. $("#supplierTaxPointDiv").hide();
  1179. }
  1180. if(invoiceType == 1){//增值税
  1181. // 如果税点为空,如果选择的是1(增值:默认13%)、2(普通:6%)
  1182. if(taxPoint == null || taxPoint == ""){
  1183. $("#taxPoint").val(13);
  1184. $("#supplierTaxPoint").val(13);
  1185. }
  1186. }else if(invoiceType == 2){//普通发票
  1187. // 如果税点为空,如果选择的是1(增值:默认13%)、2(普通:6%)
  1188. if(taxPoint == null || taxPoint == ""){
  1189. $("#taxPoint").val(6);
  1190. $("#supplierTaxPoint").val(6);
  1191. }
  1192. }
  1193. }
  1194. //删除相关参数
  1195. function deleteParams(paramsThis) {
  1196. $(paramsThis).parent().remove();
  1197. var paramsItemLength = $('.paramsItem').length;
  1198. if(paramsItemLength < 50){
  1199. $('.addParams').show();
  1200. }
  1201. }
  1202. //限制两位小数
  1203. function setTwoNumberDecimal(that) {
  1204. var n = parseFloat(that.value);
  1205. that.value = n.toFixed(2)
  1206. }
  1207. //培训相关显示
  1208. function trainingShow() {
  1209. var commodityType = $("input[name='commodityType']:checked").val();
  1210. var trainingType = $("input[name='trainingType']:checked").val();
  1211. if (commodityType == 2){
  1212. $(".training").show();
  1213. if (trainingType == 1){
  1214. $("#trainingFee").show();
  1215. }else {
  1216. $("#trainingFee").hide();
  1217. }
  1218. }else {
  1219. $(".training").hide();
  1220. $("#trainingFee").hide();
  1221. }
  1222. }
  1223. </script>
  1224. </body>
  1225. </html>