优化代码

This commit is contained in:
wuxw 2022-10-26 05:00:08 +08:00
parent 14534ad299
commit f0cfb3a1b2
12 changed files with 522 additions and 0 deletions

BIN
public/.DS_Store vendored

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,51 @@
<div id="addMarketRuleModel" class="modal fade" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body">
<h3 class="m-t-none m-b "><span>
<vc:i18n name="添加" namespace="addMarketRule"></vc:i18n>
</span></h3>
<div class="ibox-content">
<div>
<div>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><span>
<vc:i18n name='名称' namespace='addMarketRule'></vc:i18n>
</span></label>
<div class="col-sm-10">
<input v-model="addMarketRuleInfo.name" type="text"
:placeholder="vc.i18n('必填,请填写名称','addMarketRule')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><span>
<vc:i18n name='备注' namespace=' addMarketRule'></vc:i18n>
</span></label>
<div class="col-sm-10">
<textarea v-model="addMarketRuleInfo.remark"
:placeholder="vc.i18n('必填,请填写备注','addMarketRule')" class="form-control"></textarea>
</div>
</div>
<div class="ibox-content">
<button class="btn btn-primary float-right" type="button"
v-on:click="saveMarketRuleInfo()"><i class="fa fa-check"></i>&nbsp;
<span>
<vc:i18n name="保存"></vc:i18n>
</span>
</button>
<button type="button" class="btn btn-warning float-right" style="margin-right:20px;"
data-dismiss="modal">
<span>
<vc:i18n name="取消"></vc:i18n>
</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,97 @@
(function (vc) {
vc.extends({
propTypes: {
callBackListener: vc.propTypes.string, //父组件名称
callBackFunction: vc.propTypes.string //父组件监听方法
},
data: {
addMarketRuleInfo: {
ruleId: '',
name: '',
remark: '',
}
},
_initMethod: function () {
},
_initEvent: function () {
vc.on('addMarketRule', 'openAddMarketRuleModal', function () {
$('#addMarketRuleModel').modal('show');
});
},
methods: {
addMarketRuleValidate() {
return vc.validate.validate({
addMarketRuleInfo: vc.component.addMarketRuleInfo
}, {
'addMarketRuleInfo.name': [
{
limit: "required",
param: "",
errInfo: "名称不能为空"
},
{
limit: "maxLength",
param: "64",
errInfo: "名称不能超过64"
},
],
'addMarketRuleInfo.remark': [
{
limit: "required",
param: "",
errInfo: "备注'不能为空"
},
{
limit: "maxLength",
param: "512",
errInfo: "备注'不能超过512"
},
],
});
},
saveMarketRuleInfo: function () {
if (!vc.component.addMarketRuleValidate()) {
vc.toast(vc.validate.errInfo);
return;
}
vc.http.apiPost(
'/marketRule.saveMarketRule',
JSON.stringify(vc.component.addMarketRuleInfo),
{
emulateJSON: true
},
function (json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
if (_json.code == 0) {
//关闭model
$('#addMarketRuleModel').modal('hide');
vc.component.clearAddMarketRuleInfo();
vc.emit('marketRuleManage', 'listMarketRule', {});
return;
}
vc.toast(_json.msg);
},
function (errInfo, error) {
console.log('请求失败处理');
vc.toast(errInfo);
});
},
clearAddMarketRuleInfo: function () {
vc.component.addMarketRuleInfo = {
name: '',
remark: '',
};
}
}
});
})(window.vc);

View File

@ -0,0 +1,19 @@
<div class="modal fade" id="deleteMarketRuleModel" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel"> <span><vc:i18n name="请确认您的操作!"></vc:i18n></span></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<tr align="center"><th><span><vc:i18n name="确定删除营销规则" namespace="deleteMarketRule"></vc:i18n></span></th></tr>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" v-on:click="closeDeleteMarketRuleModel()"><span><vc:i18n name="点错了"></vc:i18n></span></button>
<button type="button" class="btn btn-primary" v-on:click="deleteMarketRule()"><span><vc:i18n name="确认删除!"></vc:i18n></span></button>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,51 @@
(function (vc, vm) {
vc.extends({
data: {
deleteMarketRuleInfo: {
}
},
_initMethod: function () {
},
_initEvent: function () {
vc.on('deleteMarketRule', 'openDeleteMarketRuleModal', function (_params) {
vc.component.deleteMarketRuleInfo = _params;
$('#deleteMarketRuleModel').modal('show');
});
},
methods: {
deleteMarketRule: function () {
vc.http.apiPost(
'/marketRule.deleteMarketRule',
JSON.stringify(vc.component.deleteMarketRuleInfo),
{
emulateJSON: true
},
function (json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
if (_json.code == 0) {
//关闭model
$('#deleteMarketRuleModel').modal('hide');
vc.emit('marketRuleManage', 'listMarketRule', {});
return;
}
vc.message(_json.msg);
},
function (errInfo, error) {
console.log('请求失败处理');
vc.message(json);
});
},
closeDeleteMarketRuleModel: function () {
$('#deleteMarketRuleModel').modal('hide');
}
}
});
})(window.vc, window.vc.component);

View File

@ -0,0 +1,47 @@
<div id="editMarketRuleModel" class="modal fade" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body">
<h3 class="m-t-none m-b "><span>
<vc:i18n name="修改" namespace="editMarketRule"></vc:i18n>
</span></h3>
<div class="ibox-content">
<div>
<div>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><span>
<vc:i18n name='名称' namespace='editMarketRule'></vc:i18n>
</span> </label>
<div class="col-sm-10">
<input v-model="editMarketRuleInfo.name" type="text"
:placeholder="vc.i18n('必填,请填写名称','editMarketRule')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><span>
<vc:i18n name='备注' namespace='editMarketRule'></vc:i18n>
</span> </label>
<div class="col-sm-10">
<textarea v-model="editMarketRuleInfo.remark"
:placeholder="vc.i18n('必填,请填写备注','editMarketRule')" class="form-control"></textarea>
</div>
</div>
<div class="ibox-content">
<button class="btn btn-primary float-right" type="button"
v-on:click="editMarketRule()"><i class="fa fa-check"></i>&nbsp;<span>
<vc:i18n name="保存"></vc:i18n>
</span></button>
<button type="button" class="btn btn-warning float-right" style="margin-right:20px;"
data-dismiss="modal"><span>
<vc:i18n name="取消"></vc:i18n>
</span></button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,100 @@
(function (vc, vm) {
vc.extends({
data: {
editMarketRuleInfo: {
ruleId: '',
name: '',
remark: '',
}
},
_initMethod: function () {
},
_initEvent: function () {
vc.on('editMarketRule', 'openEditMarketRuleModal', function (_params) {
vc.component.refreshEditMarketRuleInfo();
$('#editMarketRuleModel').modal('show');
vc.copyObject(_params, vc.component.editMarketRuleInfo);
});
},
methods: {
editMarketRuleValidate: function () {
return vc.validate.validate({
editMarketRuleInfo: vc.component.editMarketRuleInfo
}, {
'editMarketRuleInfo.name': [
{
limit: "required",
param: "",
errInfo: "名称不能为空"
},
{
limit: "maxLength",
param: "64",
errInfo: "名称不能超过64"
},
],
'editMarketRuleInfo.remark': [
{
limit: "required",
param: "",
errInfo: "备注'不能为空"
},
{
limit: "maxLength",
param: "512",
errInfo: "备注'不能超过512"
},
],
'editMarketRuleInfo.ruleId': [
{
limit: "required",
param: "",
errInfo: "编号不能为空"
}]
});
},
editMarketRule: function () {
if (!vc.component.editMarketRuleValidate()) {
vc.toast(vc.validate.errInfo);
return;
}
vc.http.apiPost(
'/marketRule.updateMarketRule',
JSON.stringify(vc.component.editMarketRuleInfo),
{
emulateJSON: true
},
function (json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
if (_json.code == 0) {
//关闭model
$('#editMarketRuleModel').modal('hide');
vc.emit('marketRuleManage', 'listMarketRule', {});
return;
}
vc.toast(_json.msg);
},
function (errInfo, error) {
console.log('请求失败处理');
vc.toast(errInfo);
});
},
refreshEditMarketRuleInfo: function () {
vc.component.editMarketRuleInfo = {
ruleId: '',
name: '',
remark: '',
}
}
}
});
})(window.vc, window.vc.component);

View File

@ -0,0 +1,23 @@
<div class="bg-white margin-top-xs padding border-radius">
<div class=" ">
<button type="button" class="btn btn-white btn-sm" v-on:click="_openAddMarketRuleModal()">
添加
</button>
<button type="button" class="btn btn-white btn-sm" v-on:click="_openEditMarketRuleModel()">
修改
</button>
<button type="button" class="btn btn-white btn-sm" v-on:click="_openDeleteMarketRuleModel()" >
删除
</button>
</div>
<div class="vc-org margin-top">
<ul>
<li v-for="(rule,index) in marketRuleDivInfo.marketRules" @click="_switchMarketRule(rule)"
:class="{'active':rule.ruleId == marketRuleDivInfo.curMarketRule.ruleId}">{{rule.name}}
</li>
</ul>
</div>
<vc:create path="admin/addMarketRule" callBackListener="" callBackFunction=""></vc:create>
<vc:create path="admin/editMarketRule"></vc:create>
<vc:create path="admin/deleteMarketRule"></vc:create>
</div>

View File

@ -0,0 +1,70 @@
/**
入驻小区
**/
(function (vc) {
vc.extends({
data: {
marketRuleDivInfo: {
marketRules: [],
ruleId: '',
curMarketRule: {}
}
},
_initMethod: function () {
$that._listMarketRules();
},
_initEvent: function () {
vc.on('marketRuleManage', 'listMarketRule', function (_param) {
$that._listMarketRules();
});
},
methods: {
_listMarketRules: function () {
let param = {
params: {
page:1,
row:100
}
};
//发送get请求
vc.http.apiGet('/marketRule.listMarketRule',
param,
function (json, res) {
let _marketRuleManageInfo = JSON.parse(json);
$that.marketRuleDivInfo.total = _marketRuleManageInfo.total;
$that.marketRuleDivInfo.records = _marketRuleManageInfo.records;
$that.marketRuleDivInfo.marketRules = _marketRuleManageInfo.data;
if($that.marketRuleDivInfo.marketRules && $that.marketRuleDivInfo.marketRules.length>0){
$that._switchMarketRule($that.marketRuleDivInfo.marketRules[0])
}
}, function (errInfo, error) {
console.log('请求失败处理');
}
);
},
_openAddMarketRuleModal: function () {
vc.emit('addMarketRule', 'openAddMarketRuleModal', {});
},
_openEditMarketRuleModel: function () {
if (!$that.marketRuleDivInfo.curMarketRule) {
vc.toast('未选择营销规则');
return;
}
vc.emit('editMarketRule', 'openEditMarketRuleModal', $that.marketRuleDivInfo.curMarketRule);
},
_openDeleteMarketRuleModel: function () {
if (!$that.marketRuleDivInfo.curMarketRule) {
vc.toast('未选择营销规则');
return;
}
vc.emit('deleteMarketRule', 'openDeleteMarketRuleModal', $that.marketRuleDivInfo.curMarketRule);
},
_switchMarketRule: function (_marketRule) {
$that.marketRuleDivInfo.curMarketRule = _marketRule;
vc.emit('marketRule', 'switchMarketRule', _marketRule);
},
}
});
})(window.vc);

View File

@ -0,0 +1,31 @@
<div>
<div class="row ">
<div class="col-md-2" style="padding-right:0px">
<vc:create path="admin/marketRuleDiv" callBackListener="marketRule"></vc:create>
</div>
<div class="col-md-10 margin-top-xs vc-org-page">
<div class="bg-white border-radius padding">
<h5 class="role-title">{{marketRuleInfo.curMarketRule.name}}</h5>
<div class="role-context ">{{marketRuleInfo.curMarketRule.description}}</div>
<div class="line-x margin-top"></div>
<div class="role-menu flex justify-start">
<div class="item margin-right" :class="{'active':marketRuleInfo.tabName == 'privilege'}" @click="_changeMarketRuleTab('privilege')">营销方式
</div>
<div class="item margin-right" :class="{'active':marketRuleInfo.tabName == 'community'}" @click="_changeMarketRuleTab('community')">小区授权
</div>
<div class="item margin-right" :class="{'active':marketRuleInfo.tabName == 'staff'}" @click="_changeMarketRuleTab('staff')">作用对象
</div>
</div>
<div v-if="marketRuleInfo.tabName == 'privilege' ">
<vc:create path="frame/privilegeTree"></vc:create>
</div>
<div v-if="marketRuleInfo.tabName == 'community' ">
<vc:create path="frame/roleCommunity"></vc:create>
</div>
<div v-if="marketRuleInfo.tabName == 'staff'">
<vc:create path="frame/roleStaff"></vc:create>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,33 @@
(function(vc) {
var DEFAULT_PAGE = 1;
var DEFAULT_ROWS = 10;
vc.extends({
data: {
marketRuleInfo: {
curMarketRule: {},
tabName: 'privilege'
},
},
_initMethod: function() {},
_initEvent: function() {
vc.on('marketRule', 'switchMarketRule', function(_param) {
$that.marketRuleInfo.curMarketRule = _param;
$that._changeMarketRuleTab('privilege');
})
},
methods: {
_changeMarketRuleTab: function(_tabName) {
$that.marketRuleInfo.tabName = _tabName;
if (_tabName == 'privilege') {
vc.emit('privilegeTree', 'loadPrivilege', $that.marketRuleInfo.curMarketRule.ruleId);
}
if (_tabName == 'community') {
vc.emit('roleCommunityInfo', 'openMarketRuleCommunity', { ruleId: $that.marketRuleInfo.curMarketRule.ruleId });
}
if (_tabName == 'staff') {
vc.emit('roleStaffInfo', 'openMarketRuleStaff', { ruleId: $that.marketRuleInfo.curMarketRule.ruleId });
}
}
},
});
})(window.vc);