Skip to content

Commit

Permalink
Merge branch 'v2.0.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
blackholll committed Aug 1, 2021
2 parents 165f47a + bcf78f2 commit d2682a7
Show file tree
Hide file tree
Showing 10 changed files with 192 additions and 32 deletions.
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@antv/g2": "^4.1.12",
"@antv/g6": "^3.8.4",
"antd": "^4.4.0",
"braft-editor": "^2.3.9",
"classnames": "^2.2.6",
"d3": "^6.2.0",
"dagre-d3": "^0.6.4",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DefaultFooter } from '@ant-design/pro-layout';

export default () => (
<DefaultFooter
copyright="2018-2021 loonflow 2.0.4"
copyright="2018-2021 loonflow 2.0.5"
links={[

{
Expand Down
146 changes: 140 additions & 6 deletions frontend/src/pages/Ticket/TicketDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import {
Card, Divider,
Popconfirm, Modal
} from 'antd';

import BraftEditor from 'braft-editor';
import "braft-editor/dist/index.css";

import React, { Component, Fragment } from 'react';
import moment from 'moment';
import {canInterveneRequest, getWorkflowInitState, getWorkflowSimpleState} from "@/services/workflows";
Expand Down Expand Up @@ -65,6 +69,52 @@ export interface TicketDetailState {

}



const myUploadFn =(param) =>{
const serverURL = 'api/v1.0/tickets/upload_file';
const xhr = new XMLHttpRequest
const fd = new FormData()

const successFn = (response) => {
// 假设服务端直接返回文件上传后的地址
// 上传成功后调用param.success并传入上传后的文件地址
param.success({
url: JSON.parse(xhr.responseText).data.file_path,
meta: {
id: JSON.parse(xhr.responseText).data.file_name,
title: JSON.parse(xhr.responseText).data.file_name,
alt: JSON.parse(xhr.responseText).data.file_name,
loop: true, // 指定音视频是否循环播放
autoPlay: true, // 指定音视频是否自动播放
controls: true, // 指定音视频是否显示控制栏
}
})
}

const progressFn = (event) => {
// 上传进度发生变化时调用param.progress
param.progress(event.loaded / event.total * 100)
}

const errorFn = (response) => {
// 上传发生错误时调用param.error
param.error({
msg: 'unable to upload.'
})
}

xhr.upload.addEventListener("progress", progressFn, false)
xhr.addEventListener("load", successFn, false)
xhr.addEventListener("error", errorFn, false)
xhr.addEventListener("abort", errorFn, false)

fd.append('file', param.file)
xhr.open('POST', serverURL, true)
xhr.send(fd)

}

class TicketDetail extends Component<TicketDetailProps, TicketDetailState> {
constructor(props: Readonly<TicketDetailProps>) {
super(props);
Expand Down Expand Up @@ -93,8 +143,7 @@ class TicketDetail extends Component<TicketDetailProps, TicketDetailState> {
this.fetchWorkflowInitState();
} else {
// ticket detail
this.
fetchTicketDetailInfo();
this.fetchTicketDetailInfo();
// get ticket transition
this.fetchTicketTransitionInfo();
}
Expand Down Expand Up @@ -161,7 +210,11 @@ class TicketDetail extends Component<TicketDetailProps, TicketDetailState> {
fieldTypeDict[result.field_key] = result.field_type_id
if (result.field_type_id === 30){
formInitValues[result.field_key] = moment(result.field_value);
} else if ([40, 50, 70].indexOf(result.field_type_id) >= 0) {
formInitValues[result.field_key] = result.field_value? result.field_value.split(','): []
console.log(formInitValues);
}

else if (result.field_type_id === 80){
// 附件
let newList = this.state.fileList;
Expand All @@ -178,7 +231,6 @@ class TicketDetail extends Component<TicketDetailProps, TicketDetailState> {

})


// newList[result.field_key] = result.field_value.split();
newList[result.field_key] = fileList1
console.log('newList')
Expand Down Expand Up @@ -360,7 +412,60 @@ class TicketDetail extends Component<TicketDetailProps, TicketDetailState> {

if (item.field_attribute === 1) {
// todo: 下拉列表、布尔radio等显示的处理
if (item.field_type_id === 80){
if (item.field_type_id === 20) {
// 布尔
let display_result = item.boolean_field_display[item.field_value]
child = <div>{display_result}</div>
}

else if (item.field_type_id === 35) {
// 单选框
let display_result = item.field_choice[item.field_value]
child = <div>{display_result}</div>
}else if (item.field_type_id === 40) {
//多选框
let result_list = item.field_value?item.field_value.split(','):[]
let result_display_list = []
result_list.forEach((result0)=>{
console.log(result0)
if(item.field_choice[result0]){
result_display_list.push(item.field_choice[result0])
}
})

let display_result = result_display_list.join()
child = <div>{display_result}</div>
} else if (item.field_type_id === 45) {
//下拉列表
let display_result = item.field_choice[item.field_value]
child = <div>{display_result}</div>
} else if (item.field_type_id === 50) {
//多选下拉列表
let result_list = item.field_value?item.field_value.split(','):[]
let result_display_list = []
result_list.forEach((result0)=>{
console.log(result0)
if(item.field_choice[result0]){
result_display_list.push(item.field_choice[result0])
}
})

let display_result = result_display_list.join()
child = <div>{display_result}</div>
}else if (item.field_type_id === 60) {
//用户名
child = <div>{item.field_value}</div>
}else if (item.field_type_id === 70) {
//多选用户
child = <div>{item.field_value}</div>
}
else if (item.field_type_id === 58) {
//富文本
child = <div dangerouslySetInnerHTML={{__html: item.field_value }}/>
}


else if (item.field_type_id === 80){

child = []
const url_list = item.field_value.split()
Expand Down Expand Up @@ -463,10 +568,14 @@ class TicketDetail extends Component<TicketDetailProps, TicketDetailState> {
// child = <TextArea autoSize={{ minRows: 2, maxRows: 6 }} {...formItemChildOptions} defaultValue={item.field_value}/>
} else if (item.field_type_id === 58){
// 富文本,先以文本域代替,后续再支持
child = <TextArea autoSize={{ minRows: 2, maxRows: 6 }} {...formItemChildOptions}/>
// child = <TextArea autoSize={{ minRows: 2, maxRows: 6 }} {...formItemChildOptions}/>
child = <BraftEditor
media={{uploadFn: myUploadFn}}
/>

}
else if (item.field_type_id === 80){
// 附件
// 附件import BraftEditor from 'braft-editor'
child = <Upload action="api/v1.0/tickets/upload_file" listType="text" onChange={(info)=>this.fileChange(item.field_key, info)} fileList={this.state.fileList[item.field_key]}>
{/*child = <Upload action="api/v1.0/tickets/upload_file" listType="text" onChange={(info)=>this.fileChange(item.field_key, info)}>*/}
<Button icon={<UploadOutlined />}>Click to upload</Button>
Expand All @@ -491,6 +600,7 @@ class TicketDetail extends Component<TicketDetailProps, TicketDetailState> {
else if (item.field_type_id === 70){
// 多选用户
child = <Select
mode="multiple"
showSearch onSearch = {(search_value)=>this.userSimpleSearch(item.field_key, search_value)} filterOption={(input, option) =>
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
} {...formItemChildOptions}
Expand Down Expand Up @@ -520,6 +630,7 @@ class TicketDetail extends Component<TicketDetailProps, TicketDetailState> {
{child}
</Form.Item>
</Col>

)
}

Expand Down Expand Up @@ -552,6 +663,28 @@ class TicketDetail extends Component<TicketDetailProps, TicketDetailState> {
// 时间
values[key] = values[key].format('YYYY-MM-DD HH:mm:ss')
}
if (this.state.fieldTypeDict[key] === 40 && values[key]) {
// 多选框
console.log(values);
console.log(values[key]);
values[key] = values[key].join()
}
if (this.state.fieldTypeDict[key] === 50 && values[key]) {
// 多选下拉
values[key] = values[key].join()
}
if (this.state.fieldTypeDict[key] === 58) {
// 富文本

console.log(values[key])
values[key] = typeof(values[key])=='string'?values[key]:values[key].toHTML()

// values[key] = values[key].content.toHTML()
}
if (this.state.fieldTypeDict[key] === 70 && values[key]) {
// 多选用户
values[key] = values[key].join()
}
}

values.transition_id = transitionId;
Expand Down Expand Up @@ -726,6 +859,7 @@ class TicketDetail extends Component<TicketDetailProps, TicketDetailState> {
<Row gutter={24}>
{form_items}
</Row>

{this.state.ticketTransitionList.length !== 0 && this.props.ticketId!==0?
<Form.Item
name="suggestion"
Expand Down
18 changes: 12 additions & 6 deletions frontend/src/pages/User/User/UserList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,16 @@ class UserList extends Component<any, any> {
showEditModal = (record: any) =>{
record.is_active = record.is_active? 1: 0;
const deptInfo: Arrary = [];
record.user_dept_info_list.forEach(result =>{
deptInfo.push(String(result.id));
})
record.dept = deptInfo;
if (record.user_dept_info_list.length===0){
record.dept = []
} else {
record.user_dept_info_list.forEach(result =>{
deptInfo.push(result.id);
})
record.dept = deptInfo;
}
console.log(record);

this.setState({userDetail:record, userModalVisible:true})
}

Expand Down Expand Up @@ -334,10 +340,10 @@ class UserList extends Component<any, any> {
allowClear
style={{ width: '100%' }}
placeholder="请选择用户所在部门"
//defaultValue={['a10', 'c12']}
>
{this.state.deptResult.map(d => (
<Option key={d.id}>{d.name}</Option>

<Option key={d.id} value={d.id}>{d.name}</Option>
))}
</Select>
</Form.Item>
Expand Down
15 changes: 5 additions & 10 deletions frontend/src/pages/Workflow/WorkflowBasicInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,12 @@ const WorkflowBasicInfo = (props) => {
setWorkflowInfo(result.data);

const infoResult = result.data;
if (infoResult && infoResult['notices']){
const notices = infoResult['notices']
if (!Array.isArray(result['notices'])){
infoResult['notices'] = notices.split(',');
}
if (infoResult.notices){
infoResult['notices'] = infoResult.notices.split(',');
} else {
infoResult['notices'] = []
}
form.setFieldsValue(infoResult)




}
}

Expand Down Expand Up @@ -173,7 +168,7 @@ const WorkflowBasicInfo = (props) => {
<Col span={12} key="firstCol">
<Form.Item
name="name"
label= "名称1111"
label= "名称"
rules={[
{
required: true,
Expand Down
14 changes: 11 additions & 3 deletions frontend/src/pages/Workflow/WorkflowCustomFieldList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,26 @@ class WorkflowCustomFieldList extends Component<any, any> {
const result = this.state.customFieldDetail;

if (result && result['field_choice']) {
if (!(typeof(result['field_choice']) == "string")){
result['field_choice'] = JSON.stringify(result['field_choice'])
} else {
}
}
else {
result['field_choice'] = "{}"
}

if (result && result['boolean_field_display']) {
result['boolean_field_display'] = JSON.stringify(result['boolean_field_display'])
if (!(typeof(result['boolean_field_display']) == "string")){
result['boolean_field_display'] = JSON.stringify(result['boolean_field_display'])
}
} else {
result['boolean_field_display'] = "{}"
}

if (result && result['label']) {
result['label'] = JSON.stringify(result['label'])
if (!(typeof(result['label']) == "string")){
result['label'] = JSON.stringify(result['label'])
}
} else {
result['label'] = "{}"
}
Expand Down
12 changes: 8 additions & 4 deletions frontend/src/pages/Workflow/WorkflowState/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,17 @@ class WorkflowState extends Component<any, any> {
const result = this.state.workflowStateDetail;

if (result && result['label']) {
result['label'] = JSON.stringify(result['label'])
} else {
if (!(typeof (result['label']) == "string")) {
result['label'] = JSON.stringify(result['label'])
}
}else {
result['label'] = "{}"
}
if (result && result['state_field_str']) {
result['state_field_str'] = JSON.stringify(result['state_field_str'])
} else {
if (!(typeof (result['state_field_str']) == "string")) {
result['state_field_str'] = JSON.stringify(result['state_field_str'])
}
}else {
result['state_field_str'] = "{}"
}

Expand Down
2 changes: 1 addition & 1 deletion service/account/account_base_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ def edit_user(cls, user_id: int, username: str, alias: str, email: str, phone: s
dept_id_str_list = dept_ids.split(',')
dept_id_int_list = [int(dept_id_str) for dept_id_str in dept_id_str_list]
user_id = user_obj.first().id
user_dept_queryset = LoonUserDept.objects.filter(user_id=user_id, dept_id__in=dept_id_int_list, is_deleted=0).all()
user_dept_queryset = LoonUserDept.objects.filter(user_id=user_id, is_deleted=0).all()
user_dept_id_exist = [user_dept.dept_id for user_dept in user_dept_queryset]

need_add_list = [dept_id_int for dept_id_int in dept_id_int_list if dept_id_int not in user_dept_id_exist]
Expand Down
2 changes: 1 addition & 1 deletion settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import platform


VERSION = '2.0.4'
VERSION = '2.0.5'

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
Expand Down
12 changes: 12 additions & 0 deletions sphinx_docs/source/others/release_note.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
发布说明
==============


---------
r2.0.5
---------
- 修复:【管理后台】工作流编辑时选择通知的回显异常问题
- 修复:【管理后台】工作流状态流转等多次编辑时json被重复转换导致内容异常问题
- 修复:【管理后台】用户所属部门无法被删除问题
- 修复:【工单详情】多选类型字段无法提交问题
- 修复:【管理后台】选择类型字段只读状态显示异常问题
- 新增:【工单详情】新增支持富文本的显示及回显
- 优化:【API】工单列表中工单处理人为多人时的性能优化

---------
r2.0.4
---------
Expand Down

0 comments on commit d2682a7

Please sign in to comment.