diff --git a/.vscode/launch.json b/.vscode/launch.json index dd08d4d..a4e5aaf 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -43,9 +43,10 @@ //南昌研发结束 // 镇江研发开始 "-g postgres://FashionAdmin:123456@10.8.30.36:5432/data_center", - "--redisHost localhost", + "--redisHost 10.8.30.112", "--redisPort 6379", - "--apiEmisUrl http://10.8.30.161:1111", + "--apiEmisUrl http://10.8.30.112:14000", //开发 + // "--apiEmisUrl http://10.8.30.161:1111", //测试 // 镇江研发结束 // 测试 "--qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5", diff --git a/api/app/lib/controllers/auth/index.js b/api/app/lib/controllers/auth/index.js index cfcc1f1..76d2d73 100644 --- a/api/app/lib/controllers/auth/index.js +++ b/api/app/lib/controllers/auth/index.js @@ -9,9 +9,18 @@ async function login (ctx, next) { try { const params = ctx.request.body; - const emisLoginRes = await ctx.app.fs.emisRequest.post('login', { - data: params - }) + let emisLoginRes = null + if (params.username && params.password) { + emisLoginRes = await ctx.app.fs.emisRequest.post('login', { + data: { ...params, } + }) + } else if (params.token) { + emisLoginRes = await ctx.app.fs.emisRequest.get('user-info', { + query: { + token: params.token, + } + }) + } if (!emisLoginRes) { throw "无此用户,请使用正确的登录信息" diff --git a/api/app/lib/controllers/customerContactsFollup/index.js b/api/app/lib/controllers/customerContactsFollup/index.js new file mode 100644 index 0000000..612eed1 --- /dev/null +++ b/api/app/lib/controllers/customerContactsFollup/index.js @@ -0,0 +1,23 @@ +'use strict'; + +// 查询储备项目统计表 +async function getCustomerContactsFollowup(ctx, next) { + const { type } = ctx.params; + let rslt = null; + try { + rslt = await ctx.fs.dc.models.ReserveItemReport.findAll({ + order: [['id', 'DESC']], + // where: { type: type } + }) + ctx.status = 200 + ctx.body = rslt + } catch (error) { + ctx.fs.logger.error(`path:${ctx.path},error:${error}`) + ctx.status = 400; + ctx.body = { name: 'FindAllError', message: '获取失败' } + } +} + +module.exports = { + getCustomerContactsFollowup +} \ No newline at end of file diff --git a/api/app/lib/controllers/report/achievement.js b/api/app/lib/controllers/report/achievement.js index e0fc180..7a85527 100644 --- a/api/app/lib/controllers/report/achievement.js +++ b/api/app/lib/controllers/report/achievement.js @@ -324,6 +324,59 @@ async function importAchieveDetails(ctx) { } } +/** + * 查询合同明细表数据 + * @param {*} ctx ctx ctx.query:{keywordTarget-关键字项、keyword-关键字内容、limit-页宽, page-页码} + */ +async function getContractDetail(ctx) { + try { + const { models } = ctx.fs.dc; + const { keywordTarget, keyword, limit, page } = ctx.query; + const where = {}; + if (keywordTarget && keyword) { + where[keywordTarget] = { $iLike: `%${keyword}%` }; + } + let contractDetail = await models.ContractDetail.findAndCountAll({ + where: where, + offset: Number(page) * Number(limit), + limit: Number(limit), + order: [['id', 'DESC']] + }); + ctx.status = 200 + ctx.body = contractDetail; + } catch (error) { + ctx.fs.logger.error(`path:${ctx.path},error:${error}`) + ctx.status = 400; + ctx.body = { name: 'FindError', message: '查询合同明细表数据失败' } + } +} + +/** + * 查询开票明细表数据 + * @param {*} ctx ctx ctx.query:{keywordTarget-关键字项、keyword-关键字内容、limit-页宽, page-页码} + */ +async function getInvoicingDetail(ctx) { + try { + const { models } = ctx.fs.dc; + const { keywordTarget, keyword, limit, page } = ctx.query; + const where = {}; + if (keywordTarget && keyword) { + where[keywordTarget] = { $iLike: `%${keyword}%` }; + } + let invoiceDetail = await models.InvoiceDetail.findAndCountAll({ + where: where, + offset: Number(page) * Number(limit), + limit: Number(limit), + order: [['id', 'DESC']] + }); + ctx.status = 200 + ctx.body = invoiceDetail; + } catch (error) { + ctx.fs.logger.error(`path:${ctx.path},error:${error}`) + ctx.status = 400; + ctx.body = { name: 'FindError', message: '查询开票明细表数据失败' } + } +} module.exports = { getReceivedDetail,//回款 getAchievementDetail,//业绩 @@ -331,4 +384,6 @@ module.exports = { getReceivedNumbers,//查询回款明细表 已有的所有编号 importBackDetails,//导入回款明细 importAchieveDetails,//导入业绩明细 + getContractDetail, + getInvoicingDetail } \ No newline at end of file diff --git a/api/app/lib/models/customerContactsFollup.js b/api/app/lib/models/customerContactsFollup.js new file mode 100644 index 0000000..53537c1 --- /dev/null +++ b/api/app/lib/models/customerContactsFollup.js @@ -0,0 +1,65 @@ +/* eslint-disable*/ +'use strict'; + +module.exports = dc => { + const DataTypes = dc.ORM; + const sequelize = dc.orm; + const ReserveItemReport = sequelize.define("reserveItemReport", { + id: { + type: DataTypes.INTEGER, + allowNull: false, + primaryKey: true, + field: "id", + autoIncrement: true, + }, + customer: { + type: DataTypes.STRING, + allowNull: true, + field: "customer", + }, + items: { + type: DataTypes.STRING, + allowNull: true, + field: "items", + }, + department: { + type: DataTypes.STRING, + allowNull: false, + field: "department", + }, + sale: { + type: DataTypes.STRING, + allowNull: true, + field: "sale", + }, + updatetime: { + type: DataTypes.DATE, + allowNull: false, + field: "updatetime", + }, + customerContacts: { + type: DataTypes.STRING, + allowNull: true, + field: "customer_contacts", + }, + phone: { + type: DataTypes.STRING, + allowNull: true, + field: "phone", + }, + visitStyle: { + type: DataTypes.STRING, + allowNull: true, + field: "visit_style", + }, + itemText: { + type: DataTypes.STRING, + allowNull: true, + field: "item_text", + } + }, { + tableName: "customer_contacts_followup", + }); + dc.models.ReserveItemReport = ReserveItemReport; + return ReserveItemReport; +}; \ No newline at end of file diff --git a/api/app/lib/routes/customerContactsFollup/index.js b/api/app/lib/routes/customerContactsFollup/index.js new file mode 100644 index 0000000..b8c0cee --- /dev/null +++ b/api/app/lib/routes/customerContactsFollup/index.js @@ -0,0 +1,8 @@ +'use strict'; + +const report = require('../../controllers/customerContactsFollup'); + +module.exports = function (app, router, opts) { + app.fs.api.logAttr['GET/customerContactsFollup'] = { content: '客户联系人对接跟进', visible: false }; + router.get('/customerContactsFollup', report.getReserveItemReport); +}; \ No newline at end of file diff --git a/api/app/lib/routes/report/index.js b/api/app/lib/routes/report/index.js index 8f712c0..8ae8752 100644 --- a/api/app/lib/routes/report/index.js +++ b/api/app/lib/routes/report/index.js @@ -27,4 +27,9 @@ module.exports = function (app, router, opts) { app.fs.api.logAttr['POST/add/achievement/bulk'] = { content: '导入业绩明细', visible: true }; router.post('/add/achievement/bulk', achieve.importAchieveDetails); + app.fs.api.logAttr['GET/contract/detail'] = { content: '查询合同明细表', visible: false }; + router.get('/contract/detail', achieve.getContractDetail); + + app.fs.api.logAttr['GET/invoicing/detail'] = { content: '查询开票明细表', visible: false }; + router.get('/invoicing/detail', achieve.getInvoicingDetail); }; \ No newline at end of file diff --git a/web/client/src/layout/containers/layout/index.jsx b/web/client/src/layout/containers/layout/index.jsx index 9c7eb26..37e2634 100644 --- a/web/client/src/layout/containers/layout/index.jsx +++ b/web/client/src/layout/containers/layout/index.jsx @@ -10,9 +10,13 @@ import { resize } from '../../actions/global'; import * as NProgress from 'nprogress'; import PerfectScrollbar from 'perfect-scrollbar'; import { useLocation } from "react-router"; +import { RouteTable } from '$utils'; +import { RouteRequest } from '@peace/utils'; +import Cookie from 'js-cookie'; +import { login, LOGIN_SUCCESS } from '../../../sections/auth/actions/auth'; NProgress.configure({ - template: ` + template: `
@@ -23,303 +27,354 @@ NProgress.configure({ }); let scrollbar +let requestUser = true +let requestlogout = false; + // const location111 = useLocation(); const LayoutContainer = props => { - const { - dispatch, msg, user, copyright, children, sections, clientWidth, clientHeight, - location, match, routes, history, socket, - } = props - const [collapsed, setCollapsed] = useState(false) + const { + dispatch,actions, msg, user, copyright, children, sections, clientWidth, clientHeight, + location, match, routes, history, socket, apiRoot + } = props + const [collapsed, setCollapsed] = useState(false) - NProgress.start(); + NProgress.start(); - const resize_ = () => { - dispatch(resize( - document.getElementById('DrApp').clientHeight, - document.getElementById('DrApp').clientWidth - (collapsed ? 120 : 240) - )); - } - function deepCopy(data) {//深拷贝 - //string,number,bool,null,undefined,symbol - //object,array,date - if (data && typeof data === "object") { - //针对函数的拷贝 - if (typeof data === "function") { - let tempFunc = data.bind(null); - tempFunc.prototype = deepCopy(data.prototype); - return tempFunc; - } + const resize_ = () => { + dispatch(resize( + document.getElementById('DrApp').clientHeight, + document.getElementById('DrApp').clientWidth - (collapsed ? 120 : 240) + )); + } + function deepCopy (data) {//深拷贝 + //string,number,bool,null,undefined,symbol + //object,array,date + if (data && typeof data === "object") { + //针对函数的拷贝 + if (typeof data === "function") { + let tempFunc = data.bind(null); + tempFunc.prototype = deepCopy(data.prototype); + return tempFunc; + } - switch (Object.prototype.toString.call(data)) { - case "[object String]": - return data.toString(); - case "[object Number]": - return Number(data.toString()); - case "[object Boolean]": - return new Boolean(data.toString()); - case "[object Date]": - return new Date(data.getTime()); - case "[object Array]": - var arr = []; - for (let i = 0; i < data.length; i++) { - arr[i] = deepCopy(data[i]); - } - return arr; + switch (Object.prototype.toString.call(data)) { + case "[object String]": + return data.toString(); + case "[object Number]": + return Number(data.toString()); + case "[object Boolean]": + return new Boolean(data.toString()); + case "[object Date]": + return new Date(data.getTime()); + case "[object Array]": + var arr = []; + for (let i = 0; i < data.length; i++) { + arr[i] = deepCopy(data[i]); + } + return arr; - //js自带对象或用户自定义类实例 - case "[object Object]": - var obj = {}; - for (let key in data) { - //会遍历原型链上的属性方法,可以用hasOwnProperty来控制 (obj.hasOwnProperty(prop) - obj[key] = deepCopy(data[key]); - } - return obj; - } - } else { - //string,number,bool,null,undefined,symbol - return data; - } - } - const [allItems, setAllItems] = useState([]) - // const [headerItems, setHeaderItems] = useState([]) - const [leftItems, setLeftItems] = useState([]) - const [leftChange, setLeftChange] = useState(true) - const [leftShow, setLeftShow] = useState(false) - useEffect(() => { - let topItems = []//头部导航 - const lastSelectedKeys = localStorage.getItem('poms_selected_sider') - let nextItems = []//所有导航 - for (let c of sections) { - if (typeof c.getNavItem == 'function') { - let item = c.getNavItem(user, dispatch); - if (item) { - nextItems.push.apply(nextItems, item) - if (item.length > 0) { - for (let j = 0; j < item.length; j++) { - let itm = deepCopy(item[j]); - if (itm.hasOwnProperty('items')) { - for (let i = 0; i < itm.items.length; i++) { - itm.items[i].fatherKey = itm.itemKey - delete itm.items[i].items - } - // topItems.push(itm) - // } - // else { - // topItems.push.apply(topItems, item) - } + //js自带对象或用户自定义类实例 + case "[object Object]": + var obj = {}; + for (let key in data) { + //会遍历原型链上的属性方法,可以用hasOwnProperty来控制 (obj.hasOwnProperty(prop) + obj[key] = deepCopy(data[key]); + } + return obj; + } + } else { + //string,number,bool,null,undefined,symbol + return data; + } + } + const [allItems, setAllItems] = useState([]) + // const [headerItems, setHeaderItems] = useState([]) + const [leftItems, setLeftItems] = useState([]) + const [leftChange, setLeftChange] = useState(true) + const [leftShow, setLeftShow] = useState(false) + useEffect(() => { + let topItems = []//头部导航 + const lastSelectedKeys = localStorage.getItem('poms_selected_sider') + let nextItems = []//所有导航 + for (let c of sections) { + if (typeof c.getNavItem == 'function') { + let item = c.getNavItem(user, dispatch); + if (item) { + nextItems.push.apply(nextItems, item) + if (item.length > 0) { + for (let j = 0; j < item.length; j++) { + let itm = deepCopy(item[j]); + if (itm.hasOwnProperty('items')) { + for (let i = 0; i < itm.items.length; i++) { + itm.items[i].fatherKey = itm.itemKey + delete itm.items[i].items } - } - } + // topItems.push(itm) + // } + // else { + // topItems.push.apply(topItems, item) + } + } + } } - } - setAllItems(nextItems) - // setHeaderItems(topItems) - if (lastSelectedKeys) {//如果有缓存 - for (let i = 0; i < nextItems.length; i++) { - if (JSON.parse(lastSelectedKeys)[0] == nextItems[i].itemKey) { + } + } + setAllItems(nextItems) + // setHeaderItems(topItems) + if (lastSelectedKeys) {//如果有缓存 + for (let i = 0; i < nextItems.length; i++) { + if (JSON.parse(lastSelectedKeys)[0] == nextItems[i].itemKey) { - // let openArr = [] - // for (let j = 0; j < nextItems[i].items.length; j++) { - // openArr.push(nextItems[i].items[j].itemKey) - // } - // localStorage.setItem('poms_open_sider', JSON.stringify(openArr)) - setLeftItems(nextItems[i].items) - } + // let openArr = [] + // for (let j = 0; j < nextItems[i].items.length; j++) { + // openArr.push(nextItems[i].items[j].itemKey) + // } + // localStorage.setItem('poms_open_sider', JSON.stringify(openArr)) + setLeftItems(nextItems[i].items) } - setLeftShow(true) - } - else { - setLeftShow(false) - } + } + setLeftShow(true) + } + else { + setLeftShow(false) + } - window.addEventListener('resize', resize_); - return () => { - window.removeEventListener('resize', resize_); - } - }, []) + window.addEventListener('resize', resize_); + return () => { + window.removeEventListener('resize', resize_); + } + }, []) - useEffect(() => { - let pathnameArr = location.pathname.split('/') - let openArr = [] - for (let i = 0; i < allItems.length; i++) { - if (allItems[i].items) { - for (let j = 0; j < allItems[i].items.length; j++) { - if (allItems[i].items[j].items) { - for (let k = 0; k < allItems[i].items[j].items.length; k++) { - if (allItems[i].items[j].items[k].to == location.pathname) { - for (let o = 0; o < allItems[i].items.length; o++) { - openArr.push(allItems[i].items[o].itemKey) - } - localStorage.setItem('poms_selected_sider', JSON.stringify([pathnameArr[1]])) - // localStorage.setItem('poms_open_sider', JSON.stringify(openArr)) - setLeftItems(allItems[i].items) - setLeftShow(true) - } + useEffect(() => { + let pathnameArr = location.pathname.split('/') + let openArr = [] + for (let i = 0; i < allItems.length; i++) { + if (allItems[i].items) { + for (let j = 0; j < allItems[i].items.length; j++) { + if (allItems[i].items[j].items) { + for (let k = 0; k < allItems[i].items[j].items.length; k++) { + if (allItems[i].items[j].items[k].to == location.pathname) { + for (let o = 0; o < allItems[i].items.length; o++) { + openArr.push(allItems[i].items[o].itemKey) } - } - } + localStorage.setItem('poms_selected_sider', JSON.stringify([pathnameArr[1]])) + // localStorage.setItem('poms_open_sider', JSON.stringify(openArr)) + setLeftItems(allItems[i].items) + setLeftShow(true) + } + } + } } - } - }, [location]) + } + } + }, [location]) - useEffect(() => { - NProgress.done(); - if ((!user || !user.authorized)) { - history.push('/signin'); - } - if (msg) { - if (msg.done) { - Notification.success({ - // title: msg.done, - content: msg.done, - duration: 2, - }) - } - if (msg.error) { - Notification.error({ - // title: msg.error, - content: msg.error, - duration: 2, - }) - } - } - const dom = document.getElementById('page-content'); - if (dom) { - if (!scrollbar) { - scrollbar = new PerfectScrollbar('#page-content', { suppressScrollX: true }); - scrollbar.update(); - } else { - scrollbar.update(); - dom.scrollTop = 0; - } - } - }) + useEffect(() => { + NProgress.done(); + if ((!user || !user.authorized)) { + // history.push('/signin'); + getUserInfoByToken() + } + if (msg) { + if (msg.done) { + Notification.success({ + // title: msg.done, + content: msg.done, + duration: 2, + }) + } + if (msg.error) { + Notification.error({ + // title: msg.error, + content: msg.error, + duration: 2, + }) + } + } + const dom = document.getElementById('page-content'); + if (dom) { + if (!scrollbar) { + scrollbar = new PerfectScrollbar('#page-content', { suppressScrollX: true }); + scrollbar.update(); + } else { + scrollbar.update(); + dom.scrollTop = 0; + } + } + }) + const getUserInfoByToken = () => { + if (requestUser) { + requestUser = false; + console.log(RouteTable.apiRoot); + RouteRequest.get(RouteTable.apiRoot).then(res => { + let token = Cookie.get('pepToken', { domain: res.domain }); + console.log(token); + dispatch(login({ token })).then(res => { + console.log(res); + if (res.type == 'LOGIN_SUCCESS') { + const data = res.payload?.user || {} + history.push('/businessManagement/pmReport/reserveItemsReporting') + localStorage.setItem('poms_open_sider', JSON.stringify(["pmReport"])) + localStorage.setItem('poms_selected_sider', JSON.stringify(["businessManagement"])) + localStorage.setItem('word', JSON.stringify('')) //系统登录代码时候存的,不清楚意义 + dispatch(actions.layout.initWebSocket({ ioUrl: apiRoot, token: data.token, hrUserId: data.hrUserInfo && hrUserInfo.id })) + } else { + redirectToLogin(true); + } + }, error => { + redirectToLogin(true); + }) + }, error => { + message.error('鉴权失败', 5); + redirectToLogin(true); + }) + } + } - // websocket 使用测试 - useEffect(() => { - // console.log(socket) - if (socket) { - socket.on('CAMERA_ONLINE', function (msg) { - console.info(msg); - if (msg.online == 'ON') { - Notification.success({ - title: 'Hi', - content: (
{msg.name}
已上线。
), - duration: 2, - }) - } - if (msg.online == 'OFF') { - Notification.error({ - title: 'Hi', - content: (
{msg.name}
发生离线。
), - duration: 2, - }) - } - }); - return () => { - socket.off("CAMERA_ONLINE"); + const redirectToLogin = (toLogin = false) => { + //重定位至大平台的登录页 + if (!requestlogout) { + requestlogout = true;//目的执行一遍。退出登录后,redirectToLogin执行两遍,注释window.location.href,可message.warning验证 + RouteRequest.get(RouteTable.getPepWebUrl).then(res => { + if (res.url) { + if (toLogin) { + window.location.href = `${res.url}/signin`; + } + else { + window.location.href = `${res.url}/signin?isLogout=true`; + } } - } - }, [socket]) + }); + } + } - return ( - - { - <> - -
{ - setCollapsed(!collapsed); - }} - collapsed={collapsed} - history={history} - tochange={(val) => { - // setLeftChange(!leftChange) //会导致顶部右上角转小圈 - if (val.fatherKey) { - localStorage.setItem('poms_selected_sider', JSON.stringify([val.itemKey])); - const historyOpenKeys = localStorage.getItem('poms_open_sider'); - const openKeys = historyOpenKeys && JSON.parse(historyOpenKeys).concat(val.openKey || val.itemKey) || [val.openKey || val.itemKey] - localStorage.setItem('poms_open_sider', JSON.stringify(openKeys)); - // for (let i = 0; i < allItems.length; i++) { - // if (val.fatherKey == allItems[i].itemKey) { - // let openArr = [] - // for (let j = 0; j < allItems[i].items.length; j++) { - // openArr.push(allItems[i].items[j].itemKey) - // } - // localStorage.setItem('poms_selected_sider', JSON.stringify([val.fatherKey])) - // localStorage.setItem('poms_open_sider', JSON.stringify(openArr)) - // setLeftItems(allItems[i].items) - // } - // } - // setLeftShow(true) - } - else { - localStorage.setItem('poms_open_sider', JSON.stringify([])) - localStorage.removeItem('poms_selected_sider') - // setLeftShow(false) - } - history.push(val.to); - }} - /> - - - {leftShow ? ( - - ) : ('')} - -
-
-
- {children} -
- -
- -
-
-
-
- + + // websocket 使用测试 + useEffect(() => { + // console.log(socket) + if (socket) { + socket.on('CAMERA_ONLINE', function (msg) { + console.info(msg); + if (msg.online == 'ON') { + Notification.success({ + title: 'Hi', + content: (
{msg.name}
已上线。
), + duration: 2, + }) + } + if (msg.online == 'OFF') { + Notification.error({ + title: 'Hi', + content: (
{msg.name}
发生离线。
), + duration: 2, + }) } - - ) + }); + return () => { + socket.off("CAMERA_ONLINE"); + } + } + }, [socket]) + + return ( + + { + <> + +
{ + setCollapsed(!collapsed); + }} + collapsed={collapsed} + history={history} + tochange={(val) => { + // setLeftChange(!leftChange) //会导致顶部右上角转小圈 + if (val.fatherKey) { + localStorage.setItem('poms_selected_sider', JSON.stringify([val.itemKey])); + const historyOpenKeys = localStorage.getItem('poms_open_sider'); + const openKeys = historyOpenKeys && JSON.parse(historyOpenKeys).concat(val.openKey || val.itemKey) || [val.openKey || val.itemKey] + localStorage.setItem('poms_open_sider', JSON.stringify(openKeys)); + // for (let i = 0; i < allItems.length; i++) { + // if (val.fatherKey == allItems[i].itemKey) { + // let openArr = [] + // for (let j = 0; j < allItems[i].items.length; j++) { + // openArr.push(allItems[i].items[j].itemKey) + // } + // localStorage.setItem('poms_selected_sider', JSON.stringify([val.fatherKey])) + // localStorage.setItem('poms_open_sider', JSON.stringify(openArr)) + // setLeftItems(allItems[i].items) + // } + // } + // setLeftShow(true) + } + else { + localStorage.setItem('poms_open_sider', JSON.stringify([])) + localStorage.removeItem('poms_selected_sider') + // setLeftShow(false) + } + history.push(val.to); + }} + /> + + + {leftShow ? ( + + ) : ('')} + +
+
+
+ {children} +
+ +
+ +
+
+
+
+ + } + + ) } -function mapStateToProps(state) { - const { global, auth, ajaxResponse, webSocket } = state; - return { - title: global.title, - copyright: global.copyright, - sections: global.sections, - actions: global.actions, - clientWidth: global.clientWidth, - clientHeight: global.clientHeight, - msg: ajaxResponse.msg, - user: auth.user, - socket: webSocket.socket - }; +function mapStateToProps (state) { + const { global, auth, ajaxResponse, webSocket } = state; + return { + title: global.title, + copyright: global.copyright, + sections: global.sections, + actions: global.actions, + clientWidth: global.clientWidth, + clientHeight: global.clientHeight, + msg: ajaxResponse.msg, + user: auth.user, + socket: webSocket.socket, + apiRoot: global.apiRoot, + }; } export default connect(mapStateToProps)(LayoutContainer); \ No newline at end of file diff --git a/web/client/src/sections/auth/actions/auth.js b/web/client/src/sections/auth/actions/auth.js index afcb759..18a1e59 100644 --- a/web/client/src/sections/auth/actions/auth.js +++ b/web/client/src/sections/auth/actions/auth.js @@ -4,7 +4,7 @@ import { ApiTable, AxyRequest, EmisRequest } from '$utils' import { Request } from '@peace/utils'; export const INIT_AUTH = 'INIT_AUTH'; -export function initAuth(userData) { +export function initAuth (userData) { const sessionUser = JSON.parse(sessionStorage.getItem('dcUser')) const user = userData || sessionUser || {}; if (user.authorized && !sessionUser) { @@ -21,11 +21,11 @@ export function initAuth(userData) { export const REQUEST_LOGIN = 'REQUEST_LOGIN'; export const LOGIN_SUCCESS = 'LOGIN_SUCCESS'; export const LOGIN_ERROR = 'LOGIN_ERROR'; -export function login(username, password) { +export function login ({ username, password, token }) { return dispatch => { dispatch({ type: REQUEST_LOGIN }); - if (!username || !password) { + if ((!username || !password) && !token) { dispatch({ type: LOGIN_ERROR, payload: { error: '请输入账号名和密码' } @@ -43,7 +43,7 @@ export function login(username, password) { // }, // }); - return Request.post(ApiTable.login, { username, password, code: 'HR' }) + return Request.post(ApiTable.login, { username, password, token, code: 'HR' }) .then(user => { sessionStorage.setItem('dcUser', JSON.stringify(user)); return dispatch({ @@ -63,7 +63,7 @@ export function login(username, password) { } export const LOGOUT = 'LOGOUT'; -export function logout() { +export function logout () { const user = JSON.parse(sessionStorage.getItem('dcUser')) user && user.token ? Request.put(ApiTable.logout, { diff --git a/web/client/src/sections/business/actions/achievement-report.js b/web/client/src/sections/business/actions/achievement-report.js index bc59024..66c27f3 100644 --- a/web/client/src/sections/business/actions/achievement-report.js +++ b/web/client/src/sections/business/actions/achievement-report.js @@ -61,4 +61,29 @@ export function importAchieveDetails(values) { data: values, msg: { option: '导入业绩明细' }, }); +} +//查询合同明细表 +export function getContractDetail(query) { + return (dispatch) => basicAction({ + type: "get", + dispatch: dispatch, + actionType: "GET_CONTRACT_DETAIL", + query: query, + url: `${ApiTable.getContractDetail}`, + msg: { option: "查询合同明细表" }, + reducer: { name: "ContractDetail", params: { noClear: true } }, + }); +} + +//查询开票明细表 +export function getInvoicingDetail(query) { + return (dispatch) => basicAction({ + type: "get", + dispatch: dispatch, + actionType: "GET_INVOICING_DETAIL", + query: query, + url: `${ApiTable.getInvoicingDetail}`, + msg: { option: "查询开票明细表" }, + reducer: { name: "InvoicingDetail", params: { noClear: true } }, + }); } \ No newline at end of file diff --git a/web/client/src/sections/business/containers/performanceReport/contractDetails.jsx b/web/client/src/sections/business/containers/performanceReport/contractDetails.jsx index b2cb4f0..ba5c6c5 100644 --- a/web/client/src/sections/business/containers/performanceReport/contractDetails.jsx +++ b/web/client/src/sections/business/containers/performanceReport/contractDetails.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useState, useRef, useMemo } from 'react'; import { connect } from 'react-redux'; -import { Select, Input, Button, Table, Pagination, Skeleton } from '@douyinfe/semi-ui'; +import { Select, Input, Button, Table, Pagination, Skeleton, Toast, } from '@douyinfe/semi-ui'; import { SkeletonScreen, Setup } from "$components"; import { IconSearch } from '@douyinfe/semi-icons'; import ImportContractDetailsModal from './importContractDetailsModal'; @@ -10,7 +10,7 @@ import moment from 'moment' const ContractDetails = (props) => { const { dispatch, actions } = props - const { } = actions; + const { businessManagement } = actions; const [keywordTarget, setKeywordTarget] = useState('contractNo'); const [keyword, setKeyword] = useState('');//搜索内容 const [limits, setLimits] = useState()//每页实际条数 @@ -20,6 +20,11 @@ const ContractDetails = (props) => { const [setup, setSetup] = useState(false);//表格设置是否显现 const [setupp, setSetupp] = useState([]);//实际显示的表格列表 + + const [exportUrl, setExportUrl] = useState(''); + const page = useRef(query.page); + const scroll = useMemo(() => ({}), []); + const CONTRACTDETAILS = "contractDetails"; const renderColumns = (columnKeys) => { let columns = []; @@ -52,6 +57,7 @@ const ContractDetails = (props) => { ) : ""; attribute(); + getContractDetailData(); }, []); //获取表格属性设置 function attribute() { @@ -66,9 +72,16 @@ const ContractDetails = (props) => { } setSetupp(newColumns); } - useEffect(() => { - }, [query]) + function getContractDetailData(param) { + let queryParam = param || query; + dispatch(businessManagement.getContractDetail({ keywordTarget, keyword, ...queryParam })).then(r => { + if (r.success) { + setTableData(r.payload?.data?.rows); + setLimits(r.payload?.data?.count); + } + }) + } function handleRow(record, index) {// 给偶数行设置斑马纹 if (index % 2 === 0) { return { @@ -80,7 +93,22 @@ const ContractDetails = (props) => { return {}; } } - const scroll = useMemo(() => ({}), []); + + const exportAllData = () => { + dispatch(businessManagement.getContractDetail({ limit: 1, page: 0 })).then((res) => { + if (res.success) { + if (res.payload.data.count) { + let url = `export/contract/detail?token=${user.token}×tamp=${moment().valueOf()}` + setExportUrl(url); + } else { + Toast.info({ + content: '暂无可导出的数据', + duration: 3, + }) + } + } + }) + } return ( <>
@@ -121,6 +149,7 @@ const ContractDetails = (props) => {
@@ -131,7 +160,10 @@ const ContractDetails = (props) => { onClick={() => { setImportModalV(true); }}> 导入
-
+
{ + exportAllData() + }}> 导出全部
@@ -172,7 +204,8 @@ const ContractDetails = (props) => { pageSizeOpts={[10, 20, 30, 40]} onChange={(currentPage, pageSize) => { setQuery({ limit: pageSize, page: currentPage - 1 }); - page.current = currentPage - 1 + getContractDetailData({ limit: pageSize, page: currentPage - 1 }); + page.current = currentPage - 1; }} /> @@ -186,6 +219,9 @@ const ContractDetails = (props) => { setImportModalV(false); }} /> : '' } + { + exportUrl ?