优化代码

This commit is contained in:
wuxw 2025-03-08 11:54:49 +08:00
parent e4a8024349
commit bf505e36eb
10 changed files with 672 additions and 0 deletions

View File

@ -0,0 +1,53 @@
<div id="addCityAreaModel" 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 ">
<vc:i18n name="添加区域" namespace="addCityArea"></vc:i18n>
</h3>
<div class="ibox-content">
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<vc:i18n name="地区名称" namespace="addCityArea"></vc:i18n>
</label>
<div class="col-sm-10">
<input v-model="addCityAreaInfo.areaName" type="text"
:placeholder="vc.i18n('必填,请填写地区名称','addCityArea')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<vc:i18n name="地区编码" namespace="addCityArea"></vc:i18n>
</label>
<div class="col-sm-10">
<!--@blur="textOrgName()"-->
<input v-model="addCityAreaInfo.areaCode" type="text"
:placeholder="vc.i18n('必填,请填写地区编码','addCityArea')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><span>
<vc:i18n name="上级" namespace="addCityArea"></vc:i18n>
</span></label>
<div class="col-sm-10">
<input v-model="addCityAreaInfo.parentAreaName" disabled type="text"
:placeholder="vc.i18n('必填,请填写上级','addCityArea')" class="form-control">
</div>
</div>
<div class="ibox-content">
<button class="btn btn-primary float-right" type="button" v-on:click="saveOrgInfo()"><i
class="fa fa-check"></i>&nbsp;
<vc:i18n name="保存"></vc:i18n>
</button>
<button type="button" class="btn btn-warning float-right" style="margin-right:20px;"
data-dismiss="modal"><span>
<vc:i18n name="取消" namespace="addCityArea"></vc:i18n>
</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,104 @@
(function(vc) {
vc.extends({
data: {
addCityAreaInfo: {
areaCode: '',
areaName: '',
areaLevel: '',
parentAreaId: '',
parentAreaName: '',
lon: '',
lat: '',
},
flagOrgName: false
},
_initMethod: function() {
},
_initEvent: function() {
vc.on('addCityArea', 'openAddCityAreaModal', function(_param) {
if (_param.hasOwnProperty('parentAreaCode')) {
$that.addCityAreaInfo.parentAreaCode = _param.parentAreaCode;
$that.addCityAreaInfo.areaLevel = _param.areaLevel;
$that.addCityAreaInfo.parentAreaName = _param.parentAreaName;
}
$('#addCityAreaModel').modal('show');
});
},
methods: {
addCityAreaValidate: function() {
return vc.validate.validate({
addCityAreaInfo: $that.addCityAreaInfo
}, {
'addCityAreaInfo.areaCode': [{
limit: "required",
param: "",
errInfo: "地区编码不能为空"
},
],
'addCityAreaInfo.areaName': [{
limit: "required",
param: "",
errInfo: "地区名称不能为空"
},
],
'addCityAreaInfo.parentAreaCode': [
{
limit: "maxLength",
param: "200",
errInfo: "上级编码不能为空"
},
],
});
},
saveOrgInfo: function() {
if (!$that.addCityAreaValidate()) {
vc.toast(vc.validate.errInfo);
return;
}
vc.http.apiPost(
'/area.saveCityArea',
JSON.stringify($that.addCityAreaInfo), {
emulateJSON: true
},
function(json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
if (res.status == 200) {
//关闭model
$('#addCityAreaModel').modal('hide');
$that.clearAddCityAreaInfo();
vc.emit('cityAreaTree', 'refreshTree', {});
return;
}
vc.toast(json);
},
function(errInfo, error) {
console.log('请求失败处理');
vc.toast(errInfo);
});
},
clearAddCityAreaInfo: function() {
$that.addCityAreaInfo = {
areaCode: '',
areaName: '',
areaLevel: '',
parentAreaId: '',
parentAreaName: '',
lon: '',
lat: '',
};
},
}
});
})(window.vc);

View File

@ -0,0 +1,18 @@
<div class="bg-white margin-top-xs padding border-radius">
<div class=" ">
<button type="button" v-if="cityAreaTreeInfo.curCityArea.areaLevel != '303'" class="btn btn-white btn-sm" v-on:click="_openAddCityAreaModal()" >
添加
</button>
<button type="button" class="btn btn-white btn-sm" v-if="cityAreaTreeInfo.curCityArea.areaCode != '0'" v-on:click="_openEditCityAreaTreeModel()" >
修改
</button>
<button type="button" class="btn btn-white btn-sm" v-if="cityAreaTreeInfo.curCityArea.areaCode != '0'" v-on:click="_openDeleteCityAreaTreeModel()" >
删除
</button>
</div>
<div id="jstree_org" class="margin-top">
</div>
<vc:create path="community/addCityArea"></vc:create>
<vc:create path="community/editCityArea"></vc:create>
<vc:create path="community/deleteCityArea"></vc:create>
</div>

View File

@ -0,0 +1,118 @@
/**
入驻小区
**/
(function (vc) {
vc.extends({
propTypes: {
callBackListener: vc.propTypes.string, //父组件名称
},
data: {
cityAreaTreeInfo: {
orgs: [],
orgId: '',
curCityArea: {}
}
},
_initMethod: function () {
$that._loadCityAreaTrees();
},
_initEvent: function () {
vc.on('cityAreaTree', 'refreshTree', function (_param) {
$that._loadCityAreaTrees();
});
},
methods: {
_loadCityAreaTrees: function () {
let param = {
params: {
hc: 1.8
}
};
//发送get请求
vc.http.apiGet('/area.queryAreaTree',
param,
function (json) {
let _orgs = JSON.parse(json).data;
$that.cityAreaTreeInfo.orgs = _orgs;
$that._initJsTreeFloorUnit();
},
function () {
console.log('请求失败处理');
});
},
_initJsTreeFloorUnit: function () {
let _data = $that.cityAreaTreeInfo.orgs;
$.jstree.destroy()
$("#jstree_org").jstree({
"checkbox": {
"keep_selected_style": false
},
'state': { //一些初始化状态
"opened": false,
},
// 'plugins': ['contextmenu'],
'core': {
'data': _data
},
});
$("#jstree_org").on("ready.jstree", function (e, data) {
//data.instance.open_all(); //打开所有节点
});
$('#jstree_org').on("changed.jstree", function (e, data) {
if (data.action == 'model' || data.action == 'ready') {
//默认合并
//$("#jstree_org").jstree("close_all");
return;
}
$that.cityAreaTreeInfo.curCityArea = data.node.original;
$that.cityAreaTreeInfo.curCityArea.orgId = $that.cityAreaTreeInfo.curCityArea.id;
vc.emit($props.callBackListener, 'switchCityAreaTree', {
areaCode: data.node.original.areaCode,
areaLevel: data.node.original.areaLevel,
areaName: $that.cityAreaTreeInfo.curCityArea.text
})
});
// $('#jstree_org')
// .on('click', '.jstree-anchor', function(e) {
// $(this).jstree(true).toggle_node(e.target);
// })
},
_openAddCityAreaModal: function () {
if (!$that.cityAreaTreeInfo.curCityArea.id) {
vc.toast('未选择组织');
return;
}
let _areaLevel = $that.cityAreaTreeInfo.curCityArea.areaLevel;
if( _areaLevel== '101'){
_areaLevel = "202";
}else if(_areaLevel == '202'){
_areaLevel = "303";
}else if(_areaLevel == '303'){
vc.toast('不能添加子节点');
return;
}else{
_areaLevel = "101";
}
vc.emit('addCityArea', 'openAddCityAreaModal', {
parentAreaCode: $that.cityAreaTreeInfo.curCityArea.areaCode,
areaLevel:_areaLevel,
parentAreaName: $that.cityAreaTreeInfo.curCityArea.text
});
},
_openEditCityAreaTreeModel: function () {
if (!$that.cityAreaTreeInfo.curCityArea.id) {
vc.toast('未选择组织');
return;
}
vc.emit('editCityArea', 'openEditCityAreaModal', $that.cityAreaTreeInfo.curCityArea);
},
_openDeleteCityAreaTreeModel: function () {
if (!$that.cityAreaTreeInfo.curCityArea.id) {
vc.toast('未选择组织');
return;
}
vc.emit('deleteCityArea', 'openDeleteCityAreaModal', $that.cityAreaTreeInfo.curCityArea);
},
}
});
})(window.vc);

View File

@ -0,0 +1,29 @@
<div class="modal fade" id="deleteCityAreaModel" 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">
<vc:i18n name="请确认您的操作!" namespace="deleteCityArea"></vc:i18n>
</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>
<vc:i18n name="确定删除地区" namespace="deleteCityArea"></vc:i18n>
</th>
</tr>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" v-on:click="closeDeleteCityAreaModel()">
<vc:i18n name="点错了" namespace="deleteCityArea"></vc:i18n>
</button>
<button type="button" class="btn btn-primary" v-on:click="deleteCityArea()">
<vc:i18n name="确认删除" namespace="deleteCityArea"></vc:i18n>
</button>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,48 @@
(function(vc, vm) {
vc.extends({
data: {
deleteCityAreaInfo: {
}
},
_initMethod: function() {
},
_initEvent: function() {
vc.on('deleteCityArea', 'openDeleteCityAreaModal', function(_params) {
$that.deleteCityAreaInfo = _params;
$('#deleteCityAreaModel').modal('show');
});
},
methods: {
deleteCityArea: function() {
vc.http.apiPost(
'/area.deleteCityArea',
JSON.stringify($that.deleteCityAreaInfo), {
emulateJSON: true
},
function(json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
let _json = JSON.parse(json);
if (_json.code == 0) {
//关闭model
$('#deleteCityAreaModel').modal('hide');
vc.emit('cityAreaTree', 'refreshTree', {});
return;
}
vc.toast(_json.msg);
},
function(errInfo, error) {
console.log('请求失败处理');
vc.toast(json);
});
},
closeDeleteCityAreaModel: function() {
$('#deleteCityAreaModel').modal('hide');
}
}
});
})(window.vc, window.$that);

View File

@ -0,0 +1,53 @@
<div id="editCityAreaModel" 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 ">
<vc:i18n name="修改区域" namespace="editCityArea"></vc:i18n>
</h3>
<div class="ibox-content">
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<vc:i18n name="地区名称" namespace="editCityArea"></vc:i18n>
</label>
<div class="col-sm-10">
<input v-model="editCityAreaInfo.areaName" type="text"
:placeholder="vc.i18n('必填,请填写地区名称','editCityArea')" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">
<vc:i18n name="地区编码" namespace="editCityArea"></vc:i18n>
</label>
<div class="col-sm-10">
<!--@blur="textOrgName()"-->
<input v-model="editCityAreaInfo.areaCode" type="text"
:placeholder="vc.i18n('必填,请填写地区编码','editCityArea')" disabled class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label"><span>
<vc:i18n name="上级" namespace="editCityArea"></vc:i18n>
</span></label>
<div class="col-sm-10">
<input v-model="editCityAreaInfo.parentAreaName" disabled type="text"
:placeholder="vc.i18n('必填,请填写上级','editCityArea')" class="form-control">
</div>
</div>
<div class="ibox-content">
<button class="btn btn-primary float-right" type="button" v-on:click="_editCityArea()"><i
class="fa fa-check"></i>&nbsp;
<vc:i18n name="保存"></vc:i18n>
</button>
<button type="button" class="btn btn-warning float-right" style="margin-right:20px;"
data-dismiss="modal"><span>
<vc:i18n name="取消" namespace="editCityArea"></vc:i18n>
</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,123 @@
(function(vc) {
vc.extends({
data: {
editCityAreaInfo: {
id:'',
areaCode: '',
areaName: '',
areaLevel: '',
parentAreaId: '',
parentAreaName: '',
parentAreaCode:'',
lon: '',
lat: '',
},
flagOrgName: false
},
_initMethod: function() {
},
_initEvent: function() {
vc.on('editCityArea', 'openEditCityAreaModal', function(_param) {
vc.copyObject(_param,$that.editCityAreaInfo);
$that.loadEditCityArea();
$('#editCityAreaModel').modal('show');
});
},
methods: {
editCityAreaValidate: function() {
return vc.validate.validate({
editCityAreaInfo: $that.editCityAreaInfo
}, {
'editCityAreaInfo.areaCode': [{
limit: "required",
param: "",
errInfo: "地区编码不能为空"
},
],
'editCityAreaInfo.areaName': [{
limit: "required",
param: "",
errInfo: "地区名称不能为空"
},
],
'editCityAreaInfo.parentAreaCode': [
{
limit: "maxLength",
param: "200",
errInfo: "上级编码不能为空"
},
],
});
},
_editCityArea: function() {
if (!$that.editCityAreaValidate()) {
vc.toast(vc.validate.errInfo);
return;
}
vc.http.apiPost(
'/area.updateCityArea',
JSON.stringify($that.editCityAreaInfo), {
emulateJSON: true
},
function(json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
if (res.status == 200) {
//关闭model
$('#editCityAreaModel').modal('hide');
$that.clearEditCityAreaInfo();
vc.emit('cityAreaTree', 'refreshTree', {});
return;
}
vc.toast(json);
},
function(errInfo, error) {
console.log('请求失败处理');
vc.toast(errInfo);
});
},
clearEditCityAreaInfo: function() {
$that.editCityAreaInfo = {
id:'',
areaCode: '',
areaName: '',
areaLevel: '',
parentAreaId: '',
parentAreaCode:'',
parentAreaName: '',
lon: '',
lat: '',
};
},
loadEditCityArea:function(){
let param = {
params: {
id: $that.editCityAreaInfo.id,
page:1,
row:1
}
};
//发送get请求
vc.http.apiGet('/area.listAreas',
param,
function (json) {
let _cityArea = JSON.parse(json).areas;
vc.copyObject(_cityArea[0],$that.editCityAreaInfo);
},
function () {
console.log('请求失败处理');
});
}
}
});
})(window.vc);

View File

@ -0,0 +1,73 @@
<div class="row">
<div class="col-md-2 padding-r-0">
<vc:create path="community/cityAreaTree" callBackListener="cityArea"></vc:create>
</div>
<div class="col-md-10">
<div class="white-bg padding-left padding-right padding-top border-radius-top">
<div class="flex justify-between" >
<div class="text-title">
地区详情
</div>
<div>
</div>
</div>
<!-- 业主信息 -->
<div class="margin-top" >
<div class="row" >
<div class="col-sm-3">
<div class="form-group">
<label class="col-form-label">
<vc:i18n name="地区名称:" namespace="cityAreaInfo"></vc:i18n>
</label>
<label class="">{{cityAreaInfo.areaName}}</label>
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
<label class="col-form-label">
<vc:i18n name="地区编码:" namespace="cityAreaInfo"></vc:i18n>
</label>
<label class="">{{cityAreaInfo.areaCode || '-'}}</label>
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
<label class="col-form-label">
<vc:i18n name="等级:" namespace="cityAreaInfo"></vc:i18n>
</label>
<label class="" v-if="cityAreaInfo.areaLevel == '101'">省级</label>
<label class="" v-else-if="cityAreaInfo.areaLevel == '202'">市州</label>
<label class="" v-else-if="cityAreaInfo.areaLevel == '303'">区县</label>
<label class="" v-else>地区</label>
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
<label class="col-form-label">
<vc:i18n name="父级编码:" namespace="cityAreaInfo"></vc:i18n>
</label>
<label class="">{{cityAreaInfo.parentAreaCode || '-'}}</label>
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
<label class="col-form-label">
<vc:i18n name="父级名称" namespace="cityAreaInfo"></vc:i18n>
</label>
<label class="">{{cityAreaInfo.parentAreaName || '-'}}</label>
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
<label class="col-form-label">
<vc:i18n name="创建时间:" namespace="cityAreaInfo"></vc:i18n>
</label>
<label class="">{{cityAreaInfo.createTime || '-'}}</label>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,53 @@
/**
业主详情页面
**/
(function (vc) {
vc.extends({
data: {
cityAreaInfo: {
id: '',
areaCode: '',
areaName: '',
areaLevel:'',
parentAreaCode: '',
parentAreaName: '',
}
},
_initMethod: function () {
},
_initEvent: function () {
vc.on('cityArea','switchCityAreaTree',function(_param){
$that.cityAreaInfo.id = _param.id;
$that.cityAreaInfo.areaCode = _param.areaCode;
$that.cityAreaInfo.areaName = _param.areaName;
$that._listCityArea();
});
},
methods: {
_listCityArea: function () {
let param = {
params: {
page:1,
row:1,
areaCode:$that.cityAreaInfo.areaCode,
id:$that.cityAreaInfo.id,
}
};
//发送get请求
vc.http.apiGet('/area.listAreas',
param,
function (json, res) {
let _json = JSON.parse(json);
vc.copyObject(_json.data[0],$that.cityAreaInfo);
}, function (errInfo, error) {
console.log('请求失败处理');
}
);
},
}
});
})(window.vc);