king
2025-05-13 1779677cece5864b62a65df4b01a4a69496e149a
src/tabviews/zshare/settingcomponent/editTable/index.jsx
@@ -1,13 +1,10 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
// import { fromJS } from 'immutable'
import { Table, Form, Icon, Select, Cascader } from 'antd'
import { Table, Form, Select, Cascader } from 'antd'
import { EditOutlined } from '@ant-design/icons'
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
import './index.scss'
let eTDict = localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
const EditableContext = React.createContext()
const shortkeycode = {
  65: 'A', 66: 'B', 67: 'C', 68: 'D', 69: 'E', 70: 'F', 71: 'G', 72: 'H', 73: 'I', 74: 'J', 75: 'K', 76: 'L', 77: 'M',
@@ -21,7 +18,7 @@
    if (inputType === 'select') {
      let _options = []
      if (record.$port) {
        _options = window.GLOB.UserCacheMap.get(record.$port)
        _options = window.GLOB.UserCacheMap.get(record.$port) || []
      }
      return (
        <Select allowClear>
@@ -70,32 +67,32 @@
    editingKey: '',
    visible: false,
    columns: [{
      title: '名称',
      title: window.GLOB.dict['name'] || '名称',
      dataIndex: 'label',
      width: '25%'
    }, {
      title: '快捷键',
      title: window.GLOB.dict['shortcut'] || '快捷键',
      dataIndex: 'shortcut',
      inputType: 'cascader',
      editable: true,
      options: [],
      width: '25%',
      render: (text, record) => {
      render: (text) => {
        if (!text) return ''
        return text[0] + '+' + shortkeycode[text[1]]
      }
    }, {
      title: '打印机',
      title: window.GLOB.dict['printer'] || '打印机',
      dataIndex: 'printer',
      inputType: 'select',
      editable: true,
      options: [],
      width: '25%'
    }, {
      title: '操作',
      title: window.GLOB.dict['operation'] || '操作',
      dataIndex: 'operation',
      width: '140px',
      render: (text, record) => {
      render: (_, record) => {
        const { editingKey } = this.state
        const editable = this.isEditing(record)
        return editable ? (
@@ -103,37 +100,37 @@
            <EditableContext.Consumer>
              {form => (
                <span onClick={() => this.save(form, record.uuid)} style={{ marginRight: 8 , color: '#1890ff', cursor: 'pointer'}}>
                  {eTDict['model.save']}
                  {window.GLOB.dict['save'] || '保存'}
                </span>
              )}
            </EditableContext.Consumer>
            <span style={{ color: '#1890ff', cursor: 'pointer'}} onClick={() => this.cancel(record.uuid)}>{eTDict['model.cancel']}</span>
            <span style={{ color: '#1890ff', cursor: 'pointer'}} onClick={() => this.cancel(record.uuid)}>{window.GLOB.dict['cancel'] || '取消'}</span>
          </div>
        ) : (
          <div className={'edit-operation-btn' + (editingKey !== '' ? ' disabled' : '')} style={{minWidth: '110px'}}>
            <span className="primary" onClick={() => {editingKey === '' && this.edit(record.uuid)}}><Icon type="edit" /></span>
            <span className="primary" onClick={() => {editingKey === '' && this.edit(record.uuid)}}><EditOutlined /></span>
          </div>
        )
      }
    }],
    printTypeColumns: [
      {
        title: '打印类型',
        title: window.GLOB.dict['print_type'] || '打印类型',
        dataIndex: 'Text',
        width: '26.1%'
      },
      {
        title: '打印机',
        title: window.GLOB.dict['printer'] || '打印机',
        dataIndex: 'printer',
        inputType: 'select',
        editable: true,
        options: [],
      },
      {
        title: '操作',
        title: window.GLOB.dict['operation'] || '操作',
        dataIndex: 'operation',
        width: '153px',
        render: (text, record) => {
        render: (_, record) => {
          const { editingKey } = this.state
          const editable = this.isEditing(record)
          return editable ? (
@@ -141,15 +138,15 @@
              <EditableContext.Consumer>
                {form => (
                  <span onClick={() => this.save(form, record.uuid, record.parentId)} style={{ marginRight: 8 , color: '#1890ff', cursor: 'pointer'}}>
                    {eTDict['model.save']}
                    {window.GLOB.dict['save'] || '保存'}
                  </span>
                )}
              </EditableContext.Consumer>
              <span style={{ color: '#1890ff', cursor: 'pointer'}} onClick={() => this.cancel(record.uuid)}>{eTDict['model.cancel']}</span>
              <span style={{ color: '#1890ff', cursor: 'pointer'}} onClick={() => this.cancel(record.uuid)}>{window.GLOB.dict['cancel'] || '取消'}</span>
            </div>
          ) : (
            <div className={'edit-operation-btn' + (editingKey !== '' ? ' disabled' : '')} style={{minWidth: '110px'}}>
              <span className="primary" onClick={() => {editingKey === '' && this.edit(record.uuid)}}><Icon type="edit" /></span>
              <span className="primary" onClick={() => {editingKey === '' && this.edit(record.uuid)}}><EditOutlined /></span>
            </div>
          )
        }
@@ -170,8 +167,8 @@
        children: []
      }
      Object.keys(shortkeycode).forEach(key => {
        if (item === 'ctrl' && ['65', '67', '68', '86', '70', '72', '83'].includes(key)) return
        if (item === 'alt' && key === '65') return
        if (item === 'ctrl' && ['65', '67', '68', '69', '70', '71', '72', '74', '75', '76', '78', '79', '80', '82', '83', '84', '85', '86', '87', '88', '90'].includes(key)) return
        if (item === 'alt' && ['65', '68', '69', '70'].includes(key)) return
        _op.children.push({
          value: +key,