mirror of
https://gitee.com/java110/MicroCommunityWeb.git
synced 2026-02-24 21:59:12 +08:00
加入物品导入功能
This commit is contained in:
parent
d848d2924f
commit
f807bca93c
@ -14,9 +14,7 @@
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<div class="custom-file">
|
||||
<input id="excelTemplate" ref="excelTemplate" type="file"
|
||||
class="custom-file-input form-control" name="excelTemplate"
|
||||
v-on:change="getExcelTemplate($event)" accept=".xls,.xlsx">
|
||||
<input id="excelTemplate" ref="excelTemplate" type="file" class="custom-file-input form-control" name="excelTemplate" v-on:change="getExcelTemplate($event)" accept=".xls,.xlsx">
|
||||
<label for="excelTemplate" class="custom-file-label">
|
||||
{{importOwnerRoomInfo.excelTemplate==''?'必填,请选择数据文件':importOwnerRoomInfo.excelTemplate.name}}
|
||||
</label>
|
||||
@ -39,8 +37,7 @@
|
||||
<button class="btn btn-primary float-right" type="button" v-on:click="_importData()">
|
||||
<i class="fa fa-check"></i> 导入
|
||||
</button>
|
||||
<button type="button" class="btn btn-warning float-right" style="margin-right:20px;"
|
||||
data-dismiss="modal">
|
||||
<button type="button" class="btn btn-warning float-right" style="margin-right:20px;" data-dismiss="modal">
|
||||
<i class="fa fa-close"></i> 取消
|
||||
</button>
|
||||
</div>
|
||||
@ -50,4 +47,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,52 @@
|
||||
<div id="importResourceStoreModel" 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="importResourceStore"></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="importResourceStore"></vc:i18n></span></label>
|
||||
<div class="col-sm-10">
|
||||
<select class="custom-select" v-model="importResourceStoreInfo.shId">
|
||||
<option selected disabled value="">{{vc.i18n('必填,请选择仓库','importResourceStore')}}</option>
|
||||
<option v-for="(item,index) in importResourceStoreInfo.storehouses" :key="index"
|
||||
v-bind:value="item.shId">
|
||||
{{item.shName}}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2 col-form-label"><span><vc:i18n name="选择文件" namespace="importResourceStore"></vc:i18n></span></label>
|
||||
<div class="col-sm-10">
|
||||
<div class="custom-file">
|
||||
<input id="excelTemplate" ref="excelTemplate" type="file" class="custom-file-input form-control" name="excelTemplate" v-on:change="getExcelTemplate($event)" accept=".xls,.xlsx">
|
||||
<label for="excelTemplate" class="custom-file-label">{{importResourceStoreInfo.excelTemplate==''?'必填,请选择数据文件':importResourceStoreInfo.excelTemplate.name}}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2 col-form-label"><span><vc:i18n name="下载模板" namespace="importResourceStore"></vc:i18n></span></label>
|
||||
<div class="col-sm-10">
|
||||
请先下载
|
||||
<a href="/import/importResourceStore.xlsx" target="_blank"><span><vc:i18n name="物品模板" namespace="importResourceStore"></vc:i18n></span>
|
||||
</a> <span><vc:i18n name="准备数据后" namespace="importResourceStore"></vc:i18n></span>,上传导入
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<button class="btn btn-primary float-right" type="button" v-on:click="_importData()">
|
||||
<i class="fa fa-check"></i> 导入
|
||||
</button>
|
||||
<button type="button" class="btn btn-warning float-right" style="margin-right:20px;" data-dismiss="modal">
|
||||
<i class="fa fa-close"></i> 取消
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -0,0 +1,142 @@
|
||||
(function(vc) {
|
||||
vc.extends({
|
||||
data: {
|
||||
importResourceStoreInfo: {
|
||||
communityId: vc.getCurrentCommunity().communityId,
|
||||
excelTemplate: '',
|
||||
storehouses: [],
|
||||
shId: ''
|
||||
}
|
||||
},
|
||||
_initMethod: function() {},
|
||||
_initEvent: function() {
|
||||
vc.on('importResourceStore', 'openimportResourceStoreModal', function(_param) {
|
||||
$('#importResourceStoreModel').modal('show');
|
||||
$that._listImportResourceStorehouses();
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
_listImportResourceStorehouses: function(_page, _rows) {
|
||||
var param = {
|
||||
params: {
|
||||
page: 1,
|
||||
row: 100,
|
||||
shType: '',
|
||||
communityId: vc.getCurrentCommunity().communityId
|
||||
}
|
||||
};
|
||||
//发送get请求
|
||||
vc.http.apiGet('resourceStore.listStorehouses',
|
||||
param,
|
||||
function(json, res) {
|
||||
let _storehouseManageInfo = JSON.parse(json);
|
||||
vc.component.importResourceStoreInfo.storehouses = _storehouseManageInfo.data;
|
||||
},
|
||||
function(errInfo, error) {
|
||||
console.log('请求失败处理');
|
||||
}
|
||||
);
|
||||
},
|
||||
importResourceStoreValidate() {
|
||||
return vc.validate.validate({
|
||||
importResourceStoreInfo: vc.component.importResourceStoreInfo
|
||||
}, {
|
||||
'importResourceStoreInfo.communityId': [{
|
||||
limit: "required",
|
||||
param: "",
|
||||
errInfo: "数据异常还没有入驻小区"
|
||||
}],
|
||||
'importResourceStoreInfo.excelTemplate': [{
|
||||
limit: "required",
|
||||
param: "",
|
||||
errInfo: "文件不能为空"
|
||||
}]
|
||||
});
|
||||
},
|
||||
_importData: function() {
|
||||
if (!vc.component.importResourceStoreValidate()) {
|
||||
vc.toast(vc.validate.errInfo);
|
||||
return;
|
||||
}
|
||||
// 导入数据
|
||||
if (!vc.component.checkOwnerFileType(vc.component.importResourceStoreInfo.excelTemplate.name.split('.')[1])) {
|
||||
vc.toast('不是有效的Excel格式');
|
||||
return;
|
||||
}
|
||||
if (!vc.component.checkOwnerFileSize(vc.component.importResourceStoreInfo.excelTemplate.size)) {
|
||||
vc.toast('Excel文件大小不能超过2M');
|
||||
return;
|
||||
}
|
||||
var param = new FormData();
|
||||
param.append("uploadFile", vc.component.importResourceStoreInfo.excelTemplate);
|
||||
param.append('communityId', vc.component.importResourceStoreInfo.communityId);
|
||||
param.append('shId', vc.component.importResourceStoreInfo.shId);
|
||||
// param.append('feeTypeCd', vc.component.importRoomFeeInfo.feeTypeCd);
|
||||
// param.append('objType', $that.importRoomFeeInfo.objType);
|
||||
vc.http.upload(
|
||||
'importResourceStore',
|
||||
'importData',
|
||||
param, {
|
||||
emulateJSON: true,
|
||||
//添加请求头
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
},
|
||||
function(json, res) {
|
||||
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
|
||||
let _json = JSON.parse(json);
|
||||
if (_json.code == 0) {
|
||||
//关闭model
|
||||
vc.toast(_json.data);
|
||||
$that.clearAddFeeConfigInfo();
|
||||
$('#importResourceStoreModel').modal('hide');
|
||||
// vc.jumpToPage('/#/pages/property/listOwner')
|
||||
vc.emit('resourceStoreManage', 'listResourceStore', {});
|
||||
return;
|
||||
}
|
||||
vc.toast(_json.msg, 10000);
|
||||
},
|
||||
function(errInfo, error) {
|
||||
console.log('请求失败处理');
|
||||
vc.toast(errInfo, 10000);
|
||||
});
|
||||
},
|
||||
clearAddFeeConfigInfo: function() {
|
||||
let _storehouses = vc.component.importResourceStoreInfo.storehouses;
|
||||
vc.component.importResourceStoreInfo = {
|
||||
communityId: vc.getCurrentCommunity().communityId,
|
||||
excelTemplate: '',
|
||||
storehouses: _storehouses,
|
||||
shId: ''
|
||||
// feeTypeCd: '',
|
||||
// feeTypeCds: [],
|
||||
// objType: '3333'
|
||||
};
|
||||
// vc.component.importRoomFeeInfo.feeTypeCds = _feeTypeCds;
|
||||
},
|
||||
_changeFeeTypeCd: function(_feeTypeCd) {},
|
||||
getExcelTemplate: function(e) {
|
||||
//console.log("getExcelTemplate 开始调用")
|
||||
vc.component.importResourceStoreInfo.excelTemplate = e.target.files[0];
|
||||
},
|
||||
checkOwnerFileType: function(fileType) {
|
||||
const acceptTypes = ['xlsx', 'xls'];
|
||||
for (var i = 0; i < acceptTypes.length; i++) {
|
||||
if (fileType === acceptTypes[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
checkOwnerFileSize: function(fileSize) {
|
||||
//2M
|
||||
const MAX_SIZE = 2 * 1024 * 1024;
|
||||
if (fileSize > MAX_SIZE) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
})(window.vc);
|
||||
BIN
public/import/importResourceStore.xlsx
Normal file
BIN
public/import/importResourceStore.xlsx
Normal file
Binary file not shown.
@ -111,15 +111,19 @@
|
||||
<span><vc:i18n name="物品信息" namespace="resourceStoreManage"></vc:i18n></span>
|
||||
</h5>
|
||||
<div class="ibox-tools" style="top:10px;">
|
||||
<button type="button" class="btn btn-primary btn-sm" v-on:click="_jump2InAndOutPage()" v-if="vc.hasPrivilege('502021042137960001')">
|
||||
<button type="button" class="btn btn-white btn-sm" v-on:click="_jump2InAndOutPage()" v-if="vc.hasPrivilege('502021042137960001')">
|
||||
<i class="fa fa-plus"></i>
|
||||
<span><vc:i18n name="入库与领用" namespace="resourceStoreManage"></vc:i18n></span>
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary btn-sm" v-on:click="_openAddResourceStoreModal()">
|
||||
|
||||
<button type="button" class="btn btn-white btn-sm" v-on:click="_openAddResourceStoreModal()">
|
||||
<i class="fa fa-plus"></i>
|
||||
<span><vc:i18n name="添加" namespace="resourceStoreManage"></vc:i18n></span>
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary btn-sm" v-on:click="_exportExcel()">
|
||||
<button type="button" class="btn btn-white btn-sm" v-on:click="_importResourceStoreModal()">
|
||||
<span><vc:i18n name="导入" namespace="resourceStoreManage"></vc:i18n></span>
|
||||
</button>
|
||||
<button type="button" class="btn btn-white btn-sm" v-on:click="_exportExcel()">
|
||||
<i class="fa fa-plus"></i>
|
||||
<span><vc:i18n name="导出" namespace="resourceStoreManage"></vc:i18n></span>
|
||||
</button>
|
||||
@ -258,4 +262,5 @@
|
||||
<vc:create path="common/addResourceStore" callBackListener="" callBackFunction=""></vc:create>
|
||||
<vc:create path="common/editResourceStore"></vc:create>
|
||||
<vc:create path="common/deleteResourceStore"></vc:create>
|
||||
<vc:create path="property/importResourceStore"></vc:create>
|
||||
</div>
|
||||
@ -240,7 +240,10 @@
|
||||
//导出
|
||||
_exportExcel: function() {
|
||||
vc.jumpToPage('/callComponent/exportReportFee/exportData?pagePath=resourceStoreManage&' + vc.objToGetParam($that.resourceStoreManageInfo.conditions));
|
||||
}
|
||||
},
|
||||
_importResourceStoreModal: function() {
|
||||
vc.emit('importResourceStore', 'openimportResourceStoreModal', {});
|
||||
},
|
||||
}
|
||||
});
|
||||
})(window.vc);
|
||||
Loading…
Reference in New Issue
Block a user