import React from 'react'; import $ from 'jquery/src/ajax'; import { Form, Icon, Button, Input, Select, AutoComplete, Spin, Table, message, DatePicker, Modal, Tabs } from 'antd'; import moment from 'moment'; import { ShowModal, splitUrl } from '../../../tools.js'; import { ChooseList } from "../../order/orderNew/chooseList"; import "./index.less"; import ImgList from "../../../common/imgList"; const PicturesWall = React.createClass({ getInitialState() { return { previewVisible: false, previewImage: "", fileList: this.props.pictureUrl, }; }, getDefaultProps() { return { changeClick: this.modifyChange, }; }, handleCancel() { this.setState({ previewVisible: false }); }, handlePreview(file) { this.setState({ previewImage: file.url || file.thumbUrl, previewVisible: true, }); }, handleChange(info) { let fileList = info.fileList; this.setState({ fileList }); this.props.fileList(fileList); }, componentWillReceiveProps(nextProps) { this.state.fileList = nextProps.pictureUrl; }, render() { const { fileList } = this.state; return (
{ this.handleChange(infor); }} fileList={fileList} />
); }, }); const { TabPane } = Tabs const FormItem = Form.Item; const Standard = Form.create()(React.createClass({ getInitialState() { return { searchValues: {}, loading: false, changeList: undefined, // 更改后的表格显示数据 dataSource: [], departmentArr: [], typeList: [ { key: "国家标准", value: 0, }, { key: "行业标准", value: 1, }, { key: "地方标准", value: 2, }, { key: "团体标准", value: 3, }, { key: "国际标准", value: 4, }, { key: "企业标准", value: 5, }, ], pagination: { defaultCurrent: 1, defaultPageSize: 10, showQuickJumper: true, pageSize: 20, onChange: function (page) { this.loadData(page); }.bind(this), showTotal: function (total) { return '共' + total + '条数据'; } }, columns: [ { title: '标准编号', dataIndex: 'serialNumber', key: 'serialNumber', }, { title: '标准名称', dataIndex: 'name', key: 'name', }, { title: '参考', dataIndex: 'reference', key: 'reference', render: (text, record) => {['国家 ', '行业 ', '地方 ', '团体 ', '国际 ', '企业 '][record.type]}{text} }, { title: '部门', dataIndex: 'depName', key: 'depName', }, { title: '负责人', dataIndex: 'adminName', key: 'adminName', }, { title: '标准状态', dataIndex: 'status', key: 'status', render: text => {["关闭", "开启"][text]} }, { title: '更新时间', dataIndex: 'updateTime', key: 'updateTime', }, { title: '附件', dataIndex: 'url', key: 'url', render: (text, record, index) =>
}, ], visible: "", data: {}, orgCodeUrl: [], }; }, componentWillMount() { this.loadData(); this.departmentList(); }, // 列表接口 loadData(pageNo) { const { searchValues, pagination } = this.state; this.setState({ loading: true, }); let datas = Object.assign(searchValues, { pageNo: pageNo || 1, pageSize: pagination.pageSize, }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/standard/list", data: datas, success: function (data) { ShowModal(this); this.setState({ loading: false, }); if (data.error && data.error.length === 0) { if (data.data.list) { pagination.current = data.data.pageNo; pagination.total = data.data.totalCount; if (data.data && data.data.list && !data.data.list.length) { pagination.current = 0; pagination.total = 0; } this.setState({ dataSource: data.data.list, pagination: this.state.pagination, pageNo: data.data.pageNo, }); } else { this.setState({ dataSource: data.data, pagination: false, }); } } else { message.warning(data.error[0].message); } }.bind(this), }).always( function () { this.setState({ loading: false, }); }.bind(this) ); }, //部门 departmentList() { $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/organization/selectSuperId", data: {}, success: function (data) { let thedata = data.data; let theArr = []; if (!thedata) { if (data.error && data.error.length) { message.warning(data.error[0].message); } } else { thedata.map(function (item, index) { theArr.push({ key: index, name: item.name, id: item.id }); }); } this.setState({ departmentArr: theArr }); }.bind(this) }).always( function () { }.bind(this) ); }, search() { this.loadData(); }, reset() { this.setState({ searchValues: {} }, () => { this.loadData(); }) }, changeList(arr) { const newArr = []; this.state.columns.forEach(item => { arr.forEach(val => { if (val === item.title) { newArr.push(item); } }); }); this.setState({ changeList: newArr }); }, addClick() { this.setState({ visible: "add" }) }, tableRowClick(e) { if (!adminData.isSuperAdmin) { return } this.setState({ visible: "edit", }) this.getDetails(e.id) // const orgCodeUrl = e.url ? splitUrl(e.url, ',', globalConfig.avatarHost + '/upload') : [] // this.setState({ // visible: "edit", // data: e, // orgCodeUrl, // adminName: e.adminName, // }) }, getDetails(id) { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/standard/get", data: { id, }, success: function (data) { let thedata = data.data || {}; let orgCodeUrl = [] if (!thedata) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; } else { orgCodeUrl = thedata.url ? splitUrl(thedata.url, ',', globalConfig.avatarHost + '/upload') : [] } this.setState({ data: thedata, orgCodeUrl, adminName: thedata.adminName, }) }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, getOrgCodeUrl(e) { this.setState({ orgCodeUrl: e }); }, handleCancel() { this.setState({ visible: "", adminName: undefined, data: {}, orgCodeUrl: [], }) }, handleSubmit() { const { data } = this.state if (!data.serialNumber) { message.warning('标准编号不能为空!'); return; } if (!data.name) { message.warning('标准名称不能为空!'); return; } if (!data.depId) { message.warning('部门不能为空!'); return; } if (!data.status && data.status != 0) { message.warning('请选择状态!'); return; } let pictureUrl = ""; if (this.state.orgCodeUrl.length) { let picArr = []; this.state.orgCodeUrl.map(function (item) { if ( item.response && item.response.data && item.response.data.length ) { picArr.push(item.response.data); } }); pictureUrl = picArr.join(","); } $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: data.id ? globalConfig.context + '/api/admin/standard/update' : globalConfig.context + '/api/admin/standard/add', data: Object.assign(data, { url: pictureUrl, }), }).done(function (data) { this.setState({ loading: false }); if (!data.error.length) { message.success('保存成功!'); this.handleCancel(); this.loadData(this.state.pageNo); } else { message.warning(data.error[0].message); } }.bind(this)); }, followUp(e) { this.setState({ adminName: e }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/customer/listAdminByName", data: { adminName: e, }, success: function (data) { let thedata = data.data || []; if (!thedata) { if (data.error && data.error.length) { message.warning(data.error[0].message); } thedata = {}; } this.setState({ fjlist: thedata, }); }.bind(this), }).always( function () { this.setState({ loading: false, }); }.bind(this) ); }, selectF(value) { const { data, fjlist } = this.state; const newdataSources = JSON.stringify(fjlist) == "{}" ? [] : fjlist; this.setState({ data: Object.assign(data, { aid: newdataSources.find((item) => item.name == value).id, }), }); }, render() { const { RangePicker } = DatePicker; let departmentArr = this.state.departmentArr || []; const { searchValues, data } = this.state const dataSources = this.state.fjlist || []; const options = dataSources.map((group) => ( {group.name} )); const formItemLayout = { labelCol: { span: 8 }, wrapperCol: { span: 14 }, }; return (
{ searchValues["name"] = e.target.value; this.setState({ searchValues: searchValues, }); }} /> 时间: { this.setState({ searchValues: Object.assign(searchValues, { startTime: dataString[0], endTime: dataString[1], }), }); }} />
{adminData.isSuperAdmin ? : ""}
{ this.state.visible != "" &&
{ data["serialNumber"] = e.target.value; this.setState({ data: data }); }} /> * { data["name"] = e.target.value; this.setState({ data: data }); }} /> * { data["reference"] = e.target.value; this.setState({ data: data }); }} /> * * 支持图片,pdf
} ); } })); export default Standard;