productEdit.jsp 59 KB

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