This commit is contained in:
caishi 2023-03-10 14:23:17 +08:00
parent c5b465989c
commit 7238b387b4
3 changed files with 18 additions and 14 deletions

View File

@ -1,4 +1,4 @@
import React , { useState } from 'react';
import React , { useState , useEffect } from 'react';
import { Form , Input, Button } from 'antd';
import ColorCard from './colorCard';
import axios from 'axios';
@ -6,7 +6,12 @@ import axios from 'axios';
function AddTagsBox({onSuccess , form ,owner , projectsId,onCancel}){
const { getFieldDecorator , getFieldsValue , validateFields } = form;
const [ colors , setColors ] = useState(undefined);
// const [ defaultColor , setDefaultColor ]= useState("#F17013");
const [ defaultColor , setDefaultColor ]= useState(undefined);
useEffect(()=>{
const c = Math.random().toString(16).substr(-6);
c && setDefaultColor(`#${c}`);
},[])
function saveFunc(){
validateFields((error,values)=>{
@ -14,7 +19,7 @@ function AddTagsBox({onSuccess , form ,owner , projectsId,onCancel}){
const { desc , name } = getFieldsValue();
const url = `/v1/${owner}/${projectsId}/issue_tags`;
axios.post(url,{
name,description:desc,color:colors
name,description:desc,color:colors || defaultColor
}).then(result=>{
result && onSuccess();
}).catch(error=>{})
@ -42,7 +47,7 @@ function AddTagsBox({onSuccess , form ,owner , projectsId,onCancel}){
})(<Input placeholder="标记名称15字以内" maxLength={15}/>)}
</Form.Item>
<Form.Item style={{marginTop:"7px"}}>
<ColorCard getColor={getColor}/>
<ColorCard getColor={getColor} defaultColor={defaultColor}/>
</Form.Item>
</div>
<Form.Item colon={false}>

View File

@ -3,24 +3,17 @@ import { SketchPicker } from 'react-color';
function ColorCard({getColor,defaultColor}){
const [ displayColorPicker , setDisplayColorPicker ] = useState(false);
// const [ color , setColor ] = useState({r: '241',g: '112',b: '19',a: '1',});
const [ textcolor , setTextColor ] = useState("#F17013");
useEffect(()=>{
const c = Math.random().toString(16).substr(-6);
c && setTextColor(`#${c}`);
getColor(`#${c}`);
},[])
useEffect(()=>{
if(defaultColor){
setTextColor(defaultColor);
getColor(defaultColor);
}
},[defaultColor])
//
function handleChange(color){
// setColor(color.rgb);
setTextColor(color.hex);
getColor(color ? color.hex : defaultColor);
}

View File

@ -20,7 +20,7 @@ function Sign(props){
const [ order_name , setOrderName ] = useState(undefined);
const [ order_type , setOrderType ] = useState(undefined);
const [ nameFlag , setNameFlag ] = useState(undefined);
const [ defaultColor , setDefaultColor ]= useState("#F17013");
const [ defaultColor , setDefaultColor ]= useState(undefined);
const [ arrayName , setArrayName ] = useState("标记");
const [ key , setKey ] = useState("0");
@ -183,6 +183,12 @@ function Sign(props){
setNameFlag(true);
}
}
function createSign(){
const c = Math.random().toString(16).substr(-6);
c && setDefaultColor(`#${c}`);
setEdit(true);
}
return(
<div>
<DelBox
@ -194,7 +200,7 @@ function Sign(props){
/>
<div className="between mt30 mb25">
<span><Link to={`/${owner}/${projectsId}/issues`}>疑修</Link> / 项目标记</span>
<a className="operateButton" onClick={()=>setEdit(true)}><img src={create} alt="" className="mr5"/>创建标记</a>
<a className="operateButton" onClick={createSign}><img src={create} alt="" className="mr5"/>创建标记</a>
</div>
{
edit &&