Commit 4f76d27a authored by 王珂's avatar 王珂

修改电力设备bug

parent c4a2063b
...@@ -4,7 +4,7 @@ import SysConsts from 'amos-processor/lib/config/consts'; ...@@ -4,7 +4,7 @@ import SysConsts from 'amos-processor/lib/config/consts';
import formatUrl from 'amos-processor/lib/utils/urlFormat'; import formatUrl from 'amos-processor/lib/utils/urlFormat';
import * as endConf from 'amos-processor/lib/config/endconf'; import * as endConf from 'amos-processor/lib/config/endconf';
import { FasSerUrl } from '../../../../consts/urlConsts'; import { FasSerUrl } from '../../../../consts/urlConsts';
import { Form, Upload, Input, Select, Radio, Modal, AmosAlert, Icon } from 'amos-framework'; import { Form, Upload, Input, Select, Radio, Modal, AmosAlert, Icon, Toast } from 'amos-framework';
import { TreeSelect } from 'amos-antd'; import { TreeSelect } from 'amos-antd';
import PropTypes from 'amos-react-router/lib/PropTypes'; import PropTypes from 'amos-react-router/lib/PropTypes';
import { getEquipmentDataAction, getFireStationDataAction, getPrePlanPictureAction } from '../../../../services/ledgerService'; import { getEquipmentDataAction, getFireStationDataAction, getPrePlanPictureAction } from '../../../../services/ledgerService';
...@@ -109,6 +109,16 @@ class EquipmentModel extends Component { ...@@ -109,6 +109,16 @@ class EquipmentModel extends Component {
onInputChange = (key, value) => { onInputChange = (key, value) => {
const { form } = this.state; const { form } = this.state;
let reg = /[\u4E00-\u9FA5]/g;
if (key === 'code') {
if (reg.test(value)) {
Toast.open({
content: '编码不能输入汉字',
placement: 'topMiddle'
});
return;
}
}
form[key] = value.trim(); form[key] = value.trim();
this.setState({ form }); this.setState({ form });
}; };
...@@ -162,6 +172,7 @@ class EquipmentModel extends Component { ...@@ -162,6 +172,7 @@ class EquipmentModel extends Component {
getPrePlanPictureData = equipmentId => { getPrePlanPictureData = equipmentId => {
getPrePlanPictureAction(equipmentId, '').then(data => { getPrePlanPictureAction(equipmentId, '').then(data => {
let pMap = new Map(); let pMap = new Map();
console.log(data);
data.forEach(ele => { data.forEach(ele => {
let type = ele.type; let type = ele.type;
if (type >= 1 && type <= 4) { if (type >= 1 && type <= 4) {
......
...@@ -108,33 +108,33 @@ class MatchEquipment extends Component { ...@@ -108,33 +108,33 @@ class MatchEquipment extends Component {
componentDidMount() { componentDidMount() {
if (this.props.location.state) { if (this.props.location.state) {
let { equipmentId, show } = this.props.location.state; let { equipmentId, show } = this.props.location.state;
if(equipmentId===undefined){ if (equipmentId === undefined){
equipmentId = this.props.location.query.equipmentId equipmentId = this.props.location.query.equipmentId;
this.setState({ equipmentId:equipmentId }); this.setState({ equipmentId });
} }
let { searchParam } = this.state; let { searchParam } = this.state;
searchParam.pageNumber = 0; searchParam.pageNumber = 0;
searchParam.pageSize = 10; searchParam.pageSize = 10;
if (equipmentId) { if (equipmentId) {
this.getEquipmentData(equipmentId); this.getEquipmentData(equipmentId);
this.setState({equipmentId},()=>this.getMatchEquipmentListData(searchParam)); this.setState({ equipmentId },()=>this.getMatchEquipmentListData(searchParam));
this.setState({equipmentId},()=>this.getPrePlanPictureData()); this.setState({ equipmentId },()=>this.getPrePlanPictureData());
} }
if (void 0 !== show) { if (void 0 !== show) {
this.setState({ show }); this.setState({ show });
} }
} }
//兼容url直接请求 //兼容url直接请求
if(this.props.location.query){ if (this.props.location.query){
let { equipmentId } = this.props.location.query; let { equipmentId } = this.props.location.query;
let { searchParam } = this.state; let { searchParam } = this.state;
searchParam.pageNumber = 0; searchParam.pageNumber = 0;
searchParam.pageSize = 10; searchParam.pageSize = 10;
if (equipmentId) { if (equipmentId) {
this.getEquipmentData(equipmentId); this.getEquipmentData(equipmentId);
this.setState({equipmentId},()=>this.getMatchEquipmentListData(searchParam)); this.setState({ equipmentId },()=>this.getMatchEquipmentListData(searchParam));
this.setState({equipmentId},()=>this.getPrePlanPictureData()); this.setState({ equipmentId },()=>this.getPrePlanPictureData());
this.setState({ equipmentId:equipmentId }); this.setState({ equipmentId });
} }
} }
} }
......
...@@ -104,14 +104,17 @@ class Equipment extends Component { ...@@ -104,14 +104,17 @@ class Equipment extends Component {
} }
onChange(type, value) { onChange(type, value) {
let val = value.trim();
if (type === 'name') { if (type === 'name') {
this.setState({ name: value }); this.setState({ name: val });
} else { } else {
this.setState({ equipClassify: value }); this.setState({ equipClassify: val });
}
if (val) {
let searchParam = [{ name: type, value: val, type: 'LIKE' }];
searchParam.current = 0;
this.getEquipmentListData(searchParam);
} }
let searchParam = [{ name: type, value, type: 'LIKE' }];
searchParam.current = 0;
this.getEquipmentListData(searchParam);
} }
onRowClick = record => { onRowClick = record => {
...@@ -263,67 +266,67 @@ class Equipment extends Component { ...@@ -263,67 +266,67 @@ class Equipment extends Component {
submit = (e) => { submit = (e) => {
let { form } = this.model; let { form } = this.model;
const { isClick } = this.state const { isClick } = this.state;
if (isClick) {   //如果为true 开始执行 if (isClick) {   //如果为true 开始执行
this.setState({ isClick: false });  //将isClick 变成false,将不会执行处理事件 this.setState({ isClick: false });  //将isClick 变成false,将不会执行处理事件
form.validate((valid, dataValues) => { form.validate((valid, dataValues) => {
if (valid) { if (valid) {
delete dataValues.createDate; delete dataValues.createDate;
let formData = new FormData(); let formData = new FormData();
dataValues.imageUrl1 && formData.append('img1', dataValues.imageUrl1[0]); dataValues.imageUrl1 && formData.append('img1', dataValues.imageUrl1[0]);
dataValues.imageUrl2 && formData.append('img2', dataValues.imageUrl2[0]); dataValues.imageUrl2 && formData.append('img2', dataValues.imageUrl2[0]);
dataValues.imageUrl3 && formData.append('img3', dataValues.imageUrl3[0]); dataValues.imageUrl3 && formData.append('img3', dataValues.imageUrl3[0]);
dataValues.imageUrl4 && formData.append('img4', dataValues.imageUrl4[0]); dataValues.imageUrl4 && formData.append('img4', dataValues.imageUrl4[0]);
if (dataValues) { if (dataValues) {
for (var key in dataValues) { for (var key in dataValues) {
if (dataValues[key] == null || typeof(dataValues[key]) == "undefined") { if (dataValues[key] == null || typeof dataValues[key] == 'undefined') {
delete dataValues[key]; delete dataValues[key];
}
} }
} }
}
Object.keys(dataValues).map(item => { Object.keys(dataValues).map(item => {
if (item === 'chargeDeptId' && dataValues[item] === null) { if (item === 'chargeDeptId' && dataValues[item] === null) {
formData.append(item, -1); formData.append(item, -1);
} else if (item === 'chargeUserId' && dataValues[item] === null) { } else if (item === 'chargeUserId' && dataValues[item] === null) {
formData.append(item, -1); formData.append(item, -1);
} else if (item === 'fireStationId' && dataValues[item] === null) { } else if (item === 'fireStationId' && dataValues[item] === null) {
formData.append(item, -1); formData.append(item, -1);
} else { } else {
formData.append(item, dataValues[item]); formData.append(item, dataValues[item]);
} }
});
fetch(updateEquipmentUrl, {
method: 'post',
headers: {
'Accept': 'application/json;charset=UTF-8',
'X-Api-Key': _amosTool.Store.getCookieByName(apiKey),
'X-Access-Token': ls.read(token),
'appKey': window.appKey ,
'product': window.product,
'token': ls.read(token)
},
body: formData
}).then(e => {
AmosAlert.success('提示', '保存成功');
this.state.reload();
this.setState({
enableEditOp: false
}); });
fetch(updateEquipmentUrl, { })
method: 'post',
headers: {
'Accept': 'application/json;charset=UTF-8',
'X-Api-Key': _amosTool.Store.getCookieByName(apiKey),
'X-Access-Token': ls.read(token),
'appKey': window.appKey ,
'product': window.product,
'token':ls.read(token)
},
body: formData
}).then(e => {
AmosAlert.success('提示', '保存成功');
this.state.reload();
this.setState({
enableEditOp: false
});
})
.catch(e => { .catch(e => {
AmosAlert.error('错误', '保存失败'); AmosAlert.error('错误', '保存失败');
}); });
} else { } else {
console.log('error submit!!'); console.log('error submit!!');
return false; return false;
} }
}); });
const that = this;   // 为定时器中的setState绑定this const that = this;   // 为定时器中的setState绑定this
setTimeout(function () {       // 设置延迟事件,1秒后将执行 setTimeout(() => {       // 设置延迟事件,1秒后将执行
that.setState({ isClick: true });   // 将isClick设置为true that.setState({ isClick: true });   // 将isClick设置为true
}, 5000); }, 5000);
} }
...@@ -340,7 +343,7 @@ class Equipment extends Component { ...@@ -340,7 +343,7 @@ class Equipment extends Component {
</div> </div>
<div className='important-equipment-tools'> <div className='important-equipment-tools'>
<span>搜索:</span> <span>搜索:</span>
<Input value={name} onChange={e => this.onChange('name', e.target.value)} placeholder="按编号,名称搜索"/> <Input value={name} onChange={e => this.onChange('name', e.target.value)} placeholder="按编号,名称搜索" />
<Button icon={<BizIcon icon="tianjia" />} transparent onClick={() => this.add()} /> <Button icon={<BizIcon icon="tianjia" />} transparent onClick={() => this.add()} />
<Button icon={<BizIcon icon="xiugai" />} transparent onClick={() => this.edit()} /> <Button icon={<BizIcon icon="xiugai" />} transparent onClick={() => this.edit()} />
<Button icon={<BizIcon icon="shanchu" />} transparent onClick={() => this.delete()} /> <Button icon={<BizIcon icon="shanchu" />} transparent onClick={() => this.delete()} />
......
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