add_change.html 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>新增批次</title>
  6. <meta name="renderer" content="webkit">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  9. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  10. <meta name="apple-mobile-web-app-capable" content="yes">
  11. <meta name="format-detection" content="telephone=no">
  12. <link rel="stylesheet" type="text/css" href="../../layui/css/layui.css" />
  13. <link rel="stylesheet" type="text/css" href="../../css/common.css" />
  14. <link rel="stylesheet" type="text/css" href="../../css/inputTags.css" />
  15. <style type="text/css">
  16. .ui-required:before {
  17. content: "*";
  18. color: red;
  19. vertical-align: middle;
  20. }
  21. #roleSelectViwe .layui-form-item {
  22. margin-bottom: 0
  23. }
  24. #roleSelectViwe .layui-input-inline {
  25. width: calc(100% - 110px);
  26. margin-right: 0;
  27. }
  28. .region {
  29. padding-left: 10px;
  30. height: 38px;
  31. line-height: 38px;
  32. background-color: #fff;
  33. border-radius: 2px;
  34. border: 1px solid #e6e6e6;
  35. width: calc(100% - 132px) !important;
  36. }
  37. .userTip {
  38. color: #666;
  39. font-size: 12px;
  40. }
  41. .userTip b {
  42. color: #333;
  43. }
  44. .my-middle {
  45. line-height: 36px;
  46. }
  47. .my-button {
  48. width: 60%;
  49. margin-left: 20%;
  50. height: 40px;
  51. text-align: center;
  52. line-height: 40px;
  53. border: 1px dashed;
  54. border-radius: 5px;
  55. }
  56. .my-inline {
  57. display: inline-block;
  58. float: left;
  59. text-align: center;
  60. height: 38px;
  61. line-height: 38px;
  62. width: 10%;
  63. }
  64. .my-images-inline {
  65. display: inline-block;
  66. width: 104px;
  67. height: 104px;
  68. border: 1px dashed;
  69. border-radius: 5px;
  70. padding: 4px;
  71. vertical-align: top;
  72. margin: 4px;
  73. }
  74. .my-img {
  75. width: 100%;
  76. height: 100%;
  77. }
  78. .my-images-add {
  79. display: inline-block;
  80. text-align: center;
  81. line-height: 103px;
  82. font-size: 32px;
  83. cursor: pointer;
  84. background-color: #fbfbfb;
  85. }
  86. .my-del {
  87. background-color: black;
  88. color: white;
  89. }
  90. .button-delImage.button-delAssayImage {
  91. position: relative;
  92. left: -2px;
  93. top: -106px;
  94. }
  95. </style>
  96. </head>
  97. <body>
  98. <form class="layui-form" action="" lay-filter="addForm">
  99. <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
  100. <ul class="layui-tab-title">
  101. <li class="layui-this" lay-id="1">基础信息</li>
  102. <li lay-id="2">原料生产</li>
  103. <li lay-id="3">加工流通</li>
  104. <li lay-id="4">检疫检验</li>
  105. </ul>
  106. <div class="layui-tab-content">
  107. <div class="layui-tab-item layui-show">
  108. <div class="layui-form-item">
  109. <label class="layui-form-label ui-required">产品分类</label>
  110. <div class="layui-input-block my-middle" id="goodsName">
  111. </div>
  112. </div>
  113. <div class="layui-form-item">
  114. <label class="layui-form-label ui-required">批次编码</label>
  115. <div class="layui-input-block">
  116. <input type="text" name="goodsBatchNo" lay-verify="required" maxlength="20" placeholder="请输入批次编码" autocomplete="off" class="layui-input">
  117. </div>
  118. </div>
  119. <div class="layui-form-item">
  120. <label class="layui-form-label ui-required">产品规格</label>
  121. <div class="layui-input-block">
  122. <input type="text" name="goodsUnit" lay-verify="required" maxlength="20" placeholder="请输入产品规格" autocomplete="off" class="layui-input">
  123. </div>
  124. </div>
  125. <div class="layui-form-item">
  126. <label class="layui-form-label ui-required">生产地</label>
  127. <div class="layui-input-block">
  128. <select name="fkFieldGuid" lay-verify="required" lay-filter="roles" id="rolesView"></select>
  129. </div>
  130. </div>
  131. <div class="layui-form-item">
  132. <label class="layui-form-label ui-required">生产日期</label>
  133. <div class="layui-input-block">
  134. <input type="text" name="productDateStr" id="goodsProductDate" lay-verify="required" maxlength="20" placeholder="请输入生产日期" autocomplete="off" class="layui-input">
  135. </div>
  136. </div>
  137. <div class="layui-form-item">
  138. <label class="layui-form-label ui-required">保质期</label>
  139. <div class="layui-input-block">
  140. <input type="text" name="goodsExpired" lay-verify="" maxlength="10" placeholder="请输入保质期" autocomplete="off" class="layui-input">
  141. </div>
  142. </div>
  143. <div class="layui-form-item">
  144. <label class="layui-form-label ui-required">产品标签</label>
  145. <div class="layui-input-block">
  146. <div class="tags" id="tags">
  147. <input type="text" id="inputTags" placeholder="回车生成标签" autocomplete="off">
  148. </div>
  149. </div>
  150. </div>
  151. <!-- <div class="layui-form-item">
  152. <label class="layui-form-label">销售网址</label>
  153. <div class="layui-input-block">
  154. <input type="text" name="goodsSaleUrl" lay-verify="" maxlength="300" placeholder="请输入在线销售网址" autocomplete="off"
  155. class="layui-input">
  156. </div>
  157. </div> -->
  158. <div class="layui-card">
  159. <div class="layui-card-header">自定义信息</div>
  160. <div class="layui-card-body">
  161. <div id="auxListDiv"></div>
  162. <div class="layui-form-item">
  163. <div class="my-button my-button-product">+添加</div>
  164. </div>
  165. </div>
  166. </div>
  167. <div class="layui-card">
  168. <div class="layui-card-header">产品图片视频</div>
  169. <div class="layui-card-body">
  170. <div id="imageListDiv"></div>
  171. 图片视频上传完毕后请记得按保存哦
  172. </div>
  173. </div>
  174. </div>
  175. <div class="layui-tab-item">
  176. <div class="layui-card">
  177. <div class="layui-card-header">原料信息</div>
  178. <div class="layui-card-body">
  179. <div style="display: flex;">
  180. <input class="layui-input" style="margin-right: 15px;" type="text" name="rawMaterial" />
  181. <button type="button" class="layui-btn" id="rawMaterialInfoAdd">新增</button>
  182. </div>
  183. <style type="text/css">
  184. #rawMaterialInfo li {
  185. display: inline-block;
  186. border: 1px solid rgba(0, 0, 0, .2);
  187. background: rgba(0, 0, 0, .1);
  188. border-radius: .2em;
  189. padding: .3em .6em;
  190. margin: 8px;
  191. }
  192. #rawMaterialInfo li i:hover {
  193. cursor: pointer;
  194. }
  195. </style>
  196. <script type="text/html" id='rawMaterialInfoTpl'>
  197. {{# layui.each(d,function(i,item){ }}
  198. <li>
  199. <div style="display: flex;align-items: center;">
  200. <span>{{item.inputsProcessName}}</span>
  201. {{#if ("view" !== location.searchObj().event){}}
  202. <i data-bind="{{i||0}}" class="layui-icon layui-icon-close" style="margin-left: 5px;"></i>
  203. {{#} }}
  204. </div>
  205. </li>
  206. {{# });}}
  207. </script>
  208. <ol id="rawMaterialInfo"></ol>
  209. </div>
  210. </div>
  211. <div class="layui-card">
  212. <div class="layui-card-header">生产过程信息</div>
  213. <div class="layui-card-body">
  214. <div id="produceProcessInfoForm">
  215. <div class="layui-input-inline">
  216. <label class="layui-form-label">执行项</label>
  217. <div class="layui-input-inline">
  218. <input class="layui-input" style="margin-right: 15px;" type="text" name="processItem" />
  219. </div>
  220. </div>
  221. <div class="layui-input-inline">
  222. <label class="layui-form-label">执行人</label>
  223. <div class="layui-input-inline">
  224. <input class="layui-input" style="margin-right: 15px;" type="text" name="processUser" />
  225. </div>
  226. </div>
  227. <div class="layui-input-inline">
  228. <label class="layui-form-label">开始日期</label>
  229. <div class="layui-input-inline">
  230. <input class="layui-input" style="margin-right: 15px;" type="text" name="processTime" id="produceProcessInfoForm_processTime" />
  231. </div>
  232. </div>
  233. <div class="layui-input-inline">
  234. <label class="layui-form-label">执行描述</label>
  235. <div class="layui-input-inline">
  236. <input class="layui-input" style="margin-right: 15px;" type="text" name="processDesc" />
  237. </div>
  238. </div>
  239. <input type="hidden" name="processType" value="1" />
  240. <button type="button" class="layui-btn" id='produceProcessInfoAdd'>新增</button>
  241. <table class="layui-hide" id="produceProcessInfo" lay-filter="produceProcessInfo"></table>
  242. </div>
  243. </div>
  244. </div>
  245. </div>
  246. <div class="layui-tab-item" id="processingCirculationInfoForm">
  247. <div class="layui-input-inline">
  248. <label class="layui-form-label">执行项</label>
  249. <div class="layui-input-inline">
  250. <input class="layui-input" style="margin-right: 15px;" type="text" name="processItem" />
  251. </div>
  252. </div>
  253. <div class="layui-input-inline">
  254. <label class="layui-form-label">执行人</label>
  255. <div class="layui-input-inline">
  256. <input class="layui-input" style="margin-right: 15px;" type="text" name="processUser" />
  257. </div>
  258. </div>
  259. <div class="layui-input-inline">
  260. <label class="layui-form-label">开始日期</label>
  261. <div class="layui-input-inline">
  262. <input class="layui-input" style="margin-right: 15px;" type="text" name="processTime" id="processingCirculationInfoForm_processTime" />
  263. </div>
  264. </div>
  265. <div class="layui-input-inline">
  266. <label class="layui-form-label">执行描述</label>
  267. <div class="layui-input-inline">
  268. <input class="layui-input" style="margin-right: 15px;" type="text" name="processDesc" />
  269. </div>
  270. </div>
  271. <input type="hidden" name="processType" value="2" />
  272. <button type="button" class="layui-btn" id='processingCirculationInfoAdd'>新增</button>
  273. <table class="layui-hide" id="processingCirculationInfo" lay-filter="processingCirculationInfo"></table>
  274. </div>
  275. <div class="layui-tab-item">
  276. <div class="layui-card">
  277. <div class="layui-card-header">检验信息</div>
  278. <div class="layui-card-body">
  279. <div class="layui-form-item">
  280. <label class="layui-form-label">检验单位:</label>
  281. <div class="layui-input-block">
  282. <input type="text" name="assayDepartment" lay-verify="" maxlength="10" placeholder="请输入检验单位" autocomplete="off" class="layui-input">
  283. </div>
  284. </div>
  285. <div id="assayAuxListDiv"></div>
  286. <div class="layui-form-item">
  287. <div class="my-button my-button-assay">+添加</div>
  288. </div>
  289. </div>
  290. </div>
  291. <div class="layui-card">
  292. <div class="layui-card-header">检验报告</div>
  293. <div class="layui-card-body">
  294. <div id="assayImageListDiv"></div>
  295. 图片视频上传完毕后请记得按保存哦
  296. </div>
  297. </div>
  298. </div>
  299. </div>
  300. <div class="layui-form-item" style="text-align: center;padding: 25px;">
  301. <button class="layui-btn" lay-submit lay-filter="formDemo">保存</button>
  302. <button type="reset" class="layui-btn layui-btn-primary close-win">取消</button>
  303. </div>
  304. </div>
  305. </form>
  306. <script type="text/html" id="typeHtmlTpl">
  307. <option value="">请选择</option>
  308. {{# if(!d.list){d.list = []}; layui.each(d.list, function(index, item){ }}
  309. <option value="{{item.guid}}" oneMap="{{item.oneMap}}">{{item.fieldName}}</option>
  310. {{# }); }}
  311. </script>
  312. <script type="text/html" id="auxHtmlTpl">
  313. {{# if(!d.list){d.list = []}; layui.each(d.list, function(index, item){ }}
  314. <div class="layui-form-item">
  315. <label class="layui-form-label">自定义项{{index+1}}:</label>
  316. <div class="my-inline" style="width: 20%">
  317. <input type="text" name="auxItme" maxlength="20" lay-verify="required" placeholder="标题" autocomplete="off" class="layui-input" value="{{item.auxItme}}">
  318. </div>
  319. <div class="my-inline">--</div>
  320. <div class="my-inline" style="width: 40%">
  321. <input type="text" name="auxItmeVal" maxlength="100" lay-verify="required" placeholder="项" autocomplete="off" class="layui-input" value="{{item.auxItmeVal}}">
  322. </div>
  323. <div class="my-inline">
  324. <i class="layui-icon my-del button-delAux" data-bind="{{index}}" title="删除" data-icon="&#x1006;">&#x1006;</i>
  325. </div>
  326. </div>
  327. {{# }); }}
  328. </script>
  329. <script type="text/html" id="imageHtmlTpl">
  330. <div class="layui-form-item">
  331. {{# if(!d.list){d.list = []}; layui.each(d.list, function(index, item){ }}
  332. <div class="my-images-inline">
  333. {{#if ("jpg|jpeg|png|gif|bmp".indexOf(item.substring(item.lastIndexOf(".")+1))==-1){}}
  334. <video class="my-img" src="{{window.hywa.config.href}}/{{item}}" autoplay loop></video>
  335. {{#}else{}}
  336. <img class="my-img" src="{{window.hywa.config.href}}/{{item}}">
  337. {{#} }}
  338. <i class="layui-icon my-del button-delImage" data-bind="{{index}}" title="删除" data-icon="&#x1006;">&#x1006;</i>
  339. </div>
  340. {{# }); }}
  341. <div class="my-images-inline my-images-add" id="imageUploadBtn">+</div>
  342. </div>
  343. </script>
  344. <script type="text/html" id="assayAuxHtmlTpl">
  345. {{# if(!d.list){d.list = []}; layui.each(d.list, function(index, item){ }}
  346. <div class="layui-form-item">
  347. <label class="layui-form-label">{{#if(index==0){}}检验数据:{{#} }}</label>
  348. <div class="my-inline" style="width: 20%">
  349. <input type="text" name="auxItme2" maxlength="20" placeholder="检验项名" autocomplete="off" class="layui-input" value="{{item.auxItme}}">
  350. </div>
  351. <div class="my-inline">--</div>
  352. <div class="my-inline" style="width: 40%">
  353. <input type="text" name="auxItmeVal2" maxlength="100" placeholder="数值和单位" autocomplete="off" class="layui-input" value="{{item.auxItmeVal}}">
  354. </div>
  355. <div class="my-inline">
  356. <i class="layui-icon my-del button-delAssay" data-bind="{{index}}" title="删除" data-icon="&#x1006;">&#x1006;</i>
  357. </div>
  358. </div>
  359. {{# }); }}
  360. </script>
  361. <script type="text/html" id="assayImageHtmlTpl">
  362. <div class="layui-form-item">
  363. {{# if(!d.list){d.list = []}; layui.each(d.list, function(index, item){ }}
  364. <div class="my-images-inline">
  365. {{#if ("jpg|jpeg|png|gif|bmp".indexOf(item.substring(item.lastIndexOf(".")+1))==-1){}}
  366. <video class="my-img" src="{{window.hywa.config.href}}/{{item}}" autoplay loop></video>
  367. {{#}else{}}
  368. <img class="my-img" src="{{window.hywa.config.href}}/{{item}}">
  369. {{#} }}
  370. <i class="layui-icon my-del button-delAssayImage" data-bind="{{index}}" title="删除" data-icon="&#x1006;">&#x1006;</i>
  371. </div>
  372. {{# }); }}
  373. <div class="my-images-inline my-images-add" id="assayImageUploadBtn">+</div>
  374. </div>
  375. </script>
  376. <script type="text/javascript">
  377. function loadJS(url) {
  378. document.write("<script src='" + url + "?ver=" + new Date().getTime() + "'><\/script>")
  379. }
  380. loadJS("../../layui/layui.js");
  381. loadJS("../../js/ajaxhook.min.js");
  382. loadJS("../../js/config.js");
  383. </script>
  384. <script type="text/javascript">
  385. layui.config({
  386. base: "../../js/layuiPlugins/"
  387. }).use(["form", 'layer', 'laytpl', 'jquery', 'laydate', 'element', 'upload', 'table', 'inputTags'], function () {
  388. var form = layui.form,
  389. layer = layui.layer,
  390. laytpl = layui.laytpl,
  391. $ = layui.jquery,
  392. laydate = layui.laydate,
  393. element = layui.element,
  394. upload = layui.upload,
  395. inputTags = layui.inputTags
  396. table = layui.table;
  397. laydate.render({
  398. elem: '#goodsProductDate' //指定元素
  399. });
  400. laydate.render({
  401. type: 'datetime',
  402. elem: '#produceProcessInfoForm_processTime' //指定元素
  403. });
  404. laydate.render({
  405. type: 'datetime',
  406. elem: '#processingCirculationInfoForm_processTime' //指定元素
  407. });
  408. var funcName = "pdinfo";
  409. var rolesViewOnemapParam = "";
  410. var formData = {
  411. guid: (JSON.stringify(location.searchObj()) != "{}") ? location.searchObj().guid || null : null, //带参传入ID
  412. current: {
  413. auxList: [],
  414. imagesList: [],
  415. assayInfoForm: {
  416. imagesList: [],
  417. auxList: []
  418. }
  419. }, //当前表单数据
  420. select_data: "select_" + funcName, //查询用户
  421. save_data: (location.searchObj().guid ? 'edit' : 'add') + '_' + funcName, //查询用户
  422. formLayFilter: "addForm", //表单容器
  423. closeModal: function () { //关闭当前窗口
  424. parent.layer.close(parent.layer.getFrameIndex(window.name));
  425. }
  426. };
  427. var option = {
  428. elem: '#imageUploadBtn',
  429. url: 'uploadImage',
  430. accept: "file",
  431. exts: "jpg|jpeg|png|gif|bmp|mp4|ogg|webm|avi|wma|rmvb|rm|flash|3gp|flv",
  432. size: 10240, //kb
  433. before: function () {
  434. uploadMsg = layer.msg('正在上传中……', {
  435. icon: 16,
  436. fixed: false,
  437. time: 0
  438. });
  439. },
  440. done: function (res) {
  441. layer.close(uploadMsg);
  442. formData.current.imagesList.push(res.data[0]);
  443. imageTpl({
  444. elem: "#imageListDiv",
  445. list: formData.current.imagesList
  446. });
  447. },
  448. error: function () { }
  449. };
  450. var assayOption = {
  451. elem: '#assayImageUploadBtn',
  452. url: 'uploadImage',
  453. accept: "file",
  454. exts: "jpg|jpeg|png|gif|bmp|mp4|ogg|webm|avi|wma|rmvb|rm|flash|3gp|flv",
  455. size: 10240, //kb
  456. before: function () {
  457. uploadMsg = layer.msg('正在上传中……', {
  458. icon: 16,
  459. fixed: false,
  460. time: 0
  461. });
  462. },
  463. done: function (res) {
  464. layer.close(uploadMsg);
  465. formData.current.assayInfoForm.imagesList.push(res.data[0]);
  466. assayImageTpl({
  467. elem: "#assayImageListDiv",
  468. list: formData.current.assayInfoForm.imagesList
  469. });
  470. },
  471. error: function () { }
  472. };
  473. //自定义项列表模板
  474. function auxTpl(obj) {
  475. laytpl(auxHtmlTpl.innerHTML).render(obj, function (html) {
  476. $(obj.elem).html(html);
  477. $(".button-delAux").on("click", function (e) {
  478. var sortno = e.target.getAttribute("data-bind");
  479. for (var i = formData.current.auxList.length - 1; i >= 0; i--) {
  480. if ($("input[name='auxItme']")[i]) {
  481. formData.current.auxList[i].auxItme = $("input[name='auxItme']")[i].value;
  482. formData.current.auxList[i].auxItmeVal = $("input[name='auxItmeVal']")[i].value;
  483. }
  484. }
  485. formData.current.auxList.splice(sortno, 1);
  486. auxTpl({
  487. elem: "#auxListDiv",
  488. list: formData.current.auxList
  489. });
  490. });
  491. });
  492. }
  493. //检验数据列表模板
  494. function assayTpl(obj) {
  495. laytpl(assayAuxHtmlTpl.innerHTML).render(obj, function (html) {
  496. $(obj.elem).html(html);
  497. $(".button-delAssay").on("click", function (e) {
  498. var sortno = e.target.getAttribute("data-bind");
  499. var index = formData.current.assayInfoForm.auxList.length;
  500. for (var i = index - 1; i >= 0; i--) {
  501. if ($("input[name='auxItme2']")[i]) {
  502. formData.current.assayInfoForm.auxList[i].auxItme = $("input[name='auxItme2']")[i].value;
  503. formData.current.assayInfoForm.auxList[i].auxItmeVal = $("input[name='auxItmeVal2']")[i].value;
  504. }
  505. }
  506. formData.current.assayInfoForm.auxList.splice(sortno, 1);
  507. assayTpl({
  508. elem: "#assayAuxListDiv",
  509. list: formData.current.assayInfoForm.auxList
  510. });
  511. });
  512. });
  513. }
  514. //下拉列表模板
  515. function typeTpl(obj) {
  516. laytpl(typeHtmlTpl.innerHTML).render(obj, function (html) {
  517. $(obj.elem).html(html);
  518. form.render();
  519. });
  520. }
  521. //图片列表模板
  522. function imageTpl(obj) {
  523. laytpl(imageHtmlTpl.innerHTML).render(obj, function (html) {
  524. $(obj.elem).html(html);
  525. upload.render(option);
  526. $(".button-delImage").on("click", function (e) {
  527. formData.current.imagesList.splice(e.target.getAttribute("data-bind"), 1);
  528. imageTpl({
  529. elem: "#imageListDiv",
  530. list: formData.current.imagesList
  531. });
  532. });
  533. });
  534. }
  535. //检验图片列表模板
  536. function assayImageTpl(obj) {
  537. laytpl(assayImageHtmlTpl.innerHTML).render(obj, function (html) {
  538. $(obj.elem).html(html);
  539. upload.render(assayOption);
  540. $(".button-delAssayImage").on("click", function (e) {
  541. formData.current.assayInfoForm.imagesList.splice(e.target.getAttribute("data-bind"), 1);
  542. assayImageTpl({
  543. elem: "#assayImageListDiv",
  544. list: formData.current.assayInfoForm.imagesList
  545. });
  546. });
  547. });
  548. }
  549. //原料信息模板
  550. function rawMaterial(data) {
  551. laytpl(rawMaterialInfoTpl.innerHTML).render(data, function (html) {
  552. $('#rawMaterialInfo').html(html);
  553. });
  554. }
  555. $('#rawMaterialInfo').on("click", 'li i', function (e) { //删除
  556. if (formData.guid) {
  557. $.ajax({
  558. url: 'del_rawMaterialInfo',
  559. data: {
  560. guid: formData.current.inputsFormList[e.target.getAttribute("data-bind")].guid
  561. },
  562. success: function (res) {
  563. }
  564. });
  565. }
  566. formData.current.inputsFormList.splice(e.target.getAttribute("data-bind"), 1);
  567. rawMaterial(formData.current.inputsFormList);
  568. });
  569. $("#rawMaterialInfoAdd").on('click', function () {
  570. let val = $('input[name="rawMaterial"]').val();
  571. if (val) {
  572. formData.current.inputsFormList = formData.current.inputsFormList || [];
  573. formData.current.inputsFormList.push({
  574. inputsProcessName: val
  575. });
  576. rawMaterial(formData.current.inputsFormList);
  577. if (formData.guid) {
  578. formData.submitInfo('add_rawMaterialInfo', {
  579. fkGoodsBatchGuid: formData.guid,
  580. inputsProcessName: val
  581. }, function () {
  582. formData.getCurrent();
  583. });
  584. }
  585. }
  586. });
  587. //生产过程信息
  588. formData.current.materialList = formData.current.materialList || [];
  589. //编号
  590. for (let i in formData.current.materialList) {
  591. formData.current.materialList[i].index = i;
  592. }
  593. let produceProcessInfoOptions = {
  594. id: "produceProcessInfo",
  595. elem: '#produceProcessInfo',
  596. data: formData.current.materialList,
  597. cols: [
  598. [{
  599. field: 'processItem',
  600. title: '执行项',
  601. edit: 'text',
  602. event: 'edit',
  603. align: 'center'
  604. }, {
  605. field: 'processTime',
  606. title: '开始时间',
  607. edit: 'time',
  608. align: 'center',
  609. event: 'edit'
  610. }, {
  611. field: 'processUser',
  612. title: '执行人',
  613. edit: 'text',
  614. align: 'center',
  615. event: 'edit'
  616. }, {
  617. field: 'processDesc',
  618. title: '执行描述',
  619. edit: 'text',
  620. align: 'center',
  621. event: 'edit'
  622. }, {
  623. field: 'processImgs',
  624. title: '上传过程照片',
  625. // toolbar: `<div><a href="javascript:void(0);" lay-event="processImgsPreview">{{d.processImgs || ''}}</a></div>`,
  626. toolbar: ("view" !== location.searchObj().event) ? `<div>
  627. <a class="layui-btn layui-btn-xs" lay-event="upload">上传</a>
  628. <a target="_blank" href="{{window.hywa.config.href}}/{{d.processImgs || ''}}" lay-event="aHref">{{d.processImgs || ''}}</a>
  629. </div>` : `<div>
  630. <a target="_blank" href="{{window.hywa.config.href}}/{{d.processImgs || ''}}" lay-event="aHref">{{d.processImgs || ''}}</a>
  631. </div>`,
  632. align: 'center'
  633. }, {
  634. title: '操作',
  635. toolbar: ("view" !== location.searchObj().event) ? `<div>
  636. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" id="produceProcessInfoDeeBtn">删除</a>
  637. </div>` : `<div>&nbsp;</div>`,
  638. align: 'center'
  639. }]
  640. ],
  641. page: true
  642. };
  643. let produceProcessInfoTable = table.render(produceProcessInfoOptions);
  644. //监听工具条
  645. table.on('tool(produceProcessInfo)', function (obj) {
  646. var data = obj.data;
  647. if (obj.event === 'detail') {
  648. layer.msg('ID:' + data.id + ' 的查看操作');
  649. } else if (obj.event === 'del') {
  650. layer.confirm('真的删除行么', function (index) {
  651. obj.del();
  652. formData.current.materialList.map(function (item, index) {
  653. item.index == obj.data.index && formData.current.materialList.splice(index, 1);
  654. });
  655. produceProcessInfoOptions.data = formData.current.materialList;
  656. // 刷新表格数据
  657. produceProcessInfoTable.reload(produceProcessInfoOptions);
  658. if (formData.guid) {
  659. $.ajax({
  660. url: 'del_produceProcessInfo',
  661. data: {
  662. guid: data.guid
  663. },
  664. success: function (res) {
  665. }
  666. });
  667. }
  668. layer.close(index);
  669. });
  670. } else if (obj.event === 'upload') {
  671. let upelem = document.createElement('input'),
  672. uploadMsg = 0;
  673. upload.render({
  674. elem: upelem, //绑定元素
  675. url: 'uploadImage',
  676. accept: "file",
  677. exts: "jpg|jpeg|png|gif|bmp|mp4|ogg|webm|avi|wma|rmvb|rm|flash|3gp|flv|mp3",
  678. size: 10240,
  679. before: function () {
  680. uploadMsg = layer.msg('正在上传中……', {
  681. icon: 16,
  682. fixed: false,
  683. time: 0
  684. });
  685. },
  686. done: function (res) {
  687. layer.close(uploadMsg);
  688. if (!(res.code - 0)) {
  689. let a = obj.tr[0].querySelector('a[lay-event="aHref"]');
  690. a.href = window.hywa.config.href + '/' + res.data[0];
  691. a.innerHTML = res.data[0];
  692. let ggObj = {};
  693. formData.current.materialList.map(function (item, index) {
  694. if (item.index == obj.data.index) {
  695. formData.current.materialList[index].processImgs = res.data[0];
  696. ggObj = formData.current.materialList[index];
  697. }
  698. });
  699. if (formData.guid) {
  700. formData.submitInfo('edit_produceProcessInfo', ggObj, function () {
  701. formData.getCurrent();
  702. });
  703. }
  704. }
  705. },
  706. error: function () {
  707. }
  708. });
  709. upelem.click();
  710. } else if (obj.event === 'processImgsPreview') {
  711. let imageSrc = ((obj.data || {}).processImgs || '');
  712. if (imageSrc.indexOf("downloadDocument") != -1) {
  713. imageSrc = imageSrc;
  714. } else {
  715. imageSrc = window.hywa.config.href + imageSrc;
  716. }
  717. let processImgsPreviewDialog = '<div class="dialog-role f-dsn" id="processImgsPreviewDialog"><div style="text-align: center"><img id="processImgsPreviewDialogimg" src="' + imageSrc + '" style="width: 550px; height: 520px; margin: 10px;" /></div></div>';
  718. layer.open({
  719. type: 1,
  720. title: "图片预览",
  721. fixed: true,
  722. area: ['600px', '600px'],
  723. shadeClose: true,
  724. scrollbar: false,
  725. content: processImgsPreviewDialog
  726. });
  727. } else {
  728. return;
  729. }
  730. });
  731. table.on('edit(produceProcessInfo)', function (obj) {
  732. //修改后响应
  733. let ggObj = {};
  734. formData.current.materialList.map(function (item, index) {
  735. if (item.index == obj.data.index) {
  736. formData.current.materialList[index] = obj.data;
  737. ggObj = formData.current.materialList[index];
  738. }
  739. });
  740. if (formData.guid) {
  741. formData.submitInfo('edit_produceProcessInfo', ggObj, function () {
  742. formData.getCurrent();
  743. });
  744. }
  745. });
  746. //监听新增
  747. $('#produceProcessInfoAdd').on('click', function () {
  748. let input = $("#produceProcessInfoForm")[0].querySelectorAll('input');
  749. let obj = {};
  750. let ver = [];
  751. layui.each(input, function (i, item) {
  752. if (item.name) {
  753. obj[item.name] = item.value;
  754. ver.push(item.value);
  755. }
  756. });
  757. for (let i = 0; i < ver.length; i++) {
  758. if (!ver[i]) {
  759. layer.msg("全部都需要填写噢", {
  760. icon: 2
  761. });
  762. return false;
  763. }
  764. }
  765. if (formData.guid) {
  766. obj.fkGoodsBatchGuid = formData.guid;
  767. formData.submitInfo('add_produceProcessInfo', obj, function () {
  768. formData.getCurrent();
  769. });
  770. }
  771. formData.current.materialList.push(obj);
  772. //编号
  773. for (let i in formData.current.materialList) {
  774. formData.current.materialList[i].index = i;
  775. }
  776. table.reload("produceProcessInfo", {
  777. data: formData.current.materialList
  778. });
  779. });
  780. //加工流通
  781. formData.current.productList = formData.current.productList || [];
  782. //编号
  783. for (let i in formData.current.productList) {
  784. formData.current.productList[i].index = i;
  785. }
  786. table.render({
  787. id: "processingCirculationInfo",
  788. elem: '#processingCirculationInfo',
  789. data: formData.current.productList,
  790. cols: [
  791. [{
  792. field: 'processItem',
  793. title: '执行项',
  794. edit: 'text',
  795. event: 'edit',
  796. align: 'center'
  797. }, {
  798. field: 'processTime',
  799. title: '开始时间',
  800. edit: 'time',
  801. align: 'center',
  802. event: 'edit'
  803. }, {
  804. field: 'processUser',
  805. title: '执行人',
  806. edit: 'text',
  807. align: 'center',
  808. event: 'edit'
  809. }, {
  810. field: 'processDesc',
  811. title: '执行描述',
  812. edit: 'text',
  813. align: 'center',
  814. event: 'edit'
  815. }, {
  816. field: 'processImgs',
  817. title: '上传过程照片',
  818. toolbar: ("view" !== location.searchObj().event) ? `<div>
  819. <a class="layui-btn layui-btn-xs" lay-event="upload">上传</a>
  820. <a target="_blank" href="{{window.hywa.config.href}}/{{d.processImgs || ''}}" lay-event="aHref">{{d.processImgs || ''}}</a>
  821. </div>` : `<div>
  822. <a target="_blank" href="{{window.hywa.config.href}}/{{d.processImgs || ''}}" lay-event="aHref">{{d.processImgs || ''}}</a>
  823. </div>`,
  824. align: 'center'
  825. }, {
  826. title: '操作',
  827. toolbar: ("view" !== location.searchObj().event) ? `<div>
  828. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
  829. </div>` : `<div>&nbsp;</div>`,
  830. align: 'center'
  831. }]
  832. ],
  833. page: true
  834. });
  835. //监听工具条
  836. table.on('tool(processingCirculationInfo)', function (obj) {
  837. var data = obj.data;
  838. if (obj.event === 'detail') {
  839. layer.msg('ID:' + data.id + ' 的查看操作');
  840. } else if (obj.event === 'del') {
  841. layer.confirm('真的删除行么', function (index) {
  842. obj.del();
  843. formData.current.productList.map(function (item, index) {
  844. item.index == obj.data.index && formData.current.productList.splice(index, 1);
  845. });
  846. if (formData.guid) {
  847. $.ajax({
  848. url: 'del_processingCirculationInfo',
  849. data: {
  850. guid: data.guid
  851. },
  852. success: function (res) {
  853. }
  854. });
  855. }
  856. layer.close(index);
  857. });
  858. } else if (obj.event === 'upload') {
  859. let upelem = document.createElement('input'),
  860. uploadMsg = 0;
  861. upload.render({
  862. elem: upelem, //绑定元素
  863. url: 'uploadImage',
  864. accept: "file",
  865. exts: "jpg|jpeg|png|gif|bmp|mp4|ogg|webm|avi|wma|rmvb|rm|flash|3gp|flv|mp3",
  866. size: 10240,
  867. before: function () {
  868. uploadMsg = layer.msg('正在上传中……', {
  869. icon: 16,
  870. fixed: false,
  871. time: 0
  872. });
  873. },
  874. done: function (res) {
  875. layer.close(uploadMsg);
  876. if (!(res.code - 0)) {
  877. let a = obj.tr[0].querySelector('a[lay-event="aHref"]');
  878. a.href = window.hywa.config.href + '/' + res.data[0];
  879. a.innerHTML = res.data[0];
  880. let ggObj = {};
  881. formData.current.productList.map(function (item, index) {
  882. if (item.index == obj.data.index) {
  883. formData.current.productList[index].processImgs = res.data[0];
  884. ggObj = formData.current.productList[index];
  885. }
  886. });
  887. if (formData.guid) {
  888. formData.submitInfo('edit_processingCirculationInfo', ggObj, function () {
  889. formData.getCurrent();
  890. });
  891. }
  892. }
  893. },
  894. error: function () {
  895. }
  896. });
  897. upelem.click();
  898. }
  899. });
  900. table.on('edit(processingCirculationInfo)', function (obj) {
  901. //修改后响应
  902. let ggObj = {};
  903. formData.current.productList.map(function (item, index) {
  904. if (item.index == obj.data.index) {
  905. formData.current.productList[index] = obj.data;
  906. ggObj = formData.current.productList[index];
  907. }
  908. });
  909. if (formData.guid) {
  910. formData.submitInfo('edit_processingCirculationInfo', ggObj, function () {
  911. formData.getCurrent();
  912. });
  913. }
  914. });
  915. //监听新增
  916. $('#processingCirculationInfoAdd').on('click', function () {
  917. let input = $("#processingCirculationInfoForm")[0].querySelectorAll('input');
  918. let obj = {};
  919. let ver = [];
  920. layui.each(input, function (i, item) {
  921. if (item.name) {
  922. obj[item.name] = item.value;
  923. ver.push(item.value);
  924. }
  925. });
  926. for (let i = 0; i < ver.length; i++) {
  927. if (!ver[i]) {
  928. layer.msg("全部都需要填写噢", {
  929. icon: 2
  930. });
  931. return false;
  932. }
  933. }
  934. if (formData.guid) {
  935. obj.fkGoodsBatchGuid = formData.guid;
  936. formData.submitInfo('add_processingCirculationInfo', obj, function () {
  937. formData.getCurrent();
  938. });
  939. }
  940. formData.current.productList.push(obj);
  941. //编号
  942. for (let i in formData.current.productList) {
  943. formData.current.productList[i].index = i;
  944. }
  945. table.reload("processingCirculationInfo", {
  946. data: formData.current.productList
  947. });
  948. });
  949. //初始化
  950. formData.main = function () {
  951. var _this = this;
  952. $("#goodsName").html(location.searchObj().pdName);
  953. this.current.fkGoodsGuid = location.searchObj().pid;
  954. this.current.goodsName = location.searchObj().pdName;
  955. $.ajax({
  956. url: "regionList",
  957. method: 'post',
  958. contentType: "application/json",
  959. data: JSON.stringify({
  960. page: 1,
  961. limit: 100
  962. }),
  963. success: function (res) {
  964. typeTpl({
  965. elem: "#rolesView",
  966. list: res.data
  967. });
  968. form.val(_this.formLayFilter, _this.current);
  969. }
  970. });
  971. if (this.guid) {
  972. _this.getCurrent(_this.guid); //获取并初始化表单角色信息
  973. } else {
  974. _this.initialization();
  975. imageTpl({
  976. elem: "#imageListDiv",
  977. list: _this.current.imagesList
  978. });
  979. assayImageTpl({
  980. elem: "#assayImageListDiv",
  981. list: _this.current.assayInfoForm.imagesList
  982. });
  983. }
  984. if (location.searchObj().event == "view") {
  985. var el = document.getElementsByTagName("INPUT");
  986. for (var i = 0; i < el.length; i++) {
  987. el[i].readOnly = true;
  988. }
  989. el = document.getElementsByTagName("SELECT");
  990. for (var i = 0; i < el.length; i++) {
  991. el[i].disabled = true;
  992. }
  993. el = document.getElementsByTagName("checkbox");
  994. for (var i = 0; i < el.length; i++) {
  995. el[i].disabled = true;
  996. }
  997. el = document.getElementsByTagName("button");
  998. for (var i = 0; i < el.length; i++) {
  999. if (el[i].innerText.replace(" ", "") == "保存") {
  1000. el[i].style.display = "none";
  1001. }
  1002. }
  1003. }
  1004. return this;
  1005. };
  1006. //初始化
  1007. formData.initialization = function () {
  1008. //标签初始化
  1009. let labelList = formData.current.labelList;
  1010. let productTags = []
  1011. if (labelList) {
  1012. for (let i = 0; i < labelList.length; i++) {
  1013. productTags.push(labelList[i].labelName)
  1014. }
  1015. }
  1016. var _this = this;
  1017. //监听提交
  1018. form.on('submit(formDemo)', function (obj) {
  1019. //必须return false;
  1020. return _this.fusionData(obj.field).submitInfo(); //获取选中权限变数组,提交变化===下拉
  1021. });
  1022. //关闭窗口
  1023. $(".close-win").on("click", function () {
  1024. _this.closeModal();
  1025. });
  1026. $(".my-button-product").on("click", function () {
  1027. _this.current.auxList.push({
  1028. i: _this.current.auxList.length + 1,
  1029. auxItme: "",
  1030. auxItmeVal: ""
  1031. }); //数据库里把item写成itme
  1032. for (var i = _this.current.auxList.length - 1; i >= 0; i--) {
  1033. if ($("input[name='auxItme']")[i]) {
  1034. _this.current.auxList[i].auxItme = $("input[name='auxItme']")[i].value;
  1035. _this.current.auxList[i].auxItmeVal = $("input[name='auxItmeVal']")[i].value;
  1036. }
  1037. }
  1038. auxTpl({
  1039. elem: "#auxListDiv",
  1040. list: _this.current.auxList
  1041. });
  1042. });
  1043. $(".my-button-assay").on("click", function () {
  1044. _this.current.assayInfoForm.auxList.push({
  1045. i: _this.current.assayInfoForm.auxList.length + 1,
  1046. auxItme: "",
  1047. auxItmeVal: ""
  1048. }); //数据库里把item写成itme
  1049. for (var i = _this.current.assayInfoForm.auxList.length - 1; i >= 0; i--) {
  1050. if ($("input[name='auxItme2']")[i]) {
  1051. _this.current.assayInfoForm.auxList[i].auxItme = $("input[name='auxItme2']")[i].value;
  1052. _this.current.assayInfoForm.auxList[i].auxItmeVal = $("input[name='auxItmeVal2']")[i].value;
  1053. }
  1054. }
  1055. assayTpl({
  1056. elem: "#assayAuxListDiv",
  1057. list: _this.current.assayInfoForm.auxList
  1058. });
  1059. });
  1060. inputTags.render({
  1061. elem: '#inputTags',//定义输入框input对象
  1062. content: productTags,//默认标签
  1063. aldaBtn: true,//是否开启获取所有数据的按钮
  1064. done: function (value) { //回车后的回调
  1065. formData.current.labelNames = value.toString();
  1066. },
  1067. del: function (value) {
  1068. formData.current.labelNames = value.toString();
  1069. }
  1070. })
  1071. return _this;
  1072. };
  1073. //获取当前信息
  1074. formData.getCurrent = function (id) {
  1075. var _this = this;
  1076. $.ajax({
  1077. url: this.select_data,
  1078. method: 'get',
  1079. data: {
  1080. guid: id || this.guid //当前ID
  1081. },
  1082. success: function (res) {
  1083. try {
  1084. res.data[0].productDateStr = res.data[0].goodsProductDate.substring(0, 10);
  1085. if (!res.data[0].auxList)
  1086. res.data[0].auxList = [];
  1087. if (!res.data[0].imagesList)
  1088. res.data[0].imagesList = [];
  1089. if (!res.data[0].assayInfoForm)
  1090. res.data[0].assayInfoForm = {};
  1091. if (!res.data[0].assayInfoForm.auxList)
  1092. res.data[0].assayInfoForm.auxList = [];
  1093. if (!res.data[0].assayInfoForm.imagesList)
  1094. res.data[0].assayInfoForm.imagesList = [];
  1095. res.data[0].assayDepartment = res.data[0].assayInfoForm.assayDepartment;
  1096. } catch (e) {
  1097. //TODO handle the exception
  1098. }
  1099. $("#goodsName").html(res.data[0].goodsName);
  1100. _this.current = res.data[0];
  1101. auxTpl({
  1102. elem: "#auxListDiv",
  1103. list: res.data[0].auxList
  1104. });
  1105. imageTpl({
  1106. elem: "#imageListDiv",
  1107. list: res.data[0].imagesList
  1108. });
  1109. assayTpl({
  1110. elem: "#assayAuxListDiv",
  1111. list: res.data[0].assayInfoForm.auxList
  1112. });
  1113. assayImageTpl({
  1114. elem: "#assayImageListDiv",
  1115. list: res.data[0].assayInfoForm.imagesList
  1116. });
  1117. _this.current.inputsFormList = _this.current.inputsFormList || [];
  1118. rawMaterial(_this.current.inputsFormList);
  1119. //生产过程信息
  1120. _this.current.materialList = formData.current.materialList || [];
  1121. //编号
  1122. for (let i in _this.current.materialList) {
  1123. _this.current.materialList[i].index = i;
  1124. }
  1125. table.reload("produceProcessInfo", {
  1126. data: _this.current.materialList
  1127. });
  1128. //加工流通信息
  1129. _this.current.productList = formData.current.productList || [];
  1130. //编号
  1131. for (let i in _this.current.productList) {
  1132. _this.current.productList[i].index = i;
  1133. }
  1134. table.reload("processingCirculationInfo", {
  1135. data: _this.current.productList
  1136. });
  1137. _this.initialization().formVal();
  1138. }
  1139. });
  1140. return _this;
  1141. };
  1142. //表单赋值
  1143. formData.formVal = function () {
  1144. var _this = this;
  1145. form.val(this.formLayFilter, this.current);
  1146. return this;
  1147. };
  1148. //合并表单内容
  1149. formData.fusionData = function (obj) {
  1150. for (var i = this.current.auxList.length - 1; i >= 0; i--) {
  1151. this.current.auxList[i].auxItme = $("input[name='auxItme']")[i].value;
  1152. this.current.auxList[i].auxItmeVal = $("input[name='auxItmeVal']")[i].value;
  1153. if (this.current.auxList[i].auxItme == "" && this.current.auxList[i].auxItmeVal == "")
  1154. this.current.auxList.splice(i, 1);
  1155. }
  1156. for (var i = this.current.assayInfoForm.auxList.length - 1; i >= 0; i--) {
  1157. this.current.assayInfoForm.auxList[i].auxItme = $("input[name='auxItme2']")[i].value;
  1158. this.current.assayInfoForm.auxList[i].auxItmeVal = $("input[name='auxItmeVal2']")[i].value;
  1159. if (this.current.assayInfoForm.auxList[i].auxItme == "" && this.current.assayInfoForm.auxList[i].auxItmeVal ==
  1160. "")
  1161. this.current.assayInfoForm.auxList.splice(i, 1);
  1162. }
  1163. this.current = $.extend(this.current, obj);
  1164. this.current.goodsBatchImages = this.current.imagesList.join(",");
  1165. this.current.assayInfoForm.assayImgs = this.current.assayInfoForm.imagesList.join(",");
  1166. this.current.assayInfoForm.assayDepartment = this.current.assayDepartment;
  1167. return this;
  1168. };
  1169. //提交新增修改
  1170. formData.submitInfo = function (url, data, fun) {
  1171. var _this = this;
  1172. $.ajax({
  1173. type: 'POST',
  1174. url: url || this.save_data, //+'?userId='+this.guid
  1175. data: JSON.stringify(data || this.current),
  1176. contentType: 'application/json',
  1177. success: function (res) {
  1178. if (!(res.code - 0)) {
  1179. parent.layer.msg(res.msg, {
  1180. icon: 1
  1181. });
  1182. typeof fun === 'function' && fun();
  1183. url || _this.closeModal();
  1184. } else {
  1185. layer.msg(res.msg, {
  1186. icon: 2
  1187. });
  1188. }
  1189. }
  1190. });
  1191. return false;
  1192. };
  1193. formData.main();
  1194. //验证规则
  1195. form.verify({
  1196. nickname: function (value) {
  1197. if (!new RegExp("^[a-zA-Z][a-zA-Z0-9_]*$").test(value)) {
  1198. return '账号必须以英文字母开头,只能包含英文字母、数字、下划线';
  1199. }
  1200. if (/(^\_)|(\__)|(\_+$)/.test(value)) {
  1201. return '账号首尾不能出现下划线\'_\'';
  1202. }
  1203. },
  1204. checkName: function (value) { },
  1205. phoneNumber: function (value) {
  1206. if (value) {
  1207. if (!(/^1[3|4|5|7|8]\d{9}$/).test(value)) {
  1208. return '请输入正确的手机号码';
  1209. }
  1210. }
  1211. return false;
  1212. },
  1213. password: function (value) {
  1214. if (location.searchObj().guid) {
  1215. if (value) {
  1216. if (!(/^[\S]{6,12}$/).test(value)) {
  1217. return '密码必须6到12位,且不能出现空格';
  1218. }
  1219. }
  1220. return false;
  1221. }
  1222. if (!(/^[\S]{6,12}$/).test(value)) {
  1223. return '密码必须6到12位,且不能出现空格';
  1224. }
  1225. },
  1226. resspaword: function (value) {
  1227. var pass = $('#L_pass').val();
  1228. if (value != pass) {
  1229. return '两次密码不一致';
  1230. }
  1231. },
  1232. ageLength: [
  1233. /^[0-9]{0,2}$/,
  1234. '年龄必须0到2位,且只能是数字'
  1235. ],
  1236. jobLength: [
  1237. /^[a-z\A-Z\u4e00-\u9fa5_]{0,10}$/,
  1238. '职务必须是0-10位,且不包含特殊字符与数字'
  1239. ],
  1240. workUnit: [
  1241. /^[0-9\a-z\A-Z\u4e00-\u9fa5_]{0,25}$/,
  1242. '工作单位必须是0-25位,且不包含特殊字符'
  1243. ],
  1244. vcode: [
  1245. /^[\w]{4,5}$/,
  1246. '验证码不符合规则'
  1247. ]
  1248. });
  1249. form.on('select(roles)', function (data) {
  1250. rolesViewOnemapParam = $("#rolesView option[value='" + data.value + "']").attr('oneMap');
  1251. });
  1252. /*element.on('tab(docDemoTabBrief)', function (data) {
  1253. if ('2' == this.getAttribute('lay-id')) {
  1254. if (rolesViewOnemapParam && null != rolesViewOnemapParam) {
  1255. let req = {
  1256. orchardId: rolesViewOnemapParam,
  1257. pageNo: 1,
  1258. pageSize: 10
  1259. };
  1260. $.ajax({
  1261. type: 'get',
  1262. url: 'getOrchardList' + '?orchardId=' + rolesViewOnemapParam + '&pageNo=1&pageSize=10',
  1263. success: function (res) {
  1264. formData.current.materialList = res.data;
  1265. formData.current.materialList.forEach(value => {
  1266. value.processType = 1;
  1267. });
  1268. table.reload("produceProcessInfo", {
  1269. data: formData.current.materialList
  1270. });
  1271. }
  1272. });
  1273. }
  1274. }
  1275. });*/
  1276. });
  1277. </script>
  1278. </body>
  1279. </html>