From 363bae0882830bcac76ce25c16607c4f4f1d6708 Mon Sep 17 00:00:00 2001 From: tiansuyan Date: Sat, 28 Oct 2017 11:08:51 +0800 Subject: [PATCH 001/223] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/project.config.js | 9 +-- src/components/DictSetting/DictSettingGrid.js | 68 ++++++++++--------- 2 files changed, 42 insertions(+), 35 deletions(-) diff --git a/config/project.config.js b/config/project.config.js index 81c039a..0c3c7c5 100644 --- a/config/project.config.js +++ b/config/project.config.js @@ -32,14 +32,15 @@ const config = { server_host : ip.address(), // use string 'localhost' to prevent exposure on local network server_port : process.env.PORT || 3000, - service_api: process.env.SERVICE_API || 'http://10.1.10.15:8770/v1/', // 测试接口 - websocket_api: process.env.WEBSOCKET_API || 'ws://10.1.10.15:8085/v1/', // 时序数据websocke请求接口 + // service_api: process.env.SERVICE_API || 'http://10.1.10.15:8770/v1/', // 测试接口 + // websocket_api: process.env.WEBSOCKET_API || 'ws://10.1.10.15:8085/v1/', // 时序数据websocke请求接口 // kmax_api: process.env.KMX_API || 'http://192.168.130.62:28089/data-service/v4/', // 历史数据请求接口 // kmx_real_time_api: process.env.KMX_REAL_TIME_API || 'http://192.168.130.62:28082/data-service/v4/', // 实时数据接口 - + // specific_api: process.env.SPE_API || 'http://10.1.10.54:8090/', // 特征图谱接口 + service_api: process.env.SERVICE_API || 'http://117.39.60.34:8770/v1/', // 测试接口 kmax_api: process.env.KMX_API || 'http://117.39.60.34:28089/data-service/v4/', // 历史数据请求接口 kmx_real_time_api: process.env.KMX_REAL_TIME_API || 'http://117.39.60.34:28082/data-service/v4/', // 实时数据接口 - specific_api: process.env.SPE_API || 'http://10.1.10.54:8090/', // 特征图谱接口 + specific_api: process.env.SPE_API || 'http://117.39.60.34:8090/', // 特征图谱接口 // ---------------------------------- // Compiler Configuration diff --git a/src/components/DictSetting/DictSettingGrid.js b/src/components/DictSetting/DictSettingGrid.js index 42ecf8e..6adeaa1 100644 --- a/src/components/DictSetting/DictSettingGrid.js +++ b/src/components/DictSetting/DictSettingGrid.js @@ -8,11 +8,15 @@ import universalFetch, { handleFetchError } from 'store/modules/fetch' type Props = { history: Object, - pageSize: number + pageSize: number, + current: number, + total: number, + rowData: Array, + getData: Function } type States = { - columnDefs: Array, rowData: Array, + columnDefs: Array, total: number, current: number } @@ -26,37 +30,45 @@ class DictSettingGrid extends Component { constructor (props: Props) { super(props) this.state = { + rowData: [], columnDefs: [ { - headerName: 'label', + headerName: '显示名称', field: 'label', cellStyle: { 'padding': '8px' } }, { - headerName: 'value', + headerName: '回填内容', field: 'value', cellStyle: { padding: '8px' } }, { - headerName: 'type', + headerName: '字典类型', field: 'type', cellStyle: { padding: '8px' } }, { - headerName: 'ext', + headerName: '类型描述', + field: 'typeCn', + cellStyle: { + padding: '8px' + } + }, + { + headerName: '扩展属性', field: 'ext', cellStyle: { padding: '8px' } }, { - headerName: 'sort', + headerName: '显示顺序', field: 'sort', cellStyle: { padding: '8px' @@ -75,8 +87,7 @@ class DictSettingGrid extends Component { } } ], - rowData: [], - total: 0, + total: 1, current: 1 } this.gridOptions = { @@ -92,33 +103,26 @@ class DictSettingGrid extends Component { this.getDictSetting = this.getDictSetting.bind(this) } + componentWillReceiveProps (nextProps: Object) { + this.setState({ + total: nextProps.total, + current: nextProps.current, + rowData: nextProps.rowData + }) + } + + // componentDidMount () { + // const { pageSize } = this.props + // this.getDictSetting(1, pageSize) + // } + onGridReady (params: Object) { this.api = params.api this.api.sizeColumnsToFit() } - componentDidMount () { - const { pageSize } = this.props - this.getDictSetting(1, pageSize) - } - getDictSetting (page: number, pageSize: number) { - universalFetch(`${__SERVICE_API__}sys/dicts?pageNum=${page}&pageSize=${pageSize}`) - .then(res => res.json()) - .then((json) => { - if (json.code !== 200000) { - throw new Error(JSON.stringify({ code: json.code, message: json.message })) - } - this.setState({ - current: page, - total: json.pageInfo.total, - rowData: json.result - }) - }) - .catch((error) => { - handleFetchError(error) - console.error(error) - }) + this.props.getData(page, pageSize) } render () { const { columnDefs, rowData, current, total } = this.state @@ -134,7 +138,9 @@ class DictSettingGrid extends Component { onGridReady: this.onGridReady }} /> - + ) } -- Gitee From 082f679617c6c3f90a0d76be3f6f368aa50b336c Mon Sep 17 00:00:00 2001 From: Tiansuyan Date: Fri, 3 Nov 2017 18:42:00 +0800 Subject: [PATCH 002/223] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=A4=9A=E4=B8=AA=E8=81=94=E7=B3=BB=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/project.config.js | 4 +- src/components/Bode/Bode.js | 13 +- .../CustomerContactList/AddContact.js | 179 +++++++++++++++ .../ContactList.css | 0 .../ContactList.js | 0 .../CustomerContactList/EditContact.js | 204 ++++++++++++++++++ .../index.js | 0 src/components/CustomerEdit/CustomerEdit.js | 136 +++++++----- src/components/CustomersAdd/CustomersAdd.js | 91 ++++---- .../AddContact.js | 0 .../DeviceContactList/ContactList.css | 35 +++ .../DeviceContactList/ContactList.js | 156 ++++++++++++++ .../EditContact.js | 0 src/components/DeviceContactList/index.js | 3 + src/components/HistoryLine/HistoryLine.js | 1 + src/routes/Business/components/DeviceAdd.js | 6 +- src/routes/Business/components/DeviceEdit.js | 6 +- 17 files changed, 724 insertions(+), 110 deletions(-) create mode 100644 src/components/CustomerContactList/AddContact.js rename src/components/{ContactList => CustomerContactList}/ContactList.css (100%) rename src/components/{ContactList => CustomerContactList}/ContactList.js (100%) create mode 100644 src/components/CustomerContactList/EditContact.js rename src/components/{ContactList => CustomerContactList}/index.js (100%) rename src/components/{ContactList => DeviceContactList}/AddContact.js (100%) create mode 100644 src/components/DeviceContactList/ContactList.css create mode 100644 src/components/DeviceContactList/ContactList.js rename src/components/{ContactList => DeviceContactList}/EditContact.js (100%) create mode 100644 src/components/DeviceContactList/index.js diff --git a/config/project.config.js b/config/project.config.js index 81c039a..b10c19b 100644 --- a/config/project.config.js +++ b/config/project.config.js @@ -37,8 +37,8 @@ const config = { // kmax_api: process.env.KMX_API || 'http://192.168.130.62:28089/data-service/v4/', // 历史数据请求接口 // kmx_real_time_api: process.env.KMX_REAL_TIME_API || 'http://192.168.130.62:28082/data-service/v4/', // 实时数据接口 - kmax_api: process.env.KMX_API || 'http://117.39.60.34:28089/data-service/v4/', // 历史数据请求接口 - kmx_real_time_api: process.env.KMX_REAL_TIME_API || 'http://117.39.60.34:28082/data-service/v4/', // 实时数据接口 + kmax_api: process.env.KMX_API || 'http://117.39.60.34:81/kmx/v4/data/', // 历史数据请求接口 + kmx_real_time_api: process.env.KMX_REAL_TIME_API || 'http://117.39.60.34:81/kmx/v4/data/real/', // 实时数据接口 specific_api: process.env.SPE_API || 'http://10.1.10.54:8090/', // 特征图谱接口 // ---------------------------------- diff --git a/src/components/Bode/Bode.js b/src/components/Bode/Bode.js index 98de31e..cee4722 100644 --- a/src/components/Bode/Bode.js +++ b/src/components/Bode/Bode.js @@ -128,14 +128,12 @@ class Bode extends Component { // 伯德图选择的通道数组 getBodeChannelIds (values) { - console.log(values); this.setState({ bodeChannelIds: values }) } getBodeData () { - console.log('执行取值3----------(共3)'); const { bodeData } = this.state const component = this fetch(`${__SPE_API__}api/bode`, { @@ -148,8 +146,6 @@ class Bode extends Component { }) .then(res => res.json()) .then((json) => { - console.log('3的结果'); - console.log(json); this.setState({ finalData: json }, () => { @@ -245,7 +241,6 @@ class Bode extends Component { this.draw(bodeCharts) } getDynamicData () { - console.log('执行取值--------2(共3)'); this.setState({ loading: true }) @@ -261,7 +256,8 @@ class Bode extends Component { return } const postBody = JSON.stringify({ - fieldGroup: fieldGroup[0].En, + // fieldGroup: fieldGroup[0].En, + fieldGroup: 'c_vib', fields: ['speed', 'dyna_value'], // fields: ['speed', 'dyna_value', 'average', 'direc'], coValueFilter: { @@ -305,7 +301,6 @@ class Bode extends Component { throw new Error(JSON.stringify({ code: json.code, message: json.message })) } const results = json.results - console.log('2的结果'); if (results && results[0].streams.length > 0) { const speed = results[0].streams.map((d, i) => { return d[1] @@ -464,7 +459,6 @@ class Bode extends Component { } refreDraw () { - console.log('执行取值--------1(共3)'); this.setState({ btnValue: '1' }) @@ -491,7 +485,8 @@ class Bode extends Component { return } const postBody = JSON.stringify({ - fieldGroup: fieldGroup[0].En, + // fieldGroup: fieldGroup[0].En, + fieldGroup: 'c_vib', fields: ['speed', 'direc', 'v1x', 'p1x'], // fields: ['speed', 'dyna_value', 'average', 'direc'], // sampleTime: this.props.checkTime, diff --git a/src/components/CustomerContactList/AddContact.js b/src/components/CustomerContactList/AddContact.js new file mode 100644 index 0000000..4b8231e --- /dev/null +++ b/src/components/CustomerContactList/AddContact.js @@ -0,0 +1,179 @@ +// @flow +import React, { Component } from 'react' +import { Modal, Form, Input, Row, Col, Switch } from 'antd' +// const Option = Select.Option +import R from 'ramda' +// import universalFetch, { handleFetchError } from 'store/modules/fetch' +const FormItem = Form.Item +const formItemLayout = { + labelCol: { + xs: { span: 24 }, + sm: { span: 6 } + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 14 } + } +} + +type Props = { + form: Object, + removeNode: Function, + index: number, + changeContact: Function, + contactData: Array +} + +type States = { + visible: boolean, + confirmLoading: boolean +} +class EditContact extends Component { + props: Props + state: States + closeModal: Function + handleSubmit: Function + constructor (props: Props) { + super(props) + this.state = { + visible: true, + confirmLoading: false + } + this.closeModal = this.closeModal.bind(this) + this.handleSubmit = this.handleSubmit.bind(this) + } + + closeModal () { + this.setState({ + visible: false + }) + this.props.removeNode() + } + + handleSubmit () { + const form = this.props.form + form.validateFields((err, fieldsValue) => { + if (err) { + return false + } + this.setState({ + confirmLoading: true + }) + const { index, contactData } = this.props + let importance = 'secondary' + if (fieldsValue.importance) { + importance = 'primary' + } + const values = { + ...fieldsValue, + importance: importance + } + if (importance === 'primary') { + contactData.map((d) => { + d['importance'] = 'secondary' + }) + } + let arr = R.clone(contactData) + arr[index] = values + this.props.changeContact(arr) + this.setState({ + confirmLoading: false + }, () => { + this.closeModal() + }) + }) + } + render () { + const { getFieldDecorator } = this.props.form + const { visible, confirmLoading } = this.state + return ( + +
+ + + + {getFieldDecorator('name', { + rules: [ + { required: true, message: '请填写姓名', whitespace: true } + ] + })( + + )} + + + {getFieldDecorator('phoneNum', { + rules: [ + { required: true, message: '请填写手机号', whitespace: true } + ] + })( + + )} + + + {getFieldDecorator('importance')( + + )} + + + {getFieldDecorator('email')( + + )} + + + {getFieldDecorator('companyName')( + + )} + + + {getFieldDecorator('departmentName')( + + )} + + + + + {getFieldDecorator('wechat')( + + )} + + + {getFieldDecorator('qqNum')( + + )} + + + {getFieldDecorator('businessNum')( + + )} + + + {getFieldDecorator('homeNum')( + + )} + + + {getFieldDecorator('fax')( + + )} + + + {getFieldDecorator('remark')( + + )} + + + +
+
+ ) + } +} + +export default Form.create()(EditContact) diff --git a/src/components/ContactList/ContactList.css b/src/components/CustomerContactList/ContactList.css similarity index 100% rename from src/components/ContactList/ContactList.css rename to src/components/CustomerContactList/ContactList.css diff --git a/src/components/ContactList/ContactList.js b/src/components/CustomerContactList/ContactList.js similarity index 100% rename from src/components/ContactList/ContactList.js rename to src/components/CustomerContactList/ContactList.js diff --git a/src/components/CustomerContactList/EditContact.js b/src/components/CustomerContactList/EditContact.js new file mode 100644 index 0000000..4dcd4d8 --- /dev/null +++ b/src/components/CustomerContactList/EditContact.js @@ -0,0 +1,204 @@ +// @flow +import React, { Component } from 'react' +import { Modal, Form, Input, Row, Col, Switch } from 'antd' +// const Option = Select.Option +import R from 'ramda' +// import universalFetch, { handleFetchError } from 'store/modules/fetch' +const FormItem = Form.Item +const formItemLayout = { + labelCol: { + xs: { span: 24 }, + sm: { span: 6 } + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 14 } + } +} + +type Props = { + form: Object, + removeNode: Function, + data: Object, + index: number, + changeContact: Function, + contactData: Array +} + +type States = { + visible: boolean, + confirmLoading: boolean +} +class EditContact extends Component { + props: Props + state: States + closeModal: Function + handleSubmit: Function + constructor (props: Props) { + super(props) + this.state = { + visible: true, + confirmLoading: false + } + this.closeModal = this.closeModal.bind(this) + this.handleSubmit = this.handleSubmit.bind(this) + } + + closeModal () { + this.setState({ + visible: false + }) + this.props.removeNode() + } + + handleSubmit () { + const form = this.props.form + form.validateFields((err, fieldsValue) => { + if (err) { + return false + } + this.setState({ + confirmLoading: true + }) + const { index, contactData } = this.props + let importance = 'secondary' + if (fieldsValue.importance) { + importance = 'primary' + } + const values = { + ...fieldsValue, + importance: importance + } + if (importance === 'primary') { + contactData.map((d) => { + d['importance'] = 'secondary' + }) + } + let arr = R.clone(contactData) + arr[index] = values + this.props.changeContact(arr) + this.setState({ + confirmLoading: false + }, () => { + this.closeModal() + }) + }) + } + render () { + const { getFieldDecorator } = this.props.form + const { data } = this.props + const { visible, confirmLoading } = this.state + const importance = data.importance === 'primary' ? true : false + return ( + +
+ + + + {getFieldDecorator('name', { + rules: [ + { required: true, message: '请填写姓名' } + ], + initialValue: data.name || '' + })( + + )} + + + {getFieldDecorator('phoneNum', { + rules: [ + { required: true, message: '请填写手机号' } + ], + initialValue: data.phoneNum || '' + })( + + )} + + + {getFieldDecorator('importance', { + initialValue: importance + })( + + )} + + + {getFieldDecorator('email', { + initialValue: data.email || '' + })( + + )} + + + {getFieldDecorator('companyName', { + initialValue: data.companyName || '' + })( + + )} + + + {getFieldDecorator('departmentName', { + initialValue: data.departmentName || '' + })( + + )} + + + + + {getFieldDecorator('wechat', { + initialValue: data.wechat || '' + })( + + )} + + + {getFieldDecorator('qqNum', { + initialValue: data.qqNum || '' + })( + + )} + + + {getFieldDecorator('businessNum', { + initialValue: data.businessNum || '' + })( + + )} + + + {getFieldDecorator('homeNum', { + initialValue: data.homeNum || '' + })( + + )} + + + {getFieldDecorator('fax', { + initialValue: data.fax || '' + })( + + )} + + + {getFieldDecorator('remark', { + initialValue: data.remark || '' + })( + + )} + + + +
+
+ ) + } +} + +export default Form.create()(EditContact) diff --git a/src/components/ContactList/index.js b/src/components/CustomerContactList/index.js similarity index 100% rename from src/components/ContactList/index.js rename to src/components/CustomerContactList/index.js diff --git a/src/components/CustomerEdit/CustomerEdit.js b/src/components/CustomerEdit/CustomerEdit.js index 0c3a495..3313647 100644 --- a/src/components/CustomerEdit/CustomerEdit.js +++ b/src/components/CustomerEdit/CustomerEdit.js @@ -3,6 +3,7 @@ import React, { Component } from 'react' import styles from './CustomerEdit.css' import { Form, Input, Button, Select, message, Upload, Icon } from 'antd' import universalFetch, { handleFetchError } from 'store/modules/fetch' +import CustomerContactList from 'components/CustomerContactList' const FormItem = Form.Item const Option = Select.Option const Dragger = Upload.Dragger @@ -48,6 +49,7 @@ type States = { district: string, imageUrl: string, remoteImageUrl: string, + contactData: Array, fileList: Array } class CustomerEdit extends Component { @@ -67,6 +69,7 @@ class CustomerEdit extends Component { changeFile1: Function beforeUpload: Function checkNum: Function + getContact: Function getFiles: Function constructor (props: Props) { super(props) @@ -84,6 +87,7 @@ class CustomerEdit extends Component { imageUrl: '', remoteImageUrl: '', users: [], + contactData: [], fileList: [] } @@ -101,9 +105,34 @@ class CustomerEdit extends Component { this.changeFile1 = this.changeFile1.bind(this) this.beforeUpload = this.beforeUpload.bind(this) this.checkNum = this.checkNum.bind(this) + this.getContact = this.getContact.bind(this) this.getFiles = this.getFiles.bind(this) } + componentWillMount () { + // this.getUsers()// 获得所有用户(联系人处使用) + this.getIndustry() + this.getCustomerType() + const { data } = this.props.history.location.state + console.log(data); + let imageUrl = data.imageUrl + const index = imageUrl.lastIndexOf('/') + imageUrl = imageUrl.substring(index + 1, imageUrl.length) + this.setState({ + imageUrl: imageUrl, + remoteImageUrl: data.imageUrl, + customerData: data, + contactData: data.contact || [], // 联系人信息 + province: data.region.province, + city: data.region.city, + district: data.region.district + }) + this.getProvinces() + this.getCities(data.region.province) + this.getDistricts(data.region.province, data.region.city) + this.getFiles(data) + } + checkNum (rule, value, callback) { const checkReg = /^[a-zA-Z][a-zA-Z0-9_]*$/ if (value && !checkReg.test(value)) { @@ -161,27 +190,6 @@ class CustomerEdit extends Component { } return type.indexOf('image/') > -1 } - componentWillMount () { - this.getUsers() - this.getIndustry() - this.getCustomerType() - const { data } = this.props.history.location.state - let imageUrl = data.imageUrl - const index = imageUrl.lastIndexOf('/') - imageUrl = imageUrl.substring(index + 1, imageUrl.length) - this.setState({ - imageUrl: imageUrl, - remoteImageUrl: data.imageUrl, - customerData: data, - province: data.region.province, - city: data.region.city, - district: data.region.district - }) - this.getProvinces() - this.getCities(data.region.province) - this.getDistricts(data.region.province, data.region.city) - this.getFiles(data) - } getFiles (data) { universalFetch(`${__SERVICE_API__}device/customers/${data.id}/files`) @@ -367,6 +375,12 @@ class CustomerEdit extends Component { }) } + getContact (data: Array) { + this.setState({ + contactData: data + }) + } + submit (e) { e.preventDefault() const { form } = this.props @@ -377,12 +391,13 @@ class CustomerEdit extends Component { this.setState({ loading: true }) - const { imageUrl, fileList } = this.state + const { imageUrl, contactData, fileList } = this.state const values1 = { ...Object.assign({}, fieldsValue, { imageUrl }) } const values = { - ...Object.assign({}, values1, { fileList }) + ...Object.assign({}, values1, { fileList }), + 'contact': contactData } const { customerData } = this.state console.log(values) @@ -424,7 +439,7 @@ class CustomerEdit extends Component { render () { const { getFieldDecorator } = this.props.form const { industries, customerTypes, loading, provinces, - cities, districts, customerData, city, district, remoteImageUrl, users + cities, districts, customerData, city, district, remoteImageUrl } = this.state const token = localStorage.getItem('asset_token') const cityDecorator = city @@ -536,6 +551,13 @@ class CustomerEdit extends Component { ) } + + { + getFieldDecorator('address', { initialValue: customerData.address })( + + ) + } + { getFieldDecorator('industry', { @@ -576,40 +598,40 @@ class CustomerEdit extends Component { ) } - - { - getFieldDecorator('contactPerson', { - initialValue: customerData.contactPerson - })( - - ) - } - - - { - getFieldDecorator('mobile', { initialValue: customerData.mobile })( - - ) - } - - - { - getFieldDecorator('address', { initialValue: customerData.address })( - - ) - } + + {getFieldDecorator('contact')( + + )} + { + // + // { + // getFieldDecorator('contactPerson', { + // initialValue: customerData.contactPerson + // })( + // + // ) + // } + // + // + // { + // getFieldDecorator('mobile', { initialValue: customerData.mobile })( + // + // ) + // } + // + } { getFieldDecorator('imageUrl', { initialValue: customerData.imageUrl })( diff --git a/src/components/CustomersAdd/CustomersAdd.js b/src/components/CustomersAdd/CustomersAdd.js index c72ff4d..fc162f6 100644 --- a/src/components/CustomersAdd/CustomersAdd.js +++ b/src/components/CustomersAdd/CustomersAdd.js @@ -3,6 +3,7 @@ import React, { Component } from 'react' import styles from './CustomersAdd.css' import { Form, Input, Button, Select, message, Upload, Icon } from 'antd' import universalFetch, { handleFetchError } from 'store/modules/fetch' +import CustomerContactList from 'components/CustomerContactList' const FormItem = Form.Item const Option = Select.Option const Dragger = Upload.Dragger @@ -44,6 +45,7 @@ type States = { users: Array, imageUrl: string, remoteImageUrl: string, + contactData: Array, fileList: Array } class CustomersAdd extends Component { @@ -62,6 +64,7 @@ class CustomersAdd extends Component { changeFile1: Function beforeUpload: Function checkNum: Function + getContact: Function constructor (props: Props) { super(props) this.state = { @@ -74,6 +77,7 @@ class CustomersAdd extends Component { imageUrl: '', remoteImageUrl: '', users: [], + contactData: [], fileList: [] } this.getIndustry = this.getIndustry.bind(this) @@ -88,12 +92,13 @@ class CustomersAdd extends Component { this.changeFile1 = this.changeFile1.bind(this) this.beforeUpload = this.beforeUpload.bind(this) this.checkNum = this.checkNum.bind(this) + this.getContact = this.getContact.bind(this) // this.keyPressEvent = this.keyPressEvent.bind(this) } componentWillMount () { this.getIndustry() - this.getUsers() + // this.getUsers() // 获得所有用户(联系人处使用) this.getCustomerType() this.getProvinces() } @@ -217,6 +222,11 @@ class CustomersAdd extends Component { console.error(error) }) } + getContact (data: Array) { + this.setState({ + contactData: data + }) + } submit (e) { e.preventDefault() const { form } = this.props @@ -227,14 +237,15 @@ class CustomersAdd extends Component { this.setState({ loading: true }) - const { imageUrl, fileList } = this.state + const { imageUrl, fileList, contactData } = this.state const values = { ...Object.assign({}, fieldsValue, { imageUrl }) } const values1 = { - ...Object.assign({}, values, { fileList }) + ...Object.assign({}, values, { fileList }), + 'contact': contactData } - values1.fileList = values.fileUrl.fileList + values1.fileList = values.fileUrl ? values.fileUrl.fileList : '' console.log(values1) universalFetch(`${__SERVICE_API__}device/customers`, { method: 'POST', @@ -421,6 +432,13 @@ class CustomersAdd extends Component { ) } + + { + getFieldDecorator('address', {})( + + ) + } + { getFieldDecorator('industry', {})( @@ -457,39 +475,40 @@ class CustomersAdd extends Component { ) } - - { - getFieldDecorator('contactPerson', {})( - // - - ) - } - - - { - getFieldDecorator('mobile', {})( - - ) - } - - - { - getFieldDecorator('address', {})( - - ) - } + + {getFieldDecorator('contact')( + + )} + { + // + // { + // getFieldDecorator('contactPerson', {})( + // // + // + // ) + // } + // + // + // { + // getFieldDecorator('mobile', {})( + // + // ) + // } + // + } + { getFieldDecorator('imageUrl', {})( diff --git a/src/components/ContactList/AddContact.js b/src/components/DeviceContactList/AddContact.js similarity index 100% rename from src/components/ContactList/AddContact.js rename to src/components/DeviceContactList/AddContact.js diff --git a/src/components/DeviceContactList/ContactList.css b/src/components/DeviceContactList/ContactList.css new file mode 100644 index 0000000..26f6620 --- /dev/null +++ b/src/components/DeviceContactList/ContactList.css @@ -0,0 +1,35 @@ +.main { + :global { + .ant-table-fixed-header .ant-table-scroll:after { + content: ''; + } + .ant-table-fixed-header .ant-table-scroll .ant-table-header { + overflow: auto; + } + .ant-table-thead>tr>th { + font-size: 14px; + color: #3b3b3b; + text-align: center; + border-bottom: 0px; + padding: 2px 8px 2px 0; + } + .ant-table-tbody>tr>td { + color: #666; + text-align: center; + padding: 2px 8px 2px 0; + border-bottom: 0px; + } + .ant-table, + .ant-table table { + border-radius: 0; + text-align: center; + } + .ant-select-selection--single { + width: 300px; + } + } +} +.operate { + font-size: 16px; + cursor: pointer; +} diff --git a/src/components/DeviceContactList/ContactList.js b/src/components/DeviceContactList/ContactList.js new file mode 100644 index 0000000..2b7bb54 --- /dev/null +++ b/src/components/DeviceContactList/ContactList.js @@ -0,0 +1,156 @@ +// @flow +import React from 'react' +import styles from './ContactList.css' +import { Table, Select, message, Input, Button } from 'antd' +const Option = Select.Option +import R from 'ramda' +import EditContact from './EditContact' +import AddContact from './AddContact' +import ReactDom from 'react-dom' +import universalFetch, { handleFetchError } from 'store/modules/fetch' +message.config({ + top: 100 +}) + +type Props = { + contactData: Array, + getContact: Function +} +type States = { + contactData: Array +} +class ContactList extends React.Component { + state: States + props: Props + addContact: Function + deleteContact: Function + selectParts: Function + editContact: Function + changeContact: Function + removeEditPoint: Function + constructor (props: Props) { + super(props) + this.state = { + contactData: this.props.contactData || [] + } + this.addContact = this.addContact.bind(this) + this.deleteContact = this.deleteContact.bind(this) + this.editContact = this.editContact.bind(this) + this.removeEditPoint = this.removeEditPoint.bind(this) + this.changeContact = this.changeContact.bind(this) + } + componentWillMount () { + } + componentWillReceiveProps (nextProps: Object) { + } + removeEditPoint () { + const container = this.refs.editContact + ReactDom.unmountComponentAtNode(container) + } + changeContact (data: Array) { + this.setState({ + contactData: data + }) + this.props.getContact(data) + } + deleteContact (item: Object) { + const { contactData } = this.state + let arr = R.clone(contactData) + const l = contactData.indexOf(item) + if (l > -1) { + arr.splice(l, 1) // 删除数组中的这一项 + this.setState({ + contactData: arr + }) + } + } + editContact (item: Object) { + const { contactData } = this.state + const index = contactData.indexOf(item) // 知道其为第几项 + const container = this.refs.editContact + ReactDom.render( + , + container + ) + } + addContact () { + const { contactData } = this.state + const index = contactData.length + const container = this.refs.editContact + ReactDom.render( + , + container + ) + } + render () { + const { contactData } = this.state + const component = this + const columns = [{ + title: '姓名', + dataIndex: 'name', + key: 'name', + width: '26%' + }, { + title: '手机号', + dataIndex: 'phoneNum', + key: 'phoneNum', + width: '26%' + }, { + title: '默认联系人', + dataIndex: 'importance', + key: 'importance', + width: '26%' + }, { + title: '操作', + dataIndex: 'operate', + key: 'operate', + width: '20%' + }] + const contactText = contactData.map((item, index) => { + return { + key: index, + name: item.name, + phoneNum: item.phoneNum, + importance: item.importance === 'primary' ? '默认联系人' : '', + operate: