Browse Source

(+)短信提醒查增改

dev
ww664853070 1 year ago
parent
commit
ab2cb7ba1f
  1. 26
      api/app/lib/controllers/data/anspectionNotificationPhone.js
  2. 5
      api/app/lib/routes/data/index.js
  3. 17
      web/client/src/sections/fillion/actions/patrol.js
  4. 30
      web/client/src/sections/fillion/components/patrolTable.js

26
api/app/lib/controllers/data/anspectionNotificationPhone.js

@ -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
};

5
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);
};

17
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: '添加短信提醒' },
});
}

30
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,7 +956,6 @@ 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)) {
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 || []
};
}

Loading…
Cancel
Save