From ec2f90758849515d5b5d78081038b82c36d70b6f Mon Sep 17 00:00:00 2001 From: wenlele Date: Tue, 17 Jan 2023 10:55:01 +0800 Subject: [PATCH 1/5] =?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 | 31 +++++ api/app/lib/routes/projectRegime/index.js | 3 + api/log/development.log | 3 + .../projectRegime/actions/projectSituation.js | 12 ++ .../projectRegime/components/pointModel.js | 91 +++++++++++++ .../projectRegime/containers/point.js | 80 ++---------- .../projectRegime/containers/qrCode.js | 122 ++++++++++++------ web/client/src/utils/webapi.js | 1 + 8 files changed, 235 insertions(+), 108 deletions(-) create mode 100644 web/client/src/sections/projectRegime/components/pointModel.js diff --git a/api/app/lib/controllers/projectRegime/projectSituation.js b/api/app/lib/controllers/projectRegime/projectSituation.js index 375e404..1ccb7be 100644 --- a/api/app/lib/controllers/projectRegime/projectSituation.js +++ b/api/app/lib/controllers/projectRegime/projectSituation.js @@ -211,6 +211,36 @@ async function delPosition (ctx, next) { } +async function qrCodeShow (ctx, next) { + try { + const models = ctx.fs.dc.models; + let userInfo = ctx.fs.api.userInfo; + const { projectId, name } = ctx.query; + + let options = { + where: { + qrCode: { $ne: null } + }, + } + if (projectId) { + options.where.projectId = projectId + } + if (name) { + options.where.name = { $like: `%${name}%` } + } + + let res = await models.Point.findAndCountAll(options) + ctx.status = 200; + ctx.body = res + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + "message": "获取二维码列表失败" + } + } +} + module.exports = { projectList, @@ -219,4 +249,5 @@ module.exports = { addPosition, position, delPosition, + qrCodeShow } \ No newline at end of file diff --git a/api/app/lib/routes/projectRegime/index.js b/api/app/lib/routes/projectRegime/index.js index e551acb..f1db955 100644 --- a/api/app/lib/routes/projectRegime/index.js +++ b/api/app/lib/routes/projectRegime/index.js @@ -22,4 +22,7 @@ module.exports = function (app, router, opts) { app.fs.api.logAttr['DEL/delPosition/:id'] = { content: '删除点位', visible: false }; router.del('/delPosition/:id', projectSituation.delPosition); + app.fs.api.logAttr['GET/qrCodeShow'] = { content: '获取二维码列表', visible: false }; + router.get('/qrCodeShow', projectSituation.qrCodeShow); + } \ No newline at end of file diff --git a/api/log/development.log b/api/log/development.log index 981072f..157266c 100644 --- a/api/log/development.log +++ b/api/log/development.log @@ -3849,3 +3849,6 @@ notNull Violation: project.describe cannot be null 2023-01-16 20:45:57.174 - debug: [FS-LOGGER] Init. 2023-01-16 20:45:57.417 - info: [FS-ATTACHMENT] Inject attachment mw into router. 2023-01-16 20:45:57.418 - info: [FS-AUTH] Inject auth and api mv into router. +2023-01-17 09:24:14.329 - debug: [FS-LOGGER] Init. +2023-01-17 09:24:15.116 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2023-01-17 09:24:15.117 - info: [FS-AUTH] Inject auth and api mv into router. diff --git a/web/client/src/sections/projectRegime/actions/projectSituation.js b/web/client/src/sections/projectRegime/actions/projectSituation.js index cf5b3be..46fc366 100644 --- a/web/client/src/sections/projectRegime/actions/projectSituation.js +++ b/web/client/src/sections/projectRegime/actions/projectSituation.js @@ -76,3 +76,15 @@ export function delPosition (id) { }); } + +export function qrCodeShow (query) { + return (dispatch) => basicAction({ + type: 'get', + query, + dispatch, + actionType: 'GET_QR_CODE', + url: ApiTable.qrCodeShow, + msg: { error: '获取二维码列表失败', }, + }); +} + diff --git a/web/client/src/sections/projectRegime/components/pointModel.js b/web/client/src/sections/projectRegime/components/pointModel.js new file mode 100644 index 0000000..c28cb36 --- /dev/null +++ b/web/client/src/sections/projectRegime/components/pointModel.js @@ -0,0 +1,91 @@ +import React, { useState } from 'react'; +import { Button, Form, Input, Modal, Select, DatePicker } from 'antd'; +const { TextArea } = Input; +import { connect } from 'react-redux'; +import Uploads from '$components/Uploads'; +import { useEffect } from 'react'; +import moment from 'moment'; + +const ProjectAddModel = ({ dispatch, actions, user, modelData, close, success, qrCodeId }) => { + + const { projectRegime } = actions + const [form] = Form.useForm(); + + useEffect(() => { + // console.log(modelData); + + }, []) + + + return ( + { + form.validateFields().then(r => { + dispatch(projectRegime.addPosition({ + ...r, + id: modelData?.id, + projectId: qrCodeId + })).then(res => { + if (res.success) { + success() + } + }) + }) + }} + onCancel={() => { + close() + }} + > +
{ + + }} + > + + + +
+ {/* /^\d+$|^\d*\.\d+$/g */} + + + + ~ + + + +
+ +