您好,登錄后才能下訂單哦!
直接上代碼吧
<%@ page contentType="text/html;charset=UTF-8" %> <html> <head> <title>LibGoodsController測試頁面</title> <meta name="layout" content="main"/> <script type="text/javascript" src="${resource(base: '..', dir: 'js', file: 'jquery-2.1.3.js')}"></script> <script type="text/javascript" src="${resource(base: '..', dir: 'js', file: 'vue.min.js')}"></script> <script> $(function() { //列表選中ID var tableSelectId; //列表選中tr var selTr = null; //列表JSON var printjson; //初始化過濾器 Vue.filter('isAuditFormatter', function (value) { if(value == true){ return "已審核"; } else return "未審核"; }); Vue.filter('isEnabledFormatter',function (value){ if(value == true){ return "啟用"; } else return "停用"; }); Vue.filter('goodsTypeFormatter',function (value){ if(value == "1"){ return "零售"; } else return "餐飲"; }); var OBJECT_CRUD = new Vue({ el: '#object_crud', data: { //顯示JSON message:'', //對象 object : '', //對象數(shù)組 list : '' }, methods: { //分頁查詢并顯示數(shù)據(jù) showData: function () { var _self = this; var url = "..."; $.ajax({ type: 'GET', url: url, success:function(data) { printjson = JSON.stringify(data); _self.list = data.data.rows; } }); }, //顯示查詢JSON showJSON:function(){ this.message = printjson; }, //清空查詢返回JSON clearJSON:function(){ this.message = ""; }, //選中列表行 點(diǎn)擊事件 onClick:function (evt) { var _self = this; var el = evt.srcElement?evt.srcElement:evt.target; if(el.tagName.toUpperCase() !="TD") return; var tr = el.parentNode; tr.style.backgroundColor="yellow"; if(selTr !=null) { selTr.style.backgroundColor ="white"; } selTr = tr; tableSelectId = selTr.cells[0].innerHTML; //通過ID獲取對象 var url = "..."; $.ajax({ type: 'GET', url: url, success:function(data) { if(data.result == "true"){ _self.object = data.data; } } }); }, //啟用 選中的 記錄 enable:function(){ var _self = this; var url = "..."; $.ajax({ type: 'GET', url: url, success:function(data) { _self.message = JSON.stringify(data); if(data.result == "true"){ _self.showData(); } } }); }, //停用 選中的 記錄 unEnable:function(){ var _self = this; var url = "..."; $.ajax({ type: 'GET', url: url, success:function(data) { _self.message = JSON.stringify(data); if(data.result == "true"){ _self.showData(); } } }); }, //刪除 記錄 delete:function(){ var _self = this; var url = "..."; $.ajax({ type: 'GET', url: url, success:function(data) { _self.message = JSON.stringify(data); if(data.result == "true") { _self.showData(); } } }); }, save:function(){ var _self = this; var url = "..."; $.ajax({ type: 'POST', url: url, data:{ id:$('#id').val() /*...*/ }, success:function(data) { _self.message = JSON.stringify(data); if(data.result == "true"){ _self.showData(); } } }); } } }) }); </script> </head> <body> <div id="test_title"> <font color="#ff1493" size="6">商品信息管理服務(wù)(web-service-libGoods)接口測試</font> <br><br><br> </div> <div id="object_crud"> 測試介紹:<br><br> <div class="description" style="height:auto;width:auto;border-top: 1px dashed #F00; border-bottom: 1px dashed #F00;border-left: 1px dashed #F00;border-right: 1px dashed #F00"> 1.條件查詢并分頁(查詢條件:商品名稱模糊查詢,商品類別,分頁參數(shù))<br> 2.新增商品<br> 3.更新商品<br> 4.刪除商品<br> 5.啟用/停用商品 </div><br><br> 1.商品名稱:<g:textField name="queryStr" id="queryStr1" value="佳能"></g:textField> 商品類型 : <g:radio value="2" name="goodsTypeSearch"></g:radio>餐飲 <g:radio value="1" name="goodsTypeSearch" checked="true"></g:radio>零售 列表參數(shù): 當(dāng)前頁:<g:textField name="page" value="0"></g:textField> 每頁顯示:<g:textField name="pageSize" value="20"></g:textField> <button v-on:click="showData">查詢</button> <button v-on:click="showJSON">顯示JSON</button> <br><br> 測試結(jié)果JSON:<button v-on:click="clearJSON">清空測試結(jié)果</button> <br><br> <div class="jsonResult" style="height:auto;width:auto;border-top: 1px dashed #F00; border-bottom: 1px dashed #F00;border-left: 1px dashed #F00;border-right: 1px dashed #F00"> {{message}} </div><br><br> 測試列表: <br><br> <div style="height:auto;width:auto;border-top: 1px dashed #F00; border-bottom: 1px dashed #F00;border-left: 1px dashed #F00;border-right: 1px dashed #F00"> <table id="table" ;> <thead> <tr> <th style='width:3%; text-align: left'>ID</th> <th style='width:10%; text-align: left'>商品編碼</th> <th style='width:5%; text-align: left'>商品類別</th> <th style='width:10%; text-align: left'>商品名稱</th> <th style='width:10%; text-align: left'>簡稱</th> <th style='width:5%; text-align: left'>是否審核</th> <th style='width:5%; text-align: left'>是否啟用</th> </tr> </thead> <tbody> <tr v-for="data in list" v-on:click="onClick"> <td>{{data.id}}</td> <td>{{data.barcode}}</td> <td>{{data.goodsType | goodsTypeFormatter}}</td> <td>{{data.name}}</td> <td>{{data.shortName}}</td> <td>{{data.isAudit | isAuditFormatter}}</td> <td>{{data.isEnabled | isEnabledFormatter}}</td> </tr> </tbody> </table> </div> <br><br> 2.<button v-on:click="save">保存</button> <br><br> 3.<button v-on:click="save">更新</button> <br><br> 4.<button v-on:click="delete">刪除</button> <br><br> 5.<button v-on:click="enable">啟用</button> <button v-on:click="unEnable">停用</button>br><br> 商品對象: <div class="z333" style="height:auto;width:auto;border-top: 1px dashed #F00; border-bottom: 1px dashed #F00;border-left: 1px dashed #F00;border-right: 1px dashed #F00"><br> <g:form name="myform"> ID(測試啟/停用,刪除):<g:textField name="id" v-model="object.id"></g:textField><br><br> 商品編碼:<g:textField name="barcode" v-model="object.barcode"></g:textField><font color="red"> *</font><br><br> 商品名稱:<g:textField name="name" v-model="object.name"></g:textField><font color="red"> *</font><br><br> 商品類別:<g:radio value="2" name="goodsType" v-model="object.goodsType"></g:radio>餐飲 <g:radio value="1" name="goodsType" v-model="object.goodsType"></g:radio>零售<font color="red"> *</font><br><br> 商品簡稱:<g:textField name="shortName" v-model="object.shortName"></g:textField><br><br> 商品分類:<g:textField name="categoryName" v-model="object.categoryName"></g:textField><br><br> 品牌編碼:<g:textField name="brandCode" v-model="object.brandCode"></g:textField><br><br> 產(chǎn)地:<g:textField name="productArea" v-model="object.productArea"></g:textField><br><br> 單位:<g:textField name="unitName" v-model="object.unitName"></g:textField><br><br> 規(guī)格:<g:textField name="goodsSpec" v-model="object.goodsSpec"></g:textField><br><br> 拼音碼:<g:textField name="pyCode" v-model="object.pyCode"></g:textField><br><br> 備注:<g:textField name="remark" v-model="object.remark"></g:textField><br><br> </g:form> </div><br><br> </div> </body> </html>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持億速云。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。