Browse Source

二维码

master
wenlele 2 years ago
parent
commit
86558e038d
  1. 14
      api/app/lib/controllers/projectRegime/projectSituation.js
  2. 153
      api/log/development.log
  3. 194
      web/client/src/sections/projectRegime/containers/qrCode.js
  4. 3
      web/log/development.txt

14
api/app/lib/controllers/projectRegime/projectSituation.js

@ -5,7 +5,7 @@ async function projectList (ctx, next) {
try {
const models = ctx.fs.dc.models;
let userInfo = ctx.fs.api.userInfo;
const { limit, page, name } = ctx.query;
const { limit, page, name, justStructure } = ctx.query;
let options = {
// where: {
@ -27,7 +27,15 @@ async function projectList (ctx, next) {
options.where.name = { $like: `%${name}%` }
}
let res = await models.Project.findAndCountAll(options)
let res = []
if (justStructure) {
res = await models.Project.findAndCountAll({
attributes: ['id', 'name'],
})
} else {
res = await models.Project.findAndCountAll(options)
}
ctx.status = 200;
ctx.body = res
} catch (error) {
@ -126,7 +134,7 @@ async function addPosition (ctx, next) {
})
if (data && data.id) {
await models.Point.update({qrCode}, {
await models.Point.update({ qrCode }, {
where: {
id: data.id,
}

153
api/log/development.log

@ -3693,3 +3693,156 @@ notNull Violation: project.describe cannot be null
2023-01-16 20:10:44.871 - debug: [FS-LOGGER] Init.
2023-01-16 20:10:45.117 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2023-01-16 20:10:45.118 - info: [FS-AUTH] Inject auth and api mv into router.
2023-01-16 20:22:59.211 - debug: [FS-LOGGER] Init.
2023-01-16 20:22:59.471 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2023-01-16 20:22:59.472 - info: [FS-AUTH] Inject auth and api mv into router.
2023-01-16 20:40:45.060 - debug: [FS-LOGGER] Init.
2023-01-16 20:40:45.303 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2023-01-16 20:40:45.304 - info: [FS-AUTH] Inject auth and api mv into router.
2023-01-16 20:40:46.015 - error: [app]
{
message: 'structure is not defined',
stack: 'ReferenceError: structure is not defined\n' +
' at Object.<anonymous> (C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\controllers\\projectRegime\\projectSituation.js:222:4)\n' +
' at Module._compile (internal/modules/cjs/loader.js:999:30)\n' +
' at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)\n' +
' at Module.load (internal/modules/cjs/loader.js:863:32)\n' +
' at Function.Module._load (internal/modules/cjs/loader.js:708:14)\n' +
' at Module.require (internal/modules/cjs/loader.js:887:19)\n' +
' at require (internal/modules/cjs/helpers.js:74:18)\n' +
' at Object.<anonymous> (C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\projectRegime\\index.js:3:26)\n' +
' at Module._compile (internal/modules/cjs/loader.js:999:30)\n' +
' at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)\n' +
' at Module.load (internal/modules/cjs/loader.js:863:32)\n' +
' at Function.Module._load (internal/modules/cjs/loader.js:708:14)\n' +
' at Module.require (internal/modules/cjs/loader.js:887:19)\n' +
' at require (internal/modules/cjs/helpers.js:74:18)\n' +
' at C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\index.js:11:13\n' +
' at Array.forEach (<anonymous>)\n' +
' at C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\index.js:9:57\n' +
' at Array.forEach (<anonymous>)\n' +
' at module.exports (C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\index.js:7:30)\n' +
' at Object.module.exports.entry (C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\index.js:46:13)\n' +
' at C:\\Users\\方式、\\Desktop\\Inspection\\api\\node_modules\\fs-web-server-scaffold\\index.js:74:20\n' +
' at Array.forEach (<anonymous>)'
}
2023-01-16 20:42:54.205 - debug: [FS-LOGGER] Init.
2023-01-16 20:42:54.456 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2023-01-16 20:42:54.456 - info: [FS-AUTH] Inject auth and api mv into router.
2023-01-16 20:42:55.311 - error: [app]
{
message: 'structure is not defined',
stack: 'ReferenceError: structure is not defined\n' +
' at Object.<anonymous> (C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\controllers\\projectRegime\\projectSituation.js:222:4)\n' +
' at Module._compile (internal/modules/cjs/loader.js:999:30)\n' +
' at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)\n' +
' at Module.load (internal/modules/cjs/loader.js:863:32)\n' +
' at Function.Module._load (internal/modules/cjs/loader.js:708:14)\n' +
' at Module.require (internal/modules/cjs/loader.js:887:19)\n' +
' at require (internal/modules/cjs/helpers.js:74:18)\n' +
' at Object.<anonymous> (C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\projectRegime\\index.js:3:26)\n' +
' at Module._compile (internal/modules/cjs/loader.js:999:30)\n' +
' at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)\n' +
' at Module.load (internal/modules/cjs/loader.js:863:32)\n' +
' at Function.Module._load (internal/modules/cjs/loader.js:708:14)\n' +
' at Module.require (internal/modules/cjs/loader.js:887:19)\n' +
' at require (internal/modules/cjs/helpers.js:74:18)\n' +
' at C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\index.js:11:13\n' +
' at Array.forEach (<anonymous>)\n' +
' at C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\index.js:9:57\n' +
' at Array.forEach (<anonymous>)\n' +
' at module.exports (C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\index.js:7:30)\n' +
' at Object.module.exports.entry (C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\index.js:46:13)\n' +
' at C:\\Users\\方式、\\Desktop\\Inspection\\api\\node_modules\\fs-web-server-scaffold\\index.js:74:20\n' +
' at Array.forEach (<anonymous>)'
}
2023-01-16 20:43:03.908 - debug: [FS-LOGGER] Init.
2023-01-16 20:43:04.191 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2023-01-16 20:43:04.191 - info: [FS-AUTH] Inject auth and api mv into router.
2023-01-16 20:43:05.048 - error: [app]
{
message: 'structure is not defined',
stack: 'ReferenceError: structure is not defined\n' +
' at Object.<anonymous> (C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\controllers\\projectRegime\\projectSituation.js:222:4)\n' +
' at Module._compile (internal/modules/cjs/loader.js:999:30)\n' +
' at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)\n' +
' at Module.load (internal/modules/cjs/loader.js:863:32)\n' +
' at Function.Module._load (internal/modules/cjs/loader.js:708:14)\n' +
' at Module.require (internal/modules/cjs/loader.js:887:19)\n' +
' at require (internal/modules/cjs/helpers.js:74:18)\n' +
' at Object.<anonymous> (C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\projectRegime\\index.js:3:26)\n' +
' at Module._compile (internal/modules/cjs/loader.js:999:30)\n' +
' at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)\n' +
' at Module.load (internal/modules/cjs/loader.js:863:32)\n' +
' at Function.Module._load (internal/modules/cjs/loader.js:708:14)\n' +
' at Module.require (internal/modules/cjs/loader.js:887:19)\n' +
' at require (internal/modules/cjs/helpers.js:74:18)\n' +
' at C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\index.js:11:13\n' +
' at Array.forEach (<anonymous>)\n' +
' at C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\index.js:9:57\n' +
' at Array.forEach (<anonymous>)\n' +
' at module.exports (C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\index.js:7:30)\n' +
' at Object.module.exports.entry (C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\index.js:46:13)\n' +
' at C:\\Users\\方式、\\Desktop\\Inspection\\api\\node_modules\\fs-web-server-scaffold\\index.js:74:20\n' +
' at Array.forEach (<anonymous>)'
}
2023-01-16 20:43:26.424 - debug: [FS-LOGGER] Init.
2023-01-16 20:43:26.690 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2023-01-16 20:43:26.690 - info: [FS-AUTH] Inject auth and api mv into router.
2023-01-16 20:43:27.546 - error: [app]
{
message: 'structure is not defined',
stack: 'ReferenceError: structure is not defined\n' +
' at Object.<anonymous> (C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\controllers\\projectRegime\\projectSituation.js:222:4)\n' +
' at Module._compile (internal/modules/cjs/loader.js:999:30)\n' +
' at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)\n' +
' at Module.load (internal/modules/cjs/loader.js:863:32)\n' +
' at Function.Module._load (internal/modules/cjs/loader.js:708:14)\n' +
' at Module.require (internal/modules/cjs/loader.js:887:19)\n' +
' at require (internal/modules/cjs/helpers.js:74:18)\n' +
' at Object.<anonymous> (C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\projectRegime\\index.js:3:26)\n' +
' at Module._compile (internal/modules/cjs/loader.js:999:30)\n' +
' at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)\n' +
' at Module.load (internal/modules/cjs/loader.js:863:32)\n' +
' at Function.Module._load (internal/modules/cjs/loader.js:708:14)\n' +
' at Module.require (internal/modules/cjs/loader.js:887:19)\n' +
' at require (internal/modules/cjs/helpers.js:74:18)\n' +
' at C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\index.js:11:13\n' +
' at Array.forEach (<anonymous>)\n' +
' at C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\index.js:9:57\n' +
' at Array.forEach (<anonymous>)\n' +
' at module.exports (C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\index.js:7:30)\n' +
' at Object.module.exports.entry (C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\index.js:46:13)\n' +
' at C:\\Users\\方式、\\Desktop\\Inspection\\api\\node_modules\\fs-web-server-scaffold\\index.js:74:20\n' +
' at Array.forEach (<anonymous>)'
}
2023-01-16 20:44:04.976 - debug: [FS-LOGGER] Init.
2023-01-16 20:44:05.224 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2023-01-16 20:44:05.224 - info: [FS-AUTH] Inject auth and api mv into router.
2023-01-16 20:44:06.085 - error: [app]
{
message: 'structure is not defined',
stack: 'ReferenceError: structure is not defined\n' +
' at Object.<anonymous> (C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\controllers\\projectRegime\\projectSituation.js:222:4)\n' +
' at Module._compile (internal/modules/cjs/loader.js:999:30)\n' +
' at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)\n' +
' at Module.load (internal/modules/cjs/loader.js:863:32)\n' +
' at Function.Module._load (internal/modules/cjs/loader.js:708:14)\n' +
' at Module.require (internal/modules/cjs/loader.js:887:19)\n' +
' at require (internal/modules/cjs/helpers.js:74:18)\n' +
' at Object.<anonymous> (C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\projectRegime\\index.js:3:26)\n' +
' at Module._compile (internal/modules/cjs/loader.js:999:30)\n' +
' at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)\n' +
' at Module.load (internal/modules/cjs/loader.js:863:32)\n' +
' at Function.Module._load (internal/modules/cjs/loader.js:708:14)\n' +
' at Module.require (internal/modules/cjs/loader.js:887:19)\n' +
' at require (internal/modules/cjs/helpers.js:74:18)\n' +
' at C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\index.js:11:13\n' +
' at Array.forEach (<anonymous>)\n' +
' at C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\index.js:9:57\n' +
' at Array.forEach (<anonymous>)\n' +
' at module.exports (C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\index.js:7:30)\n' +
' at Object.module.exports.entry (C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\index.js:46:13)\n' +
' at C:\\Users\\方式、\\Desktop\\Inspection\\api\\node_modules\\fs-web-server-scaffold\\index.js:74:20\n' +
' at Array.forEach (<anonymous>)'
}

194
web/client/src/sections/projectRegime/containers/qrCode.js

@ -23,22 +23,11 @@ const QrCode = (props) => {
useEffect(() => {
dispatch(projectRegime.getFirmList()).then(res => {
dispatch(projectRegime.getProjectList({ justStructure: true })).then(res => {
if (res.success) {
let data = res.payload.data?.map(r => ({ value: r.id, label: r.name }))
if (user?.role?.type == 1) {
setFirmList(data)
projectList(query)
} else if (user?.role?.type == 2) {
let dataId = user?.userDepartments[0]?.department?.company?.id
setFirmList(data?.filter(v => v.value == dataId))
projectList({ ...query, companyId: dataId })
setSearch({ companyId: dataId })
setCompanyId(dataId)
}
setFirmList(res.payload.data?.rows?.map(v => ({ value: v.id, label: v.name })))
}
})
}, [])
const projectList = (obj) => {
@ -52,89 +41,6 @@ const QrCode = (props) => {
})
}
const columns = [
{
title: '序号',
dataIndex: 'index',
key: 'index',
render: (text, record, index) => index + 1
}, {
title: '工程项目名称',
dataIndex: 'name',
key: 'name',
}, {
title: '项目类型',
dataIndex: 'type',
key: 'type',
}, {
title: '建设规模',
dataIndex: 'scale',
key: 'scale',
render: (text, record, index) => record?.scale?.scale + record?.scale?.scaleSuffix
}, {
title: '合同(投资)金额',
dataIndex: 'amount',
key: 'amount',
render: (text, record, index) => record?.amount?.amount + record?.amount?.amountSuffix
}, {
title: '负责人',
dataIndex: 'peopleInCharge',
key: 'peopleInCharge',
}, {
title: '负责人联系方式',
dataIndex: 'tel',
key: 'tel',
}, {
title: '操作',
dataIndex: 'operation',
key: 'operation',
render: (text, record, index) => {
return (
<div style={{ width: 180 }}>
{(user?.isSuper || user.id == record.userId) ?
<>
<Button type="link" onClick={() => {
setAddModel(true)
setModelData(record)
}}
>编辑</Button>
<Popconfirm
title='确认删除工程信息?'
position='topLeft'
onConfirm={() => {
dispatch(projectRegime.delProject(record.id)).then(res => {
if (res.success) {
if ((limits > 11 && tableList.length > 1) || limits < 11) {
projectList({ ...query, ...search })
} else {
projectList({ limit: query?.limit, page: query?.page - 1, ...search })
setQuery({ limit: query?.limit, page: query?.page - 1 });
}
}
})
}}
>
<Button type="link" danger >删除</Button>
</Popconfirm>
</>
: <>
<Tooltip title='请联系工程创建者'>
<Button type="link" >编辑</Button>
</Tooltip>
<Tooltip title='请联系工程创建者'>
<Button type="link" danger >删除</Button>
</Tooltip>
</>
}
</div>
)
}
}
]
return (
<>
@ -142,8 +48,7 @@ const QrCode = (props) => {
<Form
style={{ display: 'flex', }}
onFinish={r => {
projectList({ limit: 10, page: 0, ...r, companyId: companyID || r?.companyId })
setQuery({ limit: 10, page: 0 });
projectList(r)
setSearch(r)
}}
>
@ -151,18 +56,10 @@ const QrCode = (props) => {
label='所属公司'
name="companyId"
style={{ marginRight: 16, minWidth: 180 }}
initialValue={firmList[0]?.name}
>
<Select allowClear placeholder="全部" options={firmList} />
</Form.Item>
<Form.Item label='项目类型' name="type" style={{ marginRight: 16, minWidth: 180 }} >
<Select
allowClear
placeholder="全部类型"
options={[{ value: '房建', label: '房建' }, { value: '市政', label: '市政' }, { value: '道路桥梁', label: '道路桥梁' }, { value: '其他', label: '其他' }]}
/>
</Form.Item>
<Form.Item
label='项目名称'
name="name"
@ -181,88 +78,7 @@ const QrCode = (props) => {
setAddModel(true)
}}>新建项目</Button>
</div>
<Table
columns={columns}
dataSource={tableList}
expandable={{
expandedRowRender: record => {
let data = [
{ name: '项目图片:', value: record.img },
{ name: '项目类型:', value: record.type },
{ name: '建设规模:', value: record.scale?.scale + record.scale?.scaleSuffix },
{ name: '项目地址:', value: record.address },
{ name: '监理单位:', value: record.supervisor },
{ name: '施工单位:', value: record.contractor },
{ name: '设计单位:', value: record.designer },
{ name: '建筑单位:', value: record.builder },
{ name: '开始时间:', value: record.startTime ? moment(record.startTime).format("YYYY-MM-DD HH:MM:SS") : '' },
{ name: '结束时间:', value: record.endTime ? moment(record.endTime).format("YYYY-MM-DD HH:MM:SS") : '' },
{ name: '创建时间:', value: record.createTime ? moment(record.createTime).format("YYYY-MM-DD HH:MM:SS") : '' },
]
return <div style={{ width: '100%', }}>
{
data.map((v, i) => <div key={'class' + i} style={{ width: 'calc(25%)', display: 'inline-block' }}>
<div style={{ display: 'flex', marginBottom: 14 }}>
<div style={{ width: 70, fontWeight: 700, color: '#000000' }}>{v.name}</div>
{v.name == '项目图片:' ? <div style={{ color: 'blue', cursor: 'pointer' }} onClick={() => {
setIsPicture(true)
setPictureUrl(v.value)
}}>点击查看</div> : <div>{v.value}</div>}
</div>
</div>)
}
</div>
},
expandRowByClick: false,
fixed: false,
}}
pagination={{
current: query.page + 1,
total: limits,
showSizeChanger: true,
showQuickJumper: true,
pageSizeOptions: [10, 20, 50],
showTotal: (total) => {
return <span style={{ fontSize: 15 }}>{`${Math.ceil(total / query?.limit)}页,${total}`}</span>
},
onChange: (page, pageSize) => {
setQuery({ limit: pageSize, page: page - 1 });
projectList({ limit: pageSize, page: page - 1, ...search, companyId: companyID || search?.companyId })
}
}}
/>
{
<Modal
// title={ }
width={570}
open={isPicture}
onOk={() => { }}
footer={null}
onCancel={() => {
setIsPicture(false)
setPictureUrl('')
}}
>
{pictureUrl && pictureUrl[0] ? <img src={`/_file-server/${pictureUrl}`} width={500} /> : "暂无图片"}
</Modal>
}
{
addModel ?
<ProjectAddModel
firmList={firmList}
modelData={modelData}
close={() => {
setAddModel(false)
setModelData({})
}}
success={() => {
setAddModel(false)
setModelData({})
setQuery({ limit: 10, page: 0 });
projectList({ limit: 10, page: 0, ...search, companyId: companyID || search?.companyId })
}}
/> : ""
}
</>
)
}

3
web/log/development.txt

@ -4174,3 +4174,6 @@
2023-01-16 19:13:16.848 - debug: [FS-LOGGER] Init.
2023-01-16 19:13:16.851 - debug: init fs.attachment and inject it into app(app.fs.attachment) and runtime ctx(ctx.fs.attachment)
2023-01-16 19:13:17.387 - info: [Router] Inject api: attachment/index
2023-01-16 20:23:06.270 - debug: [FS-LOGGER] Init.
2023-01-16 20:23:06.274 - debug: init fs.attachment and inject it into app(app.fs.attachment) and runtime ctx(ctx.fs.attachment)
2023-01-16 20:23:06.618 - info: [Router] Inject api: attachment/index

Loading…
Cancel
Save