From b69b5f6329ca5f87932436b7a6c1ddfc3377e10f Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 16 五月 2024 10:56:41 +0800 Subject: [PATCH] 2024-05-16 --- src/tabviews/zshare/actionList/funcMegvii/index.jsx | 183 ++++++++++++++++++++++----------------------- 1 files changed, 88 insertions(+), 95 deletions(-) diff --git a/src/tabviews/zshare/actionList/funcMegvii/index.jsx b/src/tabviews/zshare/actionList/funcMegvii/index.jsx index d2d9145..652dc2a 100644 --- a/src/tabviews/zshare/actionList/funcMegvii/index.jsx +++ b/src/tabviews/zshare/actionList/funcMegvii/index.jsx @@ -1,6 +1,5 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { withRouter } from 'react-router' import { is, fromJS } from 'immutable' import { Button, Modal, notification, message, Progress } from 'antd' import CryptoJS from 'crypto-js' @@ -8,7 +7,7 @@ import NApi from '@/api' import Utils from '@/utils/utils.js' -import Api from '@/api/w4k.js' +import Api from '@/api/direct.js' import MKEmitter from '@/utils/events.js' import MkIcon from '@/components/mk-icon' @@ -35,20 +34,11 @@ } UNSAFE_componentWillMount () { - const { btn, selectedData } = this.props - let disabled = false + const { btn, selectedData, BData, disabled } = this.props - if (btn.controlField && selectedData && selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� - selectedData.forEach(item => { - let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : '' - if (btn.controlVals.includes(s)) { - disabled = true - } - }) - this.setState({hidden: disabled && btn.control === 'hidden'}) - } - - if (this.props.disabled || disabled) { + if (btn.controlField) { + this.setStatus(btn, selectedData || [], BData, disabled) + } else if (disabled) { this.setState({disabled: true}) } } @@ -58,25 +48,12 @@ } UNSAFE_componentWillReceiveProps (nextProps) { - const { btn, selectedData } = this.props + const { btn } = this.props - let disabled = false - if (btn.controlField && !is(fromJS(nextProps.selectedData || []), fromJS(selectedData || []))) { - if (nextProps.selectedData && nextProps.selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� - nextProps.selectedData.forEach(item => { - let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : '' - if (btn.controlVals.includes(s)) { - disabled = true - } - }) - } - this.setState({hidden: disabled && btn.control === 'hidden'}) - } - - if (nextProps.disabled || disabled) { - this.setState({disabled: true}) + if (btn.controlField) { + this.setStatus(btn, nextProps.selectedData || [], nextProps.BData, nextProps.disabled) } else { - this.setState({disabled: false}) + this.setState({disabled: nextProps.disabled === true}) } } @@ -91,62 +68,95 @@ MKEmitter.removeListener('triggerBtnId', this.actionTrigger) } + setStatus = (btn, data, BData, disprop) => { + let disabled = false + let hidden = false + + if (btn.control !== 'parent') { + if (data.length > 0) { + data.forEach(item => { + let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : '' + if (btn.controlVals.includes(s)) { + disabled = true + } + }) + } else if (btn.controlVals.includes('')) { + disabled = true + } + } else { + if (!BData || !BData.hasOwnProperty(btn.controlField)) { + hidden = true + } else { + let s = BData[btn.controlField] + '' + if (btn.controlVals.includes(s)) { + hidden = true + } + } + } + + if (disabled && btn.control === 'hidden') { + hidden = true + } + + if (disprop) { + disabled = true + } + + this.setState({hidden, disabled}) + } + /** * @description 瑙﹀彂鎸夐挳鎿嶄綔 */ - actionTrigger = (triggerId, record, type) => { - const { Tab, BID, btn, selectedData, setting } = this.props + actionTrigger = (triggerId, record, type, lid) => { + const { BID, btn, selectedData, setting, LID } = this.props const { loading, disabled } = this.state if (loading || disabled) return if (triggerId && btn.uuid !== triggerId) return + if (type === 'linkbtn' && !btn.$toolbtn && LID !== lid) return - if (((Tab && Tab.supMenu) || setting.supModule) && !BID) { + let data = record || selectedData || [] + // let data = fromJS(mockdata.data).toJS() + + if (setting.supModule && !BID) { notification.warning({ top: 92, message: '闇�瑕佷笂绾т富閿�硷紒', duration: 5 }) - return - } else if (type === 'linkbtn' && !btn.$toolbtn && !is(fromJS(selectedData || []), fromJS(record))) { - return - } - - let data = record || selectedData || [] - // let data = fromJS(mockdata.data).toJS() - - if (data.length === 0) { + } else if (data.length === 0) { // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹� notification.warning({ top: 92, message: '璇烽�夋嫨琛岋紒', duration: 5 }) - return + } else { + this.setState({ + loading: true, + lines: data + }) + this.getIpList() } - - this.setState({ - loading: true, - lines: data - }) - - this.getIpList() } getIpList = () => { let _scriptSql = `select ID,data_code,data_name,Remark,face_ip,face_uname,face_pwd from bd_data where typecharone='face_device' and deleted=0` - _scriptSql = Utils.formatOptions(_scriptSql) - let _sParam = { func: 'sPC_Get_SelectedList', - LText: _scriptSql, obj_name: 'data', arr_field: 'ID,data_code,data_name,Remark,face_ip,face_uname,face_pwd' } + + if (window.GLOB.execType === 'x') { + _sParam.exec_type = 'x' + } + _sParam.LText = Utils.formatOptions(_scriptSql, _sParam.exec_type) _sParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp) + _sParam.secretkey = Utils.encrypt(window.GLOB.execType === 'x' ? '' : _sParam.LText, _sParam.timestamp) NApi.getSystemCacheConfig(_sParam).then(res => { if (res.status) { @@ -196,7 +206,7 @@ // let ip = 'http://localhost:3001' let ip = selectIp.face_ip - Api.login(ip, selectIp.face_uname, selectIp.face_pwd).then(result => { + Api.w4kLogin(ip, selectIp.face_uname, selectIp.face_pwd).then(result => { if (result.errors) { this.execPreError(result) return @@ -204,7 +214,7 @@ document.cookie = 'sessionID=' + result.session_id - Api.queryUsers(ip).then(res => { + Api.w4kQueryUsers(ip).then(res => { if (res.errors) { this.execPreError(res) return @@ -279,7 +289,7 @@ } if (error) { - this.execError({ErrCode: 'E', ErrMesg: error}) + this.execError({ErrCode: 'E', message: error}) return } @@ -291,7 +301,7 @@ data.id_number = CryptoJS.enc.Base64.stringify(encrypted.ciphertext) } - Api.addUsers(ip, data).then(res => { + Api.w4kAddUsers(ip, data).then(res => { if (res.errors) { this.execPreError(res, data) return @@ -299,7 +309,7 @@ if (datas.length > 0) { this.addUser(ip, datas, sessionId) } else { - this.execSuccess({ErrCode: 'S', ErrMesg: '鎵ц鎴愬姛銆�'}) + this.execSuccess({ErrCode: 'S', message: '鎵ц鎴愬姛銆�'}) } }, (err) => { this.execPreError(err, data) @@ -314,18 +324,18 @@ * 4銆佹ā鎬佹鎵ц鎴愬姛鍚庢槸鍚﹀叧闂� * 5銆侀�氱煡涓诲垪琛ㄥ埛鏂� */ - execSuccess = (res) => { + execSuccess = (res = {}) => { const { btn } = this.props - if (res && (res.ErrCode === 'S' || !res.ErrCode)) { // 鎵ц鎴愬姛 + if (res.ErrCode === 'S' || !res.ErrCode) { // 鎵ц鎴愬姛 notification.success({ top: 92, - message: res.ErrMesg || '鎵ц鎴愬姛', + message: res.message || '鎵ц鎴愬姛', duration: btn.verify && btn.verify.stime ? btn.verify.stime : 2 }) } else if (res && res.ErrCode === 'Y') { // 鎵ц鎴愬姛 Modal.success({ - title: res.ErrMesg || '鎵ц鎴愬姛' + title: res.message || '鎵ц鎴愬姛' }) } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず @@ -396,23 +406,23 @@ if (res.ErrCode === 'E') { Modal.error({ - title: res.message || res.ErrMesg, + title: res.message || '鎵ц澶辫触锛�', }) } else if (res.ErrCode === 'N') { notification.error({ top: 92, - message: res.message || res.ErrMesg, + message: res.message || '鎵ц澶辫触锛�', duration: btn.verify && btn.verify.ntime ? btn.verify.ntime : 10 }) } else if (res.ErrCode === 'F') { notification.error({ className: 'notification-custom-error', top: 92, - message: res.message || res.ErrMesg, + message: res.message || '鎵ц澶辫触锛�', duration: btn.verify && btn.verify.ftime ? btn.verify.ftime : 10 }) } else if (res.ErrCode === 'NM') { - message.error(res.message || res.ErrMesg) + message.error(res.message || '鎵ц澶辫触锛�') } this.setState({ @@ -499,43 +509,26 @@ if (hidden) return null let label = '' - let icon = '' - let type = 'link' - let className = '' - if (btn.show === 'button') { - label = btn.label - icon = btn.icon || '' - } else if (btn.show === 'link') { - label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span> - icon = '' + if (btn.show === 'link') { + label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon} /> : ''}</span> } else if (btn.show === 'icon') { - icon = btn.icon || '' - } else if (!btn.$toolbtn) { - icon = btn.icon || '' - label = btn.label - className = 'mk-btn mk-' + btn.class + label = !loading ? <MkIcon type={btn.icon} /> : null + } else if (btn.$toolbtn) { + label = <span>{!loading && btn.icon ? <MkIcon style={{marginRight: '8px'}} type={btn.icon} /> : ''}{loadingNumber && !loadingTotal ? `(${loadingNumber})` : ''}{btn.label}</span> } else { - type = '' - icon = btn.icon || '' - label = btn.label - className = 'mk-btn mk-' + btn.class - } - - if (loadingNumber && !loadingTotal && btn.$toolbtn && (!btn.show || btn.show === 'button')) { - label = (loadingNumber && !loadingTotal ? `(${loadingNumber})` : '') + btn.label + label = <span>{!loading && btn.icon ? <MkIcon style={{marginRight: '8px'}} type={btn.icon} /> : ''}{btn.label}</span> } return ( <> <Button - type={type} + type="link" title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')} loading={loading} disabled={disabled} style={btn.style} - icon={icon} - className={className} + className={btn.hover || ''} onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} >{label}</Button> {this.getModels()} @@ -545,4 +538,4 @@ } } -export default withRouter(FuncButton) \ No newline at end of file +export default FuncButton \ No newline at end of file -- Gitblit v1.8.0