def common_issue_data(): """项目共性问题 测试工程师的界面""" start = int(request.args.get('start', 0)) length = int(request.args.get('length', 10)) search = request.args.get('search[value]', '') is_all_issue = request.args.get('is_all_issue', 0) if search: if is_all_issue == '1': all_count = CommonIssue.query.filter( db.or_(CommonIssue.name.like('%'+search+'%'), CommonIssue.description.like('%' + search + '%'), CommonIssue.baseline_name.like('%' + search + '%'), CommonIssue.platform_name.like('%' + search + '%'))).count() all_record = CommonIssue.query.filter( db.or_(CommonIssue.name.like('%'+search+'%'), CommonIssue.description.like('%' + search + '%'), CommonIssue.baseline_name.like('%' + search + '%'), CommonIssue.platform_name.like('%' + search + '%'))).all() else: all_count = CommonIssue.query.filter( db.or_(CommonIssue.name.like('%'+search+'%'), CommonIssue.description.like('%' + search + '%'), CommonIssue.baseline_name.like('%' + search + '%'), CommonIssue.platform_name.like('%' + search + '%'), CommonIssue.tester_id == current_user.id, CommonIssue.developer_id == current_user.id, CommonIssue.spm_id == current_user.id)).count() all_record = CommonIssue.query.filter( db.or_(CommonIssue.name.like('%'+search+'%'), CommonIssue.description.like('%' + search + '%'), CommonIssue.baseline_name.like('%' + search + '%'), CommonIssue.platform_name.like('%' + search + '%'), CommonIssue.tester_id == current_user.id, CommonIssue.developer_id == current_user.id, CommonIssue.spm_id == current_user.id)).all() else: if is_all_issue == '1': all_count = CommonIssue.query.count() all_record = CommonIssue.query.all() else: all_count = CommonIssue.query.filter( db.or_(CommonIssue.tester_id == current_user.id, CommonIssue.developer_id == current_user.id, CommonIssue.spm_id == current_user.id)).count() all_record = CommonIssue.query.filter( db.or_(CommonIssue.tester_id == current_user.id, CommonIssue.developer_id == current_user.id, CommonIssue.spm_id == current_user.id)).all() records = [] index = start + 1 for record in all_record[start: start + length]: enable_edit = False if record.status == '1' and record.tester_id == current_user.id: enable_edit = True if record.status == 1: status = '已创建' elif record.status == 2: status = '填写方案' elif record.status == 3: status = '等待确认' elif record.status == 4: status = '已确认' else: status = '已创建' records.append({ "id": record.id, "index": index, "name": record.name, "jira_key": record.jira_key, "project_name": record.project.name, "platform_name": record.platform_name, "status": status, "enable_edit": enable_edit }) index += 1 return '{"recordsTotal": %s ,"recordsFiltered": %s,"data":%s}' % (all_count, all_count, json.dumps(records))