fastGptRoleUpdate.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860
  1. <template>
  2. <div class="app-container">
  3. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  4. <el-form-item label="客服名称" prop="roleName">
  5. <el-input v-model="form.roleName" placeholder="请输入角色名" />
  6. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  7. <i class="el-icon-info"></i>
  8. AI角色名字
  9. </div>
  10. </el-form-item>
  11. <el-form-item label="角色类型" prop="roleType">
  12. <el-select v-model="form.roleType" placeholder="请选择类型" clearable size="small" style="width: 150px" >
  13. <el-option
  14. v-for="item in typeOptions"
  15. :key="item.dictValue"
  16. :label="item.dictLabel"
  17. :value="String(item.dictValue)"
  18. />
  19. </el-select>
  20. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  21. <i class="el-icon-info"></i>
  22. 选择角色类型:一般选择伴学助手,医生工作室,伴学助手无性别,无性别版本只会叫用户同学,其余的会叫用户先生女士
  23. </div>
  24. </el-form-item>
  25. <el-form-item label="渠道类型" prop="channelType">
  26. <el-select v-model="form.channelType" placeholder="请选择类型" clearable size="small" style="width: 150px" >
  27. <el-option
  28. v-for="item in channelOptions"
  29. :key="item.dictValue"
  30. :label="item.dictLabel"
  31. :value="String(item.dictLabel)"
  32. />
  33. </el-select>
  34. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  35. <i class="el-icon-info"></i>
  36. 选择进线渠道:只影响新客户进来的首次对话
  37. </div>
  38. </el-form-item>
  39. <el-form-item label="物流提醒" prop="logistics">
  40. <el-select v-model="form.logistics" placeholder="请选择类型" clearable size="small" style="width: 150px" >
  41. <el-option
  42. v-for="item in logisticsOptions"
  43. :key="item.value"
  44. :label="item.label"
  45. :value="item.value"
  46. />
  47. </el-select>
  48. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  49. <i class="el-icon-info"></i>
  50. AI是否主动发送物流信息,发货和到货的时候会提醒用户
  51. </div>
  52. </el-form-item>
  53. <el-form-item label="客服头像" prop="avatar">
  54. <ImageUpload v-model="form.avatar" type="image" :num="1" :width="150" :height="150" style="margin-top: 1%;" />
  55. </el-form-item>
  56. <el-form-item label="APPKey" >
  57. <el-input type="textarea" v-model="form.modeConfigJson.APPKey" placeholder="请输入APPKey(特定key)" />
  58. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  59. <i class="el-icon-info"></i>
  60. 根据管理员发送的APPKey填写
  61. </div>
  62. </el-form-item>
  63. <el-form-item label="提示词" >
  64. <el-input type="textarea" :rows="3" v-model="form.reminderWords" placeholder="请输入提示词" />
  65. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  66. <i class="el-icon-info"></i>
  67. 输入个人的介绍,并且在最后增加一个自我介绍(用于首次交流触发),模板可以找管理员获取
  68. </div>
  69. </el-form-item>
  70. <!-- <el-form-item label="标签人设" >
  71. <div v-if="tagsFormList.length > 0" style="display: flex; align-items: center; flex-wrap: wrap; width: 100%;">
  72. <div style="min-height: 40px; max-height: 200px; overflow-y: auto; width: 100%;">
  73. <div style="display: flex; flex-wrap: wrap; width: 100%;">
  74. <div v-for="(tagsForm, index) in tagsFormList" :key="tagsForm.id">
  75. <el-tag type="success"
  76. closable
  77. :disable-transitions="false"
  78. @click="handleEditRoleTag(tagsForm, index)"
  79. @close="handleCloseRoleTag(tagsForm, index)"
  80. style="margin: 3px;">
  81. {{ getTagNames(tagsForm.tagIds) }}
  82. </el-tag>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. <el-button
  88. size="mini"
  89. type="primary" plain
  90. icon="el-icon-circle-plus-outline"
  91. @click="handleAddTags(form.roleId,form.bindCorpId)"
  92. v-hasPermi="['fastGptRole:fastGptRole:edit']"
  93. >添加标签人设</el-button>
  94. </el-form-item> -->
  95. <!-- <el-form-item label="修改栏目" prop="contactInfo">
  96. <el-select v-model="contactInfo" multiple filterable placeholder="请选择修改栏目" clearable size="small" style="width: 50%" >
  97. <el-option
  98. v-for="item in externalInfoOptions"
  99. :key="item.dictValue"
  100. :label="item.dictLabel"
  101. :value="item.dictValue"
  102. />
  103. </el-select>
  104. </el-form-item> -->
  105. </el-form>
  106. <div slot="footer" class="dialog-footer" style="padding-bottom: 40px;">
  107. <el-button type="primary" @click="submitForm" style="float: right;margin-right: 20px;">确 定</el-button>
  108. <el-button @click="cancel" style="float: right;margin-right: 20px;">取 消</el-button>
  109. </div>
  110. <!-- 修改-->
  111. <el-dialog :title="changeTagsOpen.title" :visible.sync="changeTagsOpen.open" width="800px" append-to-body>
  112. <el-form ref="tagsForm" :model="tagsForm" :rules="tagsFormRules">
  113. <el-form-item label="选择标签" prop="tagIds">
  114. <div @click="handleChangeTags(changeTagsOpen.roleId)" style="cursor: pointer; border: 1px solid #e6e6e6; background-color: white; overflow: hidden; flex-grow: 1;width: 100%">
  115. <div style="min-height: 40px; max-height: 200px; overflow-y: auto;">
  116. <el-tag type="success"
  117. closable
  118. :disable-transitions="false"
  119. v-for="list in tagListFormIndex"
  120. :key="list.tagId"
  121. @close="handleCloseTag(list)"
  122. style="margin: 3px;"
  123. >{{list.name}}
  124. </el-tag>
  125. </div>
  126. </div>
  127. </el-form-item>
  128. <el-form-item label="提示词" prop="reminderWords">
  129. <el-input type="textarea" :rows="6" v-model="tagsForm.reminderWords" placeholder="请输入AI客服该标签的提示词" />
  130. </el-form-item>
  131. </el-form>
  132. <div slot="footer" class="dialog-footer">
  133. <el-button type="primary" @click="submitTagsForm(changeTagsOpen.roleId)">确 定</el-button>
  134. <el-button @click="cancelTags">取 消</el-button>
  135. </div>
  136. </el-dialog>
  137. <el-dialog :title="tagChange.title" :visible.sync="tagChange.open" width="800px" append-to-body>
  138. <div v-for="item in tagGroupList" :key="item.id" >
  139. <div style="font-size: 20px;margin-top: 20px;margin-bottom: 20px;">
  140. <span class="name-background">{{ item.name }}</span>
  141. </div>
  142. <div class="tag-container">
  143. <a
  144. v-for="tagItem in item.tag"
  145. class="tag-box"
  146. @click="tagSelection(tagItem)"
  147. :class="{ 'tag-selected': tagItem.isSelected }"
  148. >
  149. {{ tagItem.name }}
  150. </a>
  151. </div>
  152. </div>
  153. <div slot="footer" class="dialog-footer">
  154. <el-button type="primary" @click="editTagSubmitForm(tagChange.roleId)">确 定</el-button>
  155. <el-button @click="editTagCancel(tagChange.roleId)">取消</el-button>
  156. </div>
  157. </el-dialog>
  158. <!-- 新增-->
  159. <el-dialog :title="changeTagsOpenAdd.title" :visible.sync="changeTagsOpenAdd.open" width="800px" append-to-body>
  160. <el-form ref="tagsFormAdd" :model="tagsFormAdd" :rules="tagsFormAddRules">
  161. <el-form-item label="选择标签" prop="tagIds">
  162. <div @click="handleChangeTagsAdd(changeTagsOpenAdd.roleId)" style="cursor: pointer; border: 1px solid #e6e6e6; background-color: white; overflow: hidden; flex-grow: 1;width: 100%">
  163. <div style="min-height: 40px; max-height: 200px; overflow-y: auto;">
  164. <el-tag type="success"
  165. closable
  166. :disable-transitions="false"
  167. v-for="list in tagListFormIndexAdd"
  168. :key="list.tagId"
  169. @close="handleCloseTag(list)"
  170. style="margin: 3px;"
  171. >{{list.name}}
  172. </el-tag>
  173. </div>
  174. </div>
  175. </el-form-item>
  176. <el-form-item label="提示词" prop="reminderWords">
  177. <el-input type="textarea" :rows="6" v-model="tagsFormAdd.reminderWords" placeholder="请输入AI客服该标签的提示词" />
  178. </el-form-item>
  179. </el-form>
  180. <div slot="footer" class="dialog-footer">
  181. <el-button type="primary" @click="submitAddTagsForm(changeTagsOpenAdd.roleId)">确 定</el-button>
  182. <el-button @click="cancelAddTags">取 消</el-button>
  183. </div>
  184. </el-dialog>
  185. <el-dialog :title="tagChangeAdd.title" :visible.sync="tagChangeAdd.open" width="800px" append-to-body>
  186. <div v-for="item in tagGroupList" :key="item.id" >
  187. <div style="font-size: 20px;margin-top: 20px;margin-bottom: 20px;">
  188. <span class="name-background">{{ item.name }}</span>
  189. </div>
  190. <div class="tag-container">
  191. <a
  192. v-for="tagItem in item.tag"
  193. class="tag-box"
  194. @click="tagSelection(tagItem)"
  195. :class="{ 'tag-selected': tagItem.isSelected }"
  196. >
  197. {{ tagItem.name }}
  198. </a>
  199. </div>
  200. </div>
  201. <div slot="footer" class="dialog-footer">
  202. <el-button type="primary" @click="addTagSubmitForm(tagChangeAdd.roleId)">确 定</el-button>
  203. <el-button @click="addTagCancel(tagChangeAdd.roleId)">取消</el-button>
  204. </div>
  205. </el-dialog>
  206. </div>
  207. </template>
  208. <script>
  209. import { listFastGptRole, getFastGptRole, delFastGptRole, addFastGptRole, updateFastGptRole, exportFastGptRole,getAllRoleType } from "@/api/fastGpt/fastGptRole";
  210. import {allListTagGroup} from "@/api/qw/tagGroup";
  211. import {listTag} from "@/api/qw/tag";
  212. import {
  213. addFastGptRoleTag,
  214. delFastGptRoleTag,
  215. getListByRoleId,
  216. updateFastGptRoleTag
  217. } from "@/api/fastGpt/fastGptRoleTag";
  218. import source from "echarts/src/data/Source";
  219. import ImageUpload from "@/views/qw/sop/ImageUpload.vue";
  220. export default {
  221. name: "fastGptRoleUpdate",
  222. components: {ImageUpload},
  223. data() {
  224. return {
  225. logisticsOptions: [
  226. { label: '是', value: 1 },
  227. { label: '否', value: 0 }
  228. ],
  229. // 遮罩层
  230. loading: true,
  231. // 导出遮罩层
  232. exportLoading: false,
  233. //AI客服类型
  234. typeOptions: [],
  235. //AI模型
  236. modeOptions: [],
  237. //渠道类型
  238. channelOptions: [],
  239. changeTagsOpen: {
  240. title : "",
  241. open :false,
  242. roleId : null,
  243. },
  244. changeTagsOpenAdd:{
  245. title : "",
  246. open :false,
  247. roleId : null,
  248. },
  249. //标签弹窗选择
  250. tagChange:{
  251. open:false,
  252. title:"",
  253. roleId:null,
  254. id:null,
  255. },
  256. //新增
  257. tagChangeAdd:{
  258. open:false,
  259. title:"",
  260. roleId:null,
  261. id:null,
  262. },
  263. //所有的标签组-标签
  264. tagGroupList:[],
  265. //所有的标签
  266. tagList:[],
  267. contactInfo:[],
  268. //已经选择的标签
  269. tagListFormIndex:[],
  270. //新的标签
  271. tagListFormIndexAdd:[],
  272. // uploadUrl:process.env.VUE_APP_BASE_API+"/chat/upload/uploadFile",
  273. uploadUrl:process.env.VUE_APP_BASE_API+"/common/uploadOSS",
  274. // 选中数组
  275. ids: [],
  276. externalInfoOptions : [],
  277. // 非单个禁用
  278. single: true,
  279. // 非多个禁用
  280. multiple: true,
  281. // 显示搜索条件
  282. showSearch: true,
  283. // 总条数
  284. total: 0,
  285. // 应用表格数据
  286. fastGptRoleList: [],
  287. // 弹出层标题
  288. title: "",
  289. // 是否显示弹出层
  290. open: false,
  291. // 查询参数
  292. queryParams: {
  293. pageNum: 1,
  294. pageSize: 10,
  295. roleName: null,
  296. companyId: null,
  297. roleType: null,
  298. mode: null,
  299. kfId: null,
  300. kfUrl: null,
  301. avatar: null,
  302. kfMediaId: null,
  303. channelType: null,
  304. logistics: null
  305. },
  306. // 表单参数
  307. form: {
  308. },
  309. //某一个标签组
  310. tagsForm:{},
  311. //新增
  312. tagsFormAdd:{},
  313. //当前role的所有标签组
  314. tagsFormList:[],
  315. // 表单校验
  316. rules: {
  317. roleName: [
  318. { required: true, message: "角色名称不能为空", trigger: "blur" }
  319. ],
  320. roleType: [
  321. { required: true, message: "角色类型不能为空", trigger: "change" }
  322. ],
  323. logistics: [
  324. { required: true, message: "物流提醒不能为空", trigger: "change" }
  325. ],
  326. },
  327. tagsFormRules:{
  328. tagIds:[
  329. { required: true, message: "标签不能为空", trigger: "blur" }
  330. ],
  331. reminderWords:[
  332. { required: true, message: "提示词不能为空", trigger: "blur" }
  333. ]
  334. },
  335. tagsFormAddRules:{
  336. tagIds:[
  337. { required: true, message: "标签不能为空", trigger: "blur" }
  338. ],
  339. reminderWords:[
  340. { required: true, message: "提示词不能为空", trigger: "blur" }
  341. ]
  342. }
  343. };
  344. },
  345. watch: {
  346. tagListFormIndex: {
  347. handler(newList) {
  348. if (!Array.isArray(newList)) return; // 仅在 newList 为数组时继续
  349. // 确保 tagsForm.tagIds 是数组并清空它
  350. this.tagsForm.tagIds = [];
  351. // 遍历 newList,添加 tagId
  352. newList.forEach(tags => {
  353. if (Array.isArray(tags)) {
  354. // 如果 tags 是数组,遍历并添加
  355. tags.forEach(item => {
  356. if (item && item.tagId !== undefined) {
  357. this.tagsForm.tagIds.push(item.tagId);
  358. }
  359. });
  360. } else if (tags && tags.tagId !== undefined) {
  361. // 如果 tags 是单个对象,直接添加
  362. this.tagsForm.tagIds.push(tags.tagId);
  363. }
  364. });
  365. },
  366. deep: true
  367. },
  368. tagListFormIndexAdd: {
  369. handler(newList) {
  370. if (!Array.isArray(newList)) return; // 仅在 newList 为数组时继续
  371. // 确保 tagsForm.tagIds 是数组并清空它
  372. this.tagsFormAdd.tagIds = [];
  373. // 遍历 newList,添加 tagId
  374. newList.forEach(tags => {
  375. if (Array.isArray(tags)) {
  376. // 如果 tags 是数组,遍历并添加
  377. tags.forEach(item => {
  378. if (item && item.tagId !== undefined) {
  379. this.tagsFormAdd.tagIds.push(item.tagId);
  380. }
  381. });
  382. } else if (tags && tags.tagId !== undefined) {
  383. // 如果 tags 是单个对象,直接添加
  384. this.tagsFormAdd.tagIds.push(tags.tagId);
  385. }
  386. });
  387. },
  388. deep: true
  389. }
  390. },
  391. created() {
  392. this.handleUpdate();
  393. //客服类型
  394. // this.getDicts("chat_role_type").then((response) => {
  395. // this.typeOptions = response.data;
  396. // });
  397. //AI模型
  398. this.getDicts("chat_role_mode").then((response) => {
  399. this.modeOptions = response.data;
  400. });
  401. this.getDicts("sys_fastgpt_role_external_info").then((response) => {
  402. this.externalInfoOptions = response.data;
  403. });
  404. //渠道类型
  405. this.getDicts("sys_fastgpt_channel_type").then((response) => {
  406. this.channelOptions = response.data;
  407. });
  408. getAllRoleType().then(response => {
  409. this.typeOptions = response.data;
  410. });
  411. },
  412. methods: {
  413. /** 查询应用列表 */
  414. getList() {
  415. this.loading = true;
  416. listFastGptRole(this.queryParams).then(response => {
  417. this.fastGptRoleList = response.rows;
  418. this.total = response.total;
  419. this.loading = false;
  420. });
  421. },
  422. // 取消按钮
  423. cancel() {
  424. this.reset();
  425. window.location.replace('/fastGpt/fastGptRole')
  426. },
  427. cancelTags(){
  428. this.changeTagsOpen.open=false;
  429. },
  430. cancelAddTags(){
  431. this.changeTagsOpenAdd.open=false;
  432. },
  433. handleAvatarSuccess(res, file) {
  434. if(res.code==200){
  435. if(res.data.errcode!=0){
  436. this.msgError(res.data.errmsg);
  437. }
  438. else{
  439. //获取图片
  440. this.form.kfMediaId=res.data.media_id;
  441. this.form.avatar = res.ossUrl;
  442. this.$forceUpdate()
  443. }
  444. }
  445. else{
  446. this.msgError(res.msg);
  447. }
  448. },
  449. beforeAvatarUpload(file) {
  450. const isLt1M = file.size / 1024 / 1024 < 1;
  451. if (!isLt1M) {
  452. this.$message.error('上传图片大小不能超过 1MB!');
  453. }
  454. return isLt1M;
  455. },
  456. // 表单重置
  457. reset() {
  458. this.form = {
  459. roleId: null,
  460. roleName: null,
  461. companyId: null,
  462. createTime: null,
  463. updateTime: null,
  464. roleType: null,
  465. modeConfigJson:{APPKey:null,Key:null},
  466. mode: 2,
  467. kfId: null,
  468. kfUrl: null,
  469. avatar: null,
  470. kfMediaId: null,
  471. reminderWords: null,
  472. isTags:null,
  473. };
  474. this.resetForm("form");
  475. },
  476. tagRest(){
  477. this.tagListFormIndex=[];
  478. this.tagsForm={
  479. tagIds:null,
  480. reminderWords:null,
  481. };
  482. },
  483. tagAddRest(){
  484. this.tagListFormIndexAdd=[];
  485. this.tagsFormAdd={
  486. tagIds:null,
  487. reminderWords:null,
  488. };
  489. },
  490. /** 搜索按钮操作 */
  491. handleQuery() {
  492. this.queryParams.pageNum = 1;
  493. this.getList();
  494. },
  495. /** 重置按钮操作 */
  496. resetQuery() {
  497. this.resetForm("queryForm");
  498. this.handleQuery();
  499. },
  500. // 多选框选中数据
  501. handleSelectionChange(selection) {
  502. this.ids = selection.map(item => item.roleId)
  503. this.single = selection.length!==1
  504. this.multiple = !selection.length
  505. },
  506. /** 修改按钮操作 */
  507. handleUpdate() {
  508. var id=this.$route.params.command
  509. this.reset();
  510. getFastGptRole(id).then(response => {
  511. this.form = response.role;
  512. this.form.roleType = JSON.stringify(response.role.roleType);
  513. if(this.form.modeConfigJson!=null&&this.form.modeConfigJson!=""){
  514. this.form.modeConfigJson=JSON.parse(this.form.modeConfigJson)
  515. }else{
  516. this.form.modeConfigJson={APPKey:null}
  517. }
  518. if(this.form.contactInfo!=null){
  519. this.contactInfo = (this.form.contactInfo).split(",");
  520. }
  521. //含标签吗
  522. getListByRoleId(id).then(res => {
  523. this.tagsFormList=res.rows;
  524. })
  525. allListTagGroup({corpId:this.form.corpId}).then(response => {
  526. this.tagGroupList = response.rows;
  527. });
  528. //所有的标签
  529. listTag({corpId:this.form.corpId}).then(response => {
  530. this.tagList = response.rows;
  531. });
  532. this.title = "修改应用";
  533. });
  534. },
  535. getTagNames(tagIds) {
  536. // 确保 tagIds 是数组,如果是字符串则分割
  537. const idsArray = Array.isArray(tagIds) ? tagIds : tagIds.split(",");
  538. return idsArray.map(tagId => {
  539. const tag = this.tagList.find(list => list.tagId === tagId);
  540. return tag ? tag.name : tagId; // 返回标签名称或原 tagId
  541. }).join(', '); // 使用逗号和空格连接标签名称
  542. },
  543. //标签回复人设弹窗
  544. handleAddTags(value,bindCorpId) {
  545. if (bindCorpId==null){
  546. this.$message({
  547. message: '请先给AI客服-绑定企业 再添加标签【企微管理->员工管理->企微员工】',
  548. type: 'warning'
  549. });
  550. return;
  551. }
  552. this.changeTagsOpenAdd.title="创建标签回复人设";
  553. this.changeTagsOpenAdd.open=true;
  554. this.changeTagsOpenAdd.roleId=value;
  555. },
  556. //选择标签弹窗
  557. handleChangeTags(roleId){
  558. this.tagChange.open=true;
  559. this.tagChange.title='选择标签';
  560. this.tagChange.roleId=roleId;
  561. // 获取 tagListFormIndex 中的所有 tagId,用于快速查找
  562. const selectedTagIds = new Set(this.tagListFormIndex.map(tagItem => tagItem.tagId));
  563. for (let i = 0; i < this.tagGroupList.length; i++) {
  564. for (let x = 0; x < this.tagGroupList[i].tag.length; x++) {
  565. this.tagGroupList[i].tag[x].isSelected = selectedTagIds.has(this.tagGroupList[i].tag[x].tagId);
  566. }
  567. }
  568. },
  569. handleChangeTagsAdd(roleId){
  570. this.tagChangeAdd.open=true;
  571. this.tagChangeAdd.title='选择标签';
  572. this.tagChangeAdd.roleId=roleId;
  573. },
  574. //标签的选择
  575. tagSelection(row){
  576. row.isSelected= !row.isSelected;
  577. this.$forceUpdate();
  578. },
  579. //删除一些已经选择了的标签
  580. handleCloseTag(list){
  581. // 假设 list 对象具有一个 id 属性
  582. const ls = this.tagListFormIndex.findIndex(t => t.tagId === list.tagId);
  583. if (ls !== -1) {
  584. this.tagListFormIndex.splice(ls, 1);
  585. this.tagListFormIndex = [...this.tagListFormIndex];
  586. }
  587. },
  588. //删除一下已经存在的
  589. handleCloseRoleTag(row){
  590. delFastGptRoleTag(row.id).then(res => {
  591. getListByRoleId(row.roleId).then(res => {
  592. this.tagsFormList=res.rows;
  593. })
  594. })
  595. },
  596. //点击单个
  597. handleEditRoleTag(value, index) {
  598. this.changeTagsOpen.open = true;
  599. this.changeTagsOpen.title = "编辑标签回复人设";
  600. this.changeTagsOpen.roleId = value.roleId;
  601. this.tagsForm = value;
  602. // 过滤 tagList,获取匹配的标签
  603. const tagIdsArray = Array.isArray(value.tagIds) ? value.tagIds : value.tagIds.split(",");
  604. this.tagListFormIndex = this.tagList.filter(tag => tagIdsArray.includes(tag.tagId));
  605. },
  606. //选择标签
  607. editTagSubmitForm(){
  608. for (let i = 0; i < this.tagGroupList.length; i++) {
  609. for (let x = 0; x < this.tagGroupList[i].tag.length; x++) {
  610. if (this.tagGroupList[i].tag[x].isSelected === true) {
  611. if (!this.tagListFormIndex) {
  612. this.tagListFormIndex = [];
  613. }
  614. // 检查当前 tag 是否已经存在于 tagListFormIndex[index] 中
  615. let tagExists = this.tagListFormIndex.some(
  616. tag => tag.id === this.tagGroupList[i].tag[x].id
  617. );
  618. // 如果 tag 不存在于 tagListFormIndex[index] 中,则新增
  619. if (!tagExists) {
  620. this.tagListFormIndex.push(this.tagGroupList[i].tag[x]);
  621. }
  622. }
  623. }
  624. }
  625. if (!this.tagListFormIndex || this.tagListFormIndex.length === 0) {
  626. return this.$message('请选择标签');
  627. }
  628. this.tagChange.open = false;
  629. },
  630. //新增的标签
  631. addTagSubmitForm(){
  632. for (let i = 0; i < this.tagGroupList.length; i++) {
  633. for (let x = 0; x < this.tagGroupList[i].tag.length; x++) {
  634. if (this.tagGroupList[i].tag[x].isSelected === true) {
  635. if (!this.tagListFormIndexAdd) {
  636. this.tagListFormIndexAdd = [];
  637. }
  638. // 检查当前 tag 是否已经存在于 tagListFormIndex[index] 中
  639. let tagExists = this.tagListFormIndexAdd.some(
  640. tag => tag.id === this.tagGroupList[i].tag[x].id
  641. );
  642. // 如果 tag 不存在于 tagListFormIndex[index] 中,则新增
  643. if (!tagExists) {
  644. this.tagListFormIndexAdd.push(this.tagGroupList[i].tag[x]);
  645. }
  646. }
  647. }
  648. }
  649. if (!this.tagListFormIndexAdd || this.tagListFormIndexAdd.length === 0) {
  650. return this.$message('请选择标签');
  651. }
  652. this.tagChangeAdd.open = false;
  653. },
  654. //取消选择标签
  655. editTagCancel(){
  656. this.tagChange.open = false;
  657. // this.tagRest();
  658. },
  659. addTagCancel(){
  660. this.tagChangeAdd.open = false;
  661. this.tagAddRest();
  662. },
  663. /** 提交按钮 */
  664. submitForm() {
  665. if(this.contactInfo!=null){
  666. this.form.contactInfo= (this.contactInfo).toString()
  667. }
  668. this.$refs["form"].validate(valid => {
  669. if (valid) {
  670. this.form.modeConfigJson=JSON.stringify(this.form.modeConfigJson)
  671. if (this.form.roleId != null) {
  672. updateFastGptRole(this.form).then(response => {
  673. this.msgSuccess("修改成功");
  674. window.location.replace('/fastGpt/fastGptRole')
  675. });
  676. }
  677. }
  678. });
  679. },
  680. submitTagsForm(roleId){
  681. this.$refs["tagsForm"].validate(valid => {
  682. if (valid) {
  683. this.tagsForm.roleId=roleId
  684. this.tagsForm.tagIds=this.tagsForm.tagIds.join(",")
  685. if (this.tagsForm.id!= null) {
  686. updateFastGptRoleTag(this.tagsForm).then(response => {
  687. this.msgSuccess("修改成功");
  688. this.changeTagsOpen = false;
  689. this.getList();
  690. });
  691. }else {
  692. addFastGptRoleTag(this.tagsForm).then(response => {
  693. this.msgSuccess("新增成功");
  694. this.changeTagsOpen = false;
  695. this.getList();
  696. });
  697. }
  698. }
  699. });
  700. },
  701. submitAddTagsForm(roleId){
  702. this.$refs["tagsFormAdd"].validate(valid => {
  703. if (valid) {
  704. this.tagsFormAdd.roleId=roleId
  705. this.tagsFormAdd.tagIds=this.tagsFormAdd.tagIds.join(",")
  706. addFastGptRoleTag(this.tagsFormAdd).then(response => {
  707. this.msgSuccess("新增成功");
  708. this.changeTagsOpenAdd = false;
  709. this.open=false;
  710. this.handleUpdate();
  711. });
  712. }
  713. });
  714. },
  715. /** 删除按钮操作 */
  716. handleDelete(row) {
  717. const roleIds = row.roleId || this.ids;
  718. this.$confirm('是否确认删除应用编号为"' + roleIds + '"的数据项?', "警告", {
  719. confirmButtonText: "确定",
  720. cancelButtonText: "取消",
  721. type: "warning"
  722. }).then(function() {
  723. return delFastGptRole(roleIds);
  724. }).then(() => {
  725. this.getList();
  726. this.msgSuccess("删除成功");
  727. }).catch(() => {});
  728. },
  729. /** 导出按钮操作 */
  730. handleExport() {
  731. const queryParams = this.queryParams;
  732. this.$confirm('是否确认导出所有应用数据项?', "警告", {
  733. confirmButtonText: "确定",
  734. cancelButtonText: "取消",
  735. type: "warning"
  736. }).then(() => {
  737. this.exportLoading = true;
  738. return exportFastGptRole(queryParams);
  739. }).then(response => {
  740. this.download(response.msg);
  741. this.exportLoading = false;
  742. }).catch(() => {});
  743. }
  744. }
  745. };
  746. </script>
  747. <style scoped>
  748. /* CSS 样式 */
  749. .tag-container {
  750. display: flex;
  751. flex-wrap: wrap; /* 超出宽度时自动换行 */
  752. gap: 8px; /* 设置标签之间的间距 */
  753. }
  754. .name-background {
  755. display: inline-block;
  756. background-color: #abece6; /* 背景颜色 */
  757. padding: 4px 8px; /* 调整内边距,让背景包裹文字 */
  758. border-radius: 4px; /* 可选:设置圆角 */
  759. }
  760. .tag-box {
  761. padding: 8px 12px;
  762. border: 1px solid #989797;
  763. border-radius: 4px;
  764. cursor: pointer;
  765. display: inline-block;
  766. }
  767. .tag-selected {
  768. background-color: #00bc98;
  769. color: #fff;
  770. border-color: #00bc98;
  771. }
  772. .el-tag + .el-tag {
  773. margin-left: 10px;
  774. }
  775. .button-new-tag {
  776. margin-left: 10px;
  777. height: 32px;
  778. line-height: 30px;
  779. padding-top: 0;
  780. padding-bottom: 0;
  781. }
  782. .input-new-tag {
  783. width: 90px;
  784. margin-left: 10px;
  785. vertical-align: bottom;
  786. }
  787. .text-container {
  788. max-height: 5em; /* 设置最大高度为6行,根据字体大小调整 */
  789. overflow-y: auto; /* 内容超出时显示滚动条 */
  790. line-height: 1.5em; /* 行高设置,确保每行高度一致 */
  791. }
  792. </style>