优化代码

This commit is contained in:
java110 2021-11-04 17:42:54 +08:00
parent fa0e0f03ba
commit 28318048dd
4 changed files with 264 additions and 261 deletions

View File

@ -1,90 +1,90 @@
(function(vc){
(function (vc) {
vc.extends({
propTypes: {
callBackListener:vc.propTypes.string, //父组件名称
callBackFunction:vc.propTypes.string //父组件监听方法
callBackListener: vc.propTypes.string, //父组件名称
callBackFunction: vc.propTypes.string //父组件监听方法
},
data:{
addShopRangeInfo:{
shopRangeId:'',
shopRangeId:'',
shopTypeId:'',
rangeName:'',
isShow:'',
isDefault:'',
seq:'',
remark:'',
data: {
addShopRangeInfo: {
shopRangeId: '',
shopRangeId: '',
shopTypeId: '',
rangeName: '',
isShow: '',
isDefault: '',
seq: '',
remark: '',
}
},
_initMethod:function(){
_initMethod: function () {
},
_initEvent:function(){
vc.on('addShopRange','openAddShopRangeModal',function(){
},
_initEvent: function () {
vc.on('addShopRange', 'openAddShopRangeModal', function () {
$('#addShopRangeModel').modal('show');
});
},
methods:{
addShopRangeValidate(){
methods: {
addShopRangeValidate() {
return vc.validate.validate({
addShopRangeInfo:vc.component.addShopRangeInfo
},{
'addShopRangeInfo.shopTypeId':[
{
limit:"required",
param:"",
errInfo:"店铺类型id不能为空"
addShopRangeInfo: vc.component.addShopRangeInfo
}, {
'addShopRangeInfo.shopTypeId': [
{
limit: "required",
param: "",
errInfo: "店铺类型id不能为空"
},
{
limit:"maxLength",
param:"30",
errInfo:"店铺类型ID太长"
{
limit: "maxLength",
param: "30",
errInfo: "店铺类型ID太长"
},
],
'addShopRangeInfo.rangeName':[
{
limit:"required",
param:"",
errInfo:"范围名称不能为空"
'addShopRangeInfo.rangeName': [
{
limit: "required",
param: "",
errInfo: "范围名称不能为空"
},
{
limit:"maxLength",
param:"30",
errInfo:"范围名称太长"
{
limit: "maxLength",
param: "30",
errInfo: "范围名称太长"
},
],
'addShopRangeInfo.isShow':[
{
limit:"required",
param:"",
errInfo:"是否展示不能为空"
'addShopRangeInfo.isShow': [
{
limit: "required",
param: "",
errInfo: "是否展示不能为空"
},],
'addShopRangeInfo.isDefault':[
{
limit:"required",
param:"",
errInfo:"是否默认不能为空"
'addShopRangeInfo.isDefault': [
{
limit: "required",
param: "",
errInfo: "是否默认不能为空"
},],
'addShopRangeInfo.seq':[
{
limit:"required",
param:"",
errInfo:"显示序号不能为空"
'addShopRangeInfo.seq': [
{
limit: "required",
param: "",
errInfo: "显示序号不能为空"
},
{
limit:"num",
param:"",
errInfo:"显示序号不是有效数字"
{
limit: "num",
param: "",
errInfo: "显示序号不是有效数字"
},
],
'addShopRangeInfo.remark':[
{
limit:"maxLength",
param:"120",
errInfo:"描述太长"
'addShopRangeInfo.remark': [
{
limit: "maxLength",
param: "120",
errInfo: "描述太长"
},
],
@ -93,58 +93,57 @@
});
},
saveShopRangeInfo:function(){
if(!vc.component.addShopRangeValidate()){
saveShopRangeInfo: function () {
if (!vc.component.addShopRangeValidate()) {
vc.toast(vc.validate.errInfo);
return ;
return;
}
vc.component.addShopRangeInfo.communityId = vc.getCurrentCommunity().communityId;
//不提交数据将数据 回调给侦听处理
if(vc.notNull($props.callBackListener)){
vc.emit($props.callBackListener,$props.callBackFunction,vc.component.addShopRangeInfo);
if (vc.notNull($props.callBackListener)) {
vc.emit($props.callBackListener, $props.callBackFunction, vc.component.addShopRangeInfo);
$('#addShopRangeModel').modal('hide');
return ;
return;
}
vc.http.apiPost('/shopRange/saveShopRange',
JSON.stringify(vc.component.addShopRangeInfo),
{
emulateJSON:true
},
function(json,res){
emulateJSON: true
},
function (json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
if (_json.code == 0) {
//关闭model
$('#addShopRangeModel').modal('hide');
vc.component.clearAddShopRangeInfo();
vc.emit('shopRangeManage','listShopRange',{});
vc.emit('shopRangeManage', 'listShopRange', {});
return ;
return;
}
vc.message(_json.msg);
},
function(errInfo,error){
},
function (errInfo, error) {
console.log('请求失败处理');
vc.message(errInfo);
});
});
},
clearAddShopRangeInfo:function(){
clearAddShopRangeInfo: function () {
vc.component.addShopRangeInfo = {
shopRangeId:'',
shopTypeId:'',
rangeName:'',
isShow:'',
isDefault:'',
seq:'',
remark:'',
shopRangeId: '',
shopTypeId: '',
rangeName: '',
isShow: '',
isDefault: '',
seq: '',
remark: '',
};
};
}
}
});

View File

@ -1,52 +1,51 @@
(function(vc,vm){
(function (vc, vm) {
vc.extends({
data:{
deleteShopRangeInfo:{
data: {
deleteShopRangeInfo: {
}
},
_initMethod:function(){
_initMethod: function () {
},
_initEvent:function(){
vc.on('deleteShopRange','openDeleteShopRangeModal',function(_params){
},
_initEvent: function () {
vc.on('deleteShopRange', 'openDeleteShopRangeModal', function (_params) {
vc.component.deleteShopRangeInfo = _params;
$('#deleteShopRangeModel').modal('show');
});
},
methods:{
deleteShopRange:function(){
vc.component.deleteShopRangeInfo.communityId=vc.getCurrentCommunity().communityId;
methods: {
deleteShopRange: function () {
vc.http.apiPost(
'/shopRange/deleteShopRange',
JSON.stringify(vc.component.deleteShopRangeInfo),
{
emulateJSON:true
},
function(json,res){
emulateJSON: true
},
function (json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
if (_json.code == 0) {
//关闭model
$('#deleteShopRangeModel').modal('hide');
vc.emit('shopRangeManage','listShopRange',{});
return ;
vc.emit('shopRangeManage', 'listShopRange', {});
return;
}
vc.message(_json.msg);
},
function(errInfo,error){
},
function (errInfo, error) {
console.log('请求失败处理');
vc.message(json);
});
});
},
closeDeleteShopRangeModel:function(){
closeDeleteShopRangeModel: function () {
$('#deleteShopRangeModel').modal('hide');
}
}
});
})(window.vc,window.vc.component);
})(window.vc, window.vc.component);

View File

@ -1,142 +1,141 @@
(function(vc,vm){
(function (vc, vm) {
vc.extends({
data:{
editShopRangeInfo:{
shopRangeId:'',
shopRangeId:'',
shopTypeId:'',
rangeName:'',
isShow:'',
isDefault:'',
seq:'',
remark:'',
data: {
editShopRangeInfo: {
shopRangeId: '',
shopRangeId: '',
shopTypeId: '',
rangeName: '',
isShow: '',
isDefault: '',
seq: '',
remark: '',
}
},
_initMethod:function(){
_initMethod: function () {
},
_initEvent:function(){
vc.on('editShopRange','openEditShopRangeModal',function(_params){
},
_initEvent: function () {
vc.on('editShopRange', 'openEditShopRangeModal', function (_params) {
vc.component.refreshEditShopRangeInfo();
$('#editShopRangeModel').modal('show');
vc.copyObject(_params, vc.component.editShopRangeInfo );
vc.component.editShopRangeInfo.communityId = vc.getCurrentCommunity().communityId;
vc.copyObject(_params, vc.component.editShopRangeInfo);
});
},
methods:{
editShopRangeValidate:function(){
return vc.validate.validate({
editShopRangeInfo:vc.component.editShopRangeInfo
},{
'editShopRangeInfo.shopTypeId':[
{
limit:"required",
param:"",
errInfo:"店铺类型id不能为空"
methods: {
editShopRangeValidate: function () {
return vc.validate.validate({
editShopRangeInfo: vc.component.editShopRangeInfo
}, {
'editShopRangeInfo.shopTypeId': [
{
limit: "required",
param: "",
errInfo: "店铺类型id不能为空"
},
{
limit:"maxLength",
param:"30",
errInfo:"店铺类型ID太长"
{
limit: "maxLength",
param: "30",
errInfo: "店铺类型ID太长"
},
],
'editShopRangeInfo.rangeName':[
{
limit:"required",
param:"",
errInfo:"范围名称不能为空"
'editShopRangeInfo.rangeName': [
{
limit: "required",
param: "",
errInfo: "范围名称不能为空"
},
{
limit:"maxLength",
param:"30",
errInfo:"范围名称太长"
{
limit: "maxLength",
param: "30",
errInfo: "范围名称太长"
},
],
'editShopRangeInfo.isShow':[
{
limit:"required",
param:"",
errInfo:"是否展示不能为空"
'editShopRangeInfo.isShow': [
{
limit: "required",
param: "",
errInfo: "是否展示不能为空"
},],
'editShopRangeInfo.isDefault':[
{
limit:"required",
param:"",
errInfo:"是否默认不能为空"
'editShopRangeInfo.isDefault': [
{
limit: "required",
param: "",
errInfo: "是否默认不能为空"
},],
'editShopRangeInfo.seq':[
{
limit:"required",
param:"",
errInfo:"显示序号不能为空"
'editShopRangeInfo.seq': [
{
limit: "required",
param: "",
errInfo: "显示序号不能为空"
},
{
limit:"num",
param:"",
errInfo:"显示序号不是有效数字"
{
limit: "num",
param: "",
errInfo: "显示序号不是有效数字"
},
],
'editShopRangeInfo.remark':[
{
limit:"maxLength",
param:"120",
errInfo:"描述太长"
'editShopRangeInfo.remark': [
{
limit: "maxLength",
param: "120",
errInfo: "描述太长"
},
],
'editShopRangeInfo.shopRangeId':[
{
limit:"required",
param:"",
errInfo:"店铺经营范围id不能为空"
'editShopRangeInfo.shopRangeId': [
{
limit: "required",
param: "",
errInfo: "店铺经营范围id不能为空"
}]
});
},
editShopRange:function(){
if(!vc.component.editShopRangeValidate()){
});
},
editShopRange: function () {
if (!vc.component.editShopRangeValidate()) {
vc.toast(vc.validate.errInfo);
return ;
return;
}
vc.http.apiPost(
'/shopRange/updateShopRange',
JSON.stringify(vc.component.editShopRangeInfo),
{
emulateJSON:true
},
function(json,res){
emulateJSON: true
},
function (json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
if (_json.code == 0) {
//关闭model
$('#editShopRangeModel').modal('hide');
vc.emit('shopRangeManage','listShopRange',{});
return ;
vc.emit('shopRangeManage', 'listShopRange', {});
return;
}
vc.message(_json.msg);
},
function(errInfo,error){
},
function (errInfo, error) {
console.log('请求失败处理');
vc.message(errInfo);
});
});
},
refreshEditShopRangeInfo:function(){
vc.component.editShopRangeInfo= {
shopRangeId:'',
shopRangeId:'',
shopTypeId:'',
rangeName:'',
isShow:'',
isDefault:'',
seq:'',
remark:'',
refreshEditShopRangeInfo: function () {
vc.component.editShopRangeInfo = {
shopRangeId: '',
shopRangeId: '',
shopTypeId: '',
rangeName: '',
isShow: '',
isDefault: '',
seq: '',
remark: '',
}
}
}
});
})(window.vc,window.vc.component);
})(window.vc, window.vc.component);

View File

@ -1,38 +1,45 @@
<div >
<div>
<div class="row">
<div class="col-lg-12">
<div class="ibox ">
<div class="ibox-title">
<h5>查询条件</h5>
<div class="ibox-tools" style="top:10px;">
</div>
</div>
<div class="ibox-content">
<div class="row">
<div class="col-sm-4" >
<div class="form-group">
<input type="text" placeholder="请输入范围名称" v-model="shopRangeManageInfo.conditions.rangeName" class=" form-control">
</div> </div><div class="col-sm-4" >
<div class="form-group">
<select class="custom-select" v-model="shopRangeManageInfo.conditions.isShow">
<option selected value="">请选择是否展示</option>
<option value="Y"></option>
<option value="N"></option>
</select>
</div> </div>
<div class="col-sm-3" >
<div class="form-group">
<select class="custom-select" v-model="shopRangeManageInfo.conditions.isDefault">
<option selected value="">请选择是否默认</option>
<option value="F">自定义</option>
<option value="T">默认</option>
</select>
</div> </div><div class="col-sm-1">
<div class="col-sm-4">
<div class="form-group">
<input type="text" placeholder="请输入范围名称"
v-model="shopRangeManageInfo.conditions.rangeName" class=" form-control">
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<select class="custom-select" v-model="shopRangeManageInfo.conditions.isShow">
<option selected value="">请选择是否展示</option>
<option value="Y"></option>
<option value="N"></option>
</select>
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
<select class="custom-select" v-model="shopRangeManageInfo.conditions.isDefault">
<option selected value="">请选择是否默认</option>
<option value="F">自定义</option>
<option value="T">默认</option>
</select>
</div>
</div>
<div class="col-sm-1">
<button type="button" class="btn btn-primary btn-sm" v-on:click="_queryShopRangeMethod()">
<i class="glyphicon glyphicon-search"></i> 查询
<i class="glyphicon glyphicon-search"></i> 查询
</button>
</div></div>
</div>
</div>
</div>
@ -53,43 +60,45 @@
</div>
<div class="ibox-content">
<table class="footable table table-stripped toggle-arrow-tiny"
data-page-size="15"
>
<table class="footable table table-stripped toggle-arrow-tiny" data-page-size="15">
<thead>
<tr>
<th class="text-center">店铺类型</th>
<th class="text-center">范围名称</th>
<th class="text-center">是否展示</th>
<th class="text-center">是否默认</th>
<th class="text-center">显示序号</th>
<th class="text-center">备注</th>
<th class="text-center">操作</th>
</tr>
<tr>
<th class="text-center">店铺类型</th>
<th class="text-center">范围名称</th>
<th class="text-center">是否展示</th>
<th class="text-center">是否默认</th>
<th class="text-center">显示序号</th>
<th class="text-center">备注</th>
<th class="text-center">操作</th>
</tr>
</thead>
<tbody>
<tr v-for="shopRange in shopRangeManageInfo.shopRanges">
<td class="text-center">{{shopRange.typeName}}</td>
<td class="text-center">{{shopRange.rangeName}}</td>
<td class="text-center">{{shopRange.isShow =='Y'?'是':'否'}}</td>
<td class="text-center">{{shopRange.isDefault =='F'?'自定义':'默认'}}</td>
<td class="text-center">{{shopRange.seq}}</td>
<td class="text-center">{{shopRange.remark}}</td>
<td class="text-center"><div class="btn-group">
<button class="btn-white btn btn-xs" v-on:click="_openEditShopRangeModel(shopRange)">修改</button>
</div>
<div class="btn-group">
<button class="btn-white btn btn-xs" v-on:click="_openDeleteShopRangeModel(shopRange)">删除</button>
</div></td>
<tr v-for="shopRange in shopRangeManageInfo.shopRanges">
<td class="text-center">{{shopRange.typeName}}</td>
<td class="text-center">{{shopRange.rangeName}}</td>
<td class="text-center">{{shopRange.isShow =='Y'?'是':'否'}}</td>
<td class="text-center">{{shopRange.isDefault =='F'?'自定义':'默认'}}</td>
<td class="text-center">{{shopRange.seq}}</td>
<td class="text-center">{{shopRange.remark}}</td>
<td class="text-center">
<div class="btn-group">
<button class="btn-white btn btn-xs"
v-on:click="_openEditShopRangeModel(shopRange)">修改</button>
</div>
<div class="btn-group">
<button class="btn-white btn btn-xs"
v-on:click="_openDeleteShopRangeModel(shopRange)">删除</button>
</div>
</td>
</tr>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="7">
<ul class="pagination float-right"></ul>
</td>
</tr>
<tr>
<td colspan="7">
<ul class="pagination float-right"></ul>
</td>
</tr>
</tfoot>
</table>
<!-- 分页 -->
@ -99,13 +108,10 @@
</div>
</div>
<vc:create path="admin/addShopRange"
callBackListener=""
callBackFunction=""
></vc:create>
<vc:create path="admin/addShopRange" callBackListener="" callBackFunction=""></vc:create>
<vc:create path="admin/editShopRange"></vc:create>
<vc:create path="admin/deleteShopRange"></vc:create>
</div>
</div>