@/utils/utils#dealDateTimeDisplay JavaScript Examples
The following examples show how to use
@/utils/utils#dealDateTimeDisplay.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.jsx From the-eye-knows-the-garbage with MIT License | 4 votes |
TableList = () => {
const [createModalVisible, handleModalVisible] = useState(false);
const [updateModalVisible, handleUpdateModalVisible] = useState(false);
const [updateFormValues, setUpdateFormValues] = useState({});
const actionRef = useRef();
const addFormRef = useRef();
const updateFormRef = useRef();
const handleAdd = async fields => {
const hide = message.loading('正在添加');
try {
await addEmailVerifyRecord({...fields});
hide();
message.success('添加成功');
return true;
} catch (error) {
if ('fields_errors' in error.data) {
for (let key in error.data.fields_errors) {
var value = error.data.fields_errors[key];
addFormRef.current.setFields([
{
name: key,
errors: value,
},
]);
}
} else {
message.error('非字段类型错误');
}
hide();
message.error('添加失败');
return false;
}
};
const handleUpdate = async (value, current_id) => {
const hide = message.loading('正在修改');
try {
await updateEmailVerifyRecord(value, current_id);
hide();
message.success('修改成功');
return true;
} catch (error) {
if ('fields_errors' in error.data) {
for (let key in error.data.fields_errors) {
var value = error.data.fields_errors[key];
updateFormRef.current.setFields([
{
name: key,
errors: value,
},
]);
}
} else {
message.error('非字段类型错误');
}
hide();
message.error('修改失败请重试!');
return false;
}
};
const handleRemove = async selectedRows => {
const hide = message.loading('正在删除');
if (!selectedRows) return true;
try {
const ids = selectedRows.map(row => row.id).join(',');
await removeEmailVerifyRecord(ids);
hide();
message.success('删除成功');
return true;
} catch (error) {
hide();
message.error('删除失败,请重试');
return false;
}
};
const dateFieldList = ["send_time"]
const base_columns = [{
title: 'ID',
dataIndex: 'id',
hideInForm: true,
hideInSearch: true,
rules: [
{
required: true,
message: 'ID为必填项',
},
],
},{
title: '验证码',
dataIndex: 'code',
rules: [
{
required: true,
message: '验证码为必填项',
},
],
},{
title: '邮箱',
dataIndex: 'email',
rules: [
{
required: true,
message: '邮箱为必填项',
},
],
},{
title: '验证码类型',
dataIndex: 'send_type',
rules: [
{
required: true,
message: '验证码类型为必填项',
},
],
valueEnum: {
register:"注册",forget:"找回密码",update_email:"修改邮箱"
},
},{
title: '发送时间',
dataIndex: 'send_time',
valueType: 'dateTime',
hideInForm: true,
rules: [
{
required: true,
message: '发送时间为必填项',
},
],
render: (text, record) => {
return dealDateTimeDisplay(text);
},
}, {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 100,
render: (text, record) => (
<>
<EditOutlined title="编辑" className="icon" onClick={async () => {
record.send_time = moment(record.send_time);
handleUpdateModalVisible(true);
setUpdateFormValues(record);
}} />
<Divider type="vertical" />
<Popconfirm
title="您确定要删除邮箱验证码吗?"
placement="topRight"
onConfirm={() => {
handleRemove([record])
actionRef.current.reloadAndRest();
}}
okText="确定"
cancelText="取消"
>
<DeleteOutlined title="删除" className="icon" />
</Popconfirm>
</>
),
},];
let cp = deepCopy(base_columns);
const table_columns = getTableColumns(cp);
const update_columns = [...base_columns];
const create_columns = [...base_columns];
const [columnsStateMap, setColumnsStateMap] = useState({});
const [paramState, setParamState] = useState({});
return (
<PageHeaderWrapper>
<ProTable
beforeSearchSubmit={(params => {
dealTime(params, dateFieldList);
return params;
})}
params={paramState}
scroll={{x: '100%'}}
columnsStateMap={columnsStateMap}
onColumnsStateChange={(map) => setColumnsStateMap(map)}
headerTitle="邮箱验证码表格"
actionRef={actionRef}
rowKey="id"
toolBarRender={(action, {selectedRows}) => [
<Button type="primary" onClick={() => handleModalVisible(true)}>
<PlusOutlined /> 新建
</Button>,
<Input.Search style={{marginRight: 20}} placeholder="搜索邮箱验证码 " onSearch={value => {
setParamState({
search: value,
});
actionRef.current.reload();
}} />,
selectedRows && selectedRows.length > 0 && (
<Dropdown
overlay={
<Menu
onClick={async e => {
if (e.key === 'remove') {
await handleRemove(selectedRows);
actionRef.current.reloadAndRest();
}
}}
selectedKeys={[]}
>
<Menu.Item key="remove">批量删除</Menu.Item>
</Menu>
}
>
<Button>
批量操作 <DownOutlined />
</Button>
</Dropdown>
),
]}
tableAlertRender={({selectedRowKeys, selectedRows}) => (
selectedRowKeys.length > 0 ? <div>
已选择{' '}
<a
style={{
fontWeight: 600,
}}
>
{selectedRowKeys.length}
</a>{' '}
项
</div> : false
)}
request={(params, sorter, filter) => queryEmailVerifyRecord({...params, sorter, filter})}
columns={table_columns}
rowSelection={{}}
/>
<CreateForm onCancel={() => handleModalVisible(false)} modalVisible={createModalVisible}>
<ProTable
formRef={addFormRef}
onSubmit={async value => {
richTrans(value);
const success = await handleAdd(value);
if (success) {
handleModalVisible(false);
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
rowKey="key"
type="form"
form={
{
labelCol: {span: 6},
labelAlign: 'left',
}}
columns={create_columns}
rowSelection={{}}
/>
</CreateForm>
<UpdateForm onCancel={() => handleUpdateModalVisible(false)} modalVisible={updateModalVisible}>
<ProTable
formRef={updateFormRef}
onSubmit={async value => {
richTrans(value);
const success = await handleUpdate(value, updateFormValues.id);
if (success) {
handleUpdateModalVisible(false);
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
rowKey="key"
type="form"
form={{
initialValues: updateFormValues, labelCol: {span: 6},
labelAlign: 'left',
}}
columns={update_columns}
rowSelection={{}}
/>
</UpdateForm>
</PageHeaderWrapper>
);
}
Example #2
Source File: index.jsx From the-eye-knows-the-garbage with MIT License | 4 votes |
TableList = () => {
const [createModalVisible, handleModalVisible] = useState(false);
const [updateModalVisible, handleUpdateModalVisible] = useState(false);
const [updateFormValues, setUpdateFormValues] = useState({});
const actionRef = useRef();
const addFormRef = useRef();
const updateFormRef = useRef();
const handleAdd = async fields => {
const hide = message.loading('正在添加');
try {
await addTyAdminEmailVerifyRecord({ ...fields });
hide();
message.success('添加成功');
return true;
} catch (error) {
if ('fields_errors' in error.data) {
for (let key in error.data.fields_errors) {
var value = error.data.fields_errors[key];
addFormRef.current.setFields([
{
name: key,
errors: value,
},
]);
}
} else {
message.error('非字段类型错误');
}
hide();
message.error('添加失败');
return false;
}
};
const handleUpdate = async (value, current_id) => {
const hide = message.loading('正在修改');
try {
await updateTyAdminEmailVerifyRecord(value, current_id);
hide();
message.success('修改成功');
return true;
} catch (error) {
if ('fields_errors' in error.data) {
for (let key in error.data.fields_errors) {
var value = error.data.fields_errors[key];
updateFormRef.current.setFields([
{
name: key,
errors: value,
},
]);
}
} else {
message.error('非字段类型错误');
}
hide();
message.error('修改失败请重试!');
return false;
}
};
const handleRemove = async selectedRows => {
const hide = message.loading('正在删除');
if (!selectedRows) return true;
try {
const ids = selectedRows.map(row => row.id).join(',');
await removeTyAdminEmailVerifyRecord(ids);
hide();
message.success('删除成功');
return true;
} catch (error) {
hide();
message.error('删除失败,请重试');
return false;
}
};
const dateFieldList = ["send_time"]
const base_columns = [{
title: 'ID',
dataIndex: 'id',
hideInForm: true,
hideInSearch: true,
rules: [
{
required: true,
message: 'ID为必填项',
},
],
}, {
title: '验证码',
dataIndex: 'code',
rules: [
{
required: true,
message: '验证码为必填项',
},
],
}, {
title: '邮箱',
dataIndex: 'email',
rules: [
{
required: true,
message: '邮箱为必填项',
},
],
}, {
title: '验证码类型',
dataIndex: 'send_type',
rules: [
{
required: true,
message: '验证码类型为必填项',
},
],
valueEnum: {
register: "注册", forget: "找回密码", update_email: "修改邮箱", login_auth: "登录授权"
},
}, {
title: '发送时间',
dataIndex: 'send_time',
valueType: 'dateTime',
hideInForm: true,
rules: [
{
required: true,
message: '发送时间为必填项',
},
],
render: (text, record) => {
return dealDateTimeDisplay(text);
},
}, {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 100,
render: (text, record) => (
<>
<EditOutlined title="编辑" className="icon" onClick={async () => {
record.send_time = moment(record.send_time);
handleUpdateModalVisible(true);
setUpdateFormValues(record);
}} />
<Divider type="vertical" />
<Popconfirm
title="您确定要删除TyAdmin邮箱验证码吗?"
placement="topRight"
onConfirm={() => {
handleRemove([record])
actionRef.current.reloadAndRest();
}}
okText="确定"
cancelText="取消"
>
<DeleteOutlined title="删除" className="icon" />
</Popconfirm>
</>
),
},];
let cp = deepCopy(base_columns);
const table_columns = getTableColumns(cp);
const update_columns = [...base_columns];
const create_columns = [...base_columns];
const [columnsStateMap, setColumnsStateMap] = useState({});
const [paramState, setParamState] = useState({});
const [showDropdown, setShowDropdown] = useState(false)
return (
<PageHeaderWrapper>
<ProTable
beforeSearchSubmit={(params => {
dealTime(params, dateFieldList);
return params;
})}
params={paramState}
scroll={{ x: '100%' }}
columnsStateMap={columnsStateMap}
onColumnsStateChange={(map) => setColumnsStateMap(map)}
headerTitle="TyAdmin邮箱验证码表格"
actionRef={actionRef}
rowKey="id"
toolBarRender={(action, { selectedRows }) => [
<Button type="primary" onClick={() => handleModalVisible(true)}>
<PlusOutlined /> 新建
</Button>,
<Input.Search style={{ marginRight: 20 }} placeholder="搜索TyAdmin邮箱验证码 " onSearch={value => {
setParamState({
search: value,
});
actionRef.current.reload();
}} />,
selectedRows && selectedRows.length > 0 && (
<Dropdown
overlay={
<Menu
onClick={async e => {
if (e.key === 'remove') {
await handleRemove(selectedRows);
actionRef.current.reloadAndRest();
}
}}
selectedKeys={[]}
>
<Menu.Item key="remove">批量删除</Menu.Item>
</Menu>
}
>
<Button>
批量操作 <DownOutlined />
</Button>
</Dropdown>
),
]}
tableAlertRender={({ selectedRowKeys, selectedRows }) => (
selectedRowKeys.length > 0 ? <div>
已选择{' '}
<a
style={{
fontWeight: 600,
}}
>
{selectedRowKeys.length}
</a>{' '}
项
</div> : false
)}
request={(params, sorter, filter) => queryTyAdminEmailVerifyRecord({ ...params, sorter, filter })}
columns={table_columns}
rowSelection={{}}
/>
<CreateForm onCancel={() => handleModalVisible(false)} modalVisible={createModalVisible}>
<Card>
<DragTree />
</Card>
<Form >
<Form.Item
style={{ marginBottom: 24 }}
name="userName"
placeholder="菜单图标"
label="菜单图标"
rules={[
{
required: true,
message: '请输入用户名!',
},
]}
>
<IconDisplay />
</Form.Item>
</Form>
<ProTable
formRef={addFormRef}
onSubmit={async value => {
richTrans(value);
const success = await handleAdd(value);
if (success) {
handleModalVisible(false);
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
rowKey="key"
type="form"
form={
{
labelCol: { span: 6 },
labelAlign: 'left',
}}
columns={create_columns}
rowSelection={{}}
/>
</CreateForm>
<UpdateForm onCancel={() => handleUpdateModalVisible(false)} modalVisible={updateModalVisible}>
<ProTable
formRef={updateFormRef}
onSubmit={async value => {
richTrans(value);
const success = await handleUpdate(value, updateFormValues.id);
if (success) {
handleUpdateModalVisible(false);
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
rowKey="key"
type="form"
form={{
initialValues: updateFormValues, labelCol: { span: 6 },
labelAlign: 'left',
}}
columns={update_columns}
rowSelection={{}}
/>
</UpdateForm>
</PageHeaderWrapper>
);
}
Example #3
Source File: index.jsx From the-eye-knows-the-garbage with MIT License | 4 votes |
TableList = () => {
const [createModalVisible, handleModalVisible] = useState(false);
const [updateModalVisible, handleUpdateModalVisible] = useState(false);
const [updateFormValues, setUpdateFormValues] = useState({});
const actionRef = useRef();
const addFormRef = useRef();
const updateFormRef = useRef();
const handleAdd = async fields => {
const hide = message.loading('正在添加');
try {
await addTyAdminSysLog({...fields});
hide();
message.success('添加成功');
return true;
} catch (error) {
if ('fields_errors' in error.data) {
for (let key in error.data.fields_errors) {
var value = error.data.fields_errors[key];
addFormRef.current.setFields([
{
name: key,
errors: value,
},
]);
}
} else {
message.error('非字段类型错误');
}
hide();
message.error('添加失败');
return false;
}
};
const handleUpdate = async (value, current_id) => {
const hide = message.loading('正在修改');
try {
await updateTyAdminSysLog(value, current_id);
hide();
message.success('修改成功');
return true;
} catch (error) {
if ('fields_errors' in error.data) {
for (let key in error.data.fields_errors) {
var value = error.data.fields_errors[key];
updateFormRef.current.setFields([
{
name: key,
errors: value,
},
]);
}
} else {
message.error('非字段类型错误');
}
hide();
message.error('修改失败请重试!');
return false;
}
};
const handleRemove = async selectedRows => {
const hide = message.loading('正在删除');
if (!selectedRows) return true;
try {
const ids = selectedRows.map(row => row.id).join(',');
await removeTyAdminSysLog(ids);
hide();
message.success('删除成功');
return true;
} catch (error) {
hide();
message.error('删除失败,请重试');
return false;
}
};
const dateFieldList = ["action_time"]
const base_columns = [{
title: 'ID',
dataIndex: 'id',
hideInForm: true,
hideInSearch: true,
rules: [
{
required: true,
message: 'ID为必填项',
},
],
},{
title: '动作时间',
dataIndex: 'action_time',
valueType: 'dateTime',
hideInForm: true,
rules: [
{
required: true,
message: '动作时间为必填项',
},
],
render: (text, record) => {
return dealDateTimeDisplay(text);
},
},{
title: '操作ip',
dataIndex: 'ip_addr',
rules: [
{
required: true,
message: '操作ip为必填项',
},
],
},{
title: '操作flag',
dataIndex: 'action_flag',
rules: [
{
required: true,
message: '操作flag为必填项',
},
],
},{
title: '日志记录',
dataIndex: 'message',
valueType: 'textarea',
ellipsis: true,
rules: [
{
required: true,
message: '日志记录为必填项',
},
],
},{
title: '日志类型',
dataIndex: 'log_type',
rules: [
{
required: true,
message: '日志类型为必填项',
},
],
},{
title: '用户',
dataIndex: 'user_name',
rules: [
{
required: true,
message: '用户为必填项',
},
],
}, {
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 100,
render: (text, record) => (
<>
<EditOutlined title="编辑" className="icon" onClick={async () => {
record.action_time = moment(record.action_time);
handleUpdateModalVisible(true);
setUpdateFormValues(record);
}} />
<Divider type="vertical" />
<Popconfirm
title="您确定要删除系统日志吗?"
placement="topRight"
onConfirm={() => {
handleRemove([record])
actionRef.current.reloadAndRest();
}}
okText="确定"
cancelText="取消"
>
<DeleteOutlined title="删除" className="icon" />
</Popconfirm>
</>
),
},];
let cp = deepCopy(base_columns);
const table_columns = getTableColumns(cp);
const update_columns = [...base_columns];
const create_columns = [...base_columns];
const [columnsStateMap, setColumnsStateMap] = useState({});
const [paramState, setParamState] = useState({});
return (
<PageHeaderWrapper>
<ProTable
beforeSearchSubmit={(params => {
dealTime(params, dateFieldList);
return params;
})}
params={paramState}
scroll={{x: '100%'}}
columnsStateMap={columnsStateMap}
onColumnsStateChange={(map) => setColumnsStateMap(map)}
headerTitle="系统日志表格"
actionRef={actionRef}
rowKey="id"
toolBarRender={(action, {selectedRows}) => [
<Button type="primary" onClick={() => handleModalVisible(true)}>
<PlusOutlined /> 新建
</Button>,
<Input.Search style={{marginRight: 20}} placeholder="搜索系统日志 " onSearch={value => {
setParamState({
search: value,
});
actionRef.current.reload();
}} />,
selectedRows && selectedRows.length > 0 && (
<Dropdown
overlay={
<Menu
onClick={async e => {
if (e.key === 'remove') {
await handleRemove(selectedRows);
actionRef.current.reloadAndRest();
}
}}
selectedKeys={[]}
>
<Menu.Item key="remove">批量删除</Menu.Item>
</Menu>
}
>
<Button>
批量操作 <DownOutlined />
</Button>
</Dropdown>
),
]}
tableAlertRender={({selectedRowKeys, selectedRows}) => (
selectedRowKeys.length > 0 ? <div>
已选择{' '}
<a
style={{
fontWeight: 600,
}}
>
{selectedRowKeys.length}
</a>{' '}
项
</div> : false
)}
request={(params, sorter, filter) => queryTyAdminSysLog({...params, sorter, filter})}
columns={table_columns}
rowSelection={{}}
/>
<CreateForm onCancel={() => handleModalVisible(false)} modalVisible={createModalVisible}>
<ProTable
formRef={addFormRef}
onSubmit={async value => {
richTrans(value);
const success = await handleAdd(value);
if (success) {
handleModalVisible(false);
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
rowKey="key"
type="form"
form={
{
labelCol: {span: 6},
labelAlign: 'left',
}}
columns={create_columns}
rowSelection={{}}
/>
</CreateForm>
<UpdateForm onCancel={() => handleUpdateModalVisible(false)} modalVisible={updateModalVisible}>
<ProTable
formRef={updateFormRef}
onSubmit={async value => {
richTrans(value);
const success = await handleUpdate(value, updateFormValues.id);
if (success) {
handleUpdateModalVisible(false);
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
rowKey="key"
type="form"
form={{
initialValues: updateFormValues, labelCol: {span: 6},
labelAlign: 'left',
}}
columns={update_columns}
rowSelection={{}}
/>
</UpdateForm>
</PageHeaderWrapper>
);
}