You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

246 lines
6.7 KiB

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