| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- (function (vc) {
- vc.extends({
- propTypes: {
- callBackListener: vc.propTypes.string, //父组件名称
- callBackFunction: vc.propTypes.string //父组件监听方法
- },
- data: {
- addOrgInfo: {
- orgId: '',
- orgName: '',
- orgLevel: '',
- parentOrgId: '',
- description: '',
- belongCommunityId: '',
- communityId: '',
- parentOrg:[],
- belongCommunitys:[]
- }
- },
- watch: {
- "addOrgInfo.orgLevel":
- {//深度监听,可监听到对象、数组的变化
- handler(val, oldVal) {
- vc.component._addOrgListParentOrgInfo();
- }
- ,
- deep: true
- }
- }
- ,
- _initMethod: function () {
- //查询入驻的小区
- vc.component._loadAddEnterCommunitys();
- }
- ,
- _initEvent: function () {
- vc.on('addOrg', 'openAddOrgModal', function (_param) {
- if (_param.hasOwnProperty('parentOrgId')) {
- vc.component.addOrgInfo.parentOrgId = _param.parentOrgId;
- vc.component.addOrgInfo.orgLevel = _param.orgLevel;
- if(_param.parentOrgId == 3){ // 部门是不能改小区的,是依赖分公司的小区信息
- vc.component.addOrgInfo.communityId = _param.belongCommunityId;
- }
- }
- $('#addOrgModel').modal('show');
- });
- }
- ,
- methods: {
- addOrgValidate() {
- return vc.validate.validate({
- addOrgInfo: vc.component.addOrgInfo
- }, {
- 'addOrgInfo.orgName': [
- {
- limit: "required",
- param: "",
- errInfo: "组织名称不能为空"
- },
- {
- limit: "maxin",
- param: "2,50",
- errInfo: "组织名称长度为2至50"
- },
- ],
- 'addOrgInfo.orgLevel': [
- {
- limit: "required",
- param: "",
- errInfo: "组织级别不能为空"
- },
- {
- limit: "num",
- param: "",
- errInfo: "组织级别错误"
- },
- ],
- 'addOrgInfo.parentOrgId': [
- {
- limit: "required",
- param: "",
- errInfo: "上级ID不能为空"
- },
- {
- limit: "num",
- param: "",
- errInfo: "上级ID不正确"
- },
- ],
- 'addOrgInfo.belongCommunityId': [
- {
- limit: "required",
- param: "",
- errInfo: "隶属小区不能为空"
- },
- {
- limit: "num",
- param: "",
- errInfo: "隶属小区不正确"
- },
- ],
- 'addOrgInfo.description': [
- {
- limit: "maxLength",
- param: "200",
- errInfo: "描述不能为空"
- },
- ],
- });
- }
- ,
- saveOrgInfo: function () {
- vc.component.addOrgInfo.belongCommunityId = vc.component.addOrgInfo.communityId;
- if (!vc.component.addOrgValidate()) {
- vc.message(vc.validate.errInfo);
- return;
- }
- vc.component.addOrgInfo.communityId = vc.getCurrentCommunity().communityId;
- //不提交数据将数据 回调给侦听处理
- if (vc.notNull($props.callBackListener)) {
- vc.emit($props.callBackListener, $props.callBackFunction, vc.component.addOrgInfo);
- $('#addOrgModel').modal('hide');
- return;
- }
- vc.http.post(
- 'addOrg',
- 'save',
- JSON.stringify(vc.component.addOrgInfo),
- {
- emulateJSON: true
- },
- function (json, res) {
- //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
- if (res.status == 200) {
- //关闭model
- $('#addOrgModel').modal('hide');
- vc.component.clearAddOrgInfo();
- vc.emit('orgManage', 'listOrg', {});
- return;
- }
- vc.message(json);
- },
- function (errInfo, error) {
- console.log('请求失败处理');
- vc.message(errInfo);
- });
- }
- ,
- clearAddOrgInfo: function () {
- vc.component.addOrgInfo = {
- orgName: '',
- orgLevel: '',
- parentOrgId: '',
- description: '',
- parentOrg: [],
- belongCommunityId: '',
- communityId: '',
- };
- }
- ,
- _addOrgListParentOrgInfo: function () {
- var _tmpOrgLevel = vc.component.addOrgInfo.orgLevel;
- if (_tmpOrgLevel > 1) {
- _tmpOrgLevel = _tmpOrgLevel - 1;
- }
- var param = {
- params: {
- orgLevel: _tmpOrgLevel,
- page: 1,
- row: 30,
- }
- };
- //发送get请求
- vc.http.get('addOrg',
- 'list',
- param,
- function (json, res) {
- var _orgManageInfo = JSON.parse(json);
- vc.component.addOrgInfo.parentOrg = _orgManageInfo.orgs;
- }, function (errInfo, error) {
- console.log('请求失败处理');
- }
- );
- },
- _loadAddEnterCommunitys:function () {
- //belongCommunitys
- var param = {
- params:{
- _uid:'mmmllnnjhhjjh'
- }
- }
- //发送get请求
- vc.http.get('addOrg',
- 'listEnterCommunitys',
- param,
- function (json, res) {
- var _enterCommunitys = JSON.parse(json);
- vc.component.addOrgInfo.belongCommunitys = _enterCommunitys;
- }, function (errInfo, error) {
- console.log('请求失败处理');
- }
- );
- }
- }
- })
- ;
- })(window.vc);
|