index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="类型" prop="type">
  5. <el-select v-model="queryParams.type" placeholder="请选择类型" clearable size="small">
  6. <el-option
  7. v-for="dict in typeOptions"
  8. :key="dict.dictValue"
  9. :label="dict.dictLabel"
  10. :value="dict.dictValue"
  11. />
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="状态" prop="status">
  15. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
  16. <el-option
  17. v-for="dict in statusOptions"
  18. :key="dict.dictValue"
  19. :label="dict.dictLabel"
  20. :value="dict.dictValue"
  21. />
  22. </el-select>
  23. </el-form-item>
  24. <!-- <el-form-item label="排序" prop="sort">
  25. <el-input
  26. v-model="queryParams.sort"
  27. placeholder="请输入排序"
  28. clearable
  29. size="small"
  30. @keyup.enter.native="handleQuery"
  31. />
  32. </el-form-item>-->
  33. <el-form-item>
  34. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  35. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  36. </el-form-item>
  37. </el-form>
  38. <el-row :gutter="10" class="mb8">
  39. <el-col :span="1.5">
  40. <el-button
  41. type="primary"
  42. plain
  43. icon="el-icon-plus"
  44. size="mini"
  45. @click="handleAdd"
  46. v-hasPermi="['fastGpt:fastgptChatArtificialWords:add']"
  47. >新增</el-button>
  48. </el-col>
  49. <el-col :span="1.5">
  50. <el-button
  51. type="success"
  52. plain
  53. icon="el-icon-edit"
  54. size="mini"
  55. :disabled="single"
  56. @click="handleUpdate"
  57. v-hasPermi="['fastGpt:fastgptChatArtificialWords:edit']"
  58. >修改</el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="danger"
  63. plain
  64. icon="el-icon-delete"
  65. size="mini"
  66. :disabled="multiple"
  67. @click="handleDelete"
  68. v-hasPermi="['fastGpt:fastgptChatArtificialWords:remove']"
  69. >删除</el-button>
  70. </el-col>
  71. <!-- <el-col :span="1.5">
  72. <el-button
  73. type="warning"
  74. plain
  75. icon="el-icon-download"
  76. size="mini"
  77. :loading="exportLoading"
  78. @click="handleExport"
  79. v-hasPermi="['fastGpt:fastgptChatArtificialWords:export']"
  80. >导出</el-button>
  81. </el-col>-->
  82. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  83. </el-row>
  84. <el-table border v-loading="loading" :data="fastgptChatArtificialWordsList" @selection-change="handleSelectionChange">
  85. <el-table-column type="selection" width="55" align="center" />
  86. <el-table-column label="id" align="center" prop="id" />
  87. <el-table-column label="类型" align="center" prop="type">
  88. <template slot-scope="scope">
  89. <dict-tag :options="typeOptions" :value="scope.row.type"/>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="文本" align="center" prop="content" />
  93. <el-table-column label="状态" align="center" prop="status">
  94. <template slot-scope="scope">
  95. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  96. </template>
  97. </el-table-column>
  98. <el-table-column label="排序" align="center" prop="sort" />
  99. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  100. <template slot-scope="scope">
  101. <el-button
  102. size="mini"
  103. type="text"
  104. icon="el-icon-edit"
  105. @click="handleUpdate(scope.row)"
  106. v-hasPermi="['fastGpt:fastgptChatArtificialWords:edit']"
  107. >修改</el-button>
  108. <el-button
  109. size="mini"
  110. type="text"
  111. icon="el-icon-delete"
  112. @click="handleDelete(scope.row)"
  113. v-hasPermi="['fastGpt:fastgptChatArtificialWords:remove']"
  114. >删除</el-button>
  115. </template>
  116. </el-table-column>
  117. </el-table>
  118. <pagination
  119. v-show="total>0"
  120. :total="total"
  121. :page.sync="queryParams.pageNum"
  122. :limit.sync="queryParams.pageSize"
  123. @pagination="getList"
  124. />
  125. <!-- 添加或修改转人工提示词对话框 -->
  126. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  127. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  128. <el-form-item label="类型" prop="type">
  129. <el-select v-model="form.type" placeholder="请选择类型">
  130. <el-option
  131. v-for="dict in typeOptions"
  132. :key="dict.dictValue"
  133. :label="dict.dictLabel"
  134. :value="parseInt(dict.dictValue)"
  135. ></el-option>
  136. </el-select>
  137. </el-form-item>
  138. <el-form-item label="文本" prop="content">
  139. <el-input v-model="form.content" placeholder="请输入文本内容"/>
  140. </el-form-item>
  141. <el-form-item label="状态">
  142. <el-radio-group v-model="form.status">
  143. <el-radio
  144. v-for="dict in statusOptions"
  145. :key="dict.dictValue"
  146. :label="parseInt(dict.dictValue)"
  147. >{{dict.dictLabel}}</el-radio>
  148. </el-radio-group>
  149. </el-form-item>
  150. <el-form-item label="排序" prop="sort">
  151. <el-input v-model="form.sort" placeholder="请输入排序" />
  152. </el-form-item>
  153. </el-form>
  154. <div slot="footer" class="dialog-footer">
  155. <el-button type="primary" @click="submitForm">确 定</el-button>
  156. <el-button @click="cancel">取 消</el-button>
  157. </div>
  158. </el-dialog>
  159. </div>
  160. </template>
  161. <script>
  162. import { listFastgptChatArtificialWords, getFastgptChatArtificialWords, delFastgptChatArtificialWords, addFastgptChatArtificialWords, updateFastgptChatArtificialWords, exportFastgptChatArtificialWords } from "@/api/fastGpt/fastgptChatArtificialWords";
  163. export default {
  164. name: "FastgptChatArtificialWords",
  165. data() {
  166. return {
  167. // 遮罩层
  168. loading: true,
  169. // 导出遮罩层
  170. exportLoading: false,
  171. // 选中数组
  172. ids: [],
  173. // 非单个禁用
  174. single: true,
  175. // 非多个禁用
  176. multiple: true,
  177. // 显示搜索条件
  178. showSearch: true,
  179. // 总条数
  180. total: 0,
  181. // 转人工提示词表格数据
  182. fastgptChatArtificialWordsList: [],
  183. // 弹出层标题
  184. title: "",
  185. // 是否显示弹出层
  186. open: false,
  187. // 类型 1报错 2关键词字典
  188. typeOptions: [],
  189. // 状态字典
  190. statusOptions: [],
  191. // 查询参数
  192. queryParams: {
  193. pageNum: 1,
  194. pageSize: 10,
  195. type: null,
  196. content: null,
  197. status: null,
  198. sort: null,
  199. },
  200. // 表单参数
  201. form: {},
  202. // 表单校验
  203. rules: {
  204. type: [
  205. { required: true, message: "类型不能为空", trigger: "blur" }
  206. ],
  207. content: [
  208. { required: true, message: "文本不能为空", trigger: "blur" }
  209. ],
  210. sort: [
  211. { required: true, message: "排序不能为空", trigger: "blur" }
  212. ],
  213. }
  214. };
  215. },
  216. created() {
  217. this.getList();
  218. this.getDicts("sys_artificial_words_type").then(response => {
  219. this.typeOptions = response.data;
  220. });
  221. this.getDicts("sys_company_status").then(response => {
  222. this.statusOptions = response.data;
  223. });
  224. },
  225. methods: {
  226. /** 查询转人工提示词列表 */
  227. getList() {
  228. this.loading = true;
  229. listFastgptChatArtificialWords(this.queryParams).then(response => {
  230. this.fastgptChatArtificialWordsList = response.rows;
  231. this.total = response.total;
  232. this.loading = false;
  233. });
  234. },
  235. // 取消按钮
  236. cancel() {
  237. this.open = false;
  238. this.reset();
  239. },
  240. // 表单重置
  241. reset() {
  242. this.form = {
  243. id: null,
  244. type: null,
  245. content: null,
  246. status: 0,
  247. sort: null,
  248. createTime: null
  249. };
  250. this.resetForm("form");
  251. },
  252. /** 搜索按钮操作 */
  253. handleQuery() {
  254. this.queryParams.pageNum = 1;
  255. this.getList();
  256. },
  257. /** 重置按钮操作 */
  258. resetQuery() {
  259. this.resetForm("queryForm");
  260. this.handleQuery();
  261. },
  262. // 多选框选中数据
  263. handleSelectionChange(selection) {
  264. this.ids = selection.map(item => item.id)
  265. this.single = selection.length!==1
  266. this.multiple = !selection.length
  267. },
  268. /** 新增按钮操作 */
  269. handleAdd() {
  270. this.reset();
  271. this.open = true;
  272. this.title = "添加转人工提示词";
  273. },
  274. /** 修改按钮操作 */
  275. handleUpdate(row) {
  276. this.reset();
  277. const id = row.id || this.ids
  278. getFastgptChatArtificialWords(id).then(response => {
  279. this.form = response.data;
  280. this.open = true;
  281. this.title = "修改转人工提示词";
  282. });
  283. },
  284. /** 提交按钮 */
  285. submitForm() {
  286. this.$refs["form"].validate(valid => {
  287. if (valid) {
  288. if (this.form.id != null) {
  289. updateFastgptChatArtificialWords(this.form).then(response => {
  290. this.msgSuccess("修改成功");
  291. this.open = false;
  292. this.getList();
  293. });
  294. } else {
  295. addFastgptChatArtificialWords(this.form).then(response => {
  296. this.msgSuccess("新增成功");
  297. this.open = false;
  298. this.getList();
  299. });
  300. }
  301. }
  302. });
  303. },
  304. /** 删除按钮操作 */
  305. handleDelete(row) {
  306. const ids = row.id || this.ids;
  307. this.$confirm('是否确认删除转人工提示词编号为"' + ids + '"的数据项?', "警告", {
  308. confirmButtonText: "确定",
  309. cancelButtonText: "取消",
  310. type: "warning"
  311. }).then(function() {
  312. return delFastgptChatArtificialWords(ids);
  313. }).then(() => {
  314. this.getList();
  315. this.msgSuccess("删除成功");
  316. }).catch(() => {});
  317. },
  318. /** 导出按钮操作 */
  319. handleExport() {
  320. const queryParams = this.queryParams;
  321. this.$confirm('是否确认导出所有转人工提示词数据项?', "警告", {
  322. confirmButtonText: "确定",
  323. cancelButtonText: "取消",
  324. type: "warning"
  325. }).then(() => {
  326. this.exportLoading = true;
  327. return exportFastgptChatArtificialWords(queryParams);
  328. }).then(response => {
  329. this.download(response.msg);
  330. this.exportLoading = false;
  331. }).catch(() => {});
  332. }
  333. }
  334. };
  335. </script>