index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索工作栏 -->
  4. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  5. <el-form-item label="监督员名称" prop="watcher">
  6. <el-input v-model="queryParams.watcher" placeholder="请输入监督员名称" clearable @keyup.enter.native="handleQuery"/>
  7. </el-form-item>
  8. <el-form-item label="质态" prop="quality">
  9. <el-input v-model="queryParams.quality" placeholder="请输入质态" clearable @keyup.enter.native="handleQuery"/>
  10. </el-form-item>
  11. <el-form-item label="负责单位数" prop="servorg">
  12. <el-input v-model="queryParams.servorg" placeholder="请输入负责单位数" clearable @keyup.enter.native="handleQuery"/>
  13. </el-form-item>
  14. <el-form-item>
  15. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  16. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  17. </el-form-item>
  18. </el-form>
  19. <!-- 操作工具栏 -->
  20. <el-row :gutter="10" class="mb8">
  21. <el-col :span="1.5">
  22. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  23. v-hasPermi="['backend:watcher:create']">新增</el-button>
  24. </el-col>
  25. <el-col :span="1.5">
  26. <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
  27. v-hasPermi="['backend:watcher:export']">导出</el-button>
  28. </el-col>
  29. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  30. </el-row>
  31. <!-- 列表 -->
  32. <el-table v-loading="loading" :data="list">
  33. <el-table-column label="id" align="center" prop="id" />
  34. <el-table-column label="监督员名称" align="center" prop="watcher" />
  35. <el-table-column label="质态" align="center" prop="quality" />
  36. <el-table-column label="负责单位数" align="center" prop="servorg" />
  37. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  38. <template v-slot="scope">
  39. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
  40. v-hasPermi="['backend:watcher:update']">修改</el-button>
  41. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  42. v-hasPermi="['backend:watcher:delete']">删除</el-button>
  43. </template>
  44. </el-table-column>
  45. </el-table>
  46. <!-- 分页组件 -->
  47. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  48. @pagination="getList"/>
  49. <!-- 对话框(添加 / 修改) -->
  50. <el-dialog :title="title" :visible.sync="open" width="500px" v-dialogDrag append-to-body>
  51. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  52. <el-form-item label="监督员名称" prop="watcher">
  53. <el-input v-model="form.watcher" placeholder="请输入监督员名称" />
  54. </el-form-item>
  55. <el-form-item label="质态" prop="quality">
  56. <el-input v-model="form.quality" placeholder="请输入质态" />
  57. </el-form-item>
  58. <el-form-item label="负责单位数" prop="servorg">
  59. <el-input v-model="form.servorg" placeholder="请输入负责单位数" />
  60. </el-form-item>
  61. </el-form>
  62. <div slot="footer" class="dialog-footer">
  63. <el-button type="primary" @click="submitForm">确 定</el-button>
  64. <el-button @click="cancel">取 消</el-button>
  65. </div>
  66. </el-dialog>
  67. </div>
  68. </template>
  69. <script>
  70. import { createWatcher, updateWatcher, deleteWatcher, getWatcher, getWatcherPage, exportWatcherExcel } from "@/api/backend/watcher";
  71. export default {
  72. name: "Watcher",
  73. components: {
  74. },
  75. data() {
  76. return {
  77. // 遮罩层
  78. loading: true,
  79. // 导出遮罩层
  80. exportLoading: false,
  81. // 显示搜索条件
  82. showSearch: true,
  83. // 总条数
  84. total: 0,
  85. // 监督员质态统计列表
  86. list: [],
  87. // 弹出层标题
  88. title: "",
  89. // 是否显示弹出层
  90. open: false,
  91. // 查询参数
  92. queryParams: {
  93. pageNo: 1,
  94. pageSize: 10,
  95. watcher: null,
  96. quality: null,
  97. servorg: null,
  98. },
  99. // 表单参数
  100. form: {},
  101. // 表单校验
  102. rules: {
  103. }
  104. };
  105. },
  106. created() {
  107. this.getList();
  108. },
  109. methods: {
  110. /** 查询列表 */
  111. getList() {
  112. this.loading = true;
  113. // 执行查询
  114. getWatcherPage(this.queryParams).then(response => {
  115. this.list = response.data.list;
  116. this.total = response.data.total;
  117. this.loading = false;
  118. });
  119. },
  120. /** 取消按钮 */
  121. cancel() {
  122. this.open = false;
  123. this.reset();
  124. },
  125. /** 表单重置 */
  126. reset() {
  127. this.form = {
  128. id: undefined,
  129. watcher: undefined,
  130. quality: undefined,
  131. servorg: undefined,
  132. };
  133. this.resetForm("form");
  134. },
  135. /** 搜索按钮操作 */
  136. handleQuery() {
  137. this.queryParams.pageNo = 1;
  138. this.getList();
  139. },
  140. /** 重置按钮操作 */
  141. resetQuery() {
  142. this.resetForm("queryForm");
  143. this.handleQuery();
  144. },
  145. /** 新增按钮操作 */
  146. handleAdd() {
  147. this.reset();
  148. this.open = true;
  149. this.title = "添加监督员质态统计";
  150. },
  151. /** 修改按钮操作 */
  152. handleUpdate(row) {
  153. this.reset();
  154. const id = row.id;
  155. getWatcher(id).then(response => {
  156. this.form = response.data;
  157. this.open = true;
  158. this.title = "修改监督员质态统计";
  159. });
  160. },
  161. /** 提交按钮 */
  162. submitForm() {
  163. this.$refs["form"].validate(valid => {
  164. if (!valid) {
  165. return;
  166. }
  167. // 修改的提交
  168. if (this.form.id != null) {
  169. updateWatcher(this.form).then(response => {
  170. this.$modal.msgSuccess("修改成功");
  171. this.open = false;
  172. this.getList();
  173. });
  174. return;
  175. }
  176. // 添加的提交
  177. createWatcher(this.form).then(response => {
  178. this.$modal.msgSuccess("新增成功");
  179. this.open = false;
  180. this.getList();
  181. });
  182. });
  183. },
  184. /** 删除按钮操作 */
  185. handleDelete(row) {
  186. const id = row.id;
  187. this.$modal.confirm('是否确认删除监督员质态统计编号为"' + id + '"的数据项?').then(function() {
  188. return deleteWatcher(id);
  189. }).then(() => {
  190. this.getList();
  191. this.$modal.msgSuccess("删除成功");
  192. }).catch(() => {});
  193. },
  194. /** 导出按钮操作 */
  195. handleExport() {
  196. // 处理查询参数
  197. let params = {...this.queryParams};
  198. params.pageNo = undefined;
  199. params.pageSize = undefined;
  200. this.$modal.confirm('是否确认导出所有监督员质态统计数据项?').then(() => {
  201. this.exportLoading = true;
  202. return exportWatcherExcel(params);
  203. }).then(response => {
  204. this.$download.excel(response, '监督员质态统计.xls');
  205. this.exportLoading = false;
  206. }).catch(() => {});
  207. }
  208. }
  209. };
  210. </script>