重写 兑换码复制逻辑

This commit is contained in:
wangsongsole 2022-08-03 15:30:37 +08:00
parent 188fe12a0b
commit 5fc7ddc49f
1 changed files with 33 additions and 33 deletions

View File

@ -1,21 +1,11 @@
import ReactDOM from 'react-dom' import React from 'react'
import React, { Component } from 'react' import { Sweetalert, CombinedDateRangePicker, Notify, Switch } from 'zent'
import { Link } from 'react-router-dom'
import {
Button,
Sweetalert,
CombinedDateRangePicker,
Notify,
Switch
} from 'zent'
import './list.less' import './list.less'
import _ from 'lodash' import _ from 'lodash'
import '../../../assets/comm.css' import '../../../assets/comm.css'
import Ipt from '../../../components/input/main' import Ipt from '../../../components/input/main'
import Grid from '../../../components/gird/main.js' import Grid from '../../../components/gird/main.js'
import TabPage from '../../../components/tabPage/main.js' import TabPage from '../../../components/tabPage/main.js'
import Filterbar from '../../../components/filterbar/main.js'
import { nowMonth, nowDay } from '../../../assets/comm.js'
import menu from '../../../assets/enum.js' import menu from '../../../assets/enum.js'
import { import {
getCodesList, getCodesList,
@ -25,8 +15,6 @@ import {
terminateApprovals terminateApprovals
} from '../../../assets/api.js' } from '../../../assets/api.js'
var moment = require('moment') var moment = require('moment')
let day = moment(nowDay()).format('YYYY-MM-DD')
let tomonth = moment(nowMonth()).format('YYYY-MM-DD')
const Column = [ const Column = [
{ {
title: '兑换码-批次ID', title: '兑换码-批次ID',
@ -197,6 +185,34 @@ export default class acclist extends React.Component {
window.open('#/home/exchange-addcommodity') window.open('#/home/exchange-addcommodity')
} }
/* 处理可复制数据逻辑 */
copyElementFunction({ key_batch_id, status, end_time, discard }) {
const today = moment().format('yyyy-MM-DD HH:mm:ss')
let element = ''
if (![-1, 6, 7].includes(status) && end_time > today && discard === 0) {
element = (
<span
className='grid-link'
style={{ marginLeft: '10px' }}
onClick={(e) => this.copyFunction(key_batch_id)}>
复制
</span>
)
} else {
element = (
<span
style={{
marginLeft: '10px',
paddingRight: '10px',
color: '#d8dbdd'
}}>
复制
</span>
)
}
return element
}
/* 编辑 */ /* 编辑 */
editinfo(e, rowData) { editinfo(e, rowData) {
sessionStorage.setItem('pathname2', '/home/exchangecode-edit') sessionStorage.setItem('pathname2', '/home/exchangecode-edit')
@ -225,9 +241,9 @@ export default class acclist extends React.Component {
} }
/* 复制 */ /* 复制 */
copyFunction(rowData) { copyFunction(id) {
sessionStorage.setItem('copyOpearo', 2) sessionStorage.setItem('copyOpearo', 2)
sessionStorage.setItem('keybatch_id', rowData.key_batch_id) sessionStorage.setItem('keybatch_id', id)
let breakchangenav = [ let breakchangenav = [
{ {
pagetitle: '复制key', pagetitle: '复制key',
@ -585,23 +601,7 @@ export default class acclist extends React.Component {
) : ( ) : (
<span style={{ color: '#d8dbdd' }}>撤销审批</span> <span style={{ color: '#d8dbdd' }}>撤销审批</span>
)} )}
{rowData.status == 4 || rowData.status == 5 ? ( {this.copyElementFunction(rowData)}
<span
className='grid-link'
style={{ marginLeft: '10px' }}
onClick={(e) => this.copyFunction(rowData)}>
复制
</span>
) : (
<span
style={{
marginLeft: '10px',
paddingRight: '10px',
color: '#d8dbdd'
}}>
复制
</span>
)}
</div> </div>
) )
} }