优化代码

This commit is contained in:
wuxw 2022-11-20 02:00:55 +08:00
parent fec1ab621e
commit 265a753aa0
11 changed files with 763 additions and 0 deletions

BIN
public/.DS_Store vendored

Binary file not shown.

View File

@ -0,0 +1,80 @@
<div id="addCouponPropertyPoolModel" 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="addCouponPropertyPool"></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='addCouponPropertyPool'></vc:i18n>
</span></label>
<div class="col-sm-10">
<input v-model="addCouponPropertyPoolInfo.couponName" type="text"
:placeholder="vc.i18n('必填,请填写优惠券名称','addCouponPropertyPool')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><span>
<vc:i18n name='用途' namespace='addCouponPropertyPool'></vc:i18n>
</span></label>
<div class="col-sm-10">
<select class="custom-select" v-model="addCouponPropertyPoolInfo.toType">
<option selected disabled value="">{{vc.i18n('必填,请选择用途','addCouponPropertyPool')}}</option>
</option>
<option value="1001">{{vc.i18n('购物','addCouponPropertyPool')}}
</option>
<option value="2002">{{vc.i18n('缴费','addCouponPropertyPool')}}
</option>
<option value="3003">{{vc.i18n('维修劵','addCouponPropertyPool')}}
</option>
<option value="4004">{{vc.i18n('停车劵','addCouponPropertyPool')}}
</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><span>
<vc:i18n name='数量' namespace='addCouponPropertyPool'></vc:i18n>
</span></label>
<div class="col-sm-10">
<input v-model="addCouponPropertyPoolInfo.stock" type="text"
:placeholder="vc.i18n('必填,请填写数量','addCouponPropertyPool')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><span>
<vc:i18n name='有效期' namespace=' addCouponPropertyPool'></vc:i18n>
</span></label>
<div class="col-sm-10">
<input v-model="addCouponPropertyPoolInfo.validityDay" type="text"
:placeholder="vc.i18n('必填,请填写有效期','addCouponPropertyPool')" class="form-control">
</div>
</div>
<div class="ibox-content">
<button class="btn btn-primary float-right" type="button" v-on:click="saveCouponPropertyPoolInfo()"><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,147 @@
(function (vc) {
vc.extends({
propTypes: {
callBackListener: vc.propTypes.string, //父组件名称
callBackFunction: vc.propTypes.string //父组件监听方法
},
data: {
addCouponPropertyPoolInfo: {
cppId: '',
couponName: '',
fromType: '2002',
toType: '',
stock: '',
validityDay: '',
}
},
_initMethod: function () {
},
_initEvent: function () {
vc.on('addCouponPropertyPool', 'openAddCouponPropertyPoolModal', function () {
$('#addCouponPropertyPoolModel').modal('show');
});
},
methods: {
addCouponPropertyPoolValidate() {
return vc.validate.validate({
addCouponPropertyPoolInfo: vc.component.addCouponPropertyPoolInfo
}, {
'addCouponPropertyPoolInfo.couponName': [
{
limit: "required",
param: "",
errInfo: "优惠券名称不能为空"
},
{
limit: "maxLength",
param: "64",
errInfo: "优惠券名称不能超过64"
},
],
'addCouponPropertyPoolInfo.fromType': [
{
limit: "required",
param: "",
errInfo: "来自方式不能为空"
},
{
limit: "maxLength",
param: "12",
errInfo: "来自方式不能超过12"
},
],
'addCouponPropertyPoolInfo.toType': [
{
limit: "required",
param: "",
errInfo: "用途不能为空"
},
{
limit: "maxLength",
param: "12",
errInfo: "用途不能超过12"
},
],
'addCouponPropertyPoolInfo.stock': [
{
limit: "required",
param: "",
errInfo: "数量不能为空"
},
{
limit: "maxLength",
param: "12",
errInfo: "数量不能超过12"
},
],
'addCouponPropertyPoolInfo.validityDay': [
{
limit: "required",
param: "",
errInfo: "有效期'不能为空"
},
{
limit: "maxLength",
param: "12",
errInfo: "有效期'不能超过12"
},
],
});
},
saveCouponPropertyPoolInfo: function () {
if (!vc.component.addCouponPropertyPoolValidate()) {
vc.toast(vc.validate.errInfo);
return;
}
vc.component.addCouponPropertyPoolInfo.communityId = vc.getCurrentCommunity().communityId;
vc.http.apiPost(
'/couponProperty.saveCouponPropertyPool',
JSON.stringify(vc.component.addCouponPropertyPoolInfo),
{
emulateJSON: true
},
function (json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
if (_json.code == 0) {
//关闭model
$('#addCouponPropertyPoolModel').modal('hide');
vc.component.clearAddCouponPropertyPoolInfo();
vc.emit('couponPropertyPoolManage', 'listCouponPropertyPool', {});
return;
}
vc.message(_json.msg);
},
function (errInfo, error) {
console.log('请求失败处理');
vc.message(errInfo);
});
},
clearAddCouponPropertyPoolInfo: function () {
vc.component.addCouponPropertyPoolInfo = {
couponName: '',
fromType: '2002',
toType: '',
stock: '',
validityDay: '',
};
}
}
});
})(window.vc);

View File

@ -0,0 +1,19 @@
<div class="modal fade" id="deleteCouponPropertyPoolModel" tabindex="-1" 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="deleteCouponPropertyPool"></vc:i18n></span></th></tr>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" v-on:click="closeDeleteCouponPropertyPoolModel()"><span><vc:i18n name="点错了"></vc:i18n></span></button>
<button type="button" class="btn btn-primary" v-on:click="deleteCouponPropertyPool()"><span><vc:i18n name="确认删除!"></vc:i18n></span></button>
</div>
</div>
</div>
</div>

View File

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

View File

@ -0,0 +1,75 @@
<div id="editCouponPropertyPoolModel" 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="editCouponPropertyPool"></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='editCouponPropertyPool'></vc:i18n>
</span> </label>
<div class="col-sm-10">
<input v-model="editCouponPropertyPoolInfo.couponName" type="text"
:placeholder="vc.i18n('必填,请填写优惠券名称','editCouponPropertyPool')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><span>
<vc:i18n name='用途' namespace='editCouponPropertyPool'></vc:i18n>
</span> </label>
<div class="col-sm-10">
<select class="custom-select" v-model="editCouponPropertyPoolInfo.toType">
<option selected disabled value="">{{vc.i18n('必填,请选择用途','editCouponPropertyPool')}}</option>
</option>
<option value="1001">{{vc.i18n('购物','editCouponPropertyPool')}}
</option>
<option value="2002">{{vc.i18n('缴费','editCouponPropertyPool')}}
</option>
<option value="3003">{{vc.i18n('维修劵','editCouponPropertyPool')}}
</option>
<option value="4004">{{vc.i18n('停车劵','editCouponPropertyPool')}}
</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><span>
<vc:i18n name='数量' namespace='editCouponPropertyPool'></vc:i18n>
</span> </label>
<div class="col-sm-10">
<input v-model="editCouponPropertyPoolInfo.stock" type="text"
:placeholder="vc.i18n('必填,请填写数量','editCouponPropertyPool')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><span>
<vc:i18n name='有效期' namespace='editCouponPropertyPool'></vc:i18n>
</span> </label>
<div class="col-sm-10">
<input v-model="editCouponPropertyPoolInfo.validityDay" type="text"
:placeholder="vc.i18n('必填,请填写有效期','editCouponPropertyPool')" class="form-control">
</div>
</div>
<div class="ibox-content">
<button class="btn btn-primary float-right" type="button" v-on:click="editCouponPropertyPool()"><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,143 @@
(function (vc, vm) {
vc.extends({
data: {
editCouponPropertyPoolInfo: {
cppId: '',
couponName: '',
fromType: '2002',
toType: '',
stock: '',
validityDay: '',
}
},
_initMethod: function () {
},
_initEvent: function () {
vc.on('editCouponPropertyPool', 'openEditCouponPropertyPoolModal', function (_params) {
vc.component.refreshEditCouponPropertyPoolInfo();
$('#editCouponPropertyPoolModel').modal('show');
vc.copyObject(_params, vc.component.editCouponPropertyPoolInfo);
vc.component.editCouponPropertyPoolInfo.communityId = vc.getCurrentCommunity().communityId;
});
},
methods: {
editCouponPropertyPoolValidate: function () {
return vc.validate.validate({
editCouponPropertyPoolInfo: vc.component.editCouponPropertyPoolInfo
}, {
'editCouponPropertyPoolInfo.couponName': [
{
limit: "required",
param: "",
errInfo: "优惠券名称不能为空"
},
{
limit: "maxLength",
param: "64",
errInfo: "优惠券名称不能超过64"
},
],
'editCouponPropertyPoolInfo.fromType': [
{
limit: "required",
param: "",
errInfo: "来自方式不能为空"
},
{
limit: "maxLength",
param: "12",
errInfo: "来自方式不能超过12"
},
],
'editCouponPropertyPoolInfo.toType': [
{
limit: "required",
param: "",
errInfo: "用途不能为空"
},
{
limit: "maxLength",
param: "12",
errInfo: "用途不能超过12"
},
],
'editCouponPropertyPoolInfo.stock': [
{
limit: "required",
param: "",
errInfo: "数量不能为空"
},
{
limit: "maxLength",
param: "12",
errInfo: "数量不能超过12"
},
],
'editCouponPropertyPoolInfo.validityDay': [
{
limit: "required",
param: "",
errInfo: "有效期'不能为空"
},
{
limit: "maxLength",
param: "12",
errInfo: "有效期'不能超过12"
},
],
'editCouponPropertyPoolInfo.cppId': [
{
limit: "required",
param: "",
errInfo: "编号不能为空"
}]
});
},
editCouponPropertyPool: function () {
if (!vc.component.editCouponPropertyPoolValidate()) {
vc.toast(vc.validate.errInfo);
return;
}
vc.http.apiPost(
'/couponProperty.updateCouponPropertyPool',
JSON.stringify(vc.component.editCouponPropertyPoolInfo),
{
emulateJSON: true
},
function (json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
if (_json.code == 0) {
//关闭model
$('#editCouponPropertyPoolModel').modal('hide');
vc.emit('couponPropertyPoolManage', 'listCouponPropertyPool', {});
return;
}
vc.message(_json.msg);
},
function (errInfo, error) {
console.log('请求失败处理');
vc.message(errInfo);
});
},
refreshEditCouponPropertyPoolInfo: function () {
vc.component.editCouponPropertyPoolInfo = {
cppId: '',
couponName: '',
fromType: '2002',
toType: '',
stock: '',
validityDay: '',
}
}
}
});
})(window.vc, window.vc.component);

BIN
public/pages/.DS_Store vendored

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,161 @@
<div>
<div class="row">
<div class="col-lg-12">
<div class="ibox ">
<div class="ibox-title">
<h5><span>
<vc:i18n name="查询条件"></vc:i18n>
</span></h5>
<div class="ibox-tools" style="top:10px;">
<button type="button" class="btn btn-link btn-sm" style="margin-right:10px;"
v-on:click="_moreCondition()">{{couponPropertyPoolManageInfo.moreCondition ==
true?'隐藏':'更多'}}</button>
</div>
</div>
<div class="ibox-content">
<div class="row">
<div class="col-sm-4">
<div class="form-group">
<input type="text" :placeholder="vc.i18n('请选择优惠券编号','couponPropertyPoolManage')"
v-model="couponPropertyPoolManageInfo.conditions.cppId" class=" form-control">
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<input type="text" :placeholder="vc.i18n('请选择优惠券名称','couponPropertyPoolManage')"
v-model="couponPropertyPoolManageInfo.conditions.couponName" class=" form-control">
</div>
</div>
<div class="col-sm-3">
<select class="custom-select" v-model="couponPropertyPoolManageInfo.conditions.fromType">
<option selected value="">
{{vc.i18n('请选择来自方式','couponPropertyPoolManage')}}
</option>
<option value="1001"> {{vc.i18n('优惠券市场购买','couponPropertyPoolManage')}}
</option>
<option value="2002">{{vc.i18n('自己制作','couponPropertyPoolManage')}}
</option>
</select>
</div>
<div class="col-sm-1">
<button type="button" class="btn btn-primary btn-sm"
v-on:click="_queryCouponPropertyPoolMethod()">
<i class="glyphicon glyphicon-search"></i> <span>
<vc:i18n name="查询"></vc:i18n>
</span>
</button>
</div>
</div>
<div class="row">
<div class="col-sm-4" v-if="couponPropertyPoolManageInfo.moreCondition == true">
<select class="custom-select" v-model="couponPropertyPoolManageInfo.conditions.toType">
<option selected value="">{{vc.i18n('选择用途','couponPropertyPoolManage')}}
</option>
<option value="1001">{{vc.i18n('购物','couponPropertyPoolManage')}}
</option>
<option value="2002">{{vc.i18n('缴费','couponPropertyPoolManage')}}
</option>
<option value="3003">{{vc.i18n('维修劵','couponPropertyPoolManage')}}
</option>
<option value="4004">{{vc.i18n('停车劵','couponPropertyPoolManage')}}
</option>
</select>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="ibox">
<div class="ibox-title">
<h5><span>
<vc:i18n name="优惠券" namespace="couponPropertyPoolManage"></vc:i18n>
</span></h5>
<div class="ibox-tools" style="top:10px;">
<button type="button" class="btn btn-primary btn-sm"
v-on:click="_openAddCouponPropertyPoolModal()">
<span>
<vc:i18n name="制作" namespace="couponPropertyPoolManage"></vc:i18n>
</span>
</button>
</div>
</div>
<div class="ibox-content">
<table class="footable table table-stripped toggle-arrow-tiny" data-page-size="15">
<thead>
<tr>
<th class="text-center"><span>
<vc:i18n name='编号' namespace='couponPropertyPoolManage'></vc:i18n>
</span></th>
<th class="text-center"><span>
<vc:i18n name='优惠券名称' namespace='couponPropertyPoolManage'></vc:i18n>
</span></th>
<th class="text-center"><span>
<vc:i18n name='来自方式' namespace='couponPropertyPoolManage'></vc:i18n>
</span></th>
<th class="text-center"><span>
<vc:i18n name='用途' namespace='couponPropertyPoolManage'></vc:i18n>
</span></th>
<th class="text-center"><span>
<vc:i18n name='数量' namespace='couponPropertyPoolManage'></vc:i18n>
</span></th>
<th class="text-center"><span>
<vc:i18n name='有效期' namespace=' couponPropertyPoolManage'></vc:i18n>
</span></th>
<th class="text-center"><span>
<vc:i18n name='操作'></vc:i18n>
</span></th>
</tr>
</thead>
<tbody>
<tr v-for="couponPropertyPool in couponPropertyPoolManageInfo.couponPropertyPools">
<td class="text-center">{{couponPropertyPool.cppId}}</td>
<td class="text-center">{{couponPropertyPool.couponName}}</td>
<td class="text-center">{{couponPropertyPool.fromType}}</td>
<td class="text-center">{{couponPropertyPool.toType}}</td>
<td class="text-center">{{couponPropertyPool.stock}}</td>
<td class="text-center">{{couponPropertyPool.validityDay}}</td>
<td class="text-center">
<div class="btn-group" v-if="couponPropertyPool.fromType == '2002'">
<button class="btn-white btn btn-xs"
v-on:click="_openEditCouponPropertyPoolModel(couponPropertyPool)"><span>
<vc:i18n name='修改'></vc:i18n>
</span></button>
</div>
<div class="btn-group" v-if="couponPropertyPool.fromType == '2002'">
<button class="btn-white btn btn-xs"
v-on:click="_openDeleteCouponPropertyPoolModel(couponPropertyPool)"><span>
<vc:i18n name='删除'></vc:i18n>
</span></button>
</div>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="7">
<ul class="pagination float-right"></ul>
</td>
</tr>
</tfoot>
</table>
<!-- 分页 -->
<vc:create path="frame/pagination"></vc:create>
</div>
</div>
</div>
</div>
<vc:create path="scm/addCouponPropertyPool" callBackListener="" callBackFunction=""></vc:create>
<vc:create path="scm/editCouponPropertyPool"></vc:create>
<vc:create path="scm/deleteCouponPropertyPool"></vc:create>
</div>

View File

@ -0,0 +1,86 @@
/**
入驻小区
**/
(function (vc) {
var DEFAULT_PAGE = 1;
var DEFAULT_ROWS = 10;
vc.extends({
data: {
couponPropertyPoolManageInfo: {
couponPropertyPools: [],
total: 0,
records: 1,
moreCondition: false,
cppId: '',
conditions: {
cppId: '',
couponName: '',
fromType: '',
toType: '',
communityId:vc.getCurrentCommunity().communityId
}
}
},
_initMethod: function () {
vc.component._listCouponPropertyPools(DEFAULT_PAGE, DEFAULT_ROWS);
},
_initEvent: function () {
vc.on('couponPropertyPoolManage', 'listCouponPropertyPool', function (_param) {
vc.component._listCouponPropertyPools(DEFAULT_PAGE, DEFAULT_ROWS);
});
vc.on('pagination', 'page_event', function (_currentPage) {
vc.component._listCouponPropertyPools(_currentPage, DEFAULT_ROWS);
});
},
methods: {
_listCouponPropertyPools: function (_page, _rows) {
vc.component.couponPropertyPoolManageInfo.conditions.page = _page;
vc.component.couponPropertyPoolManageInfo.conditions.row = _rows;
var param = {
params: vc.component.couponPropertyPoolManageInfo.conditions
};
//发送get请求
vc.http.apiGet('/couponProperty.listCouponPropertyPool',
param,
function (json, res) {
var _couponPropertyPoolManageInfo = JSON.parse(json);
vc.component.couponPropertyPoolManageInfo.total = _couponPropertyPoolManageInfo.total;
vc.component.couponPropertyPoolManageInfo.records = _couponPropertyPoolManageInfo.records;
vc.component.couponPropertyPoolManageInfo.couponPropertyPools = _couponPropertyPoolManageInfo.data;
vc.emit('pagination', 'init', {
total: vc.component.couponPropertyPoolManageInfo.records,
currentPage: _page
});
}, function (errInfo, error) {
console.log('请求失败处理');
}
);
},
_openAddCouponPropertyPoolModal: function () {
vc.emit('addCouponPropertyPool', 'openAddCouponPropertyPoolModal', {});
},
_openEditCouponPropertyPoolModel: function (_couponPropertyPool) {
vc.emit('editCouponPropertyPool', 'openEditCouponPropertyPoolModal', _couponPropertyPool);
},
_openDeleteCouponPropertyPoolModel: function (_couponPropertyPool) {
vc.emit('deleteCouponPropertyPool', 'openDeleteCouponPropertyPoolModal', _couponPropertyPool);
},
_queryCouponPropertyPoolMethod: function () {
vc.component._listCouponPropertyPools(DEFAULT_PAGE, DEFAULT_ROWS);
},
_moreCondition: function () {
if (vc.component.couponPropertyPoolManageInfo.moreCondition) {
vc.component.couponPropertyPoolManageInfo.moreCondition = false;
} else {
vc.component.couponPropertyPoolManageInfo.moreCondition = true;
}
}
}
});
})(window.vc);