|
@@ -4,7 +4,7 @@ from ..models import Role
|
|
from ..models import User
|
|
from ..models import User
|
|
from ..models import Organization
|
|
from ..models import Organization
|
|
from flask import g, jsonify, request
|
|
from flask import g, jsonify, request
|
|
-from flask_login import current_user
|
|
|
|
|
|
+from flask_login import current_user, login_required
|
|
import json
|
|
import json
|
|
from .. import db
|
|
from .. import db
|
|
from flask import render_template
|
|
from flask import render_template
|
|
@@ -40,11 +40,19 @@ def grant_organization_resource():
|
|
|
|
|
|
return jsonify({'success': True})
|
|
return jsonify({'success': True})
|
|
|
|
|
|
-@base.route('/base/syorganization!treeGrid.action', methods=['POST'])
|
|
|
|
|
|
+@base.route('/system/dept/list', methods=['GET'])
|
|
|
|
+@login_required
|
|
def syorganization_treeGrid():
|
|
def syorganization_treeGrid():
|
|
orgs = Organization.query.all()
|
|
orgs = Organization.query.all()
|
|
|
|
|
|
- return jsonify([org.to_json() for org in orgs])
|
|
|
|
|
|
+ return jsonify({'msg': '操作成功', 'code': 200, "data": [org.to_json() for org in orgs]})
|
|
|
|
+
|
|
|
|
+@base.route('/system/dept/list/exclude/<id>', methods=['GET'])
|
|
|
|
+@login_required
|
|
|
|
+def syorganization_dept_list_exclude(id):
|
|
|
|
+ orgs = Organization.query.filter(Organization.ID != id)
|
|
|
|
+
|
|
|
|
+ return jsonify({'msg': '操作成功', 'code': 200, "data": [org.to_json() for org in orgs]})
|
|
|
|
|
|
@base.route('/base/syorganization!doNotNeedSecurity_comboTree.action', methods=['POST'])
|
|
@base.route('/base/syorganization!doNotNeedSecurity_comboTree.action', methods=['POST'])
|
|
def syorganization_comboTree():
|
|
def syorganization_comboTree():
|
|
@@ -63,41 +71,41 @@ def get_syorganization_by_userId():
|
|
orgs = Organization.query.join(User, Organization.users).filter(User.ID == request.form.get('id')).all()
|
|
orgs = Organization.query.join(User, Organization.users).filter(User.ID == request.form.get('id')).all()
|
|
return jsonify([org.to_json() for org in orgs])
|
|
return jsonify([org.to_json() for org in orgs])
|
|
|
|
|
|
-@base.route('/base/syorganization!getById.action', methods=['POST'])
|
|
|
|
-def syorganization_getById():
|
|
|
|
- org = Organization.query.get(request.form.get('id'))
|
|
|
|
|
|
+@base.route('/system/dept/<string:id>', methods=['GET'])
|
|
|
|
+def syorganization_getById(id):
|
|
|
|
+ org = Organization.query.get(id)
|
|
|
|
|
|
if org:
|
|
if org:
|
|
- return jsonify(org.to_json())
|
|
|
|
|
|
+ return jsonify({'msg': '操作成功', 'code': 200, 'data': org.to_json()})
|
|
else:
|
|
else:
|
|
return jsonify({'success': False, 'msg': 'error'})
|
|
return jsonify({'success': False, 'msg': 'error'})
|
|
|
|
|
|
-@base.route('/base/syorganization!update.action', methods=['POST'])
|
|
|
|
|
|
+@base.route('/system/dept', methods=['PUT'])
|
|
def syorganization_update():
|
|
def syorganization_update():
|
|
- org = Organization.query.get(request.form.get('data.id'))
|
|
|
|
|
|
+ org = Organization.query.get(request.json['deptId'])
|
|
|
|
|
|
org.UPDATEDATETIME = datetime.now()
|
|
org.UPDATEDATETIME = datetime.now()
|
|
- org.NAME = request.form.get('data.name')
|
|
|
|
- org.ADDRESS = request.form.get('data.address')
|
|
|
|
- org.CODE = request.form.get('data.code')
|
|
|
|
- org.ICONCLS = request.form.get('data.iconCls')
|
|
|
|
- org.SEQ = request.form.get('data.seq')
|
|
|
|
- org.parent = Organization.query.get(request.form.get('data.syorganization.id'))
|
|
|
|
|
|
+ org.NAME = request.json['deptName']
|
|
|
|
+ org.EMAIL = request.json['email']
|
|
|
|
+ org.LEADER = request.json['leader']
|
|
|
|
+ org.PHONE = request.json['phone']
|
|
|
|
+ org.SEQ = request.json['orderNum']
|
|
|
|
+ org.parent = Organization.query.get(request.json['parentId'])
|
|
|
|
|
|
db.session.add(org)
|
|
db.session.add(org)
|
|
|
|
|
|
return jsonify({'success': True})
|
|
return jsonify({'success': True})
|
|
|
|
|
|
-@base.route('/base/syorganization!save.action', methods=['POST'])
|
|
|
|
|
|
+@base.route('/system/dept', methods=['POST'])
|
|
def syorganization_save():
|
|
def syorganization_save():
|
|
org = Organization()
|
|
org = Organization()
|
|
org.ID = str(uuid.uuid4())
|
|
org.ID = str(uuid.uuid4())
|
|
- org.NAME = request.form.get('data.name')
|
|
|
|
- org.ADDRESS = request.form.get('data.address')
|
|
|
|
- org.CODE = request.form.get('data.code')
|
|
|
|
- org.ICONCLS = request.form.get('data.iconCls')
|
|
|
|
- org.SEQ = request.form.get('data.seq')
|
|
|
|
- org.parent = Organization.query.get(request.form.get('data.syorganization.id'))
|
|
|
|
|
|
+ org.NAME = request.json['deptName']
|
|
|
|
+ org.EMAIL = request.json['email']
|
|
|
|
+ org.LEADER = request.json['leader']
|
|
|
|
+ org.PHONE = request.json['phone']
|
|
|
|
+ org.SEQ = request.json['orderNum']
|
|
|
|
+ org.parent = Organization.query.get(request.json['parentId'])
|
|
|
|
|
|
# add organization to current user
|
|
# add organization to current user
|
|
current_user.organizations.append(org)
|
|
current_user.organizations.append(org)
|