index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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="word">
  5. <el-input
  6. v-model="queryParams.word"
  7. placeholder="请输入违禁词"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="操作人" prop="operator">
  14. <el-input
  15. v-model="queryParams.operator"
  16. placeholder="请输入操作人"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  24. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  25. </el-form-item>
  26. </el-form>
  27. <el-row :gutter="10" class="mb8">
  28. <el-col :span="1.5">
  29. <el-button
  30. type="primary"
  31. icon="el-icon-plus"
  32. size="mini"
  33. @click="handleAdd"
  34. v-hasPermi="['qw:words:add']"
  35. >新增</el-button>
  36. </el-col>
  37. <el-col :span="1.5">
  38. <el-button
  39. type="success"
  40. icon="el-icon-edit"
  41. size="mini"
  42. :disabled="single"
  43. @click="handleUpdate"
  44. v-hasPermi="['qw:words:edit']"
  45. >修改</el-button>
  46. </el-col>
  47. <el-col :span="1.5">
  48. <el-button
  49. type="danger"
  50. icon="el-icon-delete"
  51. size="mini"
  52. :disabled="multiple"
  53. @click="handleDelete"
  54. v-hasPermi="['qw:words:remove']"
  55. >删除</el-button>
  56. </el-col>
  57. <el-col :span="1.5">
  58. <el-button
  59. type="warning"
  60. icon="el-icon-download"
  61. size="mini"
  62. @click="handleExport"
  63. v-hasPermi="['qw:words:export']"
  64. >导出</el-button>
  65. </el-col>
  66. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  67. </el-row>
  68. <el-table border v-loading="loading" :data="wordsList" @selection-change="handleSelectionChange">
  69. <el-table-column type="selection" width="55" align="center" />
  70. <el-table-column label="序号" width="55" type="index" align="center" />
  71. <el-table-column label="id" align="center" prop="id" />
  72. <el-table-column label="违禁词" align="center" prop="word" />
  73. <el-table-column label="操作人" align="center" prop="operator" />
  74. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  75. <template slot-scope="scope">
  76. <el-button
  77. size="mini"
  78. type="text"
  79. icon="el-icon-edit"
  80. @click="handleUpdate(scope.row)"
  81. v-hasPermi="['qw:words:edit']"
  82. >修改</el-button>
  83. <el-button
  84. size="mini"
  85. type="text"
  86. icon="el-icon-delete"
  87. @click="handleDelete(scope.row)"
  88. v-hasPermi="['qw:words:remove']"
  89. >删除</el-button>
  90. </template>
  91. </el-table-column>
  92. </el-table>
  93. <pagination
  94. v-show="total>0"
  95. :total="total"
  96. :page.sync="queryParams.pageNum"
  97. :limit.sync="queryParams.pageSize"
  98. @pagination="getList"
  99. />
  100. <!-- 添加或修改企微违禁词管理对话框 -->
  101. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  102. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  103. <el-form-item label="违禁词" prop="word">
  104. <el-input v-model="form.word" placeholder="请输入违禁词" />
  105. </el-form-item>
  106. </el-form>
  107. <div slot="footer" class="dialog-footer">
  108. <el-button type="primary" @click="submitForm">确 定</el-button>
  109. <el-button @click="cancel">取 消</el-button>
  110. </div>
  111. </el-dialog>
  112. </div>
  113. </template>
  114. <script>
  115. import { listWords, getWords, delWords, addWords, updateWords, exportWords } from "@/api/qw/words";
  116. export default {
  117. name: "Words",
  118. data() {
  119. return {
  120. // 遮罩层
  121. loading: true,
  122. // 选中数组
  123. ids: [],
  124. // 非单个禁用
  125. single: true,
  126. // 非多个禁用
  127. multiple: true,
  128. // 显示搜索条件
  129. showSearch: true,
  130. // 总条数
  131. total: 0,
  132. // 企微违禁词管理表格数据
  133. wordsList: [],
  134. // 弹出层标题
  135. title: "",
  136. // 是否显示弹出层
  137. open: false,
  138. // 查询参数
  139. queryParams: {
  140. pageNum: 1,
  141. pageSize: 10,
  142. word: null,
  143. severity: null,
  144. operator: null
  145. },
  146. // 表单参数
  147. form: {},
  148. // 表单校验
  149. rules: {
  150. }
  151. };
  152. },
  153. created() {
  154. this.getList();
  155. },
  156. methods: {
  157. /** 查询企微违禁词管理列表 */
  158. getList() {
  159. this.loading = true;
  160. listWords(this.queryParams).then(response => {
  161. this.wordsList = response.rows;
  162. this.total = response.total;
  163. this.loading = false;
  164. });
  165. },
  166. // 取消按钮
  167. cancel() {
  168. this.open = false;
  169. this.reset();
  170. },
  171. // 表单重置
  172. reset() {
  173. this.form = {
  174. id: null,
  175. word: null,
  176. severity: null,
  177. createTime: null,
  178. updateTime: null,
  179. operator: null
  180. };
  181. this.resetForm("form");
  182. },
  183. /** 搜索按钮操作 */
  184. handleQuery() {
  185. this.queryParams.pageNum = 1;
  186. this.getList();
  187. },
  188. /** 重置按钮操作 */
  189. resetQuery() {
  190. this.resetForm("queryForm");
  191. this.handleQuery();
  192. },
  193. // 多选框选中数据
  194. handleSelectionChange(selection) {
  195. this.ids = selection.map(item => item.id)
  196. this.single = selection.length!==1
  197. this.multiple = !selection.length
  198. },
  199. /** 新增按钮操作 */
  200. handleAdd() {
  201. this.reset();
  202. this.open = true;
  203. this.title = "添加企微违禁词管理";
  204. },
  205. /** 修改按钮操作 */
  206. handleUpdate(row) {
  207. this.reset();
  208. const id = row.id || this.ids
  209. getWords(id).then(response => {
  210. this.form = response.data;
  211. this.open = true;
  212. this.title = "修改企微违禁词管理";
  213. });
  214. },
  215. /** 提交按钮 */
  216. submitForm() {
  217. this.$refs["form"].validate(valid => {
  218. if (valid) {
  219. if (this.form.id != null) {
  220. updateWords(this.form).then(response => {
  221. if (response.code === 200) {
  222. this.msgSuccess("修改成功");
  223. this.open = false;
  224. this.getList();
  225. }
  226. });
  227. } else {
  228. addWords(this.form).then(response => {
  229. if (response.code === 200) {
  230. this.msgSuccess("新增成功");
  231. this.open = false;
  232. this.getList();
  233. }
  234. });
  235. }
  236. }
  237. });
  238. },
  239. /** 删除按钮操作 */
  240. handleDelete(row) {
  241. const ids = row.id || this.ids;
  242. this.$confirm('是否确认删除企微违禁词管理编号为"' + ids + '"的数据项?', "警告", {
  243. confirmButtonText: "确定",
  244. cancelButtonText: "取消",
  245. type: "warning"
  246. }).then(function() {
  247. return delWords(ids);
  248. }).then(() => {
  249. this.getList();
  250. this.msgSuccess("删除成功");
  251. }).catch(function() {});
  252. },
  253. /** 导出按钮操作 */
  254. handleExport() {
  255. const queryParams = this.queryParams;
  256. this.$confirm('是否确认导出所有企微违禁词管理数据项?', "警告", {
  257. confirmButtonText: "确定",
  258. cancelButtonText: "取消",
  259. type: "warning"
  260. }).then(function() {
  261. return exportWords(queryParams);
  262. }).then(response => {
  263. this.download(response.msg);
  264. }).catch(function() {});
  265. }
  266. }
  267. };
  268. </script>