123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>新增批次</title>
- <meta name="renderer" content="webkit">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
- <meta name="apple-mobile-web-app-status-bar-style" content="black">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="format-detection" content="telephone=no">
- <link rel="stylesheet" type="text/css" href="../../layui/css/layui.css" />
- <link rel="stylesheet" type="text/css" href="../../css/common.css" />
- <link rel="stylesheet" type="text/css" href="../../css/inputTags.css" />
- <style type="text/css">
- .ui-required:before {
- content: "*";
- color: red;
- vertical-align: middle;
- }
- #roleSelectViwe .layui-form-item {
- margin-bottom: 0
- }
- #roleSelectViwe .layui-input-inline {
- width: calc(100% - 110px);
- margin-right: 0;
- }
- .region {
- padding-left: 10px;
- height: 38px;
- line-height: 38px;
- background-color: #fff;
- border-radius: 2px;
- border: 1px solid #e6e6e6;
- width: calc(100% - 132px) !important;
- }
- .userTip {
- color: #666;
- font-size: 12px;
- }
- .userTip b {
- color: #333;
- }
- .my-middle {
- line-height: 36px;
- }
- .my-button {
- width: 60%;
- margin-left: 20%;
- height: 40px;
- text-align: center;
- line-height: 40px;
- border: 1px dashed;
- border-radius: 5px;
- }
- .my-inline {
- display: inline-block;
- float: left;
- text-align: center;
- height: 38px;
- line-height: 38px;
- width: 10%;
- }
- .my-images-inline {
- display: inline-block;
- width: 104px;
- height: 104px;
- border: 1px dashed;
- border-radius: 5px;
- padding: 4px;
- vertical-align: top;
- margin: 4px;
- }
- .my-img {
- width: 100%;
- height: 100%;
- }
- .my-images-add {
- display: inline-block;
- text-align: center;
- line-height: 103px;
- font-size: 32px;
- cursor: pointer;
- background-color: #fbfbfb;
- }
- .my-del {
- background-color: black;
- color: white;
- }
- .button-delImage.button-delAssayImage {
- position: relative;
- left: -2px;
- top: -106px;
- }
- </style>
- </head>
- <body>
- <form class="layui-form" action="" lay-filter="addForm">
- <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
- <ul class="layui-tab-title">
- <li class="layui-this" lay-id="1">基础信息</li>
- <li lay-id="2">原料生产</li>
- <li lay-id="3">加工流通</li>
- <li lay-id="4">检疫检验</li>
- </ul>
- <div class="layui-tab-content">
- <div class="layui-tab-item layui-show">
- <div class="layui-form-item">
- <label class="layui-form-label ui-required">产品分类</label>
- <div class="layui-input-block my-middle" id="goodsName">
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label ui-required">批次编码</label>
- <div class="layui-input-block">
- <input type="text" name="goodsBatchNo" lay-verify="required" maxlength="20" placeholder="请输入批次编码" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label ui-required">产品规格</label>
- <div class="layui-input-block">
- <input type="text" name="goodsUnit" lay-verify="required" maxlength="20" placeholder="请输入产品规格" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label ui-required">生产地</label>
- <div class="layui-input-block">
- <select name="fkFieldGuid" lay-verify="required" lay-filter="roles" id="rolesView"></select>
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label ui-required">生产日期</label>
- <div class="layui-input-block">
- <input type="text" name="productDateStr" id="goodsProductDate" lay-verify="required" maxlength="20" placeholder="请输入生产日期" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label ui-required">保质期</label>
- <div class="layui-input-block">
- <input type="text" name="goodsExpired" lay-verify="" maxlength="10" placeholder="请输入保质期" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label ui-required">产品标签</label>
- <div class="layui-input-block">
- <div class="tags" id="tags">
- <input type="text" id="inputTags" placeholder="回车生成标签" autocomplete="off">
- </div>
- </div>
- </div>
- <!-- <div class="layui-form-item">
- <label class="layui-form-label">销售网址</label>
- <div class="layui-input-block">
- <input type="text" name="goodsSaleUrl" lay-verify="" maxlength="300" placeholder="请输入在线销售网址" autocomplete="off"
- class="layui-input">
- </div>
- </div> -->
- <div class="layui-card">
- <div class="layui-card-header">自定义信息</div>
- <div class="layui-card-body">
- <div id="auxListDiv"></div>
- <div class="layui-form-item">
- <div class="my-button my-button-product">+添加</div>
- </div>
- </div>
- </div>
- <div class="layui-card">
- <div class="layui-card-header">产品图片视频</div>
- <div class="layui-card-body">
- <div id="imageListDiv"></div>
- 图片视频上传完毕后请记得按保存哦
- </div>
- </div>
- </div>
- <div class="layui-tab-item">
- <div class="layui-card">
- <div class="layui-card-header">原料信息</div>
- <div class="layui-card-body">
- <div style="display: flex;">
- <input class="layui-input" style="margin-right: 15px;" type="text" name="rawMaterial" />
- <button type="button" class="layui-btn" id="rawMaterialInfoAdd">新增</button>
- </div>
- <style type="text/css">
- #rawMaterialInfo li {
- display: inline-block;
- border: 1px solid rgba(0, 0, 0, .2);
- background: rgba(0, 0, 0, .1);
- border-radius: .2em;
- padding: .3em .6em;
- margin: 8px;
- }
- #rawMaterialInfo li i:hover {
- cursor: pointer;
- }
- </style>
- <script type="text/html" id='rawMaterialInfoTpl'>
- {{# layui.each(d,function(i,item){ }}
- <li>
- <div style="display: flex;align-items: center;">
- <span>{{item.inputsProcessName}}</span>
- {{#if ("view" !== location.searchObj().event){}}
- <i data-bind="{{i||0}}" class="layui-icon layui-icon-close" style="margin-left: 5px;"></i>
- {{#} }}
- </div>
- </li>
- {{# });}}
- </script>
- <ol id="rawMaterialInfo"></ol>
- </div>
- </div>
- <div class="layui-card">
- <div class="layui-card-header">生产过程信息</div>
- <div class="layui-card-body">
- <div id="produceProcessInfoForm">
- <div class="layui-input-inline">
- <label class="layui-form-label">执行项</label>
- <div class="layui-input-inline">
- <input class="layui-input" style="margin-right: 15px;" type="text" name="processItem" />
- </div>
- </div>
- <div class="layui-input-inline">
- <label class="layui-form-label">执行人</label>
- <div class="layui-input-inline">
- <input class="layui-input" style="margin-right: 15px;" type="text" name="processUser" />
- </div>
- </div>
- <div class="layui-input-inline">
- <label class="layui-form-label">开始日期</label>
- <div class="layui-input-inline">
- <input class="layui-input" style="margin-right: 15px;" type="text" name="processTime" id="produceProcessInfoForm_processTime" />
- </div>
- </div>
- <div class="layui-input-inline">
- <label class="layui-form-label">执行描述</label>
- <div class="layui-input-inline">
- <input class="layui-input" style="margin-right: 15px;" type="text" name="processDesc" />
- </div>
- </div>
- <input type="hidden" name="processType" value="1" />
- <button type="button" class="layui-btn" id='produceProcessInfoAdd'>新增</button>
- <table class="layui-hide" id="produceProcessInfo" lay-filter="produceProcessInfo"></table>
- </div>
- </div>
- </div>
- </div>
- <div class="layui-tab-item" id="processingCirculationInfoForm">
- <div class="layui-input-inline">
- <label class="layui-form-label">执行项</label>
- <div class="layui-input-inline">
- <input class="layui-input" style="margin-right: 15px;" type="text" name="processItem" />
- </div>
- </div>
- <div class="layui-input-inline">
- <label class="layui-form-label">执行人</label>
- <div class="layui-input-inline">
- <input class="layui-input" style="margin-right: 15px;" type="text" name="processUser" />
- </div>
- </div>
- <div class="layui-input-inline">
- <label class="layui-form-label">开始日期</label>
- <div class="layui-input-inline">
- <input class="layui-input" style="margin-right: 15px;" type="text" name="processTime" id="processingCirculationInfoForm_processTime" />
- </div>
- </div>
- <div class="layui-input-inline">
- <label class="layui-form-label">执行描述</label>
- <div class="layui-input-inline">
- <input class="layui-input" style="margin-right: 15px;" type="text" name="processDesc" />
- </div>
- </div>
- <input type="hidden" name="processType" value="2" />
- <button type="button" class="layui-btn" id='processingCirculationInfoAdd'>新增</button>
- <table class="layui-hide" id="processingCirculationInfo" lay-filter="processingCirculationInfo"></table>
- </div>
- <div class="layui-tab-item">
- <div class="layui-card">
- <div class="layui-card-header">检验信息</div>
- <div class="layui-card-body">
- <div class="layui-form-item">
- <label class="layui-form-label">检验单位:</label>
- <div class="layui-input-block">
- <input type="text" name="assayDepartment" lay-verify="" maxlength="10" placeholder="请输入检验单位" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div id="assayAuxListDiv"></div>
- <div class="layui-form-item">
- <div class="my-button my-button-assay">+添加</div>
- </div>
- </div>
- </div>
- <div class="layui-card">
- <div class="layui-card-header">检验报告</div>
- <div class="layui-card-body">
- <div id="assayImageListDiv"></div>
- 图片视频上传完毕后请记得按保存哦
- </div>
- </div>
- </div>
- </div>
- <div class="layui-form-item" style="text-align: center;padding: 25px;">
- <button class="layui-btn" lay-submit lay-filter="formDemo">保存</button>
- <button type="reset" class="layui-btn layui-btn-primary close-win">取消</button>
- </div>
- </div>
- </form>
- <script type="text/html" id="typeHtmlTpl">
- <option value="">请选择</option>
- {{# if(!d.list){d.list = []}; layui.each(d.list, function(index, item){ }}
- <option value="{{item.guid}}" oneMap="{{item.oneMap}}">{{item.fieldName}}</option>
- {{# }); }}
- </script>
- <script type="text/html" id="auxHtmlTpl">
- {{# if(!d.list){d.list = []}; layui.each(d.list, function(index, item){ }}
- <div class="layui-form-item">
- <label class="layui-form-label">自定义项{{index+1}}:</label>
- <div class="my-inline" style="width: 20%">
- <input type="text" name="auxItme" maxlength="20" lay-verify="required" placeholder="标题" autocomplete="off" class="layui-input" value="{{item.auxItme}}">
- </div>
- <div class="my-inline">--</div>
- <div class="my-inline" style="width: 40%">
- <input type="text" name="auxItmeVal" maxlength="100" lay-verify="required" placeholder="项" autocomplete="off" class="layui-input" value="{{item.auxItmeVal}}">
- </div>
- <div class="my-inline">
- <i class="layui-icon my-del button-delAux" data-bind="{{index}}" title="删除" data-icon="ဆ">ဆ</i>
- </div>
- </div>
- {{# }); }}
- </script>
- <script type="text/html" id="imageHtmlTpl">
- <div class="layui-form-item">
- {{# if(!d.list){d.list = []}; layui.each(d.list, function(index, item){ }}
- <div class="my-images-inline">
- {{#if ("jpg|jpeg|png|gif|bmp".indexOf(item.substring(item.lastIndexOf(".")+1))==-1){}}
- <video class="my-img" src="{{window.hywa.config.href}}/{{item}}" autoplay loop></video>
- {{#}else{}}
- <img class="my-img" src="{{window.hywa.config.href}}/{{item}}">
- {{#} }}
- <i class="layui-icon my-del button-delImage" data-bind="{{index}}" title="删除" data-icon="ဆ">ဆ</i>
- </div>
- {{# }); }}
- <div class="my-images-inline my-images-add" id="imageUploadBtn">+</div>
- </div>
- </script>
- <script type="text/html" id="assayAuxHtmlTpl">
- {{# if(!d.list){d.list = []}; layui.each(d.list, function(index, item){ }}
- <div class="layui-form-item">
- <label class="layui-form-label">{{#if(index==0){}}检验数据:{{#} }}</label>
- <div class="my-inline" style="width: 20%">
- <input type="text" name="auxItme2" maxlength="20" placeholder="检验项名" autocomplete="off" class="layui-input" value="{{item.auxItme}}">
- </div>
- <div class="my-inline">--</div>
- <div class="my-inline" style="width: 40%">
- <input type="text" name="auxItmeVal2" maxlength="100" placeholder="数值和单位" autocomplete="off" class="layui-input" value="{{item.auxItmeVal}}">
- </div>
- <div class="my-inline">
- <i class="layui-icon my-del button-delAssay" data-bind="{{index}}" title="删除" data-icon="ဆ">ဆ</i>
- </div>
- </div>
- {{# }); }}
- </script>
- <script type="text/html" id="assayImageHtmlTpl">
- <div class="layui-form-item">
- {{# if(!d.list){d.list = []}; layui.each(d.list, function(index, item){ }}
- <div class="my-images-inline">
- {{#if ("jpg|jpeg|png|gif|bmp".indexOf(item.substring(item.lastIndexOf(".")+1))==-1){}}
- <video class="my-img" src="{{window.hywa.config.href}}/{{item}}" autoplay loop></video>
- {{#}else{}}
- <img class="my-img" src="{{window.hywa.config.href}}/{{item}}">
- {{#} }}
- <i class="layui-icon my-del button-delAssayImage" data-bind="{{index}}" title="删除" data-icon="ဆ">ဆ</i>
- </div>
- {{# }); }}
- <div class="my-images-inline my-images-add" id="assayImageUploadBtn">+</div>
- </div>
- </script>
- <script type="text/javascript">
- function loadJS(url) {
- document.write("<script src='" + url + "?ver=" + new Date().getTime() + "'><\/script>")
- }
- loadJS("../../layui/layui.js");
- loadJS("../../js/ajaxhook.min.js");
- loadJS("../../js/config.js");
- </script>
- <script type="text/javascript">
- layui.config({
- base: "../../js/layuiPlugins/"
- }).use(["form", 'layer', 'laytpl', 'jquery', 'laydate', 'element', 'upload', 'table', 'inputTags'], function () {
- var form = layui.form,
- layer = layui.layer,
- laytpl = layui.laytpl,
- $ = layui.jquery,
- laydate = layui.laydate,
- element = layui.element,
- upload = layui.upload,
- inputTags = layui.inputTags
- table = layui.table;
- laydate.render({
- elem: '#goodsProductDate' //指定元素
- });
- laydate.render({
- type: 'datetime',
- elem: '#produceProcessInfoForm_processTime' //指定元素
- });
- laydate.render({
- type: 'datetime',
- elem: '#processingCirculationInfoForm_processTime' //指定元素
- });
- var funcName = "pdinfo";
- var rolesViewOnemapParam = "";
- var formData = {
- guid: (JSON.stringify(location.searchObj()) != "{}") ? location.searchObj().guid || null : null, //带参传入ID
- current: {
- auxList: [],
- imagesList: [],
- assayInfoForm: {
- imagesList: [],
- auxList: []
- }
- }, //当前表单数据
- select_data: "select_" + funcName, //查询用户
- save_data: (location.searchObj().guid ? 'edit' : 'add') + '_' + funcName, //查询用户
- formLayFilter: "addForm", //表单容器
- closeModal: function () { //关闭当前窗口
- parent.layer.close(parent.layer.getFrameIndex(window.name));
- }
- };
- var option = {
- elem: '#imageUploadBtn',
- url: 'uploadImage',
- accept: "file",
- exts: "jpg|jpeg|png|gif|bmp|mp4|ogg|webm|avi|wma|rmvb|rm|flash|3gp|flv",
- size: 10240, //kb
- before: function () {
- uploadMsg = layer.msg('正在上传中……', {
- icon: 16,
- fixed: false,
- time: 0
- });
- },
- done: function (res) {
- layer.close(uploadMsg);
- formData.current.imagesList.push(res.data[0]);
- imageTpl({
- elem: "#imageListDiv",
- list: formData.current.imagesList
- });
- },
- error: function () { }
- };
- var assayOption = {
- elem: '#assayImageUploadBtn',
- url: 'uploadImage',
- accept: "file",
- exts: "jpg|jpeg|png|gif|bmp|mp4|ogg|webm|avi|wma|rmvb|rm|flash|3gp|flv",
- size: 10240, //kb
- before: function () {
- uploadMsg = layer.msg('正在上传中……', {
- icon: 16,
- fixed: false,
- time: 0
- });
- },
- done: function (res) {
- layer.close(uploadMsg);
- formData.current.assayInfoForm.imagesList.push(res.data[0]);
- assayImageTpl({
- elem: "#assayImageListDiv",
- list: formData.current.assayInfoForm.imagesList
- });
- },
- error: function () { }
- };
- //自定义项列表模板
- function auxTpl(obj) {
- laytpl(auxHtmlTpl.innerHTML).render(obj, function (html) {
- $(obj.elem).html(html);
- $(".button-delAux").on("click", function (e) {
- var sortno = e.target.getAttribute("data-bind");
- for (var i = formData.current.auxList.length - 1; i >= 0; i--) {
- if ($("input[name='auxItme']")[i]) {
- formData.current.auxList[i].auxItme = $("input[name='auxItme']")[i].value;
- formData.current.auxList[i].auxItmeVal = $("input[name='auxItmeVal']")[i].value;
- }
- }
- formData.current.auxList.splice(sortno, 1);
- auxTpl({
- elem: "#auxListDiv",
- list: formData.current.auxList
- });
- });
- });
- }
- //检验数据列表模板
- function assayTpl(obj) {
- laytpl(assayAuxHtmlTpl.innerHTML).render(obj, function (html) {
- $(obj.elem).html(html);
- $(".button-delAssay").on("click", function (e) {
- var sortno = e.target.getAttribute("data-bind");
- var index = formData.current.assayInfoForm.auxList.length;
- for (var i = index - 1; i >= 0; i--) {
- if ($("input[name='auxItme2']")[i]) {
- formData.current.assayInfoForm.auxList[i].auxItme = $("input[name='auxItme2']")[i].value;
- formData.current.assayInfoForm.auxList[i].auxItmeVal = $("input[name='auxItmeVal2']")[i].value;
- }
- }
- formData.current.assayInfoForm.auxList.splice(sortno, 1);
- assayTpl({
- elem: "#assayAuxListDiv",
- list: formData.current.assayInfoForm.auxList
- });
- });
- });
- }
- //下拉列表模板
- function typeTpl(obj) {
- laytpl(typeHtmlTpl.innerHTML).render(obj, function (html) {
- $(obj.elem).html(html);
- form.render();
- });
- }
- //图片列表模板
- function imageTpl(obj) {
- laytpl(imageHtmlTpl.innerHTML).render(obj, function (html) {
- $(obj.elem).html(html);
- upload.render(option);
- $(".button-delImage").on("click", function (e) {
- formData.current.imagesList.splice(e.target.getAttribute("data-bind"), 1);
- imageTpl({
- elem: "#imageListDiv",
- list: formData.current.imagesList
- });
- });
- });
- }
- //检验图片列表模板
- function assayImageTpl(obj) {
- laytpl(assayImageHtmlTpl.innerHTML).render(obj, function (html) {
- $(obj.elem).html(html);
- upload.render(assayOption);
- $(".button-delAssayImage").on("click", function (e) {
- formData.current.assayInfoForm.imagesList.splice(e.target.getAttribute("data-bind"), 1);
- assayImageTpl({
- elem: "#assayImageListDiv",
- list: formData.current.assayInfoForm.imagesList
- });
- });
- });
- }
- //原料信息模板
- function rawMaterial(data) {
- laytpl(rawMaterialInfoTpl.innerHTML).render(data, function (html) {
- $('#rawMaterialInfo').html(html);
- });
- }
- $('#rawMaterialInfo').on("click", 'li i', function (e) { //删除
- if (formData.guid) {
- $.ajax({
- url: 'del_rawMaterialInfo',
- data: {
- guid: formData.current.inputsFormList[e.target.getAttribute("data-bind")].guid
- },
- success: function (res) {
- }
- });
- }
- formData.current.inputsFormList.splice(e.target.getAttribute("data-bind"), 1);
- rawMaterial(formData.current.inputsFormList);
- });
- $("#rawMaterialInfoAdd").on('click', function () {
- let val = $('input[name="rawMaterial"]').val();
- if (val) {
- formData.current.inputsFormList = formData.current.inputsFormList || [];
- formData.current.inputsFormList.push({
- inputsProcessName: val
- });
- rawMaterial(formData.current.inputsFormList);
- if (formData.guid) {
- formData.submitInfo('add_rawMaterialInfo', {
- fkGoodsBatchGuid: formData.guid,
- inputsProcessName: val
- }, function () {
- formData.getCurrent();
- });
- }
- }
- });
- //生产过程信息
- formData.current.materialList = formData.current.materialList || [];
- //编号
- for (let i in formData.current.materialList) {
- formData.current.materialList[i].index = i;
- }
- let produceProcessInfoOptions = {
- id: "produceProcessInfo",
- elem: '#produceProcessInfo',
- data: formData.current.materialList,
- cols: [
- [{
- field: 'processItem',
- title: '执行项',
- edit: 'text',
- event: 'edit',
- align: 'center'
- }, {
- field: 'processTime',
- title: '开始时间',
- edit: 'time',
- align: 'center',
- event: 'edit'
- }, {
- field: 'processUser',
- title: '执行人',
- edit: 'text',
- align: 'center',
- event: 'edit'
- }, {
- field: 'processDesc',
- title: '执行描述',
- edit: 'text',
- align: 'center',
- event: 'edit'
- }, {
- field: 'processImgs',
- title: '上传过程照片',
- // toolbar: `<div><a href="javascript:void(0);" lay-event="processImgsPreview">{{d.processImgs || ''}}</a></div>`,
- toolbar: ("view" !== location.searchObj().event) ? `<div>
- <a class="layui-btn layui-btn-xs" lay-event="upload">上传</a>
- <a target="_blank" href="{{window.hywa.config.href}}/{{d.processImgs || ''}}" lay-event="aHref">{{d.processImgs || ''}}</a>
- </div>` : `<div>
- <a target="_blank" href="{{window.hywa.config.href}}/{{d.processImgs || ''}}" lay-event="aHref">{{d.processImgs || ''}}</a>
- </div>`,
- align: 'center'
- }, {
- title: '操作',
- toolbar: ("view" !== location.searchObj().event) ? `<div>
- <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" id="produceProcessInfoDeeBtn">删除</a>
- </div>` : `<div> </div>`,
- align: 'center'
- }]
- ],
- page: true
- };
- let produceProcessInfoTable = table.render(produceProcessInfoOptions);
- //监听工具条
- table.on('tool(produceProcessInfo)', function (obj) {
- var data = obj.data;
- if (obj.event === 'detail') {
- layer.msg('ID:' + data.id + ' 的查看操作');
- } else if (obj.event === 'del') {
- layer.confirm('真的删除行么', function (index) {
- obj.del();
- formData.current.materialList.map(function (item, index) {
- item.index == obj.data.index && formData.current.materialList.splice(index, 1);
- });
- produceProcessInfoOptions.data = formData.current.materialList;
- // 刷新表格数据
- produceProcessInfoTable.reload(produceProcessInfoOptions);
- if (formData.guid) {
- $.ajax({
- url: 'del_produceProcessInfo',
- data: {
- guid: data.guid
- },
- success: function (res) {
- }
- });
- }
- layer.close(index);
- });
- } else if (obj.event === 'upload') {
- let upelem = document.createElement('input'),
- uploadMsg = 0;
- upload.render({
- elem: upelem, //绑定元素
- url: 'uploadImage',
- accept: "file",
- exts: "jpg|jpeg|png|gif|bmp|mp4|ogg|webm|avi|wma|rmvb|rm|flash|3gp|flv|mp3",
- size: 10240,
- before: function () {
- uploadMsg = layer.msg('正在上传中……', {
- icon: 16,
- fixed: false,
- time: 0
- });
- },
- done: function (res) {
- layer.close(uploadMsg);
- if (!(res.code - 0)) {
- let a = obj.tr[0].querySelector('a[lay-event="aHref"]');
- a.href = window.hywa.config.href + '/' + res.data[0];
- a.innerHTML = res.data[0];
- let ggObj = {};
- formData.current.materialList.map(function (item, index) {
- if (item.index == obj.data.index) {
- formData.current.materialList[index].processImgs = res.data[0];
- ggObj = formData.current.materialList[index];
- }
- });
- if (formData.guid) {
- formData.submitInfo('edit_produceProcessInfo', ggObj, function () {
- formData.getCurrent();
- });
- }
- }
- },
- error: function () {
- }
- });
- upelem.click();
- } else if (obj.event === 'processImgsPreview') {
- let imageSrc = ((obj.data || {}).processImgs || '');
- if (imageSrc.indexOf("downloadDocument") != -1) {
- imageSrc = imageSrc;
- } else {
- imageSrc = window.hywa.config.href + imageSrc;
- }
- 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>';
- layer.open({
- type: 1,
- title: "图片预览",
- fixed: true,
- area: ['600px', '600px'],
- shadeClose: true,
- scrollbar: false,
- content: processImgsPreviewDialog
- });
- } else {
- return;
- }
- });
- table.on('edit(produceProcessInfo)', function (obj) {
- //修改后响应
- let ggObj = {};
- formData.current.materialList.map(function (item, index) {
- if (item.index == obj.data.index) {
- formData.current.materialList[index] = obj.data;
- ggObj = formData.current.materialList[index];
- }
- });
- if (formData.guid) {
- formData.submitInfo('edit_produceProcessInfo', ggObj, function () {
- formData.getCurrent();
- });
- }
- });
- //监听新增
- $('#produceProcessInfoAdd').on('click', function () {
- let input = $("#produceProcessInfoForm")[0].querySelectorAll('input');
- let obj = {};
- let ver = [];
- layui.each(input, function (i, item) {
- if (item.name) {
- obj[item.name] = item.value;
- ver.push(item.value);
- }
- });
- for (let i = 0; i < ver.length; i++) {
- if (!ver[i]) {
- layer.msg("全部都需要填写噢", {
- icon: 2
- });
- return false;
- }
- }
- if (formData.guid) {
- obj.fkGoodsBatchGuid = formData.guid;
- formData.submitInfo('add_produceProcessInfo', obj, function () {
- formData.getCurrent();
- });
- }
- formData.current.materialList.push(obj);
- //编号
- for (let i in formData.current.materialList) {
- formData.current.materialList[i].index = i;
- }
- table.reload("produceProcessInfo", {
- data: formData.current.materialList
- });
- });
- //加工流通
- formData.current.productList = formData.current.productList || [];
- //编号
- for (let i in formData.current.productList) {
- formData.current.productList[i].index = i;
- }
- table.render({
- id: "processingCirculationInfo",
- elem: '#processingCirculationInfo',
- data: formData.current.productList,
- cols: [
- [{
- field: 'processItem',
- title: '执行项',
- edit: 'text',
- event: 'edit',
- align: 'center'
- }, {
- field: 'processTime',
- title: '开始时间',
- edit: 'time',
- align: 'center',
- event: 'edit'
- }, {
- field: 'processUser',
- title: '执行人',
- edit: 'text',
- align: 'center',
- event: 'edit'
- }, {
- field: 'processDesc',
- title: '执行描述',
- edit: 'text',
- align: 'center',
- event: 'edit'
- }, {
- field: 'processImgs',
- title: '上传过程照片',
- toolbar: ("view" !== location.searchObj().event) ? `<div>
- <a class="layui-btn layui-btn-xs" lay-event="upload">上传</a>
- <a target="_blank" href="{{window.hywa.config.href}}/{{d.processImgs || ''}}" lay-event="aHref">{{d.processImgs || ''}}</a>
- </div>` : `<div>
- <a target="_blank" href="{{window.hywa.config.href}}/{{d.processImgs || ''}}" lay-event="aHref">{{d.processImgs || ''}}</a>
- </div>`,
- align: 'center'
- }, {
- title: '操作',
- toolbar: ("view" !== location.searchObj().event) ? `<div>
- <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
- </div>` : `<div> </div>`,
- align: 'center'
- }]
- ],
- page: true
- });
- //监听工具条
- table.on('tool(processingCirculationInfo)', function (obj) {
- var data = obj.data;
- if (obj.event === 'detail') {
- layer.msg('ID:' + data.id + ' 的查看操作');
- } else if (obj.event === 'del') {
- layer.confirm('真的删除行么', function (index) {
- obj.del();
- formData.current.productList.map(function (item, index) {
- item.index == obj.data.index && formData.current.productList.splice(index, 1);
- });
- if (formData.guid) {
- $.ajax({
- url: 'del_processingCirculationInfo',
- data: {
- guid: data.guid
- },
- success: function (res) {
- }
- });
- }
- layer.close(index);
- });
- } else if (obj.event === 'upload') {
- let upelem = document.createElement('input'),
- uploadMsg = 0;
- upload.render({
- elem: upelem, //绑定元素
- url: 'uploadImage',
- accept: "file",
- exts: "jpg|jpeg|png|gif|bmp|mp4|ogg|webm|avi|wma|rmvb|rm|flash|3gp|flv|mp3",
- size: 10240,
- before: function () {
- uploadMsg = layer.msg('正在上传中……', {
- icon: 16,
- fixed: false,
- time: 0
- });
- },
- done: function (res) {
- layer.close(uploadMsg);
- if (!(res.code - 0)) {
- let a = obj.tr[0].querySelector('a[lay-event="aHref"]');
- a.href = window.hywa.config.href + '/' + res.data[0];
- a.innerHTML = res.data[0];
- let ggObj = {};
- formData.current.productList.map(function (item, index) {
- if (item.index == obj.data.index) {
- formData.current.productList[index].processImgs = res.data[0];
- ggObj = formData.current.productList[index];
- }
- });
- if (formData.guid) {
- formData.submitInfo('edit_processingCirculationInfo', ggObj, function () {
- formData.getCurrent();
- });
- }
- }
- },
- error: function () {
- }
- });
- upelem.click();
- }
- });
- table.on('edit(processingCirculationInfo)', function (obj) {
- //修改后响应
- let ggObj = {};
- formData.current.productList.map(function (item, index) {
- if (item.index == obj.data.index) {
- formData.current.productList[index] = obj.data;
- ggObj = formData.current.productList[index];
- }
- });
- if (formData.guid) {
- formData.submitInfo('edit_processingCirculationInfo', ggObj, function () {
- formData.getCurrent();
- });
- }
- });
- //监听新增
- $('#processingCirculationInfoAdd').on('click', function () {
- let input = $("#processingCirculationInfoForm")[0].querySelectorAll('input');
- let obj = {};
- let ver = [];
- layui.each(input, function (i, item) {
- if (item.name) {
- obj[item.name] = item.value;
- ver.push(item.value);
- }
- });
- for (let i = 0; i < ver.length; i++) {
- if (!ver[i]) {
- layer.msg("全部都需要填写噢", {
- icon: 2
- });
- return false;
- }
- }
- if (formData.guid) {
- obj.fkGoodsBatchGuid = formData.guid;
- formData.submitInfo('add_processingCirculationInfo', obj, function () {
- formData.getCurrent();
- });
- }
- formData.current.productList.push(obj);
- //编号
- for (let i in formData.current.productList) {
- formData.current.productList[i].index = i;
- }
- table.reload("processingCirculationInfo", {
- data: formData.current.productList
- });
- });
- //初始化
- formData.main = function () {
- var _this = this;
- $("#goodsName").html(location.searchObj().pdName);
- this.current.fkGoodsGuid = location.searchObj().pid;
- this.current.goodsName = location.searchObj().pdName;
- $.ajax({
- url: "regionList",
- method: 'post',
- contentType: "application/json",
- data: JSON.stringify({
- page: 1,
- limit: 100
- }),
- success: function (res) {
- typeTpl({
- elem: "#rolesView",
- list: res.data
- });
- form.val(_this.formLayFilter, _this.current);
- }
- });
- if (this.guid) {
- _this.getCurrent(_this.guid); //获取并初始化表单角色信息
- } else {
- _this.initialization();
- imageTpl({
- elem: "#imageListDiv",
- list: _this.current.imagesList
- });
- assayImageTpl({
- elem: "#assayImageListDiv",
- list: _this.current.assayInfoForm.imagesList
- });
- }
- if (location.searchObj().event == "view") {
- var el = document.getElementsByTagName("INPUT");
- for (var i = 0; i < el.length; i++) {
- el[i].readOnly = true;
- }
- el = document.getElementsByTagName("SELECT");
- for (var i = 0; i < el.length; i++) {
- el[i].disabled = true;
- }
- el = document.getElementsByTagName("checkbox");
- for (var i = 0; i < el.length; i++) {
- el[i].disabled = true;
- }
- el = document.getElementsByTagName("button");
- for (var i = 0; i < el.length; i++) {
- if (el[i].innerText.replace(" ", "") == "保存") {
- el[i].style.display = "none";
- }
- }
- }
- return this;
- };
- //初始化
- formData.initialization = function () {
- //标签初始化
- let labelList = formData.current.labelList;
- let productTags = []
- if (labelList) {
- for (let i = 0; i < labelList.length; i++) {
- productTags.push(labelList[i].labelName)
- }
- }
- var _this = this;
- //监听提交
- form.on('submit(formDemo)', function (obj) {
- //必须return false;
- return _this.fusionData(obj.field).submitInfo(); //获取选中权限变数组,提交变化===下拉
- });
- //关闭窗口
- $(".close-win").on("click", function () {
- _this.closeModal();
- });
- $(".my-button-product").on("click", function () {
- _this.current.auxList.push({
- i: _this.current.auxList.length + 1,
- auxItme: "",
- auxItmeVal: ""
- }); //数据库里把item写成itme
- for (var i = _this.current.auxList.length - 1; i >= 0; i--) {
- if ($("input[name='auxItme']")[i]) {
- _this.current.auxList[i].auxItme = $("input[name='auxItme']")[i].value;
- _this.current.auxList[i].auxItmeVal = $("input[name='auxItmeVal']")[i].value;
- }
- }
- auxTpl({
- elem: "#auxListDiv",
- list: _this.current.auxList
- });
- });
- $(".my-button-assay").on("click", function () {
- _this.current.assayInfoForm.auxList.push({
- i: _this.current.assayInfoForm.auxList.length + 1,
- auxItme: "",
- auxItmeVal: ""
- }); //数据库里把item写成itme
- for (var i = _this.current.assayInfoForm.auxList.length - 1; i >= 0; i--) {
- if ($("input[name='auxItme2']")[i]) {
- _this.current.assayInfoForm.auxList[i].auxItme = $("input[name='auxItme2']")[i].value;
- _this.current.assayInfoForm.auxList[i].auxItmeVal = $("input[name='auxItmeVal2']")[i].value;
- }
- }
- assayTpl({
- elem: "#assayAuxListDiv",
- list: _this.current.assayInfoForm.auxList
- });
- });
- inputTags.render({
- elem: '#inputTags',//定义输入框input对象
- content: productTags,//默认标签
- aldaBtn: true,//是否开启获取所有数据的按钮
- done: function (value) { //回车后的回调
- formData.current.labelNames = value.toString();
- },
- del: function (value) {
- formData.current.labelNames = value.toString();
- }
- })
- return _this;
- };
- //获取当前信息
- formData.getCurrent = function (id) {
- var _this = this;
- $.ajax({
- url: this.select_data,
- method: 'get',
- data: {
- guid: id || this.guid //当前ID
- },
- success: function (res) {
- try {
- res.data[0].productDateStr = res.data[0].goodsProductDate.substring(0, 10);
- if (!res.data[0].auxList)
- res.data[0].auxList = [];
- if (!res.data[0].imagesList)
- res.data[0].imagesList = [];
- if (!res.data[0].assayInfoForm)
- res.data[0].assayInfoForm = {};
- if (!res.data[0].assayInfoForm.auxList)
- res.data[0].assayInfoForm.auxList = [];
- if (!res.data[0].assayInfoForm.imagesList)
- res.data[0].assayInfoForm.imagesList = [];
- res.data[0].assayDepartment = res.data[0].assayInfoForm.assayDepartment;
- } catch (e) {
- //TODO handle the exception
- }
- $("#goodsName").html(res.data[0].goodsName);
- _this.current = res.data[0];
- auxTpl({
- elem: "#auxListDiv",
- list: res.data[0].auxList
- });
- imageTpl({
- elem: "#imageListDiv",
- list: res.data[0].imagesList
- });
- assayTpl({
- elem: "#assayAuxListDiv",
- list: res.data[0].assayInfoForm.auxList
- });
- assayImageTpl({
- elem: "#assayImageListDiv",
- list: res.data[0].assayInfoForm.imagesList
- });
- _this.current.inputsFormList = _this.current.inputsFormList || [];
- rawMaterial(_this.current.inputsFormList);
- //生产过程信息
- _this.current.materialList = formData.current.materialList || [];
- //编号
- for (let i in _this.current.materialList) {
- _this.current.materialList[i].index = i;
- }
- table.reload("produceProcessInfo", {
- data: _this.current.materialList
- });
- //加工流通信息
- _this.current.productList = formData.current.productList || [];
- //编号
- for (let i in _this.current.productList) {
- _this.current.productList[i].index = i;
- }
- table.reload("processingCirculationInfo", {
- data: _this.current.productList
- });
- _this.initialization().formVal();
- }
- });
- return _this;
- };
- //表单赋值
- formData.formVal = function () {
- var _this = this;
- form.val(this.formLayFilter, this.current);
- return this;
- };
- //合并表单内容
- formData.fusionData = function (obj) {
- for (var i = this.current.auxList.length - 1; i >= 0; i--) {
- this.current.auxList[i].auxItme = $("input[name='auxItme']")[i].value;
- this.current.auxList[i].auxItmeVal = $("input[name='auxItmeVal']")[i].value;
- if (this.current.auxList[i].auxItme == "" && this.current.auxList[i].auxItmeVal == "")
- this.current.auxList.splice(i, 1);
- }
- for (var i = this.current.assayInfoForm.auxList.length - 1; i >= 0; i--) {
- this.current.assayInfoForm.auxList[i].auxItme = $("input[name='auxItme2']")[i].value;
- this.current.assayInfoForm.auxList[i].auxItmeVal = $("input[name='auxItmeVal2']")[i].value;
- if (this.current.assayInfoForm.auxList[i].auxItme == "" && this.current.assayInfoForm.auxList[i].auxItmeVal ==
- "")
- this.current.assayInfoForm.auxList.splice(i, 1);
- }
- this.current = $.extend(this.current, obj);
- this.current.goodsBatchImages = this.current.imagesList.join(",");
- this.current.assayInfoForm.assayImgs = this.current.assayInfoForm.imagesList.join(",");
- this.current.assayInfoForm.assayDepartment = this.current.assayDepartment;
- return this;
- };
- //提交新增修改
- formData.submitInfo = function (url, data, fun) {
- var _this = this;
- $.ajax({
- type: 'POST',
- url: url || this.save_data, //+'?userId='+this.guid
- data: JSON.stringify(data || this.current),
- contentType: 'application/json',
- success: function (res) {
- if (!(res.code - 0)) {
- parent.layer.msg(res.msg, {
- icon: 1
- });
- typeof fun === 'function' && fun();
- url || _this.closeModal();
- } else {
- layer.msg(res.msg, {
- icon: 2
- });
- }
- }
- });
- return false;
- };
- formData.main();
- //验证规则
- form.verify({
- nickname: function (value) {
- if (!new RegExp("^[a-zA-Z][a-zA-Z0-9_]*$").test(value)) {
- return '账号必须以英文字母开头,只能包含英文字母、数字、下划线';
- }
- if (/(^\_)|(\__)|(\_+$)/.test(value)) {
- return '账号首尾不能出现下划线\'_\'';
- }
- },
- checkName: function (value) { },
- phoneNumber: function (value) {
- if (value) {
- if (!(/^1[3|4|5|7|8]\d{9}$/).test(value)) {
- return '请输入正确的手机号码';
- }
- }
- return false;
- },
- password: function (value) {
- if (location.searchObj().guid) {
- if (value) {
- if (!(/^[\S]{6,12}$/).test(value)) {
- return '密码必须6到12位,且不能出现空格';
- }
- }
- return false;
- }
- if (!(/^[\S]{6,12}$/).test(value)) {
- return '密码必须6到12位,且不能出现空格';
- }
- },
- resspaword: function (value) {
- var pass = $('#L_pass').val();
- if (value != pass) {
- return '两次密码不一致';
- }
- },
- ageLength: [
- /^[0-9]{0,2}$/,
- '年龄必须0到2位,且只能是数字'
- ],
- jobLength: [
- /^[a-z\A-Z\u4e00-\u9fa5_]{0,10}$/,
- '职务必须是0-10位,且不包含特殊字符与数字'
- ],
- workUnit: [
- /^[0-9\a-z\A-Z\u4e00-\u9fa5_]{0,25}$/,
- '工作单位必须是0-25位,且不包含特殊字符'
- ],
- vcode: [
- /^[\w]{4,5}$/,
- '验证码不符合规则'
- ]
- });
- form.on('select(roles)', function (data) {
- rolesViewOnemapParam = $("#rolesView option[value='" + data.value + "']").attr('oneMap');
- });
- /*element.on('tab(docDemoTabBrief)', function (data) {
- if ('2' == this.getAttribute('lay-id')) {
- if (rolesViewOnemapParam && null != rolesViewOnemapParam) {
- let req = {
- orchardId: rolesViewOnemapParam,
- pageNo: 1,
- pageSize: 10
- };
- $.ajax({
- type: 'get',
- url: 'getOrchardList' + '?orchardId=' + rolesViewOnemapParam + '&pageNo=1&pageSize=10',
- success: function (res) {
- formData.current.materialList = res.data;
- formData.current.materialList.forEach(value => {
- value.processType = 1;
- });
- table.reload("produceProcessInfo", {
- data: formData.current.materialList
- });
- }
- });
- }
- }
- });*/
- });
- </script>
- </body>
- </html>
|