优化代码

This commit is contained in:
Your Name 2023-09-20 02:10:15 +08:00
parent eaacd699ad
commit 871122e721
3 changed files with 169 additions and 101 deletions

View File

@ -1,101 +1,126 @@
<div>
<div class="row">
<div class="col-lg-12">
<div class="ibox ">
<div class="ibox-title">
<h5>
<vc:i18n name="查询条件" namespace="userLogin"></vc:i18n>
</h5>
<div class="ibox-tools" style="top:10px;">
</div>
<div class="col-md-2 padding-r-0">
<div class=" border-radius ">
<div class="margin-xs-r treeview attendance-staff">
<ul class="list-group text-center border-radius">
<!-- -->
<li class="list-group-item node-orgTree " v-for="(item,index) in userLoginInfo.stores"
:key="index" @click="swatchStore(item)"
:class="{'vc-node-selected':userLoginInfo.conditions.storeId == item.storeId}">
{{item.name}}<span v-if="item.storeTypeName">({{item.storeTypeName}})</span>
</li>
</ul>
</div>
<div class="ibox-content">
<div class="row">
</div>
</div>
<div class="col-md-10">
<div class="row">
<div class="col-lg-12">
<div class="ibox ">
<div class="ibox-title">
<h5>
<vc:i18n name="查询条件" namespace="userLogin"></vc:i18n>
</h5>
<div class="ibox-tools" style="top:10px;">
<div class="col-sm-3">
<div class="form-group">
<input type="text" :placeholder="vc.i18n('请输入员工名称','userLogin')"
v-model="userLoginInfo.conditions.name" class=" form-control">
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<input type="number" :placeholder="vc.i18n('请输入手机号','userLogin')"
v-model="userLoginInfo.conditions.tel" class=" form-control">
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<input type="number" :placeholder="vc.i18n('请输入员工ID','userLogin')"
v-model="userLoginInfo.conditions.userLoginId" class=" form-control">
</div>
</div>
<div class="ibox-content">
<div class="row">
<div class="col-sm-1">
<button type="button" class="btn btn-primary btn-sm" v-on:click="_queryUserLoginMethod()">
<i class="fa fa-search"></i> <span>
<vc:i18n name="查询" namespace="userLogin"></vc:i18n>
</span>
</button>
<div class="col-sm-2">
<div class="form-group">
<input type="text" :placeholder="vc.i18n('请输入员工名称','userLogin')"
v-model="userLoginInfo.conditions.name" class=" form-control">
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<input type="number" :placeholder="vc.i18n('请输入手机号','userLogin')"
v-model="userLoginInfo.conditions.tel" class=" form-control">
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<input type="text" placeholder="登录开始时间"
v-model="userLoginInfo.conditions.startTime"
class=" form-control startTime">
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<input type="text" placeholder="登录结束时间"
v-model="userLoginInfo.conditions.endTime" class=" form-control endTime">
</div>
</div>
<div class="col-sm-1">
<button type="button" class="btn btn-primary btn-sm"
v-on:click="_queryUserLoginMethod()">
<i class="fa fa-search"></i> <span>
<vc:i18n name="查询" namespace="userLogin"></vc:i18n>
</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="ibox ">
<div class="ibox-title">
<h5>
<vc:i18n name="登录日志" namespace="userLogin"></vc:i18n>
</h5>
<div class="ibox-tools" style="top:10px;">
<div class="row">
<div class="col-lg-12">
<div class="ibox ">
<div class="ibox-title">
<h5>
<vc:i18n name="登录日志" namespace="userLogin"></vc:i18n>
</h5>
<div class="ibox-tools" style="top:10px;">
</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">
<vc:i18n name="登录ID" namespace="userLogin"></vc:i18n>
</th>
<th class="text-center">
<vc:i18n name="公司" namespace="userLogin"></vc:i18n>
</th>
<th class="text-center">
<vc:i18n name="部门" namespace="userLogin"></vc:i18n>
</th>
<th class="text-center">
<vc:i18n name="名称" namespace="userLogin"></vc:i18n>
</th>
<th class="text-center">
<vc:i18n name="登录时间" namespace="userLogin"></vc:i18n>
</th>
<th class="text-center">
<vc:i18n name="员工ID" namespace="userLogin"></vc:i18n>
</th>
</tr>
</thead>
<tbody>
<tr class="gradeX" v-for="userLogin in userLoginInfo.logs">
<td class="text-center">{{userLogin.loginId}}</td>
<td class="text-center">{{userLogin.parentOrgName || '-'}}</td>
<td class="text-center">{{userLogin.orgName}}</td>
<td class="text-center">{{userLogin.userName}}</td>
<td class="text-center">{{userLogin.loginTime}}</td>
<td class="text-center">{{userLogin.userId}}</td>
</tr>
</tbody>
</table>
<!-- 分页 -->
<vc:create path="frame/pagination"></vc:create>
</div>
</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">
<vc:i18n name="登录ID" namespace="userLogin"></vc:i18n>
</th>
<th class="text-center">
<vc:i18n name="公司" namespace="userLogin"></vc:i18n>
</th >
<th class="text-center">
<vc:i18n name="部门" namespace="userLogin"></vc:i18n>
</th>
<th class="text-center">
<vc:i18n name="名称" namespace="userLogin"></vc:i18n>
</th>
<th class="text-center">
<vc:i18n name="登录时间" namespace="userLogin"></vc:i18n>
</th>
<th class="text-center">
<vc:i18n name="员工ID" namespace="userLogin"></vc:i18n>
</th>
</tr>
</thead>
<tbody>
<tr class="gradeX" v-for="userLogin in userLoginInfo.logs">
<td class="text-center">{{userLogin.loginId}}</td>
<td class="text-center">{{userLogin.parentOrgName || '-'}}</td>
<td class="text-center">{{userLogin.orgName}}</td>
<td class="text-center">{{userLogin.userName}}</td>
<td class="text-center">{{userLogin.loginTime}}</td>
<td class="text-center">{{userLogin.userId}}</td>
</tr>
</tbody>
</table>
<!-- 分页 -->
<vc:create path="frame/pagination"></vc:create>
</div>
</div>
</div>
</div>

View File

@ -6,15 +6,27 @@
userLoginInfo: {
moreCondition: false,
logs: [],
stores:[],
conditions: {
name: '',
tel: '',
userLoginId: ''
userLoginId: '',
storeId:'',
startTime:'',
endTime:''
}
},
},
_initMethod: function () {
$that.loadData(1, 10);
$that.loadData(1, DEFAULT_ROWS);
$that._listListStores();
vc.initDateTime('startTime',function(_value){
$that.userLoginInfo.conditions.startTime = _value;
});
vc.initDateTime('endTime',function(_value){
$that.userLoginInfo.conditions.endTime = _value;
})
},
_initEvent: function () {
@ -60,9 +72,40 @@
},
_queryuserLoginMethod: function () {
_queryUserLoginMethod: function () {
$that.loadData(DEFAULT_PAGE, DEFAULT_ROWS)
}
},
_listListStores: function (_page, _rows) {
let param = {
params: {
page:1,
row:100
}
};
$that.userLoginInfo.stores = [{
storeId: '',
name: '全部'
}];
//发送get请求
vc.http.apiGet('/store.listStores',
param,
function (json, res) {
let _json = JSON.parse(json);
_json.data.forEach(item => {
$that.userLoginInfo.stores.push(item);
});
}, function (errInfo, error) {
console.log('请求失败处理');
}
);
},
swatchStore:function(_app){
$that.userLoginInfo.conditions.storeId = _app.storeId;
$that.loadData(1, DEFAULT_ROWS);
},
},

View File

@ -19,23 +19,23 @@
}
},
_initMethod: function () {
vc.component._listListStores(DEFAULT_PAGE, DEFAULT_ROWS);
$that._listListStores(DEFAULT_PAGE, DEFAULT_ROWS);
},
_initEvent: function () {
vc.on('listStoreManage', 'listListStore', function (_param) {
vc.component._listListStores(DEFAULT_PAGE, DEFAULT_ROWS);
$that._listListStores(DEFAULT_PAGE, DEFAULT_ROWS);
});
vc.on('pagination', 'page_event', function (_currentPage) {
vc.component._listListStores(_currentPage, DEFAULT_ROWS);
$that._listListStores(_currentPage, DEFAULT_ROWS);
});
},
methods: {
_listListStores: function (_page, _rows) {
vc.component.listStoreManageInfo.conditions.page = _page;
vc.component.listStoreManageInfo.conditions.row = _rows;
$that.listStoreManageInfo.conditions.page = _page;
$that.listStoreManageInfo.conditions.row = _rows;
var param = {
params: vc.component.listStoreManageInfo.conditions
params: $that.listStoreManageInfo.conditions
};
//发送get请求
@ -43,12 +43,12 @@
param,
function (json, res) {
var _listStoreManageInfo = JSON.parse(json);
vc.component.listStoreManageInfo.total = _listStoreManageInfo.total;
vc.component.listStoreManageInfo.records = _listStoreManageInfo.records;
vc.component.listStoreManageInfo.listStores = _listStoreManageInfo.data;
$that.listStoreManageInfo.total = _listStoreManageInfo.total;
$that.listStoreManageInfo.records = _listStoreManageInfo.records;
$that.listStoreManageInfo.listStores = _listStoreManageInfo.data;
vc.emit('pagination', 'init', {
total: vc.component.listStoreManageInfo.records,
dataCount: vc.component.listStoreManageInfo.total,
total: $that.listStoreManageInfo.records,
dataCount: $that.listStoreManageInfo.total,
currentPage: _page
});
}, function (errInfo, error) {
@ -60,14 +60,14 @@
vc.emit('storesCommunity','openStoresCommunity', _listStore);
},
_queryListStoreMethod: function () {
vc.component._listListStores(DEFAULT_PAGE, DEFAULT_ROWS);
$that._listListStores(DEFAULT_PAGE, DEFAULT_ROWS);
},
_moreCondition: function () {
if (vc.component.listStoreManageInfo.moreCondition) {
vc.component.listStoreManageInfo.moreCondition = false;
if ($that.listStoreManageInfo.moreCondition) {
$that.listStoreManageInfo.moreCondition = false;
} else {
vc.component.listStoreManageInfo.moreCondition = true;
$that.listStoreManageInfo.moreCondition = true;
}
}