index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10">
  4. <!--机构数据-->
  5. <!-- <el-col :span="4" :xs="24">
  6. <org-tree
  7. v-model="queryParams.orgId"
  8. @defaultOrg="getDefaultOrg"
  9. @checkChange="checkChange"
  10. @click="clickTreeNode"
  11. ></org-tree>
  12. </el-col> -->
  13. <el-col :span="24" :xs="24">
  14. <div class="main-right-box">
  15. <!-- 搜索条件 -->
  16. <div class="main-search-box">
  17. <el-form
  18. :model="queryParams"
  19. ref="search"
  20. size="small"
  21. :inline="true"
  22. v-show="showSearch"
  23. >
  24. <el-form-item label="所属机构">
  25. <org-tree
  26. v-model="queryParams.orgId"
  27. @defaultOrg="getDefaultOrg"
  28. @checkChange="checkChange"
  29. @click="clickTreeNode"
  30. ref="orgTree"
  31. ></org-tree>
  32. </el-form-item>
  33. <el-form-item prop="key" label="报警控制器名称">
  34. <el-input
  35. v-model="queryParams.key"
  36. :maxlength="50"
  37. placeholder="请输入报警控制器名称"
  38. clearable
  39. />
  40. </el-form-item>
  41. <el-form-item prop="status" label="报警控制器状态">
  42. <el-select
  43. label="报警控制器状态"
  44. v-model="queryParams.status"
  45. placeholder="请选择报警控制器状态"
  46. clearable
  47. >
  48. <el-option
  49. v-for="dict in dict.type.protection_status"
  50. :key="dict.value"
  51. :label="dict.label"
  52. :value="dict.value"
  53. />
  54. </el-select>
  55. </el-form-item>
  56. <el-form-item prop="dateRange" label="布撤防登记时间">
  57. <DataRangePicker
  58. v-model="queryParams.dateRange"
  59. key="daterange"
  60. type="daterange"
  61. range-separator="至"
  62. start-placeholder="开始日期"
  63. end-placeholder="结束日期"
  64. >
  65. </DataRangePicker>
  66. </el-form-item>
  67. </el-form>
  68. <!-- 按纽 -->
  69. <el-row :gutter="10">
  70. <el-col :span="1.5">
  71. <el-button
  72. type="primary"
  73. icon="el-icon-search"
  74. size="mini"
  75. @click="getList"
  76. v-hasPermi="['device:protection']"
  77. >搜索</el-button
  78. >
  79. <el-button
  80. type="primary"
  81. icon="el-icon-refresh"
  82. size="mini"
  83. @click="resetQuery"
  84. >重置</el-button
  85. >
  86. <!-- <el-button
  87. type="primary"
  88. icon="el-icon-plus"
  89. size="mini"
  90. @click="handleAdd()"
  91. v-hasPermi="['device:protection:add']"
  92. >新增</el-button
  93. > -->
  94. <el-button
  95. type="primary"
  96. icon="el-icon-download"
  97. size="mini"
  98. @click="handleExport()"
  99. v-hasPermi="['device:protection']"
  100. >导出数据</el-button
  101. >
  102. </el-col>
  103. <right-toolbar
  104. :showSearch.sync="showSearch"
  105. @queryTable="getList"
  106. ></right-toolbar>
  107. </el-row>
  108. </div>
  109. <el-table
  110. size="small"
  111. border
  112. v-loading="loading"
  113. :data="pageData"
  114. @selection-change="handleSelectionChange"
  115. height="594"
  116. >
  117. <el-table-column
  118. align="center"
  119. type="index"
  120. label="序号"
  121. width="60"
  122. v-if="columns[0].visible"
  123. >
  124. <template slot-scope="scope">
  125. {{
  126. (queryParams.pageNum - 1) * queryParams.pageSize +
  127. scope.$index +
  128. 1
  129. }}
  130. </template>
  131. </el-table-column>
  132. <el-table-column
  133. align="center"
  134. prop="orgName"
  135. label="所属机构"
  136. v-if="columns[1].visible"
  137. ></el-table-column>
  138. <el-table-column
  139. align="center"
  140. prop="name"
  141. label="报警控制器名称"
  142. show-overflow-tooltip
  143. v-if="columns[2].visible"
  144. >
  145. </el-table-column>
  146. <el-table-column
  147. align="center"
  148. prop="status"
  149. label="报警控制器状态"
  150. width="150"
  151. v-if="columns[3].visible"
  152. >
  153. <template slot-scope="r"
  154. >{{
  155. getLabel(dict.type.protection_status, r.row.status, "未知")
  156. }}
  157. </template>
  158. </el-table-column>
  159. <el-table-column
  160. align="center"
  161. prop="statusUpdatorName"
  162. label="登记人/数据来源"
  163. show-overflow-tooltip
  164. width="150"
  165. v-if="columns[4].visible"
  166. >
  167. </el-table-column>
  168. <el-table-column
  169. align="center"
  170. prop="statusUpdateTime"
  171. label="最近登记时间"
  172. width="150"
  173. v-if="columns[5].visible"
  174. >
  175. </el-table-column>
  176. <el-table-column
  177. align="center"
  178. prop="statusUpdateTime"
  179. label="布撤防登记时间"
  180. width="150"
  181. v-if="columns[5].visible"
  182. >
  183. </el-table-column>
  184. <el-table-column align="center" label="操作">
  185. <template slot-scope="r">
  186. <!-- <el-button
  187. size="mini"
  188. type="text"
  189. icon="el-icon-edit-outline"
  190. @click="updateStatus(r.row.id, 1)"
  191. v-hasPermi="['device:protectionstatus:maintain']"
  192. >布防</el-button
  193. >
  194. <el-button
  195. size="mini"
  196. type="text"
  197. icon="el-icon-edit-outline"
  198. @click="updateStatus(r.row.id, 0)"
  199. v-hasPermi="['device:protectionstatus:maintain']"
  200. >撤防</el-button
  201. > -->
  202. <!-- <el-button
  203. size="mini"
  204. type="text"
  205. icon="el-icon-edit-outline"
  206. @click="onEdit(r.row.id)"
  207. v-hasPermi="['device:protection:edit']"
  208. >编辑</el-button
  209. > -->
  210. <el-button
  211. size="mini"
  212. type="text"
  213. icon="el-icon-document-copy"
  214. @click="onHistory(r.row)"
  215. v-hasPermi="['device:protection']"
  216. >布撤防历史</el-button
  217. >
  218. <!-- <el-popconfirm
  219. @confirm="onDel(r.row.id)"
  220. title="点击确定删除报警控制器"
  221. >
  222. <el-button
  223. size="mini"
  224. type="text"
  225. icon="el-icon-delete"
  226. v-hasPermi="['device:protection:remove']"
  227. slot="reference"
  228. >删除</el-button
  229. >
  230. </el-popconfirm> -->
  231. </template>
  232. </el-table-column>
  233. </el-table>
  234. <pagination
  235. v-show="total > 0"
  236. :total="total"
  237. :page.sync="queryParams.pageNum"
  238. :limit.sync="queryParams.pageSize"
  239. @pagination="getList"
  240. />
  241. </div>
  242. </el-col>
  243. </el-row>
  244. <dialog-edit
  245. ref="editDialog"
  246. @success="getList()"
  247. :orgTypeOptions="dict.type.sys_org_type"
  248. :ruleTypeOptions="dict.type.rule_type"
  249. ></dialog-edit>
  250. <dialog-history
  251. ref="historyDialog"
  252. :statusDict="dict.type.protection_status"
  253. ></dialog-history>
  254. </div>
  255. </template>
  256. <script>
  257. // import OrgTree from "@/components/orgTree";
  258. import OrgTree from "@/components/orgTree/orgQuerySelector.vue";
  259. import DialogEdit from "./dialog.edit";
  260. import DialogHistory from "./dialog.history";
  261. import * as api from "@/api/resumption/protection";
  262. import { getLabel } from "@/views/commonOption.js";
  263. import { mapGetters } from "vuex";
  264. import dayjs from "dayjs";
  265. import DataRangePicker from "@/components/dateTime/daterange.picker.vue";
  266. export default {
  267. name: "protection",
  268. dicts: ["protection_status"],
  269. components: {
  270. DialogEdit,
  271. OrgTree,
  272. DialogHistory,
  273. DataRangePicker,
  274. },
  275. data() {
  276. const { params, query } = this.$route;
  277. return {
  278. isShow: false,
  279. loading: false,
  280. ids: [],
  281. // 非单个禁用
  282. single: true,
  283. // 非多个禁用
  284. multiple: true,
  285. // 显示搜索条件
  286. showSearch: true,
  287. total: 0,
  288. selectedOrgName: null,
  289. queryParams: {
  290. orgId: null,
  291. checkSub: true,
  292. key: null,
  293. status: null,
  294. dateRange: null,
  295. pageNum: 1,
  296. pageSize: 10,
  297. ...query,
  298. },
  299. pageData: [],
  300. // 列信息
  301. columns: [
  302. { key: 0, label: `序号`, visible: true },
  303. { key: 1, label: `所属机构`, visible: true },
  304. { key: 2, label: `报警控制器名称`, visible: true },
  305. { key: 3, label: `报警控制器状态`, visible: true },
  306. { key: 4, label: `登记人`, visible: true },
  307. { key: 5, label: `最近登记时间`, visible: true },
  308. ],
  309. };
  310. },
  311. props: {},
  312. watch: {},
  313. computed: {
  314. ...mapGetters(["orgId", "orgName"]),
  315. },
  316. methods: {
  317. getLabel,
  318. getList() {
  319. this.loading = true;
  320. this.pageData = [];
  321. api
  322. .list(this.queryParams)
  323. .then((response) => {
  324. this.pageData = response.rows;
  325. this.total = response.total;
  326. this.loading = false;
  327. })
  328. .catch(() => {
  329. this.loading = false;
  330. });
  331. },
  332. handleAdd(id, other = {}) {
  333. this.$refs.editDialog.show(id, other);
  334. },
  335. handleExport() {
  336. if (this.total == 0) {
  337. this.$message.error({
  338. message: `无可用数据导出!`,
  339. type: "error",
  340. duration: 2000,
  341. });
  342. return;
  343. }
  344. this.download(
  345. "/core/resumption/protection/export",
  346. {
  347. ...this.queryParams,
  348. },
  349. `${this.selectedOrgName}-布撤防情况跟踪-${dayjs(new Date()).format(
  350. "YYYYMMDD"
  351. )}.xlsx`
  352. );
  353. },
  354. onEdit(id, other = {}) {
  355. this.$refs.editDialog.show(id, other);
  356. },
  357. onHistory(row) {
  358. this.$refs.historyDialog.show(row);
  359. },
  360. async onDel(id) {
  361. let b = (await api.del(id)).data;
  362. if (b) {
  363. this.$message.info("删除成功");
  364. }
  365. this.getList();
  366. },
  367. updateStatus(id, status) {
  368. api.updateStatus(id, status).then((r) => {
  369. this.$message.info("更新状态成功");
  370. this.getList();
  371. });
  372. },
  373. // 多选框选中数据
  374. handleSelectionChange(selection) {
  375. this.ids = selection.map((item) => item.userId);
  376. this.single = selection.length != 1;
  377. this.multiple = !selection.length;
  378. },
  379. /** 重置按钮操作 */
  380. resetQuery() {
  381. this.resetForm("search");
  382. this.queryParams.dateRange = null;
  383. this.queryParams.orgId = this.orgId;
  384. this.selectedOrgName = this.orgName;
  385. this.queryParams.checkSub = true;
  386. this.$refs["orgTree"].setCheckSub(this.queryParams.checkSub);
  387. // this.queryParams.orgId = undefined;
  388. // this.$refs.tree.setCurrentKey(null);
  389. this.getList();
  390. },
  391. //单选框状态改变
  392. checkChange(state) {
  393. this.queryParams.checkSub = state;
  394. this.getList();
  395. },
  396. getDefaultOrg(node) {
  397. this.queryParams.orgId = node.id;
  398. this.selectedOrgName = node.shortName;
  399. this.getList();
  400. },
  401. // 节点单击事件
  402. clickTreeNode(data) {
  403. this.queryParams.orgId = data.id;
  404. this.selectedOrgName = data.shortName;
  405. this.getList();
  406. },
  407. },
  408. mounted() {},
  409. };
  410. </script>
  411. <style lang="scss" scoped>
  412. /* .search_key{
  413. ::v-deep .el-form-item__label{
  414. width:60px !important;
  415. }
  416. } */
  417. </style>