From 89ecc56608d89f2ed8017c9190318451e3845b75 Mon Sep 17 00:00:00 2001 From: red-deng-deng <1924913374@qq.com> Date: Wed, 24 Nov 2021 15:13:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=89=E5=BE=97=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/api.js | 27 +++++++++++++++++++- src/assets/comm.js | 28 ++++++++++++++++++++- src/pages/order/list/list.js | 42 ++++++++++++++++++++++++-------- src/pages/system/role/add/add.js | 27 +++++++++++++++----- 4 files changed, 106 insertions(+), 18 deletions(-) diff --git a/src/assets/api.js b/src/assets/api.js index 1fe0cfbb..9317d1b9 100644 --- a/src/assets/api.js +++ b/src/assets/api.js @@ -11,7 +11,29 @@ const upload = (method, url, params, responseType) => { return res.json() } ); return http.then(response => response).catch(error => console.error('Error:', error)); + } + const derive = (method, url, params, responseType) => { + var obj = { + responseType: 'blob' + }; + if (method == "get") { + if (params) { + let paramsArray = []; + //拼接参数 + Object.keys(params).forEach(key => paramsArray.push(key + '=' + params[key])) + if (url.search(/\?/) === -1) { + url += '?' + paramsArray.join('&') + } else { + url += '&' + paramsArray.join('&') + } + } + } + let http = fetch(url, obj).then(res =>{ + window.timeshow=res.headers.get('Date-Time'); + return res.json() + } ); + return http.then(response => response).catch(error => console.error('Error:', error)); } const req = (method, url, params, responseType) => { @@ -223,13 +245,16 @@ export const getOrderDetails = (id) => { } //订单导出 export const getOrderExport = (params) => { - return req('get', baseurl + "/order/export",params) + return derive('get', baseurl + "/order/export",params) } //订单改为成功 export const putOrderSuccess = (id) => { return req('put', baseurl + "/order/success/"+id) } + + + //订单作废 export const putOrderCancel = (id) => { return req('put', baseurl + "/order/cancel/"+id) diff --git a/src/assets/comm.js b/src/assets/comm.js index a80989d7..3020a8b0 100644 --- a/src/assets/comm.js +++ b/src/assets/comm.js @@ -3,4 +3,30 @@ export const getQueryString=(name)=>{ var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; -} \ No newline at end of file +} + +// 前30天的时间段 +export const nowMonth = () => { + const end = new Date(); + const start = new Date(); + start.setTime(start.getTime() - 3600 * 1000 * 24 * 30); + return start +} + +// 当前的时间段 +export const nowDay = () => { + const end = new Date(); + return end +} + + + + +// 补0操作 +function buling (num) { + if (num < 10) { + return '0' + num + } else { + return num + } +} diff --git a/src/pages/order/list/list.js b/src/pages/order/list/list.js index d3216d1e..8f07bf06 100644 --- a/src/pages/order/list/list.js +++ b/src/pages/order/list/list.js @@ -9,7 +9,11 @@ import Grid from "../../../components/gird/main.js" import TabPage from "../../../components/tabPage/main.js" import Filterbar from "../../../components/filterbar/main.js" import menu from "../../../assets/enum.js" -import {getOrderList,handelResponse,getOrderExport,putOrderSuccess,putOrderCancel} from "../../../assets/api.js" +import { nowMonth, nowDay } from "../../../assets/comm.js"; +import {getOrderList,handelResponse,putOrderSuccess,putOrderCancel} from "../../../assets/api.js" +// var moment = require("moment"); +// let day = moment(nowDay()).format("YYYY-MM-DD"); +// let tomonth = moment(nowMonth()).format("YYYY-MM-DD"); const Column = [ { title: '订单号', @@ -205,15 +209,11 @@ export default class orderlist extends React.Component{ title:'确认操作', content:

是否导出订单?

, onConfirm(){ - getOrderExport(data).then(res=>{ - handelResponse(res,(response,msg)=>{ - Notify.clear(); - Notify.success(msg); - },(err)=>{ - - }) - }).catch(err=>{ - }); + if(data.key_word){ + window.location.href=window.baseurl+'/order/export?page='+data.page+'&limit='+data.limit+'&key_word='+data.key_word; + }else{ + window.location.href=window.baseurl+'/order/export?page='+data.page+'&limit='+data.limit; + } }, onCancel(){ console.log('点击了取消按钮'); @@ -308,6 +308,23 @@ export default class orderlist extends React.Component{ this.setState({allcheck:false}) this.setState({itemcheck:false}) } + //获取当前时间 + getnow() { + var now = new Date(); + var year = now.getFullYear(); + var month = + now.getMonth() + 1 <= 9 + ? "0" + (now.getMonth() + 1) + : now.getMonth() + 1; + var day = now.getDate() <= 9 ? "0" + now.getDate() : now.getDate(); + var tt = now.getHours() <= 9 ? "0" + now.getHours() : now.getHours(); + var mm = + now.getMinutes() <= 9 ? "0" + now.getMinutes() : now.getMinutes(); + var ss = + now.getSeconds() <= 9 ? "0" + now.getSeconds() : now.getSeconds(); + let datelist = [year, month, day, tt, mm, ss]; + return datelist.join(""); +} //选择时间 onChangeCombinedDate(e){ this.setState({combinedValue:e}); @@ -369,6 +386,11 @@ export default class orderlist extends React.Component{ }); } componentWillMount(){ + // let datetime = [ + // tomonth + " " + "00:00:00", + // day + " " + "23:59:59" + // ]; + // this.setState({combinedValue:datetime}); this.getOrderFn(); } // 监听组件内部状态的变化: diff --git a/src/pages/system/role/add/add.js b/src/pages/system/role/add/add.js index 0f589907..aaabddd4 100644 --- a/src/pages/system/role/add/add.js +++ b/src/pages/system/role/add/add.js @@ -1,6 +1,6 @@ import ReactDOM from 'react-dom'; import React, { Component } from 'react'; -import { Card,Button,Notify,Sweetalert} from 'zent'; +import { Card,Button,Notify,Sweetalert,RadioGroup,RadioButton} from 'zent'; import "./add.less" import "../../../../assets/comm.css" import Ipt from "../../../../components/input/main" @@ -14,6 +14,7 @@ export default class addrole extends React.Component{ this.state={ model:{ role:'', + account_type:5, setrole:[], pagetitle:'新建角色', }, @@ -28,7 +29,6 @@ export default class addrole extends React.Component{ title:'确认操作', content:

是否取消本次操作?

, onConfirm:()=>{ - console.log(window); window.history.go(-1) sessionStorage.setItem('pathname2','/home/system/role-list') }, @@ -38,11 +38,18 @@ export default class addrole extends React.Component{ }); } + authchange=e=>{ + let model1=this.state.model; + model1.account_type=e.target.value; + this.setState({ model: model1 }); + } + submit(){ let roleFlag=this.refs.roleform.validator(); let self=this; - - if(this.refs.roletree.state.checkedKeys.length<1){ + console.log(this.refs.roletree.state); + if(!this.refs.roletree.state.checkedKeys){ + Notify.clear(); Notify.error('请至少选中一个模块权限') }else{ if(roleFlag){ @@ -53,7 +60,8 @@ export default class addrole extends React.Component{ content: self.state.enumer==0?(

是否新增[{self.state.model.role}]角色?

):(

是否修改当前角色信息?

), onConfirm:()=>{ let data={role_name:self.state.model.role, - menu_id:this.refs.roletree.state.checkedKeys + menu_id:this.refs.roletree.state.checkedKeys, + account_type:self.state.model.account_type } if(self.state.enumer==0){ postRole(data).then(res=>{ @@ -99,6 +107,7 @@ export default class addrole extends React.Component{ let menuList=JSON.parse(sessionStorage.getItem('dataInfo')); let model={}; model.role=menuList.role_name; + model.account_type=menuList.account_type; this.setState({menuList,model}); } } @@ -106,7 +115,7 @@ export default class addrole extends React.Component{ const rules = { role: [ { type: "required", message: "请输入角色名"} - ] + ], } return(
@@ -127,6 +136,12 @@ export default class addrole extends React.Component{ }} value={this.state.model.role} placeholder={"请输入角色"} labelWidth={'0px'} maxLength={12} height={'36px'} width={'520px'} alignment={'left'}/> + + + 管理员 + 普通账号 + +