add_batch.ftl 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="renderer" content="webkit|ie-comp|ie-stand">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <meta name="viewport"
  8. content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
  9. <meta http-equiv="Cache-Control" content="no-siteapp"/>
  10. <#include "/base/add_base.ftl">
  11. <link href="${path}/common/lib/jquery.ui/jquery-ui.css" rel="stylesheet" type="text/css"/>
  12. <style>
  13. .add-list>li{margin: 10px 0;}
  14. input[type=radio]{-webkit-appearance:none;appearance:none;background: url(${path}/common/images/pts/radio-1.png) center center no-repeat;background-size:auto 100%;width: 20px;height: 20px;margin-right: 10px;}
  15. input[type=radio]:checked{-webkit-appearance:none;appearance:none;background: url(${path}/common/images/pts/radio-2.png) center center no-repeat;background-size:auto 100%;width: 20px;height: 20px;margin-right: 10px;}
  16. </style>
  17. <title>添加批次 - 批次管理 - RST</title>
  18. </head>
  19. <body>
  20. <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
  21. <span class="c-gray en">/</span> 批次管理
  22. <span class="c-gray en">/</span> 添加批次
  23. <a class="btn radius r"
  24. href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
  25. </nav>
  26. <article class="page-container" style="padding: 10px;width: 600px;margin: 0 auto;">
  27. <form action="${path}/admin/batch/save_batch" method="post" class="form form-horizontal" id="form-batch-add">
  28. <div class="row cl">
  29. <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>所属产品:</label>
  30. <div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
  31. <select class="select" size="1" name="produceId">
  32. <#if produceList?? && (produceList?size > 0) >
  33. <#list produceList as produce>
  34. <option value="${produce.produceId}" >${produce.produceName}</option>
  35. </#list>
  36. <#else>
  37. <option value="">暂时没有产品,需要到生产产品页面添加产品</option>
  38. </#if>
  39. </select>
  40. </span>
  41. </div>
  42. </div>
  43. <div class="row cl">
  44. <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>批次编号:</label>
  45. <div class="formControls col-xs-8 col-sm-9">
  46. <input type="text" class="input-text" value="" id="batchNo" name="batchNo" placeholder="请输入1-20位的批次编号,支持字母、数字" datatype="/^[a-zA-Z0-9-_]{1,20}$/" errormsg="请输入1-20位的批次编号,支持字母、数字!">
  47. </div>
  48. </div>
  49. <div class="row cl">
  50. <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>批次数量:</label>
  51. <div class="formControls col-xs-8 col-sm-9 components">
  52. <input type="hidden" id="batchColorQuantity" name="batchColorQuantity">
  53. <table class="table table-border table-bordered table-bg table-hover table-sort">
  54. <thead>
  55. <tr class="text-c">
  56. <th width="150">选择颜色</th>
  57. <th width="60">批次数量</th>
  58. <th width="20">操作</th>
  59. </tr>
  60. </thead>
  61. <tbody id="batchColorAll">
  62. </tbody>
  63. </table>
  64. </div>
  65. </div>
  66. <div class="row cl">
  67. <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
  68. <input class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;新增颜色&nbsp;&nbsp;" onclick="addBatchColor('','')">
  69. </div>
  70. </div>
  71. <div class="row cl">
  72. <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>批次总数量:</label>
  73. <div class="formControls col-xs-8 col-sm-9">
  74. <input type="text" class="input-text" value="" name="batchQuantity" disabled="disabled" style="background: #eee;" placeholder="该批次的总数量" datatype="n1-6" errormsg="批次数量只能输入数字且不能超过999999!">
  75. <input type="hidden" class="input-text" value="" name="batchQuantity" >
  76. </div>
  77. </div>
  78. <div class="row cl">
  79. <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>软件版本:</label>
  80. <div class="formControls col-xs-8 col-sm-9">
  81. <span class="select-box">
  82. <select class="select" size="1" name="batchSoftwareVersionId" id="batchSoftwareVersionId" >
  83. </select>
  84. </span>
  85. <span id="batchSoftwareVersionIdMsg" style="color: red;"></span>
  86. </div>
  87. </div>
  88. <div class="row cl">
  89. <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>Bom单:</label>
  90. <div class="formControls col-xs-8 col-sm-9">
  91. <span class="select-box" >
  92. <select class="select" size="1" name="bomId" id="bomId" datatype="*" errormsg="请选择Bom单">
  93. </select>
  94. </span>
  95. <span id="bomIdMsg" style="color: red;"></span>
  96. </div>
  97. </div>
  98. <div class="row cl">
  99. <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>批次状态:</label>
  100. <div class="formControls col-xs-8 col-sm-9">
  101. <div class="radio-box">
  102. <input type="radio" id="batchStatus-1" name="batchStatus" checked value="1">
  103. <label for="batchStatus-1">立即使用</label>
  104. </div>
  105. <div class="radio-box">
  106. <input type="radio" id="batchStatus-2" name="batchStatus" value="0">
  107. <label for="batchStatus-2">暂不使用</label>
  108. </div>
  109. </div>
  110. </div>
  111. <div class="row cl">
  112. <label class="form-label col-xs-4 col-sm-3">批次描述:</label>
  113. <div class="formControls col-xs-8 col-sm-9">
  114. <textarea name="batchDesc" id="batchDesc" cols="" rows="" class="textarea"
  115. placeholder="批次描述,最多支持100字符" onKeyUp="$.Huitextarealength(this,100)" ></textarea>
  116. <p class="textarea-numberbar"><em class="textarea-length">0</em>/100</p>
  117. </div>
  118. </div>
  119. <div class="row cl">
  120. <label class="form-label col-xs-4 col-sm-3"></label>
  121. <span class="c-red">*提示</span><span>:如果设置状态为 使用,将停止使用同一个产品的其他批次!</span>
  122. </div>
  123. <div class="row cl">
  124. <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
  125. <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
  126. </div>
  127. </div>
  128. </form>
  129. </article>
  130. <script type="text/javascript">
  131. /*颜色枚举值*/
  132. var colorAll = ['黑色','白色','金色','红色','蓝色','绿色','橙色','黄色','青色','紫色','粉色','蔷薇粉','云烟紫','琉璃绿','亚麻灰'];
  133. /*修改批次时,获取之前的批次编号,添加页面为空*/
  134. var upBatchNo = null;
  135. $(function(){
  136. $("#form-batch-add").Validform({
  137. tiptype: function (msg, o, cssctl) {
  138. if (o.type == 3) {//失败
  139. layer.msg(msg, {icon: 5, time: 3000});
  140. $(window).scrollTop(o.obj.offset().top - 40);
  141. }
  142. },
  143. datatype: {//自定义验证类型
  144. },
  145. ignoreHidden: true,
  146. tipSweep: true, //若为true,则只在表单提交时验证
  147. ajaxPost: true, //异步提交
  148. beforeCheck: function (curform) { //验证通过之前执行的函数
  149. },
  150. beforeSubmit: function (curform) { //验证通过之后执行的函数
  151. //批次编号不能重复 -- 重复为false 不重复(可用)为true
  152. var batchNo = $("#batchNo").val();
  153. if(upBatchNo == null || typeof(upBatchNo) == "undefined"){
  154. if(!isValiBatchNo(batchNo)){
  155. layer.msg("批次编号重复", {icon: 5, time: 3000});
  156. return false;
  157. }
  158. }
  159. //计算批次数量
  160. calculationQuantity();
  161. //合并 批次颜色信息
  162. var colorList = new Array();
  163. $("#batchColorAll").find("tr").each(function(){
  164. var ptsBatchColor = {};
  165. ptsBatchColor.colorName = $(this).find("[name='colorName']").eq(0).val();
  166. ptsBatchColor.colorQuantity = $(this).find("[name='colorQuantity']").eq(0).val();
  167. colorList.push(ptsBatchColor);
  168. })
  169. $("#batchColorQuantity").val(JSON.stringify(colorList));
  170. },
  171. callback: function (data) {//异步回调函数
  172. if (data) {
  173. var index = layer.alert(data.resultMsg, function () {
  174. if (data.resultCode == 200) {
  175. location.href = "${path}/admin/batch/_batch_list";
  176. } else {
  177. layer.close(index);
  178. }
  179. });
  180. }
  181. }
  182. });
  183. })
  184. $(function () {
  185. /*添加页面初始化,将根据产品的来获取bom和软件版本*/
  186. var produceId = $("[name='produceId']").val();
  187. getBomByProduce(produceId);
  188. getVersionByProduce(produceId);
  189. /*初始化一个颜色*/
  190. addBatchColor('','');
  191. /*监听产品选择*/
  192. $("[name='produceId']").change(function(){
  193. var produceId = $(this).val();
  194. getBomByProduce(produceId);
  195. getVersionByProduce(produceId);
  196. })
  197. })
  198. /*判断batch是否重复 重复为false 不重复(可用)为true */
  199. function isValiBatchNo(batchNo) {
  200. var boolean = false;
  201. $.ajax({
  202. type: "POST",
  203. data: {
  204. batchNo : batchNo
  205. },
  206. url: "${path}/admin/batch/is_valiBatchNo",
  207. async: false,
  208. success: function(data){
  209. if (data.returnCode == 200 ) {
  210. if(data.returnMsg.ptsBatch == null ){
  211. boolean = true
  212. }
  213. }else{
  214. layer.msg(data.resultMsg, {icon: 5, time: 3000});
  215. }
  216. },
  217. error: function(XmlHttpRequest, textStatus, errorThrown){
  218. }
  219. });
  220. return boolean;
  221. }
  222. /*根据产品id,获取bom集合*/
  223. function getBomByProduce(produceId){
  224. $.ajax({
  225. type: "POST",
  226. data: {
  227. produceId : produceId
  228. },
  229. url: "${path}/admin/bom/get_listBom",
  230. async: false,
  231. success: function(data){
  232. var html = '';
  233. if (data.returnCode == 200) {
  234. var bomList = data.returnMsg.ptsBomsList;
  235. for(var i=0;i<bomList.length;i++){
  236. html += '<option value="'+ bomList[i].bomId +'">'+ bomList[i].bomName +'</option>';
  237. }
  238. }
  239. if(data.returnCode != 200 || data.returnMsg.ptsBomsList <1){
  240. $("#bomIdMsg").html("系统没有对应产品的Bom单,请到Bom单管理中添加Bom单");
  241. }else{
  242. $("#bomIdMsg").html("");
  243. }
  244. $("[name='bomId']").html(html);
  245. },
  246. error: function(XmlHttpRequest, textStatus, errorThrown){
  247. }
  248. });
  249. }
  250. /*根据产品获取软件版本*/
  251. function getVersionByProduce(produceId) {
  252. $.ajax({
  253. type: "POST",
  254. data: {
  255. produceId : produceId
  256. },
  257. url: "${path}/admin/batch/get_version",
  258. async: false,
  259. success: function(data){
  260. var html = '';
  261. if (data.returnCode == 200) {
  262. var versionList = data.returnMsg.ptsMachineVersionList;
  263. for(var i=0;i<versionList.length;i++){
  264. html += '<option value="'+ versionList[i].machineVersionId +'">'+ versionList[i].machineVersionName +'('+ versionList[i].machineVersionNo +')</option>';
  265. }
  266. }
  267. if(data.returnCode != 200 || data.returnMsg.ptsMachineVersionList <1){
  268. $("#batchSoftwareVersionIdMsg").html("系统没有对应产品的软件版本,请到版本管理中添加软件版本");
  269. }else{
  270. $("#batchSoftwareVersionIdMsg").html("");
  271. }
  272. $("[name='batchSoftwareVersionId']").html(html);
  273. },
  274. error: function(XmlHttpRequest, textStatus, errorThrown){
  275. }
  276. });
  277. }
  278. /**
  279. * 添加颜色
  280. * colorName
  281. * */
  282. function addBatchColor(colorName,colorQuantity) {
  283. //判断颜色数量
  284. if(getColorNumber() >= 9){
  285. layer.msg("添加的颜色不能超过9个", {icon: 5, time: 3000});
  286. return false;
  287. }
  288. var notAddColor = colorAll
  289. var opHtml = '';
  290. for(var i=0;i<notAddColor.length;i++){
  291. opHtml += '<option value="'+ notAddColor[i] +'" >'+ notAddColor[i] + '</option>'
  292. }
  293. var html = '<tr class="text-c">'
  294. +'<td>'
  295. +'<select class="select" size="1" name="colorName" style="height: 30px;">'
  296. + opHtml
  297. +'</select>'
  298. +'</td>'
  299. +'<td>'
  300. +'<input type="text" class="input-text colorQuantity" value="" onblur="calculationQuantity()" name="colorQuantity" placeholder="数量" datatype="n1-5" errormsg="零件数量只能为数字且不能超过99999!">'
  301. +'</td>'
  302. +'<td>'
  303. +'<a style="" href="javascript:void(0);" title="删除" onclick="delComponent(this,1)"> '
  304. +'<i class="Hui-iconfont">&#xe609;</i>'
  305. +'</a>'
  306. +'</td> '
  307. +'</tr>';
  308. $("#batchColorAll").append(html);
  309. }
  310. /*获取颜色数量*/
  311. function getColorNumber(){
  312. var number = $("#batchColorAll").find("tr").length;
  313. return number;
  314. }
  315. /*删除颜色 type=all时删除所有的颜色,但必须要保留一个颜色 */
  316. function delComponent(node,type) {
  317. if(type == "all"){
  318. $("#batchColorAll").find("tr").each(function () {
  319. $(this).remove();
  320. })
  321. }else{
  322. //删除零件必须保证还有一个颜色
  323. var batchLength = $("#batchColorAll").find("tr").length;
  324. if(batchLength > 1){
  325. $(node).parent().parent().remove();
  326. }else{
  327. layer.msg('必须要有一个颜色', {icon: 5, time: 3000});
  328. }
  329. }
  330. //删除操作需要计算总数量
  331. calculationQuantity();
  332. }
  333. /**计算批次总数量*/
  334. function calculationQuantity(){
  335. var quantity = 0;
  336. $("#batchColorAll").find("[name='colorQuantity']").each(function (){
  337. var colorQuantity = $(this).val();
  338. var myreg = /^[0-9]*$/;
  339. if( colorQuantity != null && colorQuantity != "" && typeof(colorQuantity) != "undefined"){
  340. if(myreg.test(colorQuantity))
  341. {
  342. quantity += parseInt(colorQuantity);
  343. }
  344. }
  345. })
  346. $("[name='batchQuantity']").val(quantity);
  347. }
  348. /*获取未被添加的颜色*/
  349. // function getNotAddColorAll() {
  350. // if($("#batchColorAll").find("tr") != null && $("#batchColorAll").find("tr").length > 0){
  351. // $("#batchColorAll").find("tr").each(function (){
  352. // for(var i=0; i<colorAll.length;i++){
  353. // colorAll.remove(1);
  354. // }
  355. // })
  356. // }else{
  357. // return colorAll;
  358. // }
  359. // }
  360. </script>
  361. <!--/请在上方写此页面业务相关的脚本-->
  362. </body>
  363. </html>