123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- <!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.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
- <link rel="stylesheet" href="../../static/css/font-awesome.min.css">
- <link rel="stylesheet" href="../../static/css/weadmin.css">
- <link rel="stylesheet" href="../../static/css/style.css">
- <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
- <!--[if lt IE 9]>
- <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
- <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
- <![endif]-->
- <style>
- html{
- overflow-y: auto;
- }
- .layui-form-label{
- width: 100px;
- }
- .layui-input-block{
- margin-left: 138px;
- }
- .w-e-toolbar{
- padding: 0 !important;
- }
- .w-e-toolbar .w-e-menu{
- padding: 5px 4px !important;
- }
- </style>
- </head>
- <body>
- <div class="weadmin-body">
- <form class="layui-form">
- <div class="layui-form-item">
- <label class="layui-form-label">
- 设备铭牌名称:
- </label>
- <div class="layui-input-block steta_grouds">
- <input type="text" placeholder="请输入设备铭牌名称" class="layui-input textName" lay-verify="required">
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label">参数介绍</label>
- <div class="layui-input-block">
- <a href="javascript:;" class="layui-btn layui-btn-normal addLink">添加其他参数</a>
- </div>
- <div class="layui-input-block" id="link_items">
- <!--<div class="link_item">-->
- <!--<input type="text" placeholder="参数名称">-->
- <!--<input type="text" placeholder="参数内容">-->
- <!--<span class="operation">-->
- <!--<i class="fa fa-long-arrow-up moveUp"></i>-->
- <!--<i class="fa fa-long-arrow-down moveDown"></i>-->
- <!--<i class="fa fa-trash-o deleteLink"></i>-->
- <!--</span>-->
- <!--</div>-->
- </div>
- </div>
- <div class="layui-form-item" style="text-align: center;padding-top: 50px">
- <button class="layui-btn" lay-submit lay-filter="equipmentBtn">提交</button>
- </div>
- </form>
- <span class="text" style="display: none"></span>
- </div>
- <script src="../../lib/layui/layui.js" charset="utf-8"></script>
- <script src="../../static/js/config.js"></script>
- <script>
- layui.use(['form','layer','jquery','laydate'], function(){
- var form = layui.form,
- $ = layui.jquery,
- laydate= layui.laydate,
- layer = layui.layer;
- form.render();
- if (sessionStorage.getItem('QRcodeIDs') !=""){
- QRcodeDevice(sessionStorage.getItem('QRcodeIDs'))
- }
- var num = 0,bums = 0,delateDevice = [];
- $("body").on('click','.addLink',function () {
- var mnum = bums++ +1;
- var str =`
- <div class="link_item" index-data="${mnum}">
- <input type="text" placeholder="参数名称" lay-verify="required" class="equipmentName" oninput="parent.deviceNameFun(this.value,${mnum})">
- <input type="text" placeholder="参数内容" lay-verify="required" class="equipmentContent" oninput="parent.deviceContentFun(this.value,${mnum})">
- <span class="operation">
- <i class="fa fa-long-arrow-up moveUp"></i>
- <i class="fa fa-long-arrow-down moveDown"></i>
- <i class="fa fa-trash-o deleteLink"></i>
- </span>
- </div>`;
- $("#link_items").append(str);
- parent.onFocus();
- parent.addDevice(mnum)
- });
- $('body').on('click','.deleteLink',function () {
- var equipmentobj = {id:'',deleteFlag:false,paramContent:"",paramName:'',parentId:'',title:'',zIndex:''};
- $(this).parent().parent().remove();
- parent.onFocus();
- parent.deleteDevice($(this).parent().parent().attr('index-data'));
- if ($(this).parent().parent().attr('link-id') != "") {
- equipmentobj = {};
- equipmentobj.title = $('.textName').val();
- equipmentobj.parentId = sessionStorage.getItem("QRcodeIDs");
- equipmentobj.paramName = $(this).parent().parent().find('.equipmentName').val();
- equipmentobj.paramContent = $(this).parent().parent().find('.equipmentContent').val();
- equipmentobj.deleteFlag = false;
- equipmentobj.id = $(this).parent().parent().attr('device-id');
- equipmentobj.zIndex = num++ +1;
- delateDevice.push(equipmentobj)
- }
- });
- // 上移
- $("body") .on("click",".moveUp",function () {
- var index = $(this).parent().parent();
- if(index.index() != 0){
- index.prev().before(index);
- }else {
- layer.msg('已经移至最高点', {icon: 8});
- }
- });
- // 下移
- $("body") .on("click",".moveDown",function () {
- var index = $(this).parent().parent();
- if(index.index() != $(".link_item").length-1){
- index.next().after(index);
- }else {
- layer.msg('已经移至最低点', {icon: 8});
- }
- });
- form.on('submit(equipmentBtn)', function(){
- if (sessionStorage.getItem('QRcodeIDs') == "false") {
- var equipmentNameArray = [] , equipmenItem = $('.link_item');
- var equipmentobj = {paramContent:"",paramName:'',pageId:'',title:'',zIndex:''};
- var num = 0;
- equipmenItem.each(function () {
- equipmentobj = {};
- equipmentobj.title = $('.textName').val();
- equipmentobj.pageId = sessionStorage.getItem("QRcodeDetaileID");
- equipmentobj.paramName = $(this).find('.equipmentName').val();
- equipmentobj.paramContent = $(this).find('.equipmentContent').val();
- equipmentobj.zIndex = num++ +1;
- equipmentNameArray.push(equipmentobj)
- });
- $.ajax({
- url:urlF+'api/page/v1/addEquipment',
- type:'post',
- data:JSON.stringify(equipmentNameArray),
- contentType:'application/json;charset=utf-8',
- dataType:'json',
- success:function (res) {
- if (res.code === '200'){
- parent.pageRelationIdFun(res.data);
- parent.QRcodeIndexas();
- layer.msg('设备铭牌新增成功');
- }else {
- layer.msg('设备铭牌新增失败,请检查信息');
- }
- },
- error:function () {
- layer.msg('网络错误,请检查网络');
- }
- });
- }else {
- var equipmentNameArray = [] , equipmenItem = $('.link_item');
- var equipmentobj = {id:'',deleteFlag:false,paramContent:"",paramName:'',parentId:'',title:'',zIndex:''};
- var num = 0;
- if (delateDevice != []) {
- for (var j = 0; j < delateDevice.length; j++) {
- equipmentNameArray.push(delateDevice[j])
- }
- }
- equipmenItem.each(function () {
- equipmentobj = {};
- equipmentobj.title = $('.textName').val();
- equipmentobj.parentId = sessionStorage.getItem("QRcodeIDs");
- equipmentobj.paramName = $(this).find('.equipmentName').val();
- equipmentobj.paramContent = $(this).find('.equipmentContent').val();
- equipmentobj.deleteFlag = false;
- equipmentobj.id = $(this).attr('device-id');
- equipmentobj.zIndex = num++ +1;
- equipmentNameArray.push(equipmentobj)
- });
- $.ajax({
- url:urlF+'api/page/v1/updateEquipment',
- type:'post',
- data:JSON.stringify(equipmentNameArray),
- contentType:'application/json;charset=utf-8',
- dataType:'json',
- success:function (res) {
- if (res.code === '200'){
- parent.onFocus();
- parent.pageRelationIdFun(res.data);
- layer.msg('设备铭牌修改成功');
- }else {
- layer.msg('设备铭牌修改失败,请检查信息');
- }
- },
- error:function () {
- layer.msg('网络错误,请检查网络');
- }
- })
- }
- return false;
- });
- // 数据回显
- function QRcodeDevice(id) {
- $.ajax({
- url: urlF+'api/page/v1/getPageEdit/'+sessionStorage.getItem('QRcodeDetaileID'),
- type: 'get',
- dataType: 'json',
- success: function (res) {
- for (var i = 0; i < res.data.pageItemList.length; i++) {
- if (res.data.pageItemList[i].pageRelation.businessType == "EQUIPMENT" && res.data.pageItemList[i].pageRelation.businessId == id) {
- for (var j = 0; j < res.data.pageItemList[i].equipmentList.length; j++) {
- $('.textName').val(res.data.pageItemList[i].equipmentList[j].title);
- bums = j;
- var str =`
- <div class="link_item" index-data="${bums}" device-id="${id}">
- <input type="text" placeholder="参数名称" value="${res.data.pageItemList[i].equipmentList[j].paramName}" class="equipmentName" oninput="parent.deviceNameFun(this.value,${bums})" lay-verify="required">
- <input type="text" placeholder="参数内容" value="${res.data.pageItemList[i].equipmentList[j].paramContent}" class="equipmentContent" oninput="parent.deviceContentFun(this.value,${bums})" lay-verify="required">
- <span class="operation">
- <i class="fa fa-long-arrow-up moveUp"></i>
- <i class="fa fa-long-arrow-down moveDown"></i>
- <i class="fa fa-trash-o deleteLink"></i>
- </span>
- </div>`;
- $("#link_items").append(str);
- }
- }
- }
- },
- error:function () {
- layer.msg('请检查网络', {icon: 2});
- }
- });
- }
- });
- </script>
- </body>
- </html>
|