update_batch.ftl 19 KB

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