优化代码

This commit is contained in:
java110 2021-04-08 01:58:34 +08:00
parent c2fdd194fe
commit 74e3dca1a6
7 changed files with 247 additions and 101 deletions

View File

@ -200,7 +200,8 @@
params: {
page: 1,
row: 100,
shType: '2806'
shType: '2806',
communityId:vc.getCurrentCommunity().communityId
}
};

View File

@ -31,10 +31,10 @@
<div class="form-group row">
<label class="col-sm-2 col-form-label">目标仓库</label>
<div class="col-sm-10">
<select class="custom-select" v-model="allocationStorehouseInfo.shId">
<select class="custom-select" v-model="allocationStorehouseInfo.shIdz">
<option selected disabled value="">必填,请选择仓库</option>
<option v-for="(item,index) in allocationStorehouseInfo.storehouses"
:key="index" v-bind:value="item.shId" v-if="item.shId != allocationStorehouseInfo.curShId">
:key="index" v-bind:value="item.shId" v-if="item.shId != allocationStorehouseInfo.shIda">
{{item.shName}}
</option>
</select>
@ -50,7 +50,7 @@
<div class="form-group row">
<label class="col-sm-2 col-form-label">备注</label>
<div class="col-sm-10">
<textarea placeholder="填,请填写备注" class="form-control"
<textarea placeholder="填,请填写备注" class="form-control"
v-model="allocationStorehouseInfo.remark">
</textarea>
</div>

View File

@ -6,11 +6,11 @@
resName: '',
resCode: '',
remark: '',
stock:0,
curStock:0,
shId: '',
curShId:'',
shName:'',
stock: 0,
curStock: 0,
shIdz: '',
shIda: '',
shName: '',
storehouses: []
}
},
@ -25,7 +25,7 @@
_that.resName = _param.resName;
_that.curStock = _param.stock;
_that.shName = _param.shName;
_that.curShId = _param.shId;
_that.shIda = _param.shId;
$('#allocationStorehouseModel').modal('show');
});
},
@ -34,114 +34,59 @@
return vc.validate.validate({
allocationStorehouseInfo: vc.component.allocationStorehouseInfo
}, {
'allocationStorehouseInfo.resName': [
'allocationStorehouseInfo.resId': [
{
limit: "required",
param: "",
errInfo: "物品名称不能为空"
},
{
limit: "maxin",
param: "2,100",
errInfo: "物品名称长度为2至100"
},
}
],
'allocationStorehouseInfo.resCode': [
'allocationStorehouseInfo.remark': [
{
limit: "required",
param: "",
errInfo: "备注不能为空"
},
{
limit: "maxLength",
param: "50",
errInfo: "物品编码不能超过50位"
},
param: "512",
errInfo: "备注太长"
}
],
'allocationStorehouseInfo.price': [
'allocationStorehouseInfo.stock': [
{
limit: "required",
param: "",
errInfo: "物品价格不能为空"
errInfo: "调拨数量不能为空"
},
{
limit: "money",
limit: "num",
param: "",
errInfo: "物品价格格式错误"
errInfo: "调拨数量必须为正整数"
},
],
'allocationStorehouseInfo.description': [
{
limit: "maxLength",
param: "200",
errInfo: "描述不能为空"
},
],
'allocationStorehouseInfo.showMobile': [
'allocationStorehouseInfo.shIdz': [
{
limit: "required",
param: "",
errInfo: "手机端显示不能为空"
},
],
'allocationStorehouseInfo.outLowPrice': [
{
limit: "required",
param: "",
errInfo: "最低收费标准不能为空"
},
{
limit: "money",
param: "",
errInfo: "收费标准格式错误"
},
],
'allocationStorehouseInfo.outHighPrice': [
{
limit: "required",
param: "",
errInfo: "最高收费标准不能为空"
},
{
limit: "money",
param: "",
errInfo: "收费标准格式错误"
},
],
'allocationStorehouseInfo.unitCode': [
{
limit: "required",
param: "",
errInfo: "单位不能为空"
},
],
'allocationStorehouseInfo.goodsType': [
{
limit: "required",
param: "",
errInfo: "物品类型不能为空"
},
],
'allocationStorehouseInfo.shId': [
{
limit: "required",
param: "",
errInfo: "仓库不能为空"
},
],
errInfo: "目标仓库不能为空"
}
]
});
},
saveResourceStoreInfo: function () {
if (!vc.component.allocationStorehouseValidate()) {
_allocationStorehouse: function () {
if (!$that.allocationStorehouseValidate()) {
vc.toast(vc.validate.errInfo);
return;
}
vc.component.allocationStorehouseInfo.communityId = vc.getCurrentCommunity().communityId;
vc.http.post(
'allocationStorehouse',
'save',
$that.allocationStorehouseInfo.communityId = vc.getCurrentCommunity().communityId;
vc.http.apiPost(
'resourceStore.saveAllocationStorehouse',
JSON.stringify(vc.component.allocationStorehouseInfo),
{
emulateJSON: true
},
function (json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
if (res.status == 200) {
//关闭model
$('#allocationStorehouseModel').modal('hide');
@ -158,24 +103,19 @@
},
clearAllocationStorehouseInfo: function () {
vc.component.allocationStorehouseInfo = {
resId: '',
resName: '',
resCode: '',
price: '',
description: '',
outLowPrice: '',
outHighPrice: '',
showMobile: '',
remark: '',
goodsType: '',
goodsTypes: [],
unitCode: '',
shId: '',
unitCodes: [],
stock: 0,
curStock: 0,
shIdz: '',
shIda: '',
shName: '',
storehouses: []
};
},
_listAllocationStorehouse: function (_page, _rows) {
var param = {
params: {
page: 1,

View File

@ -0,0 +1,106 @@
<div class="animated fadeInRight ecommerce">
<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-3">
<div class="form-group">
<select class="custom-select" v-model="allocationStorehouseManageInfo.conditions.shId">
<option selected disabled value="">必填,请选择目标仓库</option>
<option v-for="(item,index) in allocationStorehouseManageInfo.storehouses"
:key="index" v-bind:value="item.shId">
{{item.shName}}
</option>
</select>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<input type="text" placeholder="请输入物品名称"
v-model="allocationStorehouseManageInfo.conditions.resName" class=" form-control">
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
<input type="text" placeholder="请输入物品编码"
v-model="allocationStorehouseManageInfo.conditions.resCode" class=" form-control">
</div>
</div>
<div class="col-sm-2">
<button type="button" class="btn btn-primary btn-sm"
v-on:click="_queryAllocationStorehouseMethod()">
<i class="fa fa-search"></i> 查询
</button>
</div>
</div>
</div>
</div>
</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">
<table class="footable table table-stripped toggle-arrow-tiny" data-page-size="15">
<thead>
<tr>
<th class="text-center">物品ID</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>
<th class="text-center">申请说明</th>
<th class="text-center">操作</th>
</tr>
</thead>
<tbody>
<tr v-for="resourceStore in allocationStorehouseManageInfo.resourceStores">
<td class="text-center">{{resourceStore.resId}}</td>
<td class="text-center">{{resourceStore.resName}}</td>
<td class="text-center">{{resourceStore.shaName}}</td>
<td class="text-center">{{resourceStore.shzName}}</td>
<td class="text-center">{{resourceStore.stock}}</td>
<td class="text-center">{{resourceStore.startUserName}}</td>
<td class="text-center">{{resourceStore.stateName}}</td>
<td class="text-center">{{resourceStore.remark}}</td>
<td class="text-center">
<div class="btn-group">
<button class="btn-white btn btn-xs"
v-on:click="_openDeleteResourceStoreModel(resourceStore)">取消调拨
</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="common/allocationStorehouse"></vc:create>
</div>

View File

@ -0,0 +1,97 @@
/**
入驻小区
**/
(function (vc) {
var DEFAULT_PAGE = 1;
var DEFAULT_ROWS = 10;
vc.extends({
data: {
allocationStorehouseManageInfo: {
resourceStores: [],
total: 0,
records: 1,
moreCondition: false,
resName: '',
conditions: {
resId: '',
resName: '',
resCode: '',
shId: ''
},
storehouses: []
}
},
_initMethod: function () {
vc.component._listAllocationStorehouses(DEFAULT_PAGE, DEFAULT_ROWS);
$that._listStorehouses();
},
_initEvent: function () {
vc.on('allocationStorehouse', 'listAllocationStorehouse', function (_param) {
vc.component._listAllocationStorehouses(DEFAULT_PAGE, DEFAULT_ROWS);
});
vc.on('pagination', 'page_event', function (_currentPage) {
vc.component._listAllocationStorehouses(_currentPage, DEFAULT_ROWS);
});
},
methods: {
//查询方法
_listAllocationStorehouses: function (_page, _rows) {
vc.component.allocationStorehouseManageInfo.conditions.page = _page;
vc.component.allocationStorehouseManageInfo.conditions.row = _rows;
vc.component.allocationStorehouseManageInfo.conditions.communityId = vc.getCurrentCommunity().communityId;
var param = {
params: vc.component.allocationStorehouseManageInfo.conditions
};
param.params.resId = param.params.resId.trim();
param.params.resName = param.params.resName.trim();
param.params.resCode = param.params.resCode.trim();
//发送get请求
vc.http.apiGet('resourceStore.listAllocationStorehouses',
param,
function (json, res) {
var _allocationStorehouseManageInfo = JSON.parse(json);
vc.component.allocationStorehouseManageInfo.total = _allocationStorehouseManageInfo.total;
vc.component.allocationStorehouseManageInfo.records = _allocationStorehouseManageInfo.records;
vc.component.allocationStorehouseManageInfo.resourceStores = _allocationStorehouseManageInfo.data;
vc.emit('pagination', 'init', {
total: vc.component.allocationStorehouseManageInfo.records,
currentPage: _page
});
}, function (errInfo, error) {
console.log('请求失败处理');
}
);
},
_openDeleteAllocationStorehouseModel: function (_resourceStore) {
vc.emit('deleteAllocationStorehouse', 'openDeleteAllocationStorehouseModal', _resourceStore);
},
//查询
_queryAllocationStorehouseMethod: function () {
vc.component._listAllocationStorehouses(DEFAULT_PAGE, DEFAULT_ROWS);
},
_listStorehouses: function (_page, _rows) {
var param = {
params: {
page: 1,
row: 100,
communityId:vc.getCurrentCommunity().communityId
}
};
//发送get请求
vc.http.apiGet('resourceStore.listStorehouses',
param,
function (json, res) {
var _storehouseManageInfo = JSON.parse(json);
vc.component.allocationStorehouseManageInfo.storehouses = _storehouseManageInfo.data;
}, function (errInfo, error) {
console.log('请求失败处理');
}
);
},
}
});
})(window.vc);

View File

@ -121,7 +121,8 @@
var param = {
params: {
page: 1,
row: 100
row: 100,
communityId:vc.getCurrentCommunity().communityId
}
};

View File

@ -37,6 +37,7 @@
vc.component.storehouseManageInfo.conditions.page = _page;
vc.component.storehouseManageInfo.conditions.row = _rows;
vc.component.storehouseManageInfo.conditions.communityId = vc.getCurrentCommunity().communityId;
var param = {
params: vc.component.storehouseManageInfo.conditions
};