index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索工作栏 -->
  4. <el-form
  5. :model="queryParams"
  6. ref="queryForm"
  7. size="small"
  8. :inline="true"
  9. v-show="showSearch"
  10. label-width="68px"
  11. >
  12. <el-form-item label="大队id" prop="deptid">
  13. <el-select
  14. v-model="queryParams.deptid"
  15. clearable
  16. placeholder="请选择消防大队"
  17. >
  18. <el-option
  19. :label="item.deptName"
  20. :value="item.id"
  21. v-for="item in deptData"
  22. :key="item.id"
  23. ></el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item>
  27. <el-button type="primary" icon="el-icon-search" @click="handleQuery"
  28. >搜索</el-button
  29. >
  30. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  31. </el-form-item>
  32. </el-form>
  33. <!-- 操作工具栏 -->
  34. <el-row :gutter="10" class="mb8">
  35. <el-col :span="1.5">
  36. <el-button
  37. type="primary"
  38. plain
  39. icon="el-icon-plus"
  40. size="mini"
  41. @click="handleAdd"
  42. v-hasPermi="['backend:actdate-tongji:create']"
  43. >新增</el-button
  44. >
  45. </el-col>
  46. <el-col :span="1.5">
  47. <el-button
  48. type="warning"
  49. plain
  50. icon="el-icon-download"
  51. size="mini"
  52. @click="handleExport"
  53. :loading="exportLoading"
  54. v-hasPermi="['backend:actdate-tongji:export']"
  55. >导出</el-button
  56. >
  57. </el-col>
  58. <right-toolbar
  59. :showSearch.sync="showSearch"
  60. @queryTable="getList"
  61. ></right-toolbar>
  62. </el-row>
  63. <!-- 列表 -->
  64. <el-table v-loading="loading" :data="list">
  65. <el-table-column label="id" align="center" prop="id" />
  66. <el-table-column label="消防大队" align="center" prop="deptid">
  67. <template v-slot="scope">
  68. {{ deptList(scope.row.deptid) }}
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="统计日期" align="center" prop="actdate" />
  72. <el-table-column label="活跃单位数" align="center" prop="actorgs" />
  73. <el-table-column
  74. label="操作"
  75. align="center"
  76. class-name="small-padding fixed-width"
  77. >
  78. <template v-slot="scope">
  79. <el-button
  80. size="mini"
  81. type="text"
  82. icon="el-icon-edit"
  83. @click="handleUpdate(scope.row)"
  84. v-hasPermi="['backend:actdate-tongji:update']"
  85. >修改</el-button
  86. >
  87. <el-button
  88. size="mini"
  89. type="text"
  90. icon="el-icon-delete"
  91. @click="handleDelete(scope.row)"
  92. v-hasPermi="['backend:actdate-tongji:delete']"
  93. >删除</el-button
  94. >
  95. </template>
  96. </el-table-column>
  97. </el-table>
  98. <!-- 分页组件 -->
  99. <pagination
  100. v-show="total > 0"
  101. :total="total"
  102. :page.sync="queryParams.pageNo"
  103. :limit.sync="queryParams.pageSize"
  104. @pagination="getList"
  105. />
  106. <!-- 对话框(添加 / 修改) -->
  107. <el-dialog
  108. :title="title"
  109. :visible.sync="open"
  110. width="500px"
  111. v-dialogDrag
  112. append-to-body
  113. >
  114. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  115. <el-form-item label="消防大队" prop="deptid">
  116. <el-select v-model="form.deptid" placeholder="请选择消防大队">
  117. <el-option
  118. :label="item.deptName"
  119. :value="item.id"
  120. v-for="item in deptData"
  121. :key="item.id"
  122. ></el-option>
  123. </el-select>
  124. </el-form-item>
  125. <el-form-item label="统计日期" prop="actdate">
  126. <el-date-picker
  127. clearable
  128. v-model="form.actdate"
  129. type="date"
  130. value-format="timestamp"
  131. placeholder="选择统计日期"
  132. />
  133. </el-form-item>
  134. <el-form-item label="活跃单位数" prop="actorgs">
  135. <el-input v-model="form.actorgs" placeholder="请输入活跃单位数" />
  136. </el-form-item>
  137. </el-form>
  138. <div slot="footer" class="dialog-footer">
  139. <el-button type="primary" @click="submitForm">确 定</el-button>
  140. <el-button @click="cancel">取 消</el-button>
  141. </div>
  142. </el-dialog>
  143. </div>
  144. </template>
  145. <script>
  146. import {
  147. createActdateTongji,
  148. updateActdateTongji,
  149. deleteActdateTongji,
  150. getActdateTongji,
  151. getActdateTongjiPage,
  152. exportActdateTongjiExcel,
  153. } from "@/api/backend/actdateTongji";
  154. import { getDdlist } from "@/api/backend/statistics";
  155. export default {
  156. name: "ActdateTongji",
  157. components: {},
  158. data() {
  159. return {
  160. // 遮罩层
  161. loading: true,
  162. // 导出遮罩层
  163. exportLoading: false,
  164. // 显示搜索条件
  165. showSearch: true,
  166. // 总条数
  167. total: 0,
  168. // 各大队每日活跃数统计列表
  169. list: [],
  170. // 弹出层标题
  171. title: "",
  172. // 是否显示弹出层
  173. open: false,
  174. // 查询参数
  175. queryParams: {
  176. pageNo: 1,
  177. pageSize: 10,
  178. deptid: null,
  179. },
  180. // 表单参数
  181. form: {},
  182. // 表单校验
  183. rules: {
  184. deptid: [
  185. { required: true, message: "大队id不能为空", trigger: "change" },
  186. ],
  187. },
  188. deptData: [],
  189. };
  190. },
  191. created() {
  192. this.getList();
  193. this.getDeptData();
  194. },
  195. methods: {
  196. /** 查询列表 */
  197. getList() {
  198. this.loading = true;
  199. // 执行查询
  200. getActdateTongjiPage(this.queryParams).then((response) => {
  201. this.list = response.data.list;
  202. this.total = response.data.total;
  203. this.loading = false;
  204. });
  205. },
  206. /** 获取消防大队下拉框数据 */
  207. getDeptData() {
  208. getDdlist().then((res) => {
  209. this.deptData = res.data;
  210. });
  211. },
  212. /** 列表消防大队转换 id2name*/
  213. deptList(id) {
  214. let thisDept;
  215. const arr = JSON.parse(JSON.stringify(this.deptData));
  216. arr.forEach((item) => {
  217. if (item.id == id) {
  218. thisDept = item;
  219. }
  220. });
  221. if (thisDept) {
  222. return thisDept.deptName;
  223. } else {
  224. return "";
  225. }
  226. },
  227. /** 取消按钮 */
  228. cancel() {
  229. this.open = false;
  230. this.reset();
  231. },
  232. /** 表单重置 */
  233. reset() {
  234. this.form = {
  235. id: undefined,
  236. deptid: undefined,
  237. actdate: undefined,
  238. actorgs: undefined,
  239. };
  240. this.resetForm("form");
  241. },
  242. /** 搜索按钮操作 */
  243. handleQuery() {
  244. this.queryParams.pageNo = 1;
  245. this.getList();
  246. },
  247. /** 重置按钮操作 */
  248. resetQuery() {
  249. this.resetForm("queryForm");
  250. this.handleQuery();
  251. },
  252. /** 新增按钮操作 */
  253. handleAdd() {
  254. this.reset();
  255. this.open = true;
  256. this.title = "添加各大队每日活跃数统计";
  257. },
  258. /** 修改按钮操作 */
  259. handleUpdate(row) {
  260. this.reset();
  261. const id = row.id;
  262. getActdateTongji(id).then((response) => {
  263. this.form = response.data;
  264. this.open = true;
  265. this.title = "修改各大队每日活跃数统计";
  266. });
  267. },
  268. /** 提交按钮 */
  269. submitForm() {
  270. this.$refs["form"].validate((valid) => {
  271. if (!valid) {
  272. return;
  273. }
  274. // 修改的提交
  275. if (this.form.id != null) {
  276. updateActdateTongji(this.form).then((response) => {
  277. this.$modal.msgSuccess("修改成功");
  278. this.open = false;
  279. this.getList();
  280. });
  281. return;
  282. }
  283. // 添加的提交
  284. createActdateTongji(this.form).then((response) => {
  285. this.$modal.msgSuccess("新增成功");
  286. this.open = false;
  287. this.getList();
  288. });
  289. });
  290. },
  291. /** 删除按钮操作 */
  292. handleDelete(row) {
  293. const id = row.id;
  294. this.$modal
  295. .confirm('是否确认删除各大队每日活跃数统计编号为"' + id + '"的数据项?')
  296. .then(function () {
  297. return deleteActdateTongji(id);
  298. })
  299. .then(() => {
  300. this.getList();
  301. this.$modal.msgSuccess("删除成功");
  302. })
  303. .catch(() => {});
  304. },
  305. /** 导出按钮操作 */
  306. handleExport() {
  307. // 处理查询参数
  308. let params = { ...this.queryParams };
  309. params.pageNo = undefined;
  310. params.pageSize = undefined;
  311. this.$modal
  312. .confirm("是否确认导出所有各大队每日活跃数统计数据项?")
  313. .then(() => {
  314. this.exportLoading = true;
  315. return exportActdateTongjiExcel(params);
  316. })
  317. .then((response) => {
  318. this.$download.excel(response, "各大队每日活跃数统计.xls");
  319. this.exportLoading = false;
  320. })
  321. .catch(() => {});
  322. },
  323. },
  324. };
  325. </script>