index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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="viewCount">
  5. <el-input
  6. v-model="queryParams.viewCount"
  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:count: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:count: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:count: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:count: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="countList" @selection-change="handleSelectionChange">
  63. <el-table-column type="selection" width="55" align="center" />
  64. <el-table-column label="编号" align="center" prop="id" />
  65. <el-table-column label="故障案例" align="center" prop="faultCaseId" />
  66. <el-table-column label="浏览次数" align="center" prop="viewCount" />
  67. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  68. <template slot-scope="scope">
  69. <el-button
  70. size="mini"
  71. type="text"
  72. icon="el-icon-edit"
  73. @click="handleUpdate(scope.row)"
  74. v-hasPermi="['system:count:edit']"
  75. >修改</el-button>
  76. <el-button
  77. size="mini"
  78. type="text"
  79. icon="el-icon-delete"
  80. @click="handleDelete(scope.row)"
  81. v-hasPermi="['system:count:remove']"
  82. >删除</el-button>
  83. </template>
  84. </el-table-column>
  85. </el-table>
  86. <pagination
  87. v-show="total>0"
  88. :total="total"
  89. :page.sync="queryParams.pageNum"
  90. :limit.sync="queryParams.pageSize"
  91. @pagination="getList"
  92. />
  93. <!-- 添加或修改故障案例查看次数管理对话框 -->
  94. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  95. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  96. <el-form-item label="浏览次数" prop="viewCount">
  97. <el-input v-model="form.viewCount" placeholder="请输入浏览次数" />
  98. </el-form-item>
  99. </el-form>
  100. <div slot="footer" class="dialog-footer">
  101. <el-button type="primary" @click="submitForm">确 定</el-button>
  102. <el-button @click="cancel">取 消</el-button>
  103. </div>
  104. </el-dialog>
  105. </div>
  106. </template>
  107. <script>
  108. import { listCount, getCount, delCount, addCount, updateCount } from "@/api/system/count";
  109. export default {
  110. name: "Count",
  111. data() {
  112. return {
  113. // 遮罩层
  114. loading: true,
  115. // 选中数组
  116. ids: [],
  117. // 非单个禁用
  118. single: true,
  119. // 非多个禁用
  120. multiple: true,
  121. // 显示搜索条件
  122. showSearch: true,
  123. // 总条数
  124. total: 0,
  125. // 故障案例查看次数管理表格数据
  126. countList: [],
  127. // 弹出层标题
  128. title: "",
  129. // 是否显示弹出层
  130. open: false,
  131. // 查询参数
  132. queryParams: {
  133. pageNum: 1,
  134. pageSize: 10,
  135. faultCaseId: null,
  136. viewCount: null,
  137. },
  138. // 表单参数
  139. form: {},
  140. // 表单校验
  141. rules: {
  142. faultCaseId: [
  143. { required: true, message: "故障案例不能为空", trigger: "change" }
  144. ],
  145. }
  146. };
  147. },
  148. created() {
  149. this.getList();
  150. },
  151. methods: {
  152. /** 查询故障案例查看次数管理列表 */
  153. getList() {
  154. this.loading = true;
  155. listCount(this.queryParams).then(response => {
  156. this.countList = response.rows;
  157. this.total = response.total;
  158. this.loading = false;
  159. });
  160. },
  161. // 取消按钮
  162. cancel() {
  163. this.open = false;
  164. this.reset();
  165. },
  166. // 表单重置
  167. reset() {
  168. this.form = {
  169. id: null,
  170. faultCaseId: null,
  171. viewCount: null,
  172. createBy: null,
  173. createTime: null,
  174. updateBy: null,
  175. updateTime: null
  176. };
  177. this.resetForm("form");
  178. },
  179. /** 搜索按钮操作 */
  180. handleQuery() {
  181. this.queryParams.pageNum = 1;
  182. this.getList();
  183. },
  184. /** 重置按钮操作 */
  185. resetQuery() {
  186. this.resetForm("queryForm");
  187. this.handleQuery();
  188. },
  189. // 多选框选中数据
  190. handleSelectionChange(selection) {
  191. this.ids = selection.map(item => item.id)
  192. this.single = selection.length!==1
  193. this.multiple = !selection.length
  194. },
  195. /** 新增按钮操作 */
  196. handleAdd() {
  197. this.reset();
  198. this.open = true;
  199. this.title = "添加故障案例查看次数管理";
  200. },
  201. /** 修改按钮操作 */
  202. handleUpdate(row) {
  203. this.reset();
  204. const id = row.id || this.ids
  205. getCount(id).then(response => {
  206. this.form = response.data;
  207. this.open = true;
  208. this.title = "修改故障案例查看次数管理";
  209. });
  210. },
  211. /** 提交按钮 */
  212. submitForm() {
  213. this.$refs["form"].validate(valid => {
  214. if (valid) {
  215. if (this.form.id != null) {
  216. updateCount(this.form).then(response => {
  217. this.$modal.msgSuccess("修改成功");
  218. this.open = false;
  219. this.getList();
  220. });
  221. } else {
  222. addCount(this.form).then(response => {
  223. this.$modal.msgSuccess("新增成功");
  224. this.open = false;
  225. this.getList();
  226. });
  227. }
  228. }
  229. });
  230. },
  231. /** 删除按钮操作 */
  232. handleDelete(row) {
  233. const ids = row.id || this.ids;
  234. this.$modal.confirm('是否确认删除故障案例查看次数管理编号为"' + ids + '"的数据项?').then(function() {
  235. return delCount(ids);
  236. }).then(() => {
  237. this.getList();
  238. this.$modal.msgSuccess("删除成功");
  239. }).catch(() => {});
  240. },
  241. /** 导出按钮操作 */
  242. handleExport() {
  243. this.download('system/count/export', {
  244. ...this.queryParams
  245. }, `count_${new Date().getTime()}.xlsx`)
  246. }
  247. }
  248. };
  249. </script>