Commit de5d7abd by 万亚飞

fix bug

parent 81bf0869
...@@ -12,6 +12,7 @@ module.exports = { ...@@ -12,6 +12,7 @@ module.exports = {
vendor: ['react', 'better-scroll', 'react-redux', 'react-lazyload'] vendor: ['react', 'better-scroll', 'react-redux', 'react-lazyload']
}, },
output: { output: {
publicPath: '/',
filename: '[name].[hash:8].js', filename: '[name].[hash:8].js',
path: resolve(__dirname, '../build') path: resolve(__dirname, '../build')
}, },
...@@ -109,6 +110,7 @@ module.exports = { ...@@ -109,6 +110,7 @@ module.exports = {
devServer: { devServer: {
contentBase: '../build', contentBase: '../build',
host: '0.0.0.0', host: '0.0.0.0',
historyApiFallback: true,
open: true, open: true,
port: 5000, port: 5000,
hot: true hot: true
......
...@@ -18,6 +18,7 @@ module.exports = { ...@@ -18,6 +18,7 @@ module.exports = {
vendor: ['react'] vendor: ['react']
}, },
output: { output: {
publicPath: '/',
filename: '[name].[contenthash:8].js', filename: '[name].[contenthash:8].js',
path: resolve(__dirname, '../dist') path: resolve(__dirname, '../dist')
}, },
......
...@@ -49,11 +49,13 @@ class App extends React.Component { ...@@ -49,11 +49,13 @@ class App extends React.Component {
<div className="container"> <div className="container">
<div className="page-content"> <div className="page-content">
<Switch> <Switch>
<Route path={['/user/job/add', '/user/job/:id']} component={AddMaterial} /> <Route path="/user/job/add" key="add-job" component={AddMaterial} />
<Route path="/user/job/:id" key="edit-job" component={AddMaterial} />
<Route path="/user/job" component={JobList} /> <Route path="/user/job" component={JobList} />
<Route path={['/user/train/add', '/user/train/:id']} component={Train} /> <Route path="/user/train/add" key="add-train" component={Train} />
<Route path="/user/train/:id" key="edit-train" component={Train} />
<Route path="/user/train" component={TrainList} /> <Route path="/user/train" component={TrainList} />
<Route path="*" component={JobList} /> <Route component={JobList} />
</Switch> </Switch>
</div> </div>
</div> </div>
......
...@@ -8,10 +8,10 @@ import { Provider } from 'react-redux'; ...@@ -8,10 +8,10 @@ import { Provider } from 'react-redux';
// import './assets/index.less'; // import './assets/index.less';
import './static/styles/global.less'; import './static/styles/global.less';
ReactDOM.render( ReactDOM.render(
<HashRouter basename="/new"> <BrowserRouter basename="/new">
<Provider store={store}> <Provider store={store}>
<App /> <App />
</Provider> </Provider>
</HashRouter>, </BrowserRouter>,
document.querySelector('#root') document.querySelector('#root')
); );
...@@ -36,8 +36,8 @@ function ListItemView(props) { ...@@ -36,8 +36,8 @@ function ListItemView(props) {
return ( return (
<React.Fragment> <React.Fragment>
<ul className="train-list"> <ul className="train-list">
{props.dataArr.map(item => ( {props.dataArr.map((item, index) => (
<TrainItem iType={props.tabIndex} key={item.id} data={item} delToggle={props.delTrain} /> <TrainItem iType={props.tabIndex} key={index} data={item} delToggle={props.delTrain} />
))} ))}
</ul> </ul>
<AddView tabIndex={props.tabIndex} /> <AddView tabIndex={props.tabIndex} />
...@@ -64,6 +64,7 @@ class JobList extends Component { ...@@ -64,6 +64,7 @@ class JobList extends Component {
}; };
} }
componentWillMount() { componentWillMount() {
document.title = '职业背景';
this.setState({ this.setState({
tabIndex: parseInt(getParameterByName('index', location.href)) || 0 tabIndex: parseInt(getParameterByName('index', location.href)) || 0
}); });
......
...@@ -23,6 +23,8 @@ class Train extends Component { ...@@ -23,6 +23,8 @@ class Train extends Component {
imgUrls: [], imgUrls: [],
certificateFiles: [], certificateFiles: [],
viewImages: [], viewImages: [],
isEdit: false, //是否是编辑
hasChange: false, //是否编辑过
modifyId: null modifyId: null
}; };
//初始化图片 //初始化图片
...@@ -55,8 +57,10 @@ class Train extends Component { ...@@ -55,8 +57,10 @@ class Train extends Component {
this.setState({ this.setState({
[name]: value [name]: value
}); });
this.hansChangeForm();
}; };
componentDidMount() { componentDidMount() {
document.title = '受训背景';
app().downRefresh(false); app().downRefresh(false);
app().notRefresh(false); app().notRefresh(false);
const id = getParam(location.href); const id = getParam(location.href);
...@@ -98,6 +102,7 @@ class Train extends Component { ...@@ -98,6 +102,7 @@ class Train extends Component {
this.setState({ this.setState({
[name]: date [name]: date
}); });
this.hansChangeForm();
}; };
refreshFile = res => { refreshFile = res => {
if (res.code >= 0) { if (res.code >= 0) {
...@@ -109,6 +114,7 @@ class Train extends Component { ...@@ -109,6 +114,7 @@ class Train extends Component {
this.initImgs(this.state.imgUrls); this.initImgs(this.state.imgUrls);
} }
); );
this.hansChangeForm();
} else { } else {
Toast.info('上传图片失败,请重试', 2); Toast.info('上传图片失败,请重试', 2);
} }
...@@ -167,10 +173,14 @@ class Train extends Component { ...@@ -167,10 +173,14 @@ class Train extends Component {
} }
]); ]);
}; };
hansChangeForm = () => {
this.setState({ hasChange: true });
};
delFile = () => { delFile = () => {
this.setState({ this.setState({
certificateFiles: [] certificateFiles: []
}); });
this.hansChangeForm();
}; };
render() { render() {
const { startTime, endTime, backgroundArea, certificateFiles, viewImages } = this.state; const { startTime, endTime, backgroundArea, certificateFiles, viewImages } = this.state;
...@@ -201,7 +211,7 @@ class Train extends Component { ...@@ -201,7 +211,7 @@ class Train extends Component {
<UpLoad certificateFiles={certificateFiles} viewImages={viewImages} refresh={this.refreshFile} delFile={this.delFile} /> <UpLoad certificateFiles={certificateFiles} viewImages={viewImages} refresh={this.refreshFile} delFile={this.delFile} />
</div> </div>
<div className="bottom-operate"> <div className="bottom-operate">
<button onClick={this.submitTrain} className="am-button am-button-primary"> <button disabled={this.state.isEdit && !this.state.hasChange} onClick={this.submitTrain} className="am-button am-button-primary">
提交 提交
</button> </button>
</div> </div>
......
...@@ -19,6 +19,7 @@ class TrainList extends Component { ...@@ -19,6 +19,7 @@ class TrainList extends Component {
} }
}; };
componentDidMount() { componentDidMount() {
document.title = '受训背景';
app().downRefresh(true); app().downRefresh(true);
app().notRefresh(true); app().notRefresh(true);
const userInfo = storage.getSS('urlQuery'); const userInfo = storage.getSS('urlQuery');
......
...@@ -20,6 +20,7 @@ class AddMaterial extends Component { ...@@ -20,6 +20,7 @@ class AddMaterial extends Component {
certificateFiles: [], certificateFiles: [],
viewImages: [], viewImages: [],
isEdit: false, //是否是编辑 isEdit: false, //是否是编辑
hasChange: false, //是否编辑过
isShowRange: false, isShowRange: false,
modifyId: null, modifyId: null,
id: null id: null
...@@ -34,7 +35,7 @@ class AddMaterial extends Component { ...@@ -34,7 +35,7 @@ class AddMaterial extends Component {
if (index > 2 || index === null) { if (index > 2 || index === null) {
return Toast.info('路径有误'); return Toast.info('路径有误');
} }
console.log(modifyId, modifyId !== null); document.title = MATERIAL_ARR[index];
this.setState({ this.setState({
isEdit: modifyId !== null, isEdit: modifyId !== null,
materialType: index, materialType: index,
...@@ -91,6 +92,8 @@ class AddMaterial extends Component { ...@@ -91,6 +92,8 @@ class AddMaterial extends Component {
this.setState({ this.setState({
[name]: value [name]: value
}); });
this.hansChangeForm();
}; };
refreshFile = res => { refreshFile = res => {
if (res.code >= 0) { if (res.code >= 0) {
...@@ -102,6 +105,7 @@ class AddMaterial extends Component { ...@@ -102,6 +105,7 @@ class AddMaterial extends Component {
this.initImgs(this.state.imgUrls); this.initImgs(this.state.imgUrls);
} }
); );
this.hansChangeForm();
} else { } else {
Toast.info('上传图片失败,请重试', 2); Toast.info('上传图片失败,请重试', 2);
} }
...@@ -111,6 +115,7 @@ class AddMaterial extends Component { ...@@ -111,6 +115,7 @@ class AddMaterial extends Component {
this.setState({ this.setState({
certificateFiles: [] certificateFiles: []
}); });
this.hansChangeForm();
}; };
validateForm = () => { validateForm = () => {
if (!this.state.backgroundArea) { if (!this.state.backgroundArea) {
...@@ -118,6 +123,10 @@ class AddMaterial extends Component { ...@@ -118,6 +123,10 @@ class AddMaterial extends Component {
} }
return true; return true;
}; };
hansChangeForm = () => {
this.setState({ hasChange: true });
};
toggleRange = () => { toggleRange = () => {
this.setState({ this.setState({
isShowRange: !this.state.isShowRange isShowRange: !this.state.isShowRange
...@@ -188,7 +197,7 @@ class AddMaterial extends Component { ...@@ -188,7 +197,7 @@ class AddMaterial extends Component {
<UpLoad certificateFiles={certificateFiles} viewImages={viewImages} refresh={this.refreshFile} delFile={this.delFile} /> <UpLoad certificateFiles={certificateFiles} viewImages={viewImages} refresh={this.refreshFile} delFile={this.delFile} />
</div> </div>
<div className="bottom-operate"> <div className="bottom-operate">
<button onClick={this.submitJob} className="am-button am-button-primary"> <button disabled={this.state.isEdit && !this.state.hasChange} onClick={this.submitJob} className="am-button am-button-primary">
提交 提交
</button> </button>
</div> </div>
......
...@@ -927,6 +927,12 @@ textarea::placeholder { ...@@ -927,6 +927,12 @@ textarea::placeholder {
height: 45px; height: 45px;
line-height: 45px; line-height: 45px;
} }
.am-button[disabled] {
background-color: #ddd;
&::before {
border: 1px solid #ddd !important;
}
}
.deposit-user .my-list .am-list-item .am-list-line .am-list-content, .deposit-user .my-list .am-list-item .am-list-line .am-list-content,
.am-list-item .am-list-line .am-list-extra { .am-list-item .am-list-line .am-list-extra {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment