广州市综治平台前端
xusd
19 hours ago bdeacb9f02dfa74bac74296a4a2c989a8e0d45ff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
 * @Company: hugeInfo
 * @Author: lwh
 * @Date: 2025-01-07 14:39:21
 * @LastEditTime: 2025-01-09 17:32:51
 * @LastEditors: lwh
 * @Version: 1.0.0
 * @Description: 扬言极端事件匹配规则
 */
import React, { useEffect, useState } from 'react';
import { useNavigate, useLocation } from 'react-router-dom';
import { Form, Col, Space, Checkbox } from 'antd';
import NewPage from '@/components/NewPage';
import * as $$ from '@/utils/utility';
import TableView from '@/components/TableViewCanSort';
import { Button, Alert, Input, Message } from '@arco-design/web-react';
import NewTableSearch from '@/components/NewTableSearch';
import MyTabsNew from '@/components/MyTabsNew';
 
const TextArea = Input.TextArea;
 
// 获取当前风险案件关键词
function getKeyPromptApi(submitData) {
  return $$.ax.request({ urlAi: 'case-law/getKeyPrompt', typeAi: 'get', data: submitData, service: 'mediate' });
}
 
// 更新风险案件关键词
function updateKeyPromptApi(data) {
  return $$.ax.request({ urlAi: `case-law/updateKeyPrompt`, typeAi: 'post', service: 'mediate', data });
}
 
 
const Threaten = () => {
  let location = useLocation();
  let navigate = useNavigate();
  const [form] = Form.useForm();
  const [text, setText] = useState('');
  const [textStatus, setTextStatus] = useState(false);
 
  const style = { backgroundColor: '#F2F3F5', padding: '12px 16px' }
 
  async function getKeyPrompt() {
    global.setSpinning(true);
    const res = await getKeyPromptApi();
    global.setSpinning(false);
    if (res.type) {
      setText(res.data || '');
    }
  }
 
 
  async function updateKeyPrompt(data) {
    global.setSpinning(true);
    const res = await updateKeyPromptApi(data);
    global.setSpinning(false);
    if (res.type) {
      Message.success('提交成功!')
      setTextStatus(!textStatus)
    }
  }
 
  function submitClick(type) {
 
    if (type === 'submit') {
      $$.modalInfo({
        title: '确定提交该规则设定吗?',
        content: '',
        okText: '确定提交',
        cancelText: '我再想想',
        onOk: async () => {
          updateKeyPrompt({ promptText: text }, true)
        },
      });
    } else {
      setTextStatus(!textStatus)
    }
  }
 
 
 
  // 初始化
  useEffect(() => {
    getKeyPrompt();
  }, [])
 
  return (
    <NewPage pageHead={{ breadcrumbData: [{ title: '工作台' }, { title: '扬言极端事件匹配规则' }], title: '规则设定' }}>
      <div className="comprehensive" style={{ height: 'calc(100% - 100px)', backgroundColor: '#fff', }}>
        <div style={{ padding: '16px', display: 'flex', flexDirection: 'column', gap: '16px', height: '100%' }}>
          <Alert
            type='info'
            content={<span>系统将使用用户设定的短语或单词,通过语义识别算法检测符合条件的扬言/极端事件,多个单词请用逗号分隔,如自杀,情绪激动,跳楼</span>}
          />
          <div style={!textStatus && text ? { ...style, flex: '1' } : { flex: '1' }}>
            {
              !textStatus &&
              <>
                {
                  text ?
                    <div>{text}</div> :
                    <div className='handle-content-empty' style={{ marginTop: '20%' }}>
                      {$$.MyNewEmpty()}
                      <div style={{ display: 'flex', marginTop: '12px', justifyContent: 'center' }}>
                        <Button type='primary' onClick={() => { setTextStatus(!textStatus) }}>
                          去设置
                        </Button>
                      </div>
                    </div>
                }
              </>
            }
            {
              textStatus &&
              <TextArea value={text} onChange={(e) => { setText(e) }} style={{ height: '100%' }} placeholder='扬言,自杀,情绪激动,厌世,轻生,活着没意思,威胁,跳楼' />
            }
          </div>
          {
            textStatus &&
            <div style={{ display: 'flex', gap: '16px' }}>
              <Button type='primary' onClick={() => { submitClick('submit') }}>
                提交
              </Button>
              <Button type='secondary' onClick={() => { submitClick('cancel') }}>
                取消修改
              </Button>
            </div>
          }
          {
            !textStatus && text &&
            <div style={{ display: 'flex', gap: '16px' }}>
              <Button type='primary' onClick={() => { setTextStatus(!textStatus) }}>
                修改
              </Button>
            </div>
          }
 
        </div>
      </div>
    </NewPage >
  );
};
 
export default Threaten;