index_20220322161313.vue 8.7 KB

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