From 86558e038d9562845d109dc098104a2e450046f1 Mon Sep 17 00:00:00 2001 From: wenlele Date: Mon, 16 Jan 2023 21:00:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projectRegime/projectSituation.js | 14 +- api/log/development.log | 153 ++++++++++++++ .../projectRegime/containers/qrCode.js | 194 +----------------- web/log/development.txt | 3 + 4 files changed, 172 insertions(+), 192 deletions(-) diff --git a/api/app/lib/controllers/projectRegime/projectSituation.js b/api/app/lib/controllers/projectRegime/projectSituation.js index 24c159f..375e404 100644 --- a/api/app/lib/controllers/projectRegime/projectSituation.js +++ b/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, } diff --git a/api/log/development.log b/api/log/development.log index 8858320..6ed2cd7 100644 --- a/api/log/development.log +++ b/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. (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. (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 ()\n' + + ' at C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\index.js:9:57\n' + + ' at Array.forEach ()\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 ()' +} +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. (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. (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 ()\n' + + ' at C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\index.js:9:57\n' + + ' at Array.forEach ()\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 ()' +} +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. (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. (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 ()\n' + + ' at C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\index.js:9:57\n' + + ' at Array.forEach ()\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 ()' +} +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. (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. (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 ()\n' + + ' at C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\index.js:9:57\n' + + ' at Array.forEach ()\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 ()' +} +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. (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. (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 ()\n' + + ' at C:\\Users\\方式、\\Desktop\\Inspection\\api\\app\\lib\\routes\\index.js:9:57\n' + + ' at Array.forEach ()\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 ()' +} diff --git a/web/client/src/sections/projectRegime/containers/qrCode.js b/web/client/src/sections/projectRegime/containers/qrCode.js index b6a96bb..be509f7 100644 --- a/web/client/src/sections/projectRegime/containers/qrCode.js +++ b/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 ( -
- {(user?.isSuper || user.id == record.userId) ? - <> - - { - 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 }); - } - - } - }) - }} - > - - - - - : <> - - - - - - - - } - -
- ) - } - } - ] return ( <> @@ -142,8 +48,7 @@ const QrCode = (props) => {
{ - 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} > - - { setAddModel(true) }}>新建项目 - { - 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
- { - data.map((v, i) =>
-
-
{v.name}
- {v.name == '项目图片:' ?
{ - setIsPicture(true) - setPictureUrl(v.value) - }}>点击查看
:
{v.value}
} -
-
) - } -
- }, - expandRowByClick: false, - fixed: false, - }} - pagination={{ - current: query.page + 1, - total: limits, - showSizeChanger: true, - showQuickJumper: true, - pageSizeOptions: [10, 20, 50], - showTotal: (total) => { - return {`共${Math.ceil(total / query?.limit)}页,${total}项`} - }, - onChange: (page, pageSize) => { - setQuery({ limit: pageSize, page: page - 1 }); - projectList({ limit: pageSize, page: page - 1, ...search, companyId: companyID || search?.companyId }) - } - }} - /> - { - { }} - footer={null} - onCancel={() => { - setIsPicture(false) - setPictureUrl('') - }} - > - {pictureUrl && pictureUrl[0] ? : "暂无图片"} - - } - { - addModel ? - { - setAddModel(false) - setModelData({}) - }} - success={() => { - setAddModel(false) - setModelData({}) - setQuery({ limit: 10, page: 0 }); - projectList({ limit: 10, page: 0, ...search, companyId: companyID || search?.companyId }) - }} - /> : "" - } + ) } diff --git a/web/log/development.txt b/web/log/development.txt index 2dfc1a0..0ae838f 100644 --- a/web/log/development.txt +++ b/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