5 changed files with 410 additions and 443 deletions
-
0src/pages/InRoadMgm/PersonMgm/MesNotification/demon.jsx
-
0src/pages/InRoadMgm/PersonMgm/MesNotification/demon.scss
-
216src/pages/InRoadMgm/PersonMgm/MesNotification/index.scss
-
627src/pages/InRoadMgm/PersonMgm/MesNotification/loadable.jsx
-
10src/services/search.js
@ -1,389 +1,272 @@ |
|||
import React, { useState, useRef, useEffect } from "react"; |
|||
import { ResultFlowResult } from "@/components" |
|||
import { Select, Button, Table, message, Pagination } from 'antd' |
|||
import { |
|||
message, |
|||
Pagination, |
|||
Table, |
|||
Form, |
|||
Space, |
|||
Modal, |
|||
DatePicker, |
|||
Input, |
|||
Button, |
|||
Select, |
|||
Tabs, |
|||
Descriptions, |
|||
Transfer |
|||
} from "antd"; |
|||
const { RangePicker } = DatePicker; |
|||
import moment from "moment"; |
|||
const { TextArea } = Input; |
|||
import ajax from '@/config/ajax.js' |
|||
import { TableModule, ResultFlow, } from "@/components"; |
|||
import { dictionary, utils } from "@/config/common"; |
|||
pageSizeOptions |
|||
} from '@/config/character.config.js' |
|||
import "./index.scss"; |
|||
import { SearchOutlined, DeleteOutlined } from '@ant-design/icons'; |
|||
import ajax from '@/services' |
|||
import { useSessionStorageState } from "ahooks" |
|||
function MesNotification(props) { |
|||
const [ajaxLoading, setAjaxLoading] = useState(false) |
|||
const [resultData, setResultData] = useState({ |
|||
data: [], |
|||
total_records: 0, |
|||
export_url: '', |
|||
process_url: "" |
|||
}) |
|||
const parameter={ |
|||
operatorid: '', |
|||
brand_id: '', |
|||
model_id: '', |
|||
pn: 1, |
|||
page_size: Number(pageSizeOptions[0]), // 每页条数 |
|||
} |
|||
const [formData, setFormData] = useState(parameter) |
|||
const [lastFormData, setLastFormData] = useState(formData) |
|||
//物品型号 |
|||
const handleJobStatus = (value) => { |
|||
setFormData({ ...formData, model_id: value }) |
|||
} |
|||
//物品类型 |
|||
const [getBrandId, setGetBrandId] = useState({}) |
|||
const handleOperator = (v) => { |
|||
setGetBrandId(v) |
|||
setFormData({ ...formData, brand_id: v }) |
|||
} |
|||
//商户名称 |
|||
const handleDeployType = (value) => { |
|||
setFormData({ ...formData, operatorid: value }) |
|||
} |
|||
//列表 |
|||
const handleColumns = (tab) => { |
|||
let result = [...deployListColumns]; |
|||
switch (tab) { |
|||
case '1': |
|||
result.splice(5, 1) |
|||
break; |
|||
|
|||
function loadable() { |
|||
const columns = [ |
|||
{ |
|||
title: "序号", |
|||
dataIndex: "index", |
|||
key: "index", |
|||
align: "center", |
|||
fixed: "left", |
|||
render: (text, record, index) => index + 1, |
|||
width: 100, |
|||
}, |
|||
{ |
|||
title: "接收人类型", |
|||
dataIndex: "receiver_type", |
|||
key: "receiver_type", |
|||
width: 100, |
|||
align: "center", |
|||
}, |
|||
{ |
|||
title: "接收人", |
|||
dataIndex: "receiver", |
|||
key: "receiver", |
|||
width: 100, |
|||
align: "center", |
|||
}, |
|||
{ |
|||
title: "发送内容", |
|||
dataIndex: "content", |
|||
key: "content", |
|||
width: 100, |
|||
align: "center", |
|||
}, |
|||
{ |
|||
title: "发送人", |
|||
dataIndex: "sender", |
|||
key: "sender", |
|||
width: 100, |
|||
align: "center", |
|||
}, |
|||
{ |
|||
title: "发送时间", |
|||
dataIndex: "send_time", |
|||
key: "send_time", |
|||
width: 100, |
|||
align: "center", |
|||
}, |
|||
]; |
|||
const [loading, setLoading] = useState(false); |
|||
const [tag, setTag] = useState('1'); |
|||
const [sfyVisible, setSfyVisible] = useState(false); |
|||
const [pageData, setPageData] = useState({ |
|||
// 分页参数 |
|||
pn: 1, |
|||
page_size: 15, |
|||
}); |
|||
const [resultData, setResultData] = useState([]) |
|||
const [sendData, setSendData] = useState({ |
|||
receiver_type: 1,//1,全平台;2,PDA账号;3,运营商 |
|||
receiver: '',//接收人名称 |
|||
receiver_id: '',//接收人对应id |
|||
content: '',//内容 |
|||
}) |
|||
function onShowSizeChange(pn, page_size) { |
|||
setPageData({ |
|||
pn, |
|||
page_size, |
|||
}); |
|||
} |
|||
const handleChange = (value) => { |
|||
console.log(`selected ${value}`); |
|||
setSendData({ ...sendData, receiver_type: value }) |
|||
}; |
|||
const inputParams = { |
|||
maxLength: 50, |
|||
showCount: true, |
|||
}; |
|||
const [total, setTotal] = useState([]); |
|||
const [mockData, setMockData] = useState([]); |
|||
const [formData, setFormData] = useState({ |
|||
//start: moment().subtract(1, "month").format("YYYY-MM-DD HH:mm:ss"), |
|||
//end: moment().format("YYYY-MM-DD HH:mm:ss"), |
|||
start: '', |
|||
end: '', |
|||
}); |
|||
const [targetKeys, setTargetKeys] = useState([]); |
|||
const [selectedKeys, setSelectedKeys] = useState([]); |
|||
const onChange = (nextTargetKeys, direction, moveKeys) => { |
|||
console.log('targetKeys:', nextTargetKeys); |
|||
console.log('direction:', direction); |
|||
console.log('moveKeys:', moveKeys); |
|||
setTargetKeys(nextTargetKeys); |
|||
//setSendData({ ...sendData, receiver_id: nextTargetKeys }) |
|||
}; |
|||
const onChangeText = (e) => { |
|||
setSendData({ ...sendData, content: e.target.value }) |
|||
}; |
|||
const onSelectChange = (sourceSelectedKeys, targetSelectedKeys) => { |
|||
// console.log('sourceSelectedKeys:', sourceSelectedKeys); |
|||
//console.log('targetSelectedKeys:', targetSelectedKeys); |
|||
setSendData({ ...sendData, receiver_id: targetSelectedKeys }) |
|||
setSelectedKeys([...sourceSelectedKeys, ...targetSelectedKeys]); |
|||
}; |
|||
const onScroll = (direction, e) => { |
|||
console.log('direction:', direction); |
|||
console.log('target:', e.target); |
|||
}; |
|||
const handleSearch = (dir, value) => { |
|||
console.log('search:', dir, value); |
|||
}; |
|||
function onChangeTime(value, dateString) { |
|||
console.log('Selected Time: ', value); |
|||
console.log('Formatted Selected Time: ', dateString); |
|||
setFormData({ start: dateString[0], end: dateString[1] }) |
|||
}; |
|||
//退费记录检索条件 |
|||
const formSearch = [ |
|||
{//13 |
|||
name: "timePeriod", |
|||
type: "RangePicker", |
|||
label: "时间段", |
|||
defaultValue: [moment().startOf("day"), moment()], |
|||
defaultTitle: ['发送时间', '至'] |
|||
}, |
|||
]; |
|||
function send() { |
|||
var arr = [] |
|||
mockData.map((e) => { |
|||
if (sendData.receiver_id) { |
|||
sendData.receiver_id?.map((d) => { |
|||
if (d == e.key) { |
|||
arr.push(e.title) |
|||
} |
|||
} |
|||
return result; |
|||
} |
|||
//重置数据 |
|||
const getResetData = () => { |
|||
setFormData({ |
|||
...parameter |
|||
}) |
|||
} |
|||
}) |
|||
if ((sendData.receiver_type > 1) && sendData.receiver_id.length == 0) { |
|||
message.error("请勾选接收人") |
|||
return |
|||
getData({ ...parameter }) |
|||
} |
|||
//console.log(arr) |
|||
ajax({ |
|||
url: "/api/bpm/message/send", |
|||
type: "post", |
|||
data: { ...sendData, receiver: arr }, |
|||
}).then((res) => { |
|||
console.log(res) |
|||
let { status, data } = res |
|||
if (status == 20000) { |
|||
// console.log(data.list) |
|||
message.success(res.message) |
|||
setTag('1'); |
|||
} else { |
|||
message.error(res.message) |
|||
} |
|||
}) |
|||
} |
|||
function getpad() { |
|||
ajax({ |
|||
url: sendData.receiver_type == 2 ? "/api/bpm/operator/get_all_worker" : "/api/bpm/operator/get_all_operator", |
|||
type: "get", |
|||
data: { type: "message" } |
|||
}).then((res) => { |
|||
let { status, data } = res |
|||
if (status == 20000) { |
|||
let arr = [] |
|||
data.map((e) => { |
|||
let obj = { |
|||
key: e.value, |
|||
title: e.label |
|||
//列表 |
|||
const deployListColumns = [ |
|||
{ |
|||
title: '序号', |
|||
render: (_, record, index) => { |
|||
return index + 1 |
|||
} |
|||
arr.push(obj) |
|||
}, |
|||
{ |
|||
title: '接收人类型', |
|||
dataIndex: 'receiver_type', |
|||
key: 'receiver_type', |
|||
}, |
|||
{ |
|||
title: '接收人', |
|||
dataIndex: 'receiver', |
|||
key: 'receiver', |
|||
}, |
|||
{ |
|||
title: '发送内容', |
|||
dataIndex: 'content', |
|||
key: 'content', |
|||
}, |
|||
{ |
|||
title: '发送人', |
|||
dataIndex: 'sender', |
|||
key: 'sender', |
|||
}, |
|||
{ |
|||
title: '发送时间', |
|||
dataIndex: 'send_time', |
|||
key: 'send_time', |
|||
}] |
|||
|
|||
// 获取列表数据 |
|||
const getData = (data = formData) => { |
|||
setAjaxLoading(true) |
|||
ajax.MesNotificationData(data).then(res => { |
|||
setAjaxLoading(false) |
|||
if (res.status === 20000) { |
|||
let resDataArr = res.data.list.map((item) => { |
|||
item.key = item.id |
|||
return item |
|||
}) |
|||
setResultData({ |
|||
...resultData, |
|||
data: resDataArr, |
|||
total_records: res.data.total_records |
|||
}) |
|||
} else { |
|||
setResultData({ |
|||
data: [], |
|||
total_records: 0, |
|||
export_url: '', |
|||
process_url: "" |
|||
}) |
|||
message.error(res.message) |
|||
} |
|||
}, err => { |
|||
console.log(err) |
|||
}) |
|||
setMockData(arr) |
|||
} else { |
|||
message.error(res.message) |
|||
} |
|||
}) |
|||
} |
|||
function search(e) { |
|||
console.log(e) |
|||
ajax({ |
|||
url: "/api/bpm/message/list", |
|||
type: "post", |
|||
data: { ...e }, |
|||
}).then((res) => { |
|||
let { status, data } = res |
|||
if (status == 20000) { |
|||
setResultData(data.list) |
|||
setTotal(data.total) |
|||
} else { |
|||
message.error(res.message) |
|||
} |
|||
} |
|||
//切换分页 |
|||
const changePn = (pn, length) => { |
|||
if (formData.page_size === length) { |
|||
setFormData(Object.assign({}, formData, { pn: pn, page_size: length })) |
|||
setLastFormData(Object.assign({}, lastFormData, { pn: pn, page_size: length })) |
|||
getData(Object.assign({}, formData, { pn: pn, page_size: length })) |
|||
} |
|||
} |
|||
//切换每页条数 |
|||
const changeLength = (pn, length) => { |
|||
setFormData(Object.assign({}, formData, { pn: 1, page_size: length })) |
|||
setLastFormData(Object.assign({}, lastFormData, { pn: 1, page_size: length })) |
|||
getData(Object.assign({}, formData, { pn: 1, page_size: length })) |
|||
} |
|||
//检索数据 |
|||
const getSearchData = (data = formData) => { |
|||
getData(data) |
|||
} |
|||
|
|||
const [getOperationName, setGetOperationName] = useState([]) |
|||
const operationName = () => { |
|||
ajax.assetsType().then(res => { |
|||
setGetOperationName(res.data) |
|||
}) |
|||
} |
|||
const [getMerchantDataName, setGetMerchantDataName] = useState([]) |
|||
const merchantDataName = () => { |
|||
ajax.getOperator().then(res => { |
|||
setGetMerchantDataName(res.data) |
|||
}) |
|||
} |
|||
const [getAssetsModel, setGetAssetsModel] = useState([]) |
|||
const assetsModelName = () => { |
|||
let data = { |
|||
brand_id: getBrandId |
|||
} |
|||
ajax.assetsModel(data).then(res => { |
|||
setGetAssetsModel(res.data) |
|||
}) |
|||
} |
|||
useEffect(() => { |
|||
assetsModelName() |
|||
}, [getBrandId]) |
|||
|
|||
|
|||
const [sessionTabList, setSessionTabList] = useSessionStorageState('MesNotification', { |
|||
value: { |
|||
} |
|||
}) |
|||
} |
|||
// useEffect(() => { |
|||
// search() |
|||
// }, [pageData]); |
|||
useEffect(() => { |
|||
getpad() |
|||
}, [sendData.receiver_type]) |
|||
return ( |
|||
<> |
|||
{ |
|||
tag == 2 ? |
|||
<div className="push-box"> |
|||
<div><a onClick={() => { setTag('1') }}>〈返回</a></div> |
|||
<div className="push-item"> |
|||
<div className="title">接收人类型</div> |
|||
<Select |
|||
defaultValue="1" |
|||
style={{ |
|||
width: 120, |
|||
}} |
|||
onChange={handleChange} |
|||
options={[ |
|||
{ |
|||
value: '1', |
|||
label: '全平台', |
|||
}, |
|||
{ |
|||
value: '2', |
|||
label: 'PDA账号', |
|||
}, |
|||
{ |
|||
value: '3', |
|||
label: '运营商', |
|||
}, |
|||
]} |
|||
/> |
|||
</div> |
|||
{ |
|||
sendData.receiver_type == 1 ? null : |
|||
<div className="push-item"> |
|||
<div className="title">接收人 </div> |
|||
<Transfer |
|||
dataSource={mockData} |
|||
titles={['未选择', '已选择']} |
|||
targetKeys={targetKeys} |
|||
selectedKeys={selectedKeys} |
|||
onChange={onChange} |
|||
showSearch={true} |
|||
onSelectChange={onSelectChange} |
|||
//onSearch={handleSearch} |
|||
//onScroll={onScroll} |
|||
render={(item) => item.title} |
|||
/> |
|||
useEffect(() => { |
|||
console.log(location) |
|||
if (sessionTabList && Object.values(sessionTabList).length > 0) { |
|||
setFormData({ |
|||
brand_id: sessionTabList?.brand_id, |
|||
model_id: sessionTabList?.model_id, |
|||
operatorid: sessionTabList?.operatorid, |
|||
pn: sessionTabList?.pn, |
|||
page_size: sessionTabList?.page_size, |
|||
}) |
|||
} |
|||
}, []) |
|||
console.log(formData); |
|||
useEffect(() => { |
|||
setSessionTabList({ |
|||
...formData |
|||
}) |
|||
}, [formData]) |
|||
useEffect(() => { |
|||
getData() |
|||
merchantDataName() |
|||
operationName() |
|||
}, []) |
|||
return <> |
|||
<div className="paid-MesNotification"> |
|||
<div className="paid-search"> |
|||
<label className="search">查询条件</label> |
|||
<div className="yisa-search"> |
|||
<label>商户名称</label> |
|||
<Select |
|||
style={{ width: 220 }} |
|||
// allowClear |
|||
value={formData.operatorid} |
|||
options={getMerchantDataName} |
|||
onChange={handleDeployType} |
|||
/> |
|||
</div> |
|||
<div className="yisa-search"> |
|||
<label>物品类型</label> |
|||
<Select |
|||
style={{ width: 220 }} |
|||
value={formData.brand_id} |
|||
options={getOperationName} |
|||
onChange={handleOperator} |
|||
/> |
|||
</div> |
|||
<div className="yisa-search"> |
|||
<label>物品型号</label> |
|||
<Select |
|||
style={{ width: 220 }} |
|||
placeholder="请选择" |
|||
value={formData.model_id} |
|||
options={getAssetsModel} |
|||
onChange={handleJobStatus} |
|||
/> |
|||
</div> |
|||
<div className="timePicker "> |
|||
<div className="btnBox"> |
|||
<Button type="primary" className="yisa-btn colorBtn" icon={<SearchOutlined />} onClick={() => { getSearchData() }}> |
|||
搜索 |
|||
</Button> |
|||
<Button type="primary" className="yisa-btn colorReset" icon={<DeleteOutlined />} onClick={() => { getResetData() }}> |
|||
清空 |
|||
</Button> |
|||
</div> |
|||
</div> |
|||
} |
|||
|
|||
<div className="push-item"> |
|||
<div className="title">发送内容</div> |
|||
<TextArea rows={4} onChange={onChangeText} placeholder="" maxLength={200} showCount /> |
|||
</div> |
|||
<div className="btn-box"> |
|||
<Button |
|||
type="primary" |
|||
className="submit search-btn colorBtn" |
|||
onClick={() => send()} |
|||
> |
|||
发送 |
|||
</Button> |
|||
<Button className="push search-btn colorReset" onClick={() => { setTag('1'); }}>取消</Button> |
|||
<div className="paid-result"> |
|||
<div className="result"> |
|||
<span className="font">共检索到<em>{resultData.total_records}</em>条结果</span> |
|||
<ResultFlowResult ajaxLoad={ajaxLoading} resultData={resultData.data ? resultData.data : []}> |
|||
<Table |
|||
bordered |
|||
// className='yisa-table' |
|||
dataSource={resultData.data} |
|||
columns={ |
|||
handleColumns() |
|||
} |
|||
pagination={false} |
|||
loading={ajaxLoading} |
|||
/> |
|||
<Pagination |
|||
className="pagination-common" |
|||
showSizeChanger |
|||
showQuickJumper |
|||
showTotal={() => `共 ${resultData.total_records} 条`} |
|||
total={resultData.total_records} |
|||
current={formData.pn} |
|||
pageSize={formData.page_size} |
|||
pageSizeOptions={pageSizeOptions} |
|||
onChange={changePn} |
|||
onShowSizeChange={changeLength} |
|||
/> |
|||
</ResultFlowResult> |
|||
</div> |
|||
</div> |
|||
</div> : |
|||
// <div> |
|||
// <div className="search-box"> |
|||
// <div className="time">发送时间: |
|||
// <div style={{ width: "400px", display: "inline-block" }}> |
|||
// <RangePicker |
|||
// showTime={{ |
|||
// format: "HH:mm:ss", |
|||
// }} |
|||
// defaultValue={[moment().subtract(1, "month"), moment()]} |
|||
// format="YYYY-MM-DD HH:mm:ss" |
|||
// onChange={onChangeTime} |
|||
// /> |
|||
// </div> |
|||
// </div> |
|||
// <div className="btn-box"> |
|||
// <Button |
|||
// type="primary" |
|||
// className="submit search-btn colorBtn" |
|||
// onClick={() => search()} |
|||
// > |
|||
// 查询 |
|||
// </Button> |
|||
// <Button className="push search-btn colorReset" onClick={() => { |
|||
// setTag('2'); |
|||
// setSendData({ |
|||
// receiver_type: 1,//1,全平台;2,PDA账号;3,运营商 |
|||
// receiver: '',//接收人名称 |
|||
// receiver_id: '',//接收人对应id |
|||
// content: '',//内容 |
|||
// }) |
|||
// setSelectedKeys([]) |
|||
// setTargetKeys([]) |
|||
// }}>发送消息</Button> |
|||
// </div> |
|||
|
|||
// </div> |
|||
// <div className="result-box right-list"> |
|||
// <ResultFlow |
|||
// hasLoad={true} |
|||
// loading={loading} |
|||
// resultData={resultData} |
|||
// message={"暂无数据"} |
|||
// > |
|||
// <div className="table-wrap"> |
|||
// <Table |
|||
// // className="yisa-table" |
|||
// columns={columns} |
|||
// dataSource={resultData} |
|||
// pagination={false} |
|||
// // scroll={{ x: 1500 }} |
|||
// /> |
|||
// </div> |
|||
// <div> |
|||
// <Pagination |
|||
// className="pagination-common" |
|||
// showSizeChanger={true} |
|||
// showQuickJumper={true} |
|||
// // showTotal={() => `共 ${total_records} 条`} |
|||
// total={0} |
|||
// current={pageData.pn} |
|||
// pageSize={pageData.page_size} |
|||
// pageSizeOptions={dictionary?.pageSizeOptions} |
|||
// onChange={onShowSizeChange} |
|||
// onShowSizeChange={onShowSizeChange} |
|||
// /> |
|||
// </div> |
|||
// </ResultFlow> |
|||
// </div> |
|||
// </div> |
|||
<TableModule |
|||
columns={columns} |
|||
tableData={resultData} |
|||
formSearch={formSearch} |
|||
total={total} |
|||
isExport={false} |
|||
search={search} |
|||
pageName={'mesNotification'} |
|||
//exportUrl={exportUrl} |
|||
rowKey={'id'} |
|||
/> |
|||
} |
|||
<Modal |
|||
open={sfyVisible} |
|||
width={800} |
|||
title={'收费员选择'} |
|||
onCancel={() => { |
|||
setSfyVisible(false); |
|||
}} |
|||
onOk={() => { |
|||
setSfyVisible(false); |
|||
}} |
|||
> |
|||
<div> |
|||
<div>残疾人证</div> |
|||
</div> |
|||
</Modal> |
|||
</> |
|||
); |
|||
} |
|||
|
|||
export default loadable; |
|||
export default MesNotification; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue