fastGptRoleUpdate.vue 26 KB

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