feat(模块): 添加了个很棒的功能
This commit is contained in:
parent
bf17f9f44b
commit
f3966ac2c9
@ -18,10 +18,12 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
const { currentUser } = props
|
const { currentUser } = props
|
||||||
|
|
||||||
const actionRef = useRef<ActionType>();
|
const actionRef = useRef<ActionType>();
|
||||||
|
const cloneActionRef = useRef<ActionType>();
|
||||||
const formRef = useRef<FormInstance>();
|
const formRef = useRef<FormInstance>();
|
||||||
const modalActionRef = useRef<ActionType>();
|
const modalActionRef = useRef<ActionType>();
|
||||||
const modalFormRef = useRef<FormInstance>();
|
const modalFormRef = useRef<FormInstance>();
|
||||||
|
|
||||||
|
const cloneFormRef = useRef<FormInstance>();
|
||||||
|
|
||||||
|
|
||||||
// 弹出框的表单实例
|
// 弹出框的表单实例
|
||||||
@ -38,6 +40,8 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
const [currentRow, setCurrentRow] = useState<any>()
|
const [currentRow, setCurrentRow] = useState<any>()
|
||||||
// 服务区的枚举
|
// 服务区的枚举
|
||||||
const [serviceObj, setServiceObj] = useState<any>()
|
const [serviceObj, setServiceObj] = useState<any>()
|
||||||
|
// 服务区的全部数据
|
||||||
|
const [allServiceList, setAllServiceList] = useState<any>()
|
||||||
// 生成的二维码的初始
|
// 生成的二维码的初始
|
||||||
const [qrCodeUrl, setQrCodeUrl] = useState<string>()
|
const [qrCodeUrl, setQrCodeUrl] = useState<string>()
|
||||||
// 选择问题的悬浮框
|
// 选择问题的悬浮框
|
||||||
@ -64,6 +68,16 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
const [openAddQuestion, setOpenAddQuestion] = useState<boolean>(false)
|
const [openAddQuestion, setOpenAddQuestion] = useState<boolean>(false)
|
||||||
// 拿到protable的问题分类
|
// 拿到protable的问题分类
|
||||||
const [bigTypeList, setBigTypeList] = useState<any>()
|
const [bigTypeList, setBigTypeList] = useState<any>()
|
||||||
|
// 显示克隆悬浮框
|
||||||
|
const [showCloneModal, handleShowCloneModal] = useState<boolean>(false)
|
||||||
|
// 克隆的选择内容
|
||||||
|
const [selectedCloneId, setSelectedCloneId] = useState<any>()
|
||||||
|
const [selectedCloneDetail, setSelectedCloneDetail] = useState<any>()
|
||||||
|
// 默认展开行的id
|
||||||
|
const [defaultExpandRow, setDefaultExpandRow] = useState<any>()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const columns: any = [
|
const columns: any = [
|
||||||
// {
|
// {
|
||||||
@ -304,6 +318,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
})) : [];
|
})) : [];
|
||||||
setBigTypeList(formattedData);
|
setBigTypeList(formattedData);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchTreeData()
|
fetchTreeData()
|
||||||
}, [])
|
}, [])
|
||||||
@ -563,6 +578,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
obj[item.value] = item.label
|
obj[item.value] = item.label
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
setAllServiceList(data)
|
||||||
setServiceObj(obj)
|
setServiceObj(obj)
|
||||||
return data
|
return data
|
||||||
}}
|
}}
|
||||||
@ -586,13 +602,18 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
}]}
|
}]}
|
||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={8}>
|
<Col span={4}>
|
||||||
<ProFormSwitch
|
<ProFormSwitch
|
||||||
label={"有效状态"}
|
label={"有效状态"}
|
||||||
name={"status"}
|
name={"status"}
|
||||||
initialValue={currentRow?.id ? currentRow.status : true}
|
initialValue={currentRow?.id ? currentRow.status : true}
|
||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
|
<Col span={4}>
|
||||||
|
<Button type="primary" onClick={() => {
|
||||||
|
handleShowCloneModal(true)
|
||||||
|
}}>克隆点位</Button>
|
||||||
|
</Col>
|
||||||
<Col span={20}>
|
<Col span={20}>
|
||||||
<ProFormList
|
<ProFormList
|
||||||
name="questions"
|
name="questions"
|
||||||
@ -669,6 +690,7 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
width={1400}
|
width={1400}
|
||||||
title={`点位`}
|
title={`点位`}
|
||||||
open={selectQuestionModal}
|
open={selectQuestionModal}
|
||||||
|
|
||||||
destroyOnClose
|
destroyOnClose
|
||||||
onOk={() => {
|
onOk={() => {
|
||||||
console.log('selectedQuestionDetail', selectedQuestionDetail);
|
console.log('selectedQuestionDetail', selectedQuestionDetail);
|
||||||
@ -698,7 +720,9 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
actionRef={modalActionRef}
|
actionRef={modalActionRef}
|
||||||
formRef={modalFormRef}
|
formRef={modalFormRef}
|
||||||
columns={modalColumns}
|
columns={modalColumns}
|
||||||
rowKey={"id"}
|
rowKey={(record) => {
|
||||||
|
return `${record?.id}`
|
||||||
|
}}
|
||||||
scroll={{ y: 'calc(100vh - 500px)' }}
|
scroll={{ y: 'calc(100vh - 500px)' }}
|
||||||
request={async (params) => {
|
request={async (params) => {
|
||||||
console.log('查询参数:', params);
|
console.log('查询参数:', params);
|
||||||
@ -737,6 +761,161 @@ const examineModal: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
width={1500}
|
||||||
|
title={'克隆点位'}
|
||||||
|
open={showCloneModal}
|
||||||
|
destroyOnClose
|
||||||
|
onOk={() => {
|
||||||
|
console.log('selectedCloneId', selectedCloneId);
|
||||||
|
console.log('selectedCloneDetail', selectedCloneDetail);
|
||||||
|
|
||||||
|
let res: any = []
|
||||||
|
let detailList: any = []
|
||||||
|
let idList: any = []
|
||||||
|
let list: any = selectedCloneDetail[0].questionnaireTemplateQuestions
|
||||||
|
if (list && list.length > 0) {
|
||||||
|
list.forEach((item: any) => {
|
||||||
|
detailList.push(item)
|
||||||
|
idList.push(item.question.id.toString())
|
||||||
|
if (item.question) {
|
||||||
|
let obj = JSON.parse(JSON.stringify(item.question))
|
||||||
|
|
||||||
|
let str: string = ''
|
||||||
|
if (obj.options && obj?.options.length > 0) {
|
||||||
|
obj.options.forEach((subItem: any, index: number) => {
|
||||||
|
str += `${index > 0 ? ',' : ''}选项${index + 1}:${subItem.text}`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
obj.text = obj.title
|
||||||
|
obj.mark = JSON.stringify(obj.options)
|
||||||
|
obj.showText = str
|
||||||
|
res.push(obj)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
setSelectedQuestionDetail(detailList)
|
||||||
|
console.log('idList', idList);
|
||||||
|
|
||||||
|
setSelectedQuestionId(idList)
|
||||||
|
|
||||||
|
modalRef.current?.setFieldsValue({
|
||||||
|
questions: res
|
||||||
|
})
|
||||||
|
handleShowCloneModal(false)
|
||||||
|
}}
|
||||||
|
onCancel={() => {
|
||||||
|
handleShowCloneModal(false)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
|
||||||
|
<ProTable
|
||||||
|
actionRef={cloneActionRef}
|
||||||
|
formRef={cloneFormRef}
|
||||||
|
rowKey={(record) => {
|
||||||
|
return `${record?.id}`
|
||||||
|
}}
|
||||||
|
columns={[
|
||||||
|
{
|
||||||
|
title: <div style={{ textAlign: 'center' }}>服务区名称</div>,
|
||||||
|
dataIndex: "serverPartName",
|
||||||
|
// hideInSearch: true,
|
||||||
|
width: 200,
|
||||||
|
ellipsis: true,
|
||||||
|
render: (_, record) => {
|
||||||
|
return record?.type === 'district' || record?.type === 'servicePart' ? record?.name :
|
||||||
|
record?.title
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: <div style={{ textAlign: 'center' }}>问题列表</div>,
|
||||||
|
dataIndex: "questions",
|
||||||
|
hideInSearch: true,
|
||||||
|
width: 400,
|
||||||
|
ellipsis: true,
|
||||||
|
render: (_, record) => {
|
||||||
|
let questionStr: string = ""
|
||||||
|
if (record?.questionnaireTemplateQuestions && record?.questionnaireTemplateQuestions.length > 0) {
|
||||||
|
record?.questionnaireTemplateQuestions.forEach((item: any, index: number) => {
|
||||||
|
let options: string = ''
|
||||||
|
if (item.question.options && item.question.options.length > 0) {
|
||||||
|
item.question.options.forEach((subItem: any, subIndex: number) => {
|
||||||
|
options += `${subItem.text};`
|
||||||
|
// ${subIndex > 0 ? ',' : ''} 选项${subIndex + 1}:
|
||||||
|
})
|
||||||
|
}
|
||||||
|
questionStr += `${index > 0 ? ',' : ''}问题:${item.question.title}。${options}`
|
||||||
|
// ${index + 1}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return questionStr || ''
|
||||||
|
// return record?.questions && record?.questions.length > 0 ? JSON.stringify(record?.questions) : ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
request={async (params) => {
|
||||||
|
let selectId: string[] = []
|
||||||
|
console.log('cloneFormRef', cloneFormRef);
|
||||||
|
console.log('params', params);
|
||||||
|
|
||||||
|
if (allServiceList && allServiceList.length > 0) {
|
||||||
|
allServiceList.forEach((item: any) => {
|
||||||
|
selectId.push(item.value)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
console.log('selectId', selectId);
|
||||||
|
const req: any = {
|
||||||
|
serverPartIds: selectId,
|
||||||
|
any: params?.serverPartName ? [
|
||||||
|
{
|
||||||
|
key: "serverPartName",
|
||||||
|
value: params?.serverPartName
|
||||||
|
}
|
||||||
|
] : undefined
|
||||||
|
}
|
||||||
|
const data = await handleSearchModalTree(req)
|
||||||
|
console.log('dasdsa', data);
|
||||||
|
let defaultRow: any = []
|
||||||
|
|
||||||
|
if (data && data.length > 0) {
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
defaultRow.push(item.id.toString())
|
||||||
|
if (item.children && item.children.length > 0) {
|
||||||
|
item.children.forEach((subItem: any) => {
|
||||||
|
defaultRow.push(subItem.id.toString())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
console.log('defaultRow', defaultRow);
|
||||||
|
|
||||||
|
setDefaultExpandRow(defaultRow)
|
||||||
|
return { data, success: true }
|
||||||
|
}
|
||||||
|
setDefaultExpandRow(defaultRow)
|
||||||
|
return { data: [], success: true }
|
||||||
|
}}
|
||||||
|
expandable={{
|
||||||
|
expandedRowKeys: defaultExpandRow,
|
||||||
|
defaultExpandAllRows: true
|
||||||
|
}}
|
||||||
|
scroll={{ x: '100%', y: '500px' }}
|
||||||
|
rowSelection={{
|
||||||
|
type: "radio",
|
||||||
|
defaultSelectedRowKeys: selectedCloneId,
|
||||||
|
getCheckboxProps: (record) => ({
|
||||||
|
disabled: record.type === "district" || record.type === "servicePart",
|
||||||
|
}),
|
||||||
|
onChange: (selectedRowKeys, selectedRows) => {
|
||||||
|
setSelectedCloneDetail(selectedRows)
|
||||||
|
setSelectedCloneId(selectedRowKeys)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -176,32 +176,72 @@ const examineQuestion: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
|
|
||||||
// 递归 处理 将问题拼在列表的对应层 不一定是第二层
|
// 递归 处理 将问题拼在列表的对应层 不一定是第二层
|
||||||
const handleGetNewQuestion = (typeList: any, list: any) => {
|
const handleGetNewQuestion = (typeList: any, list: any) => {
|
||||||
let res: any = []
|
console.log('typeList', typeList);
|
||||||
if (typeList && typeList.length > 0) {
|
console.log('list', list);
|
||||||
typeList.forEach((item: any) => {
|
|
||||||
if (item.children && item.children.length > 0) {
|
|
||||||
let newRes = handleGetNewQuestion(item.children, list)
|
|
||||||
item.children = newRes
|
|
||||||
res.push(item)
|
|
||||||
} else {
|
|
||||||
if (list && list.length > 0) {
|
if (list && list.length > 0) {
|
||||||
list.forEach((subItem: any) => {
|
list.forEach((item: any) => {
|
||||||
if (subItem.categoryId === item.id) {
|
item.isNoChildren = true
|
||||||
if (item.children && item.children.length > 0) {
|
|
||||||
subItem.isNoChildren = true
|
|
||||||
item.children.push(subItem)
|
|
||||||
} else {
|
|
||||||
subItem.isNoChildren = true
|
|
||||||
item.children = [subItem]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
res.push(item)
|
// 递归查找并插入匹配项的函数
|
||||||
|
const findAndInsert = (nodes: any[], itemsToInsert: any[]) => {
|
||||||
|
for (const node of nodes) {
|
||||||
|
// 在当前节点的子节点中查找匹配
|
||||||
|
if (node.children) {
|
||||||
|
findAndInsert(node.children, itemsToInsert);
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
// 检查当前节点是否匹配list中的categoryId
|
||||||
|
const matchedItems = itemsToInsert.filter(item => item.categoryId === node.id);
|
||||||
|
|
||||||
|
if (matchedItems.length > 0) {
|
||||||
|
// 如果匹配到,初始化children数组(如果不存在)
|
||||||
|
if (!node.children) {
|
||||||
|
node.children = [];
|
||||||
}
|
}
|
||||||
return res
|
|
||||||
|
// 将匹配到的项添加到children中
|
||||||
|
node.children.push(...matchedItems);
|
||||||
|
|
||||||
|
// 从待插入列表中移除已处理的项
|
||||||
|
itemsToInsert = itemsToInsert.filter(item => !matchedItems.includes(item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 创建list的副本以避免修改原数组
|
||||||
|
const itemsToInsert = [...list];
|
||||||
|
|
||||||
|
// 开始递归处理
|
||||||
|
findAndInsert(typeList, itemsToInsert);
|
||||||
|
return typeList
|
||||||
|
|
||||||
|
// let res: any = []
|
||||||
|
// if (typeList && typeList.length > 0) {
|
||||||
|
// typeList.forEach((item: any) => {
|
||||||
|
// if (item.children && item.children.length > 0) {
|
||||||
|
// let newRes = handleGetNewQuestion(item.children, list)
|
||||||
|
// item.children = newRes
|
||||||
|
// res.push(item)
|
||||||
|
// } else {
|
||||||
|
// if (list && list.length > 0) {
|
||||||
|
// list.forEach((subItem: any) => {
|
||||||
|
// if (subItem.categoryId === item.id) {
|
||||||
|
// if (item.children && item.children.length > 0) {
|
||||||
|
// subItem.isNoChildren = true
|
||||||
|
// item.children.push(subItem)
|
||||||
|
// } else {
|
||||||
|
// subItem.isNoChildren = true
|
||||||
|
// item.children = [subItem]
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// res.push(item)
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// return res
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -245,10 +285,10 @@ const examineQuestion: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
any: params?.title ? [{ key: "title", value: params?.title }] : undefined
|
any: params?.title ? [{ key: "title", value: params?.title }] : undefined
|
||||||
}
|
}
|
||||||
const data = await handleGetQuestionList(req)
|
const data = await handleGetQuestionList(req)
|
||||||
console.log('data', data);
|
console.log('data3231231231', data);
|
||||||
|
|
||||||
let res = await handleGetNewQuestion(typeData, data)
|
let res = await handleGetNewQuestion(typeData, data)
|
||||||
console.log('res', res);
|
console.log('res432423', res);
|
||||||
if (res && res.length > 0) {
|
if (res && res.length > 0) {
|
||||||
return { data: res, success: true }
|
return { data: res, success: true }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,13 +79,29 @@ const recordSummary: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
width: 150,
|
width: 150,
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
render: (_, record) => {
|
render: (_, record) => {
|
||||||
return record?.template?.id && record?.inspectionNumber > 0 ? <a onClick={() => {
|
return record?.template?.id && record?.inspectionNumber > 0 ? <span>
|
||||||
|
<a style={{ color: record?.inspectionNumber === record?.allDay ? '' : 'red' }} onClick={() => {
|
||||||
setCurrentRow(record)
|
setCurrentRow(record)
|
||||||
setShowType(1)
|
setShowType(1)
|
||||||
setShowDetail(true)
|
setShowDetail(true)
|
||||||
}}>
|
}}>
|
||||||
{record?.inspectionNumber || '-'}
|
{record?.inspectionNumber || '-'}
|
||||||
</a> : <span>{record?.inspectionNumber || '-'}</span>
|
</a> / {record?.allDay}
|
||||||
|
</span > : <span><span style={{ color: record?.inspectionNumber === record?.allDay ? '' : 'red' }}>{record?.inspectionNumber || '-'} </span><span>/ {record?.allDay}</span></span>
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: <div style={{ textAlign: 'center' }}>巡查完成率</div>,
|
||||||
|
dataIndex: "inspectionRate",
|
||||||
|
align: 'center',
|
||||||
|
hideInSearch: true,
|
||||||
|
width: 150,
|
||||||
|
ellipsis: true,
|
||||||
|
render: (_, record) => {
|
||||||
|
return record?.allDay ?
|
||||||
|
<span style={{ color: record?.inspectionNumber === record?.allDay ? '' : 'red' }}>
|
||||||
|
{((record?.inspectionNumber / record?.allDay) * 100).toFixed(2) + '%'}
|
||||||
|
</span> : ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -172,6 +188,19 @@ const recordSummary: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
{record?.processedNumber || '-'}
|
{record?.processedNumber || '-'}
|
||||||
</a> : <span>{record?.processedNumber || '-'}</span>
|
</a> : <span>{record?.processedNumber || '-'}</span>
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: <div style={{ textAlign: 'center' }}>处理完成率</div>,
|
||||||
|
dataIndex: "processedRate",
|
||||||
|
align: 'center',
|
||||||
|
hideInSearch: true,
|
||||||
|
width: 150,
|
||||||
|
ellipsis: true,
|
||||||
|
render: (_, record) => {
|
||||||
|
return record?.errorNumber ? <span style={{ color: record?.processedNumber === record?.errorNumber ? '' : 'red' }}>
|
||||||
|
{((record?.processedNumber / record?.errorNumber) * 100).toFixed(2)}%
|
||||||
|
</span> : ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -351,6 +380,10 @@ const recordSummary: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
}] : undefined
|
}] : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let allDay: number = moment(params?.endTime).diff(params?.startTime, 'd') + 1
|
||||||
|
console.log('allDay', allDay);
|
||||||
|
|
||||||
|
|
||||||
setSearchParams(params)
|
setSearchParams(params)
|
||||||
|
|
||||||
console.log('req', req);
|
console.log('req', req);
|
||||||
@ -367,17 +400,23 @@ const recordSummary: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
let templateIdList: number[] = []
|
let templateIdList: number[] = []
|
||||||
// 遍历完之后 要替换的
|
// 遍历完之后 要替换的
|
||||||
let newChildren: any = []
|
let newChildren: any = []
|
||||||
|
// 因为一天时间内 多条记录 需要被计算为一条 那么这里就要加上时间的对象来筛选
|
||||||
|
let dateObj: any = {}
|
||||||
subItem.children.forEach((thirdItem: any) => {
|
subItem.children.forEach((thirdItem: any) => {
|
||||||
let extendObj: any = {}
|
let extendObj: any = {}
|
||||||
if (thirdItem.extend) {
|
if (thirdItem.extend) {
|
||||||
extendObj = JSON.parse(thirdItem.extend)
|
extendObj = JSON.parse(thirdItem.extend)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let oldDateList = dateObj[moment(thirdItem.createdAt).format('YYYY-MM-DD')]
|
||||||
|
|
||||||
|
if (!oldDateList || (oldDateList && oldDateList.indexOf(thirdItem.template.id) === -1)) {
|
||||||
|
// templateIdList 是判断 newChildren 里面已经有几个点位id了
|
||||||
if (templateIdList.indexOf(thirdItem.template.id) === -1) {
|
if (templateIdList.indexOf(thirdItem.template.id) === -1) {
|
||||||
templateIdList.push(thirdItem.template.id)
|
templateIdList.push(thirdItem.template.id)
|
||||||
// 没有过的点位数据 就给他默认值
|
|
||||||
newChildren.push({
|
newChildren.push({
|
||||||
template: thirdItem.template,
|
template: thirdItem.template,
|
||||||
|
templateId: thirdItem.template.Id,
|
||||||
inspectionNumber: 1,
|
inspectionNumber: 1,
|
||||||
normalNumber: extendObj?.situation === 0 ? 1 : 0,
|
normalNumber: extendObj?.situation === 0 ? 1 : 0,
|
||||||
errorNumber: extendObj?.situation === 1 ? 1 : 0,
|
errorNumber: extendObj?.situation === 1 ? 1 : 0,
|
||||||
@ -386,10 +425,9 @@ const recordSummary: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
processedNumber: extendObj?.errorStatus === 2 ? 1 : 0,
|
processedNumber: extendObj?.errorStatus === 2 ? 1 : 0,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// 如果已经有过了的点位 给他加当前的状态就好
|
|
||||||
if (newChildren && newChildren.length > 0) {
|
|
||||||
newChildren.forEach((fourthItem: any) => {
|
newChildren.forEach((fourthItem: any) => {
|
||||||
if (fourthItem.template.id === thirdItem.template.id) {
|
if (fourthItem.template.id === thirdItem.template.id) {
|
||||||
|
|
||||||
fourthItem.inspectionNumber += 1
|
fourthItem.inspectionNumber += 1
|
||||||
if (extendObj?.situation === 0) {
|
if (extendObj?.situation === 0) {
|
||||||
fourthItem.normalNumber += 1
|
fourthItem.normalNumber += 1
|
||||||
@ -407,7 +445,62 @@ const recordSummary: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oldDateList && oldDateList.length > 0) {
|
||||||
|
oldDateList.push(thirdItem.template.id)
|
||||||
|
} else {
|
||||||
|
dateObj[moment(thirdItem.createdAt).format('YYYY-MM-DD')] = [thirdItem.template.id]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (templateIdList.indexOf(thirdItem.template.id) === -1) {
|
||||||
|
// templateIdList.push(thirdItem.template.id)
|
||||||
|
// // 没有过的点位数据 就给他默认值
|
||||||
|
// newChildren.push({
|
||||||
|
// template: thirdItem.template,
|
||||||
|
// inspectionNumber: 1,
|
||||||
|
// normalNumber: extendObj?.situation === 0 ? 1 : 0,
|
||||||
|
// errorNumber: extendObj?.situation === 1 ? 1 : 0,
|
||||||
|
// pendingProcessNumber: extendObj?.errorStatus === 0 ? 1 : 0,
|
||||||
|
// processingNumber: extendObj?.errorStatus === 1 ? 1 : 0,
|
||||||
|
// processedNumber: extendObj?.errorStatus === 2 ? 1 : 0,
|
||||||
|
// })
|
||||||
|
// } else {
|
||||||
|
// // 如果已经有过了的点位 给他加当前的状态就好
|
||||||
|
// let nowDayData = dateObj[moment(thirdItem.createdAt).format('YYYY-MM-DD')]
|
||||||
|
// // 判断这一天 这个点位 是否已经有过了
|
||||||
|
// let isHave: boolean = false
|
||||||
|
// if (nowDayData && nowDayData.length > 0) {
|
||||||
|
// if (nowDayData.indexOf(thirdItem.template.id) !== -1) {
|
||||||
|
// isHave = true
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (!isHave) {
|
||||||
|
// if (newChildren && newChildren.length > 0) {
|
||||||
|
// newChildren.forEach((fourthItem: any) => {
|
||||||
|
// if (fourthItem.template.id === thirdItem.template.id) {
|
||||||
|
|
||||||
|
// fourthItem.inspectionNumber += 1
|
||||||
|
// if (extendObj?.situation === 0) {
|
||||||
|
// fourthItem.normalNumber += 1
|
||||||
|
// } else if (extendObj?.situation === 1) {
|
||||||
|
// fourthItem.errorNumber += 1
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (extendObj?.errorStatus === 0) {
|
||||||
|
// fourthItem.pendingProcessNumber += 1
|
||||||
|
// } else if (extendObj?.errorStatus === 1) {
|
||||||
|
// fourthItem.processingNumber += 1
|
||||||
|
// } else if (extendObj?.errorStatus === 2) {
|
||||||
|
// fourthItem.processedNumber += 1
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
console.log('dateObj', dateObj);
|
||||||
|
|
||||||
})
|
})
|
||||||
subItem.children = newChildren
|
subItem.children = newChildren
|
||||||
}
|
}
|
||||||
@ -423,6 +516,8 @@ const recordSummary: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
let pendingProcessNumberItemSum: number = 0
|
let pendingProcessNumberItemSum: number = 0
|
||||||
let processingNumberItemSum: number = 0
|
let processingNumberItemSum: number = 0
|
||||||
let processedNumberItemSum: number = 0
|
let processedNumberItemSum: number = 0
|
||||||
|
// 这一次时间段应该查询的次数(天数)
|
||||||
|
let allItemDaySum: number = 0
|
||||||
if (item.children && item.children.length > 0) {
|
if (item.children && item.children.length > 0) {
|
||||||
item.children.forEach((subItem: any) => {
|
item.children.forEach((subItem: any) => {
|
||||||
let inspectionNumberSum: number = 0
|
let inspectionNumberSum: number = 0
|
||||||
@ -431,8 +526,12 @@ const recordSummary: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
let pendingProcessNumberSum: number = 0
|
let pendingProcessNumberSum: number = 0
|
||||||
let processingNumberSum: number = 0
|
let processingNumberSum: number = 0
|
||||||
let processedNumberSum: number = 0
|
let processedNumberSum: number = 0
|
||||||
|
// 这一次时间段应该查询的次数(天数)
|
||||||
|
let allSubItemDaySum: number = 0
|
||||||
if (subItem.children && subItem.children.length > 0) {
|
if (subItem.children && subItem.children.length > 0) {
|
||||||
subItem.children.forEach((thirdItem: any) => {
|
subItem.children.forEach((thirdItem: any) => {
|
||||||
|
thirdItem.allDay = allDay
|
||||||
|
allSubItemDaySum += thirdItem.allDay
|
||||||
inspectionNumberSum += thirdItem.inspectionNumber
|
inspectionNumberSum += thirdItem.inspectionNumber
|
||||||
normalNumberSum += thirdItem.normalNumber
|
normalNumberSum += thirdItem.normalNumber
|
||||||
errorNumberSum += thirdItem.errorNumber
|
errorNumberSum += thirdItem.errorNumber
|
||||||
@ -441,6 +540,7 @@ const recordSummary: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
processedNumberSum += thirdItem.processedNumber
|
processedNumberSum += thirdItem.processedNumber
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
subItem.allDay = allSubItemDaySum
|
||||||
subItem.inspectionNumber = inspectionNumberSum
|
subItem.inspectionNumber = inspectionNumberSum
|
||||||
subItem.normalNumber = normalNumberSum
|
subItem.normalNumber = normalNumberSum
|
||||||
subItem.errorNumber = errorNumberSum
|
subItem.errorNumber = errorNumberSum
|
||||||
@ -454,7 +554,9 @@ const recordSummary: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
pendingProcessNumberItemSum += subItem.pendingProcessNumber
|
pendingProcessNumberItemSum += subItem.pendingProcessNumber
|
||||||
processingNumberItemSum += subItem.processingNumber
|
processingNumberItemSum += subItem.processingNumber
|
||||||
processedNumberItemSum += subItem.processedNumber
|
processedNumberItemSum += subItem.processedNumber
|
||||||
|
allItemDaySum += subItem.allDay
|
||||||
})
|
})
|
||||||
|
item.allDay = allItemDaySum
|
||||||
item.inspectionNumber = inspectionNumberItemSum
|
item.inspectionNumber = inspectionNumberItemSum
|
||||||
item.normalNumber = normalNumberItemSum
|
item.normalNumber = normalNumberItemSum
|
||||||
item.errorNumber = errorNumberItemSum
|
item.errorNumber = errorNumberItemSum
|
||||||
@ -586,7 +688,21 @@ const recordSummary: React.FC<{ currentUser: any }> = (props) => {
|
|||||||
console.log('data', data);
|
console.log('data', data);
|
||||||
|
|
||||||
if (data && data.length > 0) {
|
if (data && data.length > 0) {
|
||||||
return { data, success: true }
|
|
||||||
|
// 最后结果直接输出第三层的数据 好看点
|
||||||
|
let res: any = []
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
if (item.children && item.children.length > 0) {
|
||||||
|
item.children.forEach((subItem: any) => {
|
||||||
|
if (subItem.children && subItem.children.length > 0) {
|
||||||
|
subItem.children.forEach((thirdItem: any) => {
|
||||||
|
res.push(thirdItem)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return { data: res, success: true }
|
||||||
}
|
}
|
||||||
return { data: [], success: true }
|
return { data: [], success: true }
|
||||||
}}
|
}}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user