From ab2cb7ba1fa86343e133c0e28d4b405d230a1f50 Mon Sep 17 00:00:00 2001 From: ww664853070 Date: Fri, 4 Aug 2023 13:22:46 +0800 Subject: [PATCH] =?UTF-8?q?(+)=E7=9F=AD=E4=BF=A1=E6=8F=90=E9=86=92?= =?UTF-8?q?=E6=9F=A5=E5=A2=9E=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/anspectionNotificationPhone.js | 28 +++++++++++++-- api/app/lib/routes/data/index.js | 5 ++- .../src/sections/fillion/actions/patrol.js | 17 ++++++++-- .../fillion/components/patrolTable.js | 34 ++++++++++++++----- 4 files changed, 68 insertions(+), 16 deletions(-) diff --git a/api/app/lib/controllers/data/anspectionNotificationPhone.js b/api/app/lib/controllers/data/anspectionNotificationPhone.js index cfa46a26..079f37bc 100644 --- a/api/app/lib/controllers/data/anspectionNotificationPhone.js +++ b/api/app/lib/controllers/data/anspectionNotificationPhone.js @@ -1,7 +1,7 @@ 'use strict'; const moment = require('moment') -async function getAnspectionNotificationPhone (ctx) { +async function getAnspectionNotificationPhone(ctx) { try { const models = ctx.fs.dc.models; @@ -23,9 +23,31 @@ async function getAnspectionNotificationPhone (ctx) { } } } - +async function addAnspectionNotificationPhone(ctx) { + try { + // const transaction = await ctx.fs.dc.orm.transaction(); + const models = ctx.fs.dc.models; + const data = ctx.request.body; + await models.AnspectionNotificationPhone.destroy({ where: {} }) + let dataList = [] + data.phone && data.phone.map(e => { + dataList.push({ + phone: e + }) + }) + await models.AnspectionNotificationPhone.bulkCreate(dataList); + // await transaction.commit(); + ctx.status = 204 + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } +} module.exports = { - getAnspectionNotificationPhone, + getAnspectionNotificationPhone, addAnspectionNotificationPhone }; \ No newline at end of file diff --git a/api/app/lib/routes/data/index.js b/api/app/lib/routes/data/index.js index 2064bc5a..5c2bde4a 100644 --- a/api/app/lib/routes/data/index.js +++ b/api/app/lib/routes/data/index.js @@ -208,7 +208,10 @@ module.exports = function (app, router, opts) { router.put('/appointTask', appointTask.appoint); // 指派任务 END - //短信电话anspectionNotificationPhone + //查询短信电话 app.fs.api.logAttr['GET/anspection/notification/phone'] = { content: '获取短信提醒电话', visible: true }; router.get('/anspection/notification/phone', anspectionNotificationPhone.getAnspectionNotificationPhone); + //添加 + app.fs.api.logAttr['POST/anspection/notification/phone'] = { content: '导入道路数据', visible: true }; + router.post('/anspection/notification/phone', anspectionNotificationPhone.addAnspectionNotificationPhone); }; diff --git a/web/client/src/sections/fillion/actions/patrol.js b/web/client/src/sections/fillion/actions/patrol.js index fa9d51c0..6d7f6060 100644 --- a/web/client/src/sections/fillion/actions/patrol.js +++ b/web/client/src/sections/fillion/actions/patrol.js @@ -53,10 +53,21 @@ export function getAnspectionNotificationPhone (query) { return dispatch => basicAction({ type: 'get', dispatch: dispatch, - actionType: 'GET_REPORT_LIST', + actionType: 'GET_ANSPECTION_NOTIFICATION_PHONE', url: ApiTable.getAnspectionNotificationPhone, query, - msg: { error: '获取巡查数据失败' }, - reducer: { name: 'reportList' } + msg: { error: '获取短信提醒电话' }, + reducer: { name: 'anspectionNotificationPhoneList' } + }); +} + +export function addAnspectionNotificationPhone (data) { + return dispatch => basicAction({ + type: 'post', + dispatch: dispatch, + actionType: 'POST_ANSPECTION_NOTIFICATION_PHONE', + url: ApiTable.getAnspectionNotificationPhone, + data: data, + msg: { option: '添加短信提醒' }, }); } \ No newline at end of file diff --git a/web/client/src/sections/fillion/components/patrolTable.js b/web/client/src/sections/fillion/components/patrolTable.js index 20b7a8fc..69cd3670 100644 --- a/web/client/src/sections/fillion/components/patrolTable.js +++ b/web/client/src/sections/fillion/components/patrolTable.js @@ -3,7 +3,7 @@ import './protable.less' import { Card, Button, Popconfirm, Badge, Col, Row, DatePicker, Input, Modal, Spin, Image, message, Popover, Select, Tree, Form } from 'antd'; import ProTable from '@ant-design/pro-table'; import { DownOutlined, RightOutlined, CaretDownOutlined, CaretRightOutlined, MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'; -import { getReportList, getReportDetail, handleReport } from '../actions/patrol'; +import { getReportList, getReportDetail, handleReport, getAnspectionNotificationPhone, addAnspectionNotificationPhone } from '../actions/patrol'; import React, { useEffect, useState, useMemo } from 'react'; import { getAllDepUsers } from '../actions/allDepUsers' import { httpDel } from '@peace/utils' @@ -700,7 +700,7 @@ const PatrolNameList = (props) => { const PatrolTable = (props) => { - const { allDepUsers, clientHeight, user, userList, reportList, dispatch, reportListLoading, reportDetail, reportDetailLoading, userLoading, exports, pathname } = props; + const { allDepUsers, clientHeight, user, userList, reportList, dispatch, reportListLoading, reportDetail, reportDetailLoading, userLoading, exports, pathname, anspectionNotificationPhoneList } = props; const [record, setRecord] = useState(1); const [dateRange, setDateRange] = useState(); const [selectProjectType, setSelectProjectType] = useState(''); @@ -716,7 +716,8 @@ const PatrolTable = (props) => { const [form] = Form.useForm(); useEffect(() => { queryData(); - console.log(123456789); + dispatch(getAnspectionNotificationPhone()); + }, []) useEffect(() => { if (userList && userList instanceof Array && reportDetail && reportDetail instanceof Object) { @@ -813,17 +814,32 @@ const PatrolTable = (props) => { exports(ids, reportType); } } + useEffect(() => { + console.log(anspectionNotificationPhoneList, '数据'); + let phoneList = [] + if (anspectionNotificationPhoneList && anspectionNotificationPhoneList.length) { + phoneList = anspectionNotificationPhoneList.map(e => { + return e.phone + }) + } + console.log(phoneList, '789789789789'); + + }, [anspectionNotificationPhoneList]) const showModal = () => { setIsModalOpen(true); }; const handleOk = () => { // setIsModalOpen(false); - console.log(form, '====='); form.validateFields().then(values => { console.log(values, '----------'); + dispatch(addAnspectionNotificationPhone(values)).then(res => { + if (res.success) { + setIsModalOpen(false); + } + }) }).catch(err => { - console.log(err, 'err'); + console.log(err); }) }; @@ -940,11 +956,10 @@ const PatrolTable = (props) => { // }, { validator: async (_, phone) => { - console.log(phone,'phone'); let re = /^1((3[\d])|(4[5,6,9])|(5[0-3,5-9])|(6[5-7])|(7[0-8])|(8[1-3,5-8])|(9[1,8,9]))\d{8}$/ - if(!re.test(phone)){ + if (!re.test(phone)) { return Promise.reject(new Error('请输入正确的手机号!')); - } + } }, }, ]} @@ -986,7 +1001,7 @@ const PatrolTable = (props) => { }; function mapStateToProps(state) { - const { auth, depMessage, userList, reportList, reportDetail, global, allDepUsers } = state; + const { auth, depMessage, userList, reportList, reportDetail, global, allDepUsers, anspectionNotificationPhoneList } = state; const pakData = (dep) => { return dep.map((d) => { return { @@ -1010,6 +1025,7 @@ function mapStateToProps(state) { reportDetail: reportDetail.data, reportDetailLoading: reportDetail.isRequesting, clientHeight: global.clientHeight, + anspectionNotificationPhoneList: anspectionNotificationPhoneList.data || [] }; }